Ignore:
Timestamp:
07/02/07 04:12:36 (17 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderable.h

    r2240 r2475  
    134134        */ 
    135135        Renderable* getRenderable(); 
     136 
     137        SceneNode* getParentSceneNode(); 
    136138         
    137139protected: 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreSharedRuns.h

    r2320 r2475  
    218218        void freeAllResources(); 
    219219 
     220        OgreRenderable* getRootRenderable() 
     221        { 
     222                if(!child1)//this is a root 
     223                { 
     224                        std::map<OgreRenderable*, bool>::iterator it = renderables.begin(); 
     225                        OgreRenderable* rend = (*it).first; 
     226                        return rend;  
     227                } 
     228                else 
     229                        return ((OgreSharedRuns*)getRoot())->getRootRenderable(); 
     230        } 
     231 
    220232protected: 
    221233        /** 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCausticReceiverRenderTechnique.h

    r2397 r2475  
    5454                                                        String casterCenterVariableName, 
    5555                                                        String attenuationVariableName, 
     56                                                        bool bindDistanceMap, 
    5657                                                        Pass* pass, 
    5758                                                        OgreRenderable* parentRenderable, 
     
    101102        String casterCenterVariableName; 
    102103        String attenuationVariableName; 
     104        bool bindDistanceMap; 
     105        bool bindAttenuation; 
    103106}; 
    104107 
     
    128131        String casterCenterVariableName; 
    129132        String attenuationVariableName; 
     133        bool bindDistanceMap; 
    130134}; 
    131135 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.h

    r2397 r2475  
    7070                                                        int startTextureUnitID, 
    7171                                                        bool nearestLightsFromCamera, 
     72                                                        bool bindToVertexShader, 
    7273                                                        Pass* pass, 
    7374                                                        OgreRenderable* parentRenderable, 
     
    146147        int startTextureUnitID; 
    147148        bool nearestLightsFromCamera; 
     149        bool bindToVertexShader; 
    148150}; 
    149151 
     
    180182        int startTextureUnitID; 
    181183        bool nearestLightsFromCamera; 
     184        bool bindToVertexShader; 
    182185}; 
    183186 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderable.cpp

    r1425 r2475  
    131131        { 
    132132         case OGRE_RENDERABLETYPE_SUBENTITY: 
     133         { 
    133134                 parentEntity->getParentSceneNode()->_updateBounds(); 
    134135                 boundingBox = parentEntity->getWorldBoundingBox(true); 
    135                  boundingSphere = parentEntity->getWorldBoundingSphere(true);    
    136                  break; 
    137          case OGRE_RENDERABLETYPE_BILLBOARDSET: 
     136                  
     137                 Vector3 center = (boundingBox.getMaximum() + boundingBox.getMaximum()) / 2.0; 
     138                 float radius = (center - boundingBox.getMaximum()).length(); 
     139                 boundingSphere.setRadius(radius); 
     140                 boundingSphere.setCenter(center); 
     141                 //boundingSphere = parentEntity->getWorldBoundingSphere(true);  
     142                 break; 
     143         } 
     144         case OGRE_RENDERABLETYPE_BILLBOARDSET: 
     145         { 
    138146                /* billboardSetRenderable->getParentSceneNode()->_updateBounds(); 
    139147                 boundingBox = billboardSetRenderable->getWorldBoundingBox(true); 
     
    144152                 boundingSphere.setCenter( (boundingBox.getMaximum() + boundingBox.getMinimum()) / 2.0); 
    145153                 break; 
     154         } 
    146155        default: 
    147156                 OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,  
     
    152161} 
    153162 
     163SceneNode* OgreRenderable::getParentSceneNode() 
     164{ 
     165        switch(renderableType) 
     166        { 
     167         case OGRE_RENDERABLETYPE_SUBENTITY: 
     168         { 
     169                 return parentEntity->getParentSceneNode();               
     170         } 
     171         case OGRE_RENDERABLETYPE_BILLBOARDSET: 
     172         { 
     173                 return parentParticleSystem->getParentSceneNode(); 
     174         } 
     175         default: 
     176                 OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,  
     177                "Unknown renderable type! Check RenderTechnique initializations!",  
     178                "OgreRenderable::getParentSceneNode"); 
     179        } 
     180        return 0; 
     181} 
     182 
    154183Renderable* OgreRenderable::getRenderable() 
    155184{ 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticReceiverRenderTechnique.cpp

    r2366 r2475  
    1515                                                                                                String casterCenterVariableName, 
    1616                                                                                                String attenuationVariableName, 
     17                                                                                                bool bindDistanceMap, 
    1718                                                                                                Pass* pass, 
    1819                                                                                                OgreRenderable* parentRenderable, 
     
    3132        this->casterCenterVariableName = casterCenterVariableName; 
    3233        this->attenuationVariableName = attenuationVariableName; 
     34        this->bindDistanceMap = bindDistanceMap; 
     35        bindAttenuation = false; 
     36        if(attenuationVariableName != "") 
     37                bindAttenuation = true; 
    3338         
    3439        if(createNewPasses) 
     
    6671 
    6772                        TextureUnitState* st = newpass->createTextureUnitState(); 
    68                         TextureUnitState* st2 = newpass->createTextureUnitState(); 
    69  
    7073                        st->setTextureFiltering(TFO_BILINEAR); 
    71                         st2->setTextureFiltering(TFO_BILINEAR); 
     74                        if(bindDistanceMap) 
     75                        { 
     76                                TextureUnitState* st2 = newpass->createTextureUnitState(); 
     77                                st2->setTextureFiltering(TFO_BILINEAR); 
     78                        } 
    7279 
    7380                        newpass->setSceneBlending(passBlendingSRC, passBlendingDEST); 
     
    109116                         
    110117                        Pass* passToSet = this->pass; 
    111                         int textureUnit = startTextureUnitID + i; 
     118                        int p = bindDistanceMap?i*2:i; 
     119                        int textureUnit = startTextureUnitID + p; 
    112120                        if(createNewPasses) 
    113121                        { 
     
    119127                        passToSet->getTextureUnitState(textureUnit)->setTextureName( 
    120128                                cauCubeRun->getCausticCubeMapTextureName()); 
     129                        if(bindDistanceMap) 
     130                        { 
     131                                OgreCubeMapRenderingRun* distCubeRun =  
     132                                (OgreCubeMapRenderingRun*) causticCasters.at(i)-> 
     133                                        getRun(ILLUMRUN_DISTANCE_CUBEMAP)->asOgreRenderingRun(); 
     134                                if(distCubeRun) 
     135                                passToSet->getTextureUnitState(textureUnit + 1)->setTextureName( 
     136                                        distCubeRun->getCubeMapTextureName()); 
     137                        } 
    121138         
    122139                        //set caster position nad caustic attenuation 
     
    126143                        if(!createNewPasses) 
    127144                        { 
    128                                 centerVarName += String("[") + StringConverter::toString(i) + String("]"); 
    129                                 attenuationVarName += String("[") + StringConverter::toString(i) + String("]"); 
     145                                centerVarName += StringConverter::toString(i+1); 
     146                                attenuationVarName += StringConverter::toString(i+1); 
    130147                        } 
    131148                        Fparams->setNamedConstant(centerVarName, 
    132149                                                                                causticCasters.at(i)->getRootPosition(ILLUMRUN_CAUSTIC_CUBEMAP)); 
     150                        if(bindAttenuation) 
    133151                        Fparams->setNamedConstant(attenuationVarName, 
    134152                                                                                cauCubeRun->getAttenuation());                   
     
    247265                f->attenuationVariableName =  params; 
    248266        } 
     267 
     268        void parseBindDistanceMap(String& params, RenderTechniqueFactory* factory) 
     269        { 
     270                OgreCausticReceiverRenderTechniqueFactory* f = (OgreCausticReceiverRenderTechniqueFactory*) factory; 
     271                f->bindDistanceMap =  StringConverter::parseBool(params); 
     272        } 
    249273} 
    250274 
     
    263287        this->attributeParsers.insert(AttribParserList::value_type("center_var_name", (ILLUM_ATTRIBUTE_PARSER) parseCenterVarName)); 
    264288        this->attributeParsers.insert(AttribParserList::value_type("attenuation_var_name", (ILLUM_ATTRIBUTE_PARSER) parseAttenuationVarName));   
     289        this->attributeParsers.insert(AttribParserList::value_type("bind_distance_map", (ILLUM_ATTRIBUTE_PARSER) parseBindDistanceMap));         
    265290} 
    266291 
     
    280305        startTextureUnitID = 0; 
    281306        casterCenterVariableName = "cubeMapCameraPosition"; 
    282         String attenuationVariableName = "attenuation"; 
     307        attenuationVariableName = ""; 
     308        bindDistanceMap = false; 
    283309 
    284310        parseParams(params); 
     
    294320                                                                                                casterCenterVariableName, 
    295321                                                                                                attenuationVariableName, 
     322                                                                                                bindDistanceMap, 
    296323                                                                                                pass, 
    297324                                                                                                parentRenderable, 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp

    r2460 r2475  
    2121                                                                                                int startTextureUnitID, 
    2222                                                                                                bool nearestLightsFromCamera, 
     23                                                                                                bool bindToVertexShader, 
    2324                                                                                                Pass* pass, 
    2425                                                                                                OgreRenderable* parentRenderable, 
     
    2829                                                        DepthShadowReceiverRenderTechnique(parentRenderable, parentTechniqueGroup) 
    2930{ 
     31        this->bindToVertexShader = bindToVertexShader; 
    3032        this->passBlendingSRC = passBlendingSRC; 
    3133        this->passBlendingDEST = passBlendingDEST; 
     
    99101        Vector3 center = OgreIlluminationManager::getSingleton().getMainCamera()->getWorldPosition(); 
    100102        if(!nearestLightsFromCamera) 
    101                 center = ((OgreSharedRuns*) sharedRuns)->getRootPosition(); 
     103                center = ((OgreSharedRuns*) sharedRuns)->getRootRenderable()->getParentSceneNode()->_getDerivedPosition(); 
     104                //center = ((OgreSharedRuns*) sharedRuns)->getRootPosition(); 
    102105        Root::getSingleton()._getCurrentSceneManager()->_populateLightList( 
    103106                                                        center, 
     
    149152                                GpuProgramParametersSharedPtr fpParams = passToSet->getFragmentProgramParameters(); 
    150153                                GpuProgramParametersSharedPtr vpParams = passToSet->getVertexProgramParameters(); 
     154                                GpuProgramParametersSharedPtr variableSetParams = fpParams; 
     155                                if(bindToVertexShader) 
     156                                        variableSetParams = vpParams; 
    151157 
    152158                                String LightViewProjParamName = lightViewProjParamName; 
     
    165171                                        vpParams->setNamedConstant(LightViewProjParamName, depthRun->getLightViewProjMatrix()); 
    166172                                        else 
    167                                         fpParams->setNamedConstant(LightViewProjParamName, depthRun->getLightViewProjMatrix()); 
     173                                        variableSetParams->setNamedConstant(LightViewProjParamName, depthRun->getLightViewProjMatrix()); 
    168174                                } 
    169175                                if(setLightViewMatrix) 
     
    172178                                        vpParams->setNamedConstant(LightViewParamName, depthRun->getLightViewMatrix()); 
    173179                                        else 
    174                                         fpParams->setNamedConstant(LightViewParamName, depthRun->getLightViewMatrix()); 
     180                                        variableSetParams->setNamedConstant(LightViewParamName, depthRun->getLightViewMatrix()); 
    175181                                } 
    176182                                if(setLightProjFarPlane) 
     
    347353                f->nearestLightsFromCamera = StringConverter::parseBool(params); 
    348354        } 
     355        void parseBindToVertexShader(String& params, RenderTechniqueFactory* factory) 
     356        { 
     357                OgreDepthShadowReceiverRenderTechniqueFactory* f = (OgreDepthShadowReceiverRenderTechniqueFactory*) factory; 
     358                f->bindToVertexShader = StringConverter::parseBool(params); 
     359        } 
    349360} 
    350361 
     
    370381        this->attributeParsers.insert(AttribParserList::value_type("start_tex_id", (ILLUM_ATTRIBUTE_PARSER) parseStartTexID));   
    371382        this->attributeParsers.insert(AttribParserList::value_type("nearest_from_camera", (ILLUM_ATTRIBUTE_PARSER) parseNearestFromCamera));     
     383        this->attributeParsers.insert(AttribParserList::value_type("bind_to_vertex_shader", (ILLUM_ATTRIBUTE_PARSER) parseBindToVertexShader));  
    372384} 
    373385 
     
    394406        createNewPasses = true; 
    395407        startTextureUnitID = 0; 
    396         nearestLightsFromCamera = true; 
    397          
     408        nearestLightsFromCamera = false; 
     409        bindToVertexShader = false; 
     410 
    398411        parseParams(params); 
    399412 
     
    415428                                                                                                startTextureUnitID, 
    416429                                                                                                nearestLightsFromCamera, 
     430                                                                                                bindToVertexShader, 
    417431                                                                                                pass, 
    418432                                                                                                parentRenderable, 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp

    r2460 r2475  
    144144        LightList lights; 
    145145        SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 
    146         sm->_populateLightList(OgreIlluminationManager::getSingleton().getMainCamera()->getPosition(), 1000, lights); 
     146        sm->_populateLightList(OgreIlluminationManager::getSingleton().getMainCamera()->getWorldPosition(), 1000, lights); 
    147147 
    148148        int found = 0; 
    149         for(int i = 0 ; found < 5 && i < lights.size(); i++) 
     149        for(int i = 0 ; found < 2 && i < lights.size(); i++) 
    150150        { 
    151151                if(lights.at(i)->isAttached()) 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreLightVolumeRenderingRun.cpp

    r2427 r2475  
    137137                restoreMaterials(); 
    138138 
     139        //      rt->writeContentsToFile(name+"_lightVolume.bmp"); 
    139140                //do blending 
    140141            rt = lightVolumeTexture2->getBuffer().getPointer()->getRenderTarget(); 
     
    143144                renderFullscreenQuad("GameTools/BlurLightVolume", rt);           
    144145 
    145  
     146        //      rt->writeContentsToFile(name+"_blurredlightVolume.bmp"); 
    146147        /*       
    147148                static int framecount = 0; 
     
    199200void OgreLightVolumeRenderingRun::refreshLight() 
    200201{ 
     202        Vector3 center = sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP); 
     203                         
    201204        SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 
    202205        LightList list; 
    203         sm->_populateLightList(((OgreSharedRuns*)sharedRuns)->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP),100000, list); 
     206        sm->_populateLightList(center, 100000, list); 
    204207         
    205208        light = *(list.begin()); 
     
    226229                        lightVolumeCamera->setDirection( dir ); 
    227230                        Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_LIGHTVOLUME_MAP).getRadius(); 
    228                         r += baseRad; 
     231                        //r += baseRad; 
    229232                        systemRadius = r; 
    230233                        lightVolumeCamera->setPosition( sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) - dir * r); 
     
    239242                {                        
    240243                        Vector3 pos = light->getDerivedPosition(); 
    241                         Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) - pos; 
     244                        Vector3 dir = center - pos; 
     245                        Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_LIGHTVOLUME_MAP).getRadius(); 
     246                        //r += baseRad; 
     247                        Real d = dir.length(); 
    242248                        dir.normalise(); 
    243                         Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_LIGHTVOLUME_MAP).getRadius(); 
    244                         r += baseRad; 
    245                         lightVolumeCamera->setPosition( sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) - dir * r); 
    246                         lightVolumeCamera->lookAt( sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) );                      
     249                        /*float mindist = 1.5 * r; 
     250                        if(d < mindist) 
     251                        { 
     252                                pos -= dir * (mindist - d) ; 
     253                                d = mindist; 
     254                        }*/ 
     255                        lightVolumeCamera->setPosition( center - dir * d); 
     256                        lightVolumeCamera->lookAt( center );                     
    247257                        lightVolumeCamera->setProjectionType(PT_ORTHOGRAPHIC); 
    248258                        Matrix4 proj; 
Note: See TracChangeset for help on using the changeset viewer.