Changeset 2186 for GTP/trunk/App/Demos/Illum/Ogre/src/Common
- Timestamp:
- 03/02/07 19:07:56 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/src/Common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/src/Common/include/SceneSerializer.h
r1079 r2186 19 19 String meshName; 20 20 Entity* entity; 21 String pathMapTextureName; 21 22 SceneNode* sceneNode; 22 23 std::map<String, String> meshFiles; 24 std::map<String, unsigned int> pathMapResolutions; 23 25 }; 24 26 … … 50 52 SceneSerializer(SceneManager* sm); 51 53 void parseScript(DataStreamPtr& stream, const String& groupName); 54 void parseEntryPoints(String filename); 52 55 53 56 }; -
GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/SceneSerializer.cpp
r2163 r2186 1 1 #include "SceneSerializer.h" 2 #include "OgreIlluminationManager.h" 2 3 3 4 void logParseError(const String& error, const SceneScriptContext& context) … … 27 28 StringUtil::trim(params); 28 29 String meshfilename = context.meshFiles[params]; 30 context.meshName = params; 29 31 context.entity = context.sceneManager->createEntity(context.entityName, meshfilename); 30 32 SceneNode* root = context.sceneManager->getRootSceneNode(); … … 32 34 context.sceneNode->attachObject(context.entity); 33 35 36 return false; 37 } 38 39 bool parseClusters(String& params, SceneScriptContext& context) 40 { 41 if(params == "") 42 logParseError("No clusters given!", context); 43 44 //create the Entity with the given mesh, attach to a scene node 45 std::vector<String> parameters = StringUtil::split(params); 46 String subentityname = context.entityName + "_SE_" + parameters[0]; 47 PathMapClusters clasters; 48 clasters.count = parameters.size() - 2; 49 clasters.clusters = new unsigned int[clasters.count]; 50 for(int i = 2; i < parameters.size(); i++) 51 clasters.clusters[i-2] = StringConverter::parseUnsignedInt(parameters.at(i)); 52 clasters.pathMapTextureFilename = context.pathMapTextureName + "_" + parameters[0]+ ".hdr"; 53 clasters.pathMapResolution = context.pathMapResolutions[context.meshName]; 54 OgreIlluminationManager::getSingleton().addPathMapClusters(subentityname, clasters); 55 34 56 return false; 35 57 } … … 76 98 } 77 99 100 bool parsePMRes(String& params, SceneScriptContext& context) 101 { 102 context.pathMapResolutions[context.meshName] = StringConverter::parseUnsignedInt(params); 103 return false; 104 } 105 106 bool parsePRMMapName(String& params, SceneScriptContext& context) 107 { 108 context.pathMapTextureName = params; 109 return false; 110 } 111 78 112 SceneSerializer::SceneSerializer(SceneManager* sm) 79 113 { … … 85 119 86 120 mMeshAttribParsers.insert(AttribParserList::value_type("ogrefile", (SCENE_ATTRIBUTE_PARSER)parseMeshFileName)); 121 mMeshAttribParsers.insert(AttribParserList::value_type("pathmapresolution", (SCENE_ATTRIBUTE_PARSER)parsePMRes)); 87 122 88 123 mEntityAttribParsers.insert(AttribParserList::value_type("mesh", (SCENE_ATTRIBUTE_PARSER)parseMeshName)); 89 124 mEntityAttribParsers.insert(AttribParserList::value_type("transformation", (SCENE_ATTRIBUTE_PARSER)parseTransform)); 90 125 mEntityAttribParsers.insert(AttribParserList::value_type("subentity", (SCENE_ATTRIBUTE_PARSER)parseClusters)); 126 mEntityAttribParsers.insert(AttribParserList::value_type("pathmapfile", (SCENE_ATTRIBUTE_PARSER)parsePRMMapName)); 127 128 } 129 130 void SceneSerializer::parseEntryPoints(String filename) 131 { 132 DataStreamPtr stream; 133 stream = ResourceGroupManager::getSingleton().openResource(filename); 134 135 char buffer[500]; 136 137 stream->readLine(buffer, 500); 138 String line = buffer; 139 140 std::vector<String> tokens = StringUtil::split(line); 141 unsigned int entryPointCnt = StringConverter::parseUnsignedInt(tokens[1]); 142 for(int i= 0; i < entryPointCnt; i++) 143 { 144 stream->readLine(buffer, 500); 145 line = buffer; 146 tokens = StringUtil::split(line); 147 PathMapEntryPoint ep; 148 ep.position = Vector3(StringConverter::parseReal(tokens[1]), 149 StringConverter::parseReal(tokens[2]), 150 StringConverter::parseReal(tokens[3])); 151 152 stream->readLine(buffer, 500); 153 line = buffer; 154 tokens = StringUtil::split(line); 155 ep.normal = Vector3(StringConverter::parseReal(tokens[1]), 156 StringConverter::parseReal(tokens[2]), 157 StringConverter::parseReal(tokens[3])); 158 159 OgreIlluminationManager::getSingleton().addPathMapEntryPoint(ep); 160 stream->readLine(buffer, 500); 161 } 162 stream->readLine(buffer, 500); 163 line = buffer; 164 tokens = StringUtil::split(line); 165 unsigned int clusterCnt = StringConverter::parseUnsignedInt(tokens[1]); 166 for(int i= 0; i < clusterCnt; i++) 167 { 168 stream->readLine(buffer, 500); 169 unsigned int clusterlength = StringConverter::parseUnsignedInt(buffer); 170 OgreIlluminationManager::getSingleton().addPathMapClusterLength(clusterlength); 171 } 91 172 } 92 173
Note: See TracChangeset
for help on using the changeset viewer.