- Timestamp:
- Mar 12, 2006, 8:54:30 AM (19 years ago)
- Location:
- branches/std/src
- Files:
-
- 68 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/std/src/lib/coord/p_node.cc
r7193 r7216 540 540 * @param childName the name of the child to add to this PNode 541 541 */ 542 void PNode::addChild (const char*childName)542 void PNode::addChild (const std::string& childName) 543 543 { 544 544 PNode* childNode = dynamic_cast<PNode*>(ClassList::getObject(childName, CL_PARENT_NODE)); … … 624 624 * @param parentName the name of the Parent to set to this PNode 625 625 */ 626 void PNode::setParent (const char*parentName)626 void PNode::setParent (const std::string& parentName) 627 627 { 628 628 PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE)); … … 631 631 else 632 632 PRINTF(2)("Not Found PNode's (%s::%s) new Parent by Name: %s\n", 633 this->getClassName(), this->getName(), parentName);633 this->getClassName(), this->getName(), parentName.c_str()); 634 634 } 635 635 … … 699 699 * @param parentMode a String representing this parentingMode 700 700 */ 701 void PNode::setParentMode (const char*parentingMode)701 void PNode::setParentMode (const std::string& parentingMode) 702 702 { 703 703 this->setParentMode(PNode::charToParentingMode(parentingMode)); … … 1068 1068 * @return the int corresponding to the named parentingMode 1069 1069 */ 1070 PARENT_MODE PNode::charToParentingMode(const char*parentingMode)1071 { 1072 if ( !strcmp(parentingMode, "local-rotate"))1070 PARENT_MODE PNode::charToParentingMode(const std::string& parentingMode) 1071 { 1072 if (parentingMode == "local-rotate") 1073 1073 return (PNODE_LOCAL_ROTATE); 1074 else if ( !strcmp(parentingMode, "rotate-movement"))1074 else if (parentingMode == "rotate-movement") 1075 1075 return (PNODE_ROTATE_MOVEMENT); 1076 else if ( !strcmp(parentingMode, "movement"))1076 else if (parentingMode == "movement") 1077 1077 return (PNODE_MOVEMENT); 1078 else if ( !strcmp(parentingMode, "all"))1078 else if (parentingMode == "all") 1079 1079 return (PNODE_ALL); 1080 else if ( !strcmp(parentingMode, "rotate-and-move"))1080 else if (parentingMode == "rotate-and-move") 1081 1081 return (PNODE_ROTATE_AND_MOVE); 1082 1082 } -
branches/std/src/lib/coord/p_node.h
r7076 r7216 143 143 // PARENTING // 144 144 void addChild (PNode* child); 145 void addChild (const char*childName);145 void addChild (const std::string& childName); 146 146 void removeChild (PNode* child); 147 147 void removeNode(); … … 151 151 /** @param parent the new parent of this node */ 152 152 inline void setParent (PNode* parent) { parent->addChild(this); }; 153 void setParent (const char*parentName);153 void setParent (const std::string& parentName); 154 154 /** @returns the parent of this PNode */ 155 155 inline PNode* getParent () const { return this->parent; }; … … 162 162 // PARENTING_MODE AND OTHER FLAGS // 163 163 void setParentMode (PARENT_MODE parentMode); 164 void setParentMode (const char*parentingMode);164 void setParentMode (const std::string& parentingMode); 165 165 /** @returns the Parenting mode of this node */ 166 166 int getParentMode() const { return 0x000f & this->parentMode; }; … … 184 184 // HELPER_FUNCTIONS // 185 185 static const char* parentingModeToChar(int parentingMode); 186 static PARENT_MODE charToParentingMode(const char*parentingMode);186 static PARENT_MODE charToParentingMode(const std::string& parentingMode); 187 187 float distance(const PNode* node) const { return (this->getAbsCoor() - node->getAbsCoor()).len(); }; 188 188 -
branches/std/src/lib/graphics/effects/fog_effect.cc
r7193 r7216 126 126 * @param mode the mode character 127 127 */ 128 GLint FogEffect:: charToFogMode(const char*mode)128 GLint FogEffect::stringToFogMode(const std::string& mode) 129 129 { 130 if( !strcmp( "GL_LINEAR", mode))130 if(mode == "GL_LINEAR") 131 131 return GL_LINEAR; 132 else if( !strcmp("GL_EXP", mode))132 else if(mode == "GL_EXP") 133 133 return GL_EXP; 134 else if( !strcmp("GL_EXP2", mode))134 else if(mode == "GL_EXP2" ) 135 135 return GL_EXP2; 136 136 else -
branches/std/src/lib/graphics/effects/fog_effect.h
r7107 r7216 26 26 virtual bool deactivate(); 27 27 28 inline void setFogMode(const char* mode) { this->fogMode = this->charToFogMode(mode); }28 inline void setFogMode(const std::string& mode) { this->fogMode = this->stringToFogMode(mode); } 29 29 inline void setFogDensity(float density) { this->fogDensity = density; } 30 30 inline void setFogRange(float start, float end) { this->fogStart = start; this->fogEnd = end; } … … 33 33 34 34 private: 35 GLint charToFogMode(const char*mode);35 GLint stringToFogMode(const std::string& mode); 36 36 37 37 -
branches/std/src/lib/graphics/effects/lense_flare.cc
r7193 r7216 147 147 * 7th: Texture of the third burst 148 148 */ 149 void LenseFlare::addFlare(const char*textureName)149 void LenseFlare::addFlare(const std::string& textureName) 150 150 { 151 151 if( this->flares.size() > LF_MAX_FLARES) … … 159 159 bb->setSize(50, 50); 160 160 this->flares.push_back(bb); 161 PRINTF( 0)("Added a Lenseflare Billboard with texture %s\n", textureName);161 PRINTF(4)("Added a Lenseflare Billboard with texture %s\n", textureName.c_str()); 162 162 163 163 // the first flare belongs to the light source … … 167 167 bb->setVisibility(true); 168 168 } 169 PRINTF( 0)("Finished adding\n", textureName);169 PRINTF(4)("Finished adding\n"); 170 170 } 171 171 -
branches/std/src/lib/graphics/effects/lense_flare.h
r7015 r7216 39 39 virtual void tick(float dt); 40 40 41 void addFlare(const char*textureName);41 void addFlare(const std::string& textureName); 42 42 43 43 -
branches/std/src/lib/graphics/render2D/billboard.cc
r7193 r7216 78 78 void Billboard::loadParams(const TiXmlElement* root) 79 79 { 80 LoadParam(root, "texture", this , Billboard, setTexture)80 LoadParam(root, "texture", this->material, Material, setDiffuseMap) 81 81 .describe("the texture-file to load onto the Billboard"); 82 82 … … 100 100 * @param textureFile The texture-file to load onto the crosshair 101 101 */ 102 void Billboard::setTexture(const char*textureFile)102 void Billboard::setTexture(const std::string& textureFile) 103 103 { 104 104 this->material->setDiffuseMap(textureFile); -
branches/std/src/lib/graphics/render2D/billboard.h
r6815 r7216 30 30 31 31 void setSize(float sizeX, float sizeY); 32 void setTexture(const char*textureFile);32 void setTexture(const std::string& textureFile); 33 33 void attachTo(PNode* pnode); 34 34 -
branches/std/src/lib/graphics/render2D/element_2d.cc
r7199 r7216 180 180 * @param alignment the alignment @see loadParams 181 181 */ 182 void Element2D::setAlignment(const char*alignment)183 { 184 if ( !strcmp(alignment, "center"))182 void Element2D::setAlignment(const std::string& alignment) 183 { 184 if (alignment == "center") 185 185 this->setAlignment(E2D_ALIGN_CENTER); 186 else if ( !strcmp(alignment, "left"))186 else if (alignment == "left") 187 187 this->setAlignment(E2D_ALIGN_LEFT); 188 else if ( !strcmp(alignment, "right"))188 else if (alignment == "right") 189 189 this->setAlignment(E2D_ALIGN_RIGHT); 190 else if ( !strcmp(alignment, "screen-center"))190 else if (alignment == "screen-center") 191 191 this->setAlignment(E2D_ALIGN_SCREEN_CENTER); 192 192 } … … 213 213 /** 214 214 * sets the layer onto which this 2D-element is projected to. 215 * @param layer the layer @see loadParams @see Element2D::charToLayer2D(const char*layer)216 */ 217 void Element2D::setLayer(const char*layer)215 * @param layer the layer @see loadParams @see Element2D::charToLayer2D(const std::string& layer) 216 */ 217 void Element2D::setLayer(const std::string& layer) 218 218 { 219 219 this->setLayer(Element2D::charToLayer2D(layer)); … … 235 235 * @param bindNode the name of the Node (should be existing) 236 236 */ 237 void Element2D::setBindNode(const char*bindNode)237 void Element2D::setBindNode(const std::string& bindNode) 238 238 { 239 239 const PNode* tmpBindNode = dynamic_cast<const PNode*>(ClassList::getObject(bindNode, CL_PARENT_NODE)); … … 572 572 * @param childName the name of the child to add to this PNode 573 573 */ 574 void Element2D::addChild2D (const char*childName)574 void Element2D::addChild2D (const std::string& childName) 575 575 { 576 576 Element2D* childNode = dynamic_cast<Element2D*>(ClassList::getObject(childName, CL_ELEMENT_2D)); … … 651 651 * @param parentName the name of the Parent to set to this Element2D 652 652 */ 653 void Element2D::setParent2D (const char*parentName)653 void Element2D::setParent2D (const std::string& parentName) 654 654 { 655 655 Element2D* parentNode = dynamic_cast<Element2D*>(ClassList::getObject(parentName, CL_ELEMENT_2D)); … … 658 658 else 659 659 PRINTF(2)("Not Found Element2D's (%s::%s) new Parent by Name: %s\n", 660 this->getClassName(), this->getName(), parentName );660 this->getClassName(), this->getName(), parentName.c_str()); 661 661 } 662 662 … … 704 704 * @param bias the speed to iterate to this new Positions 705 705 */ 706 void Element2D::setParentSoft2D(const char*parentName, float bias)706 void Element2D::setParentSoft2D(const std::string& parentName, float bias) 707 707 { 708 708 Element2D* parentNode = dynamic_cast<Element2D*>(ClassList::getObject(parentName, CL_ELEMENT_2D)); … … 724 724 * @param parentMode a String representing this parentingMode 725 725 */ 726 void Element2D::setParentMode2D (const char*parentingMode)726 void Element2D::setParentMode2D (const std::string& parentingMode) 727 727 { 728 728 this->setParentMode2D(Element2D::charToParentingMode2D(parentingMode)); … … 1093 1093 * @return the int corresponding to the named parentingMode 1094 1094 */ 1095 E2D_PARENT_MODE Element2D::charToParentingMode2D(const char*parentingMode)1096 { 1097 if ( !strcmp(parentingMode, "local-rotate"))1095 E2D_PARENT_MODE Element2D::charToParentingMode2D(const std::string& parentingMode) 1096 { 1097 if (parentingMode == "local-rotate") 1098 1098 return (E2D_PARENT_LOCAL_ROTATE); 1099 else if ( !strcmp(parentingMode, "rotate-movement"))1099 else if (parentingMode == "rotate-movement") 1100 1100 return (E2D_PARENT_ROTATE_MOVEMENT); 1101 else if ( !strcmp(parentingMode, "movement"))1101 else if (parentingMode == "movement") 1102 1102 return (E2D_PARENT_MOVEMENT); 1103 else if ( !strcmp(parentingMode, "all"))1103 else if (parentingMode == "all") 1104 1104 return (E2D_PARENT_ALL); 1105 else if ( !strcmp(parentingMode, "rotate-and-move"))1105 else if (parentingMode == "rotate-and-move") 1106 1106 return (E2D_PARENT_ROTATE_AND_MOVE); 1107 1107 } … … 1139 1139 * @returns the E2D_LAYER on success, E2D_DEFAULT_LAYER on error. 1140 1140 */ 1141 E2D_LAYER Element2D::charToLayer2D(const char*layer)1142 { 1143 if ( !strcmp(layer, "top"))1141 E2D_LAYER Element2D::charToLayer2D(const std::string& layer) 1142 { 1143 if (layer =="top") 1144 1144 return (E2D_LAYER_TOP); 1145 else if ( !strcmp(layer, "medium"))1145 else if (layer == "medium") 1146 1146 return (E2D_LAYER_MEDIUM); 1147 else if ( !strcmp(layer, "bottom"))1147 else if (layer == "bottom") 1148 1148 return (E2D_LAYER_BOTTOM); 1149 else if ( !strcmp(layer, "below-all"))1149 else if (layer == "below-all") 1150 1150 return (E2D_LAYER_BELOW_ALL); 1151 1151 else -
branches/std/src/lib/graphics/render2D/element_2d.h
r7052 r7216 102 102 /** @param alignment the new Alignment of the 2D-Element */ 103 103 inline void setAlignment(E2D_ALIGNMENT alignment) { this->alignment = alignment; }; 104 void setAlignment(const char*alignment);104 void setAlignment(const std::string& alignment); 105 105 inline E2D_ALIGNMENT getAlignment() const { return this->alignment; }; 106 106 107 107 // LAYERING // 108 108 void setLayer(E2D_LAYER layer); 109 void setLayer(const char*layer);109 void setLayer(const std::string& layer); 110 110 /** @returns the Layer this Element is drawn to */ 111 111 inline E2D_LAYER getLayer() const { return this->layer; }; … … 121 121 /** @param bindNode the Node this 2D-element should follow. if NULL the Element will not follow anything */ 122 122 inline void setBindNode(const PNode* bindNode) { this->bindNode = bindNode; }; 123 void setBindNode(const char*bindNode);123 void setBindNode(const std::string& bindNode); 124 124 inline const PNode* getBindNode() const { return this->bindNode; }; 125 125 … … 181 181 182 182 void addChild2D (Element2D* child); 183 void addChild2D (const char*childName);183 void addChild2D (const std::string& childName); 184 184 void removeChild2D (Element2D* child); 185 185 void remove2D(); … … 187 187 /** @param parent the new parent of this Element2D */ 188 188 void setParent2D (Element2D* parent) { parent->addChild2D(this); }; 189 void setParent2D (const char*parentName);189 void setParent2D (const std::string& parentName); 190 190 /** @returns the parent of this Element2D */ 191 191 inline Element2D* getParent2D () const { return this->parent; }; … … 194 194 195 195 void setParentSoft2D(Element2D* parentNode, float bias = 1.0); 196 void setParentSoft2D(const char*parentName, float bias = 1.0);196 void setParentSoft2D(const std::string& parentName, float bias = 1.0); 197 197 198 198 void setParentMode2D (E2D_PARENT_MODE parentMode); 199 void setParentMode2D (const char*parentingMode);199 void setParentMode2D (const std::string& parentingMode); 200 200 /** @returns the Parenting mode of this node */ 201 201 int getParentMode2D() const { return this->parentMode; }; … … 213 213 // helper functions // 214 214 static const char* parentingModeToChar2D(int parentingMode); 215 static E2D_PARENT_MODE charToParentingMode2D(const char*parentingMode);215 static E2D_PARENT_MODE charToParentingMode2D(const std::string& parentingMode); 216 216 217 217 static const char* layer2DToChar(E2D_LAYER layer); 218 static E2D_LAYER charToLayer2D(const char*layer);218 static E2D_LAYER charToLayer2D(const std::string& layer); 219 219 220 220 private: -
branches/std/src/lib/graphics/text_engine/text.cc
r7207 r7216 50 50 if (this->font != NULL && this->font != Font::getDefaultFont()) 51 51 ResourceManager::getInstance()->unload(this->font); 52 53 if (this->text)54 delete[] this->text;55 52 } 56 53 … … 64 61 // initialize this Text 65 62 this->font = NULL; 66 this->text = NULL; 67 this->externText = NULL; 63 this->text = ""; 68 64 this->setAlignment(TEXT_DEFAULT_ALIGNMENT); 69 65 this->blending = TEXT_DEFAULT_BLENDING; 70 66 this->color = TEXT_DEFAULT_COLOR; 71 67 this->setSize(TEXT_DEFAULT_SIZE); 72 this->setText( NULL);68 this->setText(""); 73 69 } 74 70 … … 104 100 * @param text the new text to set 105 101 */ 106 void Text::setText(const char* text, bool isExtern) 107 { 108 if (isExtern) 109 { 110 this->externText = text; 111 112 if (unlikely(this->text != NULL)) 113 { 114 delete[] this->text; 115 this->text = NULL; 116 } 117 } 118 else 119 { 120 this->externText = NULL; 121 if (this->text) 122 delete[] this->text; 123 if (text != NULL) 124 { 125 this->text = new char[strlen(text)+1]; 126 strcpy(this->text, text); 127 } 128 else 129 this->text = NULL; 130 } 102 void Text::setText(const std::string& text) 103 { 104 this->text = text; 131 105 132 106 // setting up the Text-Width if DYNAMIC … … 138 112 139 113 float width = 0; 140 const char* tmpText = this->externText; 141 if (this->externText == NULL) 142 tmpText = this->text; 143 if (tmpText != NULL) 114 if (!this->text.empty()) 144 115 { 145 while (*tmpText != '\0')116 for (unsigned int i = 0; i < this->text.size(); i++) 146 117 { 147 if(glyphArray[ *tmpText] != NULL)118 if(glyphArray[this->text[i]] != NULL) 148 119 { 149 width += glyphArray[ *tmpText]->advance;120 width += glyphArray[this->text[i]]->advance; 150 121 } 151 tmpText++;152 122 } 153 123 this->setSizeX2D(width *this->getSizeY2D()); … … 190 160 glBindTexture(GL_TEXTURE_2D, Font::getDefaultFont()->getTexture()); 191 161 } 192 const char* tmpText = this->externText; 193 if (this->externText == NULL) 194 tmpText = this->text; 195 if (likely(tmpText != NULL)) 162 if (likely(!this->text.empty())) 196 163 { 197 164 glTranslatef(getAbsCoor2D().x, getAbsCoor2D().y, 0); … … 201 168 202 169 glBegin(GL_QUADS); 203 while (likely(*tmpText != '\0'))170 for (unsigned int i = 0; i < this->text.size(); i++) 204 171 { 205 if(likely((tmpGlyph = glyphArray[ *tmpText]) != NULL))172 if(likely((tmpGlyph = glyphArray[this->text[i]]) != NULL)) 206 173 { 207 174 glTexCoord2f(tmpGlyph->texCoord[1], tmpGlyph->texCoord[2]); … … 219 186 posX += tmpGlyph->advance * this->getSizeY2D(); 220 187 } 221 ++tmpText;222 188 } 223 189 glEnd(); … … 232 198 void Text::debug() const 233 199 { 234 if (this->externText == NULL) 235 PRINT(0)("=== TEXT: %s ===\n", this->text); 236 else 237 PRINT(0)("=== TEXT: %s ===\n", this->externText); 200 PRINT(0)("=== TEXT: %s ===\n", this->text.c_str()); 238 201 239 202 if (this->getBindNode()) -
branches/std/src/lib/graphics/text_engine/text.h
r7207 r7216 45 45 void setFont(const std::string& fontFile, unsigned int renderSize); 46 46 47 void setText(const char* text, bool isExtern = false);47 void setText(const std::string& text); 48 48 49 49 /** @returns the String this Text displays */ 50 inline const char* getText() const { return (externText == NULL)?this->text:this->externText; };50 inline const std::string& getText() const { return this->text; }; 51 51 /** @param blending the blending intensity to set (between 0.0 and 1.0) */ 52 52 inline void setBlending(float blending) { this->blending = blending; }; … … 69 69 Font* font; //!< Font of this text 70 70 71 char* text; //!< The text to display 72 const char* externText; //!< the text to Display from an external Source. 71 std::string text; //!< The text to display 73 72 Vector color; //!< The color of the font. 74 73 float blending; //!< The blending intensity. -
branches/std/src/lib/lang/base_object.cc
r7214 r7216 95 95 void BaseObject::setName (const std::string& objectName) 96 96 { 97 printf("TEST\n");98 97 this->objectName = objectName; 99 printf("TEST2\n");100 98 } 101 99 -
branches/std/src/lib/lang/class_list.cc
r7199 r7216 37 37 * Creates a new ClassList 38 38 */ 39 ClassList::ClassList(ClassID classID, unsigned long classIDFull, const char*className)40 { 41 this->className = className; 39 ClassList::ClassList(ClassID classID, unsigned long classIDFull, const std::string& className) 40 : className(className) 41 { 42 42 this->classID = classID; 43 43 this->classIDFull = classIDFull; … … 56 56 57 57 //! a List of all strings of all classes, that have registered so far. 58 std::list< const char*> ClassList::classNames;58 std::list<std::string> ClassList::classNames; 59 59 60 60 /** … … 67 67 * !! Before unsing the ClassList, as it creates the ClassLits 68 68 */ 69 ClassList* ClassList::addToClassList(BaseObject* objectPointer, ClassID classID, unsigned long classIDFull, const char*className)69 ClassList* ClassList::addToClassList(BaseObject* objectPointer, ClassID classID, unsigned long classIDFull, const std::string& className) 70 70 { 71 71 if (unlikely(classList == NULL)) 72 72 ClassList::classList = new list<ClassList>(); 73 73 74 PRINTF(5)("subscribe a '%s'\n", className );74 PRINTF(5)("subscribe a '%s'\n", className.c_str() ); 75 75 76 76 ClassList* regClass = ClassList::getClassList(classID); … … 113 113 * befor it changes anything. 114 114 */ 115 const std::list< const char*>* ClassList::getClassNames()115 const std::list<std::string>* ClassList::getClassNames() 116 116 { 117 117 if (ClassList::classNames.size() != ClassList::classList->size()) … … 155 155 * @return the List accessed by classID, or NULL if not found 156 156 */ 157 const std::list<BaseObject*>* ClassList::getList(const char*className)157 const std::list<BaseObject*>* ClassList::getList(const std::string& className) 158 158 { 159 159 ClassList* fl; … … 191 191 * @returns the ClassList with className as specifyer, or NULL if not 192 192 */ 193 ClassList* ClassList::getClassList(const char*className)194 { 195 if (className == NULL)193 ClassList* ClassList::getClassList(const std::string& className) 194 { 195 if (className.empty()) 196 196 return NULL; 197 197 std::list<ClassList>::iterator classIT = find (classList->begin(), classList->end(), className); … … 207 207 * @todo: speed this up!! 208 208 */ 209 BaseObject* ClassList::getObject(const char*objectName, ClassID classID)209 BaseObject* ClassList::getObject(const std::string& objectName, ClassID classID) 210 210 { 211 211 if (classID != CL_NULL) … … 216 216 std::list<BaseObject*>::iterator bo; 217 217 for (bo = cl->objectList.begin(); bo != cl->objectList.end(); bo++) 218 if ((*bo)->getName() != NULL && !strcmp((*bo)->getName(), objectName))218 if ((*bo)->getName() != NULL && objectName == (*bo)->getName()) 219 219 return (*bo); 220 220 } … … 227 227 std::list<BaseObject*>::iterator bo; 228 228 for (bo = (*cl).objectList.begin(); bo != (*cl).objectList.end(); bo++) 229 if ((*bo)->getName() != NULL && !strcmp((*bo)->getName(), objectName))229 if ((*bo)->getName() != NULL && objectName == (*bo)->getName()) 230 230 return (*bo); 231 231 } … … 276 276 if (object->isA((*cl).classID)) 277 277 { 278 PRINT(0)("=%s::0x%.8X=-", (*cl).className , (*cl).classID);278 PRINT(0)("=%s::0x%.8X=-", (*cl).className.c_str(), (*cl).classID); 279 279 } 280 280 } … … 285 285 * @return a String containing the name of the Class, NULL if the Class was not found 286 286 */ 287 const char* ClassList::IDToString(ClassID classID) 288 { 287 const std::string& ClassList::IDToString(ClassID classID) 288 { 289 static const std::string empty(""); 290 289 291 ClassList* cl = ClassList::getClassList(classID); 290 return (cl != NULL) ? cl->className : NULL;292 return (cl != NULL) ? cl->className : empty; 291 293 } 292 294 … … 296 298 * @return the ClassID. CL_NULL, if the class was not found. 297 299 */ 298 ClassID ClassList::StringToID(const char*className)300 ClassID ClassList::StringToID(const std::string& className) 299 301 { 300 302 ClassList* cl = ClassList::getClassList(className); … … 307 309 * @returns true on match, false otherwise 308 310 */ 309 bool ClassList::operator==(const char* className) 310 { 311 if (likely( className != NULL && this->className != NULL)) 312 return (!strcmp(this->className, className)); 313 else 314 return false; 311 bool ClassList::operator==(const std::string& className) 312 { 313 return (this->className == className); 315 314 } 316 315 … … 342 341 while (pow(10, lenCount) <= (*cl).objectList.size()) 343 342 ++lenCount; 344 for (int i=0; i < 30- strlen((*cl).className) - lenCount; i++)343 for (int i=0; i < 30-(*cl).className.size() - lenCount; i++) 345 344 (niceString[i]) = ' '; 346 niceString[30- strlen((*cl).className) - lenCount] = '\0';347 348 PRINT(0)("| CLASS %s::%s %d\n", (*cl).className , niceString, (*cl).objectList.size());345 niceString[30-(*cl).className.size() - lenCount] = '\0'; 346 347 PRINT(0)("| CLASS %s::%s %d\n", (*cl).className.c_str(), niceString, (*cl).objectList.size()); 349 348 350 349 if (debugLevel >=2 && (*cl).objectList.size() > 0) … … 371 370 * @see ClassList::debug 372 371 */ 373 void ClassList::debugS(const char*className, unsigned int debugLevel)372 void ClassList::debugS(const std::string& className, unsigned int debugLevel) 374 373 { 375 374 ClassList::debug(debugLevel, ClassList::StringToID(className)); -
branches/std/src/lib/lang/class_list.h
r7165 r7216 10 10 #include "class_id.h" 11 11 #include <list> 12 #include <string> 12 13 #ifndef NULL 13 14 #define NULL 0 //!< NULL … … 32 33 class ClassList { 33 34 public: 34 ClassList(ClassID classID, unsigned long classIDFull, const char*className);35 ClassList(ClassID classID, unsigned long classIDFull, const std::string& className); 35 36 virtual ~ClassList(); 36 37 37 38 /* MAINTENANCE FUNCTIONS THESE ARE !!ONLY FOR BASEOBJECT !! */ 38 static ClassList* addToClassList(BaseObject* objectPointer, ClassID classID, unsigned long classIDFull, const char*className);39 static ClassList* addToClassList(BaseObject* objectPointer, ClassID classID, unsigned long classIDFull, const std::string& className); 39 40 static void removeFromClassList(BaseObject* objectPointer); 40 41 … … 42 43 43 44 static const std::list<BaseObject*>* getList(ClassID classID = CL_NULL);// { return (ClassList* fl = ClassList::getClassList(classID) != NULL)? &(fl->objectList) : NULL; }; 44 static const std::list<BaseObject*>* getList(const char*className); // { return (ClassList* fl = ClassList::getClassList(className) != NULL)? &(fl->objectList) : NULL; };45 static const std::list< const char*>* getClassNames();46 static BaseObject* getObject(const char*name, ClassID classID = CL_NULL);45 static const std::list<BaseObject*>* getList(const std::string& className); // { return (ClassList* fl = ClassList::getClassList(className) != NULL)? &(fl->objectList) : NULL; }; 46 static const std::list<std::string>* getClassNames(); 47 static BaseObject* getObject(const std::string& name, ClassID classID = CL_NULL); 47 48 static bool exists(const BaseObject* object, ClassID classID = CL_NULL); 48 49 … … 51 52 static void whatIs(const BaseObject* object); 52 53 53 static const char*IDToString(ClassID classID = CL_NULL);54 static ClassID StringToID(const char*className);54 static const std::string& IDToString(ClassID classID = CL_NULL); 55 static ClassID StringToID(const std::string& className); 55 56 static void debug(unsigned int debugLevel = 0, ClassID classID = CL_NULL); 56 static void debugS(const char* className = NULL, unsigned int debugLevel = 0);57 static void debugS(const std::string& className = "", unsigned int debugLevel = 0); 57 58 58 59 inline bool operator==(ClassID classID) { return (this->classID == classID); }; 59 bool operator==(const char*className);60 bool operator==(const std::string& className); 60 61 inline ClassID getLeafClassID() const { return this->classID; }; 61 62 62 63 private: 63 64 static ClassList* getClassList(ClassID classID); 64 static ClassList* getClassList(const char*className);65 static ClassList* getClassList(const std::string& className); 65 66 66 67 private: 67 ClassID classID; //!< ClassID stored in this ClassList68 unsigned long classIDFull; //!< The Full ClassID of this Class.68 ClassID classID; //!< ClassID stored in this ClassList 69 unsigned long classIDFull; //!< The Full ClassID of this Class. 69 70 70 const char*className; //!< Name of the Class Stored here71 const std::string className; //!< Name of the Class Stored here 71 72 72 std::list<BaseObject*> objectList; //!< A list of Objects belonging to this Class73 std::list<BaseObject*> objectList; //!< A list of Objects belonging to this Class 73 74 74 75 // STATIC MEMBERS 75 static std::list<ClassList>* classList; //!< The first Class in the List76 static std::list< const char*>classNames; //!< a List of all Names of all classes, that have registered so far.76 static std::list<ClassList>* classList; //!< The first Class in the List 77 static std::list<std::string> classNames; //!< a List of all Names of all classes, that have registered so far. 77 78 }; 78 79 -
branches/std/src/lib/particles/dot_particles.h
r6652 r7216 21 21 virtual void loadParams(const TiXmlElement* root); 22 22 23 void setMaterialTexture(const char*textureFile);23 void setMaterialTexture(const std::string& textureFile); 24 24 25 25 /** @returns the Material that lies on this particles */ -
branches/std/src/lib/particles/model_particles.cc
r7198 r7216 89 89 * @param textureFile the Texture to load onto these ModelParticles 90 90 */ 91 void ModelParticles::setMaterialTexture(const char*textureFile)91 void ModelParticles::setMaterialTexture(const std::string& textureFile) 92 92 { 93 93 this->material.setDiffuseMap(textureFile); -
branches/std/src/lib/particles/model_particles.h
r6629 r7216 20 20 virtual void loadParams(const TiXmlElement* root); 21 21 22 void setMaterialTexture(const char*textureFile);22 void setMaterialTexture(const std::string& textureFile); 23 23 24 24 /** @returns the Material that lies on this particles */ -
branches/std/src/lib/particles/sprite_particles.cc
r7198 r7216 89 89 * @param textureFile the Texture to load onto these SpriteParticles 90 90 */ 91 void SpriteParticles::setMaterialTexture(const char*textureFile)91 void SpriteParticles::setMaterialTexture(const std::string& textureFile) 92 92 { 93 93 this->material.setDiffuseMap(textureFile); -
branches/std/src/lib/particles/sprite_particles.h
r6626 r7216 21 21 virtual void loadParams(const TiXmlElement* root); 22 22 23 void setMaterialTexture(const char*textureFile);23 void setMaterialTexture(const std::string& textureFile); 24 24 25 25 /** @returns the Material that lies on this particles */ -
branches/std/src/lib/physics/physics_connection.cc
r7193 r7216 73 73 * @param subjectName the name of the Subject for this PhysicsConnection 74 74 */ 75 void PhysicsConnection::setSubject(const char*subjectName)75 void PhysicsConnection::setSubject(const std::string& subjectName) 76 76 { 77 77 this->subject = PhysicsEngine::getInstance()->getPhysicsInterfaceByName(subjectName); 78 78 if (this->subject == NULL) 79 79 { 80 PRINTF(2)("subject: (%s) not found for PhysicsConnection\n", subjectName );80 PRINTF(2)("subject: (%s) not found for PhysicsConnection\n", subjectName.c_str()); 81 81 } 82 82 else … … 87 87 * @param fieldName the Name of the Field for this connection 88 88 */ 89 void PhysicsConnection::setField(const char*fieldName)89 void PhysicsConnection::setField(const std::string& fieldName) 90 90 { 91 91 this->field = PhysicsEngine::getInstance()->getFieldByName(fieldName); 92 92 if (this->field == NULL) 93 93 { 94 PRINTF(2)("field: (%s) not found for PhysicsConnection\n", fieldName);94 PRINTF(2)("field: (%s) not found for PhysicsConnection\n", fieldName.c_str()); 95 95 } 96 96 else -
branches/std/src/lib/physics/physics_connection.h
r5257 r7216 35 35 virtual ~PhysicsConnection(); 36 36 37 void setSubject(const char*subjectName);38 void setField(const char*fieldName);37 void setSubject(const std::string& subjectName); 38 void setField(const std::string& fieldName); 39 39 40 40 void apply() const; -
branches/std/src/lib/physics/physics_engine.cc
r7193 r7216 128 128 @returns the PhysicsInterface if found, or NULL if not 129 129 */ 130 PhysicsInterface* PhysicsEngine::getPhysicsInterfaceByName(const char*physicsInterfaceName) const130 PhysicsInterface* PhysicsEngine::getPhysicsInterfaceByName(const std::string& physicsInterfaceName) const 131 131 { 132 132 BaseObject* interface = ClassList::getObject(physicsInterfaceName, CL_PHYSICS_INTERFACE); … … 157 157 158 158 /** 159 * @param FieldName the Name of the PhysicsInterface to search for159 * @param fieldName the Name of the PhysicsInterface to search for 160 160 @returns the Field if found, or NULL if not 161 161 */ 162 Field* PhysicsEngine::getFieldByName(const char* FieldName) const162 Field* PhysicsEngine::getFieldByName(const std::string& fieldName) const 163 163 { 164 164 list<Field*>::const_iterator field; 165 165 for (field = this->fields.begin(); field != this->fields.end(); field++) 166 if ( !strcmp(FieldName, (*field)->getName()))166 if (fieldName == (*field)->getName()) 167 167 return (*field); 168 168 return NULL; … … 197 197 @returns the PhysicsConnection if found, or NULL if not 198 198 */ 199 PhysicsConnection* PhysicsEngine::getPhysicsConnectionByName(const char*physicsConnectionName) const199 PhysicsConnection* PhysicsEngine::getPhysicsConnectionByName(const std::string& physicsConnectionName) const 200 200 { 201 201 list<PhysicsConnection*>::const_iterator pc; 202 202 for (pc = this->connections.begin(); pc != this->connections.end(); pc++) 203 if ( !strcmp(physicsConnectionName, (*pc)->getName()))203 if (physicsConnectionName == (*pc)->getName()) 204 204 delete (*pc); 205 205 return NULL; -
branches/std/src/lib/physics/physics_engine.h
r6512 r7216 31 31 void loadConnections(const TiXmlElement* root); 32 32 33 PhysicsInterface* getPhysicsInterfaceByName(const char*physicsInterfaceName) const;33 PhysicsInterface* getPhysicsInterfaceByName(const std::string& physicsInterfaceName) const; 34 34 35 35 void addField(Field* field); 36 36 void removeField(Field* field); 37 Field* getFieldByName(const char* FieldName) const;37 Field* getFieldByName(const std::string& fieldName) const; 38 38 39 39 void addConnection(PhysicsConnection* connection); 40 40 void removeConnection(PhysicsConnection* connection); 41 PhysicsConnection* getPhysicsConnectionByName(const char*physicsConnectionName) const;41 PhysicsConnection* getPhysicsConnectionByName(const std::string& physicsConnectionName) const; 42 42 43 43 -
branches/std/src/lib/shell/shell.cc
r7198 r7216 85 85 this->lineSpacing = 0; 86 86 this->bActive = true; 87 this->fontFile = new char[strlen(SHELL_DEFAULT_FONT)+1]; 88 strcpy(this->fontFile, SHELL_DEFAULT_FONT); 87 this->fontFile = SHELL_DEFAULT_FONT; 89 88 90 89 … … 110 109 delete this->bufferText[i]; 111 110 delete[] this->bufferText; 112 delete[] this->fontFile;113 111 // delete the inputLine 114 112 delete this->shellInput; … … 139 137 if (!top) 140 138 { 141 this->bufferText[i]->setText((*textLine) , true);139 this->bufferText[i]->setText((*textLine)); 142 140 if (textLine != ShellBuffer::getInstance()->getBuffer()->begin()) 143 141 top = true; … … 167 165 if (textLine != ShellBuffer::getInstance()->getBuffer()->begin()) 168 166 { 169 this->bufferText[i]->setText((*textLine) , false);167 this->bufferText[i]->setText((*textLine)); 170 168 textLine--; 171 169 } … … 181 179 * (be aware that within orxonox fontFile is relative to the Data-Dir) 182 180 */ 183 void Shell::setFont(const char*fontFile)181 void Shell::setFont(const std::string& fontFile) 184 182 { 185 183 // if (!ResourceManager::isInDataDir(fontFile)) 186 184 // return false; 187 185 188 if (this->fontFile != NULL) 189 delete[] this->fontFile; 190 191 this->fontFile = new char[strlen(fontFile)+1]; 192 strcpy(this->fontFile, fontFile); 186 this->fontFile = fontFile; 193 187 194 188 this->rebuildText(); … … 245 239 * @param fileName the filename of the Image to load 246 240 */ 247 void Shell::setBackgroundImage(const char*fileName)241 void Shell::setBackgroundImage(const std::string& fileName) 248 242 { 249 243 this->backgroundMaterial->setDiffuseMap(fileName); … … 340 334 for (int i = 0; i < this->bufferDisplaySize; i++) 341 335 { 342 this->bufferText[i]->setText( NULL, true);336 this->bufferText[i]->setText(""); 343 337 } 344 338 … … 351 345 * @param text the text to output. 352 346 */ 353 void Shell::printToDisplayBuffer(const char*text)347 void Shell::printToDisplayBuffer(const std::string& text) 354 348 { 355 349 if(likely(bufferText != NULL)) … … 382 376 this->bufferText[0] = lastText; 383 377 384 this->bufferText[0]->setText(text , true);378 this->bufferText[0]->setText(text); 385 379 } 386 380 } … … 427 421 for (unsigned int i = 0; i < this->bufferDisplaySize; i++) 428 422 { 429 this->bufferText[i]->setText((*it) , false);423 this->bufferText[i]->setText((*it)); 430 424 it--; 431 425 } -
branches/std/src/lib/shell/shell.h
r5784 r7216 53 53 inline bool isActive() const { return this->bActive; }; 54 54 55 void setFont(const char*fontFile);55 void setFont(const std::string& fontFile); 56 56 void setTextSize(unsigned int textSize, unsigned int lineSpacing = 1); 57 57 void setTextColor(float r, float g, float b, float a); 58 58 void setBackgroundColor(float r, float g, float b, float a); 59 void setBackgroundImage(const char*fileName);59 void setBackgroundImage(const std::string& fileName); 60 60 61 61 void resetValues(); … … 64 64 // BUFFERS 65 65 void setBufferDisplaySize(unsigned int bufferDisplaySize); 66 void printToDisplayBuffer(const char*text);66 void printToDisplayBuffer(const std::string& text); 67 67 void moveDisplayBuffer(int lineCount); 68 68 … … 83 83 84 84 // void testI (int i); 85 // void testS (const char*s);85 // void testS (const std::string& s); 86 86 // void testB (bool b); 87 87 // void testF (float f); 88 // void testSF (const char*s, float f);88 // void testSF (const std::string& s, float f); 89 89 90 90 private: … … 95 95 unsigned int textSize; //!< The size of the text. 96 96 float textColor[4]; //!< The text's color [r,g,b,a]. 97 char*fontFile; //!< The file containing the font.97 std::string fontFile; //!< The file containing the font. 98 98 Material* backgroundMaterial; //!< A material for the background. 99 99 -
branches/std/src/lib/shell/shell_command.cc
r7211 r7216 153 153 * @return true on success, false otherwise. 154 154 */ 155 bool ShellCommand::execute(const char*executionString)155 bool ShellCommand::execute(const std::string& executionString) 156 156 { 157 157 if (ShellCommandClass::commandClassList == NULL) … … 184 184 { 185 185 if (inputSplits.getCount() > 1) 186 (*alias)->getCommand()->executor->execute(objectList->front(), executionString+inputSplits.getOffset(1)); 186 { 187 188 (*alias)->getCommand()->executor->execute(objectList->front(), executionString.substr(inputSplits.getOffset(1), executionString.size())); /// TODO CHECK IF OK 189 } 187 190 else 188 191 (*alias)->getCommand()->executor->execute(objectList->front(), ""); … … 240 243 return false; 241 244 if (inputSplits.getCount() > fktPos+1) 242 (*cmdIT)->executor->execute(objectPointer, executionString +inputSplits.getOffset(fktPos +1));245 (*cmdIT)->executor->execute(objectPointer, executionString.substr(inputSplits.getOffset(fktPos +1), executionString.size())); /// TODO CHECK IF OK 243 246 else 244 247 (*cmdIT)->executor->execute(objectPointer, ""); … … 326 329 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 327 330 { 328 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className , (*classIT)->commandList.size());331 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className.c_str(), (*classIT)->commandList.size()); 329 332 330 333 list<ShellCommand*>::iterator cmdIT; -
branches/std/src/lib/shell/shell_command.h
r7201 r7216 61 61 friend class ShellCommandClass; 62 62 public: 63 static bool execute (const char*executionString);63 static bool execute (const std::string& executionString); 64 64 65 65 ShellCommand* describe(const char* description); -
branches/std/src/lib/shell/shell_command_class.cc
r5780 r7216 36 36 * @param className the Name of the command-class to create 37 37 */ 38 ShellCommandClass::ShellCommandClass(const char* className) 38 ShellCommandClass::ShellCommandClass(const std::string& className) 39 : className(className) 39 40 { 40 41 this->setClassID(CL_SHELL_COMMAND_CLASS, "ShellCommandClass"); 41 42 this->setName(className); 42 43 43 this->className = className;44 44 this->classID = CL_NULL; 45 45 … … 65 65 * @returns true on success, false otherwise 66 66 */ 67 bool ShellCommandClass::getCommandListOfClass(const char* className, std::list<const char*>* stringList)68 { 69 if (stringList == NULL || className == NULL)67 bool ShellCommandClass::getCommandListOfClass(const std::string& className, std::list<std::string>* stringList) 68 { 69 if (stringList == NULL) 70 70 return false; 71 71 … … 73 73 for(elem = ShellCommandClass::commandClassList->begin(); elem != ShellCommandClass::commandClassList->end(); elem++) 74 74 { 75 if ( !strcmp ((*elem)->getName(), className))75 if (className == (*elem)->getName()) 76 76 { 77 77 list<ShellCommand*>::iterator command; … … 88 88 * @returns true on success, false otherwise 89 89 */ 90 bool ShellCommandClass::getCommandListOfAlias(std::list< const char*>* stringList)90 bool ShellCommandClass::getCommandListOfAlias(std::list<std::string>* stringList) 91 91 { 92 92 if (stringList == NULL || ShellCommandClass::aliasList == NULL) … … 138 138 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 139 139 { 140 if ( !strcmp(className, (*classIT)->className))140 if (className == (*classIT)->className) 141 141 { 142 142 if ((*classIT)->classID == CL_NULL) … … 154 154 * @returns the CommandClass if found, or a new CommandClass if not 155 155 */ 156 ShellCommandClass* ShellCommandClass::getCommandClass(const char*className)156 ShellCommandClass* ShellCommandClass::getCommandClass(const std::string& className) 157 157 { 158 158 if (ShellCommandClass::commandClassList == NULL) … … 162 162 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 163 163 { 164 if ( !strcmp(className, (*classIT)->className))164 if (className == (*classIT)->className) 165 165 { 166 166 return (*classIT); … … 186 186 * @param className: the Class of Commands to show help about 187 187 */ 188 void ShellCommandClass::help(const char* className) 189 { 190 if (className == NULL) 191 return; 188 void ShellCommandClass::help(const std::string& className) 189 { 192 190 if (likely(ShellCommandClass::commandClassList != NULL)) 193 191 { … … 195 193 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 196 194 { 197 if ( (*classIT)->className && !strcasecmp(className, (*classIT)->className))195 if (className == (*classIT)->className) 198 196 { 199 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className , (*classIT)->commandList.size());197 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className.c_str(), (*classIT)->commandList.size()); 200 198 list<ShellCommand*>::const_iterator cmdIT; 201 199 for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++) … … 212 210 } 213 211 } 214 PRINTF(3)("Class %s not found in Command's classes\n", className );212 PRINTF(3)("Class %s not found in Command's classes\n", className.c_str()); 215 213 } 216 214 else -
branches/std/src/lib/shell/shell_command_class.h
r6981 r7216 27 27 /** @returns the CommandClassList */ 28 28 static const std::list<ShellCommandClass*>* getCommandClassList() { return ShellCommandClass::commandClassList; }; 29 static bool getCommandListOfClass(const char* className, std::list<const char*>* stringList);30 static bool getCommandListOfAlias(std::list< const char*>* aliasList);29 static bool getCommandListOfClass(const std::string& className, std::list<std::string>* stringList); 30 static bool getCommandListOfAlias(std::list<std::string>* aliasList); 31 31 32 static ShellCommandClass* getCommandClass(const char*className);32 static ShellCommandClass* getCommandClass(const std::string& className); 33 33 static void unregisterAllCommands(); 34 34 35 static void help (const char*className);35 static void help (const std::string& className); 36 36 37 37 private: 38 ShellCommandClass(const char*className);38 ShellCommandClass(const std::string& className); 39 39 virtual ~ShellCommandClass(); 40 40 … … 43 43 44 44 private: 45 const char*className; //!< The Name of the Class. This should match the ClassName of the Commands Class.45 const std::string className; //!< The Name of the Class. This should match the ClassName of the Commands Class. 46 46 long classID; //!< The classID of this Class 47 47 std::list<ShellCommand*> commandList; //!< A list of Commands from this Class -
branches/std/src/lib/shell/shell_completion.cc
r7211 r7216 76 76 77 77 // Check if we are in a input. eg. the supplied string "class " and now we complete either function or object 78 if (this->input->getInput() != NULL && 79 strrchr(this->input->getInput(), ' ') >= this->input->getInput() + strlen(this->input->getInput())-1) 78 if (this->input->getInput()[this->input->getInput().size()-1] == ' ') 80 79 { 81 80 emptyComplete = true; … … 83 82 84 83 // CREATE INPUTS 85 if (this->input->getInput() == NULL) 86 completionLine = ""; 87 else 88 completionLine = this->input->getInput() + strspn(this->input->getInput(), " \t\n"); 89 SubString inputSplits(completionLine, " \t\n,"); 84 SubString inputSplits(this->input->getInput(), " \t\n,"); 90 85 91 86 // What String will be completed … … 151 146 if (unlikely(classBegin == NULL)) 152 147 return false; 153 const std::list< const char*>* clList = ClassList::getClassNames();148 const std::list<std::string>* clList = ClassList::getClassNames(); 154 149 if (clList != NULL) 155 150 { … … 195 190 if (unlikely(functionBegin == NULL)) 196 191 return false; 197 std::list< const char*> fktList;192 std::list<std::string> fktList; 198 193 ShellCommandClass::getCommandListOfClass(className, &fktList); 199 194 //printf("%s\n", boList->firstElement()->getName()); … … 212 207 if (unlikely(aliasBegin == NULL)) 213 208 return false; 214 std::list< const char*> aliasList;209 std::list<std::string> aliasList; 215 210 ShellCommandClass::getCommandListOfAlias(&aliasList); 216 211 //printf("%s\n", boList->firstElement()->getName()); … … 295 290 * !! The strings MUST NOT be deleted !! 296 291 */ 297 bool ShellCompletion::addToCompleteList(const std::list< const char*>* inputList, const char* completionBegin, SHELLC_TYPE type)292 bool ShellCompletion::addToCompleteList(const std::list<std::string>* inputList, const char* completionBegin, SHELLC_TYPE type) 298 293 { 299 294 if (inputList == NULL || completionBegin == NULL) … … 301 296 unsigned int searchLength = strlen(completionBegin); 302 297 303 list< const char*>::const_iterator string;298 list<std::string>::const_iterator string; 304 299 for (string = inputList->begin(); string != inputList->end(); string++) 305 300 { 306 if ( strlen(*string) >= searchLength &&307 !strncasecmp(*string, completionBegin, searchLength))301 if ((*string).size() >= searchLength && 302 !strncasecmp((*string).c_str(), completionBegin, searchLength)) 308 303 { 309 304 ShellC_Element newElem; 310 newElem.name = *string;305 newElem.name = (*string).c_str(); 311 306 newElem.type = type; 312 307 this->completionList.push_back(newElem); -
branches/std/src/lib/shell/shell_completion.h
r5784 r7216 52 52 bool generalComplete(const char* begin, const char* displayAs = "%s", const char* addBack = NULL, const char* addFront = NULL); 53 53 54 bool addToCompleteList(const std::list< const char*>* inputList, const char* completionBegin, SHELLC_TYPE type);54 bool addToCompleteList(const std::list<std::string>* inputList, const char* completionBegin, SHELLC_TYPE type); 55 55 bool addToCompleteList(const std::list<BaseObject*>* inputList, const char* completionBegin, SHELLC_TYPE type); 56 56 void emptyCompletionList(); -
branches/std/src/lib/shell/shell_input.cc
r7207 r7216 46 46 this->setClassID(CL_SHELL_INPUT, "ShellInput"); 47 47 48 this->inputLine = new char[1]; 49 this->inputLine[0] = '\0'; 48 this->inputLine = ""; 50 49 this->historyIT = this->history.begin(); 51 50 this->setHistoryLength(50); … … 70 69 { 71 70 // delete what has to be deleted here 72 delete[] this->inputLine;73 71 delete this->completion; 74 72 75 73 while (!this->history.empty()) 76 74 { 77 delete[] this->history.front();78 75 this->history.pop_front(); 79 76 } … … 96 93 void ShellInput::flush() 97 94 { 98 if (likely(this->inputLine != NULL)) 99 { 100 delete[] this->inputLine; 101 } 102 this->inputLine = new char[1]; 103 *this->inputLine = '\0'; 104 this->setText(this->inputLine, true); 95 this->inputLine.clear(); 96 this->setText(this->inputLine); 105 97 } 106 98 … … 109 101 * @param text the new Text to set as InputLine 110 102 */ 111 void ShellInput::setInputText(const char* text) 112 { 113 delete[] this->inputLine; 114 if (text == NULL) 115 { 116 this->inputLine = new char[1]; 117 this->inputLine[0] = '\0'; 118 } 119 else 120 { 121 this->inputLine = new char[strlen(text)+1]; 122 strcpy(this->inputLine, text); 123 } 124 this->setText(this->inputLine, true); 103 void ShellInput::setInputText(const std::string& text) 104 { 105 this->inputLine = text; 106 this->setText(this->inputLine); 125 107 } 126 108 … … 134 116 if (this->historyScrolling) 135 117 { 136 delete[] this->history.back();137 118 this->history.pop_back(); 138 119 this->historyScrolling = false; 139 120 } 140 121 141 char* addCharLine = new char[strlen(this->inputLine)+2]; 142 143 sprintf(addCharLine, "%s%c", this->inputLine, character); 144 delete[] this->inputLine; 145 this->inputLine = addCharLine; 146 this->setText(this->inputLine, true); 122 this->inputLine += character; 123 this->setText(this->inputLine); 147 124 } 148 125 … … 151 128 * @param characters a \\0 terminated char-array to add to the InputLine 152 129 */ 153 void ShellInput::addCharacters(const char*characters)130 void ShellInput::addCharacters(const std::string& characters) 154 131 { 155 132 if (this->historyScrolling) 156 133 { 157 delete[] this->history.back();158 134 this->history.pop_back(); 159 135 this->historyScrolling = false; 160 136 } 161 137 162 char* addCharLine = new char[strlen(this->inputLine)+strlen(characters)+1]; 163 164 sprintf(addCharLine, "%s%s", this->inputLine, characters); 165 delete[] this->inputLine; 166 this->inputLine = addCharLine; 167 this->setText(this->inputLine, true); 138 this->inputLine += characters; 139 this->setText(this->inputLine); 168 140 } 169 141 … … 176 148 if (this->historyScrolling) 177 149 { 178 delete[] this->history.back();179 150 this->history.pop_back(); 180 151 this->historyScrolling = false; 181 152 } 182 183 if (strlen(this->inputLine) == 0) 184 return; 185 186 if (characterCount > strlen(this->inputLine)) 187 characterCount = strlen(this->inputLine); 188 189 char* removeCharLine = new char[strlen(this->inputLine)-characterCount+1]; 190 191 strncpy(removeCharLine, this->inputLine, strlen(this->inputLine)-characterCount); 192 removeCharLine[strlen(this->inputLine)-characterCount] = '\0'; 193 delete[] this->inputLine; 194 this->inputLine = removeCharLine; 195 this->setText(this->inputLine, true); 153 if (this->inputLine.size() < characterCount) 154 characterCount = this->inputLine.size(); 155 156 this->inputLine.erase(this->inputLine.size() - characterCount, this->inputLine.size()); 157 this->setText(this->inputLine); 196 158 } 197 159 … … 202 164 bool ShellInput::executeCommand() 203 165 { 204 ShellBuffer::addBufferLineStatic("Execute Command: %s\n", this->inputLine );205 206 if ( strlen(this->inputLine) == 0)166 ShellBuffer::addBufferLineStatic("Execute Command: %s\n", this->inputLine.c_str()); 167 168 if (this->inputLine.empty()) 207 169 return false; 208 170 209 char* newCommand = new char[strlen(this->inputLine)+1]; 210 strcpy(newCommand, this->inputLine); 211 212 ShellCommand::execute(newCommand); 171 ShellCommand::execute(this->inputLine); 213 172 214 173 // removing the eventually added Entry (from scrolling) to the List 215 174 if (this->historyScrolling) 216 175 { 217 delete[] this->history.back();218 176 this->history.pop_back(); 219 177 this->historyScrolling = false; … … 221 179 222 180 // adding the new Command to the History 223 this->history.push_back( newCommand);181 this->history.push_back(this->inputLine); 224 182 if (this->history.size() > this->historyLength) 225 183 { 226 delete[] this->history.front();227 184 this->history.pop_front(); 228 185 } … … 241 198 if (!this->historyScrolling) 242 199 { 243 char* currentText = new char[strlen(this->inputLine)+1]; 244 strcpy(currentText, this->inputLine); 245 this->history.push_back(currentText); 200 this->history.push_back(this->inputLine); 246 201 this->historyScrolling = true; 247 202 this->historyIT = --this->history.end(); … … 250 205 if(this->historyIT != this->history.begin()) 251 206 { 252 char*prevElem = *(--this->historyIT);253 if (prevElem == NULL)207 std::string prevElem = *(--this->historyIT); 208 /*if (prevElem == NULL) /// TODO STD 254 209 return; 255 else 210 else */ 256 211 { 257 212 this->flush(); … … 270 225 if (this->historyIT != this->history.end()) 271 226 { 272 char*nextElem = *(++this->historyIT);273 if (nextElem == NULL)227 std::string nextElem = *(++this->historyIT); 228 /* if (nextElem == NULL) /// TODO FIX STD 274 229 return; 275 else 230 else */ 276 231 { 277 232 this->flush(); … … 285 240 * prints out some nice help about the Shell 286 241 */ 287 void ShellInput::help(const char* className, const char*functionName)288 { 289 printf("%s::%s\n", className , functionName);290 291 if ( strlen(className) == 0)242 void ShellInput::help(const std::string& className, const std::string& functionName) 243 { 244 printf("%s::%s\n", className.c_str(), functionName.c_str()); 245 246 if (className.empty()) 292 247 { 293 248 PRINT(0)("Help for the most important Shell-commands\n"); … … 298 253 PRINT(0)("- Also try 'help className'"); 299 254 } 300 else if ( strlen (className) > 0 && strlen (functionName) == 0)255 else if (!className.empty() && functionName.empty()) 301 256 { 302 257 ShellCommandClass::help(className); -
branches/std/src/lib/shell/shell_input.h
r5786 r7216 31 31 32 32 /** @returns the inputLine */ 33 const char*getInput() const { return this->inputLine; };33 const std::string& getInput() const { return this->inputLine; }; 34 34 35 35 // InputLine 36 36 void flush(); 37 void setInputText(const char*text);37 void setInputText(const std::string& text); 38 38 void addCharacter(char character); 39 void addCharacters(const char*characters);39 void addCharacters(const std::string& characters); 40 40 void removeCharacters(unsigned int characterCount = 1); 41 41 void setRepeatDelay(float repeatDelay, float repeatRate); … … 47 47 void historyMoveDown(); 48 48 49 void help(const char* className = "", const char*function = "");49 void help(const std::string& className = "", const std::string& function = ""); 50 50 51 51 virtual void tick(float dt); … … 54 54 private: 55 55 // HANDLING TEXT INPUT 56 ShellCompletion* completion;//!< The Completion Interface.56 ShellCompletion* completion; //!< The Completion Interface. 57 57 58 char* inputLine;//!< the Char-Array of the Buffer59 float repeatRate;//!< The Repeat-Delay.60 float repeatDelay;//!< The delay of the first Character of a given Character.61 float delayed;//!< how much of the delay is remaining.62 Uint16 pressedKey;//!< the pressed key that will be repeated.58 std::string inputLine; //!< the Char-Array of the Buffer 59 float repeatRate; //!< The Repeat-Delay. 60 float repeatDelay; //!< The delay of the first Character of a given Character. 61 float delayed; //!< how much of the delay is remaining. 62 Uint16 pressedKey; //!< the pressed key that will be repeated. 63 63 64 std::list< char*> history;//!< The history of given commands.65 std::list< char*>::iterator historyIT;66 unsigned int historyLength;//!< The maximum length of the InputHistory.67 bool historyScrolling;//!< true if we are scrolling through the history.64 std::list<std::string> history; //!< The history of given commands. 65 std::list<std::string>::iterator historyIT; //!< The locator that tells us, where we are in the history. 66 unsigned int historyLength; //!< The maximum length of the InputHistory. 67 bool historyScrolling; //!< true if we are scrolling through the history. 68 68 }; 69 69 -
branches/std/src/lib/util/executor/executor.h
r7214 r7216 271 271 { 272 272 SubString sub; 273 printf("===%s\n", parameters.c_str());274 273 sub.split(parameters, " \n\t,", '\\'); 275 sub.debug();276 274 //! FUNCTOR_LIST is the List of Executive Functions 277 275 #define FUNCTOR_LIST(x) ExecutorExecute ## x -
branches/std/src/lib/util/executor/functor_list.h
r7214 r7216 98 98 99 99 FUNCTOR_LIST(0)(); 100 //! makes functions with one cstring101 FUNCTOR_LIST(1)(l_CSTRING);102 //! makes functions with two cstrings103 FUNCTOR_LIST(2)(l_CSTRING, l_CSTRING);104 //! makes functions with three cstrings105 FUNCTOR_LIST(3)(l_CSTRING, l_CSTRING, l_CSTRING);106 //! makes functions with four cstrings107 FUNCTOR_LIST(4)(l_CSTRING, l_CSTRING, l_CSTRING, l_CSTRING);108 109 100 //! makes functions with one string 110 101 FUNCTOR_LIST(1)(l_STRING); … … 151 142 152 143 //! mixed values: 153 FUNCTOR_LIST(2)(l_ CSTRING, l_FLOAT);144 FUNCTOR_LIST(2)(l_STRING, l_FLOAT); 154 145 FUNCTOR_LIST(2)(l_UINT, l_LONG); 155 FUNCTOR_LIST(2)(l_ CSTRING, l_UINT);146 FUNCTOR_LIST(2)(l_STRING, l_UINT); 156 147 157 FUNCTOR_LIST(3)(l_ CSTRING, l_FLOAT, l_UINT);148 FUNCTOR_LIST(3)(l_STRING, l_FLOAT, l_UINT); 158 149 159 150 -
branches/std/src/lib/util/helper_functions.cc
r7214 r7216 104 104 { 105 105 if (STRING.size() > 0) 106 {107 printf("DECISION1: %s\n", STRING.c_str());108 106 return STRING; 109 }110 107 else 111 {112 printf("DECISION2: %s\n", defaultValue.c_str());113 108 return defaultValue; 114 }115 109 } 116 110 -
branches/std/src/lib/util/loading/load_param.cc
r7214 r7216 66 66 ((this->executor->getType() & Executor_NoLoadString) == Executor_NoLoadString))) 67 67 { 68 PRINTF( 0)("Loading value '%s' with Parameters '%s' onto: %s::%s\n", this->paramName.c_str(), loadString.c_str(), this->object->getClassName(), this->object->getName());68 PRINTF(4)("Loading value '%s' with Parameters '%s' onto: %s::%s\n", this->paramName.c_str(), loadString.c_str(), this->object->getClassName(), this->object->getName()); 69 69 this->executor->execute(this->object, loadString); 70 70 } -
branches/std/src/story_entities/game_world_data.cc
r7203 r7216 343 343 344 344 if (this->music != NULL) 345 this->setSoundTrack( NULL);345 this->setSoundTrack(""); 346 346 this->music = NULL; 347 347 /* stop the sound eninge */ … … 354 354 355 355 356 void GameWorldData::setSoundTrack(const char*name)356 void GameWorldData::setSoundTrack(const std::string& name) 357 357 { 358 358 if (this->music != NULL) … … 360 360 this->music = NULL; 361 361 362 if ( name != NULL)363 { 364 PRINTF(3)("Setting Sound Track to %s\n", name );362 if (!name.empty()) 363 { 364 PRINTF(3)("Setting Sound Track to %s\n", name.c_str()); 365 365 std::string oggFile = ResourceManager::getFullName(name); 366 366 this->music = new OggPlayer(oggFile); -
branches/std/src/story_entities/game_world_data.h
r7020 r7216 42 42 43 43 /* interface functions */ 44 void setSoundTrack(const char*name);44 void setSoundTrack(const std::string& name); 45 45 void loadGameRule(const TiXmlElement* root); 46 46 -
branches/std/src/util/Makefile.am
r7193 r7216 15 15 animation/animation_player.cc \ 16 16 \ 17 track/pilot_node.cc \ 18 track/track_manager.cc \ 17 track/pilot_node.cc 18 19 # track/track_manager.cc \ 19 20 track/track_node.cc 20 21 … … 31 32 animation/t_animation.h \ 32 33 \ 33 track/pilot_node.h \ 34 track/track_manager.h \ 34 track/pilot_node.h 35 36 # track/track_manager.h \ 35 37 track/track_node.h -
branches/std/src/util/fast_factory.cc
r5750 r7216 29 29 * @return a new FastFactory 30 30 */ 31 FastFactory::FastFactory (ClassID classID, const char*fastFactoryName)31 FastFactory::FastFactory (ClassID classID, const std::string& fastFactoryName) 32 32 { 33 33 this->setClassID(CL_FAST_FACTORY, "FastFactory"); … … 119 119 * @returns true if found, false otherwise. 120 120 */ 121 FastFactory* FastFactory::searchFastFactory(const char*fastFactoryName)121 FastFactory* FastFactory::searchFastFactory(const std::string& fastFactoryName) 122 122 { 123 123 if (FastFactory::first == NULL) … … 128 128 while (tmpFac != NULL) 129 129 { 130 if ( strcmp(tmpFac->getName(), fastFactoryName))130 if (fastFactoryName == tmpFac->getName()) 131 131 return tmpFac; 132 132 tmpFac = tmpFac->next; -
branches/std/src/util/fast_factory.h
r5447 r7216 80 80 81 81 static FastFactory* searchFastFactory(ClassID classID); 82 static FastFactory* searchFastFactory(const char*fastFactoryName);82 static FastFactory* searchFastFactory(const std::string& fastFactoryName); 83 83 84 84 ClassID getStoredID() const { return this->storedClassID; }; 85 85 86 86 protected: 87 FastFactory (ClassID classID, const char* fastFactoryName = NULL);87 FastFactory (ClassID classID, const std::string& fastFactoryName = ""); 88 88 89 89 /** sets the Next factory in the list @param nextFactory the next factory */ -
branches/std/src/util/multiplayer_team_deathmatch.cc
r7193 r7216 92 92 93 93 94 void MultiplayerTeamDeathmatch::setDeathScreen(const char*imageName)94 void MultiplayerTeamDeathmatch::setDeathScreen(const std::string& imageName) 95 95 { 96 96 if( this->deathScreen) -
branches/std/src/util/multiplayer_team_deathmatch.h
r7044 r7216 38 38 inline void setDeathPenaltyTimeout(float time) { this->deathTimeout = time; } 39 39 inline void setMaxKills(int kills) { this->maxKills = kills; } 40 void setDeathScreen(const char*imageName);40 void setDeathScreen(const std::string& imageName); 41 41 42 42 protected: -
branches/std/src/util/object_manager.cc
r7198 r7216 97 97 * this function also does a transformation from omList as char* to OM_LIST. 98 98 */ 99 void ObjectManager::toList (WorldEntity* entity, const char*omList)99 void ObjectManager::toList (WorldEntity* entity, const std::string& omList) 100 100 { 101 101 this->toList(entity, ObjectManager::StringToOMList(omList)); … … 153 153 * @param level: level 0: only show list info; level 1: also show entities and their names. 154 154 */ 155 void ObjectManager::debug(const char*listName, unsigned int level)155 void ObjectManager::debug(const std::string& listName, unsigned int level) 156 156 { 157 157 PRINT(0)("=================================\n"); 158 158 PRINT(0)("=ObjectManager-DEBUG=============\n"); 159 159 PRINT(0)("=================================\n"); 160 if (listName == NULL || listName[0] == '\0')160 if (listName.empty()) 161 161 for (unsigned int i = 0; i < OM_SIZE; ++i) 162 162 debug((OM_LIST) i, level); … … 189 189 * @returns the OM_LIST transformed from listName. or the default, if not found or NULL. 190 190 */ 191 OM_LIST ObjectManager::StringToOMList(const char*listName)192 { 193 if (unlikely(listName == NULL)) return OM_DEFAULT_LIST;191 OM_LIST ObjectManager::StringToOMList(const std::string& listName) 192 { 193 if (unlikely(listName.empty())) return OM_DEFAULT_LIST; 194 194 195 195 for(unsigned int i = 0; i < OM_SIZE; ++i) { 196 if( !strcmp(listName, ObjectManager::objectManagerListNames[i])) {196 if(listName == ObjectManager::objectManagerListNames[i]) { 197 197 return (OM_LIST)i; 198 198 } -
branches/std/src/util/object_manager.h
r6142 r7216 76 76 77 77 void toList (WorldEntity* entity, OM_LIST omList = OM_DEFAULT_LIST); 78 void toList (WorldEntity* entity, const char*omList);78 void toList (WorldEntity* entity, const std::string& omList); 79 79 80 80 … … 85 85 86 86 void debug(OM_LIST omList, unsigned int level = 0) const; 87 void debug(const char* listName = NULL, unsigned int level = 0);87 void debug(const std::string& listName = "", unsigned int level = 0); 88 88 89 static OM_LIST StringToOMList(const char*listName);89 static OM_LIST StringToOMList(const std::string& listName); 90 90 static const char* OMListToString(OM_LIST omList); 91 91 -
branches/std/src/util/track/track_manager.h
r7130 r7216 142 142 // Methods to change the Path (initialisation) 143 143 void workOn(unsigned int trackID); 144 void workOnS(const char*trackName);144 void workOnS(const std::string& trackName); 145 145 146 146 /** \see setCurveType(CurveType curveType, TrackElement* trackElem); @param curveType the type of the Curve */ … … 157 157 void fork(unsigned int count, ...); 158 158 void forkS(unsigned int count, ...); 159 void forkS(const char*forkString);159 void forkS(const std::string& forkString); 160 160 void forkV(unsigned int count, int* trackIDs, char** trackNames, TrackElement* trackElem = NULL); 161 161 void condition(unsigned int trackID, CONDITION cond, void* subject); -
branches/std/src/world_entities/elements/text_element.cc
r7193 r7216 70 70 } 71 71 72 void TextElement::setText(const char*text)72 void TextElement::setText(const std::string& text) 73 73 { 74 74 Text::setText(text); 75 75 } 76 76 77 void TextElement::setFont(const char*font)77 void TextElement::setFont(const std::string& font) 78 78 { 79 79 Text::setFont(font, (unsigned int)this->getSizeY2D()); -
branches/std/src/world_entities/elements/text_element.h
r7019 r7216 29 29 virtual void loadParams(const TiXmlElement* root); 30 30 31 void setText(const char*text);32 void setFont(const char*font);31 void setText(const std::string& text); 32 void setFont(const std::string& font); 33 33 34 34 private: -
branches/std/src/world_entities/planet.cc
r7193 r7216 45 45 this->toList(OM_GROUP_01); 46 46 47 this->material = new Material();48 47 //this->material->setIllum(20); 49 48 //this->material->setAmbient(0.1, 0.1, 0.1); … … 71 70 { 72 71 PRINTF(5)("Deleting Planet\n"); 73 if( this->material)74 delete this->material;75 72 } 76 73 … … 92 89 * @param textureName the top texture. 93 90 */ 94 void Planet::setTexture(const char*textureName)91 void Planet::setTexture(const std::string& textureName) 95 92 { 96 this->material ->setDiffuseMap(textureName);93 this->material.setDiffuseMap(textureName); 97 94 } 98 95 … … 124 121 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 125 122 126 this->material ->select();123 this->material.select(); 127 124 128 125 // /WorldEntity::draw(); -
branches/std/src/world_entities/planet.h
r6959 r7216 9 9 /* INCLUDES */ 10 10 #include "world_entity.h" 11 11 #include "material.h" 12 12 /* FORWARD DECLARATION */ 13 class Material;14 13 class Texture; 15 14 … … 26 25 void setSize(float size); 27 26 /** assumes jpg as input-format */ 28 void setTexture(const char*textureName);27 void setTexture(const std::string& textureName); 29 28 30 29 … … 34 33 35 34 private: 36 Material *material; //!< Materials for the Planet. sorted by number (0-5) top, bottom, left, right, front, back35 Material material; //!< Materials for the Planet. sorted by number (0-5) top, bottom, left, right, front, back 37 36 Texture* texture; //!< Textures for the CubeMap. 38 37 -
branches/std/src/world_entities/power_ups/param_power_up.cc
r7193 r7216 81 81 } 82 82 83 void ParamPowerUp::setType(const char*type)83 void ParamPowerUp::setType(const std::string& type) 84 84 { 85 85 for(int i = 0; i < POWERUP_PARAM_size; ++i) { 86 if( strcmp(type, paramTypes[i]) == 0) {86 if(type == paramTypes[i]) { 87 87 this->type = (EnumParamPowerUpType)i; 88 88 break; -
branches/std/src/world_entities/power_ups/param_power_up.h
r7065 r7216 28 28 void setMaxValue(float value); 29 29 void setMinValue(float value); 30 void setType(const char*type);30 void setType(const std::string& type); 31 31 EnumParamPowerUpType getType(); 32 32 float getValue(); … … 43 43 44 44 private: 45 static const char* paramTypes[]; 46 EnumParamPowerUpType type; 47 float value; 48 float max_value; 49 float min_value; 45 EnumParamPowerUpType type; 46 float value; 47 float max_value; 48 float min_value; 49 50 static const char* paramTypes[]; 51 50 52 }; 51 53 -
branches/std/src/world_entities/power_ups/power_up.cc
r7207 r7216 182 182 }; 183 183 184 void PowerUp::setRespawnType(const char* type) 184 185 void PowerUp::setRespawnType(const std::string& type) 185 186 { 186 187 for(int i = 0; i < RESPAWN_size; ++i) 187 188 { 188 if( !strcmp(type, respawnTypes[i]))189 if(type == respawnTypes[i]) 189 190 { 190 191 this->respawnType = (PowerUpRespawn)i; -
branches/std/src/world_entities/power_ups/power_up.h
r7207 r7216 31 31 virtual void draw () const; 32 32 virtual void tick(float dt); 33 void setRespawnType(const char*type);33 void setRespawnType(const std::string& type); 34 34 void setRespawnTime(const float respawn); 35 35 … … 45 45 46 46 private: 47 SoundSource soundSource;48 SoundBuffer* pickupBuffer;49 SoundBuffer* respawnBuffer;50 Material* sphereMaterial;51 PowerUpRespawn respawnType;52 float respawnTime;53 float respawnStart;54 static const char* respawnTypes[];47 SoundSource soundSource; 48 SoundBuffer* pickupBuffer; 49 SoundBuffer* respawnBuffer; 50 Material* sphereMaterial; 51 PowerUpRespawn respawnType; 52 float respawnTime; 53 float respawnStart; 54 static const char* respawnTypes[]; 55 55 56 WorldEntity* collider;56 WorldEntity* collider; 57 57 }; 58 58 -
branches/std/src/world_entities/recorder.cc
r7193 r7216 54 54 55 55 LoadParam(root, "duration", this, Recorder, setStreamDuration); 56 56 57 LoadParam(root, "fps", this, Recorder, setFPS); 58 57 59 LoadParam(root, "name", this, Recorder, initVideo); 58 60 } … … 71 73 72 74 73 void Recorder::initVideo(const char*filename)75 void Recorder::initVideo(const std::string& filename) 74 76 { 75 77 frame_count = 0; … … 78 80 79 81 // auto detect the output format from the name, default is mpeg 80 output_format = guess_format(NULL, filename , NULL);82 output_format = guess_format(NULL, filename.c_str(), NULL); 81 83 if (!output_format) 82 84 { … … 93 95 94 96 format_context->oformat = output_format; 95 snprintf(format_context->filename, sizeof(format_context->filename), "%s", filename );97 snprintf(format_context->filename, sizeof(format_context->filename), "%s", filename.c_str()); 96 98 97 99 // add video stream using the default format codec and initialize the codec … … 104 106 105 107 // print some information 106 dump_format(format_context, 0, filename , 1);108 dump_format(format_context, 0, filename.c_str(), 1); 107 109 108 110 // now that all the parameters are set, we can open the … … 110 112 if(video_stream) 111 113 this->openVideo(); 112 114 113 115 // open the output file, if needed 114 116 if(!(output_format->flags & AVFMT_NOFILE)) 115 117 { 116 if(url_fopen(&format_context->pb, filename , URL_WRONLY) < 0)117 PRINTF(1)("Could not open %s\n", filename );118 if(url_fopen(&format_context->pb, filename.c_str(), URL_WRONLY) < 0) 119 PRINTF(1)("Could not open %s\n", filename.c_str()); 118 120 } 119 121 120 122 // write the stream header, if any 121 av_write_header(format_context); 123 av_write_header(format_context); 122 124 } 123 125 … … 129 131 av_free(buffer); 130 132 131 // write the trailer, if any 133 // write the trailer, if any 132 134 av_write_trailer(format_context); 133 135 134 136 // free the streams 135 137 for(int i = 0; i < format_context->nb_streams; i++) … … 175 177 176 178 void Recorder::allocPicture() 177 { 179 { 178 180 picture = avcodec_alloc_frame(); 179 181 if(!picture) … … 189 191 return; 190 192 } 191 avpicture_fill((AVPicture *)picture, picture_buf, 193 avpicture_fill((AVPicture *)picture, picture_buf, 192 194 codec_context->pix_fmt, width, height); 193 195 … … 211 213 if (!video_stream) 212 214 PRINTF(1)("Could not alloc stream\n"); 213 215 214 216 codec_context = video_stream->codec; 215 217 codec_context->codec_id = output_format->video_codec; … … 219 221 codec_context->bit_rate = 400000; 220 222 // resolution must be a multiple of two 221 codec_context->width = State::getResX(); 223 codec_context->width = State::getResX(); 222 224 codec_context->height = State::getResY(); 223 225 … … 229 231 // timebase should be 1/framerate and timestamp increments should be 230 232 // identically 1 231 codec_context->time_base.den = (int)stream_frame_rate; 233 codec_context->time_base.den = (int)stream_frame_rate; 232 234 codec_context->time_base.num = 1; 233 235 codec_context->gop_size = 12; // emit one intra frame every twelve frames at most … … 235 237 236 238 if (codec_context->codec_id == CODEC_ID_MPEG1VIDEO) 237 // needed to avoid using macroblocks in which some coeffs overflow 238 // this doesnt happen with normal video, it just happens here as the 239 // needed to avoid using macroblocks in which some coeffs overflow 240 // this doesnt happen with normal video, it just happens here as the 239 241 // motion of the chroma plane doesnt match the luma plane 240 242 codec_context->mb_decision=2; … … 275 277 { 276 278 int out_size, err; 277 279 278 280 codec_context = video_stream->codec; 279 281 280 282 if(frame_count >= stream_nb_frames) 281 283 { … … 287 289 this->fillYuvImage(); 288 290 289 291 290 292 if(format_context->oformat->flags & AVFMT_RAWPICTURE) 291 293 { … … 293 295 // futur for that 294 296 av_init_packet(&packet); 295 297 296 298 packet.flags |= PKT_FLAG_KEY; 297 299 packet.stream_index= video_stream->index; 298 300 packet.data= (uint8_t *)picture; 299 301 packet.size= sizeof(AVPicture); 300 302 301 303 err = av_write_frame(format_context, &packet); 302 304 } … … 309 311 { 310 312 av_init_packet(&packet); 311 313 312 314 packet.pts= av_rescale_q(codec_context->coded_frame->pts, codec_context->time_base, video_stream->time_base); 313 315 if(codec_context->coded_frame->key_frame) … … 316 318 packet.data= buffer; 317 319 packet.size= out_size; 318 320 319 321 // write the compressed frame in the media file 320 322 err = av_write_frame(format_context, &packet); -
branches/std/src/world_entities/recorder.h
r6981 r7216 20 20 class Recorder : public WorldEntity 21 21 { 22 private:23 AVFrame* picture;24 uint8_t* buffer;25 int frame_count;26 int buffer_size;27 28 AVOutputFormat* output_format;29 AVFormatContext* format_context;30 AVCodecContext* codec_context;31 AVCodec *codec;32 AVStream* video_stream;33 AVPacket packet;34 double video_pts;35 36 uint8_t *picture_buf;37 int size;38 39 int height;40 int width;41 float time;42 43 float stream_duration;44 float stream_frame_rate;45 int stream_nb_frames;46 47 AVFrame* RGB_frame;48 22 public: 49 23 Recorder (const TiXmlElement* root = NULL); … … 56 30 57 31 private: 58 void initVideo(const char*filename);32 void initVideo(const std::string& filename); 59 33 void addVideoStream(); 60 34 void openVideo(); … … 66 40 void setStreamDuration(float duration); 67 41 void setFPS(float fps); 42 43 44 private: 45 AVFrame* picture; 46 uint8_t* buffer; 47 int frame_count; 48 int buffer_size; 49 50 AVOutputFormat* output_format; 51 AVFormatContext* format_context; 52 AVCodecContext* codec_context; 53 AVCodec* codec; 54 AVStream* video_stream; 55 AVPacket packet; 56 double video_pts; 57 58 uint8_t* picture_buf; 59 int size; 60 61 int height; 62 int width; 63 float time; 64 65 float stream_duration; 66 float stream_frame_rate; 67 int stream_nb_frames; 68 69 AVFrame* RGB_frame; 68 70 }; 69 71 -
branches/std/src/world_entities/terrain.cc
r7207 r7216 48 48 this->loadParams(root); 49 49 50 // if (this->model != NULL)51 50 // if (this->model != NULL) 51 //this->ssp = new SpatialSeparation((Model*)this->model, 10.0f); 52 52 } 53 53 … … 64 64 65 65 if (!strstr(fileName, ".obj") || !strstr(fileName, ".OBJ") ) 66 67 68 66 { 67 this->loadModel(fileName); 68 } 69 69 else 70 71 72 70 { 71 // load the hightMap here. 72 } 73 73 } 74 74 … … 98 98 99 99 if(this->heightMap) 100 100 delete heightMap; 101 101 } 102 102 … … 122 122 123 123 LoadParam(root, "scale", this, Terrain, setScale) 124 124 .describe("The scale in x,y,z direction"); 125 125 126 126 LoadParam(root, "texture", this, Terrain, loadTexture) 127 127 .describe("The name of the Texture for this heightMap"); 128 128 129 129 LoadParam(root, "vegetation", this, Terrain, loadVegetation) 130 130 .describe("the fileName of the vegetation, that should be loaded onto this terrain. (must be relative to the data-dir)") ; 131 131 132 132 LoadParam(root, "height-map", this, Terrain, loadHeightMap) 133 133 .describe("The HeightMap, splitted into two strings seperated by ','. 1: HeighMap, 2: ColorMap"); 134 134 135 135 } … … 140 140 } 141 141 142 void Terrain::loadHeightMap(const char* heightMapFile, const char*colorMap)142 void Terrain::loadHeightMap(const std::string& heightMapFile, const std::string& colorMap) 143 143 { 144 144 if (this->heightMap != NULL) … … 151 151 152 152 this->heightMap = new HeightMap(hmName, hmColorName); 153 // heightMap->scale(Vector(43.0f,4.7f,43.0f));153 // heightMap->scale(Vector(43.0f,4.7f,43.0f)); 154 154 heightMap->scale(this->terrainScale); 155 155 heightMap->setAbsCoor(this->getAbsCoor()); … … 158 158 159 159 160 void Terrain::loadTexture(const char*textureName)161 { 162 PRINTF(0)("Load texture: %s\n", textureName);163 164 165 166 167 168 169 170 171 heightMapMaterial->setAmbientMap(textureName);172 heightMapMaterial->setSpecularMap(textureName);160 void Terrain::loadTexture(const std::string& textureName) 161 { 162 PRINTF(4)("Load texture: %s\n", textureName.c_str()); 163 164 heightMapMaterial->setDiffuse(1.0,1.0,1.0); 165 heightMapMaterial->setAmbient(1.0,1.0,1.0 ); 166 heightMapMaterial->setSpecular(1.0,1.0,1.0); 167 heightMapMaterial->setShininess(.5); 168 heightMapMaterial->setTransparency(1.0); 169 170 heightMapMaterial->setDiffuseMap(textureName); 171 // heightMapMaterial->setAmbientMap(textureName); 172 // heightMapMaterial->setSpecularMap(textureName); 173 173 } 174 174 … … 202 202 this->getAbsCoor ().z); 203 203 /* rotate */ 204 // Vector tmpRot = this->getAbsDir().getSpacialAxis();204 // Vector tmpRot = this->getAbsDir().getSpacialAxis(); 205 205 //glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 206 206 … … 224 224 225 225 226 /*227 glMatrixMode(GL_MODELVIEW);228 glPushMatrix();229 glLoadIdentity();230 Vector camera = State::getCameraNode()->getAbsCoor(); // Go on here ..........!!!231 232 float height = heightMap->getHeight(camera.x, camera.z);233 234 glEnable (GL_COLOR_MATERIAL) ;235 glBegin(GL_QUADS); // Draw The Cube Using quads236 glColor3f(0.0f,1.0f,0.0f); // Color Blue237 glVertex3f(camera.x + 63.0f,Terrain->getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f); // Top Right Of The Quad (Top)238 glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f); // Top Left Of The Quad (Top)239 glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f); // Bottom Left Of The Quad (Top)240 glVertex3f(camera.x+ 63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f); // Bottom Right Of The Quad (Top)241 glEnd(); // End Drawing The Plan242 243 glPopMatrix();*/244 245 246 /* THIS IS ONLY FOR DEBUGGING INFORMATION */226 /* 227 glMatrixMode(GL_MODELVIEW); 228 glPushMatrix(); 229 glLoadIdentity(); 230 Vector camera = State::getCameraNode()->getAbsCoor(); // Go on here ..........!!! 231 232 float height = heightMap->getHeight(camera.x, camera.z); 233 234 glEnable (GL_COLOR_MATERIAL) ; 235 glBegin(GL_QUADS); // Draw The Cube Using quads 236 glColor3f(0.0f,1.0f,0.0f); // Color Blue 237 glVertex3f(camera.x + 63.0f,Terrain->getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f); // Top Right Of The Quad (Top) 238 glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f); // Top Left Of The Quad (Top) 239 glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f); // Bottom Left Of The Quad (Top) 240 glVertex3f(camera.x+ 63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f); // Bottom Right Of The Quad (Top) 241 glEnd(); // End Drawing The Plan 242 243 glPopMatrix();*/ 244 245 246 /* THIS IS ONLY FOR DEBUGGING INFORMATION */ 247 247 if (this->ssp != NULL) 248 248 this->ssp->drawQuadtree(); … … 254 254 // if the terrain is the Terrain of Dave 255 255 if (debugTerrain == TERRAIN_DAVE) 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 256 { 257 objectList = glGenLists(1); 258 glNewList (objectList, GL_COMPILE); 259 260 glColor3f(1.0,0,0); 261 262 int sizeX = 100; 263 int sizeZ = 80; 264 float length = 1000; 265 float width = 200; 266 float widthX = float (length /sizeX); 267 float widthZ = float (width /sizeZ); 268 269 float height [sizeX][sizeZ]; 270 Vector normal_vectors[sizeX][sizeZ]; 271 272 273 for ( int i = 0; i<sizeX-1; i+=1) 274 for (int j = 0; j<sizeZ-1;j+=1) 275 //height[i][j] = rand()/20046 + (j-25)*(j-25)/30; 276 276 #ifdef __WIN32__ 277 277 height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5; 278 278 #else 279 height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.5;279 height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.5; 280 280 #endif 281 281 282 //Die Huegel ein wenig glaetten 283 for (int h=1; h<2;h++) 284 for (int i=1;i<sizeX-2 ;i+=1 ) 285 for(int j=1;j<sizeZ-2;j+=1) 286 height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4; 287 288 //Berechnung von normalen Vektoren 289 for(int i=1;i<sizeX-2;i+=1) 290 for(int j=1;j<sizeZ-2 ;j+=1) 291 { 292 Vector v1 = Vector (widthX*(1), height[i][j], widthZ*(j) ); 293 Vector v2 = Vector (widthX*(i-1), height[i-1][j], widthZ*(j)); 294 Vector v3 = Vector (widthX*(i), height[i][j+1], widthZ*(j+1)); 295 Vector v4 = Vector (widthX*(i+1), height[i+1][j], widthZ*(j)); 296 Vector v5 = Vector (widthX*(i), height[i][j-1], widthZ*(j-1)); 297 298 Vector c1 = v2 - v1; 299 Vector c2 = v3 - v1; 300 Vector c3= v4 - v1; 301 Vector c4 = v5 - v1; 302 Vector zero = Vector (0,0,0); 303 normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4); 304 normal_vectors[i][j].normalize(); 305 } 306 307 glBegin(GL_QUADS); 308 int snowheight=3; 309 for ( int i = 0; i<sizeX; i+=1) 310 for (int j = 0; j<sizeZ;j+=1) 311 { 312 Vector v1 = Vector (widthX*(i), height[i][j]-20, widthZ*(j) -width/2); 313 Vector v2 = Vector (widthX*(i+1), height[i+1][j]-20, widthZ*(j) -width/2); 314 Vector v3 = Vector (widthX*(i+1), height[i+1][j+1]-20, widthZ*(j+1)-width/2); 315 Vector v4 = Vector (widthX*(i), height[i][j+1]-20, widthZ*(j+1)-width/2); 316 float a[3]; 317 if(height[i][j]<snowheight){ 318 a[0]=0; 319 a[1]=1.0-height[i][j]/10-.3; 320 a[2]=0; 321 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 322 } 323 else{ 324 a[0]=1.0; 325 a[1]=1.0; 326 a[2]=1.0; 327 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 328 329 } 330 glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z); 331 glVertex3f(v1.x, v1.y, v1.z); 332 if(height[i+1][j]<snowheight){ 333 a[0]=0; 334 a[1] =1.0-height[i+1][j]/10-.3; 335 a[2]=0; 336 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 337 } 338 else{ 339 a[0]=1.0; 340 a[1]=1.0; 341 a[2]=1.0; 342 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 343 344 } 345 glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z); 346 glVertex3f(v2.x, v2.y, v2.z); 347 if(height[i+1][j+1]<snowheight){ 348 a[0]=0; 349 a[1] =1.0-height[i+1][j+1]/10-.3; 350 a[2]=0; 351 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 352 } 353 else{ 354 a[0]=1.0; 355 a[1]=1.0; 356 a[2]=1.0; 357 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 358 359 360 } 361 glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z); 362 glVertex3f(v3.x, v3.y, v3.z); 363 if(height[i][j+1]<snowheight){ 364 a[0]=0; 365 a[1] =1.0-height[i+1][j+1]/10-.3; 366 a[2]=0; 367 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 368 } 369 else{ 370 a[0]=1.0; 371 a[1]=1.0; 372 a[2]=1.0; 373 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 374 } 375 glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z); 376 glVertex3f(v4.x, v4.y, v4.z); 377 378 } 379 glEnd(); 380 glEndList(); 381 } 282 //Die Huegel ein wenig glaetten 283 for (int h=1; h<2;h++) 284 for (int i=1;i<sizeX-2 ;i+=1 ) 285 for(int j=1;j<sizeZ-2;j+=1) 286 height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4; 287 288 //Berechnung von normalen Vektoren 289 for(int i=1;i<sizeX-2;i+=1) 290 for(int j=1;j<sizeZ-2 ;j+=1) 291 { 292 Vector v1 = Vector (widthX*(1), height[i][j], widthZ*(j) ); 293 Vector v2 = Vector (widthX*(i-1), height[i-1][j], widthZ*(j)); 294 Vector v3 = Vector (widthX*(i), height[i][j+1], widthZ*(j+1)); 295 Vector v4 = Vector (widthX*(i+1), height[i+1][j], widthZ*(j)); 296 Vector v5 = Vector (widthX*(i), height[i][j-1], widthZ*(j-1)); 297 298 Vector c1 = v2 - v1; 299 Vector c2 = v3 - v1; 300 Vector c3= v4 - v1; 301 Vector c4 = v5 - v1; 302 Vector zero = Vector (0,0,0); 303 normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4); 304 normal_vectors[i][j].normalize(); 305 } 306 307 glBegin(GL_QUADS); 308 int snowheight=3; 309 for ( int i = 0; i<sizeX; i+=1) 310 for (int j = 0; j<sizeZ;j+=1) 311 { 312 Vector v1 = Vector (widthX*(i), height[i][j]-20, widthZ*(j) -width/2); 313 Vector v2 = Vector (widthX*(i+1), height[i+1][j]-20, widthZ*(j) -width/2); 314 Vector v3 = Vector (widthX*(i+1), height[i+1][j+1]-20, widthZ*(j+1)-width/2); 315 Vector v4 = Vector (widthX*(i), height[i][j+1]-20, widthZ*(j+1)-width/2); 316 float a[3]; 317 if(height[i][j]<snowheight) 318 { 319 a[0]=0; 320 a[1]=1.0-height[i][j]/10-.3; 321 a[2]=0; 322 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 323 } 324 else 325 { 326 a[0]=1.0; 327 a[1]=1.0; 328 a[2]=1.0; 329 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 330 331 } 332 glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z); 333 glVertex3f(v1.x, v1.y, v1.z); 334 if(height[i+1][j]<snowheight) 335 { 336 a[0]=0; 337 a[1] =1.0-height[i+1][j]/10-.3; 338 a[2]=0; 339 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 340 } 341 else 342 { 343 a[0]=1.0; 344 a[1]=1.0; 345 a[2]=1.0; 346 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 347 348 } 349 glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z); 350 glVertex3f(v2.x, v2.y, v2.z); 351 if(height[i+1][j+1]<snowheight) 352 { 353 a[0]=0; 354 a[1] =1.0-height[i+1][j+1]/10-.3; 355 a[2]=0; 356 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 357 } 358 else 359 { 360 a[0]=1.0; 361 a[1]=1.0; 362 a[2]=1.0; 363 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 364 365 366 } 367 glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z); 368 glVertex3f(v3.x, v3.y, v3.z); 369 if(height[i][j+1]<snowheight) 370 { 371 a[0]=0; 372 a[1] =1.0-height[i+1][j+1]/10-.3; 373 a[2]=0; 374 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 375 } 376 else 377 { 378 a[0]=1.0; 379 a[1]=1.0; 380 a[2]=1.0; 381 glMaterialfv(GL_FRONT,GL_DIFFUSE,a); 382 } 383 glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z); 384 glVertex3f(v4.x, v4.y, v4.z); 385 386 } 387 glEnd(); 388 glEndList(); 389 } 382 390 383 391 if (debugTerrain == TERRAIN_BENSCH) 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 392 { 393 /* 394 this->model = (OBJModel*) new Model(); 395 this->model->setName("CUBE"); 396 this->model->addVertex (-0.5, -0.5, 0.5); 397 this->model->addVertex (0.5, -0.5, 0.5); 398 this->model->addVertex (-0.5, 0.5, 0.5); 399 this->model->addVertex (0.5, 0.5, 0.5); 400 this->model->addVertex (-0.5, 0.5, -0.5); 401 this->model->addVertex (0.5, 0.5, -0.5); 402 this->model->addVertex (-0.5, -0.5, -0.5); 403 this->model->addVertex (0.5, -0.5, -0.5); 404 405 this->model->addVertexTexture (0.0, 0.0); 406 this->model->addVertexTexture (1.0, 0.0); 407 this->model->addVertexTexture (0.0, 1.0); 408 this->model->addVertexTexture (1.0, 1.0); 409 this->model->addVertexTexture (0.0, 2.0); 410 this->model->addVertexTexture (1.0, 2.0); 411 this->model->addVertexTexture (0.0, 3.0); 412 this->model->addVertexTexture (1.0, 3.0); 413 this->model->addVertexTexture (0.0, 4.0); 414 this->model->addVertexTexture (1.0, 4.0); 415 this->model->addVertexTexture (2.0, 0.0); 416 this->model->addVertexTexture (2.0, 1.0); 417 this->model->addVertexTexture (-1.0, 0.0); 418 this->model->addVertexTexture (-1.0, 1.0); 419 420 this->model->finalize(); 421 */ 422 } 415 423 } 416 424 … … 450 458 451 459 void Terrain::writeDebug( ) const 452 { 453 } 460 {} 454 461 455 462 void Terrain::readDebug( ) const 456 { 457 } 463 {} 458 464 459 465 float Terrain::getHeight(float x, float y) 460 466 { 461 462 463 464 } 467 if(this->heightMap != NULL) 468 return (this->heightMap->getHeight(x, y)); 469 return 0; 470 } -
branches/std/src/world_entities/terrain.h
r7207 r7216 43 43 void loadVegetation(const std::string& vegetationFile); 44 44 45 void loadHeightMap(const char* heightMapFile, const char* colorMap = NULL);46 void loadTexture(const char*textureName);45 void loadHeightMap(const std::string& heightMapFile, const std::string& colorMap); 46 void loadTexture(const std::string& textureName); 47 47 void setScale(float x, float y, float z); 48 48 -
branches/std/src/world_entities/weapons/aim.cc
r7193 r7216 147 147 * @param textureFile The texture-file to load onto the crosshair 148 148 */ 149 void Aim::setTexture(const char*textureFile)149 void Aim::setTexture(const std::string& textureFile) 150 150 { 151 151 this->material->setDiffuseMap(textureFile); -
branches/std/src/world_entities/weapons/aim.h
r6724 r7216 46 46 47 47 void setSize(float size); 48 void setTexture(const char*textureFile);48 void setTexture(const std::string& textureFile); 49 49 /** @param rotationSpeed the speed at what the crosshair should rotate */ 50 50 inline void setRotationSpeed(float rotationSpeed) { this->rotationSpeed = rotationSpeed; }; -
branches/std/src/world_entities/weapons/crosshair.cc
r7193 r7216 79 79 EventListener::loadParams(root); 80 80 81 LoadParam(root, "texture", this , Crosshair, setTexture)81 LoadParam(root, "texture", this->material, Material, setDiffuseMap) 82 82 .describe("the texture-file to load onto the Crosshair"); 83 83 … … 103 103 * @param textureFile The texture-file to load onto the crosshair 104 104 */ 105 void Crosshair::setTexture(const char*textureFile)105 void Crosshair::setTexture(const std::string& textureFile) 106 106 { 107 107 this->material->setDiffuseMap(textureFile); -
branches/std/src/world_entities/weapons/crosshair.h
r6512 r7216 31 31 32 32 void setSize(float size); 33 void setTexture(const char*textureFile);33 void setTexture(const std::string& textureFile); 34 34 /** @param rotationSpeed the speed at what the crosshair should rotate */ 35 35 void setRotationSpeed(float rotationSpeed) { this->rotationSpeed = rotationSpeed; }; -
branches/std/src/world_entities/weapons/weapon.cc
r7207 r7216 165 165 * @param projectile the Name of the Projectile. 166 166 */ 167 void Weapon::setProjectileTypeC(const char* projectile) 168 { 169 if (projectile == NULL) 170 return; 167 void Weapon::setProjectileTypeC(const std::string& projectile) 168 { 171 169 FastFactory* tmpFac = FastFactory::searchFastFactory(projectile); 172 170 if (tmpFac != NULL) … … 176 174 else 177 175 { 178 PRINTF(1)("Projectile %s does not exist for weapon %s\n", projectile , this->getName());176 PRINTF(1)("Projectile %s does not exist for weapon %s\n", projectile.c_str(), this->getName()); 179 177 } 180 178 } … … 613 611 * @return The Action if known, WA_NONE otherwise. 614 612 */ 615 WeaponAction Weapon::charToAction(const char*action)616 { 617 if ( !strcmp(action, "none"))613 WeaponAction Weapon::charToAction(const std::string& action) 614 { 615 if (action == "none") 618 616 return WA_NONE; 619 else if ( !strcmp(action, "shoot"))617 else if (action == "shoot") 620 618 return WA_SHOOT; 621 else if ( !strcmp(action, "charge"))619 else if (action == "charge") 622 620 return WA_CHARGE; 623 else if ( !strcmp(action, "reload"))621 else if (action == "reload") 624 622 return WA_RELOAD; 625 else if ( !strcmp(action, "acitvate"))623 else if (action == "acitvate") 626 624 return WA_ACTIVATE; 627 else if ( !strcmp(action, "deactivate"))625 else if (action == "deactivate") 628 626 return WA_DEACTIVATE; 629 else if ( !strcmp(action, "special1"))627 else if (action == "special1") 630 628 return WA_SPECIAL1; 631 629 else 632 630 { 633 PRINTF(2)("action %s could not be identified.\n", action );631 PRINTF(2)("action %s could not be identified.\n", action.c_str()); 634 632 return WA_NONE; 635 633 } … … 674 672 * @return The State if known, WS_NONE otherwise. 675 673 */ 676 WeaponState Weapon::charToState(const char*state)677 { 678 if ( !strcmp(state, "none"))674 WeaponState Weapon::charToState(const std::string& state) 675 { 676 if (state == "none") 679 677 return WS_NONE; 680 else if ( !strcmp(state, "shooting"))678 else if (state == "shooting") 681 679 return WS_SHOOTING; 682 else if ( !strcmp(state, "charging"))680 else if (state == "charging") 683 681 return WS_CHARGING; 684 else if ( !strcmp(state, "reloading"))682 else if (state == "reloading") 685 683 return WS_RELOADING; 686 else if ( !strcmp(state, "activating"))684 else if (state == "activating") 687 685 return WS_ACTIVATING; 688 else if ( !strcmp(state, "deactivating"))686 else if (state == "deactivating") 689 687 return WS_DEACTIVATING; 690 else if ( !strcmp(state, "inactive"))688 else if (state == "inactive") 691 689 return WS_INACTIVE; 692 else if ( !strcmp(state, "idle"))690 else if (state == "idle") 693 691 return WS_IDLE; 694 692 else 695 693 { 696 PRINTF(2)("state %s could not be identified.\n", state );694 PRINTF(2)("state %s could not be identified.\n", state.c_str()); 697 695 return WS_NONE; 698 696 } -
branches/std/src/world_entities/weapons/weapon.h
r7207 r7216 111 111 inline long getCapability() const { return this->capability; }; 112 112 void setProjectileType(ClassID projectile); 113 void setProjectileTypeC(const char*projectile);113 void setProjectileTypeC(const std::string& projectile); 114 114 /** @returns The projectile's classID */ 115 115 inline ClassID getProjectileType() { return this->projectile; }; … … 132 132 // STATE CHANGES // 133 133 /** @param state the State to time @param duration the duration of the State */ 134 inline void setStateDuration(const char*state, float duration) { setStateDuration(charToState(state), duration); };134 inline void setStateDuration(const std::string& state, float duration) { setStateDuration(charToState(state), duration); }; 135 135 /** @param state the State to time @param duration the duration of the State */ 136 136 inline void setStateDuration(WeaponState state, float duration) { /*(state < WS_STATE_COUNT)?*/this->times[state] = duration; }; … … 149 149 150 150 void setActionSound(WeaponAction action, const std::string& soundFile); 151 /** @see void setActionSound(WeaponAction action, const char*soundFile); */152 void setActionSound(const char* action, const char*soundFile) { this->setActionSound(charToAction(action), soundFile); };151 /** @see void setActionSound(WeaponAction action, const std::string& soundFile); */ 152 void setActionSound(const std::string& action, const std::string& soundFile) { this->setActionSound(charToAction(action), soundFile); }; 153 153 154 154 Animation3D* getAnimation(WeaponState state, PNode* node = NULL); … … 176 176 177 177 // utility: 178 static WeaponAction charToAction(const char*action);178 static WeaponAction charToAction(const std::string& action); 179 179 static const char* actionToChar(WeaponAction action); 180 static WeaponState charToState(const char*state);180 static WeaponState charToState(const std::string& state); 181 181 static const char* stateToChar(WeaponState state); 182 182 -
branches/std/src/world_entities/world_entity.cc
r7203 r7216 61 61 this->bCollide = true; 62 62 63 this->md2TextureFileName = NULL;64 65 63 this->objectListNumber = OM_INIT; 66 64 this->objectListIterator = NULL; … … 123 121 * @todo fix this, so it only has one loadModel-Function. 124 122 */ 125 void WorldEntity::loadModel(const char*fileName, float scaling, unsigned int modelNumber)123 void WorldEntity::loadModel(const std::string& fileName, float scaling, unsigned int modelNumber) 126 124 { 127 125 this->modelLODName = fileName; 128 126 this->scaling = scaling; 129 if ( fileName != NULL && strcmp(fileName, ""))127 if (!fileName.empty()) 130 128 { 131 129 // search for the special character # in the LoadParam 132 if (strchr(fileName, '#') != NULL) 133 { 134 PRINTF(4)("Found # in %s... searching for LOD's\n", fileName); 135 char* lodFile = new char[strlen(fileName)+1]; 136 strcpy(lodFile, fileName); 137 char* depth = strchr(lodFile, '#'); 130 if (fileName.find('#') != std::string::npos) 131 { 132 PRINTF(4)("Found # in %s... searching for LOD's\n", fileName.c_str()); 133 std::string lodFile = fileName; 134 unsigned int offset = lodFile.find('#'); 138 135 for (unsigned int i = 0; i < 3; i++) 139 136 { 140 *depth= 48+(int)i;137 lodFile[offset] = 48+(int)i; 141 138 if (ResourceManager::isInDataDir(lodFile)) 142 139 this->loadModel(lodFile, scaling, i); … … 149 146 this->scaling = 1.0; 150 147 } 151 if( strstr(fileName, ".obj"))152 { 153 PRINTF(4)("fetching OBJ file: %s\n", fileName );148 if(fileName.find(".obj") != std::string::npos) 149 { 150 PRINTF(4)("fetching OBJ file: %s\n", fileName.c_str()); 154 151 BaseObject* loadedModel = ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, this->scaling); 155 152 if (loadedModel != NULL) … … 159 156 this->buildObbTree(4); 160 157 } 161 else if( strstr(fileName, ".md2"))162 { 163 PRINTF(4)("fetching MD2 file: %s\n", fileName );158 else if(fileName.find(".md2") != std::string::npos) 159 { 160 PRINTF(4)("fetching MD2 file: %s\n", fileName.c_str()); 164 161 Model* m = new MD2Model(fileName, this->md2TextureFileName, this->scaling); 165 162 //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0); -
branches/std/src/world_entities/world_entity.h
r7095 r7216 36 36 virtual void loadParams(const TiXmlElement* root); 37 37 38 void loadModel(const char*fileName, float scaling = 1.0f, unsigned int modelNumber = 0);38 void loadModel(const std::string& fileName, float scaling = 1.0f, unsigned int modelNumber = 0); 39 39 void setModel(Model* model, unsigned int modelNumber = 0); 40 40 Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; }; 41 41 42 inline void loadMD2Texture(const char*fileName) { this->md2TextureFileName = fileName; }42 inline void loadMD2Texture(const std::string& fileName) { this->md2TextureFileName = fileName; } 43 43 44 44 bool buildObbTree(unsigned int depth); … … 113 113 114 114 std::vector<Model*> models; //!< The model that should be loaded for this entity. 115 const char*md2TextureFileName; //!< the file name of the md2 model texture, only if this116 const char*modelLODName; //!< the name of the model lod file115 std::string md2TextureFileName; //!< the file name of the md2 model texture, only if this 116 std::string modelLODName; //!< the name of the model lod file 117 117 BVTree* obbTree; //!< this is the obb tree reference needed for collision detection 118 118
Note: See TracChangeset
for help on using the changeset viewer.