Changeset 1053 for OGRE/trunk/ogre_changes
- Timestamp:
- 06/26/06 09:33:12 (18 years ago)
- Location:
- OGRE/trunk/ogre_changes/Ogre1.2
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
OGRE/trunk/ogre_changes/Ogre1.2/OgreMain/include/OgrePass.h
r839 r1053 1186 1186 return illumTechniques; 1187 1187 } 1188 void setAlphaSourceBlendFactor(SceneBlendFactor f){mAlphaSourceBlendFactor = f;} 1189 void setAlphaDestBlendFactor(SceneBlendFactor f){mAlphaDestBlendFactor = f;} 1190 void setSeparateAlphaBlend(bool s){mSeparateAlpha = s;} 1191 void setSceneBlendOperation(SceneBlendOperation op){mBlendOperation = op;} 1192 void setSceneAlphaBlendOperation(SceneBlendOperation op){mAlphaBlendOperation = op;} 1193 void setAlphaSceneBlending(SceneBlendType sbt); 1194 void setAlphaSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor); 1195 1196 bool getSeparateAlphaBlend() const{return mSeparateAlpha;} 1197 SceneBlendOperation getSceneBlendOperation() const{return mBlendOperation;} 1198 SceneBlendOperation getSceneBlendOperationAlpha() const{return mAlphaBlendOperation;} 1199 SceneBlendFactor getAlphaSceneBlendingSrcFactor() const{return mAlphaSourceBlendFactor;} 1200 SceneBlendFactor getAlphaSceneBlendingDestFactor() const{return mAlphaDestBlendFactor;} 1188 1201 1189 1202 protected: … … 1192 1205 1193 1206 std::vector<IllumTechniqueParams*> illumTechniques; 1207 bool mSeparateAlpha; 1208 SceneBlendFactor mAlphaSourceBlendFactor; 1209 SceneBlendFactor mAlphaDestBlendFactor; 1210 SceneBlendOperation mBlendOperation; 1211 SceneBlendOperation mAlphaBlendOperation; 1194 1212 #endif 1195 1213 }; -
OGRE/trunk/ogre_changes/Ogre1.2/OgreMain/src/OgreMaterialSerializer.cpp
r812 r1053 248 248 249 249 } 250 251 #ifdef GAMETOOLS_ILLUMINATION_MODULE 252 253 SceneBlendOperation convertBlendOperation(const String& param) 254 { 255 if (param == "add") 256 return SBOP_ADD; 257 else if (param == "subtract") 258 return SBOP_SUBTRACT; 259 else if (param == "rev_subtract") 260 return SBOP_REVSUBTRACT; 261 else if (param == "min") 262 return SBOP_MIN; 263 else if (param == "max") 264 return SBOP_MAX; 265 else 266 { 267 OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Invalid blend operation.", "convertBlendOperation"); 268 } 269 } 270 271 bool parseSceneColorBlendOperation(String& params, MaterialScriptContext& context) 272 { 273 SceneBlendOperation op; 274 op = convertBlendOperation(params); 275 context.pass->setSceneBlendOperation(op); 276 277 return false; 278 } 279 bool parseSceneAlphaBlendOperation(String& params, MaterialScriptContext& context) 280 { 281 SceneBlendOperation op; 282 op = convertBlendOperation(params); 283 context.pass->setSceneAlphaBlendOperation(op); 284 context.pass->setSeparateAlphaBlend(true); 285 286 return false; 287 } 288 bool parseSceneAlphaBlend(String& params, MaterialScriptContext& context) 289 { 290 StringUtil::toLowerCase(params); 291 StringVector vecparams = StringUtil::split(params, " \t"); 292 // Should be 1 or 2 params 293 if (vecparams.size() == 1) 294 { 295 //simple 296 SceneBlendType stype; 297 if (vecparams[0] == "add") 298 stype = SBT_ADD; 299 else if (vecparams[0] == "modulate") 300 stype = SBT_MODULATE; 301 else if (vecparams[0] == "colour_blend") 302 stype = SBT_TRANSPARENT_COLOUR; 303 else if (vecparams[0] == "alpha_blend") 304 stype = SBT_TRANSPARENT_ALPHA; 305 else 306 { 307 logParseError( 308 "Bad scene_blend_alpha attribute, unrecognised parameter '" + vecparams[0] + "'", 309 context); 310 return false; 311 } 312 context.pass->setAlphaSceneBlending(stype); 313 context.pass->setSeparateAlphaBlend(true); 314 315 } 316 else if (vecparams.size() == 2) 317 { 318 //src/dest 319 SceneBlendFactor src, dest; 320 321 try { 322 src = convertBlendFactor(vecparams[0]); 323 dest = convertBlendFactor(vecparams[1]); 324 context.pass->setAlphaSceneBlending(src, dest); 325 context.pass->setSeparateAlphaBlend(true); 326 } 327 catch (Exception& e) 328 { 329 logParseError("Bad scene_blend_alpha attribute, " + e.getFullDescription(), context); 330 } 331 332 } 333 else 334 { 335 logParseError( 336 "Bad scene_blend_alpha attribute, wrong number of parameters (expected 1 or 2)", 337 context); 338 } 339 340 return false; 341 } 342 343 #endif 250 344 //----------------------------------------------------------------------- 251 345 bool parseSceneBlend(String& params, MaterialScriptContext& context) … … 2552 2646 2553 2647 mPassAttribParsers.insert(AttribParserList::value_type("IllumTechniques", (ATTRIBUTE_PARSER)parseIllumTechniques)); 2648 mPassAttribParsers.insert(AttribParserList::value_type("scene_blend_op", (ATTRIBUTE_PARSER)parseSceneColorBlendOperation)); 2649 mPassAttribParsers.insert(AttribParserList::value_type("scene_blend_op_alpha", (ATTRIBUTE_PARSER)parseSceneAlphaBlendOperation)); 2650 mPassAttribParsers.insert(AttribParserList::value_type("scene_blend_alpha", (ATTRIBUTE_PARSER)parseSceneAlphaBlend)); 2554 2651 mIllumTechniqueParsers.insert(AttribParserList::value_type("RenderTechnique", (ATTRIBUTE_PARSER)parseIllumTechniqueParams)); 2555 2652 #endif -
OGRE/trunk/ogre_changes/Ogre1.2/OgreMain/src/OgrePass.cpp
r923 r1053 43 43 #ifdef GAMETOOLS_ILLUMINATION_MODULE 44 44 mActive = true; 45 46 mSeparateAlpha = false; 47 mAlphaSourceBlendFactor = SBF_ONE; 48 mAlphaDestBlendFactor = SBF_ZERO; 49 mBlendOperation = SBOP_ADD; 50 mAlphaBlendOperation = SBOP_ADD; 45 51 #endif 46 52 // Default to white ambient & diffuse, no specular / emissive … … 107 113 #ifdef GAMETOOLS_ILLUMINATION_MODULE 108 114 mActive = true; 115 116 mSeparateAlpha = false; 117 mAlphaSourceBlendFactor = SBF_ONE; 118 mAlphaDestBlendFactor = SBF_ZERO; 119 mBlendOperation = SBOP_ADD; 120 mAlphaBlendOperation = SBOP_ADD; 109 121 #endif 110 122 *this = oth; … … 124 136 #ifdef GAMETOOLS_ILLUMINATION_MODULE 125 137 mActive = oth.mActive; 138 mSeparateAlpha = oth.mSeparateAlpha; 139 mAlphaSourceBlendFactor = oth.mAlphaSourceBlendFactor; 140 mAlphaDestBlendFactor = oth.mAlphaDestBlendFactor; 141 mBlendOperation = oth.mBlendOperation; 142 mAlphaBlendOperation = oth.mAlphaBlendOperation; 126 143 127 144 for(int i = 0; i < oth.illumTechniques.size(); i++ ) … … 633 650 mDestBlendFactor = destFactor; 634 651 } 652 653 #ifdef GAMETOOLS_ILLUMINATION_MODULE 654 void Pass::setAlphaSceneBlending(SceneBlendType sbt) 655 { 656 // Turn predefined type into blending factors 657 switch (sbt) 658 { 659 case SBT_TRANSPARENT_ALPHA: 660 setAlphaSceneBlending(SBF_SOURCE_ALPHA, SBF_ONE_MINUS_SOURCE_ALPHA); 661 break; 662 case SBT_TRANSPARENT_COLOUR: 663 setAlphaSceneBlending(SBF_SOURCE_COLOUR, SBF_ONE_MINUS_SOURCE_COLOUR); 664 break; 665 case SBT_MODULATE: 666 setAlphaSceneBlending(SBF_DEST_COLOUR, SBF_ZERO); 667 break; 668 case SBT_ADD: 669 setAlphaSceneBlending(SBF_ONE, SBF_ONE); 670 break; 671 case SBT_REPLACE: 672 setAlphaSceneBlending(SBF_ONE, SBF_ZERO); 673 break; 674 // TODO: more 675 } 676 677 } 678 //----------------------------------------------------------------------- 679 void Pass::setAlphaSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) 680 { 681 mAlphaSourceBlendFactor = sourceFactor; 682 mAlphaDestBlendFactor = destFactor; 683 } 684 #endif 685 635 686 //----------------------------------------------------------------------- 636 687 SceneBlendFactor Pass::getSourceBlendFactor(void) const -
OGRE/trunk/ogre_changes/Ogre1.2/OgreMain/src/OgreSceneManager.cpp
r948 r1053 809 809 810 810 // The rest of the settings are the same no matter whether we use programs or not 811 812 // Set scene blending 811 // Set scene blending 812 #ifdef GAMETOOLS_ILLUMINATION_MODULE 813 mDestRenderSystem->_setSceneBlending( 814 pass->getSourceBlendFactor(), 815 pass->getDestBlendFactor(), 816 pass->getSceneBlendOperation(), 817 pass->getSeparateAlphaBlend(), 818 pass->getAlphaSceneBlendingSrcFactor(), 819 pass->getAlphaSceneBlendingDestFactor(), 820 pass->getSceneBlendOperationAlpha()); 821 #else 813 822 mDestRenderSystem->_setSceneBlending( 814 823 pass->getSourceBlendFactor(), pass->getDestBlendFactor()); 824 #endif 815 825 816 826 // Set point parameters -
OGRE/trunk/ogre_changes/Ogre1.2/RenderSystems/Direct3D9/include/OgreD3D9RenderSystem.h
r768 r1053 241 241 void _setTextureBorderColour(size_t stage, const ColourValue& colour); 242 242 void _setTextureMatrix( size_t unit, const Matrix4 &xform ); 243 #ifdef GAMETOOLS_ILLUMINATION_MODULE 244 virtual void _setSceneBlending(SceneBlendFactor sourceFactor, 245 SceneBlendFactor destFactor, 246 SceneBlendOperation blendOp = SBOP_ADD, 247 bool separateAlpha = false, 248 SceneBlendFactor sourceFactorAlpha = SBF_ONE, 249 SceneBlendFactor destFactorAlpha = SBF_ZERO, 250 SceneBlendOperation blendOpAlpha = SBOP_ADD); 251 #else 243 252 void _setSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor ); 253 #endif 244 254 void _setAlphaRejectSettings( CompareFunction func, unsigned char value ); 245 255 void _setViewport( Viewport *vp ); -
OGRE/trunk/ogre_changes/Ogre1.2/RenderSystems/Direct3D9/src/OgreD3D9RenderSystem.cpp
r768 r1053 1912 1912 } 1913 1913 } 1914 1915 #ifdef GAMETOOLS_ILLUMINATION_MODULE 1916 1917 void D3D9RenderSystem::_setSceneBlending(SceneBlendFactor sourceFactor, 1918 SceneBlendFactor destFactor, 1919 SceneBlendOperation blendOp, 1920 bool separateAlpha, 1921 SceneBlendFactor sourceFactorAlpha, 1922 SceneBlendFactor destFactorAlpha, 1923 SceneBlendOperation blendOpAlpha) 1924 { 1925 HRESULT hr; 1926 if( sourceFactor == SBF_ONE && destFactor == SBF_ZERO && 1927 sourceFactorAlpha == SBF_ONE && destFactorAlpha == SBF_ZERO) 1928 { 1929 if (FAILED(hr = __SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE))) 1930 OGRE_EXCEPT( hr, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" ); 1931 } 1932 else 1933 { 1934 if (FAILED(hr = __SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE))) 1935 OGRE_EXCEPT( hr, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" ); 1936 1937 if(separateAlpha) 1938 { 1939 if (FAILED(hr = __SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE))) 1940 OGRE_EXCEPT( hr, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" ); 1941 1942 if (FAILED(hr = __SetRenderState(D3DRS_BLENDOPALPHA, D3D9Mappings::get(blendOp)))) 1943 OGRE_EXCEPT( hr, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" ); 1944 1945 if( FAILED( hr = __SetRenderState( D3DRS_SRCBLENDALPHA, D3D9Mappings::get(sourceFactor) ) ) ) 1946 OGRE_EXCEPT( hr, "Failed to set source blend", "D3D9RenderSystem::_setSceneBlending" ); 1947 if( FAILED( hr = __SetRenderState( D3DRS_DESTBLENDALPHA, D3D9Mappings::get(destFactor) ) ) ) 1948 OGRE_EXCEPT( hr, "Failed to set destination blend", "D3D9RenderSystem::_setSceneBlending" ); 1949 1950 } 1951 else 1952 { 1953 if (FAILED(hr = __SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, FALSE))) 1954 OGRE_EXCEPT( hr, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" ); 1955 } 1956 1957 if (FAILED(hr = __SetRenderState(D3DRS_BLENDOP, D3D9Mappings::get(blendOpAlpha)))) 1958 OGRE_EXCEPT( hr, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" ); 1959 if( FAILED( hr = __SetRenderState( D3DRS_SRCBLEND, D3D9Mappings::get(sourceFactor) ) ) ) 1960 OGRE_EXCEPT( hr, "Failed to set source blend", "D3D9RenderSystem::_setSceneBlending" ); 1961 if( FAILED( hr = __SetRenderState( D3DRS_DESTBLEND, D3D9Mappings::get(destFactor) ) ) ) 1962 OGRE_EXCEPT( hr, "Failed to set destination blend", "D3D9RenderSystem::_setSceneBlending" ); 1963 } 1964 } 1965 #else 1914 1966 //--------------------------------------------------------------------- 1915 1967 void D3D9RenderSystem::_setSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor ) … … 1931 1983 } 1932 1984 } 1985 #endif 1933 1986 //--------------------------------------------------------------------- 1934 1987 void D3D9RenderSystem::_setAlphaRejectSettings( CompareFunction func, unsigned char value )
Note: See TracChangeset
for help on using the changeset viewer.