本文整理汇总了C++中MDataHandle::asAddr方法的典型用法代码示例。如果您正苦于以下问题:C++ MDataHandle::asAddr方法的具体用法?C++ MDataHandle::asAddr怎么用?C++ MDataHandle::asAddr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDataHandle
的用法示例。
在下文中一共展示了MDataHandle::asAddr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compute
//
// DESCRIPTION:
///////////////////////////////////////////////////////
MStatus PhongNode::compute(
const MPlug& plug,
MDataBlock& block )
{
if ((plug != aOutColor) && (plug.parent() != aOutColor))
return MS::kUnknownParameter;
MFloatVector resultColor(0.0,0.0,0.0);
// get sample surface shading parameters
MFloatVector& surfaceNormal = block.inputValue( aNormalCamera ).asFloatVector();
MFloatVector& cameraPosition = block.inputValue( aPointCamera ).asFloatVector();
// use for raytracing api enhancement below
MFloatVector point = cameraPosition;
MFloatVector normal = surfaceNormal;
MFloatVector& surfaceColor = block.inputValue( aColor ).asFloatVector();
MFloatVector& incandescence = block.inputValue( aIncandescence ).asFloatVector();
float diffuseReflectivity = block.inputValue( aDiffuseReflectivity ).asFloat();
// float translucenceCoeff = block.inputValue( aTranslucenceCoeff ).asFloat();
// User-defined Reflection Color Gain
float reflectGain = block.inputValue( aReflectGain ).asFloat();
// Phong shading attributes
float power = block.inputValue( aPower ).asFloat();
float spec = block.inputValue( aSpecularity ).asFloat();
float specularR, specularG, specularB;
float diffuseR, diffuseG, diffuseB;
diffuseR = diffuseG = diffuseB = specularR = specularG = specularB = 0.0;
// get light list
MArrayDataHandle lightData = block.inputArrayValue( aLightData );
int numLights = lightData.elementCount();
// iterate through light list and get ambient/diffuse values
for( int count=1; count <= numLights; count++ )
{
MDataHandle currentLight = lightData.inputValue();
MFloatVector& lightIntensity = currentLight.child(aLightIntensity).asFloatVector();
// Find the blind data
void*& blindData = currentLight.child( aLightBlindData ).asAddr();
// find ambient component
if( currentLight.child(aLightAmbient).asBool() ) {
diffuseR += lightIntensity[0];
diffuseG += lightIntensity[1];
diffuseB += lightIntensity[2];
}
MFloatVector& lightDirection = currentLight.child(aLightDirection).asFloatVector();
if ( blindData == NULL )
{
// find diffuse and specular component
if( currentLight.child(aLightDiffuse).asBool() )
{
float cosln = lightDirection * surfaceNormal;;
if( cosln > 0.0f ) // calculate only if facing light
{
diffuseR += lightIntensity[0] * ( cosln * diffuseReflectivity );
diffuseG += lightIntensity[1] * ( cosln * diffuseReflectivity );
diffuseB += lightIntensity[2] * ( cosln * diffuseReflectivity );
}
CHECK_MSTATUS( cameraPosition.normalize() );
if( cosln > 0.0f ) // calculate only if facing light
{
float RV = ( ( (2*surfaceNormal) * cosln ) - lightDirection ) * cameraPosition;
if( RV > 0.0 ) RV = 0.0;
if( RV < 0.0 ) RV = -RV;
if ( power < 0 ) power = -power;
float s = spec * powf( RV, power );
specularR += lightIntensity[0] * s;
specularG += lightIntensity[1] * s;
specularB += lightIntensity[2] * s;
}
}
}
else
{
float cosln = MRenderUtil::diffuseReflectance( blindData, lightDirection, point, surfaceNormal, true );
if( cosln > 0.0f ) // calculate only if facing light
{
diffuseR += lightIntensity[0] * ( cosln * diffuseReflectivity );
diffuseG += lightIntensity[1] * ( cosln * diffuseReflectivity );
diffuseB += lightIntensity[2] * ( cosln * diffuseReflectivity );
}
CHECK_MSTATUS ( cameraPosition.normalize() );
//.........这里部分代码省略.........