Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/environments/model_entity.cc @ 9842

Last change on this file since 9842 was 9656, checked in by bensch, 18 years ago

orxonox/trunk: merged the proxy bache back with no conflicts

File size: 1.9 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
17
18#include "model_entity.h"
19
20#include "util/loading/load_param.h"
21#include "util/loading/factory.h"
22
23
24
25
26CREATE_FACTORY(ModelEntity, CL_MODEL_ENTITY);
27
28/**
29 *  initializes a skybox from a XmlElement
30*/
31ModelEntity::ModelEntity(const TiXmlElement* root)
32{
33  this->setClassID(CL_MODEL_ENTITY, "ModelEntity");
34  this->toList(OM_ENVIRON);
35
36  this->speed = NULL;
37  this->momentum = NULL;
38
39  this->setSynchronized(true);
40
41  if (root != NULL)
42    this->loadParams(root);
43}
44
45
46/**
47 *  default destructor
48*/
49ModelEntity::~ModelEntity()
50{
51  if (this->speed != NULL)
52    delete this->speed;
53  if (this->momentum)
54    delete this->momentum;
55}
56
57void ModelEntity::loadParams(const TiXmlElement* root)
58{
59  WorldEntity::loadParams(root);
60
61  LoadParam(root, "speed", this, ModelEntity, setSpeed);
62  LoadParam(root, "momentum", this, ModelEntity, setMomentum);
63}
64
65
66void ModelEntity::setSpeed(float x, float y, float z)
67{
68  if (this->speed == NULL)
69    this->speed = new Vector;
70  *this->speed = Vector(x,y,z);
71}
72
73void ModelEntity::setMomentum (float angle, float x, float y, float z)
74{
75  Vector v(x,y,z);
76  v.debug();
77  v.normalize();
78  v.debug();
79
80  if (this->momentum == NULL)
81    this->momentum = new Quaternion;
82  *this->momentum = Quaternion(angle, v);
83
84  this->momentum->debug();
85}
86
87void ModelEntity::tick(float dt)
88{
89  if (this->speed != NULL)
90    this->shiftCoor(*this->speed * dt);
91
92  if (this->momentum != NULL)
93  {
94    this->shiftDir((*this->momentum * dt ).getNormalized());
95    //this->getAbsDir().debug();
96  }
97}
Note: See TracBrowser for help on using the repository browser.