📄 phyexp.h
字号:
Modifier* FindPhysiqueModifier (INode* nodePtr)
{
// Get object from node. Abort if no object.
if (!mod || !nodePtr) return NULL;
Object* ObjectPtr = nodePtr->GetObjectRef();
if (!ObjectPtr ) return NULL;
while (ObjectPtr->SuperClassID() == GEN_DERIVOB_CLASS_ID && ObjectPtr)
{
// Yes -> Cast.
IDerivedObject* DerivedObjectPtr = (IDerivedObject *)(ObjectPtr);
// Iterate over all entries of the modifier stack.
int ModStackIndex = 0;
while (ModStackIndex < DerivedObjectPtr->NumModifiers())
{
// Get current modifier.
Modifier* ModifierPtr = DerivedObjectPtr->GetModifier(ModStackIndex);
// Is this Physique ?
if (ModifierPtr->ClassID() == Class_ID(PHYSIQUE_CLASS_ID_A, PHYSIQUE_CLASS_ID_B))
{
// is this the correct Physique Modifier based on index?
SkinMod *phyMod = (SkinMod *)ModifierPtr;
if (phyMod == mod)
{
ModContext *mc = DerivedObjectPtr->GetModContext(ModStackIndex);
return ((IPhyContextExport *)(new IPhyContextInternal(mod, mc)));
}
}
ModStackIndex++;
}
ObjectPtr = DerivedObjectPtr->GetObjRef();
}
// Not found.
return NULL;
}
*/
// Deformable Vertex Export via Offset Vectors
//
// Character Studio 2.1 allows users to export Deformable Vertices
// as time frame offsets from a rigid node offset
// The Rigid Offset Vector is identical to the Rigid Vertex Offset Vector.
// This represents the vertex in local coordinates from the attached node.
// Note that since the deformable offset is relative to a single node,
// Blending between links is handled internal to Physique in determining
// this offset, so that the export is a single offset for a given time
// for a single Node.
// Basically, you export a deformable offset from a single node, while
// Physique uses blending between several deformable links to determine
// this offset.
// NOTE: while the Rigid Vertex and Rigid Blended Vertex Export require
// a one time export for replicating the deformabion internal to the game engine,
// the Deformable Offset Vertex Export requires the export of DeformVertexOffset(t)
// at several (or every) frame.
class IPhyDeformableOffsetVertex : public IPhyVertexExport
{
public:
PHYExport virtual ~IPhyDeformableOffsetVertex() {}
// GetNode() will return the INode pointer of the link of the given VertexInterface
PHYExport virtual INode *GetNode() = 0;
// GetOffsetVector() will return the coordinates of the undeformed vertex
// in the local coordinates of associated INode pointer from GetNode().
// This is IDENTICAL to the Rigid Non Blended OffsetVector.
// It represents the Vertex in the local coordinates of the node via GetNode().
PHYExport virtual Point3 GetOffsetVector() = 0;
// GetDeformOffsetVector(t) will return the coorinates of the deformed vertex
// in the local coordinates of the associated INode pointer from GetNode().
// Game Developers wishing to store relative offsets can subtract the
// Deformable Offsets for given frames from the Base Offset Vector.
PHYExport virtual Point3 GetDeformOffsetVector(TimeValue t) = 0;
PHYExport virtual int Execute(int cmd, ULONG arg1=0, ULONG arg2=0, ULONG arg3=0) = 0;
};
// Import Interface Functionality for Physique
//
// Character Studio 2.1 allows users to programatically set the Rigid
// Vertex Assignments (with or without Blending) via Import Interface
// IPhyVertexImport: this is the base class for Vertex Export Interface
// NOTE: currently only RIGID_TYPE vertices are supported (IPhyRigidVertex)
// When a vertex is not assigned Rigid in Physique, the VertexInterface will be NULL
// Unless you call IPhyContextExport->ConvertToRigid(TRUE) (see IPhyContextExport below)
// With ConvertToRigid(TRUE) you will always get a IPhyRigidVertex
// from IPhyContextExport->GetVertexInterface(i)
class IPhyVertexImport
{
public:
PHYExport virtual ~IPhyVertexImport() {}
// NOTE: currently only type RIGID_TYPE | RIGID_BLENDED_TYPE are supported
PHYExport virtual int GetVertexType() = 0;
// You can lock (TRUE) or unlock (FALSE) vertex assignments
// To avoid changes to manual vertex assignments locking prevents
// these vertices from being reinitialized by Physique.
PHYExport virtual void LockVertex(BOOL lock) = 0;
PHYExport virtual int Execute(int cmd, ULONG arg1=0, ULONG arg2=0, ULONG arg3=0) = 0;
};
class IPhyRigidVertexImport : public IPhyVertexImport
{
public:
PHYExport virtual ~IPhyRigidVertexImport() {}
// SetNode() will define the INode pointer of the link of the given Rigid Vertex Interface
// If this INode is a valid Physique Link SetNode returns TRUE, and this vertex is
// now assigned Rigid (NonBlended) to this INode.
// If this INode is not a valid Physique Link, then SetNode returns FALSE,
// and no change to the vertex assignment occurs.
PHYExport virtual BOOL SetNode(INode *nodePtr) = 0;
PHYExport virtual int Execute(int cmd, ULONG arg1=0, ULONG arg2=0, ULONG arg3=0) = 0;
};
class IPhyBlendedRigidVertexImport : public IPhyVertexImport
{
public:
PHYExport virtual ~IPhyBlendedRigidVertexImport() {}
// SetWeightedNode will assign the given vertex to the nodePtr with the weight specified.
// When init = TRUE, this will remove all existing asignments and define this nodePtr
// as the first and only nodePtr assigned to the given vertex. When init = FALSE this
// nodePtr and weight are appeneded to the current assignments.
// Always set init = TRUE for the first nodePtr and weight for a given vertex
// and init = FALSE for all additional 2nd thru Nth nodeptr and weights.
// SetWeightedNode returns the number of Nodes assigned to the given Vertex
// when set successfully, or when the given nodePtr is not a valid Physique Link
// SetWeightedNode returns 0.
PHYExport virtual int SetWeightedNode(INode *nodePtr, float weight, BOOL init = FALSE) = 0;
PHYExport virtual int Execute(int cmd, ULONG arg1=0, ULONG arg2=0, ULONG arg3=0) = 0;
};
class IPhyContextImport
{
public:
PHYExport virtual ~IPhyContextImport() {}
// this returns the number of vertices for the given modContext's Object
PHYExport virtual int GetNumberVertices() = 0;
// SetVertexInterface return's a VertexInterface (IPhyVertexImport *) for the i'th vertex.
// type = RIGID_NON_BLENDED_TYPE | RIGID_BLENDED_TYPE are currently supported.
// Any other value for type will return NULL.
PHYExport virtual IPhyVertexImport *SetVertexInterface(int i, int type) = 0;
// You must call ReleaseVertexInterface to delete the VertexInterface when finished with it.
PHYExport virtual void ReleaseVertexInterface(IPhyVertexImport *vertexImport) = 0;
PHYExport virtual int Execute(int cmd, ULONG arg1=0, ULONG arg2=0, ULONG arg3=0) = 0;
};
class IPhysiqueImport
{
public:
PHYExport virtual ~IPhysiqueImport() {}
//GetContextInterface will return a pointer to IPhyContextImport Interface for a given INode.
// if the given INode does not contain the Physique Modifier of this IPhysique Import then NULL is returned.
PHYExport virtual IPhyContextImport *GetContextInterface(INode* nodePtr) = 0;
// You must call ReleaseContextInterface to delete the ContextInterface when finished with it.
PHYExport virtual void ReleaseContextInterface(IPhyContextImport *contextImport) = 0;
// You call AttachRootNode to define the root node of the Physique Modifier
// This will create default vertex assignments.
// You MUST call AttachRootNode prior to any Imported Vertex Assignments
// This method is designed specifically for developers wanting to
// define Physique fully via import. Predictable results should only be
// expected when this call is followed by a series of Vertex Import calls
// for every ModContext and Vertex of the Modifier.
// If the attach is successful it returns TRUE, otherwise it returns FALSE.
// TimeValue t specifies the initial skeleton pose, the position of the
// skeleton relative to the Object Geometry.
PHYExport virtual BOOL AttachRootNode(INode *nodePtr, TimeValue t) = 0;
PHYExport virtual BOOL InitializePhysique(INode *nodePtr, TimeValue t) = 0;
PHYExport virtual int Execute(int cmd, ULONG arg1=0, ULONG arg2=0, ULONG arg3=0) = 0;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -