Changeset 4122 in orxonox.OLD for orxonox/branches/heightMap/src/world_entities
- Timestamp:
- May 9, 2005, 11:29:19 AM (20 years ago)
- Location:
- orxonox/branches/heightMap
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/heightMap
- Property svn:externals
-
old new 1 data http://svn.orxonox.ethz.ch/data 1
-
- Property svn:externals
-
orxonox/branches/heightMap/src/world_entities/camera.cc
r3869 r4122 139 139 if (tmpFovy > .001) 140 140 this->fovy += (this->toFovy - this->fovy) * dt; 141 Vector tmpPos = (this->toRelCoor - *this->getRelCoor()) * dt;141 Vector tmpPos = (this->toRelCoor - this->getRelCoor()) * dt; 142 142 if (tmpPos.len() >= .001) 143 143 { 144 tmpPos = tmpPos + *this->getRelCoor();144 tmpPos = tmpPos + this->getRelCoor(); 145 145 this->setRelCoor(tmpPos); 146 146 } -
orxonox/branches/heightMap/src/world_entities/environment.cc
r3739 r4122 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 … … 50 49 void Environment::draw () 51 50 { 51 //this->getRelCoor().debug(); 52 52 53 glMatrixMode(GL_MODELVIEW); 53 54 glPushMatrix(); -
orxonox/branches/heightMap/src/world_entities/player.cc
r3881 r4122 1 2 3 1 /* 4 2 orxonox - the future of 3D-vertical-scrollers … … 31 29 32 30 using namespace std; 31 32 CREATE_FACTORY(Player); 33 33 34 34 /** … … 52 52 //weapons: 53 53 this->weaponMan = new WeaponManager(); 54 Weapon* wpRight = new TestGun(this, Vector(-2.6, 0.1, 3.0), Quaternion(), 0);54 Weapon* wpRight = new TestGun(this, Vector(-2.6, 0.1, 3.0), Quaternion(), 0); 55 55 Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1); 56 56 57 this->weaponMan->addWeapon(wpRight, W_CONFIG0 );58 this->weaponMan->addWeapon(wpLeft, W_CONFIG1 );57 this->weaponMan->addWeapon(wpRight, W_CONFIG0, W_SLOT0); 58 this->weaponMan->addWeapon(wpLeft, W_CONFIG1, W_SLOT1); 59 59 this->weaponMan->addWeapon(wpRight, W_CONFIG2); 60 60 this->weaponMan->addWeapon(wpLeft, W_CONFIG2); … … 74 74 } 75 75 76 /** 77 \brief creates a new Player from Xml Data 78 \param root the xml element containing player data 79 80 \todo add more parameters to load 81 */ 82 Player::Player(TiXmlElement* root) : WorldEntity(root) 83 { 84 this->weapons = new tList<Weapon>(); 85 this->activeWeapon = NULL; 86 /* 87 this is the debug player - actualy we would have to make a new 88 class derivated from Player for each player. for now, we just use 89 the player.cc for debug also 90 */ 91 travelSpeed = 15.0; 92 velocity = new Vector(); 93 bUp = bDown = bLeft = bRight = bAscend = bDescend = false; 94 bFire = false; 95 this->bWeaponChange = false; 96 acceleration = 10.0; 97 //weapons: 98 this->weaponMan = new WeaponManager(); 99 Weapon* wpRight = new TestGun(this, Vector(-2.6, 0.1, 3.0), Quaternion(), 0); 100 Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1); 101 102 this->weaponMan->addWeapon(wpRight, W_CONFIG0, W_SLOT0); 103 this->weaponMan->addWeapon(wpLeft, W_CONFIG1, W_SLOT1); 104 this->weaponMan->addWeapon(wpRight, W_CONFIG2); 105 this->weaponMan->addWeapon(wpLeft, W_CONFIG2); 106 } 76 107 77 108 /** … … 188 219 //orthDirection = orthDirection.cross (direction); 189 220 190 if( this->bUp && this->getRelCoor() ->x < 20)221 if( this->bUp && this->getRelCoor().x < 20) 191 222 accel = accel+(direction*acceleration); 192 if( this->bDown && this->getRelCoor() ->x > -5)223 if( this->bDown && this->getRelCoor().x > -5) 193 224 accel = accel-(direction*acceleration); 194 if( this->bLeft && TrackManager::getInstance()->getWidth() > -this->getRelCoor() ->z*2)225 if( this->bLeft && TrackManager::getInstance()->getWidth() > -this->getRelCoor().z*2) 195 226 accel = accel - (orthDirection*acceleration); 196 if( this->bRight && TrackManager::getInstance()->getWidth() > this->getRelCoor() ->z*2)227 if( this->bRight && TrackManager::getInstance()->getWidth() > this->getRelCoor().z*2) 197 228 accel = accel + (orthDirection*acceleration); 198 229 if( this->bAscend ) … … 230 261 { 231 262 PRINTF(3)("recieved command [%s]\n", cmd->cmd); 232 if( !strcmp( cmd->cmd, "up")) this->bUp = !cmd->bUp;233 if( !strcmp( cmd->cmd, "down")) this->bDown = !cmd->bUp;234 if( !strcmp( cmd->cmd, "left")) this->bLeft = !cmd->bUp;235 if( !strcmp( cmd->cmd, "right")) this->bRight = !cmd->bUp;236 if( !strcmp( cmd->cmd, "fire")) this->bFire = !cmd->bUp;237 if( !strcmp( cmd->cmd, "mode")) if(cmd->bUp) this->bWeaponChange = !this->bWeaponChange;238 } 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/heightMap/src/world_entities/player.h
r3873 r4122 22 22 public: 23 23 Player(); 24 Player(TiXmlElement* root); 24 25 virtual ~Player(); 25 26 -
orxonox/branches/heightMap/src/world_entities/skybox.cc
r3913 r4122 28 28 29 29 #include "skybox.h" 30 30 31 #include "stdincl.h" 32 #include "factory.h" 31 33 32 34 #include "material.h" … … 36 38 //#include "world_entity.h" 37 39 40 CREATE_FACTORY(SkyBox); 38 41 39 42 using namespace std; … … 44 47 */ 45 48 SkyBox::SkyBox(char* fileName) 49 { 50 this->preInit(); 51 this->postInit(); 52 } 53 54 SkyBox::SkyBox(TiXmlElement* root) : WorldEntity(root) 55 { 56 this->preInit(); 57 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->model == NULL) 69 { 70 PRINTF(0)("SkyBox model '%s' could not be loaded\n", string); 71 } 72 this->postInit(); 73 } 74 75 void SkyBox::preInit(void) 46 76 { 47 77 this->setClassName("SkyBox"); … … 56 86 } 57 87 this->setMode(PNODE_MOVEMENT); 58 88 } 89 90 void SkyBox::postInit(void) 91 { 59 92 this->setSize(1900.0); 93 this->rebuild(); 60 94 } 61 95 … … 67 101 { 68 102 PRINTF(5)("Deleting the SkyBox\n"); 69 70 103 for (int i = 0; i < 6; i++) 71 104 delete this->material[i]; … … 84 117 void SkyBox::setTexture(const char* name, const char* extension) 85 118 { 86 char* top = new char[strlen(name)+strlen(extension)+ 6];87 char* bottom = new char[strlen(name)+strlen(extension)+ 9];88 char* left = new char[strlen(name)+strlen(extension)+ 7];89 char* right = new char[strlen(name)+strlen(extension)+ 8];90 char* front = new char[strlen(name)+strlen(extension)+ 8];91 char* back = new char[strlen(name)+strlen(extension)+ 7];119 char* top = new char[strlen(name)+strlen(extension)+ 10]; 120 char* bottom = new char[strlen(name)+strlen(extension)+ 10]; 121 char* left = new char[strlen(name)+strlen(extension)+ 10]; 122 char* right = new char[strlen(name)+strlen(extension)+ 10]; 123 char* front = new char[strlen(name)+strlen(extension)+ 10]; 124 char* back = new char[strlen(name)+strlen(extension)+ 10]; 92 125 93 126 sprintf(top, "%s_top.%s", name, extension); … … 100 133 this->setTextures(top, bottom, left, right, front, back); 101 134 135 // deleted alocated memory of this function 102 136 delete []top; 103 137 delete []bottom; … … 125 159 this->material[4]->setDiffuseMap(front); 126 160 this->material[5]->setDiffuseMap(back); 127 128 this->rebuild();129 161 } 130 162 … … 135 167 { 136 168 this->size = size; 137 138 this->rebuild();139 169 } 140 170 … … 188 218 189 219 model->setMaterial(material[0]); 190 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 3,2,4, 4,3,4, 6,4,4, 5,1,4); // top220 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,1,3, 3,2,3, 5,3,3, 4,0,3); // top 191 221 model->setMaterial(material[1]); 192 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 7,4,2, 8,1,2, 2,2,2, 1,3,2); // bottom222 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,3,1, 7,0,1, 1,1,1, 0,2,1); // bottom 193 223 model->setMaterial(material[2]); 194 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,1,3, 2,2,3, 4,3,3, 3,4,3); // left224 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 0,0,2, 1,1,2, 3,2,2, 2,3,2); // left 195 225 model->setMaterial(material[3]); 196 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 5,3,1, 6,4,1, 8,1,1, 7,2,1); // right226 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 4,2,0, 5,3,0, 7,0,0, 6,1,0); // right 197 227 model->setMaterial(material[4]); 198 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,1,6, 8,2,6, 6,3,6, 4,4,6); // front228 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,0,5, 7,1,5, 5,2,5, 3,3,6); // front 199 229 model->setMaterial(material[5]); 200 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 7,1,5, 1,2,5, 3,3,5, 5,4,5); // back230 model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back 201 231 202 232 model->finalize(); -
orxonox/branches/heightMap/src/world_entities/skybox.h
r3807 r4122 22 22 public: 23 23 SkyBox(char* fileName = NULL); 24 SkyBox(TiXmlElement* root); 25 24 26 virtual ~SkyBox(); 27 28 void preInit(void); 29 void postInit(void); 30 25 31 26 32 void setSize(float size); -
orxonox/branches/heightMap/src/world_entities/skysphere.cc
r3763 r4122 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/heightMap/src/world_entities/test_gun.cc
r3888 r4122 49 49 this->objectComponent1 = new PNode(); 50 50 this->animation1 = new Animation3D(this->objectComponent1); 51 parent->addChild(this->objectComponent1, PNODE_ALL); 51 this->animation2 = new Animation3D(this); 52 this->animation3 = new Animation3D(this); 53 //parent->addChild(this->objectComponent1, PNODE_ALL); 54 this->addChild(this->objectComponent1, PNODE_ALL); 52 55 53 56 this->animation1->setInfinity(ANIM_INF_CONSTANT); 54 // ANIM_LINEAR was ANIM_NEG_EXP 57 this->animation2->setInfinity(ANIM_INF_CONSTANT); 58 this->animation3->setInfinity(ANIM_INF_CONSTANT); 55 59 if( this->leftRight == W_LEFT) 56 60 { 57 61 this->projectileOffset = Vector(1.0, 0.0, -0.35); 58 62 59 this->animation1->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR); 60 this->animation1->addKeyFrame(Vector(-3.0, 0.1, 3.0), Quaternion(), 0.5, ANIM_LINEAR); 61 this->animation1->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR); 63 this->animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 64 this->animation1->addKeyFrame(Vector(-0.4, 0, 0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 65 this->animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT); 66 67 this->animation2->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 68 this->animation2->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 69 70 this->animation3->addKeyFrame(Vector(-2.6, 0.1, 3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 71 this->animation3->addKeyFrame(Vector(-2.6, 0.1, 2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 62 72 } 63 73 else if( this->leftRight == W_RIGHT) … … 65 75 this->projectileOffset = Vector(1.0, 0.0, 0.5); 66 76 67 this->animation1->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.1, ANIM_LINEAR); 68 this->animation1->addKeyFrame(Vector(-3.0, 0.1, -2.5), Quaternion(), 0.5, ANIM_LINEAR); 69 this->animation1->addKeyFrame(Vector(-2.6, 0.1, -2.5), Quaternion(), 0.1, ANIM_LINEAR); 77 this->objectComponent1->setRelCoor(Vector(0,0,0.35)); 78 this->animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 79 this->animation1->addKeyFrame(Vector(-0.4, 0, .5), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 80 this->animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT); 81 82 this->animation2->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 83 this->animation2->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 84 85 this->animation3->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 86 this->animation3->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_CONSTANT); 70 87 } 88 71 89 } 72 90 … … 89 107 */ 90 108 void TestGun::activate() 91 {} 109 { 110 this->animation2->replay(); 111 } 92 112 93 113 … … 100 120 */ 101 121 void TestGun::deactivate() 102 {} 122 { 123 this->animation3->replay(); 124 } 103 125 104 126 -
orxonox/branches/heightMap/src/world_entities/weapon.cc
r3888 r4122 110 110 void WeaponManager::nextWeaponConf() 111 111 { 112 PRINTF(4)("Changing weapon configuration: from %i\n", this->currConfID); 113 114 Weapon* w; 115 for(int i = 0; i < W_MAX_SLOTS; ++i) 116 { 117 w = this->configs[this->currConfID].slots[i]; 118 if( w != NULL) w->deactivate(); 119 } 120 int i; 112 PRINTF(4)("Changing weapon configuration: from %i to next\n", this->currConfID); 113 114 int i, lastConfID; 115 lastConfID = this->currConfID; 121 116 for(i = this->currConfID + 1; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i); 122 117 if( i == W_MAX_CONFIGS) this->currConfID = W_CONFIG0; 123 118 else this->currConfID = i; 124 PRINTF(4)("\tto %i\n", this->currConfID); 125 126 for(int i = 0; i < W_MAX_SLOTS; ++i) 127 { 128 w = this->configs[this->currConfID].slots[i]; 129 if( w != NULL) w->activate(); 119 120 121 Weapon *w1, *w2; 122 for(int j = 0; j < W_MAX_SLOTS; ++j) 123 { 124 w1 = this->configs[lastConfID].slots[j]; 125 w2 = this->configs[this->currConfID].slots[j]; 126 127 if( w1 == w2) 128 { 129 printf("no need for change\n"); 130 } 131 else 132 { 133 if( w1 != NULL ) 134 { 135 w1->deactivate(); 136 printf("deactivating %i,%i\n", j,lastConfID); 137 } 138 if( w2 != NULL) 139 { 140 w2->activate(); 141 printf("activating %i,%i\n", j, this->currConfID); 142 } 143 } 130 144 } 131 145 } -
orxonox/branches/heightMap/src/world_entities/world_entity.cc
r3832 r4122 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 distunguish 34 between free and bound entities. The difference between them is simply the fact that the movement of a free entity is 35 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 World 38 class. So if you want to create a new entity at any time, call World::spawn(). It will handle everything that is necessary. 39 */ 40 WorldEntity::WorldEntity (bool isFree) : bFree(isFree) 32 */ 33 WorldEntity::WorldEntity () 41 34 { 42 35 this->setClassName ("WorldEntity"); … … 47 40 48 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 } 64 // 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; 79 } 80 81 /** 49 82 \brief standard destructor 50 83 */ … … 73 106 {} 74 107 75 76 /**77 \brief query whether the WorldEntity in question is free78 \return true if the WorldEntity is free or false if it isn't79 */80 bool WorldEntity::isFree ()81 {82 return bFree;83 }84 108 85 109 /** -
orxonox/branches/heightMap/src/world_entities/world_entity.h
r3799 r4122 23 23 24 24 public: 25 WorldEntity (bool isFree = false); 25 WorldEntity (void); 26 WorldEntity(TiXmlElement* root); 26 27 virtual ~WorldEntity (); 27 28 … … 32 33 //void removeAbility(Ability* ability); 33 34 void setDrawable (bool bDraw); 34 bool isFree ();35 35 void setCharacterAttributes(CharacterAttributes* charAttr); 36 36 CharacterAttributes* getCharacterAttributes(); … … 52 52 53 53 private: 54 const bool bFree; //!< If the entity is free.55 54 bool bCollide; //!< If it should be considered for the collisiontest. 56 55 bool bDraw; //!< If it should be visible.
Note: See TracChangeset
for help on using the changeset viewer.