Changeset 9869 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Oct 3, 2006, 12:19:30 AM (18 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 157 edited
- 46 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/Makefile.am
r8994 r9869 21 21 projectiles/projectile.cc \ 22 22 \ 23 extendable.cc \ 23 24 power_ups/power_up.cc \ 24 25 power_ups/param_power_up.cc \ -
trunk/src/world_entities/WorldEntities.am
r9656 r9869 72 72 world_entities/effects/lightning_bolt.cc \ 73 73 \ 74 world_entities/script_trigger.cc 74 world_entities/script_trigger.cc \ 75 \ 76 \ 77 world_entities/particles/particle_emitter.cc \ 78 world_entities/particles/dot_emitter.cc \ 79 world_entities/particles/box_emitter.cc \ 80 world_entities/particles/plane_emitter.cc \ 81 \ 82 world_entities/particles/particle_system.cc \ 83 world_entities/particles/sprite_particles.cc \ 84 world_entities/particles/spark_particles.cc \ 85 world_entities/particles/model_particles.cc \ 86 world_entities/particles/dot_particles.cc \ 87 \ 88 world_entities/particles/quick_animation.cc \ 89 \ 90 \ 91 world_entities/weather_effects/atmospheric_engine.cc \ 92 world_entities/weather_effects/weather_effect.cc \ 93 world_entities/weather_effects/cloud_effect.cc \ 94 world_entities/weather_effects/sun_effect.cc \ 95 world_entities/weather_effects/fog_effect.cc \ 96 world_entities/weather_effects/volfog_effect.cc \ 97 world_entities/weather_effects/rain_effect.cc \ 98 world_entities/weather_effects/snow_effect.cc \ 99 world_entities/weather_effects/lightning_effect.cc \ 100 world_entities/weather_effects/lense_flare.cc 101 102 103 104 75 105 76 106 … … 144 174 effects/lightning_bolt.h \ 145 175 \ 146 script_trigger.h 176 script_trigger.h \ 177 \ 178 \ 179 particles/particle_emitter.h \ 180 particles/dot_emitter.h \ 181 particles/box_emitter.h \ 182 particles/plane_emitter.h \ 183 \ 184 particles/particle_system.h \ 185 particles/sprite_particles.h \ 186 particles/spark_particles.h \ 187 particles/model_particles.h \ 188 particles/dot_particles.h \ 189 \ 190 particles/quick_animation.h \ 191 \ 192 \ 193 weather_effects/atmospheric_engine.h \ 194 weather_effects/weather_effect.h \ 195 weather_effects/sun_effect.h \ 196 weather_effects/fog_effect.h \ 197 weather_effects/volfog_effect.h \ 198 weather_effects/rain_effect.h \ 199 weather_effects/snow_effect.h \ 200 weather_effects/cloud_effect.h \ 201 weather_effects/lightning_effect.h \ 202 weather_effects/lense_flare.h 203 -
trunk/src/world_entities/bsp_entity.cc
r9656 r9869 15 15 16 16 #include "bsp_entity.h" 17 #include "util/loading/resource_manager.h"18 #include "util/loading/resource_manager.h"19 17 20 CREATE_FACTORY(BspEntity, CL_BSP_ENTITY); 18 #include "debug.h" 19 #include "loading/resource_manager.h" 20 21 #include "class_id_DEPRECATED.h" 22 ObjectListDefinitionID(BspEntity, CL_BSP_ENTITY); 23 CREATE_FACTORY(BspEntity); 21 24 22 25 … … 51 54 void BspEntity::init() 52 55 { 56 this->registerObject(this, BspEntity::_objectList); 53 57 54 58 this->bspManager = NULL; … … 67 71 68 72 // Check wether file exists.... 69 if ( File(Resource Manager::getFullName(name)).exists() ) {73 if ( File(Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(name)).exists() ) { 70 74 71 this->setClassID(CL_BSP_ENTITY, "BspEntity");72 75 this->bspManager = new BspManager(this); 73 76 -
trunk/src/world_entities/bsp_entity.h
r9059 r9869 18 18 class BspEntity : public WorldEntity 19 19 { 20 20 ObjectListDeclaration(BspEntity); 21 21 public: 22 22 BspEntity(const TiXmlElement* root = NULL); … … 28 28 29 29 void init(); 30 30 31 31 virtual void varChangeHandler( std::list<int> & id ); 32 32 … … 40 40 private: 41 41 BspManager* bspManager; 42 42 43 43 std::string name; //!< store name 44 44 std::string name_write; //!< temp variable to store name -
trunk/src/world_entities/camera.cc
r9406 r9869 19 19 #include "glincl.h" 20 20 21 ObjectListDefinition(Camera); 22 21 23 /** 22 24 * creates a Camera … … 24 26 Camera::Camera() 25 27 { 26 this-> setClassID(CL_CAMERA, "Camera");28 this->registerObject(this, Camera::_objectList); 27 29 this->setName("camera"); 28 30 this->target = new CameraTarget(); … … 221 223 /////////////////// 222 224 223 225 ObjectListDefinition(CameraTarget); 224 226 CameraTarget::CameraTarget() 225 227 { 226 this-> setClassID(CL_CAMERA_TARGET, "CameraTarget");228 this->registerObject(this, CameraTarget::_objectList); 227 229 // this->setParentMode(PNODE_MOVEMENT); 228 230 } -
trunk/src/world_entities/camera.h
r7347 r9869 22 22 class Camera : public PNode, public EventListener 23 23 { 24 ObjectListDeclaration(Camera); 24 25 public: 25 26 //! an enumerator for different types of view … … 84 85 { 85 86 friend class Camera; //! The CameraTarget is a friend of Camera. noone else needs a CameraTarget, so noone else can create it. 87 ObjectListDeclaration(CameraTarget); 86 88 87 89 private: -
trunk/src/world_entities/character_attributes.cc
r9406 r9869 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 18 18 19 19 #include "character_attributes.h" 20 #include "stdincl.h" 21 22 20 21 22 ObjectListDefinition(CharacterAttributes); 23 23 24 24 … … 27 27 @todo this constructor is not jet implemented - do it 28 28 */ 29 CharacterAttributes::CharacterAttributes () 30 { 31 this->setClassID(CL_CHARACTER_ATTRIBUTES, "CharacterAttributes");29 CharacterAttributes::CharacterAttributes () 30 { 31 this->registerObject(this, CharacterAttributes::_objectList); 32 32 } 33 33 … … 37 37 38 38 */ 39 CharacterAttributes::~CharacterAttributes () 39 CharacterAttributes::~CharacterAttributes () 40 40 { 41 41 } … … 97 97 98 98 /** 99 * sets maximum health 99 * sets maximum health 100 100 * @param health 101 101 … … 130 130 * adds shield strength 131 131 * @param strength 132 132 133 133 there is currently no limit to shieldstrength 134 134 */ … … 290 290 /*=====================energy=====================*/ 291 291 /** 292 * sets the amount of energy 292 * sets the amount of energy 293 293 * @param energy 294 294 */ … … 332 332 333 333 /** 334 * gets the amount of energy 334 * gets the amount of energy 335 335 * @returns energy 336 336 */ … … 358 358 return this->energyConsumption; 359 359 } 360 360 361 361 362 362 /** -
trunk/src/world_entities/character_attributes.h
r5039 r9869 15 15 */ 16 16 class CharacterAttributes : public BaseObject { 17 ObjectListDeclaration(CharacterAttributes); 17 18 18 19 public: -
trunk/src/world_entities/creatures/fps_player.cc
r9494 r9869 32 32 33 33 #include "aabb.h" 34 34 #include "bsp_entity.h" 35 35 36 36 #include "key_mapper.h" … … 41 41 42 42 43 44 CREATE_FACTORY(FPSPlayer, CL_FPS_PLAYER); 43 #include "class_id_DEPRECATED.h" 44 ObjectListDefinitionID(FPSPlayer, CL_FPS_PLAYER); 45 CREATE_FACTORY(FPSPlayer); 45 46 46 47 #include "script_class.h" 47 CREATE_SCRIPTABLE_CLASS(FPSPlayer, CL_FPS_PLAYER,48 addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))49 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))50 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))51 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))48 CREATE_SCRIPTABLE_CLASS(FPSPlayer, 49 addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) 50 ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) 51 ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 52 ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 52 53 ); 53 54 … … 85 86 void FPSPlayer::init() 86 87 { 87 this-> setClassID(CL_FPS_PLAYER, "FPSPlayer");88 this->registerObject(this, FPSPlayer::_objectList); 88 89 89 90 this->bLeft = false; … … 166 167 167 168 //subscribe to collision reaction 168 this->subscribeReaction(CREngine::CR_PHYSICS_FULL_WALK, CL_BSP_ENTITY);169 this->subscribeReaction(CREngine::CR_PHYSICS_FULL_WALK, BspEntity::staticClassID()); 169 170 170 171 this->initWeapon = false; -
trunk/src/world_entities/creatures/fps_player.h
r9235 r9869 16 16 class FPSPlayer : public Playable 17 17 { 18 ObjectListDeclaration(FPSPlayer); 18 19 19 20 public: -
trunk/src/world_entities/creatures/md2_creature.cc
r8724 r9869 22 22 #include "objModel.h" 23 23 #include "md2/md2Model.h" 24 #include "util/loading/resource_manager.h"25 24 #include "state.h" 26 25 … … 37 36 #include "debug.h" 38 37 39 CREATE_FACTORY(MD2Creature, CL_MD2_CREATURE); 38 #include "class_id_DEPRECATED.h" 39 ObjectListDefinitionID(MD2Creature, CL_MD2_CREATURE); 40 CREATE_FACTORY(MD2Creature); 40 41 41 42 /** … … 86 87 PRINTF(4)("MD2CREATURE INIT\n"); 87 88 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 88 this-> setClassID(CL_MD2_CREATURE, "MD2Creature");89 this->registerObject(this, MD2Creature::_objectList); 89 90 90 91 this->toList(OM_GROUP_01); … … 95 96 Weapon* wpLeft = new TestGun(1); 96 97 wpLeft->setName("testGun Left"); 97 Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate( CL_CANNON));98 Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate("Cannon")); 98 99 99 100 cannon->setName("BFG"); … … 112 113 this->cameraConnNode.addChild(State::getCameraNode()); 113 114 State::getCameraTargetNode()->setRelCoor(10,0,0); 114 115 115 116 116 117 -
trunk/src/world_entities/creatures/md2_creature.h
r8724 r9869 16 16 class MD2Creature : public Playable 17 17 { 18 ObjectListDeclaration(MD2Creature); 18 19 19 20 public: -
trunk/src/world_entities/effects/billboard.cc
r9406 r9869 26 26 27 27 28 29 CREATE_FACTORY(Billboard, CL_BILLBOARD);30 28 #include "class_id_DEPRECATED.h" 29 ObjectListDefinitionID(Billboard, CL_BILLBOARD); 30 CREATE_FACTORY(Billboard); 31 31 32 32 /** … … 57 57 void Billboard::init() 58 58 { 59 this-> setClassID(CL_BILLBOARD, "Billboard");59 this->registerObject(this, Billboard::_objectList); 60 60 this->setName("Billboard"); 61 61 … … 124 124 glDisable(GL_LIGHTING); 125 125 glDisable(GL_FOG); 126 126 127 127 glPushMatrix(); 128 128 … … 130 130 //glTranslatef(0,0,0); 131 131 this->material->select(); 132 132 133 133 const PNode* camera = State::getCameraNode(); //!< @todo MUST be different 134 134 Vector cameraPos = camera->getAbsCoor(); … … 141 141 h.normalize(); 142 142 v.normalize(); 143 143 144 144 v *= sizeX; 145 145 h *= sizeY; … … 165 165 this->getAbsCoor().z - h.z + v.z); 166 166 glEnd(); 167 168 167 168 169 169 glPopMatrix(); 170 170 171 171 glPopAttrib(); 172 172 } -
trunk/src/world_entities/effects/billboard.h
r8255 r9869 13 13 class Billboard : public WorldEntity 14 14 { 15 ObjectListDeclaration(Billboard); 15 16 public: 16 17 Billboard(const TiXmlElement* root = NULL); -
trunk/src/world_entities/effects/explosion.cc
r9406 r9869 18 18 #include "explosion.h" 19 19 20 #include " fast_factory.h"20 #include "loading/fast_factory.h" 21 21 22 22 #include "state.h" 23 #include "class_list.h"24 23 25 #include " box_emitter.h"26 #include " sprite_particles.h"24 #include "particles/box_emitter.h" 25 #include "particles/sprite_particles.h" 27 26 28 27 29 28 30 31 CREATE_FAST_FACTORY_STATIC(Explosion, CL_EXPLOSION);32 29 #include "class_id_DEPRECATED.h" 30 ObjectListDefinitionID(Explosion, CL_EXPLOSION); 31 CREATE_FAST_FACTORY_STATIC(Explosion); 33 32 34 33 /** … … 37 36 Explosion::Explosion () 38 37 { 39 this-> setClassID(CL_EXPLOSION, "Explosion");38 this->registerObject(this, Explosion::_objectList); 40 39 this->toList(OM_DEAD_TICK); 41 40 … … 59 58 60 59 /* this is normaly done by World.cc by deleting the ParticleEngine */ 61 if (Explosion::explosionParticles != NULL && ClassList::getList(CL_EXPLOSION)->size() <= 1)60 if (Explosion::explosionParticles != NULL && Explosion::objectList().size() <= 1) 62 61 Explosion::explosionParticles = NULL; 63 62 } -
trunk/src/world_entities/effects/explosion.h
r7125 r9869 15 15 class Explosion : public WorldEntity 16 16 { 17 ObjectListDeclaration(Explosion); 17 18 public: 18 19 static void explode (PNode* position, const Vector& size); -
trunk/src/world_entities/effects/lightning_bolt.cc
r9406 r9869 20 20 #include "material.h" 21 21 22 #include " util/loading/resource_manager.h"22 #include "sound/resource_sound_buffer.h" 23 23 24 24 25 25 26 26 27 28 CREATE_FACTORY(LightningBolt, CL_LIGHTNING_BOLT);29 27 #include "class_id_DEPRECATED.h" 28 ObjectListDefinitionID(LightningBolt, CL_LIGHTNING_BOLT); 29 CREATE_FACTORY(LightningBolt); 30 30 31 31 /** … … 34 34 LightningBolt::LightningBolt (const TiXmlElement* root) 35 35 { 36 this-> setClassID(CL_LIGHTNING_BOLT, "LightningBolt");36 this->registerObject(this, LightningBolt::_objectList); 37 37 38 38 this->toList(OM_COMMON); … … 56 56 this->seedTime = 4.0f; 57 57 58 this->soundSource = NULL;59 this->thunderBuffer = NULL;60 61 58 this->soundSource.setSourceNode(this); 62 59 63 //load sound 64 if (this->thunderBuffer != NULL) 65 ResourceManager::getInstance()->unload(this->thunderBuffer); 66 this->thunderBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/thunder.wav", WAV); 60 this->thunderBuffer = OrxSound::ResourceSoundBuffer("sound/atmosphere/thunder.wav"); 67 61 } 68 62 -
trunk/src/world_entities/effects/lightning_bolt.h
r7460 r9869 2 2 * @file lightning_bolt.h 3 3 * @brief a LightningBolt Projectile 4 * Der Effekt soll folgenderma ßen funktionieren:4 * Der Effekt soll folgenderma�n funktionieren: 5 5 * -> Ein Partikel mit einer Blitz-Textur soll sehr schnell erscheinen, 6 * -> w ährend er an Intensitätzunimmt soll die Beleuchtung der gerenderten Szene entsprechend zunehmen.7 * -> Je mehr Blitze zum gleichen Zeitpunkt sichtbar sind, desto heller soll die Beleuchtung werden, das hei ßtdie Helligkeitszunahme pro Blitz soll Additiv sein.6 * -> w�rend er an Intensit� zunimmt soll die Beleuchtung der gerenderten Szene entsprechend zunehmen. 7 * -> Je mehr Blitze zum gleichen Zeitpunkt sichtbar sind, desto heller soll die Beleuchtung werden, das hei� die Helligkeitszunahme pro Blitz soll Additiv sein. 8 8 * -> Ein Partikel soll ebenfalls sehr schnell wieder verblassen, dabei soll die Beleuchtung entsprechend der vorhergehenden Zunahme wieder abnehmen (Additiv) 9 9 */ … … 21 21 class LightningBolt : public WorldEntity 22 22 { 23 ObjectListDeclaration(LightningBolt); 23 24 public: 24 25 LightningBolt(const TiXmlElement* root = NULL); … … 51 52 52 53 OrxSound::SoundSource soundSource; 53 OrxSound::SoundBuffer *thunderBuffer;54 OrxSound::SoundBuffer thunderBuffer; 54 55 }; 55 56 -
trunk/src/world_entities/elements/image_entity.cc
r9406 r9869 30 30 31 31 32 CREATE_FACTORY(ImageEntity, CL_IMAGE_ENTITY); 32 #include "class_id_DEPRECATED.h" 33 ObjectListDefinitionID(ImageEntity, CL_IMAGE_ENTITY); 34 CREATE_FACTORY(ImageEntity); 33 35 34 36 … … 59 61 void ImageEntity::init() 60 62 { 61 this-> setClassID(CL_IMAGE_ENTITY, "ImageEntity");63 this->registerObject(this, ImageEntity::_objectList); 62 64 this->setName("ImageEntity"); 63 65 -
trunk/src/world_entities/elements/image_entity.h
r7751 r9869 21 21 //! A class that enables the 22 22 class ImageEntity : public PNode, public Element2D { 23 ObjectListDeclaration(ImageEntity); 23 24 24 25 public: -
trunk/src/world_entities/elements/text_element.cc
r9406 r9869 27 27 28 28 29 30 CREATE_FACTORY(TextElement, CL_TEXT_ELEMENT); 29 #include "class_id_DEPRECATED.h" 30 ObjectListDefinitionID(TextElement, CL_TEXT_ELEMENT); 31 CREATE_FACTORY(TextElement); 31 32 32 33 … … 36 37 TextElement::TextElement (const TiXmlElement* root) 37 38 { 38 this-> setClassID(CL_TEXT_ELEMENT, "TextElement");39 this->registerObject(this, TextElement::_objectList); 39 40 this->setName("TextElement"); 40 41 -
trunk/src/world_entities/elements/text_element.h
r7221 r9869 21 21 //! A class that enables the 22 22 class TextElement : public Text { 23 ObjectListDeclaration(TextElement); 23 24 24 25 public: -
trunk/src/world_entities/environment.cc
r9406 r9869 20 20 #include "environment.h" 21 21 22 #include "util/loading/resource_manager.h"23 24 #include "vector.h"25 22 #include "objModel.h" 26 23 #include "obb_tree.h" 27 24 #include "util/loading/factory.h" 28 25 29 30 CREATE_FACTORY(Environment, CL_ENVIRONMENT); 26 #include "class_id_DEPRECATED.h" 27 ObjectListDefinitionID(Environment, CL_ENVIRONMENT); 28 CREATE_FACTORY(Environment); 31 29 32 30 /** … … 63 61 void Environment::init() 64 62 { 65 this-> setClassID(CL_ENVIRONMENT, "Environment");63 this->registerObject(this, Environment::_objectList); 66 64 this->toList(OM_ENVIRON); 67 65 } -
trunk/src/world_entities/environment.h
r6512 r9869 16 16 class Environment : public WorldEntity 17 17 { 18 friend class World;18 ObjectListDeclaration(Environment); 19 19 20 20 public: -
trunk/src/world_entities/environments/building.cc
r9406 r9869 23 23 24 24 25 26 CREATE_FACTORY(Building, CL_BUILDING); 25 #include "class_id_DEPRECATED.h" 26 ObjectListDefinitionID(Building, CL_BUILDING); 27 CREATE_FACTORY(Building); 27 28 28 29 /** … … 31 32 Building::Building(const TiXmlElement* root) 32 33 { 33 this-> setClassID(CL_BUILDING, "Building");34 this->registerObject(this, Building::_objectList); 34 35 this->toList(OM_ENVIRON_NOTICK); 35 36 -
trunk/src/world_entities/environments/building.h
r7041 r9869 15 15 class Building : public WorldEntity 16 16 { 17 public: 17 ObjectListDeclaration(Building); 18 public: 18 19 Building(const TiXmlElement* root); 19 20 -
trunk/src/world_entities/environments/mapped_water.cc
r9406 r9869 17 17 #include "util/loading/load_param.h" 18 18 #include "util/loading/factory.h" 19 #include "util/loading/resource_manager.h"20 19 #include "state.h" 21 20 #include "t_animation.h" … … 25 24 #include "script_class.h" 26 25 27 CREATE_FACTORY(MappedWater, CL_MAPPED_WATER); 26 #include "resource_shader.h" 27 28 #include "class_id_DEPRECATED.h" 29 ObjectListDefinitionID(MappedWater, CL_MAPPED_WATER); 30 CREATE_FACTORY(MappedWater); 28 31 29 32 SHELL_COMMAND(gui, MappedWater, toggleGui); 30 33 SHELL_COMMAND(output, MappedWater, saveParams); 31 34 32 CREATE_SCRIPTABLE_CLASS(MappedWater, CL_MAPPED_WATER,33 addMethod("waterUV", Executor Lua2<MappedWater, float, float>(&MappedWater::fadeWaterUV))34 ->addMethod("waterFlow", ExecutorLua2<MappedWater, float, float>(&MappedWater::fadeWaterFlow))35 ->addMethod("shineSize", ExecutorLua2<MappedWater, float, float>(&MappedWater::fadeShineSize))36 ->addMethod("shineStrength", ExecutorLua2<MappedWater, float, float>(&MappedWater::fadeShineStrength))37 ->addMethod("reflStrength", ExecutorLua2<MappedWater, float, float>(&MappedWater::fadeReflStrength))38 ->addMethod("refraction", ExecutorLua2<MappedWater, float, float>(&MappedWater::fadeRefraction))39 ->addMethod("waterHeight", ExecutorLua2<MappedWater, float, float>(&MappedWater::fadeWaterHeight))40 ->addMethod("waterColor", ExecutorLua4<MappedWater, float, float, float, float>(&MappedWater::fadeWaterColor)));35 CREATE_SCRIPTABLE_CLASS(MappedWater, 36 addMethod("waterUV", Executor2<MappedWater, lua_State*, float, float>(&MappedWater::fadeWaterUV)) 37 ->addMethod("waterFlow", Executor2<MappedWater, lua_State*, float, float>(&MappedWater::fadeWaterFlow)) 38 ->addMethod("shineSize", Executor2<MappedWater, lua_State*, float, float>(&MappedWater::fadeShineSize)) 39 ->addMethod("shineStrength", Executor2<MappedWater, lua_State*, float, float>(&MappedWater::fadeShineStrength)) 40 ->addMethod("reflStrength", Executor2<MappedWater, lua_State*, float, float>(&MappedWater::fadeReflStrength)) 41 ->addMethod("refraction", Executor2<MappedWater, lua_State*, float, float>(&MappedWater::fadeRefraction)) 42 ->addMethod("waterHeight", Executor2<MappedWater, lua_State*, float, float>(&MappedWater::fadeWaterHeight)) 43 ->addMethod("waterColor", Executor4<MappedWater, lua_State*, float, float, float, float>(&MappedWater::fadeWaterColor))); 41 44 42 45 … … 47 50 MappedWater::MappedWater(const TiXmlElement* root) 48 51 { 49 this-> setClassID(CL_MAPPED_WATER, "MappedWater");52 this->registerObject(this, MappedWater::_objectList); 50 53 this->toList(OM_ENVIRON); 51 54 … … 75 78 MappedWater::~MappedWater() 76 79 { 77 delete shader;78 80 delete cam_uni; 79 81 delete color_uni; … … 163 165 { 164 166 // load shader files 165 shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag");166 167 this->shader ->activateShader();167 shader = ResourceShader( "/shaders/mapped_water.vert", "/shaders/mapped_water.frag"); 168 169 this->shader.activateShader(); 168 170 // Set the variable "reflection" to correspond to the first texture unit 169 171 Shader::Uniform(shader, "reflection").set(0); … … 197 199 cam_uni = new Shader::Uniform(shader, "cameraPos"); 198 200 199 this->shader ->deactivateShader();201 this->shader.deactivateShader(); 200 202 } 201 203 … … 223 225 void MappedWater::resetWaterColor(float r, float g, float b) 224 226 { 225 this->shader ->activateShader();227 this->shader.activateShader(); 226 228 this->waterColor = Vector(r, g, b); 227 229 … … 229 231 color_uni->set(waterColor.x, waterColor.y, waterColor.z, 1.0f); 230 232 231 this->shader ->deactivateShader();233 this->shader.deactivateShader(); 232 234 } 233 235 … … 238 240 void MappedWater::resetShineSize(float shine) 239 241 { 240 this->shader ->activateShader();242 this->shader.activateShader(); 241 243 this->shineSize = shine; 242 244 … … 244 246 shineSize_uni->set(this->shineSize); 245 247 246 this->shader ->deactivateShader();248 this->shader.deactivateShader(); 247 249 } 248 250 … … 253 255 void MappedWater::resetShineStrength(float strength) 254 256 { 255 this->shader ->activateShader();257 this->shader.activateShader(); 256 258 this->shineStrength = strength; 257 259 … … 259 261 shineStrength_uni->set(this->shineStrength); 260 262 261 this->shader ->deactivateShader();263 this->shader.deactivateShader(); 262 264 } 263 265 … … 268 270 void MappedWater::resetReflStrength(float strength) 269 271 { 270 this->shader ->activateShader();272 this->shader.activateShader(); 271 273 this->reflStrength = strength; 272 274 … … 274 276 reflStrength_uni->set(this->reflStrength); 275 277 276 this->shader ->deactivateShader();278 this->shader.deactivateShader(); 277 279 } 278 280 … … 283 285 void MappedWater::resetRefraction(float refraction) 284 286 { 285 this->shader ->activateShader();287 this->shader.activateShader(); 286 288 this->refraction = refraction; 287 289 … … 289 291 refr_uni->set(this->refraction); 290 292 291 this->shader ->deactivateShader();293 this->shader.deactivateShader(); 292 294 } 293 295 … … 300 302 void MappedWater::resetLightPos(float x, float y, float z) 301 303 { 302 this->shader ->activateShader();304 this->shader.activateShader(); 303 305 this->lightPos = Vector(x, y, z); 304 306 … … 306 308 light_uni->set(lightPos.x, lightPos.y, lightPos.z, 1.0f); 307 309 308 this->shader ->deactivateShader();310 this->shader.deactivateShader(); 309 311 } 310 312 … … 554 556 mat.select(); 555 557 556 this->shader ->activateShader();558 this->shader.activateShader(); 557 559 558 560 // reset the camera uniform to the current cam position … … 593 595 glEnd(); 594 596 595 this->shader ->deactivateShader();597 this->shader.deactivateShader(); 596 598 597 599 mat.unselect(); -
trunk/src/world_entities/environments/mapped_water.h
r9021 r9869 35 35 class MappedWater : public WorldEntity 36 36 { 37 ObjectListDeclaration(MappedWater); 37 38 public: 38 39 MappedWater(const TiXmlElement* root = NULL); … … 106 107 private: 107 108 Material mat; 108 Shader *shader;109 Shader shader; 109 110 OrxGui::GLGuiBox* box; 110 111 -
trunk/src/world_entities/environments/model_entity.cc
r9656 r9869 23 23 24 24 25 26 CREATE_FACTORY(ModelEntity, CL_MODEL_ENTITY); 25 #include "class_id_DEPRECATED.h" 26 ObjectListDefinitionID(ModelEntity, CL_MODEL_ENTITY); 27 CREATE_FACTORY(ModelEntity); 27 28 28 29 /** … … 31 32 ModelEntity::ModelEntity(const TiXmlElement* root) 32 33 { 33 this-> setClassID(CL_MODEL_ENTITY, "ModelEntity");34 this->registerObject(this, ModelEntity::_objectList); 34 35 this->toList(OM_ENVIRON); 35 36 -
trunk/src/world_entities/environments/model_entity.h
r7048 r9869 15 15 class ModelEntity : public WorldEntity 16 16 { 17 ObjectListDeclaration(ModelEntity); 17 18 public: 18 19 ModelEntity(const TiXmlElement* root); -
trunk/src/world_entities/environments/water.cc
r9656 r9869 23 23 #include "material.h" 24 24 25 #include "util/loading/resource_manager.h" 26 #include "shader.h" 25 #include "resource_shader.h" 27 26 28 27 #include "skybox.h" … … 33 32 34 33 35 36 CREATE_FACTORY(Water, CL_WATER); 34 #include "class_id_DEPRECATED.h" 35 ObjectListDefinitionID(Water, CL_WATER); 36 CREATE_FACTORY(Water); 37 37 38 38 39 39 Water::Water(const TiXmlElement* root) 40 40 { 41 this-> setClassID(CL_WATER, "Water");41 this->registerObject(this, Water::_objectList); 42 42 this->toList(OM_ENVIRON); 43 43 … … 55 55 56 56 this->rebuildGrid(); 57 this->waterShader = (Shader*)ResourceManager::getInstance()->load("shaders/water.vert", SHADER, RP_GAME, "shaders/water.frag");57 this->waterShader = ResourceShader("shaders/water.vert", "shaders/water.frag"); 58 58 59 59 // To test the Wave equation … … 217 217 void Water::tick(float dt) 218 218 { 219 ObjectManager::EntityList entityList = State::getObjectManager()->get ObjectList(OM_GROUP_01_PROJ);219 ObjectManager::EntityList entityList = State::getObjectManager()->getEntityList(OM_GROUP_01_PROJ); 220 220 ObjectManager::EntityList::iterator entity = entityList.begin(); 221 221 while (entity != entityList.end()) -
trunk/src/world_entities/environments/water.h
r7954 r9869 13 13 #include "world_entity.h" 14 14 #include "material.h" 15 15 #include "shader.h" 16 16 17 17 /* FORWARD DECLARATION */ 18 18 class Grid; 19 class Shader;20 19 21 20 //! A Class to handle a WaterEffects 22 21 class Water : public WorldEntity 23 22 { 24 public: 23 ObjectListDeclaration(Water); 24 public: 25 25 Water(const TiXmlElement* root = NULL); 26 26 virtual ~Water(); … … 38 38 void draw() const; 39 39 void tick(float dt); 40 40 41 41 virtual void varChangeHandler( std::list<int> & id ); 42 42 … … 51 51 52 52 Material waterMaterial; 53 Shader *waterShader;54 53 Shader waterShader; 54 55 55 float height; //!< The hight of the Water 56 56 int height_handle; //!< Handle to notify about changes of height -
trunk/src/world_entities/extendable.h
r6282 r9869 1 1 /*! 2 * @file proto_class.h3 * @brief Interface for Worldentities that can pick uup powerups.2 * @file extendable.h 3 * @brief Interface for Worldentities that can pick up powerups. 4 4 */ 5 5 … … 12 12 class PowerUp; 13 13 14 14 15 #include "power_ups/power_up.h" 15 16 //! A class for ... 16 //! A class for Extendable Entities 17 17 class Extendable : virtual public BaseObject { 18 ObjectListDeclaration(Extendable); 18 19 19 20 public: 20 // virtual ~Extendable();21 21 virtual bool pickup(PowerUp* powerUp) { return false; }; 22 22 23 23 protected: 24 Extendable() { this->setClassID(CL_EXTENDABLE, "Extendable"); }; 25 26 private: 27 24 Extendable() { this->registerObject(this, Extendable::_objectList); }; 28 25 }; 29 26 -
trunk/src/world_entities/movie_entity.cc
r9406 r9869 21 21 22 22 23 24 CREATE_FACTORY(MovieEntity, CL_MOVIE_ENTITY); 23 #include "class_id_DEPRECATED.h" 24 ObjectListDefinitionID(MovieEntity, CL_MOVIE_ENTITY); 25 CREATE_FACTORY(MovieEntity); 25 26 26 27 /** … … 29 30 MovieEntity::MovieEntity (const TiXmlElement* root) 30 31 { 31 this-> setClassID(CL_MOVIE_ENTITY, "MovieEntity");32 this->registerObject(this, MovieEntity::_objectList); 32 33 33 34 media_container = new MediaContainer(); -
trunk/src/world_entities/movie_entity.h
r7221 r9869 14 14 class MovieEntity : public WorldEntity 15 15 { 16 ObjectListDeclaration(MovieEntity); 16 17 private: 17 18 MediaContainer* media_container; -
trunk/src/world_entities/npcs/attractor_mine.cc
r9235 r9869 33 33 #include "effects/explosion.h" 34 34 35 CREATE_FACTORY(AttractorMine, CL_ATTRACTOR_MINE); 35 #include "class_id_DEPRECATED.h" 36 ObjectListDefinitionID(AttractorMine, CL_ATTRACTOR_MINE); 37 CREATE_FACTORY(AttractorMine); 36 38 #include "script_class.h" 37 CREATE_SCRIPTABLE_CLASS(AttractorMine, CL_ATTRACTOR_MINE,38 addMethod("setName", Executor Lua1<BaseObject,const std::string&>(&BaseObject::setName))39 //Coordinates40 ->addMethod("setAbsCoor", Executor Lua3<PNode,float,float,float>(&PNode::setAbsCoor))41 ->addMethod("getAbsCoorX", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorX))42 ->addMethod("getAbsCoorY", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorY))43 ->addMethod("getAbsCoorZ", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorZ))39 CREATE_SCRIPTABLE_CLASS(AttractorMine, 40 addMethod("setName", Executor1<BaseObject, lua_State*,const std::string&>(&BaseObject::setName)) 41 //Coordinates 42 ->addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) 43 ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) 44 ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 45 ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 44 46 ); 45 47 … … 50 52 : NPC(NULL) 51 53 { 52 this-> setClassID(CL_ATTRACTOR_MINE, "AttractorMine");54 this->registerObject(this, AttractorMine::_objectList); 53 55 54 56 this->toList(OM_GROUP_02); … … 64 66 65 67 this->shader = NULL; 66 if (likely(Shader::checkShaderAbility()))67 this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag");68 //if (likely(Shader::checkShaderAbility())) 69 // this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag"); 68 70 69 71 this->randomRotAxis = VECTOR_RAND(1); … … 76 78 AttractorMine::~AttractorMine () 77 79 { 78 if (this->shader)79 Shader::unload(this->shader);80 80 } 81 82 81 83 82 void AttractorMine::loadParams(const TiXmlElement* root) -
trunk/src/world_entities/npcs/attractor_mine.h
r9235 r9869 9 9 10 10 class AttractorMine : public NPC { 11 ObjectListDeclaration(AttractorMine); 11 12 12 13 public: -
trunk/src/world_entities/npcs/door.cc
r9406 r9869 25 25 26 26 #include "door.h" 27 #include "class_list.h"28 27 29 30 31 32 33 CREATE_FACTORY(Door, CL_DOOR); 28 #include "class_id_DEPRECATED.h" 29 ObjectListDefinitionID(Door, CL_DOOR); 30 CREATE_FACTORY(Door); 34 31 35 32 … … 47 44 Door::Door(const TiXmlElement* root) 48 45 { 49 50 this->setClassID(CL_DOOR, "Door"); 46 this->registerObject(this, Door::_objectList); 51 47 this->scale = 1.0f; 52 48 this->actionRadius = 1.0; … … 152 148 153 149 154 150 #include "playable.h" 151 #include "generic_npc.h" 155 152 /** 156 153 * checks if the door is open … … 159 156 { 160 157 161 std::list<BaseObject*>::const_iterator it;162 const std::list<BaseObject*>* list = ClassList::getList(CL_PLAYABLE);163 158 WorldEntity* entity; 164 159 float distance; 165 160 166 if( list == NULL)167 return false;168 161 for (ObjectList<Playable>::const_iterator it = Playable::objectList().begin(); 162 it != Playable::objectList().end(); 163 ++it) 169 164 // for all players 170 for( it = list->begin(); it != list->end(); it++)171 165 { 172 entity = dynamic_cast<WorldEntity*>(*it);166 entity = (*it); 173 167 174 168 distance = fabs((this->getAbsCoor() - entity->getAbsCoor()).len()); … … 178 172 179 173 180 list = ClassList::getList(CL_GENERIC_NPC); 181 if( list == NULL)182 return false;183 for( it = list->begin(); it != list->end(); it++)174 175 for (ObjectList<GenericNPC>::const_iterator it = GenericNPC::objectList().begin(); 176 it != GenericNPC::objectList().end(); 177 ++it) 184 178 { 185 entity = dynamic_cast<WorldEntity*>(*it);179 entity = (*it); 186 180 187 181 distance = fabs((this->getAbsCoor() - entity->getAbsCoor()).len()); -
trunk/src/world_entities/npcs/door.h
r9110 r9869 21 21 class Door : public WorldEntity 22 22 { 23 ObjectListDeclaration(Door); 24 23 25 public: 24 26 Door(const TiXmlElement* root = NULL); -
trunk/src/world_entities/npcs/gate.cc
r9406 r9869 25 25 26 26 #include "gate.h" 27 #include "class_list.h"28 29 27 #include "effects/explosion.h" 30 28 … … 33 31 34 32 35 36 CREATE_FACTORY(Gate, CL_GATE); 33 #include "class_id_DEPRECATED.h" 34 ObjectListDefinitionID(Gate, CL_GATE); 35 CREATE_FACTORY(Gate); 37 36 38 37 39 38 #include "script_class.h" 40 CREATE_SCRIPTABLE_CLASS(Gate, CL_GATE,41 addMethod("hide", ExecutorLua0<WorldEntity>(&WorldEntity::hide))42 ->addMethod("unhide", ExecutorLua0<WorldEntity>(&WorldEntity::unhide))43 ->addMethod("destroy", ExecutorLua0<Gate>(&Gate::destroy)) 44 ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))45 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))46 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))47 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))39 CREATE_SCRIPTABLE_CLASS(Gate, 40 addMethod("hide", Executor0<WorldEntity, lua_State*>(&WorldEntity::hide)) 41 ->addMethod("unhide", Executor0<WorldEntity, lua_State*>(&WorldEntity::unhide)) 42 ->addMethod("destroy", Executor0<Gate, lua_State*>(&Gate::destroy)) 43 ->addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) 44 ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) 45 ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 46 ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 48 47 ); 48 49 49 50 50 … … 62 62 Gate::Gate(const TiXmlElement* root) 63 63 { 64 65 this->setClassID(CL_GATE, "Gate"); 64 this->registerObject(this, Gate::_objectList); 66 65 this->scale = 1.0f; 67 66 this->actionRadius = 1.0; … … 165 164 void Gate::close() 166 165 { 167 166 168 167 if( this->destroyed) 169 168 return; 170 169 171 170 this->setAnimation(GATE_CLOSE, MD2_ANIM_ONCE); 172 171 this->bOpen = false; … … 178 177 if( this->destroyed) 179 178 return; 180 179 181 180 this->setAnimation(GATE_DIE, MD2_ANIM_ONCE); 182 181 183 182 Explosion::explode(this, Vector(this->getScaling()/160,this->getScaling()/160,this->getScaling()/160)); 184 185 183 184 186 185 this->destroyed = true; 187 186 } 188 187 188 #include "playable.h" 189 #include "generic_npc.h" 189 190 190 191 /** … … 195 196 196 197 std::list<BaseObject*>::const_iterator it; 197 const std::list<BaseObject*>* list = ClassList::getList(CL_PLAYABLE);198 198 WorldEntity* entity; 199 199 float distance; 200 200 201 if( list == NULL)202 return false;203 204 201 // for all players 205 for( it = list->begin(); it != list->end(); it++) 206 { 207 entity = dynamic_cast<WorldEntity*>(*it); 202 for (ObjectList<Playable>::const_iterator it = Playable::objectList().begin(); 203 it != Playable::objectList().end(); 204 ++it) 205 { 206 entity = (*it); 208 207 209 208 distance = fabs((this->getAbsCoor() - entity->getAbsCoor()).len()); … … 213 212 214 213 215 list = ClassList::getList(CL_GENERIC_NPC); 216 if( list == NULL) 217 return false; 218 for( it = list->begin(); it != list->end(); it++) 219 { 220 entity = dynamic_cast<WorldEntity*>(*it); 214 for (ObjectList<GenericNPC>::const_iterator it = GenericNPC::objectList().begin(); 215 it != GenericNPC::objectList().end(); 216 ++it) 217 { 218 entity = (*it); 221 219 222 220 distance = fabs((this->getAbsCoor() - entity->getAbsCoor()).len()); -
trunk/src/world_entities/npcs/gate.h
r9298 r9869 22 22 class Gate : public WorldEntity 23 23 { 24 ObjectListDeclaration(Gate); 25 24 26 public: 25 27 Gate(const TiXmlElement* root = NULL); -
trunk/src/world_entities/npcs/generic_npc.cc
r9235 r9869 27 27 28 28 #include "sound_buffer.h" 29 30 #include "loading/resource_manager.h" 31 32 33 CREATE_FACTORY(GenericNPC, CL_GENERIC_NPC); 29 #include "resource_sound_buffer.h" 30 31 #include "sound/resource_sound_buffer.h" 32 33 #include "bsp_entity.h" 34 35 #include "class_id_DEPRECATED.h" 36 ObjectListDefinitionID(GenericNPC, CL_GENERIC_NPC); 37 CREATE_FACTORY(GenericNPC); 34 38 35 39 #include "script_class.h" 36 CREATE_SCRIPTABLE_CLASS(GenericNPC, CL_GENERIC_NPC,40 CREATE_SCRIPTABLE_CLASS(GenericNPC, 37 41 // Move 38 addMethod("walkTo", Executor Lua3<GenericNPC,float,float,float>(&GenericNPC::walkTo))39 ->addMethod("runTo", Executor Lua3<GenericNPC,float,float,float>(&GenericNPC::runTo))40 ->addMethod("turnTo", Executor Lua1<GenericNPC,float>(&GenericNPC::turnTo))41 ->addMethod("finalGoalReached", Executor Lua0ret<GenericNPC,bool>(&GenericNPC::finalGoalReached))42 ->addMethod("stop", Executor Lua0<GenericNPC>(&GenericNPC::stop))43 ->addMethod("resume", Executor Lua0<GenericNPC>(&GenericNPC::resume))44 ->addMethod("playAnimation", Executor Lua2<GenericNPC,int,int>(&GenericNPC::playAnimation))42 addMethod("walkTo", Executor3<GenericNPC, lua_State*,float,float,float>(&GenericNPC::walkTo)) 43 ->addMethod("runTo", Executor3<GenericNPC, lua_State*,float,float,float>(&GenericNPC::runTo)) 44 ->addMethod("turnTo", Executor1<GenericNPC, lua_State*,float>(&GenericNPC::turnTo)) 45 ->addMethod("finalGoalReached", Executor0ret<GenericNPC, lua_State*,bool>(&GenericNPC::finalGoalReached)) 46 ->addMethod("stop", Executor0<GenericNPC, lua_State*>(&GenericNPC::stop)) 47 ->addMethod("resume", Executor0<GenericNPC, lua_State*>(&GenericNPC::resume)) 48 ->addMethod("playAnimation", Executor2<GenericNPC, lua_State*,int,int>(&GenericNPC::playAnimation)) 45 49 // Display 46 ->addMethod("hide", Executor Lua0<WorldEntity>(&WorldEntity::hide))47 ->addMethod("unhide", Executor Lua0<WorldEntity>(&WorldEntity::unhide))50 ->addMethod("hide", Executor0<WorldEntity, lua_State*>(&WorldEntity::hide)) 51 ->addMethod("unhide", Executor0<WorldEntity, lua_State*>(&WorldEntity::unhide)) 48 52 // Coordinates 49 ->addMethod("getAbsCoorX", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorX))50 ->addMethod("getAbsCoorY", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorY))51 ->addMethod("getAbsCoorZ", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorZ))52 ->addMethod("setAbsCoor", Executor Lua3<PNode,float,float,float>(&PNode::setAbsCoor))53 ->addMethod("setAbsDir", Executor Lua4<PNode,float,float,float,float>(&PNode::setAbsDir))53 ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) 54 ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 55 ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 56 ->addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) 57 ->addMethod("setAbsDir", Executor4<PNode, lua_State*,float,float,float,float>(&PNode::setAbsDir)) 54 58 ); 55 59 … … 81 85 void GenericNPC::init() 82 86 { 83 this-> setClassID(CL_GENERIC_NPC, "GenericNPC");87 this->registerObject(this, GenericNPC::_objectList); 84 88 85 89 this->toList(OM_GROUP_00); 86 90 87 this->soundBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);91 this->soundBuffer = OrxSound::ResourceSoundBuffer("sound/rain.wav"); 88 92 89 93 time = 30.0f; … … 92 96 93 97 // collision reaction registration 94 this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);98 this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, BspEntity::staticClassID()); 95 99 } 96 100 … … 231 235 this->setAnimationSpeed(0.5f); 232 236 } 233 237 break; 234 238 case Run: 235 239 { … … 244 248 this->setAnimationSpeed(1.0f); 245 249 } 246 250 break; 247 251 case Crouch: 248 252 { … … 257 261 this->setAnimationSpeed(1.0f); 258 262 } 259 263 break; 260 264 case LookAt: 261 262 263 265 if( this->getAnimation() != STAND) 266 this->setAnimation(STAND, MD2_ANIM_LOOP); 267 break; 264 268 case Shoot: 265 266 267 269 if( this->getAnimation() != STAND) 270 this->setAnimation(STAND, MD2_ANIM_LOOP); 271 break; 268 272 269 273 default: 270 271 272 274 if( this->getAnimation() != STAND) 275 this->setAnimation(STAND, MD2_ANIM_LOOP); 276 break; 273 277 274 278 } … … 304 308 this->setAnimationSpeed(0.5f); 305 309 } 306 310 break; 307 311 case Run: 308 312 { … … 317 321 this->setAnimationSpeed(1.0f); 318 322 } 319 323 break; 320 324 case Crouch: 321 325 { … … 330 334 this->setAnimationSpeed(1.0f); 331 335 } 332 336 break; 333 337 case LookAt: 334 338 { … … 336 340 this->setAnimation(STAND, MD2_ANIM_LOOP); 337 341 } 338 342 break; 339 343 case Shoot: 340 344 if( this->getAnimation() != STAND) 341 345 this->setAnimation(STAND, MD2_ANIM_LOOP); 342 346 break; 343 347 344 348 default: 345 349 if( this->getAnimation() != STAND) 346 350 this->setAnimation(STAND, MD2_ANIM_LOOP); 347 351 break; 348 352 349 353 } … … 507 511 { 508 512 case Walk: 513 { 514 Vector dest = currentAnimation.v - this->getAbsCoor(); 515 dest.y = 0.0f; 516 if (dest.len() < .5) 509 517 { 510 Vector dest = currentAnimation.v - this->getAbsCoor(); 511 dest.y = 0.0f; 512 if (dest.len() < .5) 513 { 514 this->nextStep(); 515 } 516 else 517 { 518 Vector move = dest.getNormalized() * currentAnimation.speed * dt; 519 this->shiftCoor(move); 520 } 518 this->nextStep(); 521 519 } 522 break; 520 else 521 { 522 Vector move = dest.getNormalized() * currentAnimation.speed * dt; 523 this->shiftCoor(move); 524 } 525 } 526 break; 523 527 524 528 case Run: … … 549 553 550 554 case TurnTo: 551 552 555 //Quaternion direction = this-> 556 break; 553 557 554 558 case LookAt: 555 559 break; 556 560 557 561 case Shoot: 558 562 break; 559 563 560 564 default: 561 565 break; 562 566 563 567 } … … 569 573 this->fallVelocity += 300.0f * dt; 570 574 //velocity -= Vector(0.0, 1.0, 0.0) * this->fallVelocity; 571 // PRINTF(0)("%s is not on ground\n", this->getName());575 // PRINTF(0)("%s is not on ground\n", this->getName()); 572 576 this->shiftCoor(Vector(0, -this->fallVelocity * dt,0)); 573 577 -
trunk/src/world_entities/npcs/generic_npc.h
r9235 r9869 25 25 class GenericNPC : public NPC 26 26 { 27 ObjectListDeclaration(GenericNPC); 27 28 28 29 … … 123 124 124 125 OrxSound::SoundSource soundSource; 125 OrxSound::SoundBuffer *soundBuffer;126 OrxSound::SoundBuffer soundBuffer; 126 127 float soundVolume; 127 128 -
trunk/src/world_entities/npcs/ground_turret.cc
r9656 r9869 29 29 #include "effects/explosion.h" 30 30 31 CREATE_FACTORY(GroundTurret, CL_GROUND_TURRET); 31 #include "class_id_DEPRECATED.h" 32 32 33 33 ObjectListDefinitionID(GroundTurret, CL_GROUND_TURRET); 34 CREATE_FACTORY(GroundTurret); 34 35 35 36 … … 61 62 void GroundTurret::init() 62 63 { 63 this-> setClassID(CL_GROUND_TURRET, "GroundTurret");64 this->registerObject(this, GroundTurret::_objectList); 64 65 this->loadModel("models/ground_turret_#.obj", 5); 65 66 this->left = NULL; -
trunk/src/world_entities/npcs/ground_turret.h
r9656 r9869 14 14 class GroundTurret : public NPC 15 15 { 16 ObjectListDeclaration(GroundTurret); 16 17 17 18 public: -
trunk/src/world_entities/npcs/network_turret.cc
r9656 r9869 30 30 31 31 #include "weapons/aiming_turret.h" 32 #include "debug.h" 32 33 33 CREATE_FACTORY(NetworkTurret, CL_NETWORK_TURRET); 34 35 34 #include "class_id_DEPRECATED.h" 35 ObjectListDefinitionID(NetworkTurret, CL_NETWORK_TURRET); 36 CREATE_FACTORY(NetworkTurret); 36 37 37 38 … … 62 63 void NetworkTurret::init() 63 64 { 64 this-> setClassID(CL_NETWORK_TURRET, "NetworkTurret");65 this->registerObject(this, NetworkTurret::_objectList); 65 66 this->loadModel("models/ground_turret_#.obj", 5); 66 67 … … 111 112 ObjectManager::EntityList::iterator entity; 112 113 Vector diffVec; 113 for (entity = State::getObjectManager()->get ObjectList((OM_LIST)this->targetGroup).begin();114 entity != State::getObjectManager()->get ObjectList((OM_LIST)this->targetGroup).end();114 for (entity = State::getObjectManager()->getEntityList((OM_LIST)this->targetGroup).begin(); 115 entity != State::getObjectManager()->getEntityList((OM_LIST)this->targetGroup).end(); 115 116 entity ++) 116 117 { -
trunk/src/world_entities/npcs/network_turret.h
r9656 r9869 14 14 class NetworkTurret : public NPC 15 15 { 16 16 ObjectListDeclaration(NetworkTurret); 17 17 public: 18 18 NetworkTurret(const TiXmlElement* root = NULL); -
trunk/src/world_entities/npcs/npc.cc
r9235 r9869 20 20 #include "npc.h" 21 21 22 ObjectListDefinition(NPC); 22 23 23 24 NPC::NPC(const TiXmlElement* root) 24 25 { 25 this-> setClassID(CL_NPC, "NPC");26 this->registerObject(this, NPC::_objectList); 26 27 27 28 this->toList(OM_GROUP_00); -
trunk/src/world_entities/npcs/npc.h
r8724 r9869 8 8 9 9 class NPC : public WorldEntity { 10 10 ObjectListDeclaration(NPC); 11 11 public: 12 12 NPC (const TiXmlElement* root); -
trunk/src/world_entities/npcs/npc_test.cc
r9235 r9869 30 30 #include "effects/explosion.h" 31 31 32 CREATE_FACTORY(NPC2, CL_NPC_TEST2); 33 32 #include "class_id_DEPRECATED.h" 33 ObjectListDefinitionID(NPC2, CL_NPC_TEST2); 34 CREATE_FACTORY(NPC2); 34 35 35 36 NPC2::NPC2(const TiXmlElement* root) 36 37 : NPC(NULL) 37 38 { 38 this-> setClassID(CL_NPC_TEST2, "NPC2");39 this->registerObject(this, NPC2::_objectList); 39 40 40 41 if ((float)rand()/RAND_MAX > .5f) … … 47 48 48 49 this->shader = NULL; 49 if (likely(Shader::checkShaderAbility()))50 this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag");50 // if (likely(Shader::checkShaderAbility())) 51 //this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag"); 51 52 52 53 this->randomRotAxis = VECTOR_RAND(1); … … 58 59 59 60 NPC2::~NPC2 () 60 { 61 if (this->shader) 62 Shader::unload(this->shader); 63 } 61 {} 64 62 65 63 -
trunk/src/world_entities/npcs/npc_test.h
r9235 r9869 9 9 10 10 class NPC2 : public NPC { 11 ObjectListDeclaration(NPC2); 11 12 12 13 public: -
trunk/src/world_entities/npcs/npc_test1.cc
r9235 r9869 25 25 #include "power_ups/laser_power_up.h" 26 26 27 ObjectListDefinition(NPCTest1); 27 28 28 29 NPCTest1::NPCTest1() 29 30 : NPC(NULL) 30 31 { 31 this-> setClassID(CL_NPC_TEST1, "NPCTest1");32 this->registerObject(this, NPCTest1::_objectList); 32 33 33 34 if ((float)rand()/RAND_MAX > .5f) -
trunk/src/world_entities/npcs/npc_test1.h
r6981 r9869 8 8 9 9 class NPCTest1 : public NPC { 10 10 ObjectListDeclaration(NPCTest1); 11 11 public: 12 12 NPCTest1 (); -
trunk/src/world_entities/npcs/repair_station.cc
r9406 r9869 25 25 26 26 #include "repair_station.h" 27 #include "class_list.h"28 27 29 30 31 32 33 CREATE_FACTORY(RepairStation, CL_DOOR); 28 #include "class_id_DEPRECATED.h" 29 ObjectListDefinitionID(RepairStation, CL_DOOR +1 ); 30 CREATE_FACTORY(RepairStation); 34 31 35 32 … … 67 64 RepairStation::RepairStation(const TiXmlElement* root) 68 65 { 69 70 this->setClassID(CL_DOOR, "RepairStation"); 66 this->registerObject(this, RepairStation::_objectList); 71 67 this->scale = 1.0f; 72 68 -
trunk/src/world_entities/npcs/repair_station.h
r9003 r9869 27 27 class RepairStation : public WorldEntity 28 28 { 29 ObjectListDeclaration(RepairStation); 29 30 public: 30 31 RepairStation (); -
trunk/src/world_entities/npcs/space_turret.cc
r9656 r9869 29 29 #include "effects/explosion.h" 30 30 31 CREATE_FACTORY(SpaceTurret, CL_SPACE_TURRET); 31 #include "class_id_DEPRECATED.h" 32 ObjectListDefinitionID(SpaceTurret, CL_SPACE_TURRET); 33 CREATE_FACTORY(SpaceTurret); 32 34 33 35 /** … … 36 38 */ 37 39 SpaceTurret::SpaceTurret(const TiXmlElement* root) 38 : NPC(root)40 : NPC(root) 39 41 { 40 42 this->init(); … … 48 50 */ 49 51 SpaceTurret::~SpaceTurret () 50 { 51 52 } 52 {} 53 53 54 54 … … 59 59 void SpaceTurret::init() 60 60 { 61 this-> setClassID(CL_SPACE_TURRET, "SpaceTurret");61 this->registerObject(this, SpaceTurret::_objectList); 62 62 this->loadModel("models/ground_turret_#.obj", 7.5); 63 63 this->loadModel("models/comet.obj", 1.0f, 3); … … 98 98 99 99 element = root->FirstChildElement("weapon-left"); 100 if (element != NULL) element = element->FirstChildElement(); 101 this->left = dynamic_cast<Weapon*>( Factory::fabricate( element) ); 100 if (element != NULL) 101 element = element->FirstChildElement(); 102 if (element != NULL) 103 this->left = dynamic_cast<Weapon*>( Factory::fabricate( element) ); 102 104 if (this->left) 103 105 { … … 112 114 113 115 element = root->FirstChildElement("weapon-right"); 114 if (element != NULL) if (element != NULL) element = element->FirstChildElement(); 115 this->right = dynamic_cast<Weapon*>( Factory::fabricate( element) ); 116 if (element != NULL) 117 element = element->FirstChildElement(); 118 if (element != NULL) 119 this->right = dynamic_cast<Weapon*>( Factory::fabricate( element) ); 116 120 if (this->right) 117 121 { … … 132 136 */ 133 137 void SpaceTurret::setWeaponLeft(const std::string& wLeft) 134 { 135 136 } 138 {} 137 139 138 140 /** … … 150 152 { 151 153 if(this->getHealth() > 0.0f && State::getPlayer() && 152 State::getPlayer()->getPlayable() &&153 State::getPlayer()->getPlayable()->distance(this) < 300) // HACK154 { 155 if (likely(this->left != NULL))156 {157 // this->left->tickW(dt);158 this->left->requestAction(WA_SHOOT);159 }160 if (likely(this->right != NULL))161 {162 // this->right->tickW(dt);163 this->right->requestAction(WA_SHOOT);164 }154 State::getPlayer()->getPlayable() && 155 State::getPlayer()->getPlayable()->distance(this) < 300) // HACK 156 { 157 if (likely(this->left != NULL)) 158 { 159 // this->left->tickW(dt); 160 this->left->requestAction(WA_SHOOT); 161 } 162 if (likely(this->right != NULL)) 163 { 164 // this->right->tickW(dt); 165 this->right->requestAction(WA_SHOOT); 166 } 165 167 } 166 168 } … … 183 185 this->getModel(3)->draw(); 184 186 glPopMatrix(); 185 /*186 if (this->left != NULL)187 this->left->draw();188 if (this->right != NULL)189 this->right->draw();*/187 /* 188 if (this->left != NULL) 189 this->left->draw(); 190 if (this->right != NULL) 191 this->right->draw();*/ 190 192 } 191 193 … … 197 199 */ 198 200 void SpaceTurret::postSpawn () 199 { 200 201 } 201 {} 202 202 203 203 /** … … 206 206 */ 207 207 void SpaceTurret::leftWorld () 208 { 209 210 } 208 {} 211 209 212 210 void SpaceTurret::destroy(WorldEntity* killer) -
trunk/src/world_entities/npcs/space_turret.h
r9656 r9869 18 18 class SpaceTurret : public NPC 19 19 { 20 ObjectListDeclaration(SpaceTurret); 20 21 21 22 public: -
trunk/src/world_entities/planet.cc
r9406 r9869 30 30 #include "primitive_model.h" 31 31 32 #include "debug.h" 32 33 33 34 35 CREATE_FACTORY(Planet, CL_PLANET); 36 34 #include "class_id_DEPRECATED.h" 35 ObjectListDefinitionID(Planet, CL_PLANET); 36 CREATE_FACTORY(Planet); 37 37 38 38 … … 42 42 Planet::Planet(const TiXmlElement* root) 43 43 { 44 this-> setClassID(CL_PLANET, "Planet");44 this->registerObject(this, Planet::_objectList); 45 45 this->toList(OM_GROUP_01); 46 46 -
trunk/src/world_entities/planet.h
r7221 r9869 16 16 class Planet : public WorldEntity 17 17 { 18 ObjectListDeclaration(Planet); 19 18 20 public: 19 21 Planet(const TiXmlElement* root); -
trunk/src/world_entities/playable.cc
r9656 r9869 30 30 #include "game_rules.h" 31 31 32 #include " dot_emitter.h"33 #include " sprite_particles.h"32 #include "particles/dot_emitter.h" 33 #include "particles/sprite_particles.h" 34 34 35 35 #include "shared_network_data.h" … … 41 41 SHELL_COMMAND_STATIC(orxoWeapon, Playable, Playable::addSomeWeapons_CHEAT) 42 42 ->setAlias("orxoWeapon"); 43 43 ObjectListDefinition(Playable); 44 44 45 45 Playable::Playable() … … 48 48 playmode(Playable::Full3D) 49 49 { 50 this-> setClassID(CL_PLAYABLE, "Playable");50 this->registerObject(this, Playable::_objectList); 51 51 PRINTF(4)("PLAYABLE INIT\n"); 52 52 … … 109 109 bool Playable::pickup(PowerUp* powerUp) 110 110 { 111 if(powerUp->isA(CL_WEAPON_POWER_UP)) 112 { 113 return dynamic_cast<WeaponPowerUp*>(powerUp)->process(&this->getWeaponManager()); 114 } 115 else if(powerUp->isA(CL_PARAM_POWER_UP)) 116 { 117 ParamPowerUp* ppu = dynamic_cast<ParamPowerUp*>(powerUp); 111 /// FIXME TOTALLY 112 if(powerUp->isA(WeaponPowerUp::staticClassID())) 113 { 114 return static_cast<WeaponPowerUp*>(powerUp)->process(&this->getWeaponManager()); 115 } 116 else if(powerUp->isA(ParamPowerUp::staticClassID())) 117 { 118 ParamPowerUp* ppu = static_cast<ParamPowerUp*>(powerUp); 118 119 switch(ppu->getType()) 119 120 { … … 213 214 { 214 215 PRINTF(2)("ADDING WEAPONS - you cheater\n"); 215 playable->addWeapon(Weapon::createWeapon( CL_HYPERBLASTER));216 playable->addWeapon(Weapon::createWeapon( CL_TURRET));217 playable->addWeapon(Weapon::createWeapon( CL_AIMING_TURRET));218 playable->addWeapon(Weapon::createWeapon( CL_CANNON));219 playable->addWeapon(Weapon::createWeapon( CL_TARGETING_TURRET));216 playable->addWeapon(Weapon::createWeapon("Hyperblaster")); 217 playable->addWeapon(Weapon::createWeapon("Turret")); 218 playable->addWeapon(Weapon::createWeapon("AimingTurret")); 219 playable->addWeapon(Weapon::createWeapon("Cannon")); 220 playable->addWeapon(Weapon::createWeapon("TargetingTurret")); 220 221 PRINTF(2)("ADDING WEAPONS FINISHED\n"); 221 222 } -
trunk/src/world_entities/playable.h
r9656 r9869 27 27 class Playable : public WorldEntity, public Extendable 28 28 { 29 ObjectListDeclaration(Playable); 29 30 public: 30 31 //! Defines the Playmode of an Entity. -
trunk/src/world_entities/player.cc
r9062 r9869 19 19 #include "event_handler.h" 20 20 21 22 #include "class_list.h"23 21 #include "state.h" 24 22 #include "util/hud.h" … … 26 24 #include "debug.h" 27 25 28 26 ObjectListDefinition(Player); 29 27 /** 30 28 * creates a new Player … … 33 31 { 34 32 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 35 this-> setClassID(CL_PLAYER, "Player");33 this->registerObject(this, Player::_objectList); 36 34 37 35 PRINTF(4)("PLAYER INIT\n"); … … 94 92 95 93 96 97 98 99 94 void Player::weaponConfigChanged() 95 { 96 this->_hud.updateWeaponManager(); 97 } 100 98 101 99 … … 103 101 { 104 102 /// FIXME this should be in the ObjectManager 105 const std::list<BaseObject*>* objectList = ClassList::getList(CL_PLAYABLE); 106 if (objectList != NULL) 103 for (ObjectList<Playable>::const_iterator node = Playable::objectList().begin(); 104 node != Playable::objectList().end(); 105 ++node) 107 106 { 108 std::list<BaseObject*>::const_iterator node; 109 for (node = objectList->begin(); node != objectList->end(); node++) 110 if (this->playable != (*node) && 111 (dynamic_cast<PNode*>(*node)->getAbsCoor() - this->playable->getAbsCoor()).len() < (dynamic_cast<Playable*>(*node)->getEnterRadius())) 112 { 107 if (this->playable != (*node) && 108 ((*node)->getAbsCoor() - this->playable->getAbsCoor()).len() < ((*node)->getEnterRadius())) 109 { 113 110 114 this->setPlayable(dynamic_cast<Playable*>(*node));111 this->setPlayable(*(node)); 115 112 116 117 113 break; 114 } 118 115 } 119 116 } -
trunk/src/world_entities/player.h
r9061 r9869 23 23 class Player : public EventListener 24 24 { 25 ObjectListDeclaration(Player); 25 26 26 27 public: … … 31 32 bool eject(); 32 33 inline Playable* getPlayable() const { return this->playable; }; 33 34 34 35 35 36 inline Hud& hud() { return this->_hud; }; -
trunk/src/world_entities/power_ups/laser_power_up.cc
r9406 r9869 24 24 25 25 26 27 CREATE_FACTORY(LaserPowerUp, CL_LASER_POWER_UP); 26 #include "class_id_DEPRECATED.h" 27 ObjectListDefinitionID(LaserPowerUp, CL_LASER_POWER_UP); 28 CREATE_FACTORY(LaserPowerUp); 28 29 29 30 LaserPowerUp::LaserPowerUp () : PowerUp(0.0, 1.0, 0.0) … … 49 50 void LaserPowerUp::init() 50 51 { 51 this-> setClassID(CL_LASER_POWER_UP, "LaserPowerUp");52 this->registerObject(this, LaserPowerUp::_objectList); 52 53 this->loadModel("models/guns/test_gun.obj", 2.0); 53 54 -
trunk/src/world_entities/power_ups/laser_power_up.h
r7954 r9869 13 13 14 14 class LaserPowerUp : public PowerUp { 15 ObjectListDeclaration(LaserPowerUp); 15 16 16 17 public: … … 22 23 23 24 24 virtual void LaserPowerUp::collidesWith(WorldEntity* entity, const Vector& location);25 virtual void collidesWith(WorldEntity* entity, const Vector& location); 25 26 virtual void tick(float dt); 26 27 virtual void draw() const; -
trunk/src/world_entities/power_ups/param_power_up.cc
r9656 r9869 27 27 28 28 29 30 CREATE_FACTORY(ParamPowerUp, CL_PARAM_POWER_UP); 29 #include "class_id_DEPRECATED.h" 30 ObjectListDefinitionID(ParamPowerUp, CL_PARAM_POWER_UP); 31 CREATE_FACTORY(ParamPowerUp); 31 32 32 33 const char* ParamPowerUp::paramTypes[] = { … … 58 59 void ParamPowerUp::init() 59 60 { 60 this-> setClassID(CL_PARAM_POWER_UP, "ParamPowerUp");61 this->registerObject(this, ParamPowerUp::_objectList); 61 62 this->value = 0; 62 63 this->max_value = 0; -
trunk/src/world_entities/power_ups/param_power_up.h
r7954 r9869 20 20 21 21 class ParamPowerUp : public PowerUp { 22 ObjectListDeclaration(ParamPowerUp); 22 23 23 24 public: -
trunk/src/world_entities/power_ups/power_up.cc
r9406 r9869 21 21 #include "primitive_model.h" 22 22 23 #include " util/loading/resource_manager.h"23 #include "sound/resource_sound_buffer.h" 24 24 #include "util/loading/load_param.h" 25 25 26 #include "debug.h" 26 27 28 ObjectListDefinition(PowerUp); 27 29 28 30 PowerUp::PowerUp(float r, float g, float b) 29 31 { 30 this-> setClassID(CL_POWER_UP, "PowerUp");32 this->registerObject(this, PowerUp::_objectList); 31 33 32 34 this->respawnType = RESPAWN_TIME; … … 45 47 46 48 this->soundSource.setSourceNode(this); 47 this->pickupBuffer = NULL;48 this->respawnBuffer = NULL;49 49 50 50 this->collider = NULL; … … 54 54 { 55 55 delete this->sphereMaterial; 56 if (this->pickupBuffer != NULL)57 ResourceManager::getInstance()->unload(this->pickupBuffer);58 if (this->respawnBuffer != NULL)59 ResourceManager::getInstance()->unload(this->respawnBuffer);60 56 } 61 57 … … 77 73 void PowerUp::loadPickupSound(const std::string& pickupSound) 78 74 { 79 if (this->pickupBuffer != NULL) 80 ResourceManager::getInstance()->unload(this->pickupBuffer); 81 82 else if (!pickupSound.empty()) 83 { 84 this->pickupBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(pickupSound, WAV); 85 if (this->pickupBuffer != NULL) 86 { 87 PRINTF(4)("Loaded sound %s to Pickup: %s.\n", pickupSound.c_str(), this->getCName()); 88 } 89 else 90 { 91 PRINTF(2)("Failed to load sound %s to pickup %s.\n.", pickupSound.c_str(), this->getCName()); 92 } 93 } 75 if (!pickupSound.empty()) 76 this->pickupBuffer = OrxSound::ResourceSoundBuffer(pickupSound); 94 77 else 95 this->pickupBuffer = NULL;78 this->pickupBuffer = OrxSound::SoundBuffer(); 96 79 } 97 80 98 81 void PowerUp::loadRespawnSound(const std::string& respawnSound) 99 82 { 100 if (this->respawnBuffer != NULL) 101 ResourceManager::getInstance()->unload(this->respawnBuffer); 102 103 else if (!respawnSound.empty()) 104 { 105 this->respawnBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(respawnSound, WAV); 106 if (this->respawnBuffer != NULL) 107 { 108 PRINTF(4)("Loaded sound %s to Pickup: %s.\n", respawnSound.c_str(), this->getCName()); 109 } 110 else 111 { 112 PRINTF(2)("Failed to load sound %s to respawn %s.\n.", respawnSound.c_str(), this->getCName()); 113 } 114 } 83 if (!respawnSound.empty()) 84 this->respawnBuffer = OrxSound::ResourceSoundBuffer(respawnSound); 115 85 else 116 this->respawnBuffer = NULL;86 this->respawnBuffer = OrxSound::SoundBuffer(); 117 87 } 118 88 … … 120 90 void PowerUp::collidesWith (WorldEntity* entity, const Vector& location) 121 91 { 122 if(this->collider != entity && entity->isA( CL_EXTENDABLE))92 if(this->collider != entity && entity->isA(Extendable::staticClassID())) 123 93 { 124 94 this->collider = entity; 125 95 if(dynamic_cast<Extendable*>(entity)->pickup(this)) 126 96 { 127 if(pickupBuffer != NULL)97 if(pickupBuffer.loaded()) 128 98 this->soundSource.play(this->pickupBuffer); 129 99 … … 154 124 this->toList(OM_COMMON); 155 125 this->collider = NULL; 156 if (likely(this->respawnBuffer != NULL))126 if (likely(this->respawnBuffer.loaded())) 157 127 this->soundSource.play(this->respawnBuffer); 158 128 -
trunk/src/world_entities/power_ups/power_up.h
r7954 r9869 21 21 22 22 class PowerUp : public WorldEntity { 23 ObjectListDeclaration(PowerUp); 23 24 24 25 public: … … 43 44 private: 44 45 OrxSound::SoundSource soundSource; 45 OrxSound::SoundBuffer *pickupBuffer;46 OrxSound::SoundBuffer *respawnBuffer;46 OrxSound::SoundBuffer pickupBuffer; 47 OrxSound::SoundBuffer respawnBuffer; 47 48 Material* sphereMaterial; 48 49 PowerUpRespawn respawnType; -
trunk/src/world_entities/power_ups/turret_power_up.cc
r9406 r9869 24 24 25 25 26 27 CREATE_FACTORY(TurretPowerUp, CL_TURRET_POWER_UP); 26 #include "class_id_DEPRECATED.h" 27 ObjectListDefinitionID(TurretPowerUp, CL_TURRET_POWER_UP); 28 CREATE_FACTORY(TurretPowerUp); 28 29 29 30 TurretPowerUp::TurretPowerUp(const TiXmlElement* root) : PowerUp(0.0, 1.0, 0.0) … … 45 46 void TurretPowerUp::init() 46 47 { 47 this-> setClassID(CL_TURRET_POWER_UP, "TurretPowerUp");48 this->registerObject(this, TurretPowerUp::_objectList); 48 49 this->loadModel("models/guns/turret1.obj", 2.0); 49 50 -
trunk/src/world_entities/power_ups/turret_power_up.h
r7954 r9869 13 13 14 14 class TurretPowerUp : public PowerUp { 15 ObjectListDeclaration(TurretPowerUp); 15 16 16 17 public: … … 20 21 virtual void loadParams(const TiXmlElement* root); 21 22 22 virtual void TurretPowerUp::collidesWith(WorldEntity* entity, const Vector& location);23 virtual void collidesWith(WorldEntity* entity, const Vector& location); 23 24 virtual void tick(float dt); 24 25 virtual void draw() const; -
trunk/src/world_entities/power_ups/weapon_power_up.cc
r9406 r9869 25 25 #include "util/loading/factory.h" 26 26 #include "util/loading/load_param.h" 27 #include "debug.h" 27 28 28 29 30 CREATE_FACTORY(WeaponPowerUp , CL_WEAPON_POWER_UP);29 #include "class_id_DEPRECATED.h" 30 ObjectListDefinitionID(WeaponPowerUp, CL_WEAPON_POWER_UP); 31 CREATE_FACTORY(WeaponPowerUp); 31 32 32 33 WeaponPowerUp::WeaponPowerUp(const TiXmlElement* root) : PowerUp(1.0, 1.0, 0.0) … … 45 46 void WeaponPowerUp::init() 46 47 { 47 this-> setClassID(CL_WEAPON_POWER_UP, "WeaponPowerUp");48 this->registerObject(this, WeaponPowerUp::_objectList); 48 49 this->loadPickupSound("sound/powerups/whats this2.wav"); 49 50 … … 87 88 { 88 89 this->weapon = dynamic_cast<Weapon*>((weaponXML == NULL) 89 ? Factory::fabricate( static_cast<ClassID>(this->weapon->getLeafClassID()))90 ? Factory::fabricate((this->weapon->getClassID())) 90 91 : Factory::fabricate((const TiXmlElement*)this->getXmlElem()->FirstChildElement("weapon"))); 91 92 this->model = this->weapon->getModel(0); -
trunk/src/world_entities/power_ups/weapon_power_up.h
r7954 r9869 14 14 15 15 class WeaponPowerUp : public PowerUp { 16 16 ObjectListDeclaration(WeaponPowerUp); 17 17 public: 18 18 WeaponPowerUp(const TiXmlElement* root = NULL); -
trunk/src/world_entities/projectiles/bomb.cc
r8362 r9869 20 20 #include "primitive_model.h" 21 21 22 #include " dot_emitter.h"23 #include "particle _system.h"22 #include "particles/dot_emitter.h" 23 #include "particles/particle_system.h" 24 24 25 25 #include "debug.h" 26 26 27 CREATE_FAST_FACTORY_STATIC(Bomb, CL_BOMB); 27 #include "class_id_DEPRECATED.h" 28 ObjectListDefinitionID(Bomb, CL_BOMB); 29 CREATE_FAST_FACTORY_STATIC(Bomb); 28 30 29 31 /** … … 67 69 void Bomb::init() 68 70 { 69 this-> setClassID(CL_BOMB, "Bomb");71 this->registerObject(this, Bomb::_objectList); 70 72 71 73 … … 173 175 } 174 176 177 175 178 void Bomb::deactivate() 176 179 { … … 182 185 void Bomb::detonate(float size) 183 186 { 184 ObjectManager::EntityList detonationList; 185 ObjectManager::distanceFromObject(detonationList, *this, size, CL_NPC); 187 /// FIXME 188 /* ObjectManager::EntityList detonationList; 189 ObjectManager::distanceFromObject(detonationList, *this, size, NPC::objectList()); 186 190 while( !detonationList.empty() ) 187 191 { 188 192 detonationList.front()->collidesWith(this, Vector(0,0,0)); 189 193 detonationList.pop_front(); 190 } 194 }*/ 191 195 } -
trunk/src/world_entities/projectiles/bomb.h
r6622 r9869 17 17 class Bomb : public Projectile 18 18 { 19 19 ObjectListDeclaration(Bomb); 20 20 public: 21 21 Bomb(const TiXmlElement* root = NULL); -
trunk/src/world_entities/projectiles/boomerang_projectile.cc
r9235 r9869 20 20 21 21 #include "state.h" 22 #include "class_list.h" 23 24 #include "dot_emitter.h" 25 #include "sprite_particles.h" 22 23 #include "particles/dot_emitter.h" 24 #include "particles/sprite_particles.h" 26 25 27 26 #include "debug.h" 28 27 29 CREATE_FAST_FACTORY_STATIC(BoomerangProjectile, CL_BOOMERANG_PROJECTILE); 28 #include "class_id_DEPRECATED.h" 29 ObjectListDefinitionID(BoomerangProjectile, CL_BOOMERANG_PROJECTILE); 30 CREATE_FAST_FACTORY_STATIC(BoomerangProjectile); 30 31 31 32 /** … … 34 35 BoomerangProjectile::BoomerangProjectile () : Projectile() 35 36 { 36 this-> setClassID(CL_BOOMERANG_PROJECTILE, "BoomerangProjectile");37 this->registerObject(this, BoomerangProjectile::_objectList); 37 38 38 39 this->loadModel("models/projectiles/orx-rocket.obj", 2.0); … … 60 61 61 62 /* this is normaly done by World.cc by deleting the ParticleEngine */ 62 if (BoomerangProjectile::trailParticles != NULL && ClassList::getList(CL_BOOMERANG_PROJECTILE)->size() <= 1)63 { 64 if ( ClassList::exists(BoomerangProjectile::trailParticles, CL_PARTICLE_SYSTEM))63 if (BoomerangProjectile::trailParticles != NULL && BoomerangProjectile::objectList().size() <= 1) 64 { 65 if (ParticleSystem::objectList().exists(BoomerangProjectile::trailParticles)) 65 66 delete BoomerangProjectile::trailParticles; 66 67 BoomerangProjectile::trailParticles = NULL; 67 68 } 68 if (BoomerangProjectile::explosionParticles != NULL && ClassList::getList(CL_BOOMERANG_PROJECTILE)->size() <= 1)69 { 70 if ( ClassList::exists(BoomerangProjectile::explosionParticles, CL_PARTICLE_SYSTEM))69 if (BoomerangProjectile::explosionParticles != NULL && BoomerangProjectile::objectList().size() <= 1) 70 { 71 if (ParticleSystem::objectList().exists(BoomerangProjectile::explosionParticles)) 71 72 delete BoomerangProjectile::explosionParticles; 72 73 BoomerangProjectile::explosionParticles = NULL; -
trunk/src/world_entities/projectiles/boomerang_projectile.h
r9235 r9869 17 17 class BoomerangProjectile : public Projectile 18 18 { 19 ObjectListDeclaration(BoomerangProjectile); 19 20 public: 20 21 BoomerangProjectile (); -
trunk/src/world_entities/projectiles/guided_missile.cc
r9298 r9869 19 19 20 20 #include "state.h" 21 #include "class_list.h" 22 23 #include "dot_emitter.h" 24 #include "sprite_particles.h" 21 22 #include "particles/dot_emitter.h" 23 #include "particles/sprite_particles.h" 25 24 26 25 #include "debug.h" 27 26 28 CREATE_FAST_FACTORY_STATIC(GuidedMissile, CL_GUIDED_MISSILE); 27 #include "class_id_DEPRECATED.h" 28 ObjectListDefinitionID(GuidedMissile, CL_GUIDED_MISSILE); 29 CREATE_FAST_FACTORY_STATIC(GuidedMissile); 29 30 30 31 /** … … 33 34 GuidedMissile::GuidedMissile () : Projectile() 34 35 { 35 this-> setClassID(CL_GUIDED_MISSILE, "GuidedMissile");36 this->registerObject(this, GuidedMissile::_objectList); 36 37 37 38 this->loadModel("models/projectiles/orx-rocket.obj", 2.0); … … 59 60 60 61 /* this is normaly done by World.cc by deleting the ParticleEngine */ 61 if (GuidedMissile::trailParticles != NULL && ClassList::getList(CL_GUIDED_MISSILE)->size() <= 1)62 { 63 if ( ClassList::exists(GuidedMissile::trailParticles, CL_PARTICLE_SYSTEM))62 if (GuidedMissile::trailParticles != NULL && GuidedMissile::objectList().size() <= 1) 63 { 64 if (ParticleSystem::objectList().exists(GuidedMissile::trailParticles)) 64 65 delete GuidedMissile::trailParticles; 65 66 GuidedMissile::trailParticles = NULL; 66 67 } 67 if (GuidedMissile::explosionParticles != NULL && ClassList::getList(CL_GUIDED_MISSILE)->size() <= 1)68 { 69 if ( ClassList::exists(GuidedMissile::explosionParticles, CL_PARTICLE_SYSTEM))68 if (GuidedMissile::explosionParticles != NULL && GuidedMissile::objectList().size() <= 1) 69 { 70 if (ParticleSystem::objectList().exists(GuidedMissile::explosionParticles)) 70 71 delete GuidedMissile::explosionParticles; 71 72 GuidedMissile::explosionParticles = NULL; -
trunk/src/world_entities/projectiles/guided_missile.h
r9656 r9869 16 16 class GuidedMissile : public Projectile 17 17 { 18 ObjectListDeclaration(GuidedMissile); 18 19 public: 19 20 GuidedMissile (); -
trunk/src/world_entities/projectiles/hyperblast.cc
r9235 r9869 19 19 20 20 #include "state.h" 21 #include "class_list.h"22 21 23 #include " box_emitter.h"24 #include " spark_particles.h"22 #include "particles/box_emitter.h" 23 #include "particles/spark_particles.h" 25 24 26 25 #include "debug.h" 27 26 28 CREATE_FAST_FACTORY_STATIC(Hyperblast, CL_HYPERBLAST); 27 #include "class_id_DEPRECATED.h" 28 ObjectListDefinitionID(Hyperblast, CL_HYPERBLAST); 29 CREATE_FAST_FACTORY_STATIC(Hyperblast); 30 29 31 30 32 /** … … 33 35 Hyperblast::Hyperblast () : Projectile() 34 36 { 35 this-> setClassID(CL_HYPERBLAST, "Hyperblast");37 this->registerObject(this, Hyperblast::_objectList); 36 38 37 39 this->loadModel("models/projectiles/hyperblast.obj", 5); … … 55 57 { 56 58 /* this is normaly done by World.cc by deleting the ParticleEngine */ 57 if (Hyperblast::explosionParticles != NULL && ClassList::getList(CL_HYPERBLAST)->size() <= 1)59 if (Hyperblast::explosionParticles != NULL && Hyperblast::objectList().size() <= 1) 58 60 { 59 61 Hyperblast::explosionParticles = NULL; -
trunk/src/world_entities/projectiles/hyperblast.h
r9235 r9869 17 17 class Hyperblast : public Projectile 18 18 { 19 ObjectListDeclaration(Hyperblast); 19 20 public: 20 21 Hyperblast (); -
trunk/src/world_entities/projectiles/laser.cc
r9656 r9869 19 19 20 20 #include "state.h" 21 #include "class_list.h"22 21 #include "model.h" 23 22 24 #include " dot_emitter.h"25 #include " sprite_particles.h"23 #include "particles/dot_emitter.h" 24 #include "particles/sprite_particles.h" 26 25 27 26 #include <cassert> … … 29 28 30 29 31 32 CREATE_FAST_FACTORY_STATIC(Laser, CL_LASER); 30 #include "class_id_DEPRECATED.h" 31 ObjectListDefinition(Laser); 32 CREATE_FAST_FACTORY_STATIC(Laser); 33 33 34 34 /** … … 37 37 Laser::Laser () : Projectile() 38 38 { 39 this-> setClassID(CL_LASER, "Laser");39 this->registerObject(this, Laser::_objectList); 40 40 41 41 this->loadModel("models/projectiles/laser.obj"); … … 61 61 62 62 /* this is normaly done by World.cc by deleting the ParticleEngine */ 63 if (Laser::explosionParticles != NULL && ClassList::getList(CL_LASER)->size() <= 1)63 if (Laser::explosionParticles != NULL && Laser::objectList().size() <= 1) 64 64 { 65 65 //if (ClassList::exists(Laser::explosionParticles, CL_PARTICLE_SYSTEM)) -
trunk/src/world_entities/projectiles/laser.h
r9235 r9869 17 17 class Laser : public Projectile 18 18 { 19 ObjectListDeclaration(Laser); 19 20 public: 20 21 Laser (); -
trunk/src/world_entities/projectiles/projectile.cc
r9656 r9869 22 22 #include "world_entities/weapons/weapon.h" 23 23 #include "model.h" 24 #include " util/loading/resource_manager.h"24 #include "sound/resource_sound_buffer.h" 25 25 26 26 #include "debug.h" 27 27 28 ObjectListDefinition(Projectile); 28 29 29 30 /** … … 32 33 Projectile::Projectile () : WorldEntity() 33 34 { 34 this-> setClassID(CL_PROJECTILE, "Projectile");35 this->registerObject(this, Projectile::_objectList); 35 36 36 37 this->lifeCycle = 0.0; … … 43 44 this->setDamage(1.0f); // default damage of a projectile set to 100.0 damage points 44 45 45 this->explosionBuffer = NULL;46 this->engineBuffer = NULL;47 48 46 //this->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 49 47 } … … 55 53 Projectile::~Projectile () 56 54 { 57 if (this->explosionBuffer != NULL)58 ResourceManager::getInstance()->unload(this->explosionBuffer);59 if (this->engineBuffer != NULL)60 ResourceManager::getInstance()->unload(this->engineBuffer);61 55 /* 62 56 do not delete the test projectModel, since it is pnode … … 69 63 void Projectile::loadExplosionSound(const std::string& explosionSound) 70 64 { 71 if (this->explosionBuffer != NULL) 72 ResourceManager::getInstance()->unload(this->explosionBuffer); 73 74 else if (!explosionSound.empty()) 75 { 76 this->explosionBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(explosionSound, WAV); 77 if (this->explosionBuffer != NULL) 78 { 79 PRINTF(4)("Loaded sound %s to Pickup: %s.\n", explosionSound.c_str(), this->getCName()); 80 } 81 else 82 { 83 PRINTF(2)("Failed to load sound %s to explosion %s.\n.", explosionSound.c_str(), this->getCName()); 84 } 85 } 65 if (!explosionSound.empty()) 66 this->explosionBuffer = OrxSound::ResourceSoundBuffer(explosionSound); 86 67 else 87 this->explosionBuffer = NULL;68 this->explosionBuffer = OrxSound::SoundBuffer(); 88 69 } 89 70 … … 91 72 void Projectile::loadEngineSound(const std::string& engineSound) 92 73 { 93 if (this->engineBuffer != NULL) 94 ResourceManager::getInstance()->unload(this->engineBuffer); 95 96 else if (!engineSound.empty()) 97 { 98 this->engineBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(engineSound, WAV); 99 if (this->engineBuffer != NULL) 100 { 101 PRINTF(4)("Loaded sound %s to Pickup: %s.\n", engineSound.c_str(), this->getCName()); 102 } 103 else 104 { 105 PRINTF(2)("Failed to load sound %s to engine %s.\n.", engineSound.c_str(), this->getCName()); 106 } 107 } 74 if (!engineSound.empty()) 75 this->engineBuffer = OrxSound::ResourceSoundBuffer(engineSound); 108 76 else 109 this->engineBuffer = NULL;77 this->engineBuffer = OrxSound::SoundBuffer(); 110 78 } 111 79 … … 139 107 //Vector offsetVel = 140 108 this->velocity = velocity; 141 // offsetVel.normalize();109 // offsetVel.normalize(); 142 110 //this->velocity += (offsetVel * 50.0); 143 111 } … … 148 116 { 149 117 if (this->target == NULL) 150 this->target = new PNode(target, PNODE_ PARENT_MODE_DEFAULT | PNODE_REPARENT_ON_PARENTS_REMOVE);118 this->target = new PNode(target, PNODE_REPARENT_ON_PARENTS_REMOVE | PNODE_REPARENT_TO_NULL | PNODE_PROHIBIT_DELETE_WITH_PARENT); 151 119 else 152 120 this->target->setParent(target); … … 173 141 void Projectile::destroy (WorldEntity* killer) 174 142 { 175 if (this->explosionBuffer != NULL)143 if (this->explosionBuffer.loaded()) 176 144 this->soundSource.play(this->explosionBuffer); 177 145 } -
trunk/src/world_entities/projectiles/projectile.h
r9235 r9869 11 11 12 12 #include "world_entity.h" 13 #include " fast_factory.h"13 #include "loading/fast_factory.h" 14 14 15 15 #include "sound_source.h" … … 18 18 class Projectile : public WorldEntity 19 19 { 20 ObjectListDeclaration(Projectile); 20 21 public: 21 22 Projectile (); … … 66 67 OrxSound::SoundSource soundSource; 67 68 private: 68 OrxSound::SoundBuffer *explosionBuffer;69 OrxSound::SoundBuffer *engineBuffer;69 OrxSound::SoundBuffer explosionBuffer; 70 OrxSound::SoundBuffer engineBuffer; 70 71 }; 71 72 -
trunk/src/world_entities/projectiles/rail_projectile.cc
r9406 r9869 19 19 20 20 #include "state.h" 21 #include "class_list.h"22 21 #include "model.h" 23 22 24 #include " dot_emitter.h"25 #include " sprite_particles.h"23 #include "particles/dot_emitter.h" 24 #include "particles/sprite_particles.h" 26 25 27 26 #include <cassert> … … 29 28 30 29 31 32 CREATE_FAST_FACTORY_STATIC(RailProjectile, CL_RAIL_PROJECTILE); 30 #include "class_id_DEPRECATED.h" 31 ObjectListDefinitionID(RailProjectile, CL_RAIL_PROJECTILE); 32 CREATE_FAST_FACTORY_STATIC(RailProjectile); 33 33 34 34 /** … … 37 37 RailProjectile::RailProjectile () : Projectile() 38 38 { 39 this-> setClassID(CL_RAIL_PROJECTILE, "RailProjectile");39 this->registerObject(this, RailProjectile::_objectList); 40 40 41 this->loadModel("models/projectiles/laser _projectile.obj", 100);41 this->loadModel("models/projectiles/laser.obj", 1); 42 42 43 43 this->setMinEnergy(10); … … 61 61 62 62 /* this is normaly done by World.cc by deleting the ParticleEngine */ 63 if (RailProjectile::explosionParticles != NULL && ClassList::getList(CL_RAIL_PROJECTILE)->size() <= 1)63 if (RailProjectile::explosionParticles != NULL && RailProjectile::objectList().size() <= 1) 64 64 { 65 65 //if (ClassList::exists(RailProjectile::explosionParticles, CL_PARTICLE_SYSTEM)) -
trunk/src/world_entities/projectiles/rail_projectile.h
r9235 r9869 17 17 class RailProjectile : public Projectile 18 18 { 19 ObjectListDeclaration(RailProjectile); 19 20 public: 20 21 RailProjectile (); -
trunk/src/world_entities/projectiles/rocket.cc
r9235 r9869 19 19 20 20 #include "state.h" 21 #include "class_list.h"22 21 23 #include " dot_emitter.h"24 #include " sprite_particles.h"22 #include "particles/dot_emitter.h" 23 #include "particles/sprite_particles.h" 25 24 26 25 #include "debug.h" 27 26 28 CREATE_FAST_FACTORY_STATIC(Rocket, CL_ROCKET); 27 #include "class_id_DEPRECATED.h" 28 ObjectListDefinitionID(Rocket, CL_ROCKET); 29 CREATE_FAST_FACTORY_STATIC(Rocket); 29 30 30 31 /** … … 33 34 Rocket::Rocket () : Projectile() 34 35 { 35 this-> setClassID(CL_ROCKET, "Rocket");36 this->registerObject(this, Rocket::_objectList); 36 37 37 38 this->loadModel("models/projectiles/orx-rocket.obj", .3); … … 55 56 56 57 /* this is normaly done by World.cc by deleting the ParticleEngine */ 57 if (Rocket::trailParticles != NULL && ClassList::getList(CL_ROCKET)->size() <= 1)58 if (Rocket::trailParticles != NULL && Rocket::objectList().size() <= 1) 58 59 { 59 60 /* if (ClassList::exists(Rocket::trailParticles, CL_PARTICLE_SYSTEM)) … … 61 62 Rocket::trailParticles = NULL; 62 63 } 63 if (Rocket::explosionParticles != NULL && ClassList::getList(CL_ROCKET)->size() <= 1)64 if (Rocket::explosionParticles != NULL && Rocket::objectList().size() <= 1) 64 65 { 65 66 /* if (ClassList::exists(Rocket::explosionParticles, CL_PARTICLE_SYSTEM)) -
trunk/src/world_entities/projectiles/rocket.h
r9235 r9869 9 9 #include "projectile.h" 10 10 11 class Vector;12 class Weapon;13 11 class SpriteParticles; 14 12 class ParticleEmitter; … … 17 15 class Rocket : public Projectile 18 16 { 19 public: 20 Rocket (); 21 virtual ~Rocket (); 17 ObjectListDeclaration(Rocket); 18 19 public: 20 Rocket (); 21 virtual ~Rocket (); 22 22 23 23 24 25 24 virtual void activate(); 25 virtual void deactivate(); 26 26 27 27 virtual void collidesWith(WorldEntity* entity, const Vector& location); 28 28 29 29 virtual void destroy (WorldEntity* killer); 30 30 31 32 31 virtual void tick (float time); 32 virtual void draw () const; 33 33 34 34 35 36 37 38 35 private: 36 static FastFactory* fastFactory; 37 static SpriteParticles* trailParticles; 38 static SpriteParticles* explosionParticles; 39 39 40 40 ParticleEmitter* emitter; 41 41 42 42 43 43 WorldEntity* hitEntity; // FIXME TEMPORARY 44 44 45 45 }; -
trunk/src/world_entities/projectiles/test_bullet.cc
r9235 r9869 19 19 20 20 #include "state.h" 21 #include "class_list.h"22 21 23 #include " dot_emitter.h"24 #include " sprite_particles.h"22 #include "particles/dot_emitter.h" 23 #include "particles/sprite_particles.h" 25 24 #include "debug.h" 26 25 27 CREATE_FAST_FACTORY_STATIC(TestBullet, CL_TEST_BULLET); 26 #include "class_id_DEPRECATED.h" 27 ObjectListDefinitionID(TestBullet, CL_TEST_BULLET); 28 CREATE_FAST_FACTORY_STATIC(TestBullet); 28 29 29 30 /** … … 32 33 TestBullet::TestBullet () : Projectile() 33 34 { 34 this-> setClassID(CL_TEST_BULLET, "TestBullet");35 this->registerObject(this, TestBullet::_objectList); 35 36 36 37 this->loadModel("models/projectiles/orx-rocket.obj", .3); … … 54 55 55 56 /* this is normaly done by World.cc by deleting the ParticleEngine */ 56 if (TestBullet::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->size() <= 1)57 if (TestBullet::trailParticles != NULL && TestBullet::objectList().size() <= 1) 57 58 { 58 if ( ClassList::exists(TestBullet::trailParticles, CL_PARTICLE_SYSTEM))59 if (ParticleSystem::objectList().exists(TestBullet::trailParticles)) 59 60 delete TestBullet::trailParticles; 60 61 TestBullet::trailParticles = NULL; 61 62 } 62 if (TestBullet::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->size() <= 1)63 if (TestBullet::explosionParticles != NULL && TestBullet::objectList().size() <= 1) 63 64 { 64 if ( ClassList::exists(TestBullet::explosionParticles, CL_PARTICLE_SYSTEM))65 if (ParticleSystem::objectList().exists(TestBullet::explosionParticles)) 65 66 delete TestBullet::explosionParticles; 66 67 TestBullet::explosionParticles = NULL; -
trunk/src/world_entities/projectiles/test_bullet.h
r9235 r9869 17 17 class TestBullet : public Projectile 18 18 { 19 ObjectListDeclaration(TestBullet); 20 19 21 public: 20 22 TestBullet (); -
trunk/src/world_entities/recorder.cc
r9406 r9869 18 18 #include "util/loading/load_param.h" 19 19 #include "util/loading/factory.h" 20 #include "util/loading/resource_manager.h"21 20 #include "state.h" 22 23 24 25 CREATE_FACTORY(Recorder, CL_RECORDER); 21 #include "debug.h" 22 23 #include "class_id_DEPRECATED.h" 24 ObjectListDefinitionID(Recorder, CL_RECORDER); 25 CREATE_FACTORY(Recorder); 26 26 27 27 28 28 Recorder::Recorder (const TiXmlElement* root) 29 29 { 30 this-> setClassID(CL_RECORDER, "Recorder");30 this->registerObject(this, Recorder::_objectList); 31 31 32 32 // initialize libavcodec, and register all codecs and formats -
trunk/src/world_entities/recorder.h
r7221 r9869 20 20 class Recorder : public WorldEntity 21 21 { 22 ObjectListDeclaration(Recorder); 22 23 public: 23 24 Recorder (const TiXmlElement* root = NULL); -
trunk/src/world_entities/satellite.cc
r9406 r9869 21 21 22 22 #include "objModel.h" 23 #include "vector.h"24 23 25 24 26 25 26 27 ObjectListDefinition(Satellite); 27 28 28 29 /** … … 31 32 Satellite::Satellite (Vector axis, float speed) 32 33 { 33 this-> setClassID(CL_SATELLITE, "Satellite");34 this->registerObject(this, Satellite::_objectList); 34 35 35 36 this->loadModel("cube"); -
trunk/src/world_entities/satellite.h
r7193 r9869 9 9 #include "world_entity.h" 10 10 #include "comincl.h" 11 #include "util/loading/resource_manager.h"12 13 11 14 12 class CharacterAttributes; … … 19 17 class Satellite : public WorldEntity 20 18 { 21 friend class World;19 ObjectListDeclaration(Satellite); 22 20 23 21 public: -
trunk/src/world_entities/script_trigger.cc
r9656 r9869 16 16 17 17 #include "script_trigger.h" 18 #include "class_list.h"19 18 #include "script.h" 20 19 21 20 #include "state.h" 22 23 24 CREATE_SCRIPTABLE_CLASS(ScriptTrigger, CL_SCRIPT_TRIGGER, 21 #include "debug.h" 22 ObjectListDefinition(ScriptTrigger); 23 24 CREATE_SCRIPTABLE_CLASS(ScriptTrigger, 25 25 // Coordinates 26 addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))27 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))28 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))29 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))26 addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) 27 ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) 28 ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 29 ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 30 30 //Properties 31 ->addMethod("setName", ExecutorLua1<BaseObject, const std::string&>(&BaseObject::setName))32 ->addMethod("setTarget", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setTarget))33 ->addMethod("setTriggerParent", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setTriggerParent))34 ->addMethod("setTriggerRemains", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setTriggerRemains))35 ->addMethod("setActiveOnCreation", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setActiveOnCreation))36 ->addMethod("setInvert", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setInvert))37 ->addMethod("setRadius", ExecutorLua1<ScriptTrigger, float>(&ScriptTrigger::setRadius))38 ->addMethod("setScript", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setScript))39 ->addMethod("setFunction", ExecutorLua1<ScriptTrigger, const std::string&>(&ScriptTrigger::setFunction))40 ->addMethod("setDebugDraw", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setDebugDraw))41 ->addMethod("setAddToScript", ExecutorLua1<ScriptTrigger, bool>(&ScriptTrigger::setAddToScript))31 ->addMethod("setName", Executor1<BaseObject, lua_State*, const std::string&>(&BaseObject::setName)) 32 ->addMethod("setTarget", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setTarget)) 33 ->addMethod("setTriggerParent", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setTriggerParent)) 34 ->addMethod("setTriggerRemains", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setTriggerRemains)) 35 ->addMethod("setActiveOnCreation", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setActiveOnCreation)) 36 ->addMethod("setInvert", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setInvert)) 37 ->addMethod("setRadius", Executor1<ScriptTrigger, lua_State*, float>(&ScriptTrigger::setRadius)) 38 ->addMethod("setScript", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setScript)) 39 ->addMethod("setFunction", Executor1<ScriptTrigger, lua_State*, const std::string&>(&ScriptTrigger::setFunction)) 40 ->addMethod("setDebugDraw", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setDebugDraw)) 41 ->addMethod("setAddToScript", Executor1<ScriptTrigger, lua_State*, bool>(&ScriptTrigger::setAddToScript)) 42 42 ); 43 43 … … 49 49 */ 50 50 ScriptTrigger::ScriptTrigger(const TiXmlElement* root) 51 { 52 this-> setClassID(CL_SCRIPT_TRIGGER, "ScriptTrigger");51 { 52 this->registerObject(this, ScriptTrigger::_objectList); 53 53 this->toList(OM_COMMON); 54 54 … … 139 139 void ScriptTrigger::setTarget(const std::string& target) 140 140 { 141 BaseObject* targetEntity = ClassList::getObject(target, CL_WORLD_ENTITY); 142 141 142 WorldEntity* targetEntity = WorldEntity::objectList().getObject(target); 143 143 if (targetEntity != NULL) 144 144 { 145 this->setTarget( dynamic_cast<WorldEntity*>(targetEntity));145 this->setTarget(targetEntity); 146 146 } 147 147 else … … 157 157 void ScriptTrigger::setTriggerParent(const std::string& parent) 158 158 { 159 BaseObject* parentEntity = ClassList::getObject(parent, CL_WORLD_ENTITY);159 WorldEntity* parentEntity = WorldEntity::objectList().getObject(parent); 160 160 161 161 if (parentEntity != NULL) 162 162 { 163 this->setParent( dynamic_cast<WorldEntity*>(parentEntity));163 this->setParent(parentEntity); 164 164 this->setParentMode(PNODE_MOVEMENT); 165 165 } -
trunk/src/world_entities/script_trigger.h
r9298 r9869 18 18 class ScriptTrigger : public WorldEntity 19 19 { 20 ObjectListDeclaration(ScriptTrigger); 20 21 public: 21 22 ScriptTrigger(const TiXmlElement* root = NULL); -
trunk/src/world_entities/skybox.cc
r9656 r9869 27 27 #include "network_game_manager.h" 28 28 #include "converter.h" 29 #include "util/loading/resource_manager.h" 30 31 32 33 34 CREATE_FACTORY(SkyBox, CL_SKYBOX); 29 #include "resource_texture.h" 30 31 #include "debug.h" 32 33 #include "class_id_DEPRECATED.h" 34 ObjectListDefinitionID(SkyBox, CL_SKYBOX); 35 CREATE_FACTORY(SkyBox); 35 36 36 37 /** … … 72 73 void SkyBox::preInit() 73 74 { 74 this-> setClassID(CL_SKYBOX, "SkyBox");75 this->registerObject(this, SkyBox::_objectList); 75 76 this->toList(OM_BACKGROUND); 76 77 this->toReflectionList(); … … 112 113 if (this->material[i]) 113 114 delete this->material[i]; 114 if (this->cubeTexture[i])115 ResourceManager::getInstance()->unload(this->cubeTexture[i]);116 115 } 117 116 } … … 174 173 const std::string& posZ, const std::string& posX, const std::string& negX) 175 174 { 176 this->cubeTexture[0] = (Texture*)ResourceManager::getInstance()->load(negX, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT);177 this->cubeTexture[1] = (Texture*)ResourceManager::getInstance()->load(posX, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT);178 179 this->cubeTexture[2] = (Texture*)ResourceManager::getInstance()->load(negY, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT);180 this->cubeTexture[3] = (Texture*)ResourceManager::getInstance()->load(posY, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT);181 182 this->cubeTexture[4] = (Texture*)ResourceManager::getInstance()->load(negZ, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT);183 this->cubeTexture[5] = (Texture*)ResourceManager::getInstance()->load(posZ, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT);175 this->cubeTexture[0] = ResourceTexture(negX, GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT); 176 this->cubeTexture[1] = ResourceTexture(posX, GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT); 177 178 this->cubeTexture[2] = ResourceTexture(negY, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT); 179 this->cubeTexture[3] = ResourceTexture(posY, GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT); 180 181 this->cubeTexture[4] = ResourceTexture(negZ, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT); 182 this->cubeTexture[5] = ResourceTexture(posZ, GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT); 184 183 } 185 184 -
trunk/src/world_entities/skybox.h
r8619 r9869 27 27 class SkyBox : public WorldEntity 28 28 { 29 public: 29 ObjectListDeclaration(SkyBox); 30 public: 30 31 SkyBox(const std::string& fileName = ""); 31 32 SkyBox(const TiXmlElement* root); … … 64 65 65 66 Material* material[6]; //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back 66 Texture *cubeTexture[6]; //!< Textures for the CubeMap.67 Texture cubeTexture[6]; //!< Textures for the CubeMap. 67 68 68 69 float size; //!< Size of the SkyBox. This should match the frustum maximum range. -
trunk/src/world_entities/skydome.cc
r9406 r9869 23 23 #include "network_game_manager.h" 24 24 #include "converter.h" 25 #include "util/loading/resource_manager.h" 25 26 #include "debug.h" 26 27 27 28 #define DTOR (PI/180.0f) … … 30 31 31 32 33 ObjectListDefinition(Skydome); 32 34 33 35 /** … … 42 44 void Skydome::init() 43 45 { 44 PRINTF( 0)("Skydome init\n");45 46 this-> setClassID(CL_SKYDOME, "Skydome");46 PRINTF(4)("Skydome init\n"); 47 48 this->registerObject(this, Skydome::_objectList); 47 49 this->toList(OM_BACKGROUND); 48 50 this->toReflectionList(); … … 61 63 Skydome::~Skydome() 62 64 { 63 PRINTF( 0)("Deleting Skydome\n");65 PRINTF(4)("Deleting Skydome\n"); 64 66 65 67 if (glIsTexture(texture)) … … 119 121 glEnd(); 120 122 121 WorldEntity::draw(); 123 WorldEntity::draw(); 122 124 123 125 glPopMatrix(); -
trunk/src/world_entities/skydome.h
r9006 r9869 21 21 class Skydome : public WorldEntity 22 22 { 23 ObjectListDeclaration(Skydome); 23 24 public: 24 25 Skydome(); … … 31 32 void generateSkyPlane(int divisions, float planetRadius, float atmosphereRadius, 32 33 float hTile, float vTile); 33 34 34 35 void setShader(Shader* shader); 35 36 void setTexture(GLuint texture); 36 37 37 38 void activate(); 38 39 void deactivate(); 39 40 40 41 private: 41 42 42 43 typedef struct VertexInfo 43 44 { … … 48 49 49 50 bool activateDome; 50 51 51 52 VertexInfo *planeVertices; 52 53 int numPlaneVertices; … … 59 60 VertexInfo *vertices; 60 61 int numVertices; 61 62 62 63 GLuint texture; 63 64 Shader* shader; -
trunk/src/world_entities/skysphere.cc
r9406 r9869 27 27 28 28 #include "skysphere.h" 29 #include "stdincl.h"30 29 31 30 #include "material.h" … … 33 32 34 33 35 34 ObjectListDefinition(Skysphere); 36 35 37 36 /** … … 41 40 Skysphere::Skysphere(char* fileName) 42 41 { 43 this-> setClassID(CL_SKYSPHERE, "SkySphere");42 this->registerObject(this, Skysphere::_objectList); 44 43 this->toList(OM_BACKGROUND); 45 44 if (fileName == NULL) -
trunk/src/world_entities/skysphere.h
r7076 r9869 24 24 class Skysphere : public WorldEntity 25 25 { 26 ObjectListDeclaration(Skysphere); 26 27 27 28 public: -
trunk/src/world_entities/space_ships/collision_probe.cc
r9406 r9869 24 24 25 25 26 #include "class_id_DEPRECATED.h" 27 ObjectListDefinitionID(CollisionProbe, CL_COLLISION_PROBE); 26 28 27 28 CREATE_FACTORY(CollisionProbe, CL_COLLISION_PROBE); 29 CREATE_FACTORY(CollisionProbe); 29 30 30 31 … … 56 57 void CollisionProbe::init() 57 58 { 58 this-> setClassID(CL_COLLISION_PROBE, "CollisionProbe");59 this->registerObject(this, CollisionProbe::_objectList); 59 60 60 61 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false; -
trunk/src/world_entities/space_ships/collision_probe.h
r8490 r9869 13 13 class CollisionProbe : public Playable 14 14 { 15 ObjectListDeclaration(CollisionProbe); 15 16 16 17 public: -
trunk/src/world_entities/space_ships/cruizer.cc
r9235 r9869 29 29 30 30 #include "graphics_engine.h" 31 #include " dot_emitter.h"32 #include " sprite_particles.h"31 #include "particles/dot_emitter.h" 32 #include "particles/sprite_particles.h" 33 33 34 34 #include "debug.h" 35 35 36 CREATE_FACTORY(Cruizer, CL_CRUIZER); 36 #include "class_id_DEPRECATED.h" 37 ObjectListDefinitionID(Cruizer, CL_CRUIZER); 38 CREATE_FACTORY(Cruizer); 37 39 38 40 /** … … 89 91 { 90 92 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 91 this-> setClassID(CL_CRUIZER, "Cruizer");93 this->registerObject(this, Cruizer::_objectList); 92 94 93 95 this->setSupportedPlaymodes(Playable::Full3D); -
trunk/src/world_entities/space_ships/cruizer.h
r9061 r9869 16 16 class Cruizer : public Playable 17 17 { 18 ObjectListDeclaration(Cruizer); 18 19 public: 19 20 Cruizer(const std::string& fileName); -
trunk/src/world_entities/space_ships/helicopter.cc
r9235 r9869 25 25 26 26 #include "util/loading/factory.h" 27 #include " util/loading/resource_manager.h"27 #include "sound/resource_sound_buffer.h" 28 28 29 29 #include "key_mapper.h" … … 34 34 #include "debug.h" 35 35 36 CREATE_FACTORY(Helicopter, CL_HELICOPTER); 36 #include "class_id_DEPRECATED.h" 37 ObjectListDefinitionID(Helicopter, CL_HELICOPTER); 38 CREATE_FACTORY(Helicopter); 37 39 #include "script_class.h" 38 CREATE_SCRIPTABLE_CLASS(Helicopter, CL_HELICOPTER,39 addMethod("moveUp", ExecutorLua1<Helicopter,bool>(&Helicopter::moveUp))40 ->addMethod("moveDown", ExecutorLua1<Helicopter,bool>(&Helicopter::moveDown))41 ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))42 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))43 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))44 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))40 CREATE_SCRIPTABLE_CLASS(Helicopter, 41 addMethod("moveUp", Executor1<Helicopter, lua_State*,bool>(&Helicopter::moveUp)) 42 ->addMethod("moveDown", Executor1<Helicopter, lua_State*,bool>(&Helicopter::moveDown)) 43 ->addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) 44 ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) 45 ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 46 ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 45 47 46 48 ); 47 49 50 48 51 /** 49 52 * creates the controlable Helicopter … … 60 63 { 61 64 this->setPlayer(NULL); 62 63 if (this->chopperBuffer != NULL)64 ResourceManager::getInstance()->unload(this->chopperBuffer);65 65 } 66 66 … … 100 100 Weapon* wpLeft = new TestGun(1); 101 101 wpLeft->setName("testGun Left"); 102 Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate( CL_CANNON));102 Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate("Cannon")); 103 103 104 104 cannon->setName("BFG"); … … 112 112 113 113 //load sound 114 if (this->chopperBuffer != NULL) 115 ResourceManager::getInstance()->unload(this->chopperBuffer); 116 this->chopperBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/engine/chopper.wav", WAV); 114 this->chopperBuffer = OrxSound::ResourceSoundBuffer("sound/engine/chopper.wav"); 117 115 118 116 } … … 124 122 void Helicopter::init() 125 123 { 126 this->chopperBuffer = NULL; 127 128 this->setClassID(CL_HELICOPTER, "Helicopter"); 124 this->registerObject(this, Helicopter::_objectList); 129 125 PRINTF(4)("HELICOPTER INIT\n"); 130 126 -
trunk/src/world_entities/space_ships/helicopter.h
r9235 r9869 17 17 class Helicopter : public Playable 18 18 { 19 ObjectListDeclaration(Helicopter); 19 20 20 21 public: … … 79 80 80 81 OrxSound::SoundSource soundSource; 81 OrxSound::SoundBuffer *chopperBuffer;82 OrxSound::SoundBuffer chopperBuffer; 82 83 83 84 }; -
trunk/src/world_entities/space_ships/hover.cc
r9656 r9869 34 34 #include "debug.h" 35 35 36 CREATE_FACTORY(Hover, CL_HOVER); 36 #include "class_id_DEPRECATED.h" 37 ObjectListDefinitionID(Hover, CL_HOVER); 38 CREATE_FACTORY(Hover); 37 39 38 40 #include "script_class.h" 39 CREATE_SCRIPTABLE_CLASS(Hover, CL_HOVER,40 addMethod("hasPlayer", ExecutorLua0ret<Playable,bool>(&Playable::hasPlayer))41 CREATE_SCRIPTABLE_CLASS(Hover, 42 addMethod("hasPlayer", Executor0ret<Playable, lua_State*,bool>(&Playable::hasPlayer)) 41 43 //Coordinates 42 ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))43 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))44 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))45 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))44 ->addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) 45 ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) 46 ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 47 ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 46 48 ); 47 49 … … 98 100 Weapon* wpLeft = new TestGun(1); 99 101 wpLeft->setName("testGun Left"); 100 Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate( CL_HYPERBLASTER));102 Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate("Hyperblaster")); 101 103 102 104 cannon->setName("BFG"); … … 123 125 124 126 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 125 this-> setClassID(CL_HOVER, "Hover");127 this->registerObject(this, Hover::_objectList); 126 128 this->toReflectionList(); 127 129 -
trunk/src/world_entities/space_ships/hover.h
r9235 r9869 15 15 class Hover : public Playable 16 16 { 17 ObjectListDeclaration(Hover); 17 18 public: 18 19 -
trunk/src/world_entities/space_ships/space_ship.cc
r9656 r9869 26 26 #include "weapons/cannon.h" 27 27 28 #include " dot_emitter.h"29 #include " sprite_particles.h"28 #include "particles/dot_emitter.h" 29 #include "particles/sprite_particles.h" 30 30 31 31 #include "util/loading/factory.h" … … 53 53 54 54 55 56 CREATE_FACTORY(SpaceShip, CL_SPACE_SHIP); 55 #include "class_id_DEPRECATED.h" 56 ObjectListDefinitionID(SpaceShip, CL_SPACE_SHIP); 57 CREATE_FACTORY(SpaceShip); 58 57 59 #include "script_class.h" 58 CREATE_SCRIPTABLE_CLASS(SpaceShip, CL_SPACE_SHIP,59 addMethod("hasPlayer", Executor Lua0ret<Playable,bool>(&Playable::hasPlayer))60 ->addMethod("fire", Executor Lua1<Playable, bool>(&Playable::fire))61 ->addMethod("loadModel", Executor Lua2<WorldEntity,const std::string& ,float>(&WorldEntity::loadModel2))62 ->addMethod("setName", Executor Lua1<BaseObject,const std::string&>(&BaseObject::setName))63 ->addMethod("hide", Executor Lua0<WorldEntity>(&WorldEntity::hide))64 ->addMethod("unhide", Executor Lua0<WorldEntity>(&WorldEntity::unhide))65 //Coordinates66 ->addMethod("setAbsCoor", Executor Lua3<PNode,float,float,float>(&PNode::setAbsCoor))67 ->addMethod("getAbsCoorX", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorX))68 ->addMethod("getAbsCoorY", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorY))69 ->addMethod("getAbsCoorZ", Executor Lua0ret<PNode, float>(&PNode::getAbsCoorZ))60 CREATE_SCRIPTABLE_CLASS(SpaceShip, 61 addMethod("hasPlayer", Executor0ret<Playable, lua_State*,bool>(&Playable::hasPlayer)) 62 ->addMethod("fire", Executor1<Playable, lua_State*, bool>(&Playable::fire)) 63 ->addMethod("loadModel", Executor2<WorldEntity, lua_State*,const std::string& ,float>(&WorldEntity::loadModel2)) 64 ->addMethod("setName", Executor1<BaseObject, lua_State*,const std::string&>(&BaseObject::setName)) 65 ->addMethod("hide", Executor0<WorldEntity, lua_State*>(&WorldEntity::hide)) 66 ->addMethod("unhide", Executor0<WorldEntity, lua_State*>(&WorldEntity::unhide)) 67 //Coordinates 68 ->addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) 69 ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) 70 ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 71 ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 70 72 ); 71 73 … … 116 118 void SpaceShip::init() 117 119 { 118 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));119 this-> setClassID(CL_SPACE_SHIP, "SpaceShip");120 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 121 this->registerObject(this, SpaceShip::_objectList); 120 122 121 123 PRINTF(4)("SPACESHIP INIT\n"); … … 145 147 controlVelocityY = 150; 146 148 shipInertia = 1.5; 147 // cycle = 0.0;149 // cycle = 0.0; 148 150 149 151 this->setHealthMax(100); … … 156 158 this->pitchDir = this->getAbsDir(); 157 159 158 // GLGuiButton* button = new GLGuiPushButton();159 // button->show();160 // button->setLabel("orxonox");161 // button->setBindNode(this);162 // GLGuiBar* bar = new GLGuiBar();163 // bar->show();164 // bar->setValue(7.0);165 // bar->setMaximum(10);166 // bar->setSize2D( 20, 100);167 // bar->setAbsCoor2D( 10, 200);160 // GLGuiButton* button = new GLGuiPushButton(); 161 // button->show(); 162 // button->setLabel("orxonox"); 163 // button->setBindNode(this); 164 // GLGuiBar* bar = new GLGuiBar(); 165 // bar->show(); 166 // bar->setValue(7.0); 167 // bar->setMaximum(10); 168 // bar->setSize2D( 20, 100); 169 // bar->setAbsCoor2D( 10, 200); 168 170 169 171 //add events to the eventlist … … 200 202 this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5)); 201 203 this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0))); 202 //203 204 205 206 // this->getWeaponManager().setSlotPosition(8, Vector(-2.5, -0.3, -2.0));207 // this->getWeaponManager().setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));208 //209 // this->getWeaponManager().setSlotPosition(9, Vector(-2.5, -0.3, 2.0));210 // this->getWeaponManager().setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:204 // 205 this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0)); 206 this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 207 // 208 // this->getWeaponManager().setSlotPosition(8, Vector(-2.5, -0.3, -2.0)); 209 // this->getWeaponManager().setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0))); 210 // 211 // this->getWeaponManager().setSlotPosition(9, Vector(-2.5, -0.3, 2.0)); 212 // this->getWeaponManager().setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));: 211 213 212 214 this->getWeaponManager().getFixedTarget()->setParent(this); … … 310 312 void SpaceShip::collidesWith(WorldEntity* entity, const Vector& location) 311 313 { 312 313 314 } 314 315 … … 332 333 333 334 if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() ) 334 335 { 335 336 if (xMouse > controlVelocityX) xMouse = controlVelocityX; 336 337 else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX; … … 342 343 mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity*yInvert, Vector(0,0,1))*pitchDir); 343 344 xMouse = yMouse = 0; 344 345 346 347 // if( this != State::getPlayer()->getControllable())348 // return;345 } 346 347 348 // if( this != State::getPlayer()->getControllable()) 349 // return; 349 350 350 351 // spaceship controlled movement fire(bool bF){ this->bFire = bF;} 351 352 //if (this->getOwner() == this->getHostID()) 352 353 this->calculateVelocity(time); 353 354 354 355 … … 363 364 364 365 //orient the spaceship in direction of the mouse 365 366 366 rotQuat = Quaternion::quatSlerp( this->getAbsDir(), mouseDir, 0.5);//fabsf(time)*shipInertia); 367 if (this->getAbsDir().distance(rotQuat) > 0.00000000000001) 367 368 this->setAbsDir( rotQuat); 368 369 //this->setAbsDirSoft(mouseDir,5); 369 370 370 371 // this is the air friction (necessary for a smooth control) … … 388 389 this->shiftCoor(move); 389 390 390 // PRINTF(0)("id of %s is: %i\n", this->getName(), this->getOMListNumber());391 // PRINTF(0)("id of %s is: %i\n", this->getName(), this->getOMListNumber()); 391 392 392 393 } … … 409 410 410 411 if( this->bUp ) 411 412 413 414 415 416 412 { 413 //this->shiftCoor(this->getAbsDirX()); 414 //accel += (this->getAbsDirX())*2; 415 accel += (this->getAbsDirX())*acceleration; 416 417 } 417 418 418 419 if( this->bDown ) 419 420 421 420 { 421 //this->shiftCoor((this->getAbsDirX())*-1); 422 //accel -= (this->getAbsDirX())*2; 422 423 //if(velocity.len() > 50) 423 424 425 426 427 424 accel -= (this->getAbsDirX())*0.5*acceleration; 425 426 427 428 } 428 429 429 430 if( this->bLeft/* > -this->getRelCoor().z*2*/) 430 431 { 431 432 this->shiftDir(Quaternion(time, Vector(0,1,0))); 432 // accel -= rightDirection;433 // accel -= rightDirection; 433 434 //velocityDir.normalize(); 434 435 //rot +=Vector(1,0,0); … … 449 450 { 450 451 mouseDir *= Quaternion(-time*2, Vector(1,0,0)); 451 // accel -= rightDirection;452 // accel -= rightDirection; 452 453 //velocityDir.normalize(); 453 454 //rot +=Vector(1,0,0); … … 467 468 this->shiftDir(Quaternion(time, Vector(0,0,1))); 468 469 469 // accel += upDirection;470 // accel += upDirection; 470 471 //velocityDir.normalize(); 471 472 //rot += Vector(0,0,1); … … 495 496 496 497 if( event.type == KeyMapper::PEV_LEFT) 497 498 this->bRollL = event.bPressed; 498 499 else if( event.type == KeyMapper::PEV_RIGHT) 499 500 this->bRollR = event.bPressed; 500 501 else if( event.type == KeyMapper::PEV_FORWARD) 501 502 this->bUp = event.bPressed; //this->shiftCoor(0,.1,0); -
trunk/src/world_entities/space_ships/space_ship.h
r9235 r9869 19 19 class SpaceShip : public Playable 20 20 { 21 ObjectListDeclaration(SpaceShip); 21 22 22 23 public: … … 36 37 virtual void postSpawn(); 37 38 virtual void leftWorld(); 38 39 39 40 virtual void destroy(WorldEntity* killer); 40 41 virtual void respawn(); -
trunk/src/world_entities/space_ships/spacecraft_2d.cc
r9406 r9869 30 30 31 31 #include "graphics_engine.h" 32 #include " dot_emitter.h"33 #include " sprite_particles.h"32 #include "particles/dot_emitter.h" 33 #include "particles/sprite_particles.h" 34 34 35 35 #include "debug.h" … … 38 38 39 39 40 CREATE_FACTORY(Spacecraft2D, CL_SPACECRAFT_2D); 41 42 43 CREATE_SCRIPTABLE_CLASS(Spacecraft2D, CL_SPACECRAFT_2D, 44 addMethod("hasPlayer", ExecutorLua0ret<Playable,bool>(&Playable::hasPlayer)) 40 #include "class_id_DEPRECATED.h" 41 ObjectListDefinitionID(Spacecraft2D, CL_SPACECRAFT_2D); 42 CREATE_FACTORY(Spacecraft2D); 43 44 CREATE_SCRIPTABLE_CLASS(Spacecraft2D, 45 addMethod("hasPlayer", Executor0ret<Playable, lua_State*,bool>(&Playable::hasPlayer)) 45 46 //Coordinates 46 ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))47 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))48 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))49 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))50 ->addMethod("setAirFriction", ExecutorLua1<Spacecraft2D, float>(&Spacecraft2D::setAirFriction))47 ->addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) 48 ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) 49 ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 50 ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 51 ->addMethod("setAirFriction", Executor1<Spacecraft2D, lua_State*, float>(&Spacecraft2D::setAirFriction)) 51 52 ); 53 52 54 53 55 … … 85 87 86 88 //weapons: 87 Weapon* wpRight = dynamic_cast<Weapon*>(Factory::fabricate( CL_LASER_CANNON));89 Weapon* wpRight = dynamic_cast<Weapon*>(Factory::fabricate("LaserCannon")); 88 90 wpRight->setName("Cannon_Right"); 89 Weapon* wpLeft = dynamic_cast<Weapon*>(Factory::fabricate( CL_LASER_CANNON));91 Weapon* wpLeft = dynamic_cast<Weapon*>(Factory::fabricate("LaserCannon")); 90 92 wpLeft->setName("Cannon_Left"); 91 93 92 Weapon* turretLeft = dynamic_cast<Weapon*>(Factory::fabricate( CL_BOOMERANG_GUN));94 Weapon* turretLeft = dynamic_cast<Weapon*>(Factory::fabricate("BoomerangGun")); 93 95 wpRight->setName("Turret_Left"); 94 Weapon* turretRight = dynamic_cast<Weapon*>(Factory::fabricate( CL_BOOMERANG_GUN));96 Weapon* turretRight = dynamic_cast<Weapon*>(Factory::fabricate("BoomerangGun")); 95 97 wpLeft->setName("Turret_Right"); 96 98 … … 125 127 { 126 128 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 127 this-> setClassID(CL_SPACECRAFT_2D, "Spacecraft2D");129 this->registerObject(this, Spacecraft2D::_objectList); 128 130 129 131 this->setSupportedPlaymodes(Playable::Full3D | Playable::Horizontal ); -
trunk/src/world_entities/space_ships/spacecraft_2d.h
r9235 r9869 16 16 class Spacecraft2D : public Playable 17 17 { 18 ObjectListDeclaration(Spacecraft2D); 18 19 public: 19 20 Spacecraft2D(const std::string& fileName); -
trunk/src/world_entities/space_ships/turbine_hover.cc
r9656 r9869 29 29 30 30 #include "graphics_engine.h" 31 #include " dot_emitter.h"32 #include " sprite_particles.h"31 #include "particles/dot_emitter.h" 32 #include "particles/sprite_particles.h" 33 33 34 34 #include "debug.h" 35 35 36 CREATE_FACTORY(TurbineHover, CL_TURBINE_HOVER); 36 #include "class_id_DEPRECATED.h" 37 ObjectListDefinitionID(TurbineHover, CL_TURBINE_HOVER); 38 CREATE_FACTORY(TurbineHover); 37 39 38 40 /** … … 101 103 { 102 104 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 103 this-> setClassID(CL_TURBINE_HOVER, "TurbineHover");105 this->registerObject(this, TurbineHover::_objectList); 104 106 105 107 this->setSupportedPlaymodes(Playable::Full3D | Playable::Horizontal | Playable::Vertical); -
trunk/src/world_entities/space_ships/turbine_hover.h
r9656 r9869 18 18 class TurbineHover : public Playable 19 19 { 20 public: 21 TurbineHover(const std::string& fileName); 22 TurbineHover(const TiXmlElement* root = NULL); 23 virtual ~TurbineHover(); 20 ObjectListDeclaration(TurbineHover); 21 public: 22 TurbineHover(const std::string& fileName); 23 TurbineHover(const TiXmlElement* root = NULL); 24 virtual ~TurbineHover(); 24 25 25 26 void setBoostColor(const Color& color); 26 27 27 28 29 30 28 virtual void loadParams(const TiXmlElement* root); 29 virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f); 30 virtual void enter(); 31 virtual void leave(); 31 32 32 33 virtual void setTeam(int teamID); 33 34 34 35 36 35 virtual void postSpawn(); 36 virtual void leftWorld(); 37 virtual void respawn(); 37 38 38 39 40 39 virtual void collidesWith(WorldEntity* entity, const Vector& location); 40 virtual void tick(float dt); 41 virtual void draw() const; 41 42 42 43 virtual void process(const Event &event); 43 44 44 45 46 45 private: 46 void init(); 47 void movement(float dt); 47 48 48 49 50 51 52 53 54 49 private: 50 bool bForward; //!< forward button pressed. 51 bool bBackward; //!< backward button pressed. 52 bool bLeft; //!< left button pressed. 53 bool bRight; //!< right button pressed. 54 bool bAscend; //!< ascend button pressed. 55 bool bDescend; //!< descend button presses. 55 56 56 57 57 int yInvert; 58 float mouseSensitivity; //!< the mouse sensitivity 58 59 59 60 61 62 60 PNode wingNodeLeft; 61 PNode wingNodeRight; 62 PNode rotorNodeLeft; 63 PNode rotorNodeRight; 63 64 64 65 66 65 PNode cameraNode; 66 float cameraLook; 67 float rotation; 67 68 68 69 70 71 72 69 // Vector velocity; //!< the velocity of the TurbineHover. 70 Quaternion direction; //!< the direction of the TurbineHover. 71 float travelSpeed; //!< the current speed of the Hove (to make soft movement) 72 float acceleration; //!< the acceleration of the TurbineHover. 73 float airFriction; //!< AirFriction. 73 74 74 75 75 float rotorSpeed; //!< the speed of the rotor. 76 float rotorCycle; //!< The Cycle the rotor is in. 76 77 77 78 float airViscosity; 78 79 79 80 80 ParticleEmitter* burstEmitter[2]; 81 ParticleSystem* burstSystem; 81 82 }; 82 83 -
trunk/src/world_entities/spawning_point.cc
r9656 r9869 22 22 #include "world_entity.h" 23 23 24 #include "class_list.h"25 26 24 #include "compiler.h" 27 25 … … 35 33 #include "converter.h" 36 34 37 CREATE_FACTORY( SpawningPoint, CL_SPAWNING_POINT ); 38 35 #include "class_id_DEPRECATED.h" 36 ObjectListDefinitionID(SpawningPoint, CL_SPAWNING_POINT); 37 CREATE_FACTORY( SpawningPoint); 39 38 /** 40 39 * constructor … … 52 51 void SpawningPoint::init() 53 52 { 54 this-> setClassID(CL_SPAWNING_POINT, "SpawningPoint");53 this->registerObject(this, SpawningPoint::_objectList); 55 54 PRINTF(0)("Created SpawningPoint\n"); 56 55 … … 84 83 /* load teamId */ 85 84 LoadParam(root, "teamId", this, SpawningPoint, setTeamId) 86 85 .describe("sets teamId"); 87 86 } 88 87 … … 108 107 void SpawningPoint::spawn(Playable* entity) 109 108 { 110 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );111 112 109 bool found = false; 113 110 114 if ( !list ) 115 return; 116 117 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 111 for (ObjectList<Playable>::const_iterator it = Playable::objectList().begin(); 112 it != Playable::objectList().end(); 113 ++it) 118 114 { 119 115 if ( *it == entity ) … … 162 158 this->spawn(it->entity); 163 159 164 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYABLE );165 166 160 bool found = false; 167 161 168 if ( !list ) 169 return; 170 171 for ( std::list<BaseObject*>::const_iterator it2 = list->begin(); it2 != list->end(); it2++ ) 162 for (ObjectList<Playable>::const_iterator it2 = Playable::objectList().begin(); 163 it2 != Playable::objectList().end(); 164 ++it2) 172 165 { 173 166 if ( *it2 == it->entity ) … … 202 195 */ 203 196 void SpawningPoint::draw() const 204 { 205 } 197 {} 206 198 207 199 void SpawningPoint::sendRespawnMessage( int uniqueId ) … … 243 235 Playable * playable = NULL; 244 236 245 const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT ); 246 247 if ( list ) 248 { 249 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 250 { 251 PRINTF(0)("%d:%d\n", dynamic_cast<SpawningPoint*>(*it)->getUniqueID(), spUniqueId); 252 if ( dynamic_cast<SpawningPoint*>(*it)->getUniqueID() == spUniqueId ) 253 { 254 sp = dynamic_cast<SpawningPoint*>(*it); 255 break; 256 } 237 for (ObjectList<SpawningPoint>::const_iterator it = SpawningPoint::objectList().begin(); 238 it != SpawningPoint::objectList().end(); 239 ++it) 240 { 241 PRINTF(0)("%d:%d\n", (*it)->getUniqueID(), spUniqueId); 242 if ( (*it)->getUniqueID() == spUniqueId ) 243 { 244 sp = (*it); 245 break; 257 246 } 258 247 } … … 264 253 } 265 254 266 list = ClassList::getList( CL_PLAYABLE ); 267 268 if ( list ) 269 { 270 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 271 { 272 if ( dynamic_cast<Playable*>(*it)->getUniqueID() == uniqueId ) 273 { 274 playable = dynamic_cast<Playable*>(*it); 275 break; 276 } 255 for (ObjectList<Playable>::const_iterator it = Playable::objectList().begin(); 256 it != Playable::objectList().end(); 257 ++it) 258 { 259 if ( (*it)->getUniqueID() == uniqueId ) 260 { 261 playable = (*it); 262 break; 277 263 } 278 264 } -
trunk/src/world_entities/spawning_point.h
r9656 r9869 42 42 */ 43 43 class SpawningPoint : public WorldEntity { 44 44 ObjectListDeclaration(SpawningPoint); 45 45 public: 46 46 SpawningPoint(const TiXmlElement* root = NULL); -
trunk/src/world_entities/spectator.cc
r9406 r9869 22 22 #include "shared_network_data.h" 23 23 24 CREATE_FACTORY(Spectator, CL_SPECTATOR); 25 26 27 24 #include "class_id_DEPRECATED.h" 25 ObjectListDefinitionID(Spectator, CL_SPECTATOR); 26 CREATE_FACTORY(Spectator); 28 27 29 28 … … 58 57 { 59 58 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 60 this-> setClassID(CL_SPECTATOR, "Spectator");59 this->registerObject(this, Spectator::_objectList); 61 60 62 61 this->getWeaponManager().changeWeaponConfig(1); … … 89 88 dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false); 90 89 91 90 92 91 registerVar( new SynchronizeableBool( &bLeft, &bLeft, "bLeft", PERMISSION_OWNER ) ); 93 92 registerVar( new SynchronizeableBool( &bRight, &bRight, "bRight", PERMISSION_OWNER ) ); … … 161 160 { 162 161 Playable::tick( time ); 163 162 164 163 if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() ) 165 164 { 166 165 xMouse *= time / 10; 167 166 yMouse *= time / 10; 168 167 169 168 angleX -= xMouse; 170 169 angleY -= yMouse; 171 170 172 171 if ( angleY > 2.05 ) 173 172 angleY = 2.05; 174 173 175 174 if ( angleY < -1.15 ) 176 175 angleY = -1.15; 177 176 178 177 this->mouseDir = Quaternion( angleX, Vector( 0, 1, 0 ) ) * Quaternion( angleY, Vector( 0, 0, 1 ) ); 179 178 180 179 xMouse = yMouse = 0; 181 180 } 182 181 183 182 this->setAbsDir( this->mouseDir ); 184 183 185 184 Vector velocity; 186 185 187 186 if ( this->bForward ) 188 187 { 189 188 velocity += this->getAbsDirX(); 190 189 } 191 190 192 191 if ( this->bBackward ) 193 192 { 194 193 velocity -= this->getAbsDirX(); 195 194 } 196 195 197 196 if ( this->bRight ) 198 197 { 199 198 velocity += this->getAbsDirZ(); 200 199 } 201 200 202 201 if ( this->bLeft ) 203 202 { 204 203 velocity -= this->getAbsDirZ(); 205 204 } 206 205 207 206 velocity *= 100; 208 207 209 208 this->shiftCoor( velocity*time ); 210 209 } -
trunk/src/world_entities/spectator.h
r8228 r9869 11 11 class Spectator : public Playable 12 12 { 13 ObjectListDeclaration(Spectator); 13 14 14 15 public: … … 37 38 bool bForward; 38 39 bool bBackward; 39 40 40 41 float xMouse; //!< mouse moved in x-Direction 41 42 float yMouse; //!< mouse moved in y-Direction -
trunk/src/world_entities/terrain.cc
r9406 r9869 18 18 #include "terrain.h" 19 19 20 #include "util/loading/resource_manager.h" 20 21 #include "util/loading/load_param.h" 21 22 #include "util/loading/factory.h" 22 23 #include "spatial_separation.h" 23 24 24 #include "util/loading/resource_manager.h"25 25 #include "model.h" 26 26 #include "network_game_manager.h" … … 32 32 33 33 #include "state.h" 34 35 36 37 CREATE_FACTORY(Terrain, CL_TERRAIN); 34 #include "debug.h" 35 36 #include "class_id_DEPRECATED.h" 37 ObjectListDefinitionID(Terrain, CL_TERRAIN); 38 CREATE_FACTORY(Terrain); 38 39 39 40 /** … … 88 89 Terrain::~Terrain () 89 90 { 90 if ( objectList)91 glDeleteLists(this-> objectList, 1);91 if (modelList) 92 glDeleteLists(this->modelList, 1); 92 93 if( this->ssp) 93 94 delete ssp; 94 if (this->vegetation)95 {96 ResourceManager::getInstance()->unload(this->vegetation);97 }98 95 99 96 if(this->heightMap) … … 104 101 void Terrain::init() 105 102 { 106 this-> setClassID(CL_TERRAIN, "Terrain");103 this->registerObject(this, Terrain::_objectList); 107 104 this->toList(OM_ENVIRON_NOTICK); 108 105 this->toReflectionList(); 109 106 110 this-> objectList = 0;107 this->modelList = 0; 111 108 this->ssp = NULL; 112 109 this->vegetation = NULL; … … 147 144 this->heightMap = NULL; 148 145 149 std::string hmName = Resource Manager::getFullName(heightMapFile);150 std::string hmColorName = Resource Manager::getFullName(colorMap);146 std::string hmName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(heightMapFile); 147 std::string hmColorName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(colorMap); 151 148 152 149 … … 180 177 PRINTF(4)("loadVegetation: %s\n", vegetationFile.c_str()); 181 178 if (this->vegetation) 182 ResourceManager::getInstance()->unload(this->vegetation, RP_LEVEL);179 this->vegetation = 0; 183 180 if (!vegetationFile.empty()) 184 181 { 185 182 PRINTF(4)("fetching %s\n", vegetationFile.c_str()); 186 this->vegetation = dynamic_cast<Model*>(ResourceManager::getInstance()->load(vegetationFile, OBJ, RP_CAMPAIGN)); 183 this->loadModel(vegetationFile, 1.0, 2); 184 this->vegetation = this->getModel(2); 187 185 } 188 186 else … … 206 204 //glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 207 205 208 if (this-> objectList)209 glCallList(this-> objectList);206 if (this->modelList) 207 glCallList(this->modelList); 210 208 else if (this->getModel()) 211 209 this->getModel()->draw(); … … 256 254 if (debugTerrain == TERRAIN_DAVE) 257 255 { 258 objectList = glGenLists(1);259 glNewList ( objectList, GL_COMPILE);256 modelList = glGenLists(1); 257 glNewList (modelList, GL_COMPILE); 260 258 261 259 glColor3f(1.0,0,0); -
trunk/src/world_entities/terrain.h
r7954 r9869 12 12 13 13 #include "world_entity.h" 14 #include "vector.h"15 14 16 15 // FORWARD DECLARATION … … 26 25 class Terrain : public WorldEntity 27 26 { 27 ObjectListDeclaration(Terrain); 28 28 29 29 public: … … 52 52 private: 53 53 Model* vegetation; 54 int objectList;54 int modelList; 55 55 56 56 HeightMap* heightMap; -
trunk/src/world_entities/test_entity.cc
r9406 r9869 26 26 27 27 #include "test_entity.h" 28 28 #include "debug.h" 29 29 30 30 #include "interactive_model.h" … … 35 35 36 36 37 38 CREATE_FACTORY(TestEntity, CL_TEST_ENTITY); 37 #include "class_id_DEPRECATED.h" 38 ObjectListDefinition(TestEntity); 39 CREATE_FACTORY(TestEntity); 39 40 40 41 #include "script_class.h" 41 CREATE_SCRIPTABLE_CLASS(TestEntity, CL_TEST_ENTITY, 42 addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor)) 43 ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX)) 44 ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY)) 45 ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ)) 46 42 CREATE_SCRIPTABLE_CLASS(TestEntity, 43 addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor)) 44 ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX)) 45 ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY)) 46 ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ)) 47 47 ); 48 48 … … 75 75 void TestEntity::init() 76 76 { 77 this-> setClassID(CL_TEST_ENTITY, "TestEntity");77 this->registerObject(this, TestEntity::_objectList); 78 78 this->toList(OM_GROUP_00); 79 79 … … 91 91 92 92 LoadParam(root, "md2animation", this, TestEntity, setAnim) 93 94 93 .describe("sets the animation of the md2 model") 94 .defaultValues(1); 95 95 96 96 } -
trunk/src/world_entities/test_entity.h
r9235 r9869 15 15 class TestEntity : public WorldEntity, public PhysicsInterface 16 16 { 17 ObjectListDeclaration(TestEntity); 17 18 public: 18 19 TestEntity (); -
trunk/src/world_entities/weapons/aim.cc
r9656 r9869 29 29 30 30 31 ObjectListDefinition(Aim); 31 32 32 33 /** … … 50 51 Aim::~Aim () 51 52 { 52 /* if (this->text != NULL)53 delete this->text;*/53 /* if (this->text != NULL) 54 delete this->text;*/ 54 55 } 55 56 … … 59 60 void Aim::init() 60 61 { 61 this-> setClassID(CL_CROSSHAIR, "Aim");62 this->registerObject(this, Aim::_objectList); 62 63 this->setName("Aim"); 63 64 … … 79 80 80 81 81 /* this->text = new Text();82 this->text->setLayer(this->getLayer());83 this->text->setParent2D(this);84 this->text->setRelCoor2D(10, -50);85 this->text->setParentMode2D(E2D_PARENT_MOVEMENT);86 this->text->setText("Testing");*/82 /* this->text = new Text(); 83 this->text->setLayer(this->getLayer()); 84 this->text->setParent2D(this); 85 this->text->setRelCoor2D(10, -50); 86 this->text->setParentMode2D(E2D_PARENT_MOVEMENT); 87 this->text->setText("Testing");*/ 87 88 } 88 89 … … 92 93 93 94 LoadParam(root, "texture", this, Aim, setTexture) 94 95 .describe("the texture-file to load onto the Aim"); 95 96 96 97 LoadParam(root, "size", this, Aim, setSize) 97 98 .describe("the size of the Aim in Pixels"); 98 99 99 100 LoadParam(root, "rotation-speed", this, Aim, setRotationSpeed) 100 101 .describe("the Speed with which the Aim should rotate"); 101 102 102 103 LoadParam(root, "target-group", this, Aim, setTargetGroupS); … … 107 108 ObjectManager::EntityList::iterator entity; 108 109 //printf("%d\n", this->targetGroup); 109 for (entity = State::getObjectManager()->get ObjectList(this->targetGroup).begin();110 entity != State::getObjectManager()->get ObjectList(this->targetGroup).end();110 for (entity = State::getObjectManager()->getEntityList(this->targetGroup).begin(); 111 entity != State::getObjectManager()->getEntityList(this->targetGroup).end(); 111 112 entity ++) 112 113 { … … 117 118 //if (this->getParent() != (*entity)) 118 119 { 119 printf("found target::: %d %s::%s\n", (*entity)->getOMListNumber(), (*entity)->getClassCName(), (*entity)->getCName());120 // printf("found target::: %d %s::%s\n", (*entity)->getOMListNumber(), (*entity)->getClassCName(), (*entity)->getCName()); 120 121 this->anim->replay(); 121 122 this->setParentSoft(*entity, 5); … … 125 126 } 126 127 127 128 128 //if no target found: 129 this->setParent(PNode::getNullParent()); 129 130 } 130 131 … … 165 166 this->shiftDir2D(dt * rotationSpeed); 166 167 167 // char outputText[100];168 // sprintf(outputText, "%s - distance: %f\n", this->getParent()->getName(), (this->source->getAbsCoor() - this->getAbsCoor()).len());169 // this->text->setText(outputText);170 171 172 // if (this->source->getAbsCoor().x > this->getAbsCoor().x )168 // char outputText[100]; 169 // sprintf(outputText, "%s - distance: %f\n", this->getParent()->getName(), (this->source->getAbsCoor() - this->getAbsCoor()).len()); 170 // this->text->setText(outputText); 171 172 173 // if (this->source->getAbsCoor().x > this->getAbsCoor().x ) 173 174 diffVec = ( this->getAbsCoor() - this->source->getAbsCoor() ); 174 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range175 175 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range 176 if(this->getParent() == PNode::getNullParent() || 176 177 diffVec.len() > range )// || 177 178 179 180 181 182 183 // float z = 0.0f;184 // glReadPixels ((int)this->getAbsCoor2D().x,185 // GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1,186 // 1,187 // 1,188 // GL_DEPTH_COMPONENT,189 // GL_FLOAT,190 // &z);191 //192 //193 // GLdouble objX=.0, objY=.0, objZ=.0;194 // gluUnProject(this->getAbsCoor2D().x,195 // GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1,196 // .99, // z197 // GraphicsEngine::modMat,198 // GraphicsEngine::projMat,199 // GraphicsEngine::viewPort,200 // &objX,201 // &objY,202 // &objZ );203 //aa204 // this->setAbsCoor(objX, objY, objZ);178 //( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle)) 179 { 180 this->setParentSoft(PNode::getNullParent(),5); 181 this->searchTarget(); 182 } 183 184 // float z = 0.0f; 185 // glReadPixels ((int)this->getAbsCoor2D().x, 186 // GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1, 187 // 1, 188 // 1, 189 // GL_DEPTH_COMPONENT, 190 // GL_FLOAT, 191 // &z); 192 // 193 // 194 // GLdouble objX=.0, objY=.0, objZ=.0; 195 // gluUnProject(this->getAbsCoor2D().x, 196 // GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1, 197 // .99, // z 198 // GraphicsEngine::modMat, 199 // GraphicsEngine::projMat, 200 // GraphicsEngine::viewPort, 201 // &objX, 202 // &objY, 203 // &objZ ); 204 //aa 205 // this->setAbsCoor(objX, objY, objZ); 205 206 } 206 207 … … 211 212 { 212 213 213 if( this->getParent() != PNode::getNullParent() )214 if( this->getParent() != PNode::getNullParent() ) 214 215 { 215 glPushMatrix();216 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);217 218 glRotatef(this->getAbsDir2D(), 0,0,1);219 this->material.select();220 glBegin(GL_TRIANGLE_STRIP);221 glTexCoord2f(0, 0);222 glVertex2f(-this->getSizeX2D(), -this->getSizeY2D());223 glTexCoord2f(1, 0);224 glVertex2f(this->getSizeX2D(), -this->getSizeY2D());225 glTexCoord2f(0, 1);226 glVertex2f(-this->getSizeX2D(), this->getSizeY2D());227 glTexCoord2f(1, 1);228 glVertex2f(this->getSizeX2D(), this->getSizeY2D());229 glEnd();230 glPopMatrix();216 glPushMatrix(); 217 glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); 218 219 glRotatef(this->getAbsDir2D(), 0,0,1); 220 this->material.select(); 221 glBegin(GL_TRIANGLE_STRIP); 222 glTexCoord2f(0, 0); 223 glVertex2f(-this->getSizeX2D(), -this->getSizeY2D()); 224 glTexCoord2f(1, 0); 225 glVertex2f(this->getSizeX2D(), -this->getSizeY2D()); 226 glTexCoord2f(0, 1); 227 glVertex2f(-this->getSizeX2D(), this->getSizeY2D()); 228 glTexCoord2f(1, 1); 229 glVertex2f(this->getSizeX2D(), this->getSizeY2D()); 230 glEnd(); 231 glPopMatrix(); 231 232 } 232 233 -
trunk/src/world_entities/weapons/aim.h
r9656 r9869 19 19 template<class T> class tAnimation; 20 20 21 21 22 //! An Aim for zooming in on Targets. 22 23 /** … … 28 29 class Aim : public PNode, public Element2D 29 30 { 31 ObjectListDeclaration(Aim); 30 32 31 33 public: -
trunk/src/world_entities/weapons/aiming_system.cc
r9406 r9869 21 21 22 22 #include "state.h" 23 #include "debug.h" 23 24 24 25 #include "aabb.h" 25 26 #include "obb_tree.h" 26 27 27 #include <vector>28 28 29 29 30 31 30 ObjectListDefinition(AimingSystem); 32 31 33 32 /** … … 55 54 void AimingSystem::init() 56 55 { 57 this-> setClassID(CL_AIMING_SYSTEM, "AimingSystem");56 this->registerObject(this, AimingSystem::_objectList); 58 57 this->setName("AimingSystem"); 59 58 … … 63 62 // registering default reactions: 64 63 this->unsubscribeReaction(CREngine::CR_OBJECT_DAMAGE); 65 this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, CL_WORLD_ENTITY);64 this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, WorldEntity::staticClassID()); 66 65 67 66 this->range = 1000.0f; -
trunk/src/world_entities/weapons/aiming_system.h
r9235 r9869 21 21 class AimingSystem : public WorldEntity 22 22 { 23 ObjectListDeclaration(AimingSystem); 23 24 24 25 public: -
trunk/src/world_entities/weapons/aiming_turret.cc
r9656 r9869 27 27 #include "util/loading/factory.h" 28 28 29 CREATE_FACTORY(AimingTurret, CL_AIMING_TURRET); 30 29 #include "class_id_DEPRECATED.h" 30 ObjectListDefinitionID(AimingTurret, CL_AIMING_TURRET); 31 CREATE_FACTORY(AimingTurret); 31 32 32 33 … … 64 65 void AimingTurret::init() 65 66 { 66 this-> setClassID(CL_AIMING_TURRET, "AimingTurret");67 this->registerObject(this, AimingTurret::_objectList); 67 68 68 69 Animation3D* animation1 = this->getAnimation(WS_ACTIVATING, this); … … 86 87 87 88 this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET); 88 this->setProjectileType (CL_GUIDED_MISSILE);89 this->setProjectileTypeC("GuidedMissile"); 89 90 90 91 -
trunk/src/world_entities/weapons/aiming_turret.h
r9656 r9869 13 13 class AimingTurret : public Weapon 14 14 { 15 ObjectListDeclaration(AimingTurret); 16 15 17 public: 16 18 AimingTurret (); -
trunk/src/world_entities/weapons/ammo_container.cc
r9406 r9869 23 23 24 24 25 25 ObjectListDefinition(AmmoContainer); 26 26 /** 27 27 * standard constructor 28 28 * @todo this constructor is not jet implemented - do it 29 29 */ 30 AmmoContainer::AmmoContainer ( ClassIDprojectileType, float maxEnergy)30 AmmoContainer::AmmoContainer (const ClassID& projectileType, float maxEnergy) 31 31 { 32 this->setClassID(CL_AMMO_CONTAINER, "AmmoContainer");32 this->registerObject(this, AmmoContainer::_objectList); 33 33 34 35 34 this->projectileType = projectileType; 35 this->maxEnergy = maxEnergy; 36 36 37 37 this->energy = 0.0; 38 38 } 39 39 -
trunk/src/world_entities/weapons/ammo_container.h
r6671 r9869 17 17 //! A class for Storing energy of Projectiles. 18 18 class AmmoContainer : public BaseObject { 19 ObjectListDeclaration(AmmoContainer); 19 20 20 21 public: 21 AmmoContainer( ClassID projectileType, float maxEnergy = DEFAULT_MAX_ENERGY);22 AmmoContainer(const ClassID& id, float maxEnergy = DEFAULT_MAX_ENERGY); 22 23 virtual ~AmmoContainer(); 23 24 24 bool operator=( ClassIDprojectileType) const { return (this->projectileType == projectileType); };25 bool operator=(int projectileType) const { return (this->projectileType == projectileType); }; 25 26 ClassID getProjectileType() const { return this->projectileType; }; 26 27 -
trunk/src/world_entities/weapons/boomerang_gun.cc
r9235 r9869 27 27 #include "util/loading/factory.h" 28 28 29 CREATE_FACTORY(BoomerangGun, CL_BOOMERANG_GUN); 29 #include "class_id_DEPRECATED.h" 30 ObjectListDefinitionID(BoomerangGun, CL_BOOMERANG_GUN); 31 CREATE_FACTORY(BoomerangGun); 30 32 31 33 … … 61 63 void BoomerangGun::init() 62 64 { 63 this-> setClassID(CL_BOOMERANG_GUN, "BoomerangGun");65 this->registerObject(this, BoomerangGun::_objectList); 64 66 65 67 … … 85 87 86 88 this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET); 87 this->setProjectileType (CL_BOOMERANG_PROJECTILE);89 this->setProjectileTypeC("BoomerangProjectile"); 88 90 89 91 this->loadModel("models/guns/turret1.obj", 5.0); -
trunk/src/world_entities/weapons/boomerang_gun.h
r9235 r9869 11 11 class BoomerangGun : public Weapon 12 12 { 13 ObjectListDeclaration(BoomerangGun); 13 14 public: 14 15 BoomerangGun (); -
trunk/src/world_entities/weapons/cannon.cc
r9406 r9869 32 32 #include "animation3d.h" 33 33 34 #include "fast_factory.h" 35 36 37 38 39 CREATE_FACTORY(Cannon, CL_CANNON); 34 #include "loading/fast_factory.h" 35 36 37 38 #include "class_id_DEPRECATED.h" 39 ObjectListDefinitionID(Cannon, CL_CANNON); 40 CREATE_FACTORY(Cannon); 40 41 41 42 /** … … 69 70 void Cannon::init() 70 71 { 71 this-> setClassID(CL_CANNON, "Cannon");72 this->registerObject(this, Cannon::_objectList); 72 73 73 74 // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN); … … 88 89 89 90 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_HEAVY); 90 this->setProjectileType (CL_BOMB);91 this->setProjectileTypeC("Bomb"); 91 92 this->prepareProjectiles(5); 92 93 -
trunk/src/world_entities/weapons/cannon.h
r8777 r9869 12 12 class Cannon : public Weapon 13 13 { 14 ObjectListDeclaration(Cannon); 14 15 public: 15 16 Cannon (); -
trunk/src/world_entities/weapons/crosshair.cc
r9406 r9869 26 26 27 27 28 28 ObjectListDefinition(Crosshair); 29 29 /** 30 30 * standart constructor … … 54 54 void Crosshair::init() 55 55 { 56 this-> setClassID(CL_CROSSHAIR, "Crosshair");56 this->registerObject(this, Crosshair::_objectList); 57 57 this->setName("Crosshair"); 58 58 -
trunk/src/world_entities/weapons/crosshair.h
r7221 r9869 22 22 //! A class that enables the 23 23 class Crosshair : public PNode, public Element2D, public EventListener { 24 24 ObjectListDeclaration(Crosshair); 25 25 public: 26 26 Crosshair(const TiXmlElement* root = NULL); -
trunk/src/world_entities/weapons/fps_sniper_rifle.cc
r9406 r9869 29 29 30 30 31 #include " fast_factory.h"31 #include "loading/fast_factory.h" 32 32 33 33 #include "fps_sniper_rifle.h" … … 39 39 40 40 41 CREATE_FACTORY(FPSSniperRifle, CL_FPS_SNIPER_RIFLE); 41 #include "class_id_DEPRECATED.h" 42 ObjectListDefinitionID(FPSSniperRifle, CL_FPS_SNIPER_RIFLE); 43 CREATE_FACTORY(FPSSniperRifle); 42 44 43 45 /** … … 76 78 void FPSSniperRifle::init() 77 79 { 78 this-> setClassID(CL_FPS_SNIPER_RIFLE, "FPSSniperRifle");80 this->registerObject(this, FPSSniperRifle::_objectList); 79 81 80 82 this->loadModel("models/guns/fps_sniper_rifle.obj", 0.2); … … 98 100 99 101 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 100 this->setProjectileType (CL_LASER);102 this->setProjectileTypeC("Laser"); 101 103 this->prepareProjectiles(20); 102 104 … … 181 183 182 184 this->material->select(); 183 static_cast<StaticModel*>(this->getModel())->draw(); 185 this->getModel()->draw(); 186 //static_cast<StaticModel*>(this->getModel())->draw(); 184 187 185 188 glPopMatrix(); -
trunk/src/world_entities/weapons/fps_sniper_rifle.h
r9003 r9869 39 39 class FPSSniperRifle : public Weapon 40 40 { 41 ObjectListDeclaration(FPSSniperRifle); 42 41 43 public: 42 44 FPSSniperRifle (int leftRight); -
trunk/src/world_entities/weapons/hyperblaster.cc
r9406 r9869 31 31 #include "animation3d.h" 32 32 33 #include " fast_factory.h"33 #include "loading/fast_factory.h" 34 34 35 35 36 36 37 38 CREATE_FACTORY(Hyperblaster, CL_HYPERBLASTER); 37 #include "class_id_DEPRECATED.h" 38 ObjectListDefinitionID(Hyperblaster, CL_HYPERBLASTER); 39 CREATE_FACTORY(Hyperblaster); 39 40 40 41 Hyperblaster::Hyperblaster(const TiXmlElement* root) … … 56 57 void Hyperblaster::init() 57 58 { 58 this-> setClassID(CL_HYPERBLASTER, "Hyperblaster");59 this->registerObject(this, Hyperblaster::_objectList); 59 60 60 61 // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN); … … 76 77 77 78 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_HEAVY); 78 this->setProjectileType (CL_HYPERBLAST);79 this->setProjectileTypeC("Hyperblast"); 79 80 this->prepareProjectiles(2); 80 81 -
trunk/src/world_entities/weapons/hyperblaster.h
r8777 r9869 12 12 class Hyperblaster : public Weapon 13 13 { 14 public: 14 ObjectListDeclaration(Hyperblaster); 15 public: 15 16 Hyperblaster (const TiXmlElement* root = NULL); 16 17 virtual ~Hyperblaster (); -
trunk/src/world_entities/weapons/laser_cannon.cc
r9656 r9869 29 29 #include "animation3d.h" 30 30 31 #include " fast_factory.h"31 #include "loading/fast_factory.h" 32 32 33 CREATE_FACTORY(LaserCannon, CL_LASER_CANNON); 34 33 #include "class_id_DEPRECATED.h" 34 ObjectListDefinitionID(LaserCannon, CL_LASER_CANNON); 35 CREATE_FACTORY(LaserCannon); 35 36 36 37 LaserCannon::LaserCannon(const TiXmlElement* root) … … 52 53 void LaserCannon::init() 53 54 { 54 this-> setClassID(CL_LASER_CANNON, "LaserCannon");55 this->registerObject(this, LaserCannon::_objectList); 55 56 56 57 // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/laser_cannon.obj", OBJ, RP_CAMPAIGN); … … 72 73 73 74 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 74 this->setProjectileType (CL_RAIL_PROJECTILE);75 this->setProjectileTypeC("RailProjectile"); 75 76 this->prepareProjectiles(100); 76 77 this->setEmissionPoint(Vector(2.8,0,0) * 5.0); -
trunk/src/world_entities/weapons/laser_cannon.h
r9235 r9869 29 29 class LaserCannon : public Weapon 30 30 { 31 public: 31 ObjectListDeclaration(LaserCannon); 32 public: 32 33 LaserCannon (const TiXmlElement* root = NULL); 33 34 virtual ~LaserCannon (); -
trunk/src/world_entities/weapons/targeting_turret.cc
r9656 r9869 26 26 #include "util/loading/factory.h" 27 27 28 CREATE_FACTORY(TargetingTurret, CL_TARGETING_TURRET); 28 #include "class_id_DEPRECATED.h" 29 ObjectListDefinitionID(TargetingTurret, CL_TARGETING_TURRET); 30 CREATE_FACTORY(TargetingTurret); 29 31 30 32 31 33 TargetingTurret::TargetingTurret(const TiXmlElement* root) 32 : target(this)33 34 { 34 35 this->init(); … … 42 43 TargetingTurret::~TargetingTurret () 43 44 { 45 if(Aim::objectList().exists(target)) 46 delete target; 44 47 // model will be deleted from WorldEntity-destructor 45 48 // delete this->target; … … 48 51 void TargetingTurret::init() 49 52 { 50 this->setClassID(CL_TARGETING_TURRET, "TargetingTurret"); 53 this->registerObject(this, TargetingTurret::_objectList); 54 this->target = new Aim(this); 51 55 52 56 Animation3D* animation1 = this->getAnimation(WS_ACTIVATING, this); … … 70 74 71 75 this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET); 72 this->setProjectileType (CL_GUIDED_MISSILE);76 this->setProjectileTypeC("GuidedMissile"); 73 77 74 78 … … 76 80 //this->getProjectileFactory()->prepare(100); 77 81 78 this->target .setVisibility(false);79 this->target .addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT | PNODE_PROHIBIT_CHILD_DELETE);80 this->target .setRange(1000);81 this->target .setAngle(M_PI_4);82 this->lockedTarget = &this->target;82 this->target->setVisibility(false); 83 this->target->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT | PNODE_PROHIBIT_CHILD_DELETE); 84 this->target->setRange(1000); 85 this->target->setAngle(M_PI_4); 86 this->lockedTarget = this->target; 83 87 84 88 this->lockedTime = 0; … … 97 101 Weapon::loadParams(root); 98 102 99 LoadParam(root, "target-group", &target, Aim, setTargetGroupS);103 LoadParam(root, "target-group", target, Aim, setTargetGroupS); 100 104 101 105 } … … 109 113 void TargetingTurret::deactivate() 110 114 { 111 this->target .setVisibility(false);115 this->target->setVisibility(false); 112 116 } 113 117 … … 117 121 return; 118 122 119 this->target .tick(dt);123 this->target->tick(dt); 120 124 121 125 if( lockedTime >= neededLockTime ) 122 126 { 123 lockedTarget = this->target .getParent();127 lockedTarget = this->target->getParent(); 124 128 lockedTime = 0; 125 129 } 126 130 127 131 128 if(this->target .getParent() == PNode::getNullParent())132 if(this->target->getParent() == PNode::getNullParent()) 129 133 lockedTime = 0; 130 134 else -
trunk/src/world_entities/weapons/targeting_turret.h
r9656 r9869 12 12 class TargetingTurret : public Weapon 13 13 { 14 ObjectListDeclaration(TargetingTurret); 14 15 public: 15 16 TargetingTurret(const TiXmlElement* root = NULL); … … 26 27 virtual void draw() const; 27 28 28 void setTargetGroup(OM_LIST targetGroup) { this->target .setTargetGroup(targetGroup); };29 void setTargetGroup(OM_LIST targetGroup) { this->target->setTargetGroup(targetGroup); }; 29 30 const PNode* getLockedTarget() const { return lockedTarget; }; 30 31 … … 33 34 34 35 private: 35 Aim 36 Aim* target; 36 37 PNode* lockedTarget; 37 38 float lockedTime; -
trunk/src/world_entities/weapons/test_gun.cc
r9656 r9869 31 31 #include "animation3d.h" 32 32 33 #include "fast_factory.h" 34 35 CREATE_FACTORY(TestGun, CL_TEST_GUN); 36 33 #include "loading/fast_factory.h" 34 35 #include "class_id_DEPRECATED.h" 36 ObjectListDefinitionID(TestGun, CL_TEST_GUN); 37 CREATE_FACTORY(TestGun); 37 38 /** 38 39 * standard constructor … … 109 110 void TestGun::init() 110 111 { 111 this->setClassID(CL_TEST_GUN, "TestGun"); 112 112 this->registerObject(this, TestGun::_objectList); 113 113 // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN); 114 114 … … 129 129 130 130 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 131 this->setProjectileType (CL_LASER);131 this->setProjectileTypeC("Laser"); 132 132 this->prepareProjectiles(100); 133 133 -
trunk/src/world_entities/weapons/test_gun.h
r8777 r9869 37 37 class TestGun : public Weapon 38 38 { 39 ObjectListDeclaration(TestGun); 39 40 public: 40 41 TestGun (int leftRight); -
trunk/src/world_entities/weapons/turret.cc
r9406 r9869 27 27 #include "util/loading/factory.h" 28 28 29 CREATE_FACTORY(Turret, CL_TURRET); 30 31 29 #include "class_id_DEPRECATED.h" 30 ObjectListDefinitionID(Turret, CL_TURRET); 31 CREATE_FACTORY(Turret); 32 32 33 33 /** … … 62 62 void Turret::init() 63 63 { 64 this-> setClassID(CL_TURRET, "Turret");64 this->registerObject(this, Turret::_objectList); 65 65 66 66 … … 86 86 87 87 this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET); 88 this->setProjectileType (CL_ROCKET);88 this->setProjectileTypeC("Rocket"); 89 89 90 90 this->loadModel("models/guns/turret1.obj"); -
trunk/src/world_entities/weapons/turret.h
r8777 r9869 11 11 class Turret : public Weapon 12 12 { 13 ObjectListDeclaration(Turret); 13 14 public: 14 15 Turret (); -
trunk/src/world_entities/weapons/weapon.cc
r9406 r9869 21 21 #include "weapon.h" 22 22 23 #include " fast_factory.h"23 #include "loading/fast_factory.h" 24 24 #include "world_entities/projectiles/projectile.h" 25 25 26 #include "util/loading/resource_manager.h"27 #include "class_list.h"28 26 #include "util/loading/factory.h" 29 27 #include "util/loading/load_param.h" … … 33 31 #include "sound_source.h" 34 32 #include "sound_buffer.h" 33 #include "resource_sound_buffer.h" 35 34 36 35 #include "elements/glgui_energywidget.h" 37 36 38 37 ObjectListDefinition(Weapon); 39 38 40 39 //////////////////// … … 58 57 { 59 58 for (int i = 0; i < WS_STATE_COUNT; i++) 60 if (this->animation[i] && ClassList::exists(animation[i], CL_ANIMATION)) //!< @todo this should check animation3D59 if (this->animation[i] && Animation::objectList().exists(animation[i])) //!< @todo this should check animation3D 61 60 delete this->animation[i]; 62 for (int i = 0; i < WA_ACTION_COUNT; i++) 63 if (this->soundBuffers[i] != NULL && ClassList::exists(this->soundBuffers[i], CL_SOUND_BUFFER)) 64 ResourceManager::getInstance()->unload(this->soundBuffers[i]); 65 66 if (ClassList::exists(this->soundSource, CL_SOUND_SOURCE)) 61 62 if (OrxSound::SoundSource::objectList().exists(this->soundSource)) 67 63 delete this->soundSource; 68 64 } … … 73 69 * @returns the newly created Weapon. 74 70 */ 75 Weapon* Weapon::createWeapon( ClassIDweaponID)71 Weapon* Weapon::createWeapon(const ClassID& weaponID) 76 72 { 77 73 BaseObject* createdObject = Factory::fabricate(weaponID); 78 74 if (createdObject != NULL) 79 75 { 80 if (createdObject->isA( CL_WEAPON))76 if (createdObject->isA(Weapon::staticClassID())) 81 77 return dynamic_cast<Weapon*>(createdObject); 82 78 else … … 89 85 } 90 86 87 Weapon* Weapon::createWeapon(const std::string& weaponName) 88 { 89 BaseObject* createdObject = Factory::fabricate(weaponName); 90 if (createdObject != NULL) 91 { 92 if (createdObject->isA(Weapon::staticClassID())) 93 return dynamic_cast<Weapon*>(createdObject); 94 else 95 { 96 delete createdObject; 97 return NULL; 98 } 99 } 100 return NULL; 101 } 102 103 91 104 /** 92 105 * initializes the Weapon with ALL default values … … 96 109 void Weapon::init() 97 110 { 98 this-> setClassID(CL_WEAPON, "Weapon");111 this->registerObject(this, Weapon::_objectList); 99 112 this->currentState = WS_INACTIVE; //< Normaly the Weapon is Inactive 100 113 this->requestedAction = WA_NONE; //< No action is requested by default … … 105 118 this->animation[i] = NULL; //< No animation 106 119 } 107 for (int i = 0; i < WA_ACTION_COUNT; i++)108 this->soundBuffers[i] = NULL; //< No Sounds109 120 110 121 this->soundSource = new OrxSound::SoundSource(this); //< Every Weapon has exacty one SoundSource. … … 115 126 this->defaultTarget = NULL; //< Nothing is Targeted by default. 116 127 117 this->projectile = CL_NULL;//< No Projectile Class is Connected to this weapon128 this->projectile = NullClass::staticClassID(); //< No Projectile Class is Connected to this weapon 118 129 this->projectileFactory = NULL; //< No Factory generating Projectiles is selected. 119 130 … … 163 174 * What it does, is telling the Weapon what Projectiles it can Emit. 164 175 */ 165 void Weapon::setProjectileType(ClassID projectile) 166 { 167 if (projectile == CL_NULL) 168 return; 176 void Weapon::setProjectileType(const ClassID& projectile) 177 { 169 178 this->projectile = projectile; 170 179 this->projectileFactory = FastFactory::searchFastFactory(projectile); … … 259 268 if (action >= WA_ACTION_COUNT) 260 269 return; 261 if (this->soundBuffers[action] != NULL)262 ResourceManager::getInstance()->unload(this->soundBuffers[action]);263 270 264 271 else if (!soundFile.empty()) 265 272 { 266 this->soundBuffers[action] = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(soundFile, WAV);267 if (this->soundBuffers[action] != NULL)273 this->soundBuffers[action] = OrxSound::ResourceSoundBuffer(soundFile); 274 if (this->soundBuffers[action].loaded()) 268 275 { 269 276 PRINTF(4)("Loaded sound %s to action %s.\n", soundFile.c_str(), actionToChar(action)); … … 275 282 } 276 283 else 277 this->soundBuffers[action] = NULL;284 this->soundBuffers[action] = OrxSound::SoundBuffer(); 278 285 } 279 286 … … 409 416 { 410 417 case WA_SHOOT: 411 412 418 return this->fireW(); 419 break; 413 420 case WA_CHARGE: 414 415 421 return this->chargeW(); 422 break; 416 423 case WA_RELOAD: 417 418 424 return this->reloadW(); 425 break; 419 426 case WA_DEACTIVATE: 420 421 427 return this->deactivateW(); 428 break; 422 429 case WA_ACTIVATE: 423 424 430 return this->activateW(); 431 break; 425 432 default: 426 427 433 PRINTF(2)("Action %s Not Implemented yet \n", Weapon::actionToChar(action)); 434 return false; 428 435 } 429 436 } … … 438 445 { 439 446 // play Sound 440 if (likely(this->soundBuffers[WA_ACTIVATE] != NULL))447 if (likely(this->soundBuffers[WA_ACTIVATE].loaded())) 441 448 this->soundSource->play(this->soundBuffers[WA_ACTIVATE]); 442 449 this->updateWidgets(); … … 460 467 PRINTF(4)("Deactivating the Weapon %s\n", this->getCName()); 461 468 // play Sound 462 if (this->soundBuffers[WA_DEACTIVATE] != NULL)469 if (this->soundBuffers[WA_DEACTIVATE].loaded()) 463 470 this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]); 464 471 // deactivate … … 479 486 { 480 487 // playing Sound 481 if (this->soundBuffers[WA_CHARGE] != NULL)488 if (this->soundBuffers[WA_CHARGE].loaded()) 482 489 this->soundSource->play(this->soundBuffers[WA_CHARGE]); 483 490 … … 504 511 { 505 512 // playing Sound 506 if (this->soundBuffers[WA_SHOOT] != NULL)513 if (this->soundBuffers[WA_SHOOT].loaded()) 507 514 this->soundSource->play(this->soundBuffers[WA_SHOOT]); 508 515 this->updateWidgets(); … … 528 535 { 529 536 PRINTF(4)("Reloading Weapon %s\n", this->getCName()); 530 if ( this->ammoContainer.get() != NULL&&537 if (!this->ammoContainer.isNull() && 531 538 unlikely(this->energy + this->ammoContainer->getStoredEnergy() < this->minCharge)) 532 539 { … … 537 544 538 545 539 if (this->soundBuffers[WA_RELOAD] != NULL)546 if (this->soundBuffers[WA_RELOAD].loaded()) 540 547 this->soundSource->play(this->soundBuffers[WA_RELOAD]); 541 548 542 if ( this->ammoContainer.get() != NULL)549 if (!this->ammoContainer.isNull()) 543 550 this->ammoContainer->fillWeapon(this); 544 551 else … … 680 687 { 681 688 case WA_SHOOT: 682 683 689 return "shoot"; 690 break; 684 691 case WA_CHARGE: 685 686 692 return "charge"; 693 break; 687 694 case WA_RELOAD: 688 689 695 return "reload"; 696 break; 690 697 case WA_ACTIVATE: 691 692 698 return "activate"; 699 break; 693 700 case WA_DEACTIVATE: 694 695 701 return "deactivate"; 702 break; 696 703 case WA_SPECIAL1: 697 698 704 return "special1"; 705 break; 699 706 default: 700 701 707 return "none"; 708 break; 702 709 } 703 710 } … … 743 750 { 744 751 case WS_SHOOTING: 745 746 752 return "shooting"; 753 break; 747 754 case WS_CHARGING: 748 749 755 return "charging"; 756 break; 750 757 case WS_RELOADING: 751 752 758 return "reloading"; 759 break; 753 760 case WS_ACTIVATING: 754 755 761 return "activating"; 762 break; 756 763 case WS_DEACTIVATING: 757 758 764 return "deactivating"; 765 break; 759 766 case WS_IDLE: 760 761 767 return "idle"; 768 break; 762 769 case WS_INACTIVE: 763 764 770 return "inactive"; 771 break; 765 772 default: 766 767 768 } 769 } 773 return "none"; 774 break; 775 } 776 } -
trunk/src/world_entities/weapons/weapon.h
r8976 r9869 19 19 #include "ammo_container.h" 20 20 21 #include "sound_buffer.h" 22 21 23 // FORWARD DECLARATION 22 24 class Projectile; … … 83 85 class Weapon : public WorldEntity 84 86 { 87 ObjectListDeclaration(Weapon); 88 85 89 public: 86 90 // INITIALISATION // 87 91 Weapon (); 88 92 virtual ~Weapon (); 89 static Weapon* createWeapon(ClassID weaponID); 93 static Weapon* createWeapon(const ClassID& weaponID); 94 static Weapon* createWeapon(const std::string& weaponName); 90 95 91 96 void init(); … … 110 115 /** @returns the Capabilities of this Weapon */ 111 116 inline long getCapability() const { return this->capability; }; 112 void setProjectileType( ClassIDprojectile);117 void setProjectileType(const ClassID& projectile); 113 118 void setProjectileTypeC(const std::string& projectile); 114 119 /** @returns The projectile's classID */ … … 216 221 // PHASES // 217 222 //////////// 218 OrxSound::SoundSource* soundSource; 219 220 WeaponState currentState; 221 WeaponAction requestedAction; 222 float stateDuration; 223 float times[WS_STATE_COUNT]; 224 Animation3D* animation[WS_STATE_COUNT]; 225 OrxSound::SoundBuffer * soundBuffers[WA_ACTION_COUNT];//!< SoundBuffers for all actions @see WeaponAction.223 OrxSound::SoundSource* soundSource; //!< A SoundSource to play sound from (this is connected to the PNode of the Weapon) 224 225 WeaponState currentState; //!< The State the weapon is in. 226 WeaponAction requestedAction; //!< An action to try to Engage after the currentState ends. 227 float stateDuration; //!< how long the state has taken until now. 228 float times[WS_STATE_COUNT]; //!< Times to stay in the different States @see WeaponState. 229 Animation3D* animation[WS_STATE_COUNT]; //!< Animations for all the States (you can say yourself on what part of the gun this animation acts). 230 OrxSound::SoundBuffer soundBuffers[WA_ACTION_COUNT]; //!< SoundBuffers for all actions @see WeaponAction. 226 231 227 232 PNode emissionPoint; //!< The point, where the projectiles are emitted. (this is coppled with the Weapon by default) -
trunk/src/world_entities/weapons/weapon_manager.cc
r9406 r9869 17 17 */ 18 18 19 #define DEBUG_SPECIAL_MODULE 4 //DEBUG_MODULE_WEAPON19 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON 20 20 21 21 #include "weapon_manager.h" 22 22 #include "weapon.h" 23 23 #include "crosshair.h" 24 #include "class_list.h"25 24 26 25 #include "playable.h" 27 26 28 #include "util/loading/load_param .h"27 #include "util/loading/load_param_xml.h" 29 28 #include "util/loading/factory.h" 30 29 … … 32 31 33 32 33 ObjectListDefinition(WeaponManager); 34 34 /** 35 35 * @brief this initializes the weaponManager for a given nnumber of weapon slots … … 57 57 // crosshair being a PNode it must not be deleted (this is because PNodes delete themselves.) 58 58 // rennerc: crosshair seems not to delete itselve 59 if (ClassList::exists(this->crosshair, CL_CROSSHAIR))60 delete this->crosshair;59 //if (Crosshair::objectList().exists(this->crosshair)) 60 // delete this->crosshair; 61 61 } 62 62 … … 66 66 void WeaponManager::init() 67 67 { 68 this-> setClassID(CL_WEAPON_MANAGER, "WeaponManager");68 this->registerObject(this, WeaponManager::_objectList); 69 69 70 70 this->parentNode = NULL; … … 298 298 { 299 299 this->parentNode->addChild(weapon); 300 if (this->parentEntity->isA( CL_PLAYABLE))300 if (this->parentEntity->isA(Playable::staticClassID())) 301 301 dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged(); 302 302 weapon->setDefaultTarget(this->crosshair); 303 303 } 304 PRINTF( 3)("Added a new Weapon (%s::%s) to the WeaponManager: config %i/ slot %i\n", weapon->getClassCName(), weapon->getCName(), configID, slotID);304 PRINTF(4)("Added a new Weapon (%s::%s) to the WeaponManager: config %i/ slot %i\n", weapon->getClassCName(), weapon->getCName(), configID, slotID); 305 305 return true; 306 306 } … … 311 311 * @param ammo the ammo to increase 312 312 */ 313 float WeaponManager::increaseAmmunition( ClassIDprojectileType, float ammo)313 float WeaponManager::increaseAmmunition(const ClassID& projectileType, float ammo) 314 314 { 315 315 return this->getAmmoContainer(projectileType)->increaseEnergy(ammo); … … 324 324 { 325 325 assert (weapon != NULL); 326 return this->increaseAmmunition(weapon->get LeafClassID(), ammo);326 return this->increaseAmmunition(weapon->getClassID(), ammo); 327 327 328 328 } … … 468 468 else 469 469 this->currentSlotConfig[i].position.deactivateNode(); 470 if (this->parentEntity != NULL && this->parentEntity->isA( CL_PLAYABLE))470 if (this->parentEntity != NULL && this->parentEntity->isA(Playable::staticClassID())) 471 471 dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged(); 472 472 } … … 523 523 } 524 524 525 CountPointer<AmmoContainer>& WeaponManager::getAmmoContainer( ClassIDprojectileType)525 CountPointer<AmmoContainer>& WeaponManager::getAmmoContainer(const ClassID& projectileType) 526 526 { 527 527 for (unsigned int i = 0; i < this->ammo.size(); i++) … … 537 537 { 538 538 assert (weapon != NULL); 539 return (this->getAmmoContainer(weapon->get LeafClassID()));539 return (this->getAmmoContainer(weapon->getClassID())); 540 540 } 541 541 -
trunk/src/world_entities/weapons/weapon_manager.h
r8844 r9869 39 39 */ 40 40 class WeaponManager : public BaseObject { 41 ObjectListDeclaration(WeaponManager); 41 42 42 43 //! an enumerator defining a Slot, where a Weapon can be stored inside. … … 89 90 void changeWeaponConfig(int weaponConfig); 90 91 91 float increaseAmmunition( ClassIDprojectileType, float ammo);92 float increaseAmmunition(const ClassID& projectileType, float ammo); 92 93 float inclreaseAmmunition(const Weapon* weapon, float ammo); 93 94 … … 106 107 // private: 107 108 int getNextFreeSlot(int configID, long capability = WTYPE_ALL); 108 CountPointer<AmmoContainer>& getAmmoContainer( ClassIDprojectileType);109 CountPointer<AmmoContainer>& getAmmoContainer(const ClassID& projectileType); 109 110 CountPointer<AmmoContainer>& getAmmoContainer(const Weapon* weapon); 110 111 -
trunk/src/world_entities/world_entity.cc
r9656 r9869 20 20 #include "shell_command.h" 21 21 22 #include "model.h" 22 #include "util/loading/resource_manager.h" 23 #include "resource_obj.h" 23 24 #include "md2/md2Model.h" 24 25 #include "md3/md3_model.h" … … 26 27 #include "aabb_tree_node.h" 27 28 28 #include "util/loading/resource_manager.h"29 29 #include "util/loading/load_param.h" 30 30 #include "obb_tree.h" … … 39 39 #include "game_rules.h" 40 40 #include "kill.h" 41 41 #include "debug.h" 42 43 #include "projectiles/projectile.h" 42 44 43 45 SHELL_COMMAND(model, WorldEntity, loadModel) … … 47 49 SHELL_COMMAND(debugEntity, WorldEntity, debugWE); 48 50 51 52 ObjectListDefinition(WorldEntity); 49 53 /** 50 54 * Loads the WordEntity-specific Part of any derived Class … … 56 60 : Synchronizeable() 57 61 { 58 this-> setClassID(CL_WORLD_ENTITY, "WorldEntity");62 this->registerObject(this, WorldEntity::_objectList); 59 63 60 64 this->obbTree = NULL; … … 72 76 this->objectListNumber = OM_INIT; 73 77 this->lastObjectListNumber = OM_INIT; 74 this->objectListIterator = NULL;75 78 76 79 // reset all collision handles to NULL == unsubscribed state … … 81 84 82 85 // registering default reactions: 83 this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /* CL_WORLD_ENTITY*/ CL_PROJECTILE);86 this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, /* WorldEntity::staticClassID(), */ Projectile::staticClassID()); 84 87 85 88 this->toList(OM_NULL); … … 160 163 std::string name = fileName; 161 164 162 if ( name.find( Resource Manager::getInstance()->getDataDir() ) == 0 )163 { 164 name.erase(Resource Manager::getInstance()->getDataDir().size());165 if ( name.find( Resources::ResourceManager::getInstance()->mainGlobalPath().name() ) == 0 ) 166 { 167 name.erase(Resources::ResourceManager::getInstance()->mainGlobalPath().name().size()); 165 168 } 166 169 … … 178 181 { 179 182 lodFile[offset] = 48+(int)i; 180 if (Resource Manager::isInDataDir(lodFile))183 if (Resources::ResourceManager::getInstance()->checkFileInMainPath( lodFile)) 181 184 this->loadModel(lodFile, scaling, i); 182 185 } … … 188 191 this->scaling = 1.0; 189 192 } 193 /// LOADING AN OBJ FILE 190 194 if(fileName.find(".obj") != std::string::npos) 191 195 { 192 196 PRINTF(4)("fetching OBJ file: %s\n", fileName.c_str()); 193 BaseObject* loadedModel = ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, this->scaling); 194 if (loadedModel != NULL) 195 this->setModel(dynamic_cast<Model*>(loadedModel), modelNumber); 197 StaticModel* model = new StaticModel(); 198 *model = ResourceOBJ(fileName, this->scaling); 199 if (model->getVertexCount() > 0) 200 { 201 this->setModel(model, modelNumber); 202 if( modelNumber == 0 /* FIXME && !this->isA(CL_WEAPON) */) 203 this->buildObbTree(obbTreeDepth); 204 } 196 205 else 197 PRINTF(1)("OBJ-File %s not found.\n", fileName.c_str()); 198 199 if( modelNumber == 0 && !this->isA(CL_WEAPON)) 200 this->buildObbTree(obbTreeDepth); 201 } 206 delete model; 207 } 208 /// LOADING AN MD2-model 202 209 else if(fileName.find(".md2") != std::string::npos) 203 210 { … … 210 217 this->buildObbTree(obbTreeDepth); 211 218 } 219 /// LOADING AN MD3-MODEL. 212 220 else if(fileName.find(".md3") != std::string::npos) 213 221 { 214 222 PRINTF(4)("fetching MD3 file: %s\n", fileName.c_str()); 215 Model* m = new md3::MD3Model(fileName, this->scaling);216 this->setModel(m, 0);217 218 // if( m != NULL)219 // this->buildObbTree(obbTreeDepth);223 // Model* m = new md3::MD3Model(fileName, this->scaling); 224 // this->setModel(m, 0); 225 226 // if( m != NULL) 227 // this->buildObbTree(obbTreeDepth); 220 228 } 221 229 } … … 238 246 if (this->models[modelNumber] != NULL) 239 247 { 240 Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(dynamic_cast<BaseObject*>(this->models[modelNumber])); 241 if (resource != NULL) 242 ResourceManager::getInstance()->unload(resource, RP_LEVEL); 243 else 244 { 245 PRINTF(4)("Forcing model deletion\n"); 246 delete this->models[modelNumber]; 247 } 248 delete this->models[modelNumber]; 248 249 } 249 250 … … 281 282 } 282 283 283 if( this->models[0] != NULL) { 284 if( this->models[0] != NULL) 285 { 284 286 this->aabbNode = new AABBTreeNode(); 285 287 this->aabbNode->spawnBVTree(this->models[0]); … … 300 302 * @param target1 a filter target (classID) 301 303 */ 302 void WorldEntity::subscribeReaction(CREngine::CRType type, longtarget1)304 void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1) 303 305 { 304 306 this->subscribeReaction(type); … … 314 316 * @param target1 a filter target (classID) 315 317 */ 316 void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, longtarget2)318 void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2) 317 319 { 318 320 this->subscribeReaction(type); … … 329 331 * @param target1 a filter target (classID) 330 332 */ 331 void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2, longtarget3)333 void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3) 332 334 { 333 335 this->subscribeReaction(type); … … 345 347 * @param target1 a filter target (classID) 346 348 */ 347 void WorldEntity::subscribeReaction(CREngine::CRType type, long target1, long target2, long target3, longtarget4)349 void WorldEntity::subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3, const ClassID& target4) 348 350 { 349 351 this->subscribeReaction(type); … … 365 367 void WorldEntity::subscribeReaction(CREngine::CRType type) 366 368 { 367 if( this->collisionHandles[type] != NULL) { 369 if( this->collisionHandles[type] != NULL) 370 { 368 371 PRINTF(2)("Registering for a CollisionReaction already subscribed to! Skipping\n"); 369 372 return; … … 496 499 void removeFromReflectionList() 497 500 { 498 /// TODO499 /// State::getObject501 /// TODO 502 /// State::getObject 500 503 } 501 504 … … 556 559 { 557 560 558 this->setAbsCoor(ray_2 - v);559 560 } 561 561 this->setAbsCoor(ray_2 - v); 562 563 } 564 else 562 565 { 563 566 if(ray_1.x == this->getAbsCoor().x + v.x && ray_1.y == this->getAbsCoor().y + v.y + 0.1 && ray_1.z ==this->getAbsCoor().z + v.z) … … 643 646 } 644 647 645 // if( this->aabbNode != NULL)646 // this->aabbNode->drawBV(0, DRAW_BV_POLYGON, Vector(1, 0.6, 0.2), true);648 // if( this->aabbNode != NULL) 649 // this->aabbNode->drawBV(0, DRAW_BV_POLYGON, Vector(1, 0.6, 0.2), true); 647 650 648 651 glPopMatrix(); -
trunk/src/world_entities/world_entity.h
r9656 r9869 37 37 38 38 39 39 40 //! Basis-class all interactive stuff in the world is derived from 40 41 class WorldEntity : public PNode 41 42 { 43 ObjectListDeclaration(WorldEntity); 42 44 public: 43 45 WorldEntity(); … … 49 51 void loadModel2(const std::string& fileN, float scal = 1.0f){this->loadModel(fileN,scal,0,4);} 50 52 void setModel(Model* model, unsigned int modelNumber = 0); 51 53 Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; }; 52 54 53 55 inline void loadMD2Texture(const std::string& fileName) { this->md2TextureFileName = fileName; } … … 73 75 74 76 75 /** @returns a reference to the obb tree of this worldentity */77 /** @returns a reference to the obb tree of this worldentity */ 76 78 inline BVTree* getOBBTree() const { return this->obbTree; }; 77 79 inline void setOBBTree(OBBTree* tree) { /*if( this->obbTree != NULL) delete this->obbTree;*/ this->obbTree = (BVTree*)tree; } … … 81 83 /* --- Collision Reaction Block --- */ 82 84 void subscribeReaction(CREngine::CRType type); 83 void subscribeReaction(CREngine::CRType type, longtarget1);84 void subscribeReaction(CREngine::CRType type, long target1, longtarget2);85 void subscribeReaction(CREngine::CRType type, long target1, long target2, longtarget3);86 void subscribeReaction(CREngine::CRType type, long target1, long target2, long target3, longtarget4);85 void subscribeReaction(CREngine::CRType type, const ClassID& target1); 86 void subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2); 87 void subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3); 88 void subscribeReaction(CREngine::CRType type, const ClassID& target1, const ClassID& target2, const ClassID& target3, const ClassID& target4); 87 89 88 90 void unsubscribeReaction(CREngine::CRType type); … … 126 128 127 129 void hide() { if( this->objectListNumber != OM_DEAD) this->lastObjectListNumber = this->objectListNumber; this->toList(OM_DEAD); } 128 130 void unhide() { if( this->objectListNumber != this->lastObjectListNumber) this->toList(this->lastObjectListNumber); } 129 131 130 132 131 133 /* --- Character Attribute Block --- */ 132 134 /** @returns the scaling of the model */ 133 135 float getScaling(){return this->scaling;} 134 136 /** @returns the damage dealt by this world entity */ 135 137 float getDamage() const { return this->damage; } … … 216 218 bool bOnGround; //!< true if this entity is standing on the ground 217 219 218 220 protected: 219 221 Vector velocity; //!< speed of the entity 220 222
Note: See TracChangeset
for help on using the changeset viewer.