- Timestamp:
- Jul 4, 2006, 8:27:13 PM (18 years ago)
- Location:
- branches/presentation/src/world_entities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/presentation/src/world_entities/creatures/fps_player.cc
r9166 r9168 145 145 this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0); 146 146 147 this->aimingSystem = new AimingSystem( );147 this->aimingSystem = new AimingSystem(this); 148 148 this->addChild(this->aimingSystem); 149 this->aimingSystem->toList(OM_LIST(this->getOMListNumber() + 1)); 149 150 150 151 151 … … 242 242 this->getWeaponManager().setSlotPosition(0, Vector(1.5, box->halfLength[1] * f - 0.7, 1.1)); 243 243 this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * f, 0.0)); 244 245 this->aimingSystem->toList(/*OM_LIST(this->getOMListNumber() + 1)*/ OM_GROUP_00); 244 246 } 245 247 } … … 266 268 } 267 269 } 270 271 WorldEntity* target = this->aimingSystem->getNearestTarget(); 272 if( target != NULL) 273 { 274 PRINTF(0)("hit hit hit, got: %s\n", target->getClassName()); 275 } 276 268 277 269 278 -
branches/presentation/src/world_entities/weapons/aiming_system.cc
r9166 r9168 10 10 11 11 ### File Specific: 12 main-programmer: Benjamin Grauer12 main-programmer: Patrick Boenzli 13 13 co-programmer: ... 14 14 */ … … 23 23 24 24 #include "aabb.h" 25 #include "obb_tree.h" 25 26 26 27 #include <vector> … … 33 34 * standart constructor 34 35 */ 35 AimingSystem::AimingSystem ( const TiXmlElement* root)36 AimingSystem::AimingSystem (WorldEntity* entity) 36 37 { 37 38 this->init(); 38 39 40 if (root)41 this->loadParams(root);42 39 } 43 40 … … 59 56 60 57 this->loadModel("models/guns/targeting_system_body.obj"); 61 }62 58 63 64 void AimingSystem::loadParams(const TiXmlElement* root) 65 { 66 PNode::loadParams(root); 67 68 // LoadParam(root, "texture", this, AimingSystem, setTexture) 69 // .describe("the texture-file to load onto the AimingSystem"); 70 // 71 // LoadParam(root, "size", this, AimingSystem, setSize) 72 // .describe("the size of the AimingSystem in Pixels"); 73 // 74 // LoadParam(root, "rotation-speed", this, AimingSystem, setRotationSpeed) 75 // .describe("the Speed with which the AimingSystem should rotate"); 59 // registering default reactions: 60 this->subscribeReaction(CREngine::CR_OBJECT_DAMAGE, CL_WORLD_ENTITY); 76 61 } 77 62 … … 89 74 return this->selectionList.back(); 90 75 91 WorldEntity* nearestEntity = this->selectionList.back();76 WorldEntity* nearestEntity = NULL; 92 77 float distance = 0.0f; 93 78 float smalestDistance = this->range * 5.0f; … … 104 89 } 105 90 106 return nearestEntity; 91 if( nearestEntity != this->owner) 92 return nearestEntity; 93 else return NULL; 107 94 } 108 95 … … 127 114 { 128 115 129 this->selectionList.clear();116 // this->selectionList.clear(); 130 117 } 131 118 … … 136 123 void AimingSystem::draw() const 137 124 { 138 // if( this->getModelAABB() != NULL) 139 // this->getModelAABB()->drawBV(0, 1); 125 WorldEntity::draw(); 126 127 if( this->getOBBTree () != NULL) 128 this->getOBBTree()->drawBV(0, 1); 140 129 } -
branches/presentation/src/world_entities/weapons/aiming_system.h
r9166 r9168 22 22 23 23 public: 24 AimingSystem( const TiXmlElement* root= NULL);24 AimingSystem(WorldEntity* owner = NULL); 25 25 virtual ~AimingSystem(); 26 26 27 27 void init(); 28 virtual void loadParams(const TiXmlElement* root);29 30 31 inline void selectTarget(PNode* target) { this->setParent(target); };32 inline PNode* getTarget(PNode* target) { return this->getParent(); };33 28 34 29 WorldEntity* getNearestTarget(); 35 36 30 37 31 void setRange(float range){this->range = range;}; … … 47 41 std::vector<WorldEntity*> selectionList; //!< the selections 48 42 43 WorldEntity* owner; //!< the owner of the targeting system 49 44 50 45 }; -
branches/presentation/src/world_entities/world_entity.cc
r9162 r9168 85 85 86 86 this->toList(OM_NULL); 87 87 88 88 registerVar( new SynchronizeableString( &this->md2TextureFileName, &this->md2TextureFileName, "md2TextureFileName" ) ); 89 89 modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) ); 90 90 scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling" ) ); 91 91 list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list" ) ); 92 92 93 93 health_handle = registerVarId( new SynchronizeableFloat( &this->health, &this->health_write, "health" ) ); 94 94 healthMax_handle = registerVarId( new SynchronizeableFloat( &this->healthMax, &this->healthMax_write, "maxHealth" ) ); … … 742 742 this->decreaseHealth(damage); 743 743 744 PRINTF( 0)("Hit me: %s now only %f/%f health\n", this->getClassName(), this->getHealth(), this->getHealthMax());744 PRINTF(5)("Hit me: %s now only %f/%f health\n", this->getClassName(), this->getHealth(), this->getHealthMax()); 745 745 746 746 if( this->getHealth() > 0) … … 838 838 this->toList( (OM_LIST)list_write ); 839 839 } 840 840 841 841 if ( std::find( id.begin(), id.end(), health_handle ) != id.end() ) 842 842 { 843 843 this->setHealth( health_write ); 844 844 } 845 845 846 846 if ( std::find( id.begin(), id.end(), healthMax_handle ) != id.end() ) 847 847 {
Note: See TracChangeset
for help on using the changeset viewer.