Changeset 4139 in orxonox.OLD for orxonox/branches/md2_loader/src/world_entities
- Timestamp:
- May 10, 2005, 10:39:01 AM (20 years ago)
- Location:
- orxonox/branches/md2_loader/src/world_entities
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/md2_loader/src/world_entities/environment.cc
r3986 r4139 30 30 { 31 31 this->model = (Model*) ResourceManager::getInstance()->load("cube", RP_LEVEL); 32 // this->model = new OBJModel("../data/models/fighter.obj");33 32 } 34 33 -
orxonox/branches/md2_loader/src/world_entities/player.cc
r4010 r4139 82 82 Player::Player(TiXmlElement* root) : WorldEntity(root) 83 83 { 84 /*85 char* temp;86 const char* string;87 string = grabParameter( root, "name");88 if( string == NULL)89 {90 PRINTF0("Player is missing a proper 'name'\n");91 string = "Unknown";92 temp = new char[strlen(string + 2)];93 strcpy( temp, string);94 this->setName( temp);95 }96 else97 {98 temp = new char[strlen(string + 2)];99 strcpy( temp, string);100 this->setName( temp);101 }102 103 this->model = NULL;104 string = grabParameter( root, "model");105 if( string != NULL)106 this->model = (Model*)ResourceManager::getInstance()->load(string, OBJ, RP_CAMPAIGN);107 else108 {109 PRINTF0("Player is missing a proper 'model'\n");110 this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN);111 }112 if( this->model == NULL)113 {114 PRINTF0("Player model '%s' could not be loaded\n", string);115 }116 */117 84 this->weapons = new tList<Weapon>(); 118 85 this->activeWeapon = NULL; … … 294 261 { 295 262 PRINTF(3)("recieved command [%s]\n", cmd->cmd); 296 if( !strcmp( cmd->cmd, "up")) this->bUp = !cmd->bUp;297 if( !strcmp( cmd->cmd, "down")) this->bDown = !cmd->bUp;298 if( !strcmp( cmd->cmd, "left")) this->bLeft = !cmd->bUp;299 if( !strcmp( cmd->cmd, "right")) this->bRight = !cmd->bUp;300 if( !strcmp( cmd->cmd, "fire")) this->bFire = !cmd->bUp;301 if( !strcmp( cmd->cmd, "mode")) if(cmd->bUp) this->bWeaponChange = !this->bWeaponChange;302 } 263 if( !strcmp( cmd->cmd, CONFIG_NAME_PLAYER_UP)) this->bUp = !cmd->bUp; 264 if( !strcmp( cmd->cmd, CONFIG_NAME_PLAYER_DOWN)) this->bDown = !cmd->bUp; 265 if( !strcmp( cmd->cmd, CONFIG_NAME_PLAYER_LEFT)) this->bLeft = !cmd->bUp; 266 if( !strcmp( cmd->cmd, CONFIG_NAME_PLAYER_RIGHT)) this->bRight = !cmd->bUp; 267 if( !strcmp( cmd->cmd, CONFIG_NAME_PLAYER_FIRE)) this->bFire = !cmd->bUp; 268 if( !strcmp( cmd->cmd, CONFIG_NAME_PLAYER_NEXT_WEAPON)) if(cmd->bUp) this->bWeaponChange = !this->bWeaponChange; 269 } -
orxonox/branches/md2_loader/src/world_entities/skybox.cc
r4012 r4139 66 66 PRINTF(0)("SkyBox is missing a proper 'MaterialSet'\n"); 67 67 } 68 if( this-> model == NULL)68 if( this->skyModel == NULL) 69 69 { 70 70 PRINTF(0)("SkyBox model '%s' could not be loaded\n", string); … … 76 76 { 77 77 this->setClassName("SkyBox"); 78 this->skyModel = NULL; 78 79 this->material = new Material*[6]; 79 for (int i = 0; i < 6; i++)80 for (int i = 0; i < 6; i++) 80 81 { 81 82 this->material[i] = new Material(); … … 100 101 SkyBox::~SkyBox() 101 102 { 102 PRINTF(5)("Deleting theSkyBox\n");103 PRINTF(5)("Deleting SkyBox\n"); 103 104 for (int i = 0; i < 6; i++) 104 105 delete this->material[i]; … … 179 180 glTranslatef(r.x, r.y, r.z); 180 181 181 this-> model->draw();182 this->skyModel->draw(); 182 183 183 184 glPopMatrix(); … … 192 193 void SkyBox::rebuild() 193 194 { 194 if (this-> model)195 delete model;196 model = new Model();197 198 model->addVertex (-0.5*size, -0.5*size, 0.5*size);199 model->addVertex (0.5*size, -0.5*size, 0.5*size);200 model->addVertex (-0.5*size, 0.5*size, 0.5*size);201 model->addVertex (0.5*size, 0.5*size, 0.5*size);202 model->addVertex (-0.5*size, 0.5*size, -0.5*size);203 model->addVertex (0.5*size, 0.5*size, -0.5*size);204 model->addVertex (-0.5*size, -0.5*size, -0.5*size);205 model->addVertex (0.5*size, -0.5*size, -0.5*size);206 207 model->addVertexTexture (0.0, 0.0);208 model->addVertexTexture (1.0, 0.0);209 model->addVertexTexture (1.0, 1.0);210 model->addVertexTexture (0.0, 1.0);211 212 model->addVertexNormal (0.0, 0.0, 1.0);213 model->addVertexNormal (0.0, 1.0, 0.0);214 model->addVertexNormal (0.0, 0.0, -1.0);215 model->addVertexNormal (0.0, -1.0, 0.0);216 model->addVertexNormal (1.0, 0.0, 0.0);217 model->addVertexNormal (-1.0, 0.0, 0.0);218 219 model->setMaterial(material[0]);220 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 3,2,4, 4,3,4, 6,4,4, 5,1,4); // top221 model->setMaterial(material[1]);222 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 7,4,2, 8,1,2, 2,2,2, 1,3,2); // bottom223 model->setMaterial(material[2]);224 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,1,3, 2,2,3, 4,3,3, 3,4,3); // left225 model->setMaterial(material[3]);226 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 5,3,1, 6,4,1, 8,1,1, 7,2,1); // right227 model->setMaterial(material[4]);228 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,1,6, 8,2,6, 6,3,6, 4,4,6); // front229 model->setMaterial(material[5]);230 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 7,1,5, 1,2,5, 3,3,5, 5,4,5); // back195 if (this->skyModel) 196 delete skyModel; 197 skyModel = new Model(); 198 199 this->skyModel->addVertex (-0.5*size, -0.5*size, 0.5*size); 200 this->skyModel->addVertex (0.5*size, -0.5*size, 0.5*size); 201 this->skyModel->addVertex (-0.5*size, 0.5*size, 0.5*size); 202 this->skyModel->addVertex (0.5*size, 0.5*size, 0.5*size); 203 this->skyModel->addVertex (-0.5*size, 0.5*size, -0.5*size); 204 this->skyModel->addVertex (0.5*size, 0.5*size, -0.5*size); 205 this->skyModel->addVertex (-0.5*size, -0.5*size, -0.5*size); 206 this->skyModel->addVertex (0.5*size, -0.5*size, -0.5*size); 207 208 this->skyModel->addVertexTexture (0.0, 0.0); 209 this->skyModel->addVertexTexture (1.0, 0.0); 210 this->skyModel->addVertexTexture (1.0, 1.0); 211 this->skyModel->addVertexTexture (0.0, 1.0); 212 213 this->skyModel->addVertexNormal (0.0, 0.0, 1.0); 214 this->skyModel->addVertexNormal (0.0, 1.0, 0.0); 215 this->skyModel->addVertexNormal (0.0, 0.0, -1.0); 216 this->skyModel->addVertexNormal (0.0, -1.0, 0.0); 217 this->skyModel->addVertexNormal (1.0, 0.0, 0.0); 218 this->skyModel->addVertexNormal (-1.0, 0.0, 0.0); 219 220 this->skyModel->setMaterial(material[0]); 221 this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,1,3, 3,2,3, 5,3,3, 4,0,3); // top 222 this->skyModel->setMaterial(material[1]); 223 this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,3,1, 7,0,1, 1,1,1, 0,2,1); // bottom 224 this->skyModel->setMaterial(material[2]); 225 this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 0,0,2, 1,1,2, 3,2,2, 2,3,2); // left 226 this->skyModel->setMaterial(material[3]); 227 this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 4,2,0, 5,3,0, 7,0,0, 6,1,0); // right 228 this->skyModel->setMaterial(material[4]); 229 this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,0,5, 7,1,5, 5,2,5, 3,3,6); // front 230 this->skyModel->setMaterial(material[5]); 231 this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back 231 232 232 model->finalize();233 } 233 this->skyModel->finalize(); 234 } -
orxonox/branches/md2_loader/src/world_entities/skybox.h
r4012 r4139 39 39 void rebuild(); 40 40 41 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. 41 42 Material **material; //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back 42 43 float size; //!< Size of the SkyBox. This should match the frustum maximum range. -
orxonox/branches/md2_loader/src/world_entities/skysphere.cc
r3763 r4139 44 44 { 45 45 if (fileName == NULL) 46 this->initialize(" ../data/pictures/sky-replace.jpg");46 this->initialize("pictures/sky-replace.jpg"); 47 47 else 48 48 this->initialize(fileName); -
orxonox/branches/md2_loader/src/world_entities/terrain.cc
r3677 r4139 77 77 void Terrain::init(void) 78 78 { 79 80 81 79 this->setClassName ("Terrain"); 80 81 this->objectList = 0; 82 82 } 83 83 … … 98 98 glMultMatrixf((float*)matrix); 99 99 100 if (objectList) 101 glCallList(objectList); 102 else if (model) 103 model->draw(); 104 // this->model->draw(); 100 if (this->objectList) 101 glCallList(this->objectList); 102 else if (this->model) 103 this->model->draw(); 105 104 glPopMatrix(); 106 105 } -
orxonox/branches/md2_loader/src/world_entities/world_entity.cc
r4013 r4139 30 30 /** 31 31 \brief standard constructor 32 33 Every derived contructor HAS to call the previous one supplying the isFree parameter. This is necessary to distunguish34 between free and bound entities. The difference between them is simply the fact that the movement of a free entity is35 not bound to the track of a world. Use this to implement projectile or effect classes that do not have to travel along the track.36 To specify an entity to be free or bound set the default parameter in the declaration of the constructor.37 Theoretically you should never have to call the constructor of an Entity directly, for it is called by the spawn() function of the World38 class. So if you want to create a new entity at any time, call World::spawn(). It will handle everything that is necessary.39 32 */ 40 33 WorldEntity::WorldEntity () … … 46 39 } 47 40 41 /** 42 \brief Loads the WordEntity-specific Part of any derived Class 43 */ 48 44 WorldEntity::WorldEntity(TiXmlElement* root) 49 45 { … … 54 50 if( string == NULL) 55 51 { 56 PRINTF( 0)("WorldEntity is missing a proper 'name'\n");52 PRINTF(2)("WorldEntity is missing a proper 'name'\n"); 57 53 string = "Unknown"; 58 54 temp = new char[strlen(string + 2)]; … … 73 69 else 74 70 { 75 PRINTF( 0)("WorldEntity is missing a proper 'model'\n");71 PRINTF(2)("WorldEntity is missing a proper 'model'\n"); 76 72 this->model = NULL; 77 73 } 78 74 if( this->model == NULL) 79 75 { 80 PRINTF(0)("WorldEntity model '%s' could not be loaded\n", string); 81 } 82 76 PRINTF(2)("WorldEntity model '%s' could not be loaded\n", string); 77 } 83 78 this->bDraw = true; 84 79 }
Note: See TracChangeset
for help on using the changeset viewer.