CAMorphNode Manual
A
CAMorphNode
object stores the actual morph data for a corresponding
BaseList2D
object. It is stored in a
CAPoseMorphTag
,见
CAPoseMorphTag Manual
. The class is defined in the
lib_ca.h
header file.
A CAMorphNode object is obtained from the host CAMorph 。见 CAMorph Manual .
// This example accesses the morph data of the // first morph of the given CAPoseMorphTag.// get active morph const Int32 activeIndex = poseMorphTag->GetActiveMorphIndex(); CAMorph * const morph = poseMorphTag->GetMorph(activeIndex); if (morph == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// expand data to access it const CAMORPH_MODE_FLAGS expandFlags = CAMORPH_MODE_FLAGS::ALL | CAMORPH_MODE_FLAGS::EXPAND ; morph-> SetMode (doc, poseMorphTag, expandFlags, CAMORPH_MODE::ABS );
// check stored data if (mnode-> GetInfo () & CAMORPH_DATA_FLAGS::POINTS ) { // access point data const Int32 pointCount = mnode-> GetPointCount (); for ( Int32 i = 0; i < pointCount; ++i) { const 向量 point = mnode-> GetPoint (i); ApplicationOutput ( "Point: " + String::VectorToString (point)); } }
// collapse data const CAMORPH_MODE_FLAGS collapseFlags = CAMORPH_MODE_FLAGS::ALL | CAMORPH_MODE_FLAGS::COLLAPSE ; morph-> SetMode (doc, poseMorphTag, collapseFlags, CAMORPH_MODE::AUTO ); poseMorphTag->UpdateMorphs();
A CAMorphNode stores the data of the corresponding BaseList2D object. In "Hierarchy" mode of the host CAPoseMorphTag a CAMorph stores multiple CAMorphNode objects for all corresponding objects in the object tree.
// check child nodes CheckMorphNode(mnode-> GetDown (), tag, morph, doc);
// get next node mnode = mnode-> GetNext (); } }
A CAMorphNode stores morph data of a corresponding BaseList2D 对象。
A CAMorphNode object can store PSR data:
// check stored data if (mnode-> GetInfo () & CAMORPH_DATA_FLAGS::P ) { // access data const 向量 position = mnode-> GetP ();
// print data ApplicationOutput ( "Position: " + String::VectorToString (position)); }
A CAMorphNode object can store point data:
// check stored data if (mnode-> GetInfo () & CAMORPH_DATA_FLAGS::POINTS ) { Random random;
// loop through points const Int32 pointCount = mnode-> GetPointCount (); for ( Int32 i = 0; i < pointCount; ++i) { // get point 向量 point = mnode-> GetPoint (i);
// random offset point. x += random. Get01 () * 10.0; point. y += random. Get01 () * 10.0; point. z += random. Get01 () * 10.0;
// set point mnode-> SetPoint (i, point); } }
For point mode additional Pose Space Deformation data is stored:
// This example accesses the PSD data of the given point morph.// expand data to access it const CAMORPH_MODE_FLAGS expandFlags = CAMORPH_MODE_FLAGS::ALL | CAMORPH_MODE_FLAGS::EXPAND ; morph-> SetMode (doc, poseMorphTag, expandFlags, CAMORPH_MODE::ABS );
// check stored data if (mnode-> GetInfo () & CAMORPH_DATA_FLAGS::POINTS ) { // get PSD data CAReferencePSD * const psd = mnode-> GetPSDReference (); if (psd) { // loop through all controllers const Int32 controllerCount = psd-> GetExternalControllerCount (); for ( Int32 controllerIndex = 0; controllerIndex < controllerCount; ++controllerIndex) { BaseObject * const controller = psd-> GetExternalController (controllerIndex); if (controller == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); ApplicationOutput ( "Controller: " + controller-> GetName ()); } } } // collapse data const CAMORPH_MODE_FLAGS collapseFlags = CAMORPH_MODE_FLAGS::ALL | CAMORPH_MODE_FLAGS::COLLAPSE ; morph-> SetMode (doc, poseMorphTag, collapseFlags, CAMORPH_MODE::AUTO );
A CAMorphNode object can store tangent data for spline points:
// check stored data if (mnode-> GetInfo () & CAMORPH_DATA_FLAGS::TANGENTS ) { // loop through tangents const Int32 tangentCount = mnode-> GetTangentCount (); for ( Int32 i = 0; i < tangentCount; ++i) { // get data const 向量 tangent = mnode-> GetTangent (i); // print data ApplicationOutput ( "Tangent: " + String::VectorToString (tangent)); } }
A CAMorphNode object can store vertex map data for all vertex map tags of the host object.
// check stored data if (mnode-> GetInfo () & CAMORPH_DATA_FLAGS::VERTEXMAPS ) { const Int32 vertexMapCount = mnode-> GetVertexMapTagCount ();
// loop through tags for ( Int32 tagIndex = 0; tagIndex < vertexMapCount; ++tagIndex) { ApplicationOutput ( "Tag Index " + String::IntToString (tagIndex));
// loop through vertice const Int32 vertexCount = mnode-> GetVertexMapCount (tagIndex); for ( Int32 vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex) { const Float weight = mnode-> GetVertexMap (tagIndex, vertexIndex); ApplicationOutput ( "Weight: " + String::FloatToString (weight)); } } }
A CAMorphNode object can store data for various object parameters.
A CAMorphNode object can store UVW data for all UVW tags of the host object. See also UVWTag Manual .
// expand data to access it const CAMORPH_MODE_FLAGS expandFlags = CAMORPH_MODE_FLAGS::ALL | CAMORPH_MODE_FLAGS::EXPAND ; morph-> SetMode (doc, poseMorphTag, expandFlags, CAMORPH_MODE::ABS );
// check stored data if (mnode-> GetInfo () & CAMORPH_DATA_FLAGS::UV ) { // loop through data for all uvw tags const Int32 uvTagCount = mnode-> GetUVTagCount (); for ( Int32 tagIndex = 0; tagIndex < uvTagCount; ++tagIndex) { ApplicationOutput ( "UVW Tag #" + String::IntToString (tagIndex));
// loop through data for each polygon const Int32 uvCount = mnode-> GetUVCount (tagIndex); for ( Int32 uvIndex = 0; uvIndex < uvCount; ++uvIndex) { ApplicationOutput ( "Polygon #" + String::IntToString (uvIndex)); UVWStruct uvw; mnode-> GetUV (tagIndex, uvIndex, uvw); ApplicationOutput ( String::VectorToString (uvw. a )); ApplicationOutput ( String::VectorToString (uvw. b )); ApplicationOutput ( String::VectorToString (uvw. c )); ApplicationOutput ( String::VectorToString (uvw. d )); } } } // collapse data const CAMORPH_MODE_FLAGS collapseFlags = CAMORPH_MODE_FLAGS::ALL | CAMORPH_MODE_FLAGS::COLLAPSE ; morph-> SetMode (doc, poseMorphTag, collapseFlags, CAMORPH_MODE::AUTO );
A CAMorphNode object can store weight data for all weight tags of the host object. See also CAWeightTag Manual .
// expand data to access it const CAMORPH_MODE_FLAGS expandFlags = CAMORPH_MODE_FLAGS::ALL | CAMORPH_MODE_FLAGS::EXPAND ; morph-> SetMode (doc, poseMorphTag, expandFlags, CAMORPH_MODE::ABS );
// check stored data if (mnode-> GetInfo () & CAMORPH_DATA_FLAGS::WEIGHTMAPS ) { // loop through data for all weight tags const Int32 weightTagCount = mnode-> GetWeightMapTagCount (); for ( Int32 tagIndex = 0; tagIndex < weightTagCount; ++tagIndex) { ApplicationOutput ( "Weight Tag #" + String::IntToString (tagIndex));
// loop through data for all joints const Int32 jointCount = mnode-> GetWeightMapJointCount (tagIndex); for ( Int32 jointIndex = 0; jointIndex < jointCount; ++jointIndex) { ApplicationOutput ( "Joint #" + String::IntToString (jointIndex)); const Int32 weightCount = mnode-> GetWeightMapCount (tagIndex, jointIndex); for ( Int32 weightIndex = 0; weightIndex < weightCount; ++weightIndex) { const Float weight = mnode-> GetWeightMap (tagIndex, jointIndex, weightIndex); ApplicationOutput ( String::FloatToString (weight)); } } } } // collapse data const CAMORPH_MODE_FLAGS collapseFlags = CAMORPH_MODE_FLAGS::ALL | CAMORPH_MODE_FLAGS::COLLAPSE ; morph-> SetMode (doc, poseMorphTag, collapseFlags, CAMORPH_MODE::AUTO );