我是 C++ 的新手,我在文档上工作的内容告诉我只看示例代码,它没有解释任何内容,所以我试图破译它。
我遇到了这个函数声明,但我不完全理解。
只是第一个功能
我得到下面部分我没有得到的是在 MHWRender::MPxShaderOverride(obj) 之后,然后它作为参数列表开始(或者我不知道它叫什么)
我猜我会在哪里找到指定的输入。
我再次不知道这是在做什么,所以我有点迷失了如何解释它。
完整的代码可以在这里找到: http ://help.autodesk.com/view/MAYAUL/2016/ENU/?guid=__cpp_ref_hw_phong_shader_2hw_phong_shader_8cpp_example_html
hwPhongShaderOverride(const MObject& obj)
: MHWRender::MPxShaderOverride(obj)
, fShaderNode(NULL)
, fTextureData(NULL)
, fDrawUsingShader(true) // Disabling this will use fixed-function which only has an OpenGL implementation
, fShaderBound(false)
, fTexture(NULL)
, fInColorPass(false)
, fColorShaderInstance(NULL)
, fInShadowPass(false)
, fShadowShaderInstance(NULL)
, fTransparency(0.0f)
{
// Create a shader instance to use for drawing
//
if (fDrawUsingShader)
{
createShaderInstance();
}
fAmbient[0] = fAmbient[1] = fAmbient[2] = 0.0f;
fDiffuse[0] = fDiffuse[1] = fDiffuse[2] = fDiffuse[3] = 0.0f;
fSpecular[0] = fSpecular[1] = fSpecular[2] = 0.0f;
fShininess[0] = fShininess[1] = fShininess[2] = 500.0f;
}
// override blend state when there is blending
static const MHWRender::MBlendState *sBlendState;
// Current hwPhongShader node associated with the shader override.
// Updated during doDG() time.
hwPhongShader *fShaderNode;
// Shader inputs values including transparency
float fTransparency;
float fAmbient[3];
float fDiffuse[4];
float fSpecular[3];
float fShininess[3];
// Temporary system buffer for creating textures
unsigned char* fTextureData;
// Pass tracking
bool fInColorPass;
bool fInShadowPass;
// Draw with texture or shader flag
bool fDrawUsingShader;
// VP2 texture
MHWRender::MTexture *fTexture;
// VP2 color shader
MHWRender::MShaderInstance *fColorShaderInstance;
// VP2 shadow shader
MHWRender::MShaderInstance *fShadowShaderInstance;
mutable bool fShaderBound;