Changeset 9516 in orxonox.OLD for branches/proxy/src/world_entities
- Timestamp:
- Jul 27, 2006, 6:45:58 PM (18 years ago)
- Location:
- branches/proxy/src/world_entities
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/world_entities/projectiles/guided_missile.h
r9235 r9516 13 13 class ParticleEmitter; 14 14 class FastFactory; 15 class Aim;16 15 17 16 class GuidedMissile : public Projectile -
branches/proxy/src/world_entities/weapons/aim.cc
r9406 r9516 50 50 Aim::~Aim () 51 51 { 52 if (this->material)53 delete this->material;54 55 52 /* if (this->text != NULL) 56 53 delete this->text;*/ … … 70 67 71 68 this->setBindNode(this); 72 this->material = new Material;73 69 this->source = NULL; 74 70 75 71 this->range = 10000; 76 72 this->angle = M_PI_4; 77 this-> group = OM_GROUP_01;73 this->targetGroup = OM_GROUP_02_PROJ; 78 74 this->anim = new tAnimation<Aim>(this, &Aim::setSize); 79 75 this->anim->setInfinity(ANIM_INF_CONSTANT); … … 103 99 LoadParam(root, "rotation-speed", this, Aim, setRotationSpeed) 104 100 .describe("the Speed with which the Aim should rotate"); 101 102 LoadParam(root, "target-group", this, Aim, setTargetGroupS); 105 103 } 106 104 … … 108 106 { 109 107 ObjectManager::EntityList::iterator entity; 110 111 for (entity = State::getObjectManager()->getObjectList(group).begin(); 112 entity != State::getObjectManager()->getObjectList(group).end(); 108 //printf("%d\n", this->targetGroup); 109 110 for (entity = State::getObjectManager()->getObjectList(this->targetGroup).begin(); 111 entity != State::getObjectManager()->getObjectList(this->targetGroup).end(); 113 112 entity ++) 114 113 { 115 114 diffVec = ( (*entity)->getAbsCoor() - this->source->getAbsCoor() ); 116 115 117 if ( diffVec.len() < range && acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle)116 if ( diffVec.len() < range )//&& acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) < angle) 118 117 { 119 118 //if (this->getParent() != (*entity)) 120 119 { 120 printf("found target::: %d %s::%s\n", (*entity)->getOMListNumber(), (*entity)->getClassCName(), (*entity)->getCName()); 121 121 this->anim->replay(); 122 this->setParent Soft(*entity, 5);122 this->setParent/*Soft*/(*entity/*, 5 */); 123 123 return; 124 124 } … … 128 128 //if no target found: 129 129 this->setParent(PNode::getNullParent()); 130 131 132 133 } 134 130 } 131 132 void Aim::setTargetGroupS(const std::string& groupName) 133 { 134 printf("::::::::::::::::::::::: TEST\n"); 135 OM_LIST id = ObjectManager::StringToOMList(groupName); 136 if (id != OM_NULL) 137 this->setTargetGroup(id); 138 else 139 PRINTF(2)("List %s not found for targetting\n", groupName.c_str()); 140 141 printf("targetGroup: %s, %d", groupName.c_str(), id); 142 } 135 143 136 144 /** … … 149 157 void Aim::setTexture(const std::string& textureFile) 150 158 { 151 this->material ->setDiffuseMap(textureFile);159 this->material.setDiffuseMap(textureFile); 152 160 } 153 161 … … 170 178 //only look for target if the aim hasn`t locked a target yet or if the actual target is out of range 171 179 if(this->getParent() == PNode::getNullParent() || 172 diffVec.len() > range ||173 ( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle))180 diffVec.len() > range )// || 181 //( acos( (this->source->getAbsDirX()).dot(diffVec)/(diffVec.len() * (this->source->getAbsDirX()).len() ) ) > angle)) 174 182 { 175 183 this->setParentSoft(PNode::getNullParent(),5); … … 213 221 214 222 glRotatef(this->getAbsDir2D(), 0,0,1); 215 this->material ->select();223 this->material.select(); 216 224 glBegin(GL_TRIANGLE_STRIP); 217 225 glTexCoord2f(0, 0); -
branches/proxy/src/world_entities/weapons/aim.h
r9513 r9516 11 11 #include "object_manager.h" 12 12 13 #include "material.h" 14 13 15 // FORWARD DECLARATION 14 16 class Model; 15 17 class Text; 16 class Material;17 18 class TiXmlElement; 18 19 template<class T> class tAnimation; … … 25 26 * Also the Aim is a Element2D, as it draws a cross onto the Target. 26 27 */ 27 class Aim : public PNode, public Element2D { 28 class Aim : public PNode, public Element2D 29 { 28 30 29 31 public: 30 32 Aim(PNode* source, const TiXmlElement* root = NULL); 31 33 virtual ~Aim(); 32 34 33 void init();34 35 virtual void loadParams(const TiXmlElement* root); 35 36 … … 43 44 void setRange(float range) {this->range = range;}; 44 45 void setAngle(float angle) {this->angle = angle;}; 45 void setGroup(OM_LIST group) {this->group = group;}; 46 void setTargetGroup(OM_LIST group) { this->targetGroup = group; }; 47 void setTargetGroupS(const std::string& grounName); 46 48 47 49 void setSize(float size); … … 53 55 virtual void draw() const; 54 56 55 private: 56 Material* material; //!< a material for the Aim. 57 float rotationSpeed; //!< Speed of the Rotation. 58 tAnimation<Aim>* anim; 57 private: 58 void init(); 59 59 60 float range; //!<61 float angle; //!<62 Vector diffVec;63 OM_LIST group;64 60 65 PNode* source; //!< Where this Shot has come from. 61 private: 62 Material material; //!< a material for the Aim. 63 float rotationSpeed; //!< Speed of the Rotation. 64 tAnimation<Aim>* anim; 66 65 67 Text* text; //!< A Text to display onto this Node. (distance to Target) 66 float range; //!< 67 float angle; //!< 68 Vector diffVec; 69 OM_LIST targetGroup; 70 71 PNode* source; //!< Where this Shot has come from. 72 73 // Text text; //!< A Text to display onto this Node. (distance to Target) 68 74 }; 69 75 -
branches/proxy/src/world_entities/weapons/targeting_turret.cc
r9406 r9516 17 17 #include "targeting_turret.h" 18 18 19 #include "weapon_manager.h" 20 #include "aim.h" 21 #include "world_entities/projectiles/projectile.h" 19 #include "projectiles/projectile.h" 22 20 23 21 #include "model.h" … … 25 23 #include "animation3d.h" 26 24 25 #include "util/loading/load_param.h" 27 26 #include "util/loading/factory.h" 28 27 … … 30 29 31 30 32 33 34 /**35 * standard constructor36 37 creates a new weapon38 */39 TargetingTurret::TargetingTurret ()40 : Weapon()41 {42 this->init();43 44 }45 46 47 31 TargetingTurret::TargetingTurret(const TiXmlElement* root) 32 : target(this) 48 33 { 49 34 this->init(); … … 91 76 //this->getProjectileFactory()->prepare(100); 92 77 93 this->target = new Aim(this);94 this->target ->setVisibility(false);95 this->target ->setRange(1000);96 this->target ->setAngle(M_PI_4);97 this->lockedTarget = this->target;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; 98 83 99 84 this->lockedTime = 0; … … 112 97 Weapon::loadParams(root); 113 98 99 LoadParam(root, "target-group", &target, Aim, setTargetGroupS); 100 114 101 } 115 102 … … 122 109 void TargetingTurret::deactivate() 123 110 { 124 this->target ->setVisibility(false);111 this->target.setVisibility(false); 125 112 } 126 113 … … 130 117 return; 131 118 119 this->target.tick(dt); 120 132 121 if( lockedTime >= neededLockTime ) 133 122 { 134 lockedTarget = this->target ->getParent();123 lockedTarget = this->target.getParent(); 135 124 lockedTime = 0; 136 125 } 137 126 138 this->target->tick(dt);139 127 140 if(this->target ->getParent() == PNode::getNullParent())128 if(this->target.getParent() == PNode::getNullParent()) 141 129 lockedTime = 0; 142 130 else -
branches/proxy/src/world_entities/weapons/targeting_turret.h
r8777 r9516 8 8 9 9 #include "weapon.h" 10 11 /* FORWARD DECLARATION */ 12 class Aim; 10 #include "aim.h" 13 11 14 12 class TargetingTurret : public Weapon 15 { 16 public: 17 TargetingTurret (); 18 TargetingTurret(const TiXmlElement* root); 19 virtual ~TargetingTurret (); 13 { 14 public: 15 TargetingTurret(const TiXmlElement* root = NULL); 16 virtual ~TargetingTurret (); 20 17 21 void init(); 22 virtual void loadParams(const TiXmlElement* root); 18 virtual void loadParams(const TiXmlElement* root); 23 19 24 25 20 virtual void activate(); 21 virtual void deactivate(); 26 22 27 28 23 virtual void tick(float dt); 24 virtual void fire(); 29 25 30 26 virtual void draw() const; 31 27 32 private: 33 Aim* target; 34 PNode* lockedTarget; 35 float lockedTime; 36 float neededLockTime; 37 }; 28 private: 29 void init(); 30 31 private: 32 Aim target; 33 PNode* lockedTarget; 34 float lockedTime; 35 float neededLockTime; 36 }; 38 37 39 38 #endif /* _TARGETING_TURRET_H */ -
branches/proxy/src/world_entities/world_entity.cc
r9513 r9516 28 28 #include "util/loading/resource_manager.h" 29 29 #include "util/loading/load_param.h" 30 #include "vector.h"31 30 #include "obb_tree.h" 32 31
Note: See TracChangeset
for help on using the changeset viewer.