| 46 | } |
| 47 | |
| 48 | void ReflectionMaterialHook::init( BaseMatInstance *inMat ) |
| 49 | { |
| 50 | if( !inMat->isValid() ) |
| 51 | return; |
| 52 | |
| 53 | Material *reflectMat = (Material*)inMat->getMaterial(); |
| 54 | if ( inMat->isCustomMaterial() ) |
| 55 | { |
| 56 | // This is a custom material... who knows what it really does...do something |
| 57 | // smart here later. |
| 58 | } |
| 59 | |
| 60 | // We may want to disable some states that the material might enable for us. |
| 61 | GFXStateBlockDesc refractState = inMat->getUserStateBlock(); |
| 62 | |
| 63 | // Always z-read, and z-write if the material isn't translucent |
| 64 | refractState.setZReadWrite( true, reflectMat->isTranslucent() ? false : true ); |
| 65 | |
| 66 | // Create reflection material instance. |
| 67 | BaseMatInstance *newMat = new ReflectionMatInstance( reflectMat ); |
| 68 | newMat->setUserObject( inMat->getUserObject() ); |
| 69 | newMat->getFeaturesDelegate().bind( &ReflectionMaterialHook::_overrideFeatures ); |
| 70 | newMat->addStateBlockDesc( refractState ); |
| 71 | if( !newMat->init( inMat->getFeatures(), inMat->getVertexFormat() ) ) |
| 72 | { |
| 73 | SAFE_DELETE( newMat ); |
| 74 | newMat = MATMGR->createWarningMatInstance(); |
| 75 | } |
| 76 | |
| 77 | mReflectMat = newMat; |
| 78 | } |
| 79 | |
| 80 | void ReflectionMaterialHook::_overrideFeatures( ProcessedMaterial *mat, |
| 81 | U32 stageNum, |
nothing calls this directly
no test coverage detected