- Timestamp:
- 06/26/06 09:33:12 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.