/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Manuel Leuenberger co-programmer: ... */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY #include "power_up.h" #include "extendable.h" #include "primitive_model.h" using namespace std; Model* PowerUp::sphereModel = NULL; PowerUp::PowerUp(float r, float g, float b) { if(!PowerUp::sphereModel) { PowerUp::sphereModel = new PrimitiveModel(PRIM_SPHERE, 7, 5); } this->sphereMaterial = new Material; this->sphereMaterial->setTransparency(.1); this->sphereMaterial->setDiffuse(r, g, b); this->toList(OM_COMMON); } PowerUp::~PowerUp () { delete this->sphereMaterial; } void PowerUp::loadParams(const TiXmlElement* root) { static_cast(this)->loadParams(root); } void PowerUp::collidesWith (WorldEntity* entity, const Vector& location) { if(entity->isA(CL_EXTENDABLE)) { if(dynamic_cast(entity)->pickup(this)) { this->setVisibiliy(false); } } } void PowerUp::draw() const { WorldEntity::draw(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); float matrix[4][4]; /* translate */ glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); /* rotate */ // FIXME: devise a new Way to rotate this this->getAbsDir ().matrix (matrix); glMultMatrixf((float*)matrix); this->sphereMaterial->select(); sphereModel->draw(); glPopMatrix(); } const char* PowerUp::respawnTypes[] = { "none", "time" }; void PowerUp::setRespawnType(const char* type) { for(int i = 0; i < RESPAWN_size; ++i) { if(strcmp(type, respawnTypes[i]) == 0) { this->respawnType = (PowerUpRespawn)i; break; } } }