Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 5875 was 5819, checked in by bensch, 19 years ago

orxonox/trunk: merged branches world_entities to trunk again
merged with command
svn merge -r5795:HEAD branches/world_entities/ trunk/
no conflicts (what a wonder)

File size: 3.1 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::getFirst()->fabricate( element) );
88  if (this->left)
89  {
90    this->left->setParent(this);
91    this->left->setRelCoor(0,10,-5);
92  }
93
94  element = root->FirstChildElement("weapon-right");
95  if (element != NULL)  if (element != NULL) element = element->FirstChildElement();
96  this->right = dynamic_cast<Weapon*>( Factory::getFirst()->fabricate( element) );
97  if (this->right)
98  {
99    this->right->setParent(this);
100    this->right->setRelCoor(0,10,5);
101  }
102}
103
104/**
105 * advances the GroundTurret about time seconds
106 * @param time the Time to step
107 */
108void GroundTurret::tick(float time)
109{
110
111}
112
113/**
114 * draws this worldEntity
115 */
116void GroundTurret::draw () const
117{
118  glMatrixMode(GL_MODELVIEW);
119  glPushMatrix();
120  float matrix[4][4];
121
122  /* translate */
123  glTranslatef (this->getAbsCoor ().x,
124                this->getAbsCoor ().y,
125                this->getAbsCoor ().z);
126  /* rotate */
127  this->getAbsDir().matrix(matrix);
128  glMultMatrixf((float*)matrix);
129
130  if (this->model)
131    this->model->draw();
132
133  glPopMatrix();
134  if (this->left != NULL)
135    this->left->draw();
136  if (this->right != NULL)
137    this->right->draw();
138}
139
140
141/**
142 *
143 *
144 */
145void GroundTurret::collidesWith (WorldEntity* entity, const Vector& location)
146{
147
148}
149
150/**
151 *
152 *
153 */
154void GroundTurret::postSpawn ()
155{
156
157}
158
159/**
160 *
161 *
162 */
163void GroundTurret::leftWorld ()
164{
165
166}
Note: See TracBrowser for help on using the repository browser.