Ignore:
Timestamp:
04/27/06 09:24:44 (18 years ago)
Author:
szirmay
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDistanceCubeMapRenderTechnique.cpp

    r790 r836  
    6868 
    6969 
     70///Technique Parsers 
     71namespace CausticCubemapParsers 
     72{ 
     73        void parseStartFrame(String& params, RenderTechniqueFactory* factory) 
     74        { 
     75                OgreDistanceCubeMapRenderTechniqueFactory* f = (OgreDistanceCubeMapRenderTechniqueFactory*) factory; 
     76                f->startFrame =  StringConverter::parseUnsignedLong(params); 
     77        } 
     78        void parseCubeMapUpdateInterval(String& params, RenderTechniqueFactory* factory) 
     79        { 
     80                OgreDistanceCubeMapRenderTechniqueFactory* f = (OgreDistanceCubeMapRenderTechniqueFactory*) factory; 
     81                f->cubeMapUpdateInterval =  StringConverter::parseUnsignedLong(params); 
     82        } 
     83 
     84        void parseCubeMapResolution(String& params, RenderTechniqueFactory* factory) 
     85        { 
     86                OgreDistanceCubeMapRenderTechniqueFactory* f = (OgreDistanceCubeMapRenderTechniqueFactory*) factory; 
     87                f->cubeMapResolution =  StringConverter::parseUnsignedInt(params); 
     88        } 
     89 
     90        void parseTexID(String& params, RenderTechniqueFactory* factory) 
     91        { 
     92                OgreDistanceCubeMapRenderTechniqueFactory* f = (OgreDistanceCubeMapRenderTechniqueFactory*) factory; 
     93                f->texID =  StringConverter::parseUnsignedInt(params); 
     94        } 
     95 
     96        void parseUseDistCalc(String& params, RenderTechniqueFactory* factory) 
     97        { 
     98                OgreDistanceCubeMapRenderTechniqueFactory* f = (OgreDistanceCubeMapRenderTechniqueFactory*) factory; 
     99                // format: on/off tolerance(float) 
     100                StringVector vecparams = StringUtil::split(params, " \t"); 
     101 
     102                if(StringConverter::parseBool(vecparams[0]))//on 
     103                { 
     104                        f->useDistCalc = true; 
     105 
     106                        if(vecparams.size()>1) 
     107                        {                        
     108                                f->distTolerance = StringConverter::parseReal(vecparams[1]); 
     109                        } 
     110                } 
     111                else 
     112                { 
     113                        f->useDistCalc = false; 
     114                } 
     115        } 
     116 
     117        void parseUseFaceAngleCalc(String& params, RenderTechniqueFactory* factory) 
     118        { 
     119                OgreDistanceCubeMapRenderTechniqueFactory* f = (OgreDistanceCubeMapRenderTechniqueFactory*) factory; 
     120                // format: on/off tolerance(float) 
     121                StringVector vecparams = StringUtil::split(params, " \t"); 
     122 
     123                if(StringConverter::parseBool(vecparams[0]))//on 
     124                { 
     125                        f->useFaceAngleCalc = true; 
     126 
     127                        if(vecparams.size()>1) 
     128                        {                        
     129                                f->angleTolerance = StringConverter::parseReal(vecparams[1]); 
     130                        } 
     131                } 
     132                else 
     133                { 
     134                        f->useFaceAngleCalc = false; 
     135                } 
     136        } 
     137 
     138        void parseUpdateAllFace(String& params, RenderTechniqueFactory* factory) 
     139        { 
     140                OgreDistanceCubeMapRenderTechniqueFactory* f = (OgreDistanceCubeMapRenderTechniqueFactory*) factory; 
     141                f->updateAllFace =  StringConverter::parseBool(params); 
     142        } 
     143} 
     144///Technique factory 
     145OgreDistanceCubeMapRenderTechniqueFactory::OgreDistanceCubeMapRenderTechniqueFactory() 
     146{ 
     147        typeName = "DistanceCubeMap"; 
     148 
     149        using namespace CausticCubemapParsers; 
     150        //register parsers 
     151        this->attributeParsers.insert(AttribParserList::value_type("start_frame", (ILLUM_ATTRIBUTE_PARSER) parseStartFrame)); 
     152        this->attributeParsers.insert(AttribParserList::value_type("update_interval", (ILLUM_ATTRIBUTE_PARSER) parseCubeMapUpdateInterval)); 
     153        this->attributeParsers.insert(AttribParserList::value_type("resolution", (ILLUM_ATTRIBUTE_PARSER) parseCubeMapResolution)); 
     154        this->attributeParsers.insert(AttribParserList::value_type("texture_unit_id", (ILLUM_ATTRIBUTE_PARSER) parseTexID)); 
     155        this->attributeParsers.insert(AttribParserList::value_type("distance_calc", (ILLUM_ATTRIBUTE_PARSER) parseUseDistCalc)); 
     156        this->attributeParsers.insert(AttribParserList::value_type("face_angle_calc", (ILLUM_ATTRIBUTE_PARSER) parseUseFaceAngleCalc)); 
     157        this->attributeParsers.insert(AttribParserList::value_type("update_all_face", (ILLUM_ATTRIBUTE_PARSER) parseUpdateAllFace)); 
     158 
     159} 
     160 
     161OgreRenderTechnique* OgreDistanceCubeMapRenderTechniqueFactory::createInstance(  
     162                                                                                IllumTechniqueParams* params, 
     163                                                                                Pass* pass, 
     164                                                                                OgreRenderable* parentRenderable, 
     165                                                                                OgreTechniqueGroup* parentTechniqueGroup) 
     166{        
     167        //reset parameters 
     168        startFrame = 0; 
     169        cubeMapUpdateInterval = 1; 
     170        cubeMapResolution = 256;                                                                                                 
     171        texID = 1; 
     172        useDistCalc = 1; 
     173        useFaceAngleCalc = false; 
     174        distTolerance = 2.0; 
     175        angleTolerance = 2.0; 
     176        updateAllFace = false; 
     177 
     178        parseParams(params); 
     179 
     180        OgreDistanceCubeMapRenderTechnique* result = new OgreDistanceCubeMapRenderTechnique( 
     181                                                                                                startFrame, 
     182                                                                                                cubeMapUpdateInterval, 
     183                                                                                                cubeMapResolution, 
     184                                                                                                texID, 
     185                                                                                                useDistCalc, 
     186                                                                                                useFaceAngleCalc, 
     187                                                                                                distTolerance, 
     188                                                                                                angleTolerance, 
     189                                                                                                updateAllFace, 
     190                                                                                                pass, 
     191                                                                                                parentRenderable, 
     192                                                                                                parentTechniqueGroup); 
     193 
     194        return result; 
     195} 
     196 
Note: See TracChangeset for help on using the changeset viewer.