Changeset 3605 in orxonox.OLD for orxonox/branches/levelloader/src/world_entities
- Timestamp:
- Mar 18, 2005, 11:52:15 AM (20 years ago)
- Location:
- orxonox/branches/levelloader/src/world_entities
- Files:
-
- 4 deleted
- 9 edited
- 10 copied
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/world_entities/environment.cc
r3557 r3605 100 100 Environment::~Environment () 101 101 { 102 delete this->model; 102 103 103 } 104 104 105 105 void Environment::tick (float time) {} 106 106 107 void Environment::hit (WorldEntity* weapon, Vector loc) {}107 void Environment::hit (WorldEntity* weapon, Vector* loc) {} 108 108 109 109 void Environment::destroy () {} … … 114 114 { 115 115 glMatrixMode(GL_MODELVIEW); 116 gl LoadIdentity();116 glPushMatrix(); 117 117 float matrix[4][4]; 118 118 … … 123 123 124 124 this->model->draw(); 125 126 glPopMatrix(); 125 127 } 126 128 -
orxonox/branches/levelloader/src/world_entities/environment.h
r3542 r3605 9 9 friend class World; 10 10 11 private:12 float xCor;13 float yCor;14 float zCor;15 16 float mountainTest[10][10];17 18 11 public: 19 12 Environment (); 20 13 Environment (TiXmlElement* root); 21 ~Environment (); 22 14 virtual ~Environment (); 23 15 24 16 virtual void tick (float time); 25 virtual void hit (WorldEntity* weapon, Vector loc);17 virtual void hit (WorldEntity* weapon, Vector* loc); 26 18 virtual void destroy (); 27 19 virtual void collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags); -
orxonox/branches/levelloader/src/world_entities/player.cc
r3604 r3605 16 16 */ 17 17 18 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_PLAYER 19 18 20 #include "player.h" 21 19 22 #include "stdincl.h" 20 23 //#include "collision.h" 21 24 #include "objModel.h" 25 #include "list.h" 26 #include "weapon.h" 27 #include "track_manager.h" 22 28 23 29 using namespace std; … … 31 37 Player::Player(bool isFree) : WorldEntity(isFree) 32 38 { 33 34 39 this->model = new OBJModel("../data/models/reaplow.obj"); 35 /*36 objectList = glGenLists(1);37 glNewList (objectList, GL_COMPILE); 38 39 glBegin(GL_TRIANGLES);40 glColor3f(1,1,1);41 glVertex3f(0,0,0.5);42 glVertex3f(-0.5,0,-1);43 glVertex3f(0.5,0,-1); 44 45 glVertex3f(0,0,0.5); 46 glVertex3f(0,0.5,-1);47 glVertex3f(0,-0.5,-1); 48 glEnd(); 49 50 glBegin(GL_QUADS);51 glColor3f(0,0,1);52 glVertex3f(0.5,0.5,-1);53 glVertex3f(0.5,-0.5,-1);54 glVertex3f(-0.5,-0.5,-1);55 glVertex3f(-0.5,0.5,-1);56 glEnd();57 58 glEndList ();59 */ 60 } 40 this->weapons = new tList<Weapon>(); 41 this->activeWeapon = NULL; 42 43 travelSpeed = 15.0; 44 velocity = Vector(); 45 bUp = bDown = bLeft = bRight = bAscend = bDescend = false; 46 bFire = false; 47 acceleration = 10.0; 48 } 49 50 /** 51 \brief destructs the player, deletes alocated memory 52 */ 53 Player::~Player () 54 { 55 Weapon* w = this->weapons->enumerate(); 56 while( w != NULL) 57 { 58 delete w; 59 w = this->weapons->nextElement(); 60 } 61 delete this->weapons; 62 63 //delete this->velocity; 64 } 65 61 66 62 67 /** … … 102 107 103 108 /** 104 \brief destructs the player 105 */ 106 Player::~Player () 107 { 108 delete this->model; 109 } 109 \brief adds a weapon to the weapon list of player 110 \param weapon to add 111 */ 112 void Player::addWeapon(Weapon* weapon) 113 { 114 this->weapons->add(weapon); 115 } 116 117 118 /** 119 \brief removes a weapon from the player 120 \param weapon to remove 121 */ 122 void Player::removeWeapon(Weapon* weapon) 123 { 124 this->weapons->remove(weapon); 125 } 126 110 127 111 128 /** … … 114 131 void Player::postSpawn () 115 132 { 116 travelSpeed = 15.0;117 velocity = Vector();118 bUp = bDown = bLeft = bRight = bAscend = bDescend = false;119 bFire = false;120 acceleration = 10.0;121 133 //setCollision(new CollisionCluster(1.0, Vector(0,0,0))); 122 134 } 123 135 124 /** 125 \brief the function called for each passing timeSnap 126 \param time The timespan passed since last update 127 */ 128 void Player::tick (float time) 129 { 130 // movement 131 this->move (time); 132 } 136 137 /** 138 \brief the action occuring if the player left the game 139 */ 140 void Player::leftWorld () 141 {} 142 143 133 144 134 145 /** … … 137 148 \param loc ?? 138 149 */ 139 void Player::hit (WorldEntity* weapon, Vector loc) 140 { 141 } 142 143 /** 144 \brief action that happens when the player is destroyed. 145 */ 146 void Player::destroy () 147 { 148 } 150 void Player::hit (WorldEntity* weapon, Vector* loc) 151 { 152 } 153 149 154 150 155 /** … … 158 163 } 159 164 160 /**161 \brief The connection to the command node162 \param cmd the Command unit from witch to map163 164 here the commands are mapped to the players movement/weaponary165 */166 void Player::command (Command* cmd)167 {168 //printf("Player|recieved command [%s]\n", cmd->cmd);169 if( !strcmp( cmd->cmd, "up")) bUp = !cmd->bUp;170 else if( !strcmp( cmd->cmd, "down")) bDown = !cmd->bUp;171 else if( !strcmp( cmd->cmd, "left")) bLeft = !cmd->bUp;172 else if( !strcmp( cmd->cmd, "right")) bRight = !cmd->bUp;173 else if( !strcmp( cmd->cmd, "fire")) bFire = !cmd->bUp;174 }175 165 176 166 /** … … 180 170 { 181 171 glMatrixMode(GL_MODELVIEW); 182 gl LoadIdentity();172 glPushMatrix(); 183 173 float matrix[4][4]; 184 174 … … 191 181 glMultMatrixf((float*)matrix); 192 182 193 glMatrixMode(GL_MODELVIEW);194 183 this->model->draw(); 195 // glCallList(objectList); 196 } 197 198 199 /*PN 200 void Player::getLookat(Location* locbuf) 201 { 202 *locbuf = *getLocation(); 203 //locbuf->dist += 5.0; 204 } 205 */ 206 207 /** 208 \brief the action occuring if the player left the game 209 */ 210 void Player::leftWorld () 211 { 212 } 184 glPopMatrix(); 185 } 186 187 188 /** 189 \brief the function called for each passing timeSnap 190 \param time The timespan passed since last update 191 */ 192 void Player::tick (float time) 193 { 194 // player controlled movement 195 this->move (time); 196 // weapon system manipulation 197 this->fire(); 198 } 199 213 200 214 201 /** … … 220 207 Vector accel(0.0, 0.0, 0.0); 221 208 /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */ 222 //Placement *pos = getPlacement();223 209 224 210 /* calculate the direction in which the craft is heading */ … … 228 214 //orthDirection = orthDirection.cross (direction); 229 215 230 if( bUp) { accel = accel+(direction*acceleration); } 231 if( bDown) { accel = accel-(direction*acceleration); } 232 if( bLeft ) { accel = accel - (orthDirection*acceleration); } 233 if( bRight ) { accel = accel + (orthDirection*acceleration); } 234 if( bAscend ) { /* not yet implemented but just: (0,0,1)*acceleration */} 235 if( bDescend) {/* FIXME */} /* \todo up and down player movement */ 236 237 //Location* l = getLocation(); 238 239 // r(t) = r(0) + v(0)*t + 1/2*a*t^2 240 // r = position 241 // v = velocity 242 // a = acceleration 243 244 /* this the base-speed of the player: determines how fast and how the player follows the track*/ 245 //l->dist = l->dist + travelSpeed * time; 246 247 Vector* shift = new Vector (this->travelSpeed * time, 0, 0); 248 this->shiftCoor (shift); 249 250 /* this updates the player position on the track - user interaction */ 251 //l->pos = l->pos + accel*time; 216 if( this->bUp && this->getRelCoor().x < 20) 217 accel = accel+(direction*acceleration); 218 if( this->bDown && this->getRelCoor().x > -5) 219 accel = accel-(direction*acceleration); 220 if( this->bLeft && TrackManager::getInstance()->getWidth() > -this->getRelCoor().z*2) 221 accel = accel - (orthDirection*acceleration); 222 if( this->bRight && TrackManager::getInstance()->getWidth() > this->getRelCoor().z*2) 223 accel = accel + (orthDirection*acceleration); 224 if( this->bAscend ) 225 if( this->bDescend) {/* FIXME */} /* \todo up and down player movement */ 226 252 227 Vector move = accel * time; 253 228 this->shiftCoor (&move); 254 229 } 230 231 232 /** 233 \brief weapon manipulation by the player 234 */ 235 void Player::fire() 236 { 237 if(this->bFire) 238 { 239 if(this->activeWeapon != NULL) 240 this->activeWeapon->fire(); 241 } 242 if(this->bWeaponChange) 243 { 244 Weapon* w = this->weapons->enumerate(); 245 this->activeWeapon = this->weapons->nextElement(this->activeWeapon); 246 } 247 } 248 249 250 /** 251 \brief The connection to the command node 252 \param cmd the Command unit from witch to map 253 254 here the commands are mapped to the players movement/weaponary 255 */ 256 void Player::command (Command* cmd) 257 { 258 PRINTF(3)("recieved command [%s]\n", cmd->cmd); 259 if( !strcmp( cmd->cmd, "up")) this->bUp = !cmd->bUp; 260 else if( !strcmp( cmd->cmd, "down")) this->bDown = !cmd->bUp; 261 else if( !strcmp( cmd->cmd, "left")) this->bLeft = !cmd->bUp; 262 else if( !strcmp( cmd->cmd, "right")) this->bRight = !cmd->bUp; 263 else if( !strcmp( cmd->cmd, "fire")) this->bFire = !cmd->bUp; 264 else if( !strcmp( cmd->cmd, "mode")) this->bWeaponChange = !cmd->bUp; 265 } -
orxonox/branches/levelloader/src/world_entities/player.h
r3542 r3605 9 9 #include "world_entity.h" 10 10 11 template<class T> class tList; 11 12 class OBJModel; 13 class Weapon; 12 14 13 15 //! Basic controllable WorldEntity … … 19 21 Player(bool isFree = false); 20 22 Player(TiXmlElement* root); 21 ~Player(); 23 virtual ~Player(); 24 25 void addWeapon(Weapon* weapon); 26 void removeWeapon(Weapon* weapon); 22 27 23 28 virtual void postSpawn(); 24 virtual void tick(float time); 25 virtual void hit(WorldEntity* weapon, Vector loc); 26 virtual void destroy(); 29 virtual void leftWorld(); 30 virtual void hit(WorldEntity* weapon, Vector* loc); 27 31 virtual void collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags); 32 33 virtual void tick(float time); 34 virtual void draw(); 35 28 36 virtual void command(Command* cmd); 29 30 virtual void draw();31 // virtual void getLookat(Location* locbuf);32 33 virtual void leftWorld();34 37 35 38 private: … … 41 44 bool bDescend; //!< descend button presses. 42 45 bool bFire; //!< fire button pressed. 46 bool bWeaponChange; //!< weapon change button pressed 47 48 tList<Weapon>* weapons;//!< a list of weapon 49 Weapon* activeWeapon; //!< the weapon that is currenty activated 43 50 44 51 Vector velocity; //!< the velocity of the player. … … 47 54 48 55 void move(float time); 56 void fire(void); 49 57 50 58 }; -
orxonox/branches/levelloader/src/world_entities/power_up.h
r3499 r3605 15 15 public: 16 16 PowerUp (); 17 ~PowerUp ();17 virtual ~PowerUp (); 18 18 19 19 }; -
orxonox/branches/levelloader/src/world_entities/skysphere.cc
r3499 r3605 24 24 */ 25 25 26 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY 27 26 28 #include "material.h" 27 29 #include "skysphere.h" … … 29 31 #include "vector.h" 30 32 #include "world_entity.h" 31 32 33 33 34 using namespace std; … … 38 39 Skysphere::Skysphere() 39 40 { 40 initialize("../data/pictures/sky-replace.jpg");41 this->initialize("../data/pictures/sky-replace.jpg"); 41 42 } 43 42 44 43 45 /** … … 47 49 Skysphere::Skysphere(char* fileName) 48 50 { 49 initialize(fileName);51 this->initialize(fileName); 50 52 } 53 51 54 52 55 /** … … 56 59 { 57 60 PRINTF(3)("Deleting the SkySphere\n"); 58 delete skyMaterial;59 free( sphereObj);61 delete this->skyMaterial; 62 free(this->sphereObj); 60 63 } 61 64 … … 69 72 this->sphereObj = gluNewQuadric(); 70 73 gluQuadricTexture(this->sphereObj, GL_TRUE); 71 this->setRadius( 250.0);74 this->setRadius(1900.0); 72 75 73 76 this->skyMaterial = new Material("Sky"); … … 75 78 this->skyMaterial->setIllum(3); 76 79 this->skyMaterial->setAmbient(1.0, 1.0, 1.0); 77 }78 79 80 /**81 \brief sets the Radius of the Sphere.82 \param radius The Radius of The Sphere83 */84 void Skysphere::setRadius(float radius)85 {86 this->sphereRadius = radius;87 80 } 88 81 … … 99 92 100 93 /** 101 \brief updates the position of the Skysphere102 \param sphereCenter The coordinate of the Center of the Sphere103 104 This is normally done in the update-phase of world, so the Skysphere is always centered at the Camera.105 */106 void Skysphere::updatePosition(Vector sphereCenter)107 {108 this->sphereCenter = sphereCenter;109 }110 111 112 /**113 94 \brief draws the Skysphere 114 95 … … 117 98 void Skysphere::draw() 118 99 { 119 glEnable(GL_TEXTURE_2D); 100 glPushMatrix(); 101 glMatrixMode(GL_MODELVIEW); 102 glTranslatef(this->absCoordinate.x, 103 this->absCoordinate.y, 104 this->absCoordinate.z); 105 106 //glRotatef(-30, 1, 0, 0); 107 //glRotatef(95.0f, 0.0f, 0.0f, 1.0f); 108 //glRotatef(-250.0f, 0.0, 1.0f, 0.0f); 109 120 110 skyMaterial->select(); 121 glPushMatrix(); 122 glTranslatef(this->sphereCenter.x,this->sphereCenter.y,this->sphereCenter.z); 123 124 glRotatef(-30, 1, 0, 0); 125 glRotatef(95.0f, 0.0f, 0.0f, 1.0f); 126 glRotatef(-250.0f, 0.0, 1.0f, 0.0f); 127 128 gluSphere(sphereObj, sphereRadius, 20, 20); 111 gluSphere(this->sphereObj, this->sphereRadius, 20, 20); 129 112 glPopMatrix(); 130 glDisable(GL_TEXTURE_2D);131 113 } 114 115 116 /** 117 \brief sets the Radius of the Sphere. 118 \param radius The Radius of The Sphere 119 */ 120 void Skysphere::setRadius(float radius) 121 { 122 this->sphereRadius = radius; 123 } -
orxonox/branches/levelloader/src/world_entities/skysphere.h
r3499 r3605 15 15 /* INCLUDES */ 16 16 #include "p_node.h" 17 #include "world_entity.h" 17 18 18 19 /* FORWARD DEFINITION */ … … 21 22 22 23 //! A Class to handle a SkySphere 23 class Skysphere : public PNode24 class Skysphere : public WorldEntity 24 25 { 25 26 … … 27 28 Skysphere(); 28 29 Skysphere(char* fileName); 29 ~Skysphere(); 30 virtual ~Skysphere(); 31 void destroy(); 30 32 31 33 void setRadius(float radius); 32 34 void setTexture(char* fileName); 33 35 34 void updatePosition(Vector sphereCenter); 35 void draw(); 36 virtual void draw(); 36 37 37 38 private: 38 39 GLUquadricObj *sphereObj; //!< A Placeholder for the SkySphere. 39 40 Material *skyMaterial; //!< A Material for the SkySphere. 40 Vector sphereCenter; //!< Center of the SkySphere.41 41 float sphereRadius; //!< Radius of the SkySphere. This should match the frustum maximum range. 42 43 42 44 43 void initialize(char* fileName); 45 44 }; -
orxonox/branches/levelloader/src/world_entities/world_entity.cc
r3499 r3605 38 38 this->setClassName ("WorldEntity"); 39 39 this->bDraw = true; 40 this->model = NULL; 40 41 // collisioncluster = NULL; 41 42 } … … 47 48 { 48 49 // if( collisioncluster != NULL) delete collisioncluster; 50 delete this->model; 49 51 } 50 52 51 53 /** 52 \brief get the Location of the WorldEntity 53 \return a pointer to location 54 \brief sets the character attributes of a worldentity 55 \param character attributes 56 57 these attributes don't have to be set, only use them, if you need them 54 58 */ 55 /*PN 56 Location* WorldEntity::getLocation () 57 { 58 return &loc; 59 } 60 */ 59 void WorldEntity::setCharacterAttributes(CharacterAttributes* charAttr) 60 {} 61 61 62 62 63 /** 63 \brief get the Placement of the WorldEntity64 \return a pointer to placement64 \brief gets the Character attributes of this worldentity 65 \returns character attributes 65 66 */ 66 /*PN 67 Placement* WorldEntity::getPlacement () 68 { 69 return &place; 70 } 71 */ 67 CharacterAttributes* WorldEntity::getCharacterAttributes() 68 {} 69 70 72 71 /** 73 72 \brief query whether the WorldEntity in question is free … … 93 92 } 94 93 */ 95 96 /**97 \brief this method is called every frame98 \param time: the time in seconds that has passed since the last tick99 100 Handle all stuff that should update with time inside this method (movement, animation, etc.)101 */102 void WorldEntity::tick(float time)103 {104 }105 94 106 95 … … 130 119 131 120 /** 132 \brief the entity is drawn onto the screen with this function133 134 This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.135 */136 void WorldEntity::draw()137 {}138 139 /**140 121 \brief this function is called, when two entities collide 141 122 \param other: the world entity with whom it collides … … 147 128 void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {} 148 129 130 149 131 /** 150 132 \brief this function is called, when the ship is hit by a waepon … … 154 136 calculate the damage depending 155 137 */ 156 void WorldEntity::hit(WorldEntity* weapon, Vector loc) {} 157 158 /** 159 \brief this function is called when the entity is to be destroied 160 161 This can be called, if eg. something realy bad happens :) 162 */ 163 void WorldEntity::destroy() {} 138 void WorldEntity::hit(WorldEntity* weapon, Vector* loc) {} 164 139 165 140 … … 174 149 } 175 150 151 152 /** 153 \brief this method is called by the world if the WorldEntity leaves valid gamespace 154 155 For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a 156 place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy). 157 */ 158 void WorldEntity::leftWorld () 159 { 160 } 161 162 163 /** 164 \brief this method is called every frame 165 \param time: the time in seconds that has passed since the last tick 166 167 Handle all stuff that should update with time inside this method (movement, animation, etc.) 168 */ 169 void WorldEntity::tick(float time) 170 { 171 } 172 173 174 /** 175 \brief the entity is drawn onto the screen with this function 176 177 This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn. 178 */ 179 void WorldEntity::draw() 180 {} 181 182 176 183 /** 177 184 \brief this handles incoming command messages … … 184 191 { 185 192 } 186 187 /**188 \brief this is called by the local Camera to determine the point it should look at on the WorldEntity189 \param locbuf: a pointer to the buffer to fill with a location to look at190 191 You may put any Location you want into locbuf, the Camera will determine via the corresponding Track how192 to look at the location you return with this.193 */194 /*PN195 void WorldEntity::getLookat (Location* locbuf)196 {197 }198 */199 200 /**201 \brief this method is called by the world if the WorldEntity leaves valid gamespace202 203 For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a204 place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).205 */206 void WorldEntity::leftWorld ()207 {208 } -
orxonox/branches/levelloader/src/world_entities/world_entity.h
r3499 r3605 9 9 #include "stdincl.h" 10 10 #include "p_node.h" 11 #include "objModel.h" 11 12 12 13 //class CollisionCluster; 13 class OBJModel; 14 class CharacterAttributes; 15 14 16 15 17 //! Basic class from which all interactive stuff in the world is derived from … … 22 24 virtual ~WorldEntity (); 23 25 24 OBJModel* model; //!< The model that should be loaded for this entity. 26 27 25 28 26 29 //void setCollision (CollisionCluster* newhull); 27 30 28 bool isFree ();29 30 31 //void addAbility(Ability* ability); 31 32 //void removeAbility(Ability* ability); 32 33 void setDrawable (bool bDraw); 34 bool isFree (); 35 void setCharacterAttributes(CharacterAttributes* charAttr); 36 CharacterAttributes* getCharacterAttributes(); 37 33 38 virtual void postSpawn (); 34 virtual void tick (float time);35 virtual void hit (WorldEntity* weapon, Vector loc); 36 virtual void destroy ();39 virtual void leftWorld (); 40 41 virtual void hit (WorldEntity* weapon, Vector* loc); 37 42 virtual void collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags); 38 43 virtual void command (Command* cmd); … … 40 45 void processDraw (); 41 46 virtual void draw (); 42 v oid setDrawable (bool bDraw);47 virtual void tick (float time); 43 48 44 virtual void leftWorld (); 49 protected: 50 OBJModel* model; //!< The model that should be loaded for this entity. 51 CharacterAttributes* charAttr; //!< the character attributes of a world_entity 45 52 46 53 private: … … 49 56 bool bDraw; //!< If it should be visible. 50 57 58 59 51 60 //CollisionCluster* collisioncluster; //!< The collision-Cluster of this entity. 52 61 };
Note: See TracChangeset
for help on using the changeset viewer.