Ignore:
Timestamp:
03/02/07 19:07:56 (17 years ago)
Author:
szirmay
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/SceneSerializer.cpp

    r2163 r2186  
    11#include "SceneSerializer.h" 
     2#include "OgreIlluminationManager.h" 
    23 
    34void logParseError(const String& error, const SceneScriptContext& context) 
     
    2728        StringUtil::trim(params); 
    2829        String meshfilename = context.meshFiles[params]; 
     30        context.meshName = params; 
    2931        context.entity = context.sceneManager->createEntity(context.entityName, meshfilename); 
    3032        SceneNode* root = context.sceneManager->getRootSceneNode(); 
     
    3234        context.sceneNode->attachObject(context.entity); 
    3335 
     36    return false; 
     37} 
     38 
     39bool 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         
    3456    return false; 
    3557} 
     
    7698} 
    7799 
     100bool parsePMRes(String& params, SceneScriptContext& context) 
     101{ 
     102        context.pathMapResolutions[context.meshName] = StringConverter::parseUnsignedInt(params); 
     103        return false; 
     104} 
     105 
     106bool parsePRMMapName(String& params, SceneScriptContext& context) 
     107{ 
     108        context.pathMapTextureName = params; 
     109        return false; 
     110} 
     111 
    78112SceneSerializer::SceneSerializer(SceneManager* sm) 
    79113{ 
     
    85119         
    86120        mMeshAttribParsers.insert(AttribParserList::value_type("ogrefile", (SCENE_ATTRIBUTE_PARSER)parseMeshFileName)); 
     121        mMeshAttribParsers.insert(AttribParserList::value_type("pathmapresolution", (SCENE_ATTRIBUTE_PARSER)parsePMRes)); 
    87122 
    88123        mEntityAttribParsers.insert(AttribParserList::value_type("mesh", (SCENE_ATTRIBUTE_PARSER)parseMeshName)); 
    89124        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 
     130void 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        } 
    91172} 
    92173 
Note: See TracChangeset for help on using the changeset viewer.