Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6340 was 6282, checked in by bensch, 19 years ago

orxonox/trunk: merged the PowerUps back here

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
25PowerUp::PowerUp(float r, float g, float b)
26{
27  this->respawnType = RESPAWN_NONE;
28/*  if(!PowerUp::sphereModel) {*/
29
30  Model* sphereModel = new PrimitiveModel(PRIM_SPHERE, 7, 5);
31
32  this->setModel(sphereModel);
33  this->buildObbTree( 4);
34  this->sphereMaterial = new Material;
35  this->sphereMaterial->setTransparency(.1);
36  this->sphereMaterial->setDiffuse(r, g, b);
37  this->toList(OM_COMMON);
38}
39
40PowerUp::~PowerUp ()
41{
42  delete this->sphereMaterial;
43}
44
45
46void PowerUp::loadParams(const TiXmlElement* root)
47{
48  static_cast<WorldEntity*>(this)->loadParams(root);
49}
50
51
52void PowerUp::collidesWith (WorldEntity* entity, const Vector& location)
53{
54 if(entity->isA(CL_EXTENDABLE))
55  {
56    if(dynamic_cast<Extendable*>(entity)->pickup(this))
57    {
58      this->toList(OM_DEAD_TICK);
59    }
60  }
61}
62
63void PowerUp::draw() const
64{
65  glMatrixMode(GL_MODELVIEW);
66  glPushMatrix();
67
68  /* translate */
69  glTranslatef (this->getAbsCoor ().x,
70                this->getAbsCoor ().y,
71                this->getAbsCoor ().z);
72  Vector tmpRot = this->getAbsDir().getSpacialAxis();
73  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
74
75   this->sphereMaterial->select();
76   this->getModel(0)->draw();
77
78   glPopMatrix();
79}
80
81const char* PowerUp::respawnTypes[] = {
82  "none",
83  "time"
84};
85
86void PowerUp::setRespawnType(const char* type)
87{
88  for(int i = 0; i < RESPAWN_size; ++i) {
89    if(!strcmp(type, respawnTypes[i])) {
90      this->respawnType = (PowerUpRespawn)i;
91      break;
92    }
93  }
94}
95
Note: See TracBrowser for help on using the repository browser.