本文整理汇总了C++中Shader::GetReference方法的典型用法代码示例。如果您正苦于以下问题:C++ Shader::GetReference方法的具体用法?C++ Shader::GetReference怎么用?C++ Shader::GetReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shader
的用法示例。
在下文中一共展示了Shader::GetReference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createStandardMaterial
//------------------------------
StdMat2* MaterialCreator::createStandardMaterial( const COLLADAFW::EffectCommon& effectCommon, const String& name, const MaterialCreator::MaterialIdentifier& materialIdentifier )
{
StdMat2* material = NewDefaultStdMat();
COLLADAFW::EffectCommon::ShaderType shaderType = effectCommon.getShaderType();
switch ( shaderType )
{
case COLLADAFW::EffectCommon::SHADER_CONSTANT:
material->SetFaceted(true); // BUG393: Max actually does not support a constant shader!
case COLLADAFW::EffectCommon::SHADER_BLINN:
material->SwitchShader(Class_ID(StandardMaterial::STD2_BLINN_SHADER_CLASS_ID, 0));
break;
case COLLADAFW::EffectCommon::SHADER_LAMBERT:
case COLLADAFW::EffectCommon::SHADER_PHONG:
case COLLADAFW::EffectCommon::SHADER_UNKNOWN:
default:
material->SwitchShader(Class_ID(StandardMaterial::STD2_PHONG_CLASS_ID, 0));
break;
}
// Retrieve the shader parameter blocks
Shader* materialShader = material->GetShader();
IParamBlock2* shaderParameters = (IParamBlock2*) materialShader->GetReference(0);
IParamBlock2* extendedParameters = (IParamBlock2*) material->GetReference(StandardMaterial::EXTENDED_PB_REF);
// Common material parameters
material->SetName(name.c_str());
const COLLADAFW::ColorOrTexture& diffuse = effectCommon.getDiffuse();
if ( diffuse.isColor() )
material->SetDiffuse( toMaxColor(diffuse), 0);
const COLLADAFW::ColorOrTexture& emission = effectCommon.getEmission();
if ( emission.isColor() )
{
material->SetSelfIllumColorOn(TRUE);
material->SetSelfIllumColor( toMaxColor(emission), 0);
}
else
{
material->SetSelfIllumColorOn(FALSE);
material->SetSelfIllum( 0, 0 );
}
float maxOpacity = 1;
const COLLADAFW::ColorOrTexture& opacity = effectCommon.getOpacity();
if ( opacity.isColor() )
{
const COLLADAFW::Color& opacityColor = opacity.getColor();
float averageTransparent = (float)(opacityColor.getRed() + opacityColor.getGreen() + opacityColor.getBlue())/3;
maxOpacity = averageTransparent;
}
if ( getDocumentImporter()->getInvertTransparency() )
{
maxOpacity = 1 - maxOpacity;
}
// Max seems to like to have opacity 0 for opacity textures
if ( opacity.isTexture() )
{
material->SetOpacity( 0, 0);
}
else
{
material->SetOpacity( maxOpacity, 0);
}
if (shaderType != COLLADAFW::EffectCommon::SHADER_CONSTANT && shaderType != COLLADAFW::EffectCommon::SHADER_UNKNOWN)
{
// Unlock the ambient and diffuse colors
materialShader->SetLockAD(FALSE);
materialShader->SetLockADTex(FALSE);
material->LockAmbDiffTex(FALSE);
material->SyncADTexLock(FALSE);
// Lambert/Phong material parameters
const COLLADAFW::ColorOrTexture& ambient = effectCommon.getAmbient();
if ( ambient.isColor() )
material->SetAmbient( toMaxColor(ambient), 0);
}
else
{
// Approximate constant shader, specular is the same color
if ( diffuse.isColor() )
material->SetSpecular( toMaxColor(diffuse), 0 );
}
const COLLADAFW::ColorOrTexture& specular = effectCommon.getSpecular();
const COLLADAFW::FloatOrParam& shininessFloatOrParam = effectCommon.getShininess();
float shininess = 1;
if ( shininessFloatOrParam.getType() == COLLADAFW::FloatOrParam::FLOAT )
{
shininess = shininessFloatOrParam.getFloatValue();
}
if ( shaderType == COLLADAFW::EffectCommon::SHADER_PHONG || shaderType == COLLADAFW::EffectCommon::SHADER_BLINN)
{
//.........这里部分代码省略.........