Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/weapons/ground_turret.cc @ 6233

Last change on this file since 6233 was 6142, checked in by bensch, 19 years ago

orxonox/trunk: merge the ObjectManager to the trunk
merged with command:
svn merge -r6082:HEAD objectmanager/ ../trunk/

conflicts resolution was easy this time :)
but specially merged the world to network_world

File size: 3.3 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: Manuel Leuenberger
13   co-programmer: ...
14*/
15
16#include "ground_turret.h"
17#include "model.h"
18#include "turret.h"
19
20#include "factory.h"
21#include "load_param.h"
22
23CREATE_FACTORY(GroundTurret, CL_GROUND_TURRET);
24
25using namespace std;
26
27
28/**
29 * constructs and loads a GroundTurret from a XML-element
30 * @param root the XML-element to load from
31 */
32GroundTurret::GroundTurret(const TiXmlElement* root)
33{
34  this->init();
35  if (root != NULL)
36    this->loadParams(root);
37}
38
39
40/**
41 * standard deconstructor
42 */
43GroundTurret::~GroundTurret ()
44{
45
46}
47
48
49/**
50 * initializes the GroundTurret
51 * @todo change this to what you wish
52 */
53void GroundTurret::init()
54{
55  this->setClassID(CL_GROUND_TURRET, "GroundTurret");
56  this->loadModel("models/ground_turret.obj", 5);
57  this->left = NULL;
58  this->right = NULL;
59
60  /*  left = new Turret();
61  left->setParent(this);
62  left->setRelCoor(0,10,0);
63  right = new Turret();
64  right->setParent(this);
65  right->setRelCoor(0,10,0);*/
66}
67
68
69/**
70 * loads a GroundTurret from a XML-element
71 * @param root the XML-element to load from
72 * @todo make the class Loadable
73 */
74void GroundTurret::loadParams(const TiXmlElement* root)
75{
76  // all the clases this Entity is directly derived from must be called in this way, to load all settings.
77  static_cast<NPC*>(this)->loadParams(root);
78
79
80  /**
81   * @todo: make the class Loadable
82   */
83  const TiXmlElement* element;
84
85  element = root->FirstChildElement("weapon-left");
86  if (element != NULL) element = element->FirstChildElement();
87  this->left = dynamic_cast<Weapon*>( Factory::fabricate( element) );
88  if (this->left)
89  {
90    this->left->setParent(this);
91    this->left->toList(this->getOMListNumber());
92    this->left->setRelCoor(0,10,-5);
93  }
94
95  element = root->FirstChildElement("weapon-right");
96  if (element != NULL)  if (element != NULL) element = element->FirstChildElement();
97  this->right = dynamic_cast<Weapon*>( Factory::fabricate( element) );
98  if (this->right)
99  {
100    this->right->setParent(this);
101    this->right->toList(this->getOMListNumber());
102    this->right->setRelCoor(0,10,5);
103  }
104}
105
106/**
107 * advances the GroundTurret about time seconds
108 * @param time the Time to step
109 */
110void GroundTurret::tick(float time)
111{
112
113}
114
115/**
116 * draws this worldEntity
117 */
118void GroundTurret::draw () const
119{
120  glMatrixMode(GL_MODELVIEW);
121  glPushMatrix();
122  float matrix[4][4];
123
124  /* translate */
125  glTranslatef (this->getAbsCoor ().x,
126                this->getAbsCoor ().y,
127                this->getAbsCoor ().z);
128  /* rotate */
129  this->getAbsDir().matrix(matrix);
130  glMultMatrixf((float*)matrix);
131
132  if (this->getModel())
133    this->getModel()->draw();
134
135  glPopMatrix();
136  if (this->left != NULL)
137    this->left->draw();
138  if (this->right != NULL)
139    this->right->draw();
140}
141
142
143/**
144 *
145 *
146 */
147void GroundTurret::collidesWith (WorldEntity* entity, const Vector& location)
148{
149  if (entity->isA(CL_PROJECTILE))
150    this->setAbsDirSoft(Quaternion(-90, Vector(0,0,1)), 90);
151}
152
153/**
154 *
155 *
156 */
157void GroundTurret::postSpawn ()
158{
159
160}
161
162/**
163 *
164 *
165 */
166void GroundTurret::leftWorld ()
167{
168
169}
Note: See TracBrowser for help on using the repository browser.