Changeset 5994 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Dec 9, 2005, 10:43:31 AM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/environment.cc
r5750 r5994 37 37 this->init(); 38 38 this->loadModel("models/ships/bolido.obj"); 39 40 if(this->obbTree == NULL)41 this->obbTree = new OBBTree(4, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());42 39 } 43 40 … … 84 81 85 82 86 /**87 * draws the Environment88 */89 void Environment::draw () const90 {91 glMatrixMode(GL_MODELVIEW);92 glPushMatrix();93 float matrix[4][4];94 95 glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);96 //rotate97 this->getAbsDir().matrix (matrix);98 glMultMatrixf((float*)matrix);99 100 this->model->draw();101 102 glPopMatrix();103 }104 -
trunk/src/world_entities/environment.h
r5500 r5994 30 30 virtual void tick (float time); 31 31 32 virtual void draw () const;33 34 32 }; 35 33 -
trunk/src/world_entities/power_ups/laser_power_up.cc
r5915 r5994 112 112 Vector tmpRot = this->getAbsDir().getSpacialAxis(); 113 113 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 114 this-> model->draw();114 this->getModel()->draw(); 115 115 116 116 this->sphereMaterial->select(); -
trunk/src/world_entities/power_ups/turret_power_up.cc
r5915 r5994 112 112 Vector tmpRot = this->getAbsDir().getSpacialAxis(); 113 113 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 114 this-> model->draw();114 this->getModel()->draw(); 115 115 116 116 this->sphereMaterial->select(); -
trunk/src/world_entities/satellite.cc
r5500 r5994 34 34 this->setClassID(CL_SATELLITE, "Satellite"); 35 35 36 this-> model = (Model*) ResourceManager::getInstance()->load("cube", RP_LEVEL);36 this->loadModel("cube"); 37 37 this->speed = speed; 38 38 this->axis = new Vector(); … … 64 64 } 65 65 66 67 /**68 * the entity is drawn onto the screen with this function69 70 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.71 */72 void Satellite::draw() const73 {74 glMatrixMode(GL_MODELVIEW);75 glPushMatrix();76 float matrix[4][4];77 78 /* translate */79 glTranslatef (this->getAbsCoor ().x,80 this->getAbsCoor ().y,81 this->getAbsCoor ().z);82 /* rotate */83 this->getAbsDir ().matrix (matrix);84 glMultMatrixf((float*)matrix);85 86 this->model->draw();87 glPopMatrix();88 89 }90 -
trunk/src/world_entities/satellite.h
r5500 r5994 25 25 virtual ~Satellite (); 26 26 27 virtual void draw () const;28 27 virtual void tick (float time); 29 28 -
trunk/src/world_entities/skybox.cc
r5750 r5994 92 92 { 93 93 PRINTF(5)("Deleting SkyBox\n"); 94 this->setModel(NULL); //< so that WorldEntity does not try to delete it again. 94 95 for (int i = 0; i < 6; i++) 95 96 delete this->material[i]; 96 97 delete[] this->material; 97 delete this->model; 98 this->model = NULL; //< so that WorldEntity does not try to delete it again. 99 } 98 } 100 99 101 100 /** … … 171 170 void SkyBox::rebuild() 172 171 { 173 if (this->model)174 delete this->model; 175 model = new Model();176 177 this->model->addVertex (-0.5*size, -0.5*size, 0.5*size);178 this->model->addVertex (0.5*size, -0.5*size, 0.5*size);179 this->model->addVertex (-0.5*size, 0.5*size,0.5*size);180 this->model->addVertex (0.5*size, 0.5*size,0.5*size);181 this->model->addVertex (-0.5*size,0.5*size, -0.5*size);182 this->model->addVertex (0.5*size,0.5*size, -0.5*size);183 this->model->addVertex (-0.5*size, -0.5*size, -0.5*size); 184 this->model->addVertex (0.5*size, -0.5*size, -0.5*size);185 186 this->model->addVertexTexture (0.0, 1.0);187 this->model->addVertexTexture (1.0, 1.0);188 this->model->addVertexTexture (1.0, 0.0); 189 this->model->addVertexTexture (0.0, 0.0);190 191 this->model->addVertexNormal (0.0, 0.0,1.0);192 this->model->addVertexNormal (0.0,1.0, 0.0);193 this->model->addVertexNormal (0.0, 0.0, -1.0);194 this->model->addVertexNormal (0.0, -1.0, 0.0);195 this->model->addVertexNormal (1.0, 0.0, 0.0); 196 this->model->addVertexNormal (-1.0, 0.0, 0.0);197 198 this->model->setMaterial(material[0]);199 this->model->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,0,3, 3,1,3, 5,2,3, 4,3,3); // top200 this->model->setMaterial(material[1]);201 this->model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,1, 7,1,1, 1,2,1, 0,3,1); // bottom202 this->model->setMaterial(material[2]);203 this->model->addFace (4, VERTEX_TEXCOORD_NORMAL, 4,2,2, 5,3,2, 7,0,2, 6,1,2); // left204 this->model->setMaterial(material[3]);205 this->model->addFace (4, VERTEX_TEXCOORD_NORMAL, 0,0,0, 1,1,0, 3,2,0, 2,3,0); // right206 this->model->setMaterial(material[4]);207 this->model->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,0,5, 7,1,5, 5,2,5, 3,3,5); // front208 this->model->setMaterial(material[5]); 209 this->model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back210 211 this-> model->finalize();212 } 172 Model* model = new Model(); 173 174 model->addVertex (-0.5*size, -0.5*size, 0.5*size); 175 model->addVertex (0.5*size, -0.5*size, 0.5*size); 176 model->addVertex (-0.5*size, 0.5*size, 0.5*size); 177 model->addVertex (0.5*size, 0.5*size, 0.5*size); 178 model->addVertex (-0.5*size, 0.5*size, -0.5*size); 179 model->addVertex (0.5*size, 0.5*size, -0.5*size); 180 model->addVertex (-0.5*size, -0.5*size, -0.5*size); 181 model->addVertex (0.5*size, -0.5*size, -0.5*size); 182 183 model->addVertexTexture (0.0, 1.0); 184 model->addVertexTexture (1.0, 1.0); 185 model->addVertexTexture (1.0, 0.0); 186 model->addVertexTexture (0.0, 0.0); 187 188 model->addVertexNormal (0.0, 0.0, 1.0); 189 model->addVertexNormal (0.0, 1.0, 0.0); 190 model->addVertexNormal (0.0, 0.0, -1.0); 191 model->addVertexNormal (0.0, -1.0, 0.0); 192 model->addVertexNormal (1.0, 0.0, 0.0); 193 model->addVertexNormal (-1.0, 0.0, 0.0); 194 195 model->setMaterial(material[0]); 196 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,0,3, 3,1,3, 5,2,3, 4,3,3); // top 197 model->setMaterial(material[1]); 198 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,1, 7,1,1, 1,2,1, 0,3,1); // bottom 199 model->setMaterial(material[2]); 200 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 4,2,2, 5,3,2, 7,0,2, 6,1,2); // left 201 model->setMaterial(material[3]); 202 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 0,0,0, 1,1,0, 3,2,0, 2,3,0); // right 203 model->setMaterial(material[4]); 204 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,0,5, 7,1,5, 5,2,5, 3,3,5); // front 205 model->setMaterial(material[5]); 206 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back 207 208 model->finalize(); 209 210 this->setModel(model); 211 } -
trunk/src/world_entities/space_ships/space_ship.cc
r5982 r5994 250 250 Vector tmpRot = this->getAbsDir().getSpacialAxis(); 251 251 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 252 this-> model->draw();252 this->getModel()->draw(); 253 253 glPopMatrix(); 254 254 -
trunk/src/world_entities/terrain.cc
r5750 r5994 138 138 if (this->objectList) 139 139 glCallList(this->objectList); 140 else if (this-> model)141 this-> model->draw();140 else if (this->getModel()) 141 this->getModel()->draw(); 142 142 if (this->vegetation) 143 143 this->vegetation->draw(); -
trunk/src/world_entities/test_entity.cc
r5500 r5994 37 37 // this->md2Model = new MD2Model("models/tris.md2", "models/tris.pcx"); 38 38 // this->md2Model = new MD2Model("models/goblin.md2", "maps/goblin.bmp"); 39 this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices); 39 40 /// FIXME 41 // this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices); 40 42 41 43 this->md2Model->setAnim(RUN); -
trunk/src/world_entities/weapons/aiming_turret.cc
r5930 r5994 169 169 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 170 170 171 this-> model->draw();171 this->getModel()->draw(); 172 172 glPopMatrix(); 173 173 } -
trunk/src/world_entities/weapons/bomb.cc
r5828 r5994 147 147 if (this->lifeCycle < .9) 148 148 { 149 if ( model)150 model->draw();149 if (this->getModel() != NULL) 150 this->getModel()->draw(); 151 151 } 152 152 else -
trunk/src/world_entities/weapons/cannon.cc
r5930 r5994 194 194 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 195 195 196 this-> model->draw();196 this->getModel()->draw(); 197 197 glPopMatrix(); 198 198 -
trunk/src/world_entities/weapons/ground_turret.cc
r5982 r5994 128 128 glMultMatrixf((float*)matrix); 129 129 130 if (this-> model)131 this-> model->draw();130 if (this->getModel()) 131 this->getModel()->draw(); 132 132 133 133 glPopMatrix(); -
trunk/src/world_entities/weapons/guided_missile.cc
r5915 r5994 202 202 glMultMatrixf((float*)matrix); 203 203 glScalef(2.0, 2.0, 2.0); 204 this-> model->draw();204 this->getModel()->draw(); 205 205 206 206 glPopMatrix(); -
trunk/src/world_entities/weapons/laser.cc
r5779 r5994 156 156 glMultMatrixf((float*)matrix); 157 157 glScalef(2.0, 2.0, 2.0); 158 this-> model->draw();158 this->getModel()->draw(); 159 159 glPopAttrib(); 160 160 glPopMatrix(); -
trunk/src/world_entities/weapons/projectile.cc
r5769 r5994 137 137 {} 138 138 139 140 void Projectile::draw () const141 {142 glMatrixMode(GL_MODELVIEW);143 glPushMatrix();144 145 float matrix[4][4];146 glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);147 this->getAbsDir().matrix (matrix);148 glMultMatrixf((float*)matrix);149 this->model->draw();150 151 glPopMatrix();152 }153 -
trunk/src/world_entities/weapons/projectile.h
r5766 r5994 41 41 42 42 virtual void tick (float time); 43 virtual void draw () const;44 43 45 44 protected: -
trunk/src/world_entities/weapons/rocket.cc
r5819 r5994 187 187 glMultMatrixf((float*)matrix); 188 188 glScalef(2.0, 2.0, 2.0); 189 this-> model->draw();189 this->getModel()->draw(); 190 190 191 191 glPopMatrix(); -
trunk/src/world_entities/weapons/test_bullet.cc
r5779 r5994 181 181 glMultMatrixf((float*)matrix); 182 182 glScalef(2.0, 2.0, 2.0); 183 this-> model->draw();183 this->getModel()->draw(); 184 184 185 185 glPopMatrix(); -
trunk/src/world_entities/weapons/test_gun.cc
r5930 r5994 219 219 if( this->leftRight == W_RIGHT) 220 220 glScalef(1.0, 1.0, -1.0); 221 this-> model->draw(1);221 this->getModel()->draw(1); 222 222 glPopMatrix(); 223 223 … … 230 230 tmpRot = this->objectComponent1->getAbsDir().getSpacialAxis(); 231 231 glRotatef (this->objectComponent1->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 232 this-> model->draw(0);232 this->getModel()->draw(0); 233 233 glPopMatrix(); 234 234 } -
trunk/src/world_entities/weapons/turret.cc
r5930 r5994 147 147 void Turret::destroy () 148 148 {} 149 150 /**151 * draws the Turret152 */153 void Turret::draw () const154 {155 if (this->model != NULL)156 {157 /* draw gun body */158 glMatrixMode(GL_MODELVIEW);159 glPushMatrix();160 glTranslatef (this->getAbsCoor ().x,161 this->getAbsCoor ().y,162 this->getAbsCoor ().z);163 Vector tmpRot = this->getAbsDir().getSpacialAxis();164 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );165 166 this->model->draw();167 glPopMatrix();168 }169 } -
trunk/src/world_entities/weapons/turret.h
r5750 r5994 26 26 virtual void destroy(); 27 27 28 virtual void draw() const;29 28 30 29 private: -
trunk/src/world_entities/world_entity.cc
r5708 r5994 58 58 WorldEntity::~WorldEntity () 59 59 { 60 // Delete the model (unregister it with the ResourceManager)61 if (likely(this->model != NULL))62 ResourceManager::getInstance()->unload(this->model);63 60 // Delete the obbTree 64 61 if( this->obbTree != NULL) 65 62 delete this->obbTree; 63 64 // Delete the model (unregister it with the ResourceManager) 65 this->setModel(NULL); 66 66 } 67 67 … … 91 91 void WorldEntity::loadModel(const char* fileName, float scaling) 92 92 { 93 if (this->model)94 ResourceManager::getInstance()->unload(this->model, RP_LEVEL);95 93 if (fileName != NULL) 96 94 { 97 95 PRINTF(4)("fetching %s\n", fileName); 98 96 if (scaling == 1.0) 99 this-> model = (Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN);97 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN)); 100 98 else 101 this-> model = (Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling);99 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling)); 102 100 103 101 this->buildObbTree(4); … … 106 104 this->model = NULL; 107 105 } 106 107 /** 108 * sets a specific Model for the Object. 109 * @param model The Model to set 110 * @param modelNumber the n'th model in the List to get. 111 */ 112 void WorldEntity::setModel(Model* model, unsigned int modelNumber) 113 { 114 if (this->model != NULL) 115 { 116 Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(this->model); 117 if (resource != NULL) 118 ResourceManager::getInstance()->unload(resource, RP_LEVEL); 119 else 120 delete this->model; 121 } 122 this->model = model; 123 124 // if (this->model != NULL) 125 // this->buildObbTree(4); 126 } 127 108 128 109 129 /** -
trunk/src/world_entities/world_entity.h
r5511 r5994 28 28 29 29 void loadParams(const TiXmlElement* root); 30 30 31 void loadModel(const char* fileName, float scaling = 1.0f); 32 void setModel(Model* model, unsigned int modelNumber = 0); 33 Model* getModel(unsigned int modelNumber = 0) const { return this->model; }; 34 31 35 bool buildObbTree(unsigned int depth); 36 /** @returns a reference to the obb tree of this worldentity */ 37 BVTree* getOBBTree() const { return this->obbTree; }; 32 38 33 39 /** @param visibility if the Entity should be visible (been draw) */ … … 46 52 47 53 void drawBVTree(unsigned int depth, int drawMode) const; 48 /** @returns a reference to the obb tree of this worldentity */49 BVTree* getOBBTree() const { return this->obbTree; };50 54 51 55 /* @returns the Count of Faces on this WorldEntity */ … … 58 62 59 63 protected: 60 Model* model; //!< The model that should be loaded for this entity.61 BVTree* obbTree; //!< this is the obb tree reference needed for collision detection62 64 // CharacterAttributes* charAttr; //!< the character attributes of a world_entity 63 65 64 66 private: 67 Model* model; //!< The model that should be loaded for this entity. 68 BVTree* obbTree; //!< this is the obb tree reference needed for collision detection 69 65 70 bool bCollide; //!< If it should be considered for the collisiontest. 66 71 bool bVisible; //!< If it should be visible.
Note: See TracChangeset
for help on using the changeset viewer.