Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/world_entities/environments/model_entity.cc @ 9505

Last change on this file since 9505 was 9406, checked in by bensch, 18 years ago

orxonox/trunk: merged the proxy back

merged with commandsvn merge -r9346:HEAD https://svn.orxonox.net/orxonox/branches/proxy .

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  if (root != NULL)
40    this->loadParams(root);
41}
42
43
44/**
45 *  default destructor
46*/
47ModelEntity::~ModelEntity()
48{
49  if (this->speed != NULL)
50    delete this->speed;
51  if (this->momentum)
52    delete this->momentum;
53}
54
55void ModelEntity::loadParams(const TiXmlElement* root)
56{
57  WorldEntity::loadParams(root);
58
59  LoadParam(root, "speed", this, ModelEntity, setSpeed);
60  LoadParam(root, "momentum", this, ModelEntity, setMomentum);
61}
62
63
64void ModelEntity::setSpeed(float x, float y, float z)
65{
66  if (this->speed == NULL)
67    this->speed = new Vector;
68  *this->speed = Vector(x,y,z);
69}
70
71void ModelEntity::setMomentum (float angle, float x, float y, float z)
72{
73  Vector v(x,y,z);
74  v.debug();
75  v.normalize();
76  v.debug();
77
78  if (this->momentum == NULL)
79    this->momentum = new Quaternion;
80  *this->momentum = Quaternion(angle, v);
81
82  this->momentum->debug();
83}
84
85void ModelEntity::tick(float dt)
86{
87  if (this->speed != NULL)
88    this->shiftCoor(*this->speed * dt);
89
90  if (this->momentum != NULL)
91  {
92    this->shiftDir((*this->momentum * dt ).getNormalized());
93    //this->getAbsDir().debug();
94  }
95}
Note: See TracBrowser for help on using the repository browser.