Changeset 7208 in orxonox.OLD for branches/std/src/world_entities
- Timestamp:
- Mar 10, 2006, 1:56:40 AM (19 years ago)
- Location:
- branches/std/src/world_entities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/std/src/world_entities/movie_entity.cc
r7193 r7208 74 74 } 75 75 76 void MovieEntity::loadMovie(const char*filename)76 void MovieEntity::loadMovie(const std::string& filename) 77 77 { 78 78 if(media_container->loadMedia(filename)) -
branches/std/src/world_entities/movie_entity.h
r7010 r7208 37 37 virtual void loadParams(const TiXmlElement* root); 38 38 39 void loadMovie(const char*filename);39 void loadMovie(const std::string& filename); 40 40 void setAxis(float axis); 41 41 void setRotation(float rotation); -
branches/std/src/world_entities/skybox.cc
r7193 r7208 38 38 * @param fileName the file to take as input for the SkyBox 39 39 */ 40 SkyBox::SkyBox(const char*fileName)40 SkyBox::SkyBox(const std::string& fileName) 41 41 { 42 42 this->preInit(); 43 if ( fileName)43 if (!fileName.empty()) 44 44 this->setTextureAndType(fileName, ".jpg"); 45 45 this->postInit(); … … 89 89 this->setParentMode(PNODE_MOVEMENT); 90 90 91 this->textureName = NULL;91 this->textureName = ""; 92 92 } 93 93 … … 106 106 for (int i = 0; i < 6; i++) 107 107 { 108 if (this->material[i])108 if (this->material[i]) 109 109 delete this->material[i]; 110 if (this->cubeTexture[i])110 if (this->cubeTexture[i]) 111 111 ResourceManager::getInstance()->unload(this->cubeTexture[i]); 112 112 } 113 113 } 114 115 void SkyBox::setTexture(const std::string& name) 116 { 117 this->textureName = name; 118 this->setTextureAndType (name, "jpg"); 119 }; 120 114 121 115 122 /** … … 122 129 "skybox_right.jpg", "skybox_front.jpg", "skybox_back.jpg"); 123 130 */ 124 void SkyBox::setTextureAndType(const char* name, const char* extension) 125 { 126 char* top = new char[strlen(name)+strlen(extension)+ 10]; 127 char* bottom = new char[strlen(name)+strlen(extension)+ 10]; 128 char* left = new char[strlen(name)+strlen(extension)+ 10]; 129 char* right = new char[strlen(name)+strlen(extension)+ 10]; 130 char* front = new char[strlen(name)+strlen(extension)+ 10]; 131 char* back = new char[strlen(name)+strlen(extension)+ 10]; 132 133 sprintf(top, "%s_top.%s", name, extension); 134 sprintf(bottom, "%s_bottom.%s", name, extension); 135 sprintf(left, "%s_left.%s", name, extension); 136 sprintf(right, "%s_right.%s", name, extension); 137 sprintf(front, "%s_front.%s", name, extension); 138 sprintf(back, "%s_back.%s", name, extension); 131 void SkyBox::setTextureAndType(const std::string& name, const std::string& extension) 132 { 133 std::string top = name + "_top." + extension; 134 std::string bottom = name + "_bottom." + extension; 135 std::string left = name + "_left." + extension; 136 std::string right = name + "_right." + extension; 137 std::string front = name + "_front." + extension; 138 std::string back = name + "_back." + extension; 139 139 140 140 this->setTextures(top, bottom, left, right, front, back); 141 142 // deleted alocated memory of this function143 delete []top;144 delete []bottom;145 delete []left;146 delete []right;147 delete []front;148 delete []back;149 141 } 150 142 … … 158 150 * @param back the back texture. 159 151 */ 160 void SkyBox::setTextures(const char* top, const char* bottom, const char*left,161 const char* right, const char* front, const char*back)152 void SkyBox::setTextures(const std::string& top, const std::string& bottom, const std::string& left, 153 const std::string& right, const std::string& front, const std::string& back) 162 154 { 163 155 this->material[0]->setDiffuseMap(top); … … 171 163 } 172 164 173 void SkyBox::loadCubeMapTextures(const char* top, const char* bottom, const char*left,174 const char* right, const char* front, const char*back)165 void SkyBox::loadCubeMapTextures(const std::string& top, const std::string& bottom, const std::string& left, 166 const std::string& right, const std::string& front, const std::string& back) 175 167 { 176 168 this->cubeTexture[0] = (Texture*)ResourceManager::getInstance()->load(top, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT); … … 304 296 305 297 SYNCHELP_READ_FLOAT( size, NWT_SB_SIZE ); 306 if ( textureName)298 if ( !this->textureName.empty() ) 307 299 { 308 delete[] textureName; 309 textureName = NULL; 300 textureName = ""; 310 301 } 311 SYNCHELP_READ_STRINGM( textureName, NWT_SB_TEXTURENAME ); 302 char* texName; 303 SYNCHELP_READ_STRINGM( texName, NWT_SB_TEXTURENAME ); 312 304 313 305 this->setSize( size ); 314 this->setTextureAndType( tex tureName, "jpg" );306 this->setTextureAndType( texName, "jpg" ); 315 307 this->rebuild(); 316 308 … … 338 330 339 331 SYNCHELP_WRITE_FLOAT(this->size, NWT_SB_SIZE); 340 SYNCHELP_WRITE_STRING(this->textureName , NWT_SB_TEXTURENAME);332 SYNCHELP_WRITE_STRING(this->textureName.c_str(), NWT_SB_TEXTURENAME); 341 333 342 334 return SYNCHELP_WRITE_N; -
branches/std/src/world_entities/skybox.h
r6771 r7208 28 28 { 29 29 public: 30 SkyBox(const char* fileName = NULL);30 SkyBox(const std::string& fileName = ""); 31 31 SkyBox(const TiXmlElement* root); 32 32 … … 44 44 void setSize(float size); 45 45 /** assumes jpg as input-format */ 46 void setTexture(const char* name) { if (textureName) delete[] textureName; textureName = new char[strlen(name)+1]; strcpy(textureName, name); this->setTextureAndType (name, "jpg"); };46 void setTexture(const std::string& name); 47 47 48 void setTextureAndType(const char* name, const char*extension);49 void setTextures(const char* top, const char* bottom, const char*left,50 const char* right, const char* front, const char*back);48 void setTextureAndType(const std::string& name, const std::string& extension); 49 void setTextures(const std::string& top, const std::string& bottom, const std::string& left, 50 const std::string& right, const std::string& front, const std::string& back); 51 51 52 void loadCubeMapTextures(const char* top, const char* bottom, const char*left,53 const char* right, const char* front, const char*back);52 void loadCubeMapTextures(const std::string& top, const std::string& bottom, const std::string& left, 53 const std::string& right, const std::string& front, const std::string& back); 54 54 55 55 GLuint getTexture(SKY_SIDE side) const { return (this->material[side]) ? this->material[side]->getDiffuseTexture(): 0; }; … … 71 71 float size; //!< Size of the SkyBox. This should match the frustum maximum range. 72 72 float textureSize; //!< this is the length of a texture (assumes a square texture) 73 char*textureName; //!< Name of the Texture73 std::string textureName; //!< Name of the Texture 74 74 75 75 };
Note: See TracChangeset
for help on using the changeset viewer.