Changeset 4597 in orxonox.OLD for orxonox/trunk/src/world_entities
- Timestamp:
- Jun 11, 2005, 12:55:48 AM (20 years ago)
- Location:
- orxonox/trunk/src/world_entities
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/environment.cc
r4490 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 13 13 ### File Specific 14 14 main-programmer: Patrick Boenzli 15 co-programmer: 15 co-programmer: 16 16 */ 17 17 … … 31 31 Environment::Environment () : WorldEntity() 32 32 { 33 33 this->setClassID(CL_ENVIRONMENT, "Environment"); 34 34 } 35 35 … … 38 38 \brief deletes an environment 39 39 */ 40 Environment::~Environment () 40 Environment::~Environment () 41 41 { 42 42 … … 67 67 \brief draws the Environment 68 68 */ 69 void Environment::draw () 69 void Environment::draw () 70 70 { 71 71 //this->getRelCoor().debug(); … … 74 74 glPushMatrix(); 75 75 float matrix[4][4]; 76 76 77 77 glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); 78 78 //rotate 79 79 this->getAbsDir().matrix (matrix); 80 80 glMultMatrixf((float*)matrix); 81 81 82 82 this->model->draw(); 83 83 -
orxonox/trunk/src/world_entities/npc.cc
r3472 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 27 27 28 28 29 NPC::NPC() 30 : WorldEntity() 29 NPC::NPC() : WorldEntity() 31 30 { 31 this->setClassID(CL_NPC, "NPC"); 32 32 hasDied = 0; 33 33 } … … 41 41 } 42 42 43 void NPC::getPosition(float* x, float* y, float* z) 43 void NPC::getPosition(float* x, float* y, float* z) 44 44 { 45 *x = xCor; 46 *y = yCor; 45 *x = xCor; 46 *y = yCor; 47 47 *z = zCor; 48 48 } 49 49 50 void NPC::setCollisionRadius(float r) 50 void NPC::setCollisionRadius(float r) 51 51 { 52 52 collisionRadius = r; 53 53 } 54 54 55 float NPC::getCollisionRadius() 55 float NPC::getCollisionRadius() 56 56 { 57 57 return collisionRadius; … … 64 64 void NPC::paint() 65 65 { 66 //cout << "WorldEntity::WorldEntity();" << endl; 66 //cout << "WorldEntity::WorldEntity();" << endl; 67 67 /* fix: died flag approach is very stupid, just to show @ convention */ 68 68 if( hasDied == 0 ) { … … 75 75 } 76 76 77 void NPC::drawNPC() 77 void NPC::drawNPC() 78 78 { 79 79 -
orxonox/trunk/src/world_entities/player.cc
r4592 r4597 49 49 */ 50 50 this->setClassID(CL_PLAYER, "Player"); 51 51 52 this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN); 52 53 travelSpeed = 15.0; … … 90 91 { 91 92 this->setClassID(CL_PLAYER, "Player"); 93 92 94 this->weapons = new tList<Weapon>(); 93 95 this->activeWeapon = NULL; -
orxonox/trunk/src/world_entities/power_up.cc
r3483 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 24 24 25 25 26 PowerUp::PowerUp () {} 26 PowerUp::PowerUp () 27 { 28 this->setClassID(CL_POWER_UP, "PowerUp"); 29 } 27 30 28 31 -
orxonox/trunk/src/world_entities/projectile.cc
r4464 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 13 13 ### File Specific 14 14 main-programmer: Patrick Boenzli 15 co-programmer: 15 co-programmer: 16 16 */ 17 17 … … 34 34 { 35 35 this->setClassID(CL_PROJECTILE, "Projectile"); 36 36 37 this->weapon = weapon; 37 38 this->flightDirection = NULL; … … 45 46 \brief standard deconstructor 46 47 */ 47 Projectile::~Projectile () 48 Projectile::~Projectile () 48 49 { 49 /* 50 do not delete the test projectModel, since it is pnode 51 and will be cleaned out by world 50 /* 51 do not delete the test projectModel, since it is pnode 52 and will be cleaned out by world 52 53 */ 53 54 //delete this->projectileModel; … … 110 111 \param time since last tick 111 112 */ 112 void Projectile::tick (float time) 113 void Projectile::tick (float time) 113 114 { 114 115 Vector v = this->velocity * (time); … … 131 132 \param place where it is hit 132 133 */ 133 void Projectile::hit (WorldEntity* entity, Vector* place) 134 void Projectile::hit (WorldEntity* entity, Vector* place) 134 135 {} 135 136 … … 138 139 \brief the function gets called, when the projectile is destroyed 139 140 */ 140 void Projectile::destroy () 141 void Projectile::destroy () 141 142 {} 142 143 143 144 144 void Projectile::draw () 145 void Projectile::draw () 145 146 { 146 147 glMatrixMode(GL_MODELVIEW); 147 148 glPushMatrix(); 148 149 149 float matrix[4][4]; 150 float matrix[4][4]; 150 151 glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); 151 152 this->getAbsDir().matrix (matrix); 152 glMultMatrixf((float*)matrix); 153 glMultMatrixf((float*)matrix); 153 154 this->model->draw(); 154 155 -
orxonox/trunk/src/world_entities/projectile.h
r4464 r4597 1 /*! 1 /*! 2 2 \projectile.h 3 3 \brief a projectile, that is been shooted by a weapon 4 4 5 5 You can use this class to make some shoots, but this isn't the real idea. If you want to just test, if the 6 shooting funcions work, use the Projectile class. But if you want to implement your own shoots its 6 shooting funcions work, use the Projectile class. But if you want to implement your own shoots its 7 7 different:<br> 8 8 Make a new class and derive it from Projectile. To have a weapon work well, reimplement the functions … … 10 10 - void draw() 11 11 - void hit() (only if you have working collision detection) 12 When you have implemented these functions you have just to add the projectiles to your weapon. You ll want 13 to make this by looking into the function 12 When you have implemented these functions you have just to add the projectiles to your weapon. You ll want 13 to make this by looking into the function 14 14 - Weapon::fire() 15 15 there you just change the line: … … 27 27 class Weapon; 28 28 29 class Projectile : public WorldEntity 29 class Projectile : public WorldEntity 30 30 { 31 31 friend class World; … … 48 48 protected: 49 49 //physical attriutes like: force, speed, acceleration etc. 50 float speed;//!< this is the speed of the projectile51 float currentLifeTime;//!< this is the time, the projectile exists in this world (incremented by tick)52 float ttl;//!< time to life, after this time, the projectile will garbage collect itself53 Vector* flightDirection;//!< direction in which the shoot flights54 Weapon* weapon;//!< weapon the shoot belongs to55 56 Vector velocity;//!< velocity of the projectile57 Vector offsetVel;//!< offset velocity TEMP50 float speed; //!< this is the speed of the projectile 51 float currentLifeTime; //!< this is the time, the projectile exists in this world (incremented by tick) 52 float ttl; //!< time to life, after this time, the projectile will garbage collect itself 53 Vector* flightDirection; //!< direction in which the shoot flights 54 Weapon* weapon; //!< weapon the shoot belongs to 55 56 Vector velocity; //!< velocity of the projectile 57 Vector offsetVel; //!< offset velocity TEMP 58 58 }; 59 59 -
orxonox/trunk/src/world_entities/satellite.cc
r4320 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 13 13 ### File Specific: 14 14 main-programmer: Patrick Boenzli 15 co-programmer: 15 co-programmer: 16 16 */ 17 17 … … 32 32 { 33 33 this->setClassID(CL_SATELLITE, "Satellite"); 34 34 35 this->model = (Model*) ResourceManager::getInstance()->load("cube", RP_LEVEL); 35 36 this->speed = speed; … … 52 53 \brief this method is called every frame 53 54 \param time: the time in seconds that has passed since the last tick 54 55 55 56 Handle all stuff that should update with time inside this method (movement, animation, etc.) 56 57 */ 57 void Satellite::tick(float time) 58 void Satellite::tick(float time) 58 59 { 59 60 float w = this->speed * M_PI; 60 61 61 Quaternion rotation(w * time, *this->axis); 62 Quaternion rotation(w * time, *this->axis); 62 63 Quaternion v = this->getRelDir(); 63 64 64 65 this->setRelDir(v * rotation); 65 66 } … … 68 69 /** 69 70 \brief the entity is drawn onto the screen with this function 70 71 71 72 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. 72 73 */ 73 void Satellite::draw() 74 void Satellite::draw() 74 75 { 75 76 glMatrixMode(GL_MODELVIEW); 76 77 glPushMatrix(); 77 78 float matrix[4][4]; 78 79 79 80 /* translate */ 80 glTranslatef (this->getAbsCoor ().x, 81 this->getAbsCoor ().y, 82 81 glTranslatef (this->getAbsCoor ().x, 82 this->getAbsCoor ().y, 83 this->getAbsCoor ().z); 83 84 /* rotate */ 84 85 this->getAbsDir ().matrix (matrix); 85 86 glMultMatrixf((float*)matrix); 86 87 87 88 this->model->draw(); 88 89 glPopMatrix(); -
orxonox/trunk/src/world_entities/satellite.h
r3750 r4597 1 /*! 1 /*! 2 2 \file world_entity.h 3 3 \brief Definition of the basic WorldEntity … … 18 18 //! Basic class from which all interactive stuff in the world is derived from 19 19 class Satellite : public WorldEntity 20 { 20 { 21 21 friend class World; 22 22 … … 27 27 virtual void draw (); 28 28 virtual void tick (float time); 29 29 30 30 private: 31 Vector* axis;32 float speed;33 31 Vector* axis; 32 float speed; 33 34 34 35 35 }; -
orxonox/trunk/src/world_entities/skybox.cc
r4444 r4597 1 1 2 /* 2 /* 3 3 orxonox - the future of 3D-vertical-scrollers 4 4 … … 68 68 { 69 69 this->setClassID(CL_SKYBOX, "SkyBox"); 70 70 71 this->skyModel = NULL; 71 72 this->material = new Material*[6]; 72 for (int i = 0; i < 6; i++) 73 for (int i = 0; i < 6; i++) 73 74 { 74 75 this->material[i] = new Material(); … … 104 105 usage: give this function an argument like 105 106 setTexture("skybox", "jpg"); 106 and it will convert this to 107 and it will convert this to 107 108 setTextures("skybox_top.jpg", "skybox_bottom.jpg", "skybox_left.jpg", 108 109 "skybox_right.jpg", "skybox_front.jpg", "skybox_back.jpg"); … … 123 124 sprintf(front, "%s_front.%s", name, extension); 124 125 sprintf(back, "%s_back.%s", name, extension); 125 126 126 127 this->setTextures(top, bottom, left, right, front, back); 127 128 … … 180 181 /** 181 182 \brief rebuilds the SkyBox 182 183 183 184 this must be done, when changing the Size of the Skybox (runtime-efficency) 184 185 */ … … 189 190 skyModel = new Model(); 190 191 191 this->skyModel->addVertex (-0.5*size, -0.5*size, 0.5*size); 192 this->skyModel->addVertex (-0.5*size, -0.5*size, 0.5*size); 192 193 this->skyModel->addVertex (0.5*size, -0.5*size, 0.5*size); 193 194 this->skyModel->addVertex (-0.5*size, 0.5*size, 0.5*size); … … 222 223 this->skyModel->setMaterial(material[5]); 223 224 this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back 224 225 225 226 this->skyModel->finalize(); 226 227 } -
orxonox/trunk/src/world_entities/skybox.h
r4261 r4597 1 /*! 1 /*! 2 2 \file skybox.h 3 3 \brief Definition of the SkyBox, that handles the Display of an atmosphere for orxonox. … … 43 43 void rebuild(); 44 44 45 Model* skyModel; //!< A Model for the Sky. This must not be the same as the Model from WorldEntity, because it is not alocated through the ResourceManager.46 Material **material;//!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back47 float size;//!< Size of the SkyBox. This should match the frustum maximum range.48 45 Model* skyModel; //!< A Model for the Sky. This must not be the same as the Model from WorldEntity, because it is not alocated through the ResourceManager. 46 Material** material; //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back 47 float size; //!< Size of the SkyBox. This should match the frustum maximum range. 48 49 49 }; 50 50 -
orxonox/trunk/src/world_entities/skysphere.cc
r4444 r4597 1 1 2 /* 2 /* 3 3 orxonox - the future of 3D-vertical-scrollers 4 4 … … 13 13 main-programmer: David Gruetter 14 14 co-programmer: Benjamin Grauer 15 16 Created by Dave: this file is actually quite similar to player.cc and so is 15 16 Created by Dave: this file is actually quite similar to player.cc and so is 17 17 skybox.h similar to player.h 18 18 With that said, things should be clear:) 19 19 20 20 Edited: 21 21 Bensch: more constructors, changeability, comments... … … 43 43 Skysphere::Skysphere(char* fileName) 44 44 { 45 this->setClassID(CL_SKYSPHERE, "SkySphere"); 46 45 47 if (fileName == NULL) 46 48 this->initialize("pictures/sky-replace.jpg"); … … 92 94 /** 93 95 \brief draws the Skysphere 94 96 95 97 This part is normally precessed in the "Painting Phase". 96 98 */ … … 105 107 //glRotatef(95.0f, 0.0f, 0.0f, 1.0f); 106 108 //glRotatef(-250.0f, 0.0, 1.0f, 0.0f); 107 109 108 110 skyMaterial->select(); 109 111 gluSphere(this->sphereObj, this->sphereRadius, 20, 20); -
orxonox/trunk/src/world_entities/skysphere.h
r3763 r4597 1 /*! 1 /*! 2 2 \file skysphere.h 3 3 \brief Definition of the Skysphere, that handles the Display of an atmosphere of orxonox. … … 34 34 virtual void draw(); 35 35 36 private: 37 GLUquadricObj *sphereObj; //!< A Placeholder for the SkySphere. 38 Material *skyMaterial; //!< A Material for the SkySphere. 39 float sphereRadius; //!< Radius of the SkySphere. This should match the frustum maximum range. 40 41 void initialize(char* fileName); 36 private: 37 void initialize(char* fileName); 38 39 private: 40 GLUquadricObj* sphereObj; //!< A Placeholder for the SkySphere. 41 Material* skyMaterial; //!< A Material for the SkySphere. 42 float sphereRadius; //!< Radius of the SkySphere. This should match the frustum maximum range. 42 43 }; 43 44 -
orxonox/trunk/src/world_entities/terrain.cc
r4320 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 28 28 29 29 */ 30 Terrain::Terrain () 30 Terrain::Terrain () 31 31 { 32 32 this->init(); … … 36 36 \brief Constructor for loading a Terrain out of a file 37 37 \param fileName The file to load data from. 38 38 39 39 this either loads out of an OBJ-file, or loads a heightmap if no .obj-extension is found. 40 40 */ 41 Terrain::Terrain(c har* fileName)41 Terrain::Terrain(const char* fileName) 42 42 { 43 43 this->init(); … … 68 68 69 69 */ 70 Terrain::~Terrain () 70 Terrain::~Terrain () 71 71 { 72 72 if (objectList) … … 78 78 { 79 79 this->setClassID(CL_TERRAIN, "Terrain"); 80 80 81 this->objectList = 0; 81 82 } … … 84 85 85 86 void Terrain::draw () 86 { 87 { 87 88 glMatrixMode(GL_MODELVIEW); 88 89 glPushMatrix(); 89 90 float matrix[4][4]; 90 91 91 92 /* translate */ 92 glTranslatef (this->getAbsCoor ().x, 93 this->getAbsCoor ().y, 94 93 glTranslatef (this->getAbsCoor ().x, 94 this->getAbsCoor ().y, 95 this->getAbsCoor ().z); 95 96 /* rotate */ 96 97 this->getAbsDir ().matrix (matrix); … … 112 113 objectList = glGenLists(1); 113 114 glNewList (objectList, GL_COMPILE); 114 115 115 116 glColor3f(1.0,0,0); 116 117 117 118 int sizeX = 100; 118 119 int sizeZ = 80; … … 121 122 float widthX = float (length /sizeX); 122 123 float widthZ = float (width /sizeZ); 123 124 124 125 float height [sizeX][sizeZ]; 125 126 Vector normal_vectors[sizeX][sizeZ]; 126 127 127 128 128 129 for ( int i = 0; i<sizeX-1; i+=1) 129 130 130 for (int j = 0; j<sizeZ-1;j+=1) 131 //height[i][j] = rand()/20046 + (j-25)*(j-25)/30; 131 132 #ifdef __WIN32__ 132 133 height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5; 133 134 #else 134 135 height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.5; 135 136 #endif 136 137 137 138 //Die Huegel ein wenig glaetten 138 139 for (int h=1; h<2;h++) 139 140 141 142 140 for (int i=1;i<sizeX-2 ;i+=1 ) 141 for(int j=1;j<sizeZ-2;j+=1) 142 height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4; 143 143 144 //Berechnung von normalen Vektoren 144 145 for(int i=1;i<sizeX-2;i+=1) 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 146 for(int j=1;j<sizeZ-2 ;j+=1) 147 { 148 Vector v1 = Vector (widthX*(1), height[i][j], widthZ*(j) ); 149 Vector v2 = Vector (widthX*(i-1), height[i-1][j], widthZ*(j)); 150 Vector v3 = Vector (widthX*(i), height[i][j+1], widthZ*(j+1)); 151 Vector v4 = Vector (widthX*(i+1), height[i+1][j], widthZ*(j)); 152 Vector v5 = Vector (widthX*(i), height[i][j-1], widthZ*(j-1)); 153 154 Vector c1 = v2 - v1; 155 Vector c2 = v3 - v1; 156 Vector c3= v4 - v1; 157 Vector c4 = v5 - v1; 158 Vector zero = Vector (0,0,0); 159 normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4); 160 normal_vectors[i][j].normalize(); 161 } 162 162 163 glBegin(GL_QUADS); 163 164 int snowheight=3; 164 165 for ( int i = 0; i<sizeX; i+=1) 165 166 { 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 166 for (int j = 0; j<sizeZ;j+=1) 167 { 168 Vector v1 = Vector (widthX*(i), height[i][j]-20, widthZ*(j) -width/2); 169 Vector v2 = Vector (widthX*(i+1), height[i+1][j]-20, widthZ*(j) -width/2); 170 Vector v3 = Vector (widthX*(i+1), height[i+1][j+1]-20, widthZ*(j+1)-width/2); 171 Vector v4 = Vector (widthX*(i), height[i][j+1]-20, widthZ*(j+1)-width/2); 172 float a[3]; 173 if(height[i][j]<snowheight){ 174 a[0]=0; 175 a[1]=1.0-height[i][j]/10-.3; 176 a[2]=0; 177 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 178 } 179 else{ 180 a[0]=1.0; 181 a[1]=1.0; 182 a[2]=1.0; 183 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 184 185 } 186 glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z); 187 glVertex3f(v1.x, v1.y, v1.z); 188 if(height[i+1][j]<snowheight){ 189 a[0]=0; 190 a[1] =1.0-height[i+1][j]/10-.3; 191 a[2]=0; 192 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 193 } 194 else{ 195 a[0]=1.0; 196 a[1]=1.0; 197 a[2]=1.0; 198 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 199 200 } 201 glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z); 202 glVertex3f(v2.x, v2.y, v2.z); 203 if(height[i+1][j+1]<snowheight){ 204 a[0]=0; 205 a[1] =1.0-height[i+1][j+1]/10-.3; 206 a[2]=0; 207 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 208 } 209 else{ 210 a[0]=1.0; 211 a[1]=1.0; 212 a[2]=1.0; 213 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 214 215 216 } 217 glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z); 218 glVertex3f(v3.x, v3.y, v3.z); 219 if(height[i][j+1]<snowheight){ 220 a[0]=0; 221 a[1] =1.0-height[i+1][j+1]/10-.3; 222 a[2]=0; 223 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 224 } 225 else{ 226 a[0]=1.0; 227 a[1]=1.0; 228 a[2]=1.0; 229 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 230 } 231 glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z); 232 glVertex3f(v4.x, v4.y, v4.z); 233 234 } 234 235 glEnd(); 235 236 glEndList(); … … 239 240 { 240 241 /* 241 242 this->model = (OBJModel*) new Model(); 242 243 this->model->setName("CUBE"); 243 244 this->model->addVertex (-0.5, -0.5, 0.5); … … 249 250 this->model->addVertex (-0.5, -0.5, -0.5); 250 251 this->model->addVertex (0.5, -0.5, -0.5); 251 252 252 253 this->model->addVertexTexture (0.0, 0.0); 253 254 this->model->addVertexTexture (1.0, 0.0); … … 268 269 */ 269 270 } 270 271 } 271 272 } -
orxonox/trunk/src/world_entities/terrain.h
r3566 r4597 1 /*! 1 /*! 2 2 \file terrain.h 3 3 \brief Defines and handles the terrain of the World … … 20 20 21 21 //! A Class to handle Terrain of orxonox 22 class Terrain : public WorldEntity 22 class Terrain : public WorldEntity 23 23 { 24 24 25 25 public: 26 26 Terrain(); 27 Terrain(c har* fileName);27 Terrain(const char* fileName); 28 28 Terrain(DebugTerrain debugTerrain); 29 29 virtual ~Terrain(); 30 30 void init(); 31 31 32 32 void buildDebugTerrain(DebugTerrain debugTerrain); 33 33 virtual void draw(); -
orxonox/trunk/src/world_entities/test_bullet.cc
r4593 r4597 34 34 { 35 35 this->setClassID(CL_TEST_BULLET, "TestBullet"); 36 36 37 float modelSize = .5; 37 38 this->model = (Model*)ResourceManager::getInstance()->load("models/Rocket1.obj", OBJ, RP_LEVEL, (void*) &modelSize); -
orxonox/trunk/src/world_entities/test_gun.cc
r4592 r4597 43 43 creates a new weapon 44 44 */ 45 TestGun::TestGun (PNode* parent, const Vector& coordinate, const Quaternion& direction, int leftRight) 45 TestGun::TestGun (PNode* parent, const Vector& coordinate, 46 const Quaternion& direction, int leftRight) 46 47 : Weapon (parent, coordinate, direction) 47 48 { 48 49 this->setClassID(CL_TEST_GUN, "TestGun"); 50 49 51 this->model = (Model*)ResourceManager::getInstance()->load("models/test_gun.obj", OBJ, RP_CAMPAIGN); 50 52 this->idleTime = 0.2f; -
orxonox/trunk/src/world_entities/weapon.cc
r4000 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 13 13 ### File Specific 14 14 main-programmer: Patrick Boenzli 15 co-programmer: 15 co-programmer: 16 16 */ 17 17 … … 35 35 \param number of weapon slots of the model/ship <= 8 (limitied) 36 36 */ 37 WeaponManager::WeaponManager(int nrOfSlots) 38 { 37 WeaponManager::WeaponManager(int nrOfSlots) 38 { 39 this->setClassID(CL_WEAPON_MANAGER, "WeaponManager"); 40 39 41 for(int i = 0; i < W_MAX_CONFIGS; ++i) 40 42 { 41 43 this->configs[i].bUsed = false; 42 44 for(int j = 0; j < W_MAX_SLOTS; ++j) 43 45 this->configs[i].slots[j] = NULL; 44 46 } 45 47 this->nrOfSlots = nrOfSlots; … … 48 50 49 51 50 WeaponManager::~WeaponManager() 51 { 52 /* 53 i dont have to delete the weapons itself, because they are 52 WeaponManager::~WeaponManager() 53 { 54 /* 55 i dont have to delete the weapons itself, because they are 54 56 worldentities and therefore in the entities list of the world. 55 57 world will clean them up for me … … 59 61 this->configs[i].bUsed = false; 60 62 for(int j = 0; j < W_MAX_SLOTS; ++j) 61 63 this->configs[i].slots[j] = NULL; 62 64 } 63 65 } … … 72 74 if you add explicitly a weapon at config:n, slot:m, the weapon placed at this location will be 73 75 replaced by the weapon specified. if you use the W_FREE_SLOT, the manager will look for a free 74 slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be 76 slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be 75 77 a error message. 76 78 */ 77 void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID) 79 void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID) 78 80 { 79 81 if( slotID == W_FREE_SLOT) … … 81 83 int freeSlot = this->getNextFreeSlot( configID); 82 84 if( freeSlot < 0 || freeSlot >= this->nrOfSlots) 83 84 85 86 85 { 86 PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n"); 87 return; 88 } 87 89 PRINTF(3)("Added new Weapon to Config:%i/Slot:%i\n", configID, freeSlot); 88 90 this->configs[configID].bUsed = true; … … 108 110 this function will deactivate the weapons first, change the config and reactivate them later 109 111 */ 110 void WeaponManager::nextWeaponConf() 112 void WeaponManager::nextWeaponConf() 111 113 { 112 114 PRINTF(4)("Changing weapon configuration: from %i to next\n", this->currConfID); … … 116 118 for(i = this->currConfID + 1; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i); 117 119 if( i == W_MAX_CONFIGS) this->currConfID = W_CONFIG0; 118 else this->currConfID = i; 119 120 120 else this->currConfID = i; 121 122 121 123 Weapon *w1, *w2; 122 124 for(int j = 0; j < W_MAX_SLOTS; ++j) … … 124 126 w1 = this->configs[lastConfID].slots[j]; 125 127 w2 = this->configs[this->currConfID].slots[j]; 126 128 127 129 if( w1 == w2) 128 129 130 130 { 131 printf("no need for change\n"); 132 } 131 133 else 132 133 134 135 136 137 138 139 140 141 142 143 134 { 135 if( w1 != NULL ) 136 { 137 w1->deactivate(); 138 printf("deactivating %i,%i\n", j,lastConfID); 139 } 140 if( w2 != NULL) 141 { 142 w2->activate(); 143 printf("activating %i,%i\n", j, this->currConfID); 144 } 145 } 144 146 } 145 147 } … … 199 201 { 200 202 if( this->configs[configID].slots[i] == NULL) 201 203 return i; 202 204 } 203 205 return -1; … … 214 216 creates a new weapon 215 217 */ 216 Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction) 218 Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction) 217 219 : WorldEntity() 218 220 { … … 236 238 \brief standard deconstructor 237 239 */ 238 Weapon::~Weapon () 240 Weapon::~Weapon () 239 241 { 240 242 // model will be deleted from WorldEntity-destructor 241 243 //this->worldEntities = NULL; 242 244 243 245 /* dont delete objectComponentsX here, they will be killed when the pnodes are cleaned out */ 244 246 … … 247 249 248 250 249 /** 251 /** 250 252 \brief enables the weapon 251 253 252 a weapon can be enabled/disabled because of various reasons. if a weapon is 254 a weapon can be enabled/disabled because of various reasons. if a weapon is 253 255 been enabled, it can interact in a world. elswhere it wont react to any 254 256 action. … … 260 262 261 263 262 /** 264 /** 263 265 \brief disables the weapon 264 266 265 a weapon can be enabled/disabled because of various reasons. if a weapon is 267 a weapon can be enabled/disabled because of various reasons. if a weapon is 266 268 been enabled, it can interact in a world. elswhere it wont react to any 267 269 action. … … 273 275 274 276 275 /** 277 /** 276 278 \brief checks if the weapon is enabled 277 279 \returns true if enabled 278 280 279 a weapon can be ebabled/disabled because of various reasons. if a weapon is 281 a weapon can be ebabled/disabled because of various reasons. if a weapon is 280 282 been enabled, it can interact in a world. elswhere it wont react to any 281 283 action. … … 314 316 \brief this activates the weapon 315 317 316 This is needed, since there can be more than one weapon on a ship. the 317 activation can be connected with an animation. for example the weapon is 318 been armed out. 318 This is needed, since there can be more than one weapon on a ship. the 319 activation can be connected with an animation. for example the weapon is 320 been armed out. 319 321 */ 320 322 void Weapon::activate() … … 325 327 \brief this deactivates the weapon 326 328 327 This is needed, since there can be more than one weapon on a ship. the 328 activation can be connected with an animation. for example the weapon is 329 This is needed, since there can be more than one weapon on a ship. the 330 activation can be connected with an animation. for example the weapon is 329 331 been armed out. 330 332 */ … … 352 354 can destroy the weapons of enemies or vice versa. 353 355 */ 354 void Weapon::hit (WorldEntity* entity, Vector* position) 356 void Weapon::hit (WorldEntity* entity, Vector* position) 355 357 {} 356 358 … … 362 364 hit, it can also be destoryed. 363 365 */ 364 void Weapon::destroy () 366 void Weapon::destroy () 365 367 {} 366 368 … … 369 371 \brief tick signal for time dependent/driven stuff 370 372 */ 371 void Weapon::tick (float time) 373 void Weapon::tick (float time) 372 374 {} 373 375 … … 383 385 \brief this will draw the weapon 384 386 */ 385 void Weapon::draw () 386 {} 387 387 void Weapon::draw () 388 {} 389 -
orxonox/trunk/src/world_entities/weapon.h
r4504 r4597 1 /*! 1 /*! 2 2 \file weapon.h 3 3 \brief a weapon that a player can use … … 12 12 o slowdown-factor: this is a factor d: exp(-d*x), d is element of all positive R. it determines how fast the firing-rate will slow down. if no slowdown: d=0, the bigger d is, the faster the weapon will slow down! 13 13 o energy-consumption: this determines the energy that has to be used to produce this projectile = costs per projectile 14 14 15 15 Furthermore there are some other attributes, that will help to represent a firing 16 16 weapon in this world: 17 17 o sound file/ressource: this is a pointer to the sound-file/ressource. however it may be represented 18 18 o shooting animation 19 19 20 20 21 21 a player defines one or more weapon configurations. a player has got one to eight … … 31 31 #define _WEAPON_H 32 32 33 #include "base_object.h" 33 34 #include "world_entity.h" 34 35 … … 74 75 //! this is a weapon Configuration: it has up to 8 slots 75 76 typedef struct weaponConfig { 76 bool bUsed; //<! is set to true, if this configuration is 77 bool bUsed; //<! is set to true, if this configuration is 77 78 Weapon* slots[8]; 78 79 }; 79 80 80 81 81 class WeaponManager {82 class WeaponManager : public BaseObject { 82 83 public: 83 84 WeaponManager(int nrOfSlots = 2); 84 85 ~WeaponManager(); 85 86 86 87 void addWeapon(Weapon* weapon, int configID = W_CONFIG0, int slotID = W_FREE_SLOT); 87 88 void removeWeapon(Weapon* weapon, int configID = W_CONFIG0); … … 96 97 int currConfID; //<! the currently selected config 97 98 weaponConfig configs[4]; //<! a list of four configurations 98 99 99 100 int getNextFreeSlot(int configID); 100 101 }; 101 102 102 class Weapon : public WorldEntity 103 class Weapon : public WorldEntity 103 104 { 104 105 friend class World; … … 107 108 Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction); 108 109 virtual ~Weapon (); 109 110 110 111 void enable(void); 111 112 void disable(void); … … 123 124 \brief sets a weapon idle time 124 125 \param idle time in ms 125 126 126 127 a weapon idle time is the time spend after a shoot until the weapon can 127 128 shoot again … … 131 132 \brief gets the weapon idle time 132 133 \returns idle time in ms 133 134 134 135 a weapon idle time is the time spend after a shoot until the weapon can 135 136 shoot again … … 139 140 \brief checks if the idle time is elapsed 140 141 \return true if time is elapsed 141 142 142 143 a weapon idle time is the time spend after a shoot until the weapon can 143 144 shoot again … … 147 148 /** 148 149 \brief fires the weapon 149 150 150 151 this is called from the player.cc, when fire-button is been pushed 151 152 */ … … 153 154 virtual void hit (WorldEntity* weapon, Vector* loc); 154 155 virtual void destroy(void); 155 156 156 157 virtual void tick(float time); 157 158 virtual void weaponIdle(void); -
orxonox/trunk/src/world_entities/world_entity.cc
r4570 r4597 31 31 { 32 32 this->setClassID(CL_WORLD_ENTITY, "WorldEntity"); 33 33 34 this->model = NULL; 34 35
Note: See TracChangeset
for help on using the changeset viewer.