Changeset 4283 in orxonox.OLD for orxonox/branches/physics/src/world_entities
- Timestamp:
- May 24, 2005, 10:32:34 PM (20 years ago)
- Location:
- orxonox/branches/physics/src/world_entities
- Files:
-
- 6 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/world_entities/player.cc
r4178 r4283 80 80 \todo add more parameters to load 81 81 */ 82 Player::Player( TiXmlElement* root) : WorldEntity(root)82 Player::Player(const TiXmlElement* root) : WorldEntity(root) 83 83 { 84 84 this->weapons = new tList<Weapon>(); -
orxonox/branches/physics/src/world_entities/player.h
r4178 r4283 22 22 public: 23 23 Player(); 24 Player( TiXmlElement* root);24 Player(const TiXmlElement* root); 25 25 virtual ~Player(); 26 26 -
orxonox/branches/physics/src/world_entities/skybox.cc
r4178 r4283 11 11 12 12 ### File Specific: 13 main-programmer: David Gruetter 14 co-programmer: Benjamin Grauer 15 16 Created by Dave: this file is actually quite similar to player.cc and so is 17 skybox.h similar to player.h 18 With that said, things should be clear:) 19 20 Edited: 21 Bensch: more constructors, changeability, comments... 22 Patrick: giving it the common orxonox style, not much to do... good work Dave! 23 13 main-programmer: Benjamin Grauer 14 co-programmer: ... 24 15 */ 25 16 … … 46 37 \param fileName the file to take as input for the SkyBox 47 38 */ 48 SkyBox::SkyBox(c har* fileName)39 SkyBox::SkyBox(const char* fileName) 49 40 { 50 41 this->preInit(); 42 if (fileName) 43 this->setTextureAndType(fileName, ".jpg"); 51 44 this->postInit(); 52 45 } 53 46 54 SkyBox::SkyBox( TiXmlElement* root) : WorldEntity(root)47 SkyBox::SkyBox(const TiXmlElement* root) : WorldEntity(root) 55 48 { 56 49 this->preInit(); 57 50 58 const char* string; 59 60 // Model Loading 61 string = grabParameter( root, "materialset"); 62 if( string != NULL) 63 this->setTexture(string, "jpg"); 64 else 65 { 66 PRINTF(0)("SkyBox is missing a proper 'MaterialSet'\n"); 67 } 68 if( this->skyModel == NULL) 69 { 70 PRINTF(0)("SkyBox model '%s' could not be loaded\n", string); 71 } 51 this->loadParams(root); 52 72 53 this->postInit(); 54 } 55 56 void SkyBox::loadParams(const TiXmlElement* root) 57 { 58 LoadParam<SkyBox>(root, "Materialset", this, &SkyBox::setTexture) 59 .describe("Sets the material on the SkyBox. The string must be the path relative to the data-dir, and without a trailing .jpg"); 73 60 } 74 61 … … 116 103 "skybox_right.jpg", "skybox_front.jpg", "skybox_back.jpg"); 117 104 */ 118 void SkyBox::setTexture (const char* name, const char* extension)105 void SkyBox::setTextureAndType(const char* name, const char* extension) 119 106 { 120 107 char* top = new char[strlen(name)+strlen(extension)+ 10]; … … 219 206 220 207 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); // top208 this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,0,3, 3,1,3, 5,2,3, 4,3,3); // top 222 209 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); // bottom210 this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,1, 7,1,1, 1,2,1, 0,3,1); // bottom 224 211 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); // left212 this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 4,2,2, 5,3,2, 7,0,2, 6,1,2); // left 226 213 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); // right214 this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 0,0,0, 1,1,0, 3,2,0, 2,3,0); // right 228 215 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); // front216 this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,0,5, 7,1,5, 5,2,5, 3,3,5); // front 230 217 this->skyModel->setMaterial(material[5]); 231 218 this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back -
orxonox/branches/physics/src/world_entities/skybox.h
r4178 r4283 21 21 { 22 22 public: 23 SkyBox(c har* fileName = NULL);24 SkyBox( TiXmlElement* root);23 SkyBox(const char* fileName = NULL); 24 SkyBox(const TiXmlElement* root); 25 25 26 26 virtual ~SkyBox(); 27 28 void loadParams(const TiXmlElement* root); 27 29 28 30 void preInit(void); … … 31 33 32 34 void setSize(float size); 33 void setTexture(const char* name, const char* extension); 35 /** \brief assumes jpg as input-format */ 36 void setTexture(const char* name) { setTextureAndType (name, "jpg");}; 37 void setTextureAndType(const char* name, const char* extension); 34 38 void setTextures(const char* top, const char* bottom, const char* left, const char* right, const char* front, const char* back); 35 39 -
orxonox/branches/physics/src/world_entities/world_entity.cc
r4178 r4283 23 23 #include "vector.h" 24 24 25 //#include "stdincl.h"26 //#include "collision.h"27 28 25 using namespace std; 29 26 30 27 /** 31 \brief standard constructor32 */ 33 WorldEntity::WorldEntity ()28 \brief Loads the WordEntity-specific Part of any derived Class 29 */ 30 WorldEntity::WorldEntity(const TiXmlElement* root) 34 31 { 35 32 this->setClassName ("WorldEntity"); 33 this->model = NULL; 34 35 if (root) 36 this->loadParams(root); 37 36 38 this->bDraw = true; 37 this->model = NULL; 38 // collisioncluster = NULL; 39 } 40 41 /** 42 \brief Loads the WordEntity-specific Part of any derived Class 43 */ 44 WorldEntity::WorldEntity(TiXmlElement* root) 45 { 46 // Name Setup 47 char* temp; 48 const char* string; 49 string = grabParameter( root, "name"); 50 if( string == NULL) 51 { 52 PRINTF(2)("WorldEntity is missing a proper 'name'\n"); 53 string = "Unknown"; 54 temp = new char[strlen(string + 2)]; 55 strcpy( temp, string); 56 this->setName( temp); 57 } 58 else 59 { 60 temp = new char[strlen(string + 2)]; 61 strcpy( temp, string); 62 this->setName( temp); 63 } 39 } 40 41 void WorldEntity::loadParams(const TiXmlElement* root) 42 { 43 // name setup 44 LoadParam<WorldEntity>(root, "name", this, &WorldEntity::setName) 45 .describe("the name of the Object at hand"); 46 64 47 // Model Loading 65 this->model = NULL; 66 string = grabParameter( root, "model"); 67 if( string != NULL) 68 this->model = (Model*)ResourceManager::getInstance()->load(string, OBJ, RP_CAMPAIGN); 69 else 70 { 71 PRINTF(2)("WorldEntity is missing a proper 'model'\n"); 72 this->model = NULL; 73 } 74 if( this->model == NULL) 75 { 76 PRINTF(2)("WorldEntity model '%s' could not be loaded\n", string); 77 } 78 this->bDraw = true; 48 LoadParam<WorldEntity>(root, "model", this, &WorldEntity::loadModel) 49 .describe("the fileName of the model, that should be loaded onto this world-entity. (must be relative to the data-dir)") ; 79 50 } 80 51 … … 87 58 if (this->model) 88 59 ResourceManager::getInstance()->unload(this->model); 60 } 61 62 /** 63 \brief loads a Model onto a WorldEntity 64 \param fileName the name of the model to load 65 */ 66 void WorldEntity::loadModel(const char* fileName) 67 { 68 if (this->model) 69 ResourceManager::getInstance()->unload(this->model, RP_LEVEL); 70 this->model = (Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN); 89 71 } 90 72 -
orxonox/branches/physics/src/world_entities/world_entity.h
r4178 r4283 10 10 #include "comincl.h" 11 11 #include "resource_manager.h" 12 #include "factory.h" 13 #include "load_param.h" 12 14 13 15 … … 15 17 class CharacterAttributes; 16 18 class Model; 17 18 19 19 //! Basic class from which all interactive stuff in the world is derived from 20 20 class WorldEntity : public PNode … … 23 23 24 24 public: 25 WorldEntity (void); 26 WorldEntity(TiXmlElement* root); 25 WorldEntity(const TiXmlElement* root = NULL); 27 26 virtual ~WorldEntity (); 28 27 28 void loadParams(const TiXmlElement* root); 29 void loadModel(const char* fileName); 29 30 30 31 //void setCollision (CollisionCluster* newhull);
Note: See TracChangeset
for help on using the changeset viewer.