This commit is contained in:
nephacks
2025-06-04 03:22:50 +02:00
parent f234f23848
commit f12416cffd
14243 changed files with 6446499 additions and 26 deletions

View File

@@ -0,0 +1,222 @@
//====== Copyright © 1996-2009, Valve Corporation, All rights reserved. =======
//
// Declaration of CDmAnimUtils a set of animation related utilities
// which work on DmeDag and other DmElement derived objects.
//
//=============================================================================
#ifndef DMANIMUTILS_H
#define DMANIMUTILS_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmerigconstraintoperators.h"
#include "movieobjects/dmechannel.h"
class CDmeGameModel;
enum TransformSpace_t
{
TS_WORLD_SPACE,
TS_LOCAL_SPACE,
TS_OBJECT_SPACE,
TS_REFERENCE_SPACE,
};
enum ReParentLogMode_t
{
REPARENT_LOGS_NONE, // Do not touch logs
REPARENT_LOGS_OVERWRITE, // Overwrite the logs with new local transform of the dag
REPARENT_LOGS_OFFSET_LOCAL, // Apply the transform required to maintain the world space transform of the dag to all log samples
REPARENT_LOGS_MAINTAIN_WORLD, // Modify the logs so that the world space position and orientation animation is maintained
};
//-----------------------------------------------------------------------------
// CDmeDagPtr - For swig generation this is an actual class with a single
// member which is a pointer to dag, for normal c++ code it is just a typedef
// of a pointer to a CDmeDag* , this is required because swig has issues
// generating code for CUtlVector< CDmeDag * > as there are functions within
// CUtlVector which use the paremter of T & wich with T = CDmeDag * results in
// CDmeDag *&, and when swig generates code to parse this type coming from python
// it considers a pointer to a pointer, when infact it is still just a pointer.
// So we tell swig that CDmeDagPtr is a class to avoid this issue, but treat it
// as typedef in code. This works since both are exactly 4 bytes containing the
// address of the CDmeDag instance.
//-----------------------------------------------------------------------------
#ifdef SWIG
class CDmeDagPtr
{
public:
CDmeDagPtr() { m_pDag = NULL; }
CDmeDagPtr( CDmeDag *pDag ) { m_pDag = pDag; }
private:
CDmeDag *m_pDag;
};
#else
typedef CDmeDag* CDmeDagPtr;
#endif
//-----------------------------------------------------------------------------
// CDmeAnimUtils - A collection of utility functions which perform animation
// related operations on data model elements. This class is wrapped by swig so
// that the functions are accessible from python, but the functions are
// designed to be used directly as well.
//-----------------------------------------------------------------------------
class CDmAnimUtils
{
public:
// Create an infinite time selection
static CDmeTimeSelection *CreateInfiniteTimeSelection();
// Create an absolute time selection with the specified key times
static CDmeTimeSelection *CreateTimeSelection( DmeTime_t leftFalloff, DmeTime_t leftHold, DmeTime_t rightHold, DmeTime_t rightFalloff );
// Create a dag with the specified name, position and orientation
static CDmeDag *CreateDag( const char *pchName, const Vector &position, const Quaternion &orientation, CDmeDag *pParent = NULL );
// Get the average position of the provided dag nodes in the specified space
static Vector GetDagPosition( const CUtlVector< CDmeDagPtr > &dagList, TransformSpace_t space, const CDmeDag *pReference = NULL );
// Get the average Euler rotation of the provided dag nodes in the specified space
static Vector GetDagRotation( const CUtlVector< CDmeDagPtr > &dagList, TransformSpace_t space, const CDmeDag *pReference = NULL );
// Get the average orientation (quaternion) of the provided dag nodes in the specified space
static Quaternion GetDagOrientation( const CUtlVector< CDmeDagPtr > &dagList, TransformSpace_t space, const CDmeDag *pReference = NULL );
// Get the average position and orientation of the provided dag nodes in the specified space
static void GetDagPositionOrienation( Vector &position, Quaternion &orienation, const CUtlVector< CDmeDagPtr > &dagList, TransformSpace_t space, const CDmeDag *pReferenceDag = NULL );
// Move the provided dag nodes in the specified space
static void MoveDagNodes( const Vector &offset, const CUtlVector< CDmeDagPtr > &dagList, bool bRelative, TransformSpace_t space, CDmeDag *pReference = NULL );
// Move the provided dag nodes in the specified space and apply the operation to the logs associated with the dag
static void MoveDagNodes( const Vector &offset, const CUtlVector< CDmeDagPtr > &dagList, bool bRelative, const CDmeTimeSelection *pTimeSelection, bool bOffsetOverTime, TransformSpace_t space, CDmeDag *pReference = NULL );
// Rotate the provided dag nodes in the specified space
static void RotateDagNodes( const Vector &rotation, const CUtlVector< CDmeDagPtr > &dagList, bool bRelative, TransformSpace_t space, CDmeDag *pReference = NULL );
// Rotate the provided dag nodes in the specified space and apply the operation to the logs associated with the dag
static void RotateDagNodes( const Vector &rotation, const CUtlVector< CDmeDagPtr > &dagList, bool bRelative, const CDmeTimeSelection *pTimeSelection, bool bOffsetOverTime, TransformSpace_t space, CDmeDag* pReference = NULL );
// Perform both a translation and a rotation of the specified dag nodes
static void TransformDagNodes( const Vector &offset, const Quaternion &rotation, const CUtlVector< CDmeDagPtr > &dagList, bool bRelative, TransformSpace_t space, CDmeDag* pReferenceDag = NULL, bool bPosition = true, bool bRotation = true );
// Perform both a translation and a rotation of the specified dag nodes and apply the operation to the logs associated with the dag
static void TransformDagNodes( const Vector &offset, const Quaternion &rotation, const CUtlVector< CDmeDagPtr > &dagList, bool bRelative, const CDmeTimeSelection *pTimeSelection, bool bOffsetOverTime, TransformSpace_t space, CDmeDag* pReferenceDag = NULL, bool bPosition = true, bool bRotation = true );
// Set the current position and orientation as the defaults for the specified dag nodes.
static void SetDagTransformDefaults( const CUtlVector< CDmeDagPtr > &dagList, bool bPosition, bool bOrientation );
// Set the controls associated with the specified dag nodes to the reference pose position and orientation
static void SetReferencePose( CDmeGameModel *pGameModel, const CUtlVector< CDmeDag* > &dagList );
// Re-parent the specified dag node from its current parent to the specified dag node.
static void ReParentDagNode( CDmeDag *pDagNode, CDmeDag *pNewParent, bool bMaintainWorldPos, ReParentLogMode_t logMode );
// Set the temporary override parent of a dag, maintaining its world space position and orientation animation
static void SetOverrideParent( CDmeDag *pDagNode, const CDmeDag *pOverrideParent, bool bPosition, bool bRotation );
// Enable or disable the override parent functionality on a dag, if different than the current state the logs will be udpdated such the dag world space position and orientation are maintained.
static void ToggleOverrideParent( CDmeDag *pDagNode, bool bEnable );
// Determine if the specified dag node has any constraints
static bool DagHasConstraints( CDmeDag *pDag );
// Remove all of the constraints from the specified dag
static void RemoveConstraints( CDmeDag *pDag );
// Update the logs of the dag so the the current local transform is the only value in the log
static void SetLogsToCurrentTransform( CDmeDag *pDag );
// Generate log samples for the specified dag node, if a parent is provided, generate the samples in the space of that parent, otherwise generate the samples in world space.
static void GenerateLogSamples( CDmeDag* pDag, CDmeDag *pParent, bool bPosition, bool bOrientation, const DmeLog_TimeSelection_t *pTimeSelection = NULL );
// Find and operate all of the channels driving the specified dag nodes
static void OperateDagChannels( const CUtlVector< CDmeDag* > &dagList, ChannelMode_t mode, const DmeLog_TimeSelection_t &timeSelection, CDmeClip *pShot = NULL, CDmeClip *pMovie = NULL );
// Create a constraint of the specified type
static CDmeRigBaseConstraintOperator *CreateConstraint( const char *pchName, EConstraintType constraintType, CDmeDag *pConstrainedDag, const CUtlVector< CDmeDagPtr > &targetDagList, bool bPreserveOffset, float flWeight, bool bOperate );
// Create a Point constraint which will control the position of the specified dag such that it matches the weighted target position
static CDmeRigPointConstraintOperator* CreatePointConstraint( char const *pchName, CDmeDag *pConstrainedDag, const CUtlVector< CDmeDagPtr > &targetDagList, bool bPreserveOffset, float flWeight );
// Create a Orient constraint which will control the orientation of the specified dag such that it matches the weighted target orientation
static CDmeRigOrientConstraintOperator* CreateOrientConstraint( char const *pchName, CDmeDag *pConstrainedDag, const CUtlVector< CDmeDagPtr > &targetDagList, bool bPreserveOffset, float flWeight );
// Create a Parent constraint which will control the position and orientation of the specified dag such the dag behaves as if it is a child of the transform defined by the weighted target list
static CDmeRigParentConstraintOperator* CreateParentConstraint( char const *pchName, CDmeDag *pConstrainedDag, const CUtlVector< CDmeDagPtr > &targetDagList, bool bPreserveOffset, float flWeight );
// Create an Aim constraint which will control the orientation of the specified dag such that it points toward the weighted target position
static CDmeRigAimConstraintOperator* CreateAimConstraint( char const *pchName, CDmeDag *pConstrainedDag, const CUtlVector< CDmeDagPtr > &targetDagList, bool bPreserveOffset, float flWeight, const Vector &upVector, TransformSpace_t upSpace, const CDmeDag* pReferenceDag = NULL );
// Create an IK constraint controlling the 2 bone chain from the specified root dag to the specified end dag
static CDmeRigIKConstraintOperator* CreateIKConstraint( const char *pchName, CDmeDag *pChainRootDag, CDmeDag *pChainEndDag, CDmeDag *pTargetDag, bool bPreserveOffset, const Vector &poleVector, CDmeDag *pPoleVectorTarget = NULL );
// Print the position and orientation of the dag over time for debugging purposes
static void PrintDagTransformOverTime( CDmeDag* pDag, CDmeClip *pShot = NULL, CDmeClip *pMovie = NULL );
private:
// Find the constraint of the specified type controlling the specified dag node
static CDmeRigBaseConstraintOperator *FindConstraintOnDag( CDmeDag* pDag, EConstraintType constraintType );
// Allocate an constraint of the specified type.
static CDmeRigBaseConstraintOperator *InstanceConstraint( char const *pchName, EConstraintType eType, const DmFileId_t &fileId );
// Find the position or orientation channel for the specified dag node
static CDmeChannel *FindDagTransformChannel( CDmeDag *pDag, const char *pchAttributeName );
// Create the position and orientation channels for the specified dag node if they do not already exist.
static void CreateTransformChannelsForDag( CDmeDag *pDag, CDmeChannelsClip *pChannelsClip, bool bPosition, bool bOrientation, CDmeChannel *&pPositionChannel, CDmeChannel *&pOrientationChannel );
// Generate a list of all of the world space transform of the specified dag node at each time in the provided list
static void GenerateDagWorldTransformList( CDmeDag *pDag, const CUtlVector< DmeTime_t > &times, CUtlVector< matrix3x4_t > &transformList, CDmeClip *pShot, CDmeClip *pMovie );
// Update the position and orientation logs of the specified dag node so that the dag node's world space transform matches the provided list
static void SetDagWorldSpaceTransforms( CDmeDag* pDag, CUtlVector< DmeTime_t > &times, const CUtlVector< matrix3x4_t > &transformList, CDmeClip *pShot, CDmeClip *pMovie );
// Create a list of all of the key times in the provided list of channels
static void CompileKeyTimeList( const CUtlVector< CDmeOperator* > &channelList, CUtlVector< DmeTime_t > &times, const DmeLog_TimeSelection_t *pTimeSelection, CDmeClip *pShot, CDmeClip *pMovie );
// Find the position and orientation controls for the specified dag node
static CDmeTransformControl *GetTransformControl( const CDmeDag *pDag );
// Get the local space default transform for the specified dag node
static void GetDefaultTransform( CDmeDag *pDagNode, matrix3x4_t &defaultTransform );
// Get the world space default transform for the specified dag node
static void GetDefaultAbsTransform( CDmeDag *pDagNode, matrix3x4_t &absDefaultTransform );
// Update the default values for the position and orientation controls of the specified dag so they maintain their world space position
static void UpdateDefaultsForNewParent( CDmeDag *pDagNode, CDmeDag *pParentDag );
// Get all of the channels directly driving the specified dag nodes
static void GetChannelsForDags( const CUtlVector< CDmeDag* > &dagList, CUtlVector< CDmeChannel* > &channelList );
// Operate all of the provided channels.
static void OperateChannels( const CUtlVector< CDmeChannel* > &channelList, const DmeLog_TimeSelection_t &timeSelection, CDmeClip *pShot, CDmeClip *pMovie );
// Operate all of the provided channels in the specified mode.
static void RecordChannels( const CUtlVector< CDmeChannel* > &channelList, const DmeLog_TimeSelection_t &timeSelection, CDmeClip *pShot, CDmeClip *pMovie );
// Find the shot and the movie to which the specified dag node belongs
static void FindShotAndMovieForDag( const CDmeDag *pDag, CDmeClip *&pShot, CDmeClip *&pMovie );
};
#endif // DMANIMUTILS_H

View File

@@ -0,0 +1,92 @@
//============ Copyright (c) Valve Corporation, All rights reserved. ==========
//
// Autodesk FBX <-> Valve DMX
//
//=============================================================================
#ifndef DMFBXSERIALIZER_H
#define DMFBXSERIALIZER_H
#if defined( _WIN32 )
#pragma once
#endif
// FBX includes
#include <fbxsdk.h>
// Valve includes
#include "datamodel/idatamodel.h"
#include "tier1/utlbuffer.h"
#include "tier1/utlmap.h"
#include "tier1/utlstring.h"
#include "tier1/utlvector.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeCombinationOperator;
class CDmeDag;
class CDmeMesh;
class CDmeModel;
//-----------------------------------------------------------------------------
// Serialization class for FBX files
//-----------------------------------------------------------------------------
class CDmFbxSerializer
{
public:
CDmFbxSerializer();
virtual ~CDmFbxSerializer();
const char *GetName() const { return "fbx"; }
const char *GetDescription() const { return "Autodesk® FBX®"; }
// CDmFbxSerializer
CDmElement *ReadFBX( const char *pszFilename );
bool Verbose1() const { return m_nOptVerbosity >= 1; }
bool Verbose2() const { return m_nOptVerbosity >= 2; }
// UtlHashtable is non-functional in //ValveGames/main 5/16/2012
typedef CUtlMap< FbxNode *, CDmeDag * > FbxToDmxMap_t;
protected:
FbxManager *CreateFbxManager();
void DestroyFbxManager();
FbxScene *LoadFbxScene( const char *pszFilename );
void LoadModelAndSkeleton_R( FbxToDmxMap_t &fbxToDmxMap, CDmeModel *pDmeModel, CDmeDag *pDmeDagParent, FbxNode *pFbxNode, bool bAnimation, int nDepth ) const;
CDmeDag *FbxNodeToDmeDag( CDmeDag *pDmeDagParent, FbxNode *pFbxNode, const char *pszDmeType ) const;
CDmeMesh *FbxShapeToDmeMesh( CDmeDag *pDmeDag, FbxNode *pFbxNode ) const;
bool FbxMeshToDmeFaceSets( CDmeDag *pDmeDag, CDmeMesh *pDmeMesh, FbxMesh *pFbxMesh, CUtlVector< int > &nPolygonToFaceSetMap ) const;
void GetDmeMaterialPathFromFbxFileTexture( CUtlString &sMaterialPath, FbxFileTexture *pFileTexture ) const;
void GetFbxMaterialNameAndPath( CUtlString &sMaterialName, CUtlString &sMaterialPath, FbxSurfaceMaterial *pFbxMat ) const;
void SkinMeshes_R( const FbxToDmxMap_t &fbxToDmxMap, CDmeModel *pDmeModel, FbxNode *pFbxNode ) const;
void SkinMesh( CDmeDag *pDmeDag, const FbxToDmxMap_t &fbxToDmxMap, CDmeModel *pDmeModel, FbxNode *pFbxNode ) const;
void AddBlendShapes_R( const FbxToDmxMap_t &fbxToDmxMap, CDmElement *pDmeRoot, FbxNode *pFbxNode ) const;
void AddBlendShape( CDmeDag *pDmeDag, const FbxToDmxMap_t &fbxToDmxMap, CDmElement *pDmeRoot, FbxNode *pFbxNode ) const;
CDmeCombinationOperator *FindOrCreateComboOp( CDmElement *pDmeRoot ) const;
bool FindOrCreateControl( CDmeCombinationOperator *pDmeComboOp, const char *pszName ) const;
void GetName( CUtlString &sCleanName, const FbxNode *pFbxNode ) const;
void CleanupName( CUtlString &sCleanName, const char *pszName ) const;
void LoadAnimation( CDmElement *pDmeRoot, CDmeModel *pDmeModel, const FbxToDmxMap_t &fbxToDmxMap, FbxScene *pFbxScene, FbxNode *pFbxRootNode ) const;
FbxManager *m_pFbxManager;
public:
int m_nOptVerbosity;
bool m_bOptUnderscoreForCorrectors;
bool m_bAnimation;
};
#endif // DMFBXSERIALIZER_H

View File

@@ -0,0 +1,234 @@
//======= Copyright © 1996-2006, Valve Corporation, All rights reserved. ======
//
// Mesh Manipulation Utilities
//
//=============================================================================
#ifndef DMMESHUTILS_H
#define DMMESHUTILS_H
#if defined( _WIN32 )
#pragma once
#endif
#include "movieobjects/dmedag.h"
#include "movieobjects/dmmeshcomp.h"
#include "movieobjects/dmevertexdata.h"
#include "tier1/utlstring.h"
#include "tier1/UtlStringMap.h"
#include "tier1/utlvector.h"
class CDmeMesh;
class CDmeModel;
class CDmMeshComp::CEdge;
class CDmeCombinationOperator;
class CDmePreset;
class CDmePresetGroup;
class CDmeFaceSet;
class CMesh;
bool SaveMeshesToDMX( CUtlVector<CMesh*> &inputMeshes, const char *pDMXFile, bool bForce2DTexcoords = true );
bool LoadMeshesFromDMX( CUtlVector<CMesh*> &outputMeshes, const char *pDMXFile );
bool LoadMeshes( CUtlVector<CMesh*> &outputMeshes, CDmeModel *pModel, float flScale, int *pBoneRemap = NULL );
bool LoadCollisionMeshes( CUtlVector< CMesh* > &outputMeshes, CUtlVector< CDmeDag* > &outputDags, CDmeModel *pModel, float flScale );
bool ConvertMeshFromDMX( CMesh *pMeshOut, CDmeMesh *pDmeMesh );
void ConvertMeshToDMX( CDmeMesh *pDmeMeshOut, CMesh *pMeshIn, bool bForce2DTexcoords );
//-----------------------------------------------------------------------------
// Mesh Utility function class (more like a namespace)
//-----------------------------------------------------------------------------
class CDmMeshUtils
{
public:
static bool RemoveLargeAxisAlignedPlanarFaces( CDmeMesh *pMesh );
static bool RemoveFacesWithMaterial( CDmeMesh *pMesh, const char *pMaterialName );
static bool RemoveFacesWithMoreThanNVerts( CDmeMesh *pMesh, const int nVertexCount );
enum Axis_t
{
kXAxis,
kYAxis,
kZAxis
};
static bool Mirror( CDmeMesh *pMesh, int axis = kXAxis );
static bool RemapMaterial( CDmeMesh *pMesh, const CUtlString &src, const CUtlString &dst );
static bool RemapMaterial( CDmeMesh *pMesh, const int nMaterialIndex, const CUtlString &dst );
// Merge the specified mesh onto the first mesh under pRoot that fits it
static bool Merge( CDmeMesh *pSrcMesh, CDmElement *pRoot );
static bool Merge( CDmeMesh *pSrcMesh, CDmeMesh *pDstMesh, int nSkinningJointIndex, CUtlMap< int, int > *pJointMap = NULL );
static bool CreateDeltasFromPresets( CDmeMesh *pMesh, CDmeVertexData *pPassedDst, const CUtlStringMap< CUtlString > &presetMap, bool bPurge, const CUtlVector< CUtlString > *pPurgeAllButThese = NULL );
static bool PurgeUnusedDeltas( CDmeMesh *pMesh );
enum WrinkleOp
{
kReplace,
kAdd
};
static bool CreateWrinkleDeltaFromBaseState( CDmeVertexDeltaData *pDelta, float flScale = 1.0f, WrinkleOp wrinkleOp = kReplace, CDmeMesh *pMesh = NULL, CDmeVertexData *pBind = NULL, CDmeVertexData *pCurrent = NULL, bool bUseNormalForSign = false );
static int FindMergeSocket(
const CUtlVector< CUtlVector< CDmMeshComp::CEdge * > > &srcBorderEdgesList,
CDmeMesh *pDstMesh );
static bool Merge(
CDmMeshComp &srcComp,
const CUtlVector< CDmMeshComp::CEdge * > &edgeList,
CDmeMesh *pDstMesh );
static bool NewMerge(
CDmeMesh *pDstMesh,
CDmeMesh *pSrcMesh,
const CUtlVector< CDmMeshComp::CEdge * > &edgeList,
float flTolerance = 1.0e-4,
float flTexCoordTolerance = 1.0e-6 );
static CDmeModel *GetDmeModelFromMesh( CDmeMesh *pDmeMesh );
// Does a depth first walk of the DmeDag hierarchy specified until a DmeDag with the
// requested name is found, returns that dag if found, NULL if not found or on error
static CDmeDag *FindDagByNameInHierarchy( CDmeDag *pSearchDag, const char *pszSearchName );
// Adds the joint to the specified model by finding the common ancestor
// Duplicates the required hierarchy of the source joint
static CDmeDag *AddJointToModel( CDmeModel *pDstModel, CDmeDag *pSrcJoint );
static bool MergeMeshAndSkeleton( CDmeMesh *pDstMesh, CDmeMesh *pSrcMesh );
protected:
static const int *BuildDataMirrorMap( CDmeVertexData *pBase, int axis, CDmeVertexData::StandardFields_t standardField, CUtlVector< int > &dataMirrorMap );
static bool MirrorVertices( CDmeMesh *pMesh, CDmeVertexData *pBase, int axis, CUtlVector< int > &mirrorMap );
static bool MirrorVertices( CDmeVertexData *pBase, int axis, int nOldVertexCount, int nMirrorCount, const CUtlVector< int > &mirrorMap, const CUtlVector< int > &posMirrorMap, const CUtlVector< int > &normalMirrorMap, const CUtlVector< int > &uvMirrorMap );
static void MirrorVertices( CDmeVertexData *pBase, FieldIndex_t fieldIndex, int nOldVertexCount, int nMirrorCount, const CUtlVector< int > &baseIndices, const CUtlVector< int > &mirrorMap );
static bool MirrorDelta( CDmeVertexDeltaData *pDelta, int axis, const CUtlVector< int > &posMirrorMap, const CUtlVector< int > &normalMirrorMap, const CUtlVector< int > &uvMirrorMap );
static bool PurgeUnusedData( CDmeMesh *pMesh );
static void CreateDeltasFromPresetGroup( CDmePresetGroup *pPresetGroup, CDmeCombinationOperator * pComboOp, const CUtlVector< CUtlString > * pPurgeAllButThese, CDmeMesh * pMesh, CDmeVertexData * pDst, CUtlStringMap< CUtlString > &conflictingNames, CUtlStringMap< CDmePreset * > &presetMap );
static void PurgeUnreferencedDeltas( CDmeMesh *pMesh, CUtlStringMap< CDmePreset * > &presetMap, const CUtlVector< CUtlString > *pPurgeAllButThese, CDmeCombinationOperator *pComboOp );
};
//-----------------------------------------------------------------------------
// Iterate over all of the faces in a mesh. Use it like this:
//
// for ( CDmMeshFaceIt fIt( pMesh ); !fIt.IsDone(); fIt.Next() )
// {
// }
//-----------------------------------------------------------------------------
class CDmMeshFaceIt
{
public:
// Constructs a new face iterator for the specified mesh
CDmMeshFaceIt( const CDmeMesh *pMesh, const CDmeVertexData *pVertexData = NULL );
// Resets the iterator to the start of the specified mesh or for another iteration of the
// current mesh if the specified mesh is NULL
bool Reset( const CDmeMesh *pMesh = NULL, const CDmeVertexData *pVertexData = NULL );
// Returns the total number of faces in the mesh
int Count() const;
// The number of vertices in the face
int VertexCount() const;
// Is the iterator at the end of the mesh?
bool IsDone() const;
// Move the iterator to the next face
bool Next();
// Returns opposite sense of IsDone(), i.e. !IsDone() so true if iterator still has stuff to do
operator bool() const { return !IsDone(); }
// Prefix ++ which just calls Next() for syntax sugar
CDmMeshFaceIt &operator ++() { Next(); return *this; }
// Postfix ++ which just calls Next() for syntax sugar
CDmMeshFaceIt operator ++( int ) { const CDmMeshFaceIt thisCopy( *this ); ++( *this ); return thisCopy; }
// Gets the vertex indices for the vertices of this face
bool GetVertexIndices( int *pIndices, int nIndices ) const;
// Gets the vertex indices for the vertices of this face
bool GetVertexIndices( CUtlVector< int > &vertexIndices ) const;
// Gets the mesh relative vertex index given the face relative vertex index
int GetVertexIndex( int nFaceRelativeVertexIndex ) const;
// Gets the specified vertex data for the vertices of this face (if it exists) and the type matches
template < class T_t >
bool GetVertexData(
CUtlVector< T_t > &vertexData,
CDmeVertexDataBase::StandardFields_t nStandardField,
CDmeVertexData *pPassedBase = NULL ) const;
protected:
bool SetFaceSet();
const CDmeMesh *m_pMesh; // Current Mesh
const CDmeVertexData *m_pVertexData; // Current Vertex Data
int m_nFaceSetCount; // Number of face sets in current mesh: m_pMesh->FaceSetCount();
int m_nFaceSetIndex; // Index of current face set: [ 0, m_nFaceSetCount ]
const CDmeFaceSet *m_pFaceSet; // Current face set: m_pMesh->GetFaceSet( m_nFaceSetIndex )
int m_nFaceSetIndexCount; // Number of indices in current face set: m_pFaceSet->NumIndices();
int m_nFaceSetIndexIndex; // Index of current face set's indices: [ 0, m_nFaceSetIndexCount ]
int m_nFaceCount; // Number of faces in current mesh
int m_nFaceIndex; // The current face in the iteration [ 0, m_nFaceCount ]
};
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
template < class T_t >
inline bool CDmMeshFaceIt::GetVertexData(
CUtlVector< T_t > &vertexData,
CDmeVertexDataBase::StandardFields_t nStandardField,
CDmeVertexData *pPassedBase /* = NULL */ ) const
{
vertexData.RemoveAll();
if ( IsDone() )
return false;
CDmeVertexData *pBase = pPassedBase ? pPassedBase : m_pMesh->GetCurrentBaseState();
if ( !pBase )
return false;
const FieldIndex_t nFieldIndex = pBase->FindFieldIndex( nStandardField );
if ( nFieldIndex < 0 )
return false;
CDmAttribute *pDataAttr = pBase->GetVertexData( nFieldIndex );
if ( pDataAttr->GetType() != CDmAttributeInfo< CUtlVector< T_t > >().AttributeType() )
return false;
const CDmrArrayConst< T_t > data( pDataAttr );
const CUtlVector< int > &indices( pBase->GetVertexIndexData( nFieldIndex ) );
}
#endif // DMMESHUTILS_H