ProjectedShadow::ProjectedShadow( SceneObject *object ) { mParentObject = object; mShapeBase = dynamic_cast<ShapeBase*>( object ); mRadius = 0; mLastRenderTime = 0; mUpdateTexture = false; mShadowLength = 10.0f; mDecalData = new DecalData; mDecalData->skipVertexNormals = true; mDecalInstance = NULL; mLastLightDir.set( 0, 0, 0 ); mLastObjectPosition.set( object->getRenderPosition() ); mLastObjectScale.set( object->getScale() ); CustomMaterial *customMat = NULL; Sim::findObject( "BL_ProjectedShadowMaterial", customMat ); if ( customMat ) { mDecalData->material = customMat; mDecalData->matInst = customMat->createMatInstance(); } else mDecalData->matInst = MATMGR->createMatInstance( "WarningMaterial" ); mDecalData->matInst->init( MATMGR->getDefaultFeatures(), getGFXVertexFormat<GFXVertexPNTT>() ); mCasterPositionSC = NULL; mShadowLengthSC = NULL; }
bool WaterObject::initMaterial( S32 idx ) { // We must return false for any case which it is NOT safe for the caller // to use the indexed material. if ( idx < 0 || idx > NumMatTypes ) return false; BaseMatInstance *mat = mMatInstances[idx]; WaterMatParams &matParams = mMatParamHandles[idx]; // Is it already initialized? if ( mat && mat->isValid() ) return true; // Do we need to allocate anything? if ( mSurfMatName[idx].isNotEmpty() ) { if ( mat ) SAFE_DELETE( mat ); CustomMaterial *custMat; if ( Sim::findObject( mSurfMatName[idx], custMat ) && custMat->mShaderData ) mat = custMat->createMatInstance(); else mat = MATMGR->createMatInstance( mSurfMatName[idx] ); const GFXVertexFormat *flags = getGFXVertexFormat<GFXVertexPC>(); if ( mat && mat->init( MATMGR->getDefaultFeatures(), flags ) ) { mMatInstances[idx] = mat; matParams.init( mat ); return true; } SAFE_DELETE( mat ); } return false; }