Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/power_ups/power_up.cc @ 6142

Last change on this file since 6142 was 6142, checked in by bensch, 18 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: 2.0 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#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
17
18
19#include "power_up.h"
20#include "extendable.h"
21#include "primitive_model.h"
22
23using namespace std;
24
25Model* PowerUp::sphereModel = NULL;
26
27PowerUp::PowerUp(float r, float g, float b)
28{
29  if(!PowerUp::sphereModel) {
30    PowerUp::sphereModel = new PrimitiveModel(PRIM_SPHERE, 7, 5);
31  }
32  this->sphereMaterial = new Material;
33  this->sphereMaterial->setTransparency(.1);
34  this->sphereMaterial->setDiffuse(r, g, b);
35}
36
37PowerUp::~PowerUp ()
38{
39  delete this->sphereMaterial;
40  this->toList(OM_COMMON);
41}
42
43
44void PowerUp::loadParams(const TiXmlElement* root)
45{
46  static_cast<WorldEntity*>(this)->loadParams(root);
47}
48
49
50void PowerUp::collidesWith (WorldEntity* entity, const Vector& location)
51{
52 if(entity->isA(CL_EXTENDABLE))
53  {
54    if(dynamic_cast<Extendable*>(entity)->pickup(this))
55    {
56      this->setVisibiliy(false);
57    }
58  }
59}
60
61void PowerUp::draw() const
62{
63  WorldEntity::draw();
64
65  glMatrixMode(GL_MODELVIEW);
66  glPushMatrix();
67  float matrix[4][4];
68
69  /* translate */
70  glTranslatef (this->getAbsCoor ().x,
71                this->getAbsCoor ().y,
72                this->getAbsCoor ().z);
73  /* rotate */ // FIXME: devise a new Way to rotate this
74  this->getAbsDir ().matrix (matrix);
75  glMultMatrixf((float*)matrix);
76
77  this->sphereMaterial->select();
78  sphereModel->draw();
79
80  glPopMatrix();
81}
82
83const char* PowerUp::respawnTypes[] = {
84  "none",
85  "time"
86};
87
88void PowerUp::setRespawnType(const char* type)
89{
90  for(int i = 0; i < RESPAWN_size; ++i) {
91    if(strcmp(type, respawnTypes[i]) == 0) {
92      this->respawnType = (PowerUpRespawn)i;
93      break;
94    }
95  }
96}
97
Note: See TracBrowser for help on using the repository browser.