Changeset 3803 in orxonox.OLD for orxonox/trunk/src/world_entities
- Timestamp:
- Apr 13, 2005, 7:38:52 PM (20 years ago)
- Location:
- orxonox/trunk/src/world_entities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/skybox.cc
r3801 r3803 46 46 { 47 47 this->setClassName("SkyBox"); 48 49 this->model = NULL;50 51 this->setMode(PNODE_MOVEMENT);52 53 this->setSize(1900.0);54 this->rebuild();55 56 48 this->material = new Material*[6]; 57 49 for (int i = 0; i <6; i++) … … 61 53 this->material[i]->setAmbient(1.0, 1.0, 1.0); 62 54 } 55 this->setMode(PNODE_MOVEMENT); 56 57 58 59 this->setSize(1900.0); 60 this->rebuild(); 63 61 } 64 62 … … 76 74 } 77 75 78 76 /** 77 \brief sets A set of textures when just giving a Name and an extension: 78 79 usage: give this function an argument like 80 setTexture("skybox", "jpg"); 81 and it will convert this to 82 setTextures("skybox_top.jpg", "skybox_bottom.jpg", "skybox_left.jpg", 83 "skybox_right.jpg", "skybox_front.jpg", "skybox_back.jpg"); 84 */ 85 void SkyBox::setTexture(const char* name, const char* extension) 86 { 87 char* top = new char[strlen(name)+strlen(extension)+ 6]; 88 char* bottom = new char[strlen(name)+strlen(extension)+ 9]; 89 char* left = new char[strlen(name)+strlen(extension)+ 7]; 90 char* right = new char[strlen(name)+strlen(extension)+ 8]; 91 char* front = new char[strlen(name)+strlen(extension)+ 8]; 92 char* back = new char[strlen(name)+strlen(extension)+ 7]; 93 94 sprintf(top, "%s_top.%s", name, extension); 95 sprintf(bottom, "%s_bottom.%s", name, extension); 96 sprintf(left, "%s_left.%s", name, extension); 97 sprintf(right, "%s_right.%s", name, extension); 98 sprintf(front, "%s_front.%s", name, extension); 99 sprintf(back, "%s_back.%s", name, extension); 100 101 this->setTextures(top, bottom, left, right, front, back); 102 103 delete []top; 104 delete []bottom; 105 delete []left; 106 delete []right; 107 delete []front; 108 delete []back; 109 } 110 111 /** 112 \brief Defines which textures should be loaded onto the SkyBox. 113 \param top the top texture. 114 \param bottom the bottom texture. 115 \param left the left texture. 116 \param right the right texture. 117 \param front the front texture. 118 \param back the back texture. 119 */ 120 void SkyBox::setTextures(const char* top, const char* bottom, const char* left, const char* right, const char* front, const char* back) 121 { 122 this->material[0]->setDiffuseMap(top); 123 this->material[1]->setDiffuseMap(bottom); 124 this->material[2]->setDiffuseMap(left); 125 this->material[3]->setDiffuseMap(right); 126 this->material[4]->setDiffuseMap(front); 127 this->material[5]->setDiffuseMap(back); 128 } 129 130 /** 131 \brief sets the Radius of the Sphere. 132 \param radius The Radius of The Sphere 133 */ 134 void SkyBox::setSize(float size) 135 { 136 this->size = size; 137 } 138 139 /** 140 \brief rebuilds the SkyBox 141 142 this must be done, when changing the Size of the Skybox (runtime-efficency) 143 */ 79 144 void SkyBox::rebuild() 80 145 { … … 144 209 model->addUseMtl(material[5]); 145 210 model->addFace (4, 3, 7,13,21, 1,1,22, 3,3,23, 5,14,24); 146 } 147 148 /** 149 \brief Defines which texture should be loaded onto the SkyBox. 150 \param fileName The filename of the Texture 151 */ 152 void SkyBox::setTexture(char* top, char* bottom, char* left, char* right, char* front, char* back) 153 { 154 this->material[0]->setDiffuseMap(top); 155 this->material[1]->setDiffuseMap(bottom); 156 this->material[2]->setDiffuseMap(left); 157 this->material[3]->setDiffuseMap(right); 158 this->material[4]->setDiffuseMap(front); 159 this->material[5]->setDiffuseMap(back); 160 } 161 162 163 /** 164 \brief draws the SkyBox 165 166 This part is normally precessed in the "Painting Phase". 167 */ 168 void SkyBox::draw() 169 { 170 glPushMatrix(); 171 glMatrixMode(GL_MODELVIEW); 172 Vector r = this->getAbsCoor(); 173 glTranslatef(r.x, r.y, r.z); 174 175 this->material[1]->select(); 176 177 this->model->draw(); 178 179 glPopMatrix(); 180 } 181 182 183 /** 184 \brief sets the Radius of the Sphere. 185 \param radius The Radius of The Sphere 186 */ 187 void SkyBox::setSize(float size) 188 { 189 this->size = size; 190 } 211 212 model->finalize(); 213 } -
orxonox/trunk/src/world_entities/skybox.h
r3801 r3803 26 26 27 27 void setSize(float size); 28 void setTexture(char* top, char* bottom, char* left, char* right, char* front, char* back); 29 30 virtual void draw(); 28 void setTexture(const char* name, const char* extension); 29 void setTextures(const char* top, const char* bottom, const char* left, const char* right, const char* front, const char* back); 31 30 32 31 private: 33 32 void rebuild(); 33 34 34 35 35 Material **material; //!< A Material for the Skybox. -
orxonox/trunk/src/world_entities/world_entity.cc
r3755 r3803 19 19 20 20 #include "world_entity.h" 21 #include " objModel.h"21 #include "model.h" 22 22 #include "list.h" 23 #include "vector.h" 23 24 24 25 //#include "stdincl.h" … … 41 42 this->setClassName ("WorldEntity"); 42 43 this->bDraw = true; 43 //this->model = NULL;44 this->model = NULL; 44 45 // collisioncluster = NULL; 45 46 } … … 171 172 Handle all stuff that should update with time inside this method (movement, animation, etc.) 172 173 */ 173 inlinevoid WorldEntity::tick(float time)174 void WorldEntity::tick(float time) 174 175 { 175 176 } … … 181 182 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. 182 183 */ 183 inline void WorldEntity::draw() 184 {} 184 void WorldEntity::draw() 185 { 186 glMatrixMode(GL_MODELVIEW); 187 glPushMatrix(); 188 float matrix[4][4]; 189 190 /* translate */ 191 glTranslatef (this->getAbsCoor ().x, 192 this->getAbsCoor ().y, 193 this->getAbsCoor ().z); 194 /* rotate */ 195 this->getAbsDir ().matrix (matrix); 196 glMultMatrixf((float*)matrix); 197 198 if (this->model) 199 this->model->draw(); 200 glPopMatrix(); 201 } 185 202 186 203
Note: See TracChangeset
for help on using the changeset viewer.