Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7287 was 7193, checked in by bensch, 19 years ago

orxonox/trunk: new style for resources (prework/movement)

File size: 1.8 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
23using namespace std;
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_NOTICK);
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  if (this->momentum == NULL)
74    this->momentum = new Quaternion;
75  *this->momentum = Quaternion(angle, Vector(x, y, z));
76}
77
78void ModelEntity::tick(float dt)
79{
80  if (this->speed != NULL)
81    this->shiftCoor(*this->speed * dt);
82
83  if (this->momentum != NULL)
84    this->shiftDir(*this->momentum * dt);
85}
Note: See TracBrowser for help on using the repository browser.