本文整理汇总了C++中mhwrender::MDrawContext::viewDirectionAlongNegZ方法的典型用法代码示例。如果您正苦于以下问题:C++ MDrawContext::viewDirectionAlongNegZ方法的具体用法?C++ MDrawContext::viewDirectionAlongNegZ怎么用?C++ MDrawContext::viewDirectionAlongNegZ使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mhwrender::MDrawContext
的用法示例。
在下文中一共展示了MDrawContext::viewDirectionAlongNegZ方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lightPosition
/* static */
GlfSimpleLightingContextRefPtr
px_vp20Utils::GetLightingContextFromDrawContext(
const MHWRender::MDrawContext& context)
{
const GfVec4f blackColor(0.0f, 0.0f, 0.0f, 1.0f);
const GfVec4f whiteColor(1.0f, 1.0f, 1.0f, 1.0f);
GlfSimpleLightingContextRefPtr lightingContext =
GlfSimpleLightingContext::New();
MStatus status;
unsigned int numMayaLights =
context.numberOfActiveLights(MHWRender::MDrawContext::kFilteredToLightLimit,
&status);
if (status != MS::kSuccess || numMayaLights < 1) {
return lightingContext;
}
bool viewDirectionAlongNegZ = context.viewDirectionAlongNegZ(&status);
if (status != MS::kSuccess) {
// If we fail to find out the view direction for some reason, assume
// that it's along the negative Z axis (OpenGL).
viewDirectionAlongNegZ = true;
}
GlfSimpleLightVector lights;
for (unsigned int i = 0; i < numMayaLights; ++i) {
MHWRender::MLightParameterInformation* mayaLightParamInfo =
context.getLightParameterInformation(i);
if (!mayaLightParamInfo) {
continue;
}
// Setup some default values before we read the light parameters.
bool lightEnabled = true;
bool lightHasPosition = false;
GfVec4f lightPosition(0.0f, 0.0f, 0.0f, 1.0f);
bool lightHasDirection = false;
GfVec3f lightDirection(0.0f, 0.0f, -1.0f);
if (!viewDirectionAlongNegZ) {
// The convention for DirectX is positive Z.
lightDirection[2] = 1.0f;
}
float lightIntensity = 1.0f;
GfVec4f lightColor = blackColor;
bool lightEmitsDiffuse = true;
bool lightEmitsSpecular = false;
float lightDecayRate = 0.0f;
float lightDropoff = 0.0f;
// The cone angle is 180 degrees by default.
GfVec2f lightCosineConeAngle(-1.0f);
float lightShadowBias = 0.0f;
bool lightShadowOn = false;
bool globalShadowOn = false;
MStringArray paramNames;
mayaLightParamInfo->parameterList(paramNames);
for (unsigned int paramIndex = 0; paramIndex < paramNames.length(); ++paramIndex) {
const MString paramName = paramNames[paramIndex];
const MHWRender::MLightParameterInformation::ParameterType paramType =
mayaLightParamInfo->parameterType(paramName);
const MHWRender::MLightParameterInformation::StockParameterSemantic paramSemantic =
mayaLightParamInfo->parameterSemantic(paramName);
MIntArray intValues;
MFloatArray floatValues;
switch (paramType) {
case MHWRender::MLightParameterInformation::kBoolean:
case MHWRender::MLightParameterInformation::kInteger:
mayaLightParamInfo->getParameter(paramName, intValues);
break;
case MHWRender::MLightParameterInformation::kFloat:
case MHWRender::MLightParameterInformation::kFloat2:
case MHWRender::MLightParameterInformation::kFloat3:
case MHWRender::MLightParameterInformation::kFloat4:
mayaLightParamInfo->getParameter(paramName, floatValues);
break;
default:
// Unsupported paramType.
continue;
break;
}
switch (paramSemantic) {
case MHWRender::MLightParameterInformation::kLightEnabled:
_GetLightingParam(intValues, floatValues, lightEnabled);
break;
case MHWRender::MLightParameterInformation::kWorldPosition:
if (_GetLightingParam(intValues, floatValues, lightPosition)) {
lightHasPosition = true;
}
//.........这里部分代码省略.........