Represents the primitive object of a X3DObject, a primitive is the basic form that is the building block of modeling and animation.
Primitive can be created with X3DObject.GetActivePrimitive.
using namespace XSI; Application app; Model root = app.GetActiveSceneRoot(); X3DObject myCube; root.AddGeometry( L"Cube", L"MeshSurface",L"myMesh",myCube); PolygonMesh myMesh(myCube.GetActivePrimitive().GetGeometry()); CVertexRefArray vertices(myMesh.GetVertices()); LONG lCount = vertices.GetCount(); for (LONG i=0; i<lCount; i++ ) { Vertex vertex(vertices.GetItem(i)); CVertexRefArray neighbors(vertex.GetNeighborVertices(1)); app.LogMessage(L"Number of neighbor vertices for Vertex " + CValue(i).GetAsText() + L": " + CValue(neighbors.GetCount()).GetAsText() ); }
#include <xsi_primitive.h>
Public Member Functions | |
Primitive () | |
~Primitive () | |
Primitive (const CRef &in_ref) | |
Primitive (const Primitive &in_obj) | |
bool | IsA (siClassID in_ClassID) const |
siClassID | GetClassID () const |
Primitive & | operator= (const Primitive &in_obj) |
Primitive & | operator= (const CRef &in_ref) |
Geometry | GetGeometry (double in_time=DBL_MAX) const |
Geometry | GetGeometry (double in_time, siConstructionMode in_mode) const |
CRefArray | GetICETrees () const |
Primitive | ( | ) |
Default constructor.
~Primitive | ( | ) |
Default destructor.
bool IsA | ( | siClassID | in_ClassID | ) | const [virtual] |
Returns true if a given class type is compatible with this API class.
in_ClassID | class type. |
Reimplemented from ProjectItem.
Reimplemented in CustomPrimitive, HairPrimitive, and ParticleCloudPrimitive.
siClassID GetClassID | ( | ) | const [virtual] |
Returns the type of the API class.
Reimplemented from ProjectItem.
Reimplemented in CustomPrimitive, HairPrimitive, and ParticleCloudPrimitive.
Creates an object from another object. The newly created object is set to empty if the input object is not compatible.
in_obj | constant class object. |
Creates an object from a reference object. The newly created object is set to empty if the input reference object is not compatible.
in_ref | constant class object. |
Reimplemented from ProjectItem.
Reimplemented in CustomPrimitive, HairPrimitive, and ParticleCloudPrimitive.
Geometry GetGeometry | ( | double | in_time = DBL_MAX | ) | const |
Geometry GetGeometry | ( | double | in_time, |
siConstructionMode | in_mode | ||
) | const |
Returns a snapshot of the Geometry at the specified time.
in_time | Time (in frames) at which to get property. Use DBL_MAX to specify the current time. |
in_mode | The construction mode is used to access a version of the geometry with specific deforms. The geometry positions you get depends on the mode you passed in. |
Valid construction modes include:
siConstructionModeModeling:
Gets the original geometry positions. This mode is typically used in export applications where geometry, shape and envelope positions are exported separately.siConstructionModePrimaryShape:
Combines the geometry positions with the shape deformation.siConstructionModeSecondaryShape:
Combines the geometry positions with the shape deformation, the envelope deformation and the deforms installed above the envelope such as the move point operators. This mode is typically used for plotting the final results of shape and envelope deformation.siConstructionModeAnimation:
Combines the geometry positions with the shape and envelope deformation altogether.siConstructionModeDefault:
Uses the current construction mode set in XSI.Application app; Model root = app.GetActiveSceneRoot(); X3DObject myCube; root.AddGeometry( L"Cube", L"MeshSurface",L"myMesh",myCube); Primitive cubePrimitive = myCube.GetActivePrimitive(); CValue retval; CValueArray args(19); args[0] = myCube.GetFullName() + L".pnt[0]"; args[1] = 10; args[2] = 10; args[3] = 10; args[17] = siConstructionModeAnimation; app.ExecuteCommand(L"Translate",args,retval ); Geometry modelGeometry = cubePrimitive.GetGeometry(0,siConstructionModeModeling); Point modelPoint1 = modelGeometry.GetPoints()[0]; app.LogMessage( L"modelPoint1: " + CString(modelPoint1.GetPosition()) ); Geometry shapeGeometry = cubePrimitive.GetGeometry(0,siConstructionModeAnimation); Point shapePoint1 = shapeGeometry.GetPoints()[0]; app.LogMessage( L"shapePoint1: " + CString(shapePoint1.GetPosition()) );
CRefArray GetICETrees | ( | ) | const |
Returns all ICETree objects that write to this primitive.
void CreatePrim( const CString& in_presetobj, const CString& in_geometrytype, const CString& in_name, const CString& in_parent ); void ApplyOp( const CString& in_presetobj, CString& io_connectionset, const CValue& in_connecttype, siOperationMode io_immediatemode, CValue& out_outputobjs, const CValue& in_constructionmode ); // Create agrid primitive and apply a ICETree on it CreatePrim( L"Grid", L"MeshSurface", L"", L"" ); CString strObj(L"grid"); CValue retVal; ApplyOp( L"ICETree", strObj, 0, siPersistentOperation, retVal, 0 ); // Get the X3DObject grid from the selection and iterate over the ICETrees Selection selection = xsi.GetSelection(); X3DObject x3DGrid = selection[ 0 ]; CRefArray trees = x3DGrid.GetActivePrimitive().GetICETrees(); for (LONG i=0; i<trees.GetCount(); i++) { ICETree t = tress[i]; xsi.LogMessage( t.GetClassIDName() ); }