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,104 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef ANIMSETATTRIBUTEVALUE_H
#define ANIMSETATTRIBUTEVALUE_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/UtlMap.h"
#include "tier1/strtools.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmAttribute;
enum DmElementHandle_t;
//-----------------------------------------------------------------------------
// AnimationControlType
//-----------------------------------------------------------------------------
enum AnimationControlType_t
{
ANIM_CONTROL_INVALID = -1,
ANIM_CONTROL_VALUE = 0,
ANIM_CONTROL_VALUE_RIGHT,
ANIM_CONTROL_VALUE_LEFT,
ANIM_CONTROL_COUNT,
ANIM_CONTROL_TXFORM_POSITION = ANIM_CONTROL_COUNT,
ANIM_CONTROL_TXFORM_ORIENTATION,
ANIM_CONTROL_FULL_COUNT,
ANIM_CONTROL_TRANSFORM_CONTROL_COUNT = ANIM_CONTROL_FULL_COUNT - ANIM_CONTROL_COUNT,
};
struct AttributeValue_t
{
AttributeValue_t()
{
// Default values
m_pValue[ANIM_CONTROL_VALUE] = 0.0f;
m_pValue[ANIM_CONTROL_VALUE_RIGHT] = 0.0f;
m_pValue[ANIM_CONTROL_VALUE_LEFT] = 0.0f;
// Default values
m_Vector.Init();
m_Quaternion = quat_identity;
}
float m_pValue[ANIM_CONTROL_COUNT];
Vector m_Vector; // ANIM_CONTROL_TXFORM_POSITION
Quaternion m_Quaternion; // ANIM_CONTROL_TXFORM_ORIENTATION
};
struct AnimationControlAttributes_t : public AttributeValue_t
{
AnimationControlAttributes_t()
{
m_pValueAttribute[ANIM_CONTROL_VALUE] = 0;
m_pValueAttribute[ANIM_CONTROL_VALUE_RIGHT] = 0;
m_pValueAttribute[ANIM_CONTROL_VALUE_LEFT] = 0;
m_pValueAttribute[ANIM_CONTROL_TXFORM_POSITION] = 0;
m_pValueAttribute[ANIM_CONTROL_TXFORM_ORIENTATION] = 0;
m_pTimesAttribute[ANIM_CONTROL_VALUE] = 0;
m_pTimesAttribute[ANIM_CONTROL_VALUE_RIGHT] = 0;
m_pTimesAttribute[ANIM_CONTROL_VALUE_LEFT] = 0;
m_pTimesAttribute[ANIM_CONTROL_TXFORM_POSITION] = 0;
m_pTimesAttribute[ANIM_CONTROL_TXFORM_ORIENTATION] = 0;
}
void Clear()
{
// Only works because we are a class
Q_memset( this, 0, sizeof( *this ) );
m_Quaternion = quat_identity;
}
CDmAttribute* m_pValueAttribute[ ANIM_CONTROL_FULL_COUNT ];
CDmAttribute* m_pTimesAttribute[ ANIM_CONTROL_FULL_COUNT ];
};
typedef CUtlMap< DmElementHandle_t, AnimationControlAttributes_t, unsigned short > AttributeDict_t;
inline AttributeDict_t *CopyAttributeDict( AttributeDict_t *pSrc )
{
if ( !pSrc )
return NULL;
AttributeDict_t *pDest = new AttributeDict_t();
pDest->AccessTree()->CopyFrom( *pSrc->AccessTree() );
return pDest;
}
#endif // ANIMSETATTRIBUTEVALUE_H

View File

@@ -0,0 +1,59 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =====//
//
// Snapshot of
//
//===========================================================================//
#ifndef DMEANIMATIONLIST_H
#define DMEANIMATIONLIST_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeChannelsClip;
//-----------------------------------------------------------------------------
// A class representing a list of animations
//-----------------------------------------------------------------------------
class CDmeAnimationList : public CDmElement
{
DEFINE_ELEMENT( CDmeAnimationList, CDmElement );
public:
int GetAnimationCount() const;
CDmeChannelsClip *GetAnimation( int nIndex );
int FindAnimation( const char *pAnimName );
void SetAnimation( int nIndex, CDmeChannelsClip *pAnimation );
int AddAnimation( CDmeChannelsClip *pAnimation );
void RemoveAnimation( int nIndex );
private:
CDmaElementArray<CDmeChannelsClip> m_Animations;
};
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
inline int CDmeAnimationList::GetAnimationCount() const
{
return m_Animations.Count();
}
inline CDmeChannelsClip *CDmeAnimationList::GetAnimation( int nIndex )
{
return m_Animations[nIndex];
}
#endif // DMEANIMATIONLIST_H

View File

@@ -0,0 +1,339 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMEANIMATIONSET_H
#define DMEANIMATIONSET_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "movieobjects/dmephonememapping.h"
#include "movieobjects/proceduralpresets.h"
#include "movieobjects/dmecontrolgroup.h"
#include "movieobjects/dmetransformcontrol.h"
#include "tier1/utldict.h"
class CDmeDag;
class CDmeFilmClip;
class CDmeTransform;
class CDmeRig;
// names of control value attributes and single-valued (non-animated) preset value attributes
#define AS_VALUE_ATTR "value"
#define AS_VALUE_LEFT_ATTR "leftValue"
#define AS_VALUE_RIGHT_ATTR "rightValue"
#define AS_VALUE_POSITION_ATTR "valuePosition"
#define AS_VALUE_ORIENTATION_ATTR "valueOrientation"
// names of animated preset value attributes
#define AS_VALUES_ATTR "values"
#define AS_VALUES_LEFT_ATTR "leftValues"
#define AS_VALUES_RIGHT_ATTR "rightValues"
#define AS_VALUES_POSITION_ATTR "valuePositions"
#define AS_VALUES_ORIENTATION_ATTR "valueOrientations"
// names of animated preset time attributes
#define AS_TIMES_ATTR "times"
#define AS_TIMES_LEFT_ATTR "leftTimes"
#define AS_TIMES_RIGHT_ATTR "rightTimes"
#define AS_TIMES_POSITION_ATTR "timePositions"
#define AS_TIMES_ORIENTATION_ATTR "timeOrientations"
//-----------------------------------------------------------------------------
// A preset is a list of values to be applied to named controls in the animation set
//-----------------------------------------------------------------------------
class CDmePreset : public CDmElement
{
DEFINE_ELEMENT( CDmePreset, CDmElement );
public:
CDmaElementArray< CDmElement > &GetControlValues();
const CDmaElementArray< CDmElement > &GetControlValues() const;
CDmElement *FindControlValue( const char *pControlName );
CDmElement *FindOrAddControlValue( const char *pControlName );
void RemoveControlValue( const char *pControlName );
bool IsReadOnly();
void CopyControlValuesFrom( CDmePreset *pSource );
bool IsAnimated();
private:
int FindControlValueIndex( const char *pControlName );
CDmaElementArray< CDmElement > m_ControlValues;
};
class CDmeProceduralPresetSettings : public CDmElement
{
DEFINE_ELEMENT( CDmeProceduralPresetSettings, CDmElement );
public:
float GetJitterScale( DmAttributeType_t attType ) const;
float GetSmoothScale( DmAttributeType_t attType ) const;
float GetSharpenScale( DmAttributeType_t attType ) const;
float GetSoftenScale( DmAttributeType_t attType ) const;
CDmaVar< float > m_flJitterScale;
CDmaVar< float > m_flSmoothScale;
CDmaVar< float > m_flSharpenScale;
CDmaVar< float > m_flSoftenScale;
CDmaVar< float > m_flJitterScaleVector;
CDmaVar< float > m_flSmoothScaleVector;
CDmaVar< float > m_flSharpenScaleVector;
CDmaVar< float > m_flSoftenScaleVector;
CDmaVar< int > m_nJitterIterations;
CDmaVar< int > m_nSmoothIterations;
CDmaVar< int > m_nSharpenIterations;
CDmaVar< int > m_nSoftenIterations;
CDmaTime m_staggerInterval;
};
class CDmeAnimationSet;
class CDmeCombinationOperator;
//-----------------------------------------------------------------------------
// A preset group is a list of presets, with shared visibility + readonly settings
//-----------------------------------------------------------------------------
class CDmePresetGroup : public CDmElement
{
DEFINE_ELEMENT( CDmePresetGroup, CDmElement );
public:
CDmaElementArray< CDmePreset > &GetPresets(); // raw access to the array
const CDmaElementArray< CDmePreset > &GetPresets() const;
CDmePreset *FindPreset( const char *pPresetName );
CDmePreset *FindOrAddPreset( const char *pPresetName );
bool RemovePreset( CDmePreset *pPreset );
bool RemovePreset( const char *pPresetName );
void MovePresetInFrontOf( CDmePreset *pPreset, CDmePreset *pInFrontOf );
CDmaVar< bool > m_bIsVisible;
CDmaVar< bool > m_bIsReadOnly;
// Exports this preset group to a faceposer .txt expression file
bool ExportToTXT( const char *pFilename, CDmeAnimationSet *pAnimationSet = NULL, CDmeCombinationOperator *pComboOp = NULL ) const;
// Exports this preset group to a faceposer .vfe expression file
bool ExportToVFE( const char *pFilename, CDmeAnimationSet *pAnimationSet = NULL, CDmeCombinationOperator *pComboOp = NULL ) const;
private:
int FindPresetIndex( CDmePreset *pPreset );
int FindPresetIndex( const char *pPresetName );
CDmaElementArray< CDmePreset > m_Presets; // "presets"
};
//-----------------------------------------------------------------------------
// The main controlbox for controlling animation for a single model
//-----------------------------------------------------------------------------
class CDmeAnimationSet : public CDmElement
{
DEFINE_ELEMENT( CDmeAnimationSet, CDmElement );
public:
virtual void OnAttributeArrayElementAdded ( CDmAttribute *pAttribute, int nFirstElem, int nLastElem );
virtual void OnAttributeArrayElementRemoved( CDmAttribute *pAttribute, int nFirstElem, int nLastElem );
CDmaElementArray< CDmElement > &GetControls(); // raw access to the array
CDmaElementArray< CDmePresetGroup > &GetPresetGroups(); // raw access to the array
CDmaElementArray< CDmePhonemeMapping > &GetPhonemeMap(); // raw access to the array
CDmaElementArray< CDmeOperator > &GetOperators(); // raw access to the array
void RestoreDefaultPhonemeMap();
CDmePhonemeMapping *FindMapping( const char *pRawPhoneme );
// Control methods
void AddControl( CDmElement *pControl );
void RemoveControl( CDmElement *pControl );
CDmElement *FindControl( const char *pControlName ) const;
CDmElement *FindOrAddControl( const char *pControlName, bool bTransformControl, bool bMustBeNew = false );
CDmElement *CreateNewControl( const char *pControlName, bool bTransformControl );
// Methods pertaining to preset groups
CDmePresetGroup *FindPresetGroup( const char *pGroupName );
CDmePresetGroup *FindOrAddPresetGroup( const char *pGroupName );
void AddPresetGroup( CDmePresetGroup *pPresetGroup );
bool RemovePresetGroup( CDmePresetGroup *pPresetGroup );
bool RemovePresetGroup( const char *pGroupName );
void MovePresetGroupInFrontOf( CDmePresetGroup *pPresetGroup, CDmePresetGroup *pInFrontOf );
CDmePreset *FindOrAddPreset( const char *pGroupName, const char *pPresetName );
bool RemovePreset( CDmePreset *pPreset );
bool RemovePreset( const char *pPresetName );
// Get the root selection group
CDmeControlGroup *GetRootControlGroup() const;
// Find the control group with the specified name.
CDmeControlGroup *FindControlGroup( const char *pControlGroupName ) const;
// Find the control group with the specified name or add it if does not exist
CDmeControlGroup *FindOrAddControlGroup( CDmeControlGroup *pParentGroup, const char *pControlGroupName );
// Find the control with the specified name, remove it from the group it belongs to and destroy it
void RemoveControlFromGroups( char const *pchControlName, bool removeEmpty = false );
// Build a list of the root dag nodes of the animation set
void FindRootDagNodes( CUtlVector< CDmeDag* > &dagNodeList ) const;
virtual void OnElementUnserialized();
void CollectDagNodes( CUtlVector< CDmeDag* > &dagNodeList ) const;
void CollectOperators( CUtlVector< DmElementHandle_t > &operators );
void AddOperator( CDmeOperator *pOperator );
void RemoveOperator( CDmeOperator *pOperator );
void UpdateTransformDefaults() const;
private:
int FindPresetGroupIndex( CDmePresetGroup *pGroup );
int FindPresetGroupIndex( const char *pGroupName );
CDmaElementArray< CDmElement > m_Controls; // "controls"
CDmaElementArray< CDmePresetGroup > m_PresetGroups; // "presetGroups"
CDmaElementArray< CDmePhonemeMapping > m_PhonemeMap; // "phonememap"
CDmaElementArray< CDmeOperator > m_Operators; // "operators"
CDmaElement< CDmeControlGroup > m_RootControlGroup; // "rootControlGroup"
// Helper for searching for controls by name
CUtlDict< DmElementHandle_t, int > m_ControlNameMap;
};
CDmeAnimationSet *FindAnimationSetForDag( CDmeDag *pDagNode );
//-----------------------------------------------------------------------------
// Utility class to migrate from traversing all animationsets within an animationsetgroup to a filmclip
//-----------------------------------------------------------------------------
class CAnimSetGroupAnimSetTraversal
{
public:
CAnimSetGroupAnimSetTraversal( CDmeFilmClip *pFilmClip ) : m_pFilmClip( pFilmClip ), m_nIndex( 0 ) {}
void Reset( CDmeFilmClip *pFilmClip ) { m_pFilmClip = pFilmClip; m_nIndex = 0; }
bool IsValid();
CDmeAnimationSet *Next();
private:
CDmeFilmClip *m_pFilmClip;
int m_nIndex;
};
//-----------------------------------------------------------------------------
// Utility class for finding the dependencies of a control with in the
// animation set.
//-----------------------------------------------------------------------------
class CAnimSetControlDependencyMap
{
public:
// Add the controls of the specified animation set to the dependency map
void AddAnimationSet( const CDmeAnimationSet* pAnimSet );
// Get the list of controls which the specified control is dependent on.
const CUtlVector< const CDmElement * > *GetControlDepndencies( const CDmElement *pControl ) const;
private:
struct DependencyList_t
{
const CDmElement *m_pElement;
CUtlVector< const CDmElement * > m_Dependencies;
};
DependencyList_t *FindDependencyList( const CDmElement* pElement );
CUtlVector< DependencyList_t > m_DependencyData;
};
static const char DEFAULT_POSITION_ATTR[] = "defaultPosition";
static const char DEFAULT_ORIENTATION_ATTR[] = "defaultOrientation";
static const char DEFAULT_FLOAT_ATTR[] = "defaultValue";
#define MULTI_CONTROL_FORMAT_STRING "multi_%s"
typedef int ControlIndex_t;
ControlIndex_t FindComboOpControlIndexForAnimSetControl( CDmeCombinationOperator *pComboOp, const char *pControlName, bool *pIsMulti = NULL );
inline bool IsMonoControl( const CDmElement *pControl )
{
// static CUtlSymbolLarge sym = g_pDataModel->GetSymbol( "value" );
return pControl->HasAttribute( "value" );
}
inline bool IsStereoControl( const CDmElement *pControl )
{
// static CUtlSymbolLarge sym = g_pDataModel->GetSymbol( "rightValue" );
return pControl->HasAttribute( "rightValue" );
}
inline bool IsTransformControl( const CDmElement *pControl )
{
return pControl->IsA( CDmeTransformControl::GetStaticTypeSymbol() );
}
//-----------------------------------------------------------------------------
// Utility methods to convert between L/R and V/B
//-----------------------------------------------------------------------------
inline void ValueBalanceToLeftRight( float *pLeft, float *pRight, float flValue, float flBalance, float flDefaultValue )
{
*pLeft = ( flBalance <= 0.5f ) ? flValue : ( ( 1.0f - flBalance ) / 0.5f ) * ( flValue - flDefaultValue ) + flDefaultValue;
*pRight = ( flBalance >= 0.5f ) ? flValue : ( flBalance / 0.5f ) * ( flValue - flDefaultValue ) + flDefaultValue;
}
//-----------------------------------------------------------------------------
// CDmePresetGroupInfo - container for shared preset groups
//-----------------------------------------------------------------------------
class CDmePresetGroupInfo : public CDmElement
{
DEFINE_ELEMENT( CDmePresetGroupInfo, CDmElement );
public:
void LoadPresetGroups();
const char *GetFilenameBase() const { return m_filenameBase.Get(); }
void SetFilenameBase( const char *pFilenameBase ) { m_filenameBase = pFilenameBase; }
int GetPresetGroupCount() const { return m_presetGroups.Count(); }
CDmePresetGroup *GetPresetGroup( int i ) { return m_presetGroups[ i ]; }
int AddPresetGroup( CDmePresetGroup *pPresetGroup ) { return m_presetGroups.AddToTail( pPresetGroup ); }
static void FilenameBaseForModelName( const char *pModelName, char *pFileNameBase, int nFileNameBaseLen );
static CDmePresetGroupInfo *FindPresetGroupInfo( const char *pFilenameBase, CDmrElementArray< CDmePresetGroupInfo > &presetGroupInfos );
static CDmePresetGroupInfo *FindOrCreatePresetGroupInfo( const char *pFilenameBase, CDmrElementArray< CDmePresetGroupInfo > &presetGroupInfos );
static CDmePresetGroupInfo *CreatePresetGroupInfo( const char *pFilenameBase, DmFileId_t fileid );
static void LoadPresetGroups( const char *pFilenameBase, CDmaElementArray< CDmePresetGroup > &presetGroups );
protected:
CDmaString m_filenameBase; // "filenameBase"
CDmaElementArray< CDmePresetGroup > m_presetGroups; // "presetGroups"
};
#endif // DMEANIMATIONSET_H

View File

@@ -0,0 +1,47 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =====//
//
// Dme version of a model attachment point
//
//===========================================================================//
#ifndef DMEATTACHMENT_H
#define DMEATTACHMENT_H
#ifdef _WIN32
#pragma once
#endif
// Valve includes
#include "movieobjects/dmeshape.h"
#include "materialsystem/imaterialsystem.h"
#include "materialsystem/materialsystemutil.h"
//-----------------------------------------------------------------------------
// Forward Declarations
//-----------------------------------------------------------------------------
class CDmeDrawSettings;
//-----------------------------------------------------------------------------
// A class representing an attachment point
//-----------------------------------------------------------------------------
class CDmeAttachment : public CDmeShape
{
DEFINE_ELEMENT( CDmeAttachment, CDmeShape );
public:
virtual void Draw( const matrix3x4_t &shapeToWorld, CDmeDrawSettings *pDrawSettings = NULL );
CDmaVar< bool > m_bIsRigid; // Does the attachment animate?
CDmaVar< bool > m_bIsWorldAligned; // Is the attachment world-aligned?
private:
static IMaterial *sm_pMatAttachment;
CMaterialReference m_MatRefAttachment;
};
#endif // DMEATTACHMENT_H

View File

@@ -0,0 +1,58 @@
//====== Copyright © 1996-2009, Valve Corporation, All rights reserved. =======
//
// Purpose: Declaration of the CDmeAttributeReference class, a simple DmElement
// used to store references to attributes within other DmElements.
//
//=============================================================================
#ifndef DMEATTRIBUTEREFERENCE_H
#define DMEATTRIBUTEREFERENCE_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmattributevar.h"
//-------------------------------------------------------------------------------------------------
// The CDmeAttributeReference class provides storage of the information needed to access an
// attribute in any element. It also provides an interface for accessing the attribute which
// automatically looks up the attribute and caches the handle.
//-------------------------------------------------------------------------------------------------
class CDmeAttributeReference : public CDmElement
{
DEFINE_ELEMENT( CDmeAttributeReference, CDmElement );
public:
// Process notifications of changed attributes and update the attribute handles if needed.
virtual void OnAttributeChanged( CDmAttribute *pAttribute );
// Set the attribute by specifying the element, name of the attribute and optionally the array index of the attribute.
bool SetAttribute( CDmElement* pElement, const char* pchAttributeName, int index = 0 );
// Get the attribute using the cached handle or looking up the handle if needed.
CDmAttribute* GetReferencedAttribute() const;
// Get the value of the referenced attribute
const void *GetAttributeValue( DmAttributeType_t &type ) const;
// Set the value of the referenced attribute
void SetAttributeValue( const void *pValue, DmAttributeType_t type ) const;
// Determine if the attribute reference points to a valid attribute
bool IsValid() const;
private:
// Lookup and cache the attribute handle
CDmAttribute* LookupAttributeHandle() const;
CDmaElement< CDmElement > m_Element;
CDmaString m_AttributeName;
CDmaVar< int > m_AttributeIndex;
mutable DmAttributeHandle_t m_AttributeHandle;
};
#endif // DMEATTRIBUTEREFERENCE_H

View File

@@ -0,0 +1,147 @@
//============ Copyright (c) Valve Corporation, All rights reserved. ==========
//
// This is patterned after FbxAxisSystem
//
//=============================================================================
#ifndef DMEAXISSYSTEM_H
#define DMEAXISSYSTEM_H
#include "datamodel/dmelement.h"
//=============================================================================
//
// CDmeAxisSystem, an unambiguous definition of the axis system. Previously
// the terms Y Up and Z Up got thrown around a lot but they do not unambiguously
// specify a coordinate system.
//
// To define an axis system both the up axis and the parity of the axis system
// need to be specified. The parity is not an independent variable, it depends
// on the value of the up axis specified. Whichever axis is specified as the
// up axis leaves two remaining axes and even implies the first remaining
// axis, in alphabetical order, is the Forward axis.
//
// The Valve engine coordinate system has traditionally been +Z Up and
// +X as the forward axis. By specifying +Z as the up axis that leaves
// X & Y, since X is desired, that's even parity. It would be defined
// in Axis, Parity as:
//
// pDmeAxisSystem->Init( CDmeAxisSystem::AS_AXIS_Z, CDmeAxisSystem::AS_PARITY_EVEN );
//
// By default, Maya's coordinate system is +Y Up with +Z forward. Taking
// +Y as up leaves X & Z, since Z is 2nd, that's odd parity. i.e.
//
// pDmeAxisSystem->Init( CDmeAxisSystem::AS_AXIS_Y, CDmeAxisSystem::AS_PARITY_ODD );
//
//=============================================================================
class CDmeAxisSystem : public CDmElement
{
DEFINE_ELEMENT( CDmeAxisSystem, CDmElement );
public:
enum Axis_t
{
AS_AXIS_NZ = -3,
AS_AXIS_NY = -2,
AS_AXIS_NX = -1,
AS_AXIS_X = 1,
AS_AXIS_Y = 2,
AS_AXIS_Z = 3
};
enum ForwardParity_t
{
AS_PARITY_NODD = -2,
AS_PARITY_NEVEN = -1,
AS_PARITY_EVEN = 1,
AS_PARITY_ODD = 2
};
enum CoordSys_t
{
AS_RIGHT_HANDED = 0,
AS_LEFT_HANDED = 1
};
enum PredefinedAxisSystem
{
AS_INVALID = -1, // Invalid
AS_VALVE_ENGINE, // Up: +Z, Forward: +X
AS_SMD, // Up: +Z, Forward: -Y
AS_MAYA_YUP, // Up: +Y, Forward: +Z
AS_MAYA_ZUP, // Up: +Z, Forward: -Y
AS_MODO_YUP, // Up: +Y, Forward: +Z
AS_3DSMAX // Up: +Z, Forward: -Y
};
bool Init( Axis_t eUpAxis, ForwardParity_t eForwardParity, CoordSys_t eCoordSys = AS_RIGHT_HANDED );
bool Init( PredefinedAxisSystem nPredefinedAxisSystem );
// Returns true if the specified eUpAxis, eForward and eCoordSys are all valid values together
static bool IsValid( Axis_t eUpAxis, ForwardParity_t eForwardAxis, CoordSys_t eCoordSys = AS_RIGHT_HANDED );
bool IsValid() const;
// Returns the upAxis, forwardParity & coordSys for the specified predefined axisSystem
static bool GetPredefinedAxisSystem( Axis_t &eUpAxis, ForwardParity_t &eForwardParity, CoordSys_t &eCoordSys, PredefinedAxisSystem ePredefinedAxisSystem );
// Specifies whether this CDmeAxisSystem is the same as the predefined axis system specified
bool IsEqual( PredefinedAxisSystem ePredefinedAxisSystem ) const;
// Returns one of [ AS_AXIS_NX, AS_AXIS_NY, AS_AXIS_NZ, AS_AXIS_X, AS_AXIS_Y, AS_AXIS_Z ] from m_nUpAxis
Axis_t GetUpAxis() const;
// Returns one of [ AS_PARITY_NEVEN, AS_PARITY_NODD, AS_PARITY_EVEN, AS_PARITY_ODD ] from m_nForwardParity
ForwardParity_t GetForwardParity() const;
// Returns one of [ AS_LEFT_HANDED, AS_RIGHT_HANDED ] from m_nCoordSys
CoordSys_t GetCoordSys() const;
// Get the matrix to convert the identity to this axis system
static void ComputeMatrix( matrix3x4a_t &mMatrix, PredefinedAxisSystem ePredefinedAxisSystem );
// Get the matrix to convert data from the specified axis system to the specified axis system
static void GetConversionMatrix(
matrix3x4a_t &mMat,
PredefinedAxisSystem eFromAxisSystem,
PredefinedAxisSystem eToAxisSystem );
static void GetConversionMatrix( matrix3x4a_t &mMat,
Axis_t eFromUpAxis, ForwardParity_t eFromForwardParity,
Axis_t eToUpAxis, ForwardParity_t eToForwardParity );
static void GetConversionMatrix( matrix3x4a_t &mMat,
Axis_t eFromUpAxis, ForwardParity_t eFromForwardParity, CoordSys_t eFromCoordSys,
Axis_t eToUpAxis, ForwardParity_t eToForwardParity, CoordSys_t eToCoordSys );
static CUtlString GetAxisString(
Axis_t eUpAxis,
ForwardParity_t eForwardParity,
CoordSys_t eCoordSys );
protected:
// Returns one of [ AS_AXIS_X, AS_AXIS_Y, AS_AXIS_Z ] along with one of [ -1, 1 ] to indicate the sign
Axis_t GetAbsUpAxisAndSign( int &nSign ) const;
// Returns one of [ AS_PARITY_EVEN, AS_PARITY_ODD ] along with one of [ -1, 1 ] to indicate the sign
ForwardParity_t GetAbsForwardParityAndSign( int &nSign ) const;
// Returns one of [ AS_AXIS_X, AS_AXIS_Y, AS_AXIS_Z ] along with one of [ -1, 1 ] to indicate the sign
Axis_t ComputeAbsForwardAxisAndSign( int &nSign ) const;
// Returns one of [ AS_AXIS_X, AS_AXIS_Y, AS_AXIS_Z ] along with one of [ -1, 1 ] to indicate the sign
Axis_t ComputeLeftAxis( int &nSign ) const;
// Computes the matrix for the specified upAxis, forwardParity and coordSys values
static void ComputeMatrix( matrix3x4a_t &mMatrix, Axis_t eUpAxis, ForwardParity_t eForwardParity, CoordSys_t eCoordSys );
CDmaVar< int > m_nUpAxis; // [ +/- AS_AXIS_X, +/- AS_AXIS_Y, +/- AS_AXIS_Z ]
CDmaVar< int > m_nForwardParity; // [ +/- AS_PARITY_EVEN, +/- AS_PARITY_ODD ]
CDmaVar< int > m_nCoordSys; // [ AS_RIGHT_HANDED, AS_LEFT_HANDED ]
};
#endif // DMEAXISSYSTEM_H

View File

@@ -0,0 +1,49 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMEBOOKMARK_H
#define DMEBOOKMARK_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattributevar.h"
class CDmeBookmark : public CDmElement
{
DEFINE_ELEMENT( CDmeBookmark, CDmElement );
public:
const char *GetNote() const { return m_Note; }
DmeTime_t GetTime() const { return m_Time; }
DmeTime_t GetDuration() const { return m_Duration; }
void SetNote( const char *pNote ) { m_Note = pNote; }
void SetTime( DmeTime_t time ) { m_Time = time; }
void SetDuration( DmeTime_t duration ) { m_Duration = duration; }
private:
CDmaString m_Note;
CDmaTime m_Time;
CDmaTime m_Duration;
};
class CDmeBookmarkSet : public CDmElement
{
DEFINE_ELEMENT( CDmeBookmarkSet, CDmElement );
public:
const CDmaElementArray< CDmeBookmark > &GetBookmarks() const;
CDmaElementArray< CDmeBookmark > &GetBookmarks();
void ScaleBookmarkTimes( float scale );
private:
CDmaElementArray< CDmeBookmark > m_Bookmarks; // "bookmarks"
};
#endif // DMEBOOKMARK_H

View File

@@ -0,0 +1,158 @@
//======= Copyright (c) 1996-2009, Valve Corporation, All rights reserved. ======
//
// A class representing a camera
//
//===============================================================================
#ifndef DMECAMERA_H
#define DMECAMERA_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmedag.h"
enum EOrthoAxes
{
AXIS_X = 0,
AXIS_Y,
AXIS_Z,
AXIS_X_NEG,
AXIS_Y_NEG,
AXIS_Z_NEG,
AXIS_COUNT, // == 6
};
//-----------------------------------------------------------------------------
// A class representing a camera
//-----------------------------------------------------------------------------
class CDmeCamera : public CDmeDag
{
DEFINE_ELEMENT( CDmeCamera, CDmeDag );
public:
// Sets up render state in the material system for rendering
// This includes the view matrix and the projection matrix
void SetupRenderState( int nDisplayWidth, int nDisplayHeight, bool bUseEngineCoordinateSystem = false );
// accessors for generated matrices
void GetViewMatrix( VMatrix &view, bool bUseEngineCoordinateSystem = false );
void GetProjectionMatrix( VMatrix &proj, int width, int height );
void GetViewProjectionInverse( VMatrix &viewprojinv, int width, int height );
void ComputeScreenSpacePosition( const Vector &vecWorldPosition, int width, int height, Vector2D *pScreenPosition );
// Returns the x FOV (the full angle)
float GetFOVx() const;
void SetFOVx( float fov );
// Near and far Z
float GetNearZ() const;
void SetNearZ( float zNear );
float GetFarZ() const;
void SetFarZ( float zFar );
// Returns the focal distance in inches
float GetFocalDistance() const;
// Sets the focal distance in inches
void SetFocalDistance( const float &fFocalDistance );
// Zero-parallax distance for stereo rendering
float GetZeroParallaxDistance() const;
void SetZeroParallaxDistance( const float &fZeroParallaxDistance );
// Eye separation for stereo rendering
float GetEyeSeparation() const;
void SetEyeSeparation( const float &flEyeSeparation );
// Returns the aperture size in inches
float GetAperture() const;
// Returns the shutter speed in seconds
DmeTime_t GetShutterSpeed() const;
// Returns the tone map scale
float GetToneMapScale() const;
// Returns the camera's Ambient occlusion bias
float GetAOBias() const;
// Returns the camera's Ambient occlusion sgrength
float GetAOStrength() const;
// Returns the camera's Ambient occlusion radius
float GetAORadius() const;
// Returns the tone map scale
float GetBloomScale() const;
// Returns the tone map scale
float GetBloomWidth() const;
// Returns the view direction
void GetViewDirection( Vector *pDirection );
// Returns Depth of Field quality level
int GetDepthOfFieldQuality() const;
// Returns the Motion Blur quality level
int GetMotionBlurQuality() const;
// Ortho stuff
void OrthoUpdate();
const matrix3x4_t &GetOrthoTransform() const;
const Vector &GetOrthoAbsOrigin() const;
const QAngle &GetOrthoAbsAngles() const;
void FromCamera( CDmeCamera *pCamera );
void ToCamera( CDmeCamera *pCamera );
private:
// Loads the material system view matrix based on the transform
void LoadViewMatrix( bool bUseEngineCoordinateSystem );
// Loads the material system projection matrix based on the fov, etc.
void LoadProjectionMatrix( int nDisplayWidth, int nDisplayHeight );
// Sets the studiorender state
void LoadStudioRenderCameraState();
CDmaVar< float > m_flFieldOfView;
CDmaVar< float > m_zNear;
CDmaVar< float > m_zFar;
CDmaVar< float > m_flFocalDistance;
CDmaVar< float > m_flZeroParallaxDistance;
CDmaVar< float > m_flEyeSeparation;
CDmaVar< float > m_flAperture;
CDmaTime m_shutterSpeed;
CDmaVar< float > m_flToneMapScale;
CDmaVar< float > m_flAOBias;
CDmaVar< float > m_flAOStrength;
CDmaVar< float > m_flAORadius;
CDmaVar< float > m_flBloomScale;
CDmaVar< float > m_flBloomWidth;
CDmaVar< int > m_nDoFQuality;
CDmaVar< int > m_nMotionBlurQuality;
public:
CDmaVar< bool > m_bOrtho;
// Ortho vars
CDmaVar< Vector > m_vecLookAt[ AXIS_COUNT ];
CDmaVar< float > m_flScale[ AXIS_COUNT ];
CDmaVar< float > m_flDistance;
CDmaVar< int > m_nAxis;
CDmaVar< bool > m_bWasBehindFrustum;
private: // private ortho vars
Vector m_vecAxis;
Vector m_vecOrigin;
QAngle m_angRotation;
matrix3x4_t m_Transform;
};
#endif // DMECAMERA_H

View File

@@ -0,0 +1,601 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// The channel class - connects elements together, and allows for logging of data
//
//=============================================================================
#ifndef DMECHANNEL_H
#define DMECHANNEL_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/animsetattributevalue.h"
#include "movieobjects/dmeoperator.h"
#include "movieobjects/dmelog.h"
#include "movieobjects/dmedag.h"
#include "movieobjects/dmeclip.h"
#include "movieobjects/proceduralpresets.h"
#include "datamodel/idatamodel.h"
#include "datamodel/dmehandle.h"
#include "tier1/utlbuffer.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeClip;
class CDmeChannel;
class CDmeTimeSelection;
class CUndoAddRecordingLayer;
class CUndoSetTimeSelection;
void RemapFloatLogValues( CDmeChannel *pChannel, float flBias, float flScale );
CDmeChannel *FindChannelTargetingAttribute( CDmAttribute *pTargetAttr );
//-----------------------------------------------------------------------------
// different channel modes of operation
//-----------------------------------------------------------------------------
enum ChannelMode_t
{
CM_OFF,
CM_PASS,
CM_RECORD,
CM_PLAY,
};
enum PlayMode_t
{
PM_HOLD,
PM_LOOP,
};
enum RecordOperationFlags_t
{
RECORD_OPERATION_FLAG_PRESET = ( 1 << 0 ),
RECORD_OPERATION_FLAG_REVERSE = ( 1 << 1 ),
RECORD_OPERATION_FLAG_REVEAL = ( 1 << 2 ),
RECORD_OPERATION_FLAG_REBASE_TIME = ( 1 << 3 )
};
//-----------------------------------------------------------------------------
// The layer channel info structure contains information about a channel which
// is currently being modified within a recording layer.
//-----------------------------------------------------------------------------
struct LayerChannelInfo_t
{
LayerChannelInfo_t()
: m_BaseLayer( 0 )
, m_ModLayerIndex( -1 )
, m_HeadPosition( 0 )
, m_TransformWriteMode( TRANSFORM_WRITE_MODE_OVERWRITE )
, m_bManipulateInFalloff( false )
, m_ComponentFlags( LOG_COMPONENTS_ALL )
, m_pPresetValue( 0 )
, m_pPresetTimes( 0 )
, m_pRoot( 0 )
, m_pShot( 0 )
{
SetIdentityMatrix( m_Transform );
}
CDmeHandle< CDmeChannel > m_Channel;
DmeClipStack_t m_ClipStack;
CUtlBuffer m_ToAttrData; // Data of the channel's to attribute before the recording operation
CUtlBuffer m_FromAttrData; // Data of the channel's from attribute after the recording operation
int m_BaseLayer; // Index of the log layer which represents the modification layer
int m_ModLayerIndex; // Index of the channel within the modification layer
DmeTime_t m_HeadPosition; // Time position of the head when the recording operation took place
TransformWriteMode_t m_TransformWriteMode; // Specification of how existing values in the channel are to be modified
bool m_bManipulateInFalloff; // Should manipulation be applied in falloff (true), or should interpolation be used (false)
matrix3x4_t m_Transform; // Transform matrix which was applied to the log positions of the channel
Quaternion m_DeltaRotationLocal; // Delta rotation value to be used with rotation operations ( local space )
Quaternion m_DeltaRotationParent; // Delta rotation value to be used with rotation operations ( parent space )
Vector m_PivotPosition; // Pivot position value to be used with rotation operations
LogComponents_t m_ComponentFlags; // Flags specifying which individual components of the channel can be modified
const CDmAttribute *m_pPresetValue; // Pointer to the attribute storing the preset value for the operation
const CDmAttribute *m_pPresetTimes; // Pointer to the attribute storing animated preset times for the operation
CDmeClip *m_pRoot; // Pointer to the root clip (sequence) in which the operation occurs
CDmeClip *m_pShot; // Pointer to the shot clip in which the operation occurs
CDmeHandle< CDmeLogLayer, HT_STRONG > m_hRawDataLayer; // Handle to the log layer containing the raw recorded data
};
typedef void ( *FnRecordChannelCallback )( CDmeChannel *pChannel );
//-----------------------------------------------------------------------------
// The recording layer structure contains a set of channels and the information
// about a recording operation which was performed on the channels.
//-----------------------------------------------------------------------------
class CRecordingLayer
{
public:
CRecordingLayer();
~CRecordingLayer();
AttributeDict_t *m_pPresetValuesDict;
DmeTime_t m_tHeadShotTime;
int m_ProceduralType;
int m_OperationFlags;
int m_RandomSeed;
float m_flThreshold;
float m_flIntensity;
RecordingMode_t m_RecordingMode;
TimeSelection_t m_BaseTimes;
TimeSelection_t m_OriginalTimes;
CUtlVector< LayerChannelInfo_t > m_LayerChannels;
CUtlVector< KeyValues * > m_ClipboardData;
CUndoAddRecordingLayer *m_pUndoOperation;
FnRecordChannelCallback m_pfnAddChannelCallback;
FnRecordChannelCallback m_pfnFinishChannelCallback;
};
//-----------------------------------------------------------------------------
// Simple helper structure used to specify a channel and the components of the
// channel that should be modified.
//-----------------------------------------------------------------------------
class ModifyChannel
{
public:
explicit ModifyChannel( CDmeChannel *pChannel = NULL, LogComponents_t nComponentFlags = LOG_COMPONENTS_ALL )
: m_pChannel( pChannel ), m_nComponentFlags( nComponentFlags ) { }
static bool IsChannelInList( CUtlVector< ModifyChannel > const &modifyList, CDmeChannel *pChannel );
CDmeChannel *m_pChannel;
LogComponents_t m_nComponentFlags;
};
//-----------------------------------------------------------------------------
// The channel modification layer manages a group of log layer modifications
// which can be applied to a varying time range.
//-----------------------------------------------------------------------------
class CDmeChannelModificationLayer
{
public:
// Default constructor
CDmeChannelModificationLayer();
// Destructor
~CDmeChannelModificationLayer();
// Add a channel to the modification layer if it is not already present,
// adding the channel to the modification layer causes a new log layer to
// be added to the channel to which modifications will be made.
int AddChannel( CDmeChannel *pChannel, bool enableUndo );
// Add a recording layer to the modification layer.
CRecordingLayer *AddRecordingLayer();
// Remove the last recording layer from the modification layer.
void RemoveLastRecordingLayer();
// Complete the channel modification layer by flattening all the log layers of
// the active channels and clearing out the contents of the modification layer.
void Finish( bool bFlattenLayers, bool bSaveChanges, bool bRunChannelCallbacks );
// Return the modification layer of each channel to is base state.
void WipeChannelModifications();
// Get the number of recording layers in the modification layer
int NumRecordingLayers() const;
// Get a reference to the specified recording layer
CRecordingLayer &GetRecordingLayer( int index );
// Is the modification layer visible to the user
bool IsVisible() const;
// Apply the specified transform write mode all of the active channels in each of the recording layers
void UpdateTransformWriteMode( TransformWriteMode_t mode );
private:
struct ChannelRef_t
{
int m_RefCount;
CDmeHandle< CDmeChannel > m_Channel;
};
bool m_bVisible;
CUtlVector< CRecordingLayer > m_RecordingLayerStack;
CUtlVector< ChannelRef_t > m_ActiveChannels;
};
//-----------------------------------------------------------------------------
// A class managing channel recording
//-----------------------------------------------------------------------------
class CDmeChannelRecordingMgr
{
public:
// constructor
CDmeChannelRecordingMgr();
// Start and complete a modification layer. All recording layers must be placed within a modification
// layer, so a modification layer must be active before starting a recording layer.
void StartModificationLayer( const DmeLog_TimeSelection_t *pTimeSelection = NULL, bool createLayer = true );
void FinishModificationLayer( bool bSaveChanges = true, bool bFlattenLayers = true );
// Enable or disable use of the modification layer.
void EnableModificationLayer( bool enable );
// Activates, deactivates layer recording.
void StartLayerRecording( const char * const pUndoRedoDesc, AttributeDict_t *pPresetValuesDict = NULL, DmeTime_t tHeadShotTime = DMETIME_INVALID, int proceduralType = PROCEDURAL_PRESET_NOT, int recordFlags = 0, FnRecordChannelCallback pfnAddChannel = NULL, FnRecordChannelCallback pfnFinishChannel = NULL );
void FinishLayerRecording( float flThreshold, bool bFlattenLayers = true, bool bAllowFinishModification = true );
void CancelLayerRecording();
// Adds a channel to the recording layer
int AddChannelToRecordingLayer( CDmeChannel *pChannel, LogComponents_t componentWriteFlags = LOG_COMPONENTS_ALL, CDmeClip *pRoot = NULL, CDmeClip *pShot = NULL );
// Explicitly set the clipboard data for the active recording layer
void CopyClipboardDataForRecordingLayer( const CUtlVector< KeyValues * > &keyValuesList );
// Used to iterate over all channels currently being recorded
// NOTE: Use CDmeChannel::AddToRecordingLayer to add a channel to the recording layer
int GetLayerRecordingChannelCount();
CDmeChannel* GetLayerRecordingChannel( int nIndex );
// Computes time selection info in log time for a particular recorded channel
// NOTE: Only valid if IsUsingTimeSelection() returns true
void GetLocalTimeSelection( DmeLog_TimeSelection_t& selection, int nIndex );
// Get the index of the modification base layer for the specified channel within the current recording layer.
int GetModificationBaseLayer( int nIndex );
// Set the time selection for the modification layer and re-apply all recording layers that are on the current modification
// layer with the new time selection. Must be done with active modification layer, but without an active recording layer.
void SetTimeSelection( const DmeLog_TimeSelection_t &timeSelection, bool bUpdateBaseTime );
// Start or continue processing of the recording layers within the modification layer.
CRecordingLayer *ProcessModificationLayer( int &recordingLayer );
// Complete the modification layer processing for the specified recording layer.
void CompleteModificationProcessing( );
// Save the to or from attribute data of the specified channel within the current recording layer.
void StoreChannelAttributeData( int nChannelIndex, bool fromAttr );
// Get the current time selection
void GetTimeSelection( CDmeTimeSelection &timeSelection ) const;
const DmeLog_TimeSelection_t &GetTimeSelection() const;
// Methods which control various aspects of recording
void UpdateTimeAdvancing( bool bPaused, DmeTime_t tCurTime );
void UpdateRecordingChannelHeadPositions( DmeTime_t tCurTime );
void UpdateRecordingTimeSelectionTimes( const DmeLog_TimeSelection_t& timeSelection );
void SetIntensityOnAllLayers( float flIntensity );
void SetRecordingMode( RecordingMode_t mode );
void SetPresetValue( CDmeChannel* pChannel, const CDmAttribute *pPresetValue, const CDmAttribute *pPresetTimes );
void SetInRedo( bool bInRedo );
void SetProceduralTarget( int nProceduralMode, const CDmAttribute *pTarget );
void SetProceduralTarget( int nProceduralMode, const CUtlVector< KeyValues * >& list, int randomSeed );
int GetProceduralType() const;
const CDmAttribute *GetProceduralTarget() const;
const CUtlVector< KeyValues * > &GetPasteTarget() const;
void GetPasteClipboardData( CUtlVector< KeyValues * > &list ) const;
void SetModificationLayerDirty();
CDmeChannelModificationLayer *GetModificationLayer();
void SetTransformWriteMode( TransformWriteMode_t mode );
TransformWriteMode_t GetTransformWriteMode() const;
void UpdateActiveLayerManipulateInFalloff( bool bManipulateInFalloff );
static void RunFinishCallbacksOnRecordingLayer( CRecordingLayer *pRecordingLayer );
// Methods to query aspects of recording
bool IsTimeAdvancing() const;
bool IsUsingDetachedTimeSelection() const;
bool IsUsingTimeSelection() const;
bool IsRecordingLayerActive() const;
bool IsModificationLayerActive() const;
bool IsModificationLayerVisible() const;
bool IsProcessingModifications() const;
bool IsModificationLayerEnabled() const;
bool IsInRedo() const;
private:
// Methods available for CDmeChannel
bool ShouldRecordUsingTimeSelection() const;
// Internal methods
void FlattenLayers( CRecordingLayer *pRecordingLayer );
void RemoveAllChannelsFromRecordingLayer( CRecordingLayer *pRecordingLayer, bool destroyLogLayers );
// Apply the effects of the recording layer to its channels with the active time selection.
bool ApplyRecordingLayer( CRecordingLayer &recordingLayer );
// Update the time selection state, this is used by undo
void UpdateTimeSelection( const TimeSelection_t &timeSelection, const CUtlVector< TimeSelection_t > &baseTimeSelection, int leftFalloff, int rightFalloff, bool bLeftInfinite, bool bRightInfinite );
bool m_bSavedUndoState : 1;
bool m_bUseTimeSelection : 1;
bool m_bModificationLayerDirty : 1;
bool m_bModificationProcessing : 1;
bool m_bWantsToFinish : 1;
bool m_bFinishFlattenLayers : 1;
bool m_bModificationLayerEnabled : 1;
bool m_bInRedo : 1;
CRecordingLayer *m_pActiveRecordingLayer;
CDmeChannelModificationLayer *m_pModificationLayer;
DmeLog_TimeSelection_t m_TimeSelection;
int m_nProceduralType;
const CDmAttribute *m_pRevealTarget;
CUtlVector< KeyValues * > m_PasteTarget;
int m_RandomSeed;
TransformWriteMode_t m_TransformWriteMode;
friend CDmeChannel;
friend CUndoAddRecordingLayer;
friend CUndoSetTimeSelection;
};
// Singleton
extern CDmeChannelRecordingMgr *g_pChannelRecordingMgr;
struct TimeState_t
{
TimeState_t() : m_timeOutsideTimeframe( DMETIME_INVALID ), m_tCurrentTime( DMETIME_INVALID ), m_tPreviousTime( DMETIME_INVALID )
{
}
DmeTime_t m_timeOutsideTimeframe;
DmeTime_t m_tCurrentTime;
DmeTime_t m_tPreviousTime;
};
//-----------------------------------------------------------------------------
// A class representing a channel
//-----------------------------------------------------------------------------
class CDmeChannel : public CDmeOperator
{
DEFINE_ELEMENT( CDmeChannel, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
void SetInput ( CDmElement* pElement, const char* pAttribute, int index = 0 );
void SetOutput( CDmElement* pElement, const char* pAttribute, int index = 0 );
void SetInput( CDmAttribute *pAttribute, int index = 0 );
void SetOutput( CDmAttribute *pAttribute, int index = 0 );
CDmElement *GetFromElement() const;
CDmElement *GetToElement() const;
CDmAttribute *GetFromAttribute();
CDmAttribute *GetToAttribute();
int GetFromArrayIndex() const;
int GetToArrayIndex() const;
int GetRecordLayerIndex() const;
void SetRecordLayerIndex( int layerIndex );
ChannelMode_t GetMode();
void SetMode( ChannelMode_t mode );
void ClearLog();
CDmeLog *GetLog();
void SetLog( CDmeLog *pLog );
CDmeLog *CreateLog( DmAttributeType_t type );
template < class T > CDmeTypedLog<T> *CreateLog();
void ClearTimeMetric();
void SetCurrentTime( DmeTime_t time, DmeTime_t start, DmeTime_t end );
void SetCurrentTime( DmeTime_t time ); // Simple version. Only works if multiple active channels clips do not reference the same channels
DmeTime_t GetCurrentTime() const;
const TimeState_t &GetTimeState() const;
void SetTimeState( TimeState_t &TimeState );
void SetChannelToPlayToSelf( const char *outputAttributeName, float defaultValue, bool force = false );
template< class T >
void SetValueOnInput( const T &value );
// need this until we have the EditApply message queue
void OnAttributeChanged( CDmAttribute *pAttribute );
template< class T >
bool GetInputValue( T &value );
template< class T >
bool GetOutputValue( T &value );
template< class T >
bool GetCurrentPlaybackValue( T& value );
template< class T >
bool GetPlaybackValueAtTime( DmeTime_t time, T& value );
void Play( bool useEmptyLog = false );
void Record();
void SetNextKeyCurveType( int nCurveType );
// Builds a clip stack for the channel
CDmeClip* FindOwnerClipForChannel( CDmeClip *pRoot );
bool BuildClipStack( DmeClipStack_t *pClipStack, CDmeClip *pRoot, CDmeClip *pShot ) const;
void ScaleSampleTimes( float scale );
void ClearAndAddSampleAtTime( DmeTime_t time );
protected:
// Used to cache off handles to attributes
CDmAttribute* SetupFromAttribute();
CDmAttribute* SetupToAttribute();
template< class T >
bool GetValue( T &value, const CDmAttribute *pAttr, int nIndex );
void Pass();
CDmaElement< CDmElement > m_fromElement;
CDmaString m_fromAttribute;
CDmaVar< int > m_fromIndex;
CDmaElement< CDmElement > m_toElement;
CDmaString m_toAttribute;
CDmaVar< int > m_toIndex;
CDmaVar< int > m_mode;
CDmaElement< CDmeLog > m_log;
DmAttributeHandle_t m_FromAttributeHandle;
DmAttributeHandle_t m_ToAttributeHandle;
TimeState_t m_TimeState;
int m_nRecordLayerIndex;
int m_nNextCurveType;
};
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
template < class T >
inline CDmeTypedLog<T> *CDmeChannel::CreateLog()
{
return CastElement< CDmeTypedLog<T> >( CreateLog( CDmAttributeInfo<T>::AttributeType() ) );
}
inline CDmAttribute *CDmeChannel::GetFromAttribute()
{
CDmAttribute *pAttribute = g_pDataModel->GetAttribute( m_FromAttributeHandle );
if ( !pAttribute )
{
pAttribute = SetupFromAttribute();
}
return pAttribute;
}
inline CDmAttribute *CDmeChannel::GetToAttribute()
{
CDmAttribute *pAttribute = g_pDataModel->GetAttribute( m_ToAttributeHandle );
if ( !pAttribute )
{
pAttribute = SetupToAttribute();
}
return pAttribute;
}
template< class T >
inline bool CDmeChannel::GetPlaybackValueAtTime( DmeTime_t time, T& value )
{
CDmeTypedLog< T > *pLog = CastElement< CDmeTypedLog< T > >( GetLog() );
if ( !pLog || pLog->IsEmpty() )
return false;
DmeTime_t t0 = pLog->GetBeginTime();
DmeTime_t tn = pLog->GetEndTime();
PlayMode_t pmode = PM_HOLD;
switch ( pmode )
{
case PM_HOLD:
time = clamp( time, t0, tn );
break;
case PM_LOOP:
if ( tn == t0 )
{
time = t0;
}
else
{
time -= t0;
time = time % ( tn - t0 );
time += t0;
}
break;
}
value = pLog->GetValue( time );
return true;
}
template< class T >
inline bool CDmeChannel::GetValue( T &value, const CDmAttribute *pAttr, int nIndex )
{
if ( pAttr )
{
if ( IsArrayType( pAttr->GetType() ) )
{
CDmrArrayConst< T > array( pAttr );
if ( nIndex >= 0 && nIndex < array.Count() )
{
value = array[ nIndex ];
return true;
}
}
else
{
value = pAttr->GetValue< T >();
return true;
}
}
CDmAttributeInfo< T >::SetDefaultValue( value );
return false;
}
template< class T >
inline bool CDmeChannel::GetInputValue( T &value )
{
return GetValue< T >( value, GetFromAttribute(), m_fromIndex );
}
template< class T >
inline bool CDmeChannel::GetOutputValue( T &value )
{
return GetValue< T >( value, GetToAttribute(), m_toIndex );
}
template< class T >
inline bool CDmeChannel::GetCurrentPlaybackValue( T& value )
{
return GetPlaybackValueAtTime( GetCurrentTime(), value );
}
template< class T >
void CDmeChannel::SetValueOnInput( const T &value )
{
CDmAttribute *pFromAttr = GetFromAttribute();
if ( !pFromAttr )
return;
if ( IsArrayType( pFromAttr->GetType() ) )
{
if ( ArrayTypeToValueType( pFromAttr->GetType() ) != CDmAttributeInfo< T >::AttributeType() )
return;
CDmrArray< T > array( pFromAttr );
array.Set( m_fromIndex.Get(), value );
}
else
{
if ( pFromAttr->GetType() != CDmAttributeInfo< T >::AttributeType() )
return;
pFromAttr->SetValue( value );
}
}
#endif // DMECHANNEL_H

View File

@@ -0,0 +1,652 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMECLIP_H
#define DMECLIP_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "datamodel/dmehandle.h"
#include "avi/iavi.h"
#include "materialsystem/materialsystemutil.h"
#include "tier1/utlmap.h"
#include "videocache/iremotevideomaterial.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeClip;
class CDmeTimeFrame;
class CDmeBookmark;
class CDmeBookmarkSet;
class CDmeSound;
class CDmeChannel;
class CDmeCamera;
class CDmeDag;
class CDmeInput;
class CDmeOperator;
class CDmeMaterial;
class CDmeTrack;
class CDmeTrackGroup;
class IMaterial;
class CDmeChannelsClip;
class CDmeAnimationSet;
class CDmeMaterialOverlayFXClip;
class DmeLog_TimeSelection_t;
struct TimeSelection_t;
struct Rect_t;
enum ChannelMode_t;
enum DmeClipSkipFlag_t
{
DMESKIP_NONE = 0,
DMESKIP_MUTED = 1,
DMESKIP_INVISIBLE = 2,
};
DEFINE_ENUM_BITWISE_OPERATORS( DmeClipSkipFlag_t )
//-----------------------------------------------------------------------------
// Clip types
//-----------------------------------------------------------------------------
enum DmeClipType_t
{
DMECLIP_UNKNOWN = -1,
DMECLIP_FIRST = 0,
DMECLIP_CHANNEL = 0,
DMECLIP_SOUND,
DMECLIP_FX,
DMECLIP_FILM,
DMECLIP_LAST = DMECLIP_FILM,
DMECLIP_TYPE_COUNT
};
DEFINE_ENUM_INCREMENT_OPERATORS( DmeClipType_t )
struct DmeClipStack_t
{
public:
DmeClipStack_t() : m_bOptimized( false ) {}
DmeClipStack_t( const CDmeClip *pRoot, CDmeClip *pShot, CDmeClip *pClip ) { BuildClipStack( pRoot, pShot, pClip ); }
int GetClipCount() const { return m_clips.Count(); }
const CDmeClip *GetClip( int i ) const { return m_clips[ i ]; }
CDmeClip *GetClip( int i ) { return m_clips[ i ]; }
int FindClip( const CDmeClip *pClip ) const;
int InvalidClipIndex() const { return m_clips.InvalidIndex(); }
bool BuildClipStack( const CDmeClip *pRoot, const CDmeClip *pShot, const CDmeClip *pClip );
int AddClipToHead( const CDmeClip *pClip );
int AddClipToTail( const CDmeClip *pClip );
void RemoveClip( int i ) { m_clips.Remove( i ); m_bOptimized = false; }
void RemoveAll() { m_clips.RemoveAll(); m_bOptimized = false; }
DmeTime_t ToChildMediaTime ( DmeTime_t t, bool bClamp = true ) const;
DmeTime_t FromChildMediaTime( DmeTime_t t, bool bClamp = true ) const;
DmeTime_t ToChildMediaDuration ( DmeTime_t t ) const;
DmeTime_t FromChildMediaDuration( DmeTime_t t ) const;
void ToChildMediaTime( TimeSelection_t &params ) const;
protected:
// Given a root clip and a child (or grandchild) clip, builds the stack
// from root on down to the destination clip. If shot is specified, then it
// must build a clip stack that passes through the shot
bool BuildClipStack_R( const CDmeClip *pMovie, const CDmeClip *pShot, const CDmeClip *pCurrent );
CUtlVector< CDmeHandle< CDmeClip > > m_clips;
mutable DmeTime_t m_tStart;
mutable DmeTime_t m_tDuration;
mutable DmeTime_t m_tOffset;
mutable double m_flScale;
mutable bool m_bOptimized;
void Optimize() const;
};
//-----------------------------------------------------------------------------
// Is a particular clip type non-overlapping?
//-----------------------------------------------------------------------------
inline bool IsNonoverlapping( DmeClipType_t type )
{
return ( type == DMECLIP_FILM );
}
//-----------------------------------------------------------------------------
// String to clip type + back
//-----------------------------------------------------------------------------
DmeClipType_t ClipTypeFromString( const char *pName );
const char *ClipTypeToString( DmeClipType_t type );
//-----------------------------------------------------------------------------
// Used to move clips in non-film track groups with film clips
//-----------------------------------------------------------------------------
struct ClipAssociation_t
{
enum AssociationType_t
{
HAS_CLIP = 0,
BEFORE_START,
AFTER_END,
NO_MOVEMENT,
};
AssociationType_t m_nType;
CDmeHandle< CDmeClip > m_hClip;
CDmeHandle< CDmeClip > m_hAssociation;
DmeTime_t m_startTimeInAssociatedClip; // used for HAS_CLIP
DmeTime_t m_offset; // used for BEFORE_START and AFTER_END
};
//-----------------------------------------------------------------------------
// Constructor, destructor
//-----------------------------------------------------------------------------
class CDmeClip : public CDmElement
{
DEFINE_ELEMENT( CDmeClip, CDmElement );
public:
// Returns the time frame
CDmeTimeFrame *GetTimeFrame() const;
DmeTime_t ToChildMediaTime ( DmeTime_t t, bool bClamp = true ) const;
DmeTime_t FromChildMediaTime( DmeTime_t t, bool bClamp = true ) const;
DmeTime_t ToChildMediaDuration ( DmeTime_t dt ) const;
DmeTime_t FromChildMediaDuration( DmeTime_t dt ) const;
DmeTime_t GetStartTime() const;
DmeTime_t GetEndTime() const;
DmeTime_t GetDuration() const;
DmeTime_t GetTimeOffset() const;
DmeTime_t GetStartInChildMediaTime() const;
DmeTime_t GetEndInChildMediaTime() const;
float GetTimeScale() const;
void SetStartTime ( DmeTime_t t );
void SetDuration ( DmeTime_t t );
void SetTimeOffset( DmeTime_t t );
void SetTimeScale ( float s );
virtual void BakeTimeScale( float scale = 1.0f );
// Given a root clip and a child (or grandchild) clip, builds the stack
// from root on down to the destination clip. If shot is specified, then it
// must build a clip stack that passes through the shot
bool BuildClipStack( DmeClipStack_t* pStack, const CDmeClip *pRoot, CDmeClip *pShot = NULL );
void SetClipColor( const Color& clr );
Color GetClipColor() const;
void SetClipText( const char *pText );
const char* GetClipText() const;
// Clip type
virtual DmeClipType_t GetClipType() { return DMECLIP_UNKNOWN; }
// Track group iteration methods
int GetTrackGroupCount() const;
CDmeTrackGroup *GetTrackGroup( int nIndex ) const;
const CUtlVector< DmElementHandle_t > &GetTrackGroups( ) const;
// Track group addition/removal
void AddTrackGroup( CDmeTrackGroup *pTrackGroup );
void AddTrackGroupBefore( CDmeTrackGroup *pTrackGroup, CDmeTrackGroup *pBefore );
CDmeTrackGroup *AddTrackGroup( const char *pTrackGroupName );
void RemoveTrackGroup( int nIndex );
void RemoveTrackGroup( CDmeTrackGroup *pTrackGroup );
void RemoveTrackGroup( const char *pTrackGroupName );
// Track group finding
CDmeTrackGroup *FindTrackGroup( const char *pTrackGroupName ) const;
int GetTrackGroupIndex( CDmeTrackGroup *pTrack ) const;
CDmeTrackGroup *FindOrAddTrackGroup( const char *pTrackGroupName );
// Swap track groups
void SwapOrder( CDmeTrackGroup *pTrackGroup1, CDmeTrackGroup *pTrackGroup2 );
// Clip finding
virtual CDmeTrack *FindTrackForClip( CDmeClip *pClip, CDmeTrackGroup **ppTrackGroup = NULL ) const;
bool FindMultiTrackGroupForClip( CDmeClip *pClip, int *pTrackGroupIndex, int *pTrackIndex = NULL, int *pClipIndex = NULL ) const;
// Finding clips in tracks by time
virtual void FindClipsAtTime( DmeClipType_t clipType, DmeTime_t time, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
virtual void FindClipsIntersectingTime( DmeClipType_t clipType, DmeTime_t startTime, DmeTime_t endTime, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
virtual void FindClipsWithinTime ( DmeClipType_t clipType, DmeTime_t startTime, DmeTime_t endTime, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
// Is a particular clip typed able to be added?
bool IsSubClipTypeAllowed( DmeClipType_t type ) const;
// Returns the special film track group
virtual CDmeTrackGroup *GetFilmTrackGroup() const { return NULL; }
virtual CDmeTrack *GetFilmTrack() const { return NULL; }
// Checks for muteness
void SetMute( bool state );
bool IsMute( ) const;
// Clip vertical display size
void SetDisplayScale( float flDisplayScale );
float GetDisplayScale() const;
protected:
virtual int AllowedClipTypes() const { return 1 << DMECLIP_CHANNEL; }
// Is a track group valid to add?
bool IsTrackGroupValid( CDmeTrackGroup *pTrackGroup );
CDmaElementArray< CDmeTrackGroup > m_TrackGroups;
CDmaElement< CDmeTimeFrame > m_TimeFrame;
CDmaVar< Color > m_ClipColor;
CDmaVar< bool > m_bMute;
CDmaVar< float > m_flDisplayScale;
CDmaString m_ClipText;
};
inline bool CDmeClip::IsSubClipTypeAllowed( DmeClipType_t type ) const
{
return ( AllowedClipTypes() & ( 1 << type ) ) != 0;
}
inline void CDmeClip::SetMute( bool state )
{
m_bMute = state;
}
inline bool CDmeClip::IsMute( ) const
{
return m_bMute;
}
//-----------------------------------------------------------------------------
// Clip vertical display size
//-----------------------------------------------------------------------------
inline void CDmeClip::SetDisplayScale( float flDisplayScale )
{
m_flDisplayScale = flDisplayScale;
}
inline float CDmeClip::GetDisplayScale() const
{
return m_flDisplayScale;
}
//-----------------------------------------------------------------------------
// Sound clip
//-----------------------------------------------------------------------------
class CDmeSoundClip : public CDmeClip
{
DEFINE_ELEMENT( CDmeSoundClip, CDmeClip );
public:
virtual DmeClipType_t GetClipType() { return DMECLIP_SOUND; }
void SetShowWave( bool state );
bool ShouldShowWave( ) const;
void SetFadeTimes( DmeTime_t fadeIn, DmeTime_t fadeOut ) { m_fadeInDuration = fadeIn; m_fadeOutDuration = fadeOut; }
void SetFadeInTime( DmeTime_t t ) { m_fadeInDuration = t; }
void SetFadeOutTime( DmeTime_t t ) { m_fadeOutDuration = t; }
DmeTime_t GetFadeInTime() const { return m_fadeInDuration; }
DmeTime_t GetFadeOutTime() const { return m_fadeOutDuration; }
float GetVolumeFade( DmeTime_t tParent );
virtual void BakeTimeScale( float scale = 1.0f );
CDmaElement< CDmeSound > m_Sound;
CDmaVar< bool > m_bShowWave;
CDmaTime m_fadeInDuration;
CDmaTime m_fadeOutDuration;
};
//-----------------------------------------------------------------------------
// Clip containing recorded data from the game
//-----------------------------------------------------------------------------
class CDmeChannelsClip : public CDmeClip
{
DEFINE_ELEMENT( CDmeChannelsClip, CDmeClip );
public:
virtual DmeClipType_t GetClipType() { return DMECLIP_CHANNEL; }
virtual void BakeTimeScale( float scale = 1.0f );
CDmeChannel *CreatePassThruConnection
(
char const *passThruName,
CDmElement *pFrom,
char const *pFromAttribute,
CDmElement *pTo,
char const *pToAttribute,
int index = 0
);
void RemoveChannel( CDmeChannel *pChannel );
// Set the mode of all of the channels in the clip
void SetChannelMode( const ChannelMode_t &mode );
// Operate all of the channels in the clip
void OperateChannels();
// Play all of the channels in the clip
void PlayChannels();
CDmaElementArray< CDmeChannel > m_Channels;
};
//-----------------------------------------------------------------------------
// An effect clip
//-----------------------------------------------------------------------------
class CDmeFXClip : public CDmeClip
{
DEFINE_ELEMENT( CDmeFXClip, CDmeClip );
public:
virtual DmeClipType_t GetClipType() { return DMECLIP_FX; }
enum
{
MAX_FX_INPUT_TEXTURES = 3
};
// All effects must be able to apply their effect
virtual void ApplyEffect( DmeTime_t time, Rect_t &currentRect, Rect_t &totalRect, ITexture *pTextures[MAX_FX_INPUT_TEXTURES] ) {}
// Global list of FX clip types
static void InstallFXClipType( const char *pElementType, const char *pDescription );
static int FXClipTypeCount();
static const char *FXClipType( int nIndex );
static const char *FXClipDescription( int nIndex );
private:
enum
{
MAX_FXCLIP_TYPES = 16
};
static const char *s_pFXClipTypes[MAX_FXCLIP_TYPES];
static const char *s_pFXClipDescriptions[MAX_FXCLIP_TYPES];
static int s_nFXClipTypeCount;
};
//-----------------------------------------------------------------------------
// Helper Template factory for simple creation of factories
//-----------------------------------------------------------------------------
template <class T>
class CDmFXClipFactory : public CDmElementFactory<T>
{
public:
CDmFXClipFactory( const char *pLookupName, const char *pDescription ) : CDmElementFactory<T>( pLookupName )
{
CDmeFXClip::InstallFXClipType( pLookupName, pDescription );
}
};
//-----------------------------------------------------------------------------
// All effects must use IMPLEMENT_FX_CLIP_ELEMENT_FACTORY instead of IMPLEMENT_ELEMENT_FACTORY
//-----------------------------------------------------------------------------
#if defined( MOVIEOBJECTS_LIB ) || defined ( DATAMODEL_LIB ) || defined ( DMECONTROLS_LIB )
#define IMPLEMENT_FX_CLIP_ELEMENT_FACTORY( lookupName, className, description ) \
IMPLEMENT_ELEMENT( className ) \
CDmFXClipFactory< className > g_##className##_Factory( #lookupName, description ); \
CDmElementFactoryHelper g_##className##_Helper( #lookupName, &g_##className##_Factory, true ); \
className *g_##className##LinkerHack = NULL;
#else
#define IMPLEMENT_FX_CLIP_ELEMENT_FACTORY( lookupName, className, description ) \
IMPLEMENT_ELEMENT( className ) \
CDmFXClipFactory< className > g_##className##_Factory( #lookupName, description ); \
CDmElementFactoryHelper g_##className##_Helper( #lookupName, &g_##className##_Factory, false ); \
className *g_##className##LinkerHack = NULL;
#endif
//-----------------------------------------------------------------------------
// Film clip
//-----------------------------------------------------------------------------
class CDmeFilmClip : public CDmeClip
{
DEFINE_ELEMENT( CDmeFilmClip, CDmeClip );
public:
virtual DmeClipType_t GetClipType() { return DMECLIP_FILM; }
virtual void BakeTimeScale( float scale = 1.0f );
// Attribute changed
virtual void OnElementUnserialized( );
virtual void OnAttributeChanged( CDmAttribute *pAttribute );
// Resolve
virtual void Resolve();
// Returns the special film track group
virtual CDmeTrackGroup *GetFilmTrackGroup() const;
virtual CDmeTrack *GetFilmTrack() const;
CDmeTrackGroup *FindOrCreateFilmTrackGroup();
CDmeTrack *FindOrCreateFilmTrack();
// Clip finding
virtual CDmeTrack *FindTrackForClip( CDmeClip *pClip, CDmeTrackGroup **ppTrackGroup = NULL ) const;
// Finding clips in tracks by time
virtual void FindClipsAtTime( DmeClipType_t clipType, DmeTime_t time, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
virtual void FindClipsIntersectingTime( DmeClipType_t clipType, DmeTime_t startTime, DmeTime_t endTime, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
virtual void FindClipsWithinTime ( DmeClipType_t clipType, DmeTime_t startTime, DmeTime_t endTime, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
// mapname helper methods
const char *GetMapName();
void SetMapName( const char *pMapName );
// Returns the camera associated with the clip
CDmeCamera *GetCamera();
void SetCamera( CDmeCamera *pCamera );
// Audio volume
void SetVolume( float state );
float GetVolume() const;
int GetConCommandCount() const;
const char *GetConCommand( int i ) const;
int GetConVarCount() const;
const char *GetConVar( int i ) const;
// Returns the monitor camera associated with the clip (for now, only 1 supported)
CDmeCamera *GetMonitorCamera();
void AddMonitorCamera( CDmeCamera *pCamera );
void RemoveMonitorCamera( CDmeCamera *pCamera );
void SelectMonitorCamera( CDmeCamera *pCamera );
int FindMonitorCamera( CDmeCamera *pCamera );
// Scene / Dag helper methods
void SetScene( CDmeDag *pDag );
CDmeDag *GetScene( bool bCreateIfNull = false );
// helper for inputs and operators
int GetInputCount();
CDmeInput *GetInput( int nIndex );
void AddInput( CDmeInput *pInput );
void RemoveAllInputs();
void AddOperator( CDmeOperator *pOperator );
void RemoveOperator( CDmeOperator *pOperator );
void CollectOperators( CUtlVector< DmElementHandle_t > &operators );
CDmaElementArray< CDmeOperator > &GetOperators();
// Helper for overlays
// FIXME: Change this to use CDmeMaterials
IMaterial *GetOverlayMaterial();
void SetOverlay( const char *pMaterialName );
float GetOverlayAlpha();
void SetOverlayAlpha( float alpha );
void DrawOverlay( DmeTime_t time, Rect_t &currentRect, Rect_t &totalRect );
bool HasOpaqueOverlay();
// AVI tape out
void UseCachedVersion( bool bUseCachedVersion );
bool IsUsingCachedVersion() const;
AVIMaterial_t GetCachedAVI();
void SetCachedAVI( const char *pAVIFile );
void AssignRemoteVideoMaterial( IRemoteVideoMaterial *theMaterial );
void UpdateRemoteVideoMaterialStatus();
bool HasRemoteVideo();
bool GetCachedQTVideoFrameAt( float timeInSec );
IMaterial *GetRemoteVideoMaterial();
void GetRemoteVideoMaterialTexCoordRange( float *u, float *v );
CDmaElementArray< CDmeAnimationSet > &GetAnimationSets(); // raw access to the array
const CDmaElementArray< CDmeAnimationSet > &GetAnimationSets() const;
CDmeAnimationSet *FindAnimationSet( const char *pAnimSetName ) const;
const CDmaElementArray< CDmeBookmarkSet > &GetBookmarkSets() const;
CDmaElementArray< CDmeBookmarkSet > &GetBookmarkSets();
int GetActiveBookmarkSetIndex() const;
void SetActiveBookmarkSetIndex( int nActiveBookmarkSet );
CDmeBookmarkSet *GetActiveBookmarkSet();
CDmeBookmarkSet *CreateBookmarkSet( const char *pName = "default set" );
void SetFadeTimes( DmeTime_t fadeIn, DmeTime_t fadeOut ) { m_fadeInDuration = fadeIn; m_fadeOutDuration = fadeOut; }
void SetFadeInTime( DmeTime_t t ) { m_fadeInDuration = t; }
void SetFadeOutTime( DmeTime_t t ) { m_fadeOutDuration = t; }
DmeTime_t GetFadeInTime() const { return m_fadeInDuration; }
DmeTime_t GetFadeOutTime() const { return m_fadeOutDuration; }
// Used to move clips in non-film track groups with film clips
// Call BuildClipAssociations before modifying the film track,
// then UpdateAssociatedClips after modifying it.
void BuildClipAssociations( CUtlVector< ClipAssociation_t > &association, bool bHandleGaps = true );
void UpdateAssociatedClips( CUtlVector< ClipAssociation_t > &association );
void LatchWorkCamera( CDmeCamera *pCamera );
void UpdateWorkCamera( CDmeCamera *pCamera );
void PreviousWorkCamera();
void NextWorkCamera();
CDmeCamera *GetCurrentCameraStackEntry();
void PurgeCameraStack();
private:
virtual int AllowedClipTypes() const { return (1 << DMECLIP_CHANNEL) | (1 << DMECLIP_SOUND) | (1 << DMECLIP_FX) | (1 << DMECLIP_FILM); }
CDmaElement< CDmeTrackGroup > m_FilmTrackGroup;
CDmaString m_MapName;
CDmaElement < CDmeCamera > m_Camera;
CDmaElementArray< CDmeCamera > m_MonitorCameras;
CDmaVar< int > m_nActiveMonitor;
CDmaElement < CDmeDag > m_Scene;
CDmaElementArray< CDmeInput > m_Inputs;
CDmaElementArray< CDmeOperator > m_Operators;
CDmaString m_AVIFile;
CDmaTime m_fadeInDuration;
CDmaTime m_fadeOutDuration;
CDmaElement< CDmeMaterialOverlayFXClip >m_MaterialOverlayEffect;
CDmaVar< bool > m_bIsUsingCachedVersion;
CDmaElementArray< CDmeAnimationSet > m_AnimationSets; // "animationSets"
CDmaElementArray< CDmeBookmarkSet > m_BookmarkSets; // "bookmarkSets"
CDmaVar< int > m_nActiveBookmarkSet; // "activeBookmarkSet"
CDmaVar< float > m_Volume;
CDmaStringArray m_ConCommands;
CDmaStringArray m_ConVars;
AVIMaterial_t m_hCachedVersion;
bool m_bReloadCachedVersion;
CMaterialReference m_FadeMaterial;
CDmaElementArray< CDmeCamera > m_CameraStack;
int m_nCurrentStackCamera;
IRemoteVideoMaterial *m_pRemoteVideoMaterial;
};
//-----------------------------------------------------------------------------
// Fast type conversions
//-----------------------------------------------------------------------------
inline bool IsFilmClip( CDmeClip *pClip )
{
return pClip && pClip->IsA( CDmeFilmClip::GetStaticTypeSymbol() );
}
//-----------------------------------------------------------------------------
// Creates a slug clip
//-----------------------------------------------------------------------------
CDmeFilmClip *CreateSlugClip( const char *pClipName, DmeTime_t startTime, DmeTime_t endTime, DmFileId_t fileid );
//-----------------------------------------------------------------------------
// For use in template functions
//-----------------------------------------------------------------------------
template <class T>
class CDmeClipInfo
{
public:
static DmeClipType_t ClipType( ) { return DMECLIP_UNKNOWN; }
};
#define DECLARE_DMECLIP_TYPE( _className, _dmeClipType ) \
template< > class CDmeClipInfo< _className > \
{ \
public: \
static DmeClipType_t ClipType() { return _dmeClipType; } \
};
DECLARE_DMECLIP_TYPE( CDmeSoundClip, DMECLIP_SOUND )
DECLARE_DMECLIP_TYPE( CDmeChannelsClip, DMECLIP_CHANNEL )
DECLARE_DMECLIP_TYPE( CDmeFXClip, DMECLIP_FX )
DECLARE_DMECLIP_TYPE( CDmeFilmClip, DMECLIP_FILM )
#define DMECLIP_TYPE( _className ) CDmeClipInfo<T>::ClipType()
//-----------------------------------------------------------------------------
// helper methods
//-----------------------------------------------------------------------------
CDmeTrack *GetParentTrack( CDmeClip *pClip );
CDmeChannel *FindChannelTargetingElement( CDmElement *pElement, const char *pAttributeName = NULL );
CDmeChannel *FindChannelTargetingElement( CDmeChannelsClip *pChannelsClip, CDmElement *pElement, const char *pAttributeName = NULL );
CDmeChannel *FindChannelTargetingElement( CDmeFilmClip *pClip, CDmElement *pElement, const char *pAttributeName, CDmeChannelsClip **ppChannelsClip, CDmeTrack **ppTrack = NULL, CDmeTrackGroup **ppTrackGroup = NULL );
CDmeFilmClip *FindFilmClipContainingDag( CDmeDag *pDag );
void BuildClipStackList( const CUtlVector< CDmeChannel* > &channelList, CUtlVector< DmeClipStack_t > &clipStackList, CUtlVector< DmeTime_t > &orginalTimeList, const CDmeClip *pMovie, CDmeClip *pShot );
void PlayChannelsAtTime( DmeTime_t time, const CUtlVector< CDmeChannel* > &channelList, const CUtlVector< CDmeOperator* > &operatorList, const CUtlVector< DmeClipStack_t > &clipStackList, bool forcePlay = true );
void PlayChannelsAtLocalTimes( const CUtlVector< DmeTime_t > &timeList, const CUtlVector< CDmeChannel* > &channelList, const CUtlVector< CDmeOperator* > &operatorList, bool forcePlay = true );
#endif // DMECLIP_H

View File

@@ -0,0 +1,453 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// Operators that generate combinations
//
//=============================================================================
#ifndef DMECOMBINATIONOPERATOR_H
#define DMECOMBINATIONOPERATOR_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "movieobjects/dmeoperator.h"
#include "movieobjects/dmeexpressionoperator.h"
#include "datamodel/dmehandle.h"
//-----------------------------------------------------------------------------
// Expression operator
//-----------------------------------------------------------------------------
class CDmeChannel;
class CDmeDag;
class CDmElement;
class CDmeChannelsClip;
class CDmeShape;
//-----------------------------------------------------------------------------
// Control handles
//-----------------------------------------------------------------------------
typedef int ControlIndex_t;
//-----------------------------------------------------------------------------
// Basic version..
//-----------------------------------------------------------------------------
class CDmeCombinationInputControl : public CDmElement
{
DEFINE_ELEMENT( CDmeCombinationInputControl, CDmElement );
public:
virtual void OnElementUnserialized();
// Adds a control, returns the control index,
// returns true if remapped control lists need updating
bool AddRawControl( const char *pRawControlName );
// Removes controls
// returns true if remapped control lists need updating
bool RemoveRawControl( const char *pRawControlName );
void RemoveAllRawControls();
// Iterates remapped controls
int RawControlCount() const;
const char *RawControlName( int nIndex ) const;
// Reordering controls
void MoveRawControlUp( const char *pRawControlName );
void MoveRawControlDown( const char *pRawControlName );
// Is this control a stereo control?
bool IsStereo() const;
void SetStereo( bool bStereo );
// Is this control an eyelid control?
bool IsEyelid() const;
void SetEyelid( bool bEyelid );
// Returns the name of the eyeball
const char *GetEyesUpDownFlexName() const;
// Returns the wrinkle scale for a particular control
float WrinkleScale( const char *pRawControlName );
float WrinkleScale( int nIndex );
void SetWrinkleScale( const char *pRawControlName, float flWrinkleScale );
float GetDefaultValue() const;
float GetBaseValue() const;
private:
int FindRawControl( const char *pRawControlName );
CDmaStringArray m_RawControlNames;
CDmaVar<bool> m_bIsStereo;
CDmaVar< bool > m_bIsEyelid;
// FIXME! Remove soon! Used to autogenerate wrinkle deltas
CDmaArray< float > m_WrinkleScales;
};
//-----------------------------------------------------------------------------
// Basic version..
//-----------------------------------------------------------------------------
class CDmeCombinationDominationRule : public CDmElement
{
DEFINE_ELEMENT( CDmeCombinationDominationRule, CDmElement );
public:
// Methods of IDmElement
virtual void OnAttributeChanged( CDmAttribute *pAttribute );
// Adds a dominating control
void AddDominator( const char *pDominatorControl );
// Add a suppressed control
void AddSuppressed( const char *pSuppressedControl );
// Remove all dominatior + suppressed controls
void RemoveAllDominators();
void RemoveAllSuppressed();
// Iteration
int DominatorCount() const;
const char *GetDominator( int i ) const;
int SuppressedCount() const;
const char *GetSuppressed( int i ) const;
// Search
bool HasDominatorControl( const char *pDominatorControl ) const;
bool HasSuppressedControl( const char *pSuppressedControl ) const;
private:
bool HasString( const char *pString, const CDmaStringArray& attr );
CDmaStringArray m_Dominators;
CDmaStringArray m_Suppressed;
};
//-----------------------------------------------------------------------------
// Basic version.. needs channels to copy the data out of its output attributes
//-----------------------------------------------------------------------------
enum CombinationControlType_t
{
COMBO_CONTROL_FIRST = 0,
COMBO_CONTROL_NORMAL = 0,
COMBO_CONTROL_LAGGED,
COMBO_CONTROL_TYPE_COUNT,
};
class CDmeCombinationOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmeCombinationOperator, CDmeOperator );
public:
// Methods of IDmElement
virtual void OnAttributeChanged( CDmAttribute *pAttribute );
virtual void OnElementUnserialized();
// Adds a control, returns the control index. Also adds a raw control with the same name to this control
ControlIndex_t FindOrCreateControl( const char *pControlName, bool bStereo, bool bAutoAddRawControl = false );
// Finds the index of the control with the specified name
ControlIndex_t FindControlIndex( const char *pControlName );
// Changes a control's name
void SetControlName( ControlIndex_t nControl, const char *pControlName );
// Removes a control
void RemoveControl( const char *pControlName );
void RemoveAllControls();
// Adds a remapped control to a input control
void AddRawControl( ControlIndex_t nControl, const char *pRawControlName );
// Removes an remapped control from a control
void RemoveRawControl( ControlIndex_t nControl, const char *pRawControlName );
void RemoveAllRawControls( ControlIndex_t nControl );
// Iterates output controls associated with an input control
int GetRawControlCount( ControlIndex_t nControl ) const;
const char *GetRawControlName( ControlIndex_t nControl, int nIndex ) const;
float GetRawControlWrinkleScale( ControlIndex_t nControl, int nIndex ) const;
float GetRawControlWrinkleScale( ControlIndex_t nControl, const char *pRawControlName ) const;
// Iterates a global list of output controls
int GetRawControlCount( ) const;
const char *GetRawControlName( int nIndex ) const;
float GetRawControlWrinkleScale( int nIndex ) const;
bool IsStereoRawControl( int nIndex ) const;
bool IsEyelidRawControl( int nIndex ) const;
// Gets Input Control Default & Base Values
float GetControlDefaultValue( ControlIndex_t nControl ) const;
float GetControlBaseValue( ControlIndex_t nControl ) const;
// Do we have a raw control?
bool HasRawControl( const char *pRawControlName ) const;
// Sets the wrinkle scale for a particular raw control
void SetWrinkleScale( ControlIndex_t nControlIndex, const char *pRawControlName, float flWrinkleScale );
// Sets the value of a control
void SetControlValue( ControlIndex_t nControlIndex, float flValue, CombinationControlType_t type = COMBO_CONTROL_NORMAL );
// Sets the value of a stereo control
void SetControlValue( ControlIndex_t nControlIndex, float flLeftValue, float flRightValue, CombinationControlType_t type = COMBO_CONTROL_NORMAL );
void SetControlValue( ControlIndex_t nControlIndex, const Vector2D& vec, CombinationControlType_t type = COMBO_CONTROL_NORMAL );
// Returns true if a control is a stereo control
void SetStereoControl( ControlIndex_t nControlIndex, bool bIsStereo );
bool IsStereoControl( ControlIndex_t nControlIndex ) const;
// Sets the level of a control (only used by controls w/ 3 or more remappings)
void SetMultiControlLevel( ControlIndex_t nControlIndex, float flLevel, CombinationControlType_t type = COMBO_CONTROL_NORMAL );
float GetMultiControlLevel( ControlIndex_t nControlIndex, CombinationControlType_t type = COMBO_CONTROL_NORMAL ) const;
// Reordering controls
void MoveControlUp( const char *pControlName );
void MoveControlDown( const char *pControlName );
void MoveControlBefore( const char *pDragControlName, const char *pDropControlName );
void MoveControlAfter( const char *pDragControlName, const char *pDropControlName );
void MoveRawControlUp( ControlIndex_t nControlIndex, const char *pRawControlName );
void MoveRawControlDown( ControlIndex_t nControlIndex, const char *pRawControlName );
// Returns true if a control is a multi control (a control w/ 3 or more remappings)
bool IsMultiControl( ControlIndex_t nControlIndex ) const;
// Returns true if a control is a multi-control which controls eyelids
void SetEyelidControl( ControlIndex_t nControlIndex, bool bIsEyelid );
bool IsEyelidControl( ControlIndex_t nControlIndex ) const;
const char *GetEyesUpDownFlexName( ControlIndex_t nControlIndex ) const;
// Sets the value of a control
float GetControlValue( ControlIndex_t nControlIndex, CombinationControlType_t type = COMBO_CONTROL_NORMAL ) const;
const Vector2D& GetStereoControlValue( ControlIndex_t nControlIndex, CombinationControlType_t type = COMBO_CONTROL_NORMAL ) const;
// Iterates controls
int GetControlCount() const;
const char *GetControlName( ControlIndex_t i ) const;
// Attaches a channel to an input
void AttachChannelToControlValue( ControlIndex_t nControlIndex, CombinationControlType_t type, CDmeChannel *pChannel );
// Adds a domination rule. Domination rules are specified using raw control names
CDmeCombinationDominationRule *AddDominationRule( );
CDmeCombinationDominationRule *AddDominationRule( int nDominatorCount, const char **ppDominatorOutputControlNames, int nSuppressedCount, const char **ppSuppressedOutputControlNames );
CDmeCombinationDominationRule *AddDominationRule( const CUtlVector< const char * > dominators, const CUtlVector< const char * > suppressed );
CDmeCombinationDominationRule *AddDominationRule( CDmeCombinationDominationRule *pSrcRule );
// Removes a domination rule
void RemoveDominationRule( int nIndex );
void RemoveDominationRule( CDmeCombinationDominationRule *pRule );
void RemoveAllDominationRules();
// Iteration
int DominationRuleCount() const;
CDmeCombinationDominationRule *GetDominationRule( int i );
// Rule reordering
void MoveDominationRuleUp( CDmeCombinationDominationRule* pRule );
void MoveDominationRuleDown( CDmeCombinationDominationRule* pRule );
// Indicates we're using lagged control values
void UsingLaggedData( bool bEnable );
bool IsUsingLaggedData() const;
// Adds a target model/arbitrary element to perform the combinations on
// The arbitrary element must have two attributes
// "deltaStates", which is an array of elements
// "deltaStateWeights", which is an array of floats
// In the case of the model, it will look for all shapes in the dag hierarchy
// and attempt to add that shape as a target
// NOTE: Targets are not saved
void AddTarget( CDmeDag *pDag );
void AddTarget( CDmElement *pElement );
void RemoveAllTargets();
// Used by studiomdl to discover the various combination rules
int GetOperationTargetCount() const;
CDmElement *GetOperationTarget( int nTargetIndex );
int GetOperationCount( int nTargetIndex ) const;
CDmElement *GetOperationDeltaState( int nTargetIndex, int nOpIndex );
const CUtlVector< int > &GetOperationControls( int nTargetIndex, int nOpIndex ) const;
int GetOperationDominatorCount( int nTargetIndex, int nOpIndex ) const;
const CUtlVector< int > &GetOperationDominator( int nTargetIndex, int nOpIndex, int nDominatorIndex ) const;
// Does one of the targets we refer to contain a particular delta state?
bool DoesTargetContainDeltaState( const char *pDeltaStateName );
virtual void Operate();
virtual void Resolve();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
// Would a particular delta state attached to this combination operator end up stero?
bool IsDeltaStateStereo( const char *pDeltaStateName );
void CopyControls( CDmeCombinationOperator *pSrc );
void GenerateWrinkleDeltas( bool bOverwrite, bool bUseNormalForSign = false, float flScale = 1.0f );
void SetToDefault();
// The base values are different from the default values see CDmeCombinationInputControl
void SetToBase();
// Remove all controls and domination rules which are not referring to anything
void Purge();
protected:
void ComputeCombinationInfo( int nIndex );
private:
typedef int RawControlIndex_t;
struct DominatorInfo_t
{
CUtlVector< RawControlIndex_t > m_DominantIndices;
CUtlVector< RawControlIndex_t > m_SuppressedIndices;
};
struct CombinationOperation_t
{
int m_nDeltaStateIndex;
CUtlVector< RawControlIndex_t > m_ControlIndices;
CUtlVector< RawControlIndex_t > m_DominatorIndices;
};
struct CombinationInfo_t
{
DmAttributeHandle_t m_hDestAttribute[COMBO_CONTROL_TYPE_COUNT];
CUtlVector< CombinationOperation_t > m_Outputs;
};
struct RawControlInfo_t
{
CUtlString m_Name;
bool m_bIsDefaultControl;
ControlIndex_t m_InputControl;
float m_flWrinkleScale;
bool m_bLowerEyelid;
Vector4D m_FilterRamp; // [0] = point at which ramp starts going up
// [1] = point at which ramp hits 1.0
// [2] = point at which ramp stops holding at 1.0
// [3] = point at which ramp starts going down
};
void ComputeCombinationInfo();
void CleanUpCombinationInfo( int nIndex );
void CleanUpCombinationInfo();
// Is a particular remapped control stereo?
bool IsRawControlStereo( const char *pRawControlName );
// Determines the weighting of input controls based on the deltaState name
int FindDeltaStateIndex( CDmAttribute *pDeltaArray, const char *pDeltaStateName );
// Determines which combination to use based on the deltaState name
int ParseDeltaName( const char *pDeltaStateName, int *pControlIndices );
// Finds dominators
void FindDominators( CombinationOperation_t& op );
// Computes lists of dominators and suppressors
void RebuildDominatorInfo();
// Computes list of all remapped controls
void RebuildRawControlList();
// Remaps non-stereo -> stereo, stereo ->left/right
void ComputeInternalControlValue( RawControlIndex_t nRawControlIndex, CombinationControlType_t type, Vector2D &value );
// Computes lagged input values from non-lagged input
void ComputeLaggedInputValues();
// Finds the index of the remapped control with the specified name
RawControlIndex_t FindRawControlIndex( const char *pControlName, bool bIgnoreDefaultControls = false ) const;
// Updates the default value associated with a control
void UpdateDefaultValue( ControlIndex_t nControlIndex );
// Finds a domination rule
int FindDominationRule( CDmeCombinationDominationRule *pRule );
// Generates wrinkle deltas for a dag hierarchy
void GenerateWrinkleDeltas( CDmeShape *pShape, bool bOverwrite, bool bUseNormalForSign, float flScale = 1.0f );
CDmaElementArray< CDmeCombinationInputControl > m_InputControls;
CDmaArray< Vector > m_ControlValues[COMBO_CONTROL_TYPE_COUNT];
CDmaVar< bool > m_bSpecifyingLaggedData;
CDmaElementArray< CDmeCombinationDominationRule > m_Dominators;
CDmaElementArray< CDmElement > m_Targets;
CUtlVector< bool > m_IsDefaultValue; // one per control value
CUtlVector< RawControlInfo_t > m_RawControlInfo;
CUtlVector< CombinationInfo_t > m_CombinationInfo;
CUtlVector< DominatorInfo_t > m_DominatorInfo;
float m_flLastLaggedComputationTime;
};
//-----------------------------------------------------------------------------
// Indicates we're using lagged control values
//-----------------------------------------------------------------------------
inline void CDmeCombinationOperator::UsingLaggedData( bool bEnable )
{
m_bSpecifyingLaggedData = bEnable;
}
inline bool CDmeCombinationOperator::IsUsingLaggedData() const
{
return m_bSpecifyingLaggedData;
}
//-----------------------------------------------------------------------------
// Helper method to create a lagged version of channel data from source data
//-----------------------------------------------------------------------------
void CreateLaggedVertexAnimation( CDmeChannelsClip *pClip, int nSamplesPerSec );
//-----------------------------------------------------------------------------
//
// A class used to edit combination operators in Maya.. doesn't connect to targets
//
//-----------------------------------------------------------------------------
class CDmeMayaCombinationOperator : public CDmeCombinationOperator
{
DEFINE_ELEMENT( CDmeMayaCombinationOperator, CDmeCombinationOperator );
public:
void AddDeltaState( const char *pDeltaStateName );
void RemoveDeltaState( const char *pDeltaStateName );
void RemoveAllDeltaStates();
int FindDeltaState( const char *pDeltaStateName );
int DeltaStateCount() const;
const char *GetDeltaState( int nIndex ) const;
const Vector2D& GetDeltaStateWeight( int nIndex, CombinationControlType_t type ) const;
private:
CDmaElementArray< CDmElement > m_DeltaStates;
CDmaArray< Vector2D > m_DeltaStateWeights[COMBO_CONTROL_TYPE_COUNT];
};
#endif // DMECOMBINATIONOPERATOR_H

View File

@@ -0,0 +1,79 @@
//====== Copyright © 1996-2009, Valve Corporation, All rights reserved. =======
//
// Purpose: Declaration of the CDmeConnectionOperator class, a CDmeOperator
// which copies one attribute value to another, providing similar functionality
// to CDmeChannel, but does not store a log and is not effected by the
// recording mode.
//
//=============================================================================
#ifndef DMECONNECTIONOPERATOR_H
#define DMECONNECTIONOPERATOR_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmeattributereference.h"
#include "movieobjects/dmeoperator.h"
//-------------------------------------------------------------------------------------------------
// The CDmeConnectionOperator class is a CDmeOperator which copies the value from one attribute
// to another. The CDmeConnectionOperator is frequently used in combination with the
// CDmeExpressionOperator to allow a single value, often on controlled by a channel, to drive the
// value of multiple targets. The connection operator may have multiple outputs, but only one
// input. Only a single input is allowed because allowing multiple inputs would mean that the
// operator could actually represent multiple unrelated connections, and this would could cause
// various dependency and evaluation issues. Multiple outputs are allowed as it reduces the number
// of individual operators required to accomplish many setups, all of the connections must be
// related, and the dependency chain is essentially the same as having individual operators for
// each connection, as the operator with multiple outputs can always be evaluated immediately
// following the evaluation of its single input.
//-------------------------------------------------------------------------------------------------
class CDmeConnectionOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmeConnectionOperator, CDmeOperator );
public:
// Run the operator, which copies the value from the source attribute to the destination attributes.
virtual void Operate();
// Add the input attribute used by the operator to the provided list of attributes, This is
// generally used by the evaluation process to find the attributes an operator is dependent on.
virtual void GetInputAttributes( CUtlVector< CDmAttribute * > &attrs );
// Add each of attributes the connection operator outputs to the provided list of attributes.
// This is generally used by the evaluation process to find out what attributes are written by
// the operator in order to determine what other operators are dependent on this operator.
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
// Determine if data has changed and the operator needs to be updated
virtual bool IsDirty();
// Set the input attribute of the connection.
void SetInput( CDmElement* pElement, const char* pchAttributeName, int index = 0 );
// Add an attribute to be written to by the connection.
void AddOutput( CDmElement* pElement, const char* pchAttributeName, int index = 0 );
// Get the number of output attributes
int NumOutputAttributes() const;
// Get the specified output attribute
CDmAttribute *GetOutputAttribute( int index ) const;
// Get the input attribute
CDmAttribute *GetInputAttribute();
protected:
CDmaElement< CDmeAttributeReference > m_Input; // Reference to the input attribute
CDmaElementArray< CDmeAttributeReference > m_Outputs; // Array of references to output attributes
};
#endif // DMECONNECTIONOPERATOR_H

View File

@@ -0,0 +1,172 @@
//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =======
//
// Purpose: Contains the declaration of the CDmeControlGroup class. The
// CDmeControlGroup class is a grouping of animation controls that is used for
// selection.
//
//=============================================================================
#ifndef DMECONTROLGROUP_H
#define DMECONTROLGROUP_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmattributevar.h"
class CDmeTransform;
class CDmeAnimationSet;
//-----------------------------------------------------------------------------
// CDmeControlGroup: A class representing a grouping of controls used for
// selection. Contains a list of controls as well as a list of child groups
// which are used to for a group hierarchy.
//-----------------------------------------------------------------------------
class CDmeControlGroup : public CDmElement
{
DEFINE_ELEMENT( CDmeControlGroup, CDmElement );
public:
//---------------------------------
// Control functions
//---------------------------------
// Add a control to the group
void AddControl( CDmElement *pControl, const CDmElement *pInsertBeforeControl = NULL );
// Remove a control from the group
bool RemoveControl( const CDmElement *pControl );
// Get a flat list of all of the controls in the group
void GetControlsInGroup( CUtlVector< CDmElement* > &controlList, bool recursive ) const;
// Find a control with the specified name within the group
CDmElement *FindControlByName( const char *pchName, bool recursive, CDmeControlGroup **pParentGroup = NULL );
// Find the group to which the specified control belongs, if any.
static CDmeControlGroup *FindGroupContainingControl( const CDmElement* pControl );
//---------------------------------
// Group functions
//---------------------------------
// Make the specified group a child of this group
void AddChild( CDmeControlGroup *pGroup, const CDmeControlGroup *pInsertBeforeGroup = NULL );
// Remove the specified child group
bool RemoveChild( const CDmeControlGroup *pGroup );
// Move the specified child group to the top of the list
void MoveChildToTop( const CDmeControlGroup *pGroup );
// Move the specified child group to the bottom of the list
void MoveChildToBottom( const CDmeControlGroup *pGroup );
// Sore the children by name
void SortChildrenByName( bool bAscending );
// Determine if the group has child of the specified name
bool HasChildGroup( const char *pchName, bool recursive );
// Find the child group with the specified name
CDmeControlGroup *FindChildByName( const char *pchName, bool recursive, CDmeControlGroup **pParentGroup = NULL );
// Find the parent of the group
CDmeControlGroup *FindParent() const;
// Determine if this group is an ancestor of the specified group
bool IsAncestorOfGroup( const CDmeControlGroup *pGroup ) const;
// Create a control group with the provided name and make it a child of this group
CDmeControlGroup *CreateControlGroup( const char *pchName );
// Get a flat list of all of the groups in sub-tree of the group
void GetAllChildren( CUtlVector< DmElementHandle_t > &childGroupList ) const;
// Destroy all of the empty children of the group, will not destroy this group even it is empty.
void DestroyEmptyChildren();
// Destroy the control group, moving all of its children and controls into this node
static void DestroyGroup( CDmeControlGroup *pGroup, CDmeControlGroup *pRecipient, bool recursive );
// Remove all of the children and controls from the group
void RemoveAllChildrenAndControls();
// Set the color of the group
void SetGroupColor( const Color &groupColor, bool recursive );
// Set the color to be used on the controls of the group
void SetControlColor( const Color &controlColor, bool recursive );
// Set the visible state of the group
void SetVisible( bool bVisible );
// Enable or disable selection of the controls
void SetSelectable( bool bEnable );
// Enable or disable control snapping
void SetSnappable( bool bEnable );
// Determine if there are any controls or children in the group
bool IsEmpty() const;
// Is the group visible, will return false if any parent of the group is not visible
bool IsVisible() const;
// Can controls in the group be selected in the viewport, check includes parents
bool IsSelectable() const;
// Can controls in the group be snapped to in the viewport, check includes parents
bool IsSnappable() const;
// Find the animation set associated with the control group
CDmeAnimationSet *FindAnimationSet( bool bSearchAncestors ) const;
// Find the shared ancestor between this control group and the specified control group
CDmeControlGroup *FindCommonAncestor( CDmeControlGroup *pControlGroup );
// Find the root control group which this control group is in the sub tree of.
CDmeControlGroup *FindRootControlGroup();
// Compare the two groups by name for an ascending sort
static int CDmeControlGroup::CompareByNameAscending( CDmeControlGroup * const *pGroupA, CDmeControlGroup * const *pGroupB );
// Compare the two groups by name for a descending sort
static int CDmeControlGroup::CompareByNameDecending( CDmeControlGroup * const *pGroupA, CDmeControlGroup * const *pGroupB );
// Accessors
const CDmaElementArray< CDmeControlGroup > &Children() const { return m_Children; }
const CDmaElementArray< CDmElement > &Controls() const { return m_Controls; }
const Color &GroupColor() const { return m_GroupColor; }
const Color &ControlColor() const { return m_ControlColor; }
bool Visible() const { return m_Visible; }
bool Selectable() const { return m_Selectable; }
bool Snappable() const { return m_Snappable; }
private:
// Recursively destroy the children of the specified group which have no controls or sub groups
static bool DestroyEmptyChildren_R( CDmeControlGroup *pGroup );
// Recursively destroy the child groups of the specified group and and the controls to the specified recipient group
static void DestroyGroup_R( CDmeControlGroup *pGroup, CDmeControlGroup *pRecipient, bool recursive );
// Build a list of the control group that form the path to the root of the tree to which the control group belongs
void BuildPathFromRoot( CUtlVector< CDmeControlGroup * > &path );
CDmaElementArray< CDmeControlGroup > m_Children; // "children" : Child groups of this control group
CDmaElementArray< CDmElement > m_Controls; // "controls" : Controls within the group
CDmaVar< Color > m_GroupColor; // "groupColor" : Color which the group is to be displayed with
CDmaVar< Color > m_ControlColor; // "controlColor" : Color in which the controls of the group are to be displayed
CDmaVar< bool > m_Visible; // "visible" : Is the group visible in animation set editor
CDmaVar< bool > m_Selectable; // "selectable" : Can the group be selected
CDmaVar< bool > m_Snappable; // "snapping" : Can controls in the group be snapped to
};
#endif // DMECONTROLGROUP_H

View File

@@ -0,0 +1,49 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class representing a procedural texture
//
//=============================================================================
#ifndef DMECYCLE_H
#define DMECYCLE_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeDag;
//-----------------------------------------------------------------------------
// A class representing a cycle, which can arbitrarily break C1 continuity.
// When these jumps occur, we need to make sure we interpolate properly.
//-----------------------------------------------------------------------------
class CDmeCycle : public CDmElement
{
DEFINE_ELEMENT( CDmeCycle, CDmElement );
public:
float GetCycle( float flCurTime ) const;
float GetCycleRate() const;
float GetPrevCycle() const;
void SetCycle( float flCycle, float flCurTime );
void SetCycleRate( float flCycleRate );
// If transform is contained inside some kind of CDmeDag, return that (it's "parent")
CDmeDag *GetDag();
private:
void SetPrevCycle( float flPrevCycle );
CDmaVar<float> m_cycleRate;
CDmaVar<int> m_prevCycle; // NOTE: Stored as an integers so they will not be interpolated
CDmaVar<int> m_lastCycleResetTime;
CDmaVar<int> m_lastCycleResetValue;
};
#endif // DMECYCLE_H

View File

@@ -0,0 +1,250 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class representing a Dag (directed acyclic graph) node used for holding transforms, lights, cameras and shapes
//
//=============================================================================
#ifndef DMEDAG_H
#define DMEDAG_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/utlstack.h"
#include "datamodel/dmehandle.h"
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "movieobjects/dmeshape.h"
#include "movieobjects/dmetransform.h"
#include "movieobjects/dmeoverlay.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeOverlay;
class CDmeTransform;
class CDmeShape;
class CDmeDrawSettings;
class CDmeChannel;
class CDmeClip;
class DmeLog_TimeSelection_t;
class CDmeTransformControl;
//-----------------------------------------------------------------------------
// A class representing a camera
//-----------------------------------------------------------------------------
class CDmeDag : public CDmElement
{
DEFINE_ELEMENT( CDmeDag, CDmElement );
public:
virtual void Resolve();
// Accessors
CDmeTransform *GetTransform() const;
CDmeShape *GetShape();
// Changes the shage
void SetShape( CDmeShape *pShape );
bool IsVisible() const;
void SetVisible( bool bVisible = true );
// child helpers
const CUtlVector< DmElementHandle_t > &GetChildren() const;
int GetChildCount() const;
CDmeDag *GetChild( int i ) const;
bool AddChild( CDmeDag* pDag );
void RemoveChild( int i );
void RemoveChild( const CDmeDag *pChild, bool bRecurse = false );
int FindChild( const CDmeDag *pChild ) const;
int FindChild( CDmeDag *&pParent, const CDmeDag *pChild );
int FindChild( const char *name ) const;
CDmeDag *FindOrAddChild( const char *name );
void RemoveAllChildren();
bool SetParent( CDmeDag *pDmeDagParent );
CDmeDag *FindChildByName_R( const char *name ) const;
// Count the number of steps between the node and the specified child node, returns -1 if not related
int StepsToChild( const CDmeDag *pChild ) const;
// Recursively render the Dag hierarchy
virtual void Draw( CDmeDrawSettings *pDrawSettings = NULL );
void GetBoundingSphere( Vector &center, float &radius ) const
{
matrix3x4_t identity;
SetIdentityMatrix( identity );
GetBoundingSphere( center, radius, identity );
}
void GetBoundingBox( Vector &min, Vector &max ) const
{
matrix3x4_t identity;
SetIdentityMatrix( identity );
GetBoundingBox( min, max, identity );
}
void GetShapeToWorldTransform( matrix3x4_t &mat );
void GetLocalMatrix( matrix3x4_t &mat ) const;
void SetLocalMatrix( matrix3x4_t &mat );
void GetAbsTransform( matrix3x4_t &matAbsTransform ) const;
void SetAbsTransform( const matrix3x4_t &matAbsTransform );
void GetAbsPosition( Vector &absPos ) const;
void SetAbsPosition( const Vector &absPos );
void GetAbsOrientation( Quaternion &absOrientation ) const;
void SetAbsOrientation( const Quaternion &absOrientation );
void BakeStaticTransforms( bool bRecurse = true );
void OnAttachToDmeDag( CDmeDag *pParentDag, bool bFixupLogs = true );
CDmeDag *GetParent() const;
template <class T>
T *FindParentDagOfType();
// Find all nodes in the sub-tree of the dag which are of the specified type.
template< class T >
void FindChildrenOfType( CUtlVector< T* > &children );
// Determine if the dag has an override parent
bool HasOverrideParent() const;
// Get the current override parent, returns NULL if no override parent is set
const CDmeDag *GetOverrideParent( bool bIgnoreEnable = false ) const;
const CDmeDag *GetOverrideParent( bool &bPosition, bool &bRotation, bool bIgnoreEnable = false ) const;
// Set the current override parent, if the parameter is NULL the overrider parent will be cleared.
void SetOverrideParent( const CDmeDag *pParentDag, bool bPosition, bool bRotation );
// Set the flag which enables or disables the override parent
void EnableOverrideParent( bool bEnable );
// Determine if the override parent is enabled ( This only says if an override parent is allowed, not if the dag has an override parent)
bool IsOverrideParentEnabled() const;
// Determine if this dag node is ancestor of the specified dag
bool IsAncestorOfDag( const CDmeDag *pDag ) const;
// Find the dag node which is the root of the tree the dag node is in.
CDmeDag *FindRoot();
void BindTransformToDmeDag( const CDmeDag *pTargetDag, const DmeLog_TimeSelection_t &params, const CDmeClip *pMovie, const Vector& offsset,
bool bPosition, bool bOrientation, bool bMaintainOffset );
void ComputeTransformAtTime( DmeTime_t globalTime,const CDmeClip* pMovie, matrix3x4_t &matAbsTransform, matrix3x4_t &localTransform );
void MoveToTarget( const CDmeDag *pTargetDag, const DmeLog_TimeSelection_t &params, const CDmeClip *pMovie );
void GetParentWorldMatrix( matrix3x4_t &mat ) const;
void GetTranslationParentWorldMatrix( matrix3x4_t &mParentToWorld );
static void DrawUsingEngineCoordinates( bool bEnable );
static void DrawZUp( bool bZUp );
static bool IsDrawZUp() { return !s_bDrawZUp; }
// Transform from DME to engine coordinates
static void DmeToEngineMatrix( matrix3x4_t& dmeToEngine, bool bZUp );
static void EngineToDmeMatrix( matrix3x4_t& engineToDme, bool bZUp );
// Find the channels targeting the transform of the object either directly or through a constraint
void FindTransformChannels( CUtlVector< CDmeChannel * > &list ) const;
// Find the transform controls driving the dag node
CDmeTransformControl *FindTransformControl() const;
// Find all of the operators on which dag node is dependent, this recursively finds operators for the parents of the dag.
void FindRelevantOperators( CUtlVector< CDmeOperator * > &operatorList ) const;
// Find all of the operators on which the dag node is dependent, splitting the channels into a separate list.
void FindRelevantOperators( CUtlVector< CDmeChannel * > &list, CUtlVector< CDmeOperator * > &operatorList ) const;
// This one only looks at the current CDmeDag
void FindLocalOperators( CUtlVector< CDmeOperator * > &operatorList ) const;
protected:
void GetBoundingSphere( Vector &center, float &radius, const matrix3x4_t &pMat ) const;
void GetBoundingBox( Vector &min, Vector &max, const matrix3x4_t &pMat ) const;
void PushDagTransform();
void PopDagTransform();
CDmAttribute *GetVisibilityAttribute();
CDmaVar< bool > m_Visible;
CDmaVar< bool > m_bDisableOverrideParent;
CDmaElement< CDmeTransform > m_Transform;
CDmaElement< CDmeShape > m_Shape;
CDmaElementArray< CDmeDag > m_Children;
private:
struct TransformInfo_t
{
CDmeTransform *m_pTransform;
matrix3x4_t m_DagToWorld;
bool m_bComputedDagToWorld;
};
static CUtlStack<TransformInfo_t> s_TransformStack;
static bool s_bDrawUsingEngineCoordinates;
static bool s_bDrawZUp; // NOTE: s_bZUp doesn't mean the model is in engine coordinates, it means it's Z Up, -Y Front & X Right. Engine is Z Up, X Front & Y Right.
};
void RemoveDagFromParents( CDmeDag *pDag, bool bRecursivelyRemoveEmptyDagsFromParents = false );
template <class T>
inline T *CDmeDag::FindParentDagOfType()
{
CDmeDag *parent = GetParent();
while ( parent )
{
if ( CastElement< T >( parent ) )
return static_cast< T * >( parent );
parent = parent->GetParent();
}
if ( CastElement< T >( this ) )
return static_cast< T * >( this );
return NULL;
}
//-----------------------------------------------------------------------------
// Purpose: Find all dag nodes in the sub-tree of the dag which are of the
// specified type.
//-----------------------------------------------------------------------------
template< class T >
void CDmeDag::FindChildrenOfType( CUtlVector< T* > &children )
{
int nChildren = m_Children.Count();
for ( int iChild = 0; iChild < nChildren; ++iChild )
{
CDmeDag *pChild = m_Children[ iChild ];
if ( pChild == NULL )
continue;
// Add the child to the list if it is of the specified type
T* pChildType = CastElement< T >( pChild );
if ( pChildType )
{
children.AddToTail( pChildType );
}
// Recursively add the children of the child.
pChild->FindChildrenOfType( children );
}
}
#endif // DMEDAG_H

View File

@@ -0,0 +1,131 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =====//
//
// Describes the way to compile data in DCC files (describes an export step)
//
//===========================================================================//
#ifndef DMEDCCMAKEFILE_H
#define DMEDCCMAKEFILE_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmemakefile.h"
//-----------------------------------------------------------------------------
// Describes a source for DCC makefiles
//-----------------------------------------------------------------------------
class CDmeSourceDCCFile : public CDmeSource
{
DEFINE_ELEMENT( CDmeSourceDCCFile, CDmeSource );
public:
CDmaStringArray m_RootDCCObjects;
CDmaVar< int > m_ExportType; // 0 == model, 1 == skeletal animation
CDmaVar< float > m_FrameStart;
CDmaVar< float > m_FrameEnd;
CDmaVar< float > m_FrameIncrement;
};
//-----------------------------------------------------------------------------
// Strictly here to customize OpenEditor
//-----------------------------------------------------------------------------
class CDmeSourceMayaFile : public CDmeSourceDCCFile
{
DEFINE_ELEMENT( CDmeSourceMayaFile, CDmeSourceDCCFile );
};
class CDmeSourceMayaModelFile : public CDmeSourceMayaFile
{
DEFINE_ELEMENT( CDmeSourceMayaModelFile, CDmeSourceMayaFile );
};
class CDmeSourceMayaAnimationFile : public CDmeSourceMayaFile
{
DEFINE_ELEMENT( CDmeSourceMayaAnimationFile, CDmeSourceMayaFile );
};
class CDmeSourceXSIFile : public CDmeSourceDCCFile
{
DEFINE_ELEMENT( CDmeSourceXSIFile, CDmeSourceDCCFile );
};
//-----------------------------------------------------------------------------
// Describes a DCC asset
//-----------------------------------------------------------------------------
class CDmeDCCMakefile : public CDmeMakefile
{
DEFINE_ELEMENT( CDmeDCCMakefile, CDmeMakefile );
public:
virtual void GetOutputs( CUtlVector<CUtlString> &fullPaths );
private:
virtual CDmElement *CreateOutputElement( );
virtual void DestroyOutputElement( CDmElement *pOutput );
virtual const char *GetOutputDirectoryID() { return "makefiledir:..\\dmx"; }
bool m_bFlushFile;
};
//-----------------------------------------------------------------------------
// Describes a Maya asset
//-----------------------------------------------------------------------------
class CDmeMayaMakefile : public CDmeDCCMakefile
{
DEFINE_ELEMENT( CDmeMayaMakefile, CDmeDCCMakefile );
};
//-----------------------------------------------------------------------------
// Describes a XSI asset
//-----------------------------------------------------------------------------
class CDmeXSIMakefile : public CDmeDCCMakefile
{
DEFINE_ELEMENT( CDmeXSIMakefile, CDmeDCCMakefile );
public:
// Compiling is just exporting the data in the file
virtual DmeMakefileType_t *GetMakefileType();
virtual DmeMakefileType_t* GetSourceTypes();
};
//-----------------------------------------------------------------------------
// Describes a Maya model/animation asset
//-----------------------------------------------------------------------------
class CDmeMayaModelMakefile : public CDmeMayaMakefile
{
DEFINE_ELEMENT( CDmeMayaModelMakefile, CDmeMayaMakefile );
public:
// Compiling is just exporting the data in the file
virtual DmeMakefileType_t *GetMakefileType();
virtual DmeMakefileType_t* GetSourceTypes();
};
class CDmeMayaAnimationMakefile : public CDmeMayaMakefile
{
DEFINE_ELEMENT( CDmeMayaAnimationMakefile, CDmeMayaMakefile );
public:
// Compiling is just exporting the data in the file
virtual DmeMakefileType_t *GetMakefileType();
virtual DmeMakefileType_t* GetSourceTypes();
};
//-----------------------------------------------------------------------------
// Describes a XSI animation asset
//-----------------------------------------------------------------------------
class CDmeXSIAnimationMakefile : public CDmeXSIMakefile
{
DEFINE_ELEMENT( CDmeXSIAnimationMakefile, CDmeXSIMakefile );
};
#endif // DMEDCCMAKEFILE_H

View File

@@ -0,0 +1,195 @@
//====== Copyright © 1996-2006, Valve Corporation, All rights reserved. =======
//
// A class representing draw settings for Dme things
//
//=============================================================================
#ifndef DMEDRAWSETTINGS_H
#define DMEDRAWSETTINGS_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "materialsystem/MaterialSystemUtil.h"
#include "tier1/utlstack.h"
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
class CDmeDag;
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
class CDmeDrawSettings : public CDmElement
{
DEFINE_ELEMENT( CDmeDrawSettings, CDmElement );
public:
enum DrawType_t
{
DRAW_INVALID = -1,
DRAW_SMOOTH,
DRAW_FLAT,
DRAW_WIREFRAME,
DRAW_BOUNDINGBOX,
STANDARD_DRAW_COUNT
};
// resolve internal data from changed attributes
virtual void Resolve();
DrawType_t GetDrawType() const;
DrawType_t SetDrawType( int drawType );
void PushDrawType();
void PopDrawType();
bool Shaded() const {
const DrawType_t drawType = GetDrawType();
return drawType == DRAW_SMOOTH || drawType == DRAW_FLAT;
}
bool GetBackfaceCulling() const { return m_bBackfaceCulling.Get(); }
void SetBackfaceCulling( bool val ) { m_bBackfaceCulling.Set( val ); }
bool GetWireframeOnShaded() const { return m_bWireframeOnShaded.Get(); }
void SetWireframeOnShaded( bool val ) { m_bWireframeOnShaded.Set( val ); }
bool GetXRay() const { return m_bXRay.Get(); }
void SetXRay( bool val ) { m_bXRay.Set( val ); }
bool GetGrayShade() const { return m_bGrayShade.Get(); }
void SetGrayShade( bool val ) { m_bGrayShade.Set( val ); }
bool GetNormals() const { return m_bNormals.Get(); }
void SetNormals( bool val ) { m_bNormals.Set( val ); }
float GetNormalLength() const { return m_NormalLength.Get(); }
void SetNormalLength( float val ) { m_NormalLength.Set( val ); }
const Color &GetColor() const { return m_Color.Get(); }
void SetColor( Color val ) { m_Color.Set( val ); }
bool Drawable( CDmElement *pElement );
void BindWireframe();
void BindWireframeOnShaded();
void BindGray();
void BindUnlitGray();
bool GetDeltaHighlight() const { return m_bDeltaHighlight; }
void SetDeltaHighlight( bool bDeltaHighlight ) { m_bDeltaHighlight.Set( bDeltaHighlight ); }
bool IsAMaterialBound() const {
return m_IsAMaterialBound;
}
void DrawDag( CDmeDag *pDag );
CUtlVector< Vector > &GetHighlightPoints() { return m_vHighlightPoints; }
public:
CDmaVar< int > m_DrawType;
CDmaVar< bool > m_bBackfaceCulling;
CDmaVar< bool > m_bWireframeOnShaded;
CDmaVar< bool > m_bXRay;
CDmaVar< bool > m_bGrayShade;
CDmaVar< bool > m_bNormals;
CDmaVar< float > m_NormalLength;
CDmaVar< Color > m_Color;
CDmaVar< bool > m_bDeltaHighlight;
CDmaVar< float > m_flHighlightSize;
CDmaVar< Color > m_cHighlightColor;
protected:
void BuildKnownDrawableTypes();
static bool s_bWireframeMaterialInitialized;
static CMaterialReference s_WireframeMaterial;
static bool s_bWireframeOnShadedMaterialInitialized;
static CMaterialReference s_WireframeOnShadedMaterial;
static bool s_bFlatGrayMaterial;
static CMaterialReference s_FlatGrayMaterial;
static bool s_bUnlitGrayMaterial;
static CMaterialReference s_UnlitGrayMaterial;
static CUtlRBTree< CUtlSymbolLarge > s_KnownDrawableTypes;
CUtlRBTree< CUtlSymbolLarge > m_NotDrawable;
CUtlStack< DrawType_t > m_drawTypeStack;
bool m_IsAMaterialBound;
// Points to highlight
CUtlVector< Vector > m_vHighlightPoints;
};
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
inline CDmeDrawSettings::DrawType_t CDmeDrawSettings::SetDrawType( int drawType )
{
if ( drawType < 0 || drawType >= STANDARD_DRAW_COUNT )
{
drawType = DRAW_SMOOTH;
}
m_DrawType.Set( drawType );
return GetDrawType();
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
inline CDmeDrawSettings::DrawType_t CDmeDrawSettings::GetDrawType() const
{
const int drawType( m_DrawType.Get() );
if ( drawType < 0 || drawType >= STANDARD_DRAW_COUNT )
return DRAW_SMOOTH;
return static_cast< DrawType_t >( drawType );
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
inline void CDmeDrawSettings::PushDrawType()
{
m_drawTypeStack.Push( GetDrawType() );
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
inline void CDmeDrawSettings::PopDrawType()
{
if ( m_drawTypeStack.Count() )
{
DrawType_t drawType = GetDrawType();
m_drawTypeStack.Pop( drawType );
SetDrawType( drawType );
}
}
#endif // DMEDRAWSETTINGS_H

View File

@@ -0,0 +1,132 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Contains a bunch of information about editor types
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef DMEEDITORTYPEDICTIONARY_H
#define DMEEDITORTYPEDICTIONARY_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
//-----------------------------------------------------------------------------
// Contains all attributes related to a particular attribute on a particular editor type
//-----------------------------------------------------------------------------
class CDmeEditorAttributeInfo : public CDmElement
{
DEFINE_ELEMENT( CDmeEditorAttributeInfo, CDmElement );
public:
// Returns the attribute name this info is associated with
const char *GetAttributeName() const;
// Returns the widget name to create
const char *GetWidgetName() const;
// Sets the info for an entry in an attribute array
void SetArrayInfo( CDmeEditorAttributeInfo *pInfo );
// Returns the info for a entry in an attribute array, if this attribute is an array type
CDmeEditorAttributeInfo *GetArrayInfo();
// NOTE: The name field of the widget element is the widget type
// The attributes of the widget element are data for the widget to initialize
CDmaString m_Widget;
CDmaVar< bool > m_bIsVisible;
CDmaVar< bool > m_bIsReadOnly;
CDmaVar< bool > m_bHideType;
CDmaVar< bool > m_bHideValue;
CDmaString m_Help;
private:
// If this attribute is an array attribute, how do we edit the array entries?
CDmaElement< CDmeEditorAttributeInfo > m_ArrayEntries;
};
//-----------------------------------------------------------------------------
// Base class for configuration for choices
//-----------------------------------------------------------------------------
class CDmeEditorChoicesInfo : public CDmeEditorAttributeInfo
{
DEFINE_ELEMENT( CDmeEditorChoicesInfo, CDmeEditorAttributeInfo );
public:
void SetChoiceType( const char *pChoiceType );
// Gets the choices
int GetChoiceCount() const;
const char *GetChoiceString( int nIndex ) const;
const char *GetChoiceType() const;
bool HasChoiceType() const;
protected:
CDmElement *CreateChoice( const char *pChoiceString );
CDmaElementArray< CDmElement > m_Choices;
CDmaString m_ChoiceType;
};
//-----------------------------------------------------------------------------
// A single editor type
//-----------------------------------------------------------------------------
class CDmeEditorType : public CDmElement
{
DEFINE_ELEMENT( CDmeEditorType, CDmElement );
public:
// Adds a editor type to be associated with a particular attribute
void AddAttributeInfo( const char *pAttributeName, CDmeEditorAttributeInfo *pInfo );
// Removes a editor type associated with a particular attribute
void RemoveAttributeInfo( const char *pAttributeName );
// Returns the editor info associated with an editor type
CDmeEditorAttributeInfo *GetAttributeInfo( const char *pAttributeName );
// Returns the editor info associated with a single entry in an attribute array
CDmeEditorAttributeInfo *GetAttributeArrayInfo( const char *pAttributeName );
private:
// Computes the actual attribute name stored in the type
const char *GetActualAttributeName( const char *pAttributeName );
};
//-----------------------------------------------------------------------------
// A dictionary of all editor types
//-----------------------------------------------------------------------------
class CDmeEditorTypeDictionary : public CDmElement
{
DEFINE_ELEMENT( CDmeEditorTypeDictionary, CDmElement );
public:
void AddEditorTypesFromFile( const char *pFileName, const char *pPathID );
void AddEditorType( CDmeEditorType *pEditorType );
// Returns the editor info associated with an editor type
CDmeEditorAttributeInfo *GetAttributeInfo( CDmElement *pElement, const char *pAttributeName );
// Returns the editor info associated with a single entry in an attribute array
CDmeEditorAttributeInfo *GetAttributeArrayInfo( CDmElement *pElement, const char *pAttributeName );
private:
// Returns the editor type to use with an element
CDmeEditorType *GetEditorType( CDmElement *pElement );
};
#endif // DMEEDITORTYPEDICTIONARY_H

View File

@@ -0,0 +1,55 @@
//============ Copyright (c) Valve Corporation, All rights reserved. ==========
//
//=============================================================================
#ifndef DMEEXPORTTAGS_H
#define DMEEXPORTTAGS_H
#include "datamodel/dmelement.h"
//=============================================================================
//
//=============================================================================
class CDmeExportTags : public CDmElement
{
DEFINE_ELEMENT( CDmeExportTags, CDmElement );
public:
// Initializes all fields by calling each Set* function with no arguments
void Init( const char *pszApp = NULL, const char *pszAppVersion = NULL );
// Sets the app field, if NULL, app is the empty string
void SetApp( const char *pszVal = NULL );
const char *GetApp() const { return m_sApp.GetString(); }
// Sets the app version, if NULL, appVersion is the empty string
void SetAppVersion( const char *pszVal = NULL );
const char *GetAppVersion() const { return m_sAppVersion.GetString(); }
// Sets the date, if NULL, date is set to the current date
void SetDate( const char *pszVal = NULL );
const char *GetDate() const { return m_sDate.GetString(); }
// Sets the time, if NULL, time is set to the current date
void SetTime( const char *pszVal = NULL );
const char *GetTime() const { return m_sTime.GetString(); }
// Sets the user, if NULL, time is set to the current user
void SetUser( const char *pszVal = NULL );
const char *GetUser() const { return m_sUser.GetString(); }
// Sets the machine, if NULL, machine is set to the current machine
void SetMachine( const char *pszVal = NULL );
const char *GetMachine() const { return m_sMachine.GetString(); }
protected:
CDmaString m_sApp;
CDmaString m_sAppVersion;
CDmaString m_sDate;
CDmaString m_sTime;
CDmaString m_sUser;
CDmaString m_sMachine;
};
#endif // DMEEXPORTTAGS_H

View File

@@ -0,0 +1,48 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// The expression operator class - scalar math calculator
// for a good list of operators and simple functions, see:
// \\fileserver\user\MarcS\boxweb\aliveDistLite\v4.2.0\doc\alive\functions.txt
// (although we'll want to implement elerp as the standard 3x^2 - 2x^3 with rescale)
//
//=============================================================================
#ifndef DMEEXPRESSIONOPERATOR_H
#define DMEEXPRESSIONOPERATOR_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmeoperator.h"
#include "mathlib/expressioncalculator.h"
//-----------------------------------------------------------------------------
// An operator which computes the value of expressions
//-----------------------------------------------------------------------------
class CDmeExpressionOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmeExpressionOperator, CDmeOperator );
public:
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
void SetSpewResult( bool state );
protected:
bool Parse( const char *expr );
bool IsInputAttribute( CDmAttribute *pAttribute );
CExpressionCalculator m_calc;
CDmaVar< float > m_result;
CDmaString m_expr;
CDmaVar< bool > m_bSpewResult;
};
#endif // DMEEXPRESSIONOPERATOR_H

View File

@@ -0,0 +1,87 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class representing an abstract shape (ie drawable object)
//
//=============================================================================
#ifndef DMEFACESET_H
#define DMEFACESET_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "tier1/utlvector.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeMaterial;
//-----------------------------------------------------------------------------
// A class representing a face of a polygonal mesh
//-----------------------------------------------------------------------------
class CDmeFaceSet : public CDmElement
{
DEFINE_ELEMENT( CDmeFaceSet, CDmElement );
public:
// material accessors
CDmeMaterial *GetMaterial();
void SetMaterial( CDmeMaterial *pMaterial );
// Total number of indices in the face set including the -1 end of face designators
int NumIndices() const;
const int *GetIndices() const;
int AddIndices( int nCount );
void SetIndex( int i, int nValue );
void SetIndices( int nFirstIndex, int nCount, int *pIndices );
int GetIndex( int i ) const;
// Returns the number of vertices in the next polygon
int GetNextPolygonVertexCount( int nFirstIndex ) const;
// Returns the number of triangulated indices total
int GetTriangulatedIndexCount() const;
// Total number of indices in the face set excluding the -1 end of face designators
int GetIndexCount() const;
// Removes multiple faces from the face set
void RemoveMultiple( int elem, int num );
// Returns the number of faces in total... This should be the number of -1 indices in the face set
// Which should equal NumIndices() - GetIndexCount() but this function accounts for
// empty faces (which aren't counted as faces) and a missing -1 terminator at the end
int GetFaceCount() const;
private:
CDmaArray< int > m_indices;
CDmaElement< CDmeMaterial > m_material;
};
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
inline int CDmeFaceSet::NumIndices() const
{
return m_indices.Count();
}
inline const int *CDmeFaceSet::GetIndices() const
{
return m_indices.Base();
}
inline int CDmeFaceSet::GetIndex( int i ) const
{
return m_indices[i];
}
#endif // DMEFACESET_H

View File

@@ -0,0 +1,144 @@
//=========== Copyright (c) Valve Corporation, All rights reserved. ===========
//
//=============================================================================
#ifndef DMEFLEXRULES_H
#define DMEFLEXRULES_H
#if defined( COMPILER_MSVC )
#pragma once
#endif
// Valve includes
#include "datamodel/dmattributevar.h"
#include "mathlib/expressioncalculator.h"
#include "movieobjects/dmeoperator.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeCombinationOperator;
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
class CDmeFlexRuleBase : public CDmeOperator
{
DEFINE_ELEMENT( CDmeFlexRuleBase, CDmeOperator );
public:
// CDmeOperator
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
CDmAttribute *ResultAttr() { return m_flResult.GetAttribute(); }
protected:
friend class CDmeFlexRules;
CDmeFlexRules *GetFlexRules() const;
CDmaVar< float > m_flResult;
};
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
class CDmeFlexRulePassThrough : public CDmeFlexRuleBase
{
DEFINE_ELEMENT( CDmeFlexRulePassThrough, CDmeFlexRuleBase );
public:
// CDmeOperator
virtual void Operate();
protected:
friend class CDmeFlexRules;
};
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
class CDmeFlexRuleExpression : public CDmeFlexRuleBase
{
DEFINE_ELEMENT( CDmeFlexRuleExpression, CDmeFlexRuleBase );
public:
// CDmeOperator
virtual void Operate();
virtual void Resolve();
bool SetExpression( const char *pszExpression );
const char *GetExpression() const { return m_expr.Get(); }
protected:
friend class CDmeFlexRules;
CDmaString m_expr;
CExpressionCalculator m_calc;
};
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
class CDmeFlexRuleLocalVar : public CDmeFlexRuleBase
{
DEFINE_ELEMENT( CDmeFlexRuleLocalVar, CDmeFlexRuleBase );
public:
protected:
friend class CDmeFlexRules;
};
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
class CDmeFlexRules : public CDmeOperator
{
DEFINE_ELEMENT( CDmeFlexRules, CDmeOperator );
public:
// From DmeOperator
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
virtual void Operate();
virtual void Resolve();
void AddFlexRule( CDmeFlexRuleBase *pDmeFlexRule );
int GetRuleCount() const { return m_eDeltaStates.Count(); }
CDmeFlexRuleBase *GetRule( int i ) const { return ( i < 0 || i >= GetRuleCount() ) ? NULL : m_eDeltaStates[i]; }
void RemoveAllRules();
void SetTarget( CDmElement *pDmElement );
int GetDeltaStateIndex( const char *pszDeltaName ) const;
float GetDeltaStateWeight( const char *pszDeltaName ) const;
protected:
friend class CDmeFlexRuleBase;
friend class CDmeFlexRuleExpression;
// Required to drive this node from a DmeCombinationOperator
CDmaElementArray< CDmeFlexRuleBase > m_eDeltaStates;
CDmaArray< Vector2D > m_vDeltaStateWeights;
CDmaElement< CDmElement > m_eTarget;
CDmeCombinationOperator *GetComboOp() const;
CUtlVector< int > m_deltaToTargetMap;
};
#endif // DMEFLEXRULES_H

View File

@@ -0,0 +1,209 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// Dme version of a game model (MDL)
//
//=============================================================================
#ifndef DMEGAMEMODEL_H
#define DMEGAMEMODEL_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmedag.h"
#include "movieobjects/dmeoperator.h"
#include "datacache/imdlcache.h"
#include "tier1/UtlDict.h"
#include "toolframework/itoolframework.h"
struct studiohdr_t;
// Fixme, this might not be the best spot for this
class IGlobalFlexController
{
public:
virtual int FindGlobalFlexController( char const *name ) = 0;
virtual char const *GetGlobalFlexControllerName( int idx ) = 0;
};
class CDmeGameModel;
// Mapping from name to dest index
class CDmeGlobalFlexControllerOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmeGlobalFlexControllerOperator, CDmeOperator );
public:
void SetGameModel( CDmeGameModel *gameModel );
virtual void Resolve();
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
void SetWeight( float flWeight );
void SetMapping( int globalIndex );
void SetupToAttribute();
int GetGlobalIndex() const;
virtual void OnAttributeChanged( CDmAttribute *pAttribute );
CDmaVar< float > m_flexWeight;
CDmaElement< CDmeGameModel > m_gameModel;
DmAttributeHandle_t m_ToAttributeHandle;
private:
int FindGlobalFlexControllerIndex() const;
int m_nFlexControllerIndex;
};
//-----------------------------------------------------------------------------
// A class representing a game model
//-----------------------------------------------------------------------------
class CDmeGameModel : public CDmeDag
{
DEFINE_ELEMENT( CDmeGameModel, CDmeDag );
public:
virtual void OnAttributeChanged( CDmAttribute *pAttribute );
void AddBone( CDmeTransform* pTransform );
void AddBones( studiohdr_t *pStudioHdr, int nFirstBone, int nCount );
void SetBone( uint index, const Vector& pos, const Quaternion& rot );
uint NumBones() const;
CDmeTransform *GetBone( uint index ) const;
int FindBone( CDmeTransform *pTransform ) const;
void RemoveAllBones();
// A src bone transform transforms pre-compiled data (.dmx or .smd files, for example)
// into post-compiled data (.mdl or .ani files)
// Returns false if there is no transform (or if the transforms are identity)
bool GetSrcBoneTransforms( matrix3x4_t *pPreTransform, matrix3x4_t *pPostTransform, int nBoneIndex ) const;
bool GetBoneDefaultPosition( int nBoneIndex, Vector &position ) const;
bool GetBoneDefaultOrientation( int nBoneIndex, Quaternion &orientation ) const;
bool IsRootTransform( int nBoneIndex ) const;
uint NumFlexWeights() const;
const CUtlVector< float >& GetFlexWeights() const;
// We drive these through the operators instead
// void SetFlexWeights( uint nFlexWeights, const float* flexWeights );
void SetNumFlexWeights( uint nFlexWeights );
void SetFlexWeights( uint nFlexWeights, const float* flexWeights );
void SetSkin( int nSkin );
void SetBody( int nBody );
void SetSequence( int nSequence );
void SetFlags( int nFlags );
int GetSkin() const;
int GetBody() const;
int GetSequence() const;
int GetFlags() const;
const char *GetModelName() const;
MDLHandle_t GetModelHandle();
CDmeGlobalFlexControllerOperator *AddGlobalFlexController( char const *controllerName, int globalIndex );
CDmeGlobalFlexControllerOperator *FindGlobalFlexController( int nGlobalIndex );
void RemoveGlobalFlexController( CDmeGlobalFlexControllerOperator *controller );
int NumGlobalFlexControllers() const;
CDmeGlobalFlexControllerOperator *GetGlobalFlexController( int localIndex ); // localIndex is in order of calls to AddGlobalFlexController
void AppendGlobalFlexControllerOperators( CUtlVector< IDmeOperator * >& list );
studiohdr_t* GetStudioHdr() const;
void FindFlexControllerDependencies( CUtlVector< CUtlVector< int > > &dependencyList ) const;
int FindAttachment( const char *pchAttachmentName ) const;
Vector ComputeAttachmentPosition( const char *pchAttachmentName ) const;
CDmeDag *CreateDagForAttachment( const char *pchAttachmentName ) const;
void SetComputeBounds( bool bEnable ) { m_bComputeBounds = bEnable; }
void SetEvaluateProceduralBones( bool bEnable ) { m_bEvaluateProceduralBones = bEnable; }
bool ShouldComputeBounds() const { return m_bComputeBounds; }
bool ShouldEvaluateProceduralBones() const { return m_bEvaluateProceduralBones; }
public:
protected:
void PopulateExistingDagList( CDmeDag** pDags, int nCount );
void UpdateHMDL();
// This holds the operators which map to the m_flexWeights below
CDmaElementArray< CDmeGlobalFlexControllerOperator > m_globalFlexControllers;
CDmaArray< float > m_flexWeights; // These are global flex weights (so there can be gaps, unused indices)
CDmaString m_modelName;
CDmaVar< int > m_skin;
CDmaVar< int > m_body;
CDmaVar< int > m_sequence;
CDmaVar< int > m_flags;
CDmaVar< bool > m_bComputeBounds;
CDmaVar< bool > m_bEvaluateProceduralBones;
// this is different than m_Children - this is ALL transforms in the tree that are used by the model
// m_Children holds the roots of that tree
CDmaElementArray< CDmeTransform > m_bones;
MDLHandle_t m_hMDL;
bool m_bHMDLDirty;
};
//-----------------------------------------------------------------------------
// A class representing a game sprite
//-----------------------------------------------------------------------------
class CDmeGameSprite : public CDmeDag
{
DEFINE_ELEMENT( CDmeGameSprite, CDmeDag );
public:
const char *GetModelName() const;
float GetScale() const;
float GetFrame() const;
int GetRenderMode() const;
int GetRenderFX() const;
const Color &GetColor() const;
float GetProxyRadius() const;
void SetState( bool bVisible, float nFrame, int nRenderMode, int nRenderFX, float flRenderScale, float flProxyRadius, const Vector &pos, const Quaternion &rot, const Color &color );
protected:
CDmaString m_modelName;
CDmaVar< float > m_frame;
CDmaVar< int > m_rendermode;
CDmaVar< int > m_renderfx;
CDmaVar< float > m_renderscale;
CDmaVar< Color > m_color;
CDmaVar< float > m_proxyRadius;
};
//-----------------------------------------------------------------------------
// A class representing a game portal
//-----------------------------------------------------------------------------
class CDmeGamePortal : public CDmeDag
{
DEFINE_ELEMENT( CDmeGamePortal, CDmeDag );
public:
CDmaVar< int > m_nPortalId;
CDmaVar< int > m_nLinkedPortalId;
CDmaVar< float > m_flStaticAmount;
CDmaVar< float > m_flSecondaryStaticAmount;
CDmaVar< float > m_flOpenAmount;
CDmaVar< float > m_flHalfWidth;
CDmaVar< float > m_flHalfHeight;
CDmaVar< bool > m_bIsPortal2;
CDmaString m_PortalType;
};
#endif // DMEGAMEMODEL_H

View File

@@ -0,0 +1,28 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// The abstract base operator class - all actions within the scenegraph happen via operators
//
//=============================================================================
#ifndef DMEINPUT_H
#define DMEINPUT_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmeoperator.h"
//-----------------------------------------------------------------------------
// A class representing a camera
//-----------------------------------------------------------------------------
class CDmeInput : public CDmeOperator
{
DEFINE_ELEMENT( CDmeInput, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
};
#endif // DMEINPUT_H

View File

@@ -0,0 +1,46 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =====//
//
// Dme version of a joint of a skeletal model (gets compiled into a MDL)
//
//===========================================================================//
#ifndef DMEJOINT_H
#define DMEJOINT_H
#ifdef _WIN32
#pragma once
#endif
// Valve includes
#include "movieobjects/dmedag.h"
#include "materialsystem/imaterial.h"
#include "materialsystem/materialsystemutil.h"
// Forward declarations
class CDmeDrawSettings;
//-----------------------------------------------------------------------------
// A class representing a skeletal model
//-----------------------------------------------------------------------------
class CDmeJoint : public CDmeDag
{
DEFINE_ELEMENT( CDmeJoint, CDmeDag );
public:
virtual void Draw( CDmeDrawSettings *pDrawSettings = NULL );
static void DrawJointHierarchy( bool bDrawJoints );
private:
void DrawJoints();
static bool sm_bDrawJoints;
static IMaterial *sm_pMatJoint;
CMaterialReference m_MatRefJoint;
};
#endif // DMEJOINT_H

View File

@@ -0,0 +1,36 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// The keyboard input class
//
//=============================================================================
#ifndef DMEKEYBOARDINPUT_H
#define DMEKEYBOARDINPUT_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmeinput.h"
//-----------------------------------------------------------------------------
// A class representing a camera
//-----------------------------------------------------------------------------
class CDmeKeyboardInput : public CDmeInput
{
DEFINE_ELEMENT( CDmeKeyboardInput, CDmeInput );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< bool > *m_keys;
bool GetKeyStatus( uint ki );
};
#endif // DMEKEYBOARDINPUT_H

View File

@@ -0,0 +1,116 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class representing a light
//
//=============================================================================
#ifndef DMELIGHT_H
#define DMELIGHT_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmedag.h"
//-----------------------------------------------------------------------------
// Forward declaration
//-----------------------------------------------------------------------------
struct LightDesc_t;
//-----------------------------------------------------------------------------
// A base class for lights
//-----------------------------------------------------------------------------
class CDmeLight : public CDmeDag
{
DEFINE_ELEMENT( CDmeLight, CDmeDag );
public:
// Sets the color and intensity
// NOTE: Color is specified 0-255 floating point.
void SetColor( const Color &color );
void SetIntensity( float flIntensity );
// Sets up render state in the material system for rendering
virtual bool GetLightDesc( LightDesc_t *pDesc ) { return false; }
protected:
// Sets up render state in the material system for rendering
void SetupRenderStateInternal( LightDesc_t &desc, float flAtten0, float flAtten1, float flAtten2 );
CDmaVar< Color > m_Color;
CDmaVar< float > m_flIntensity;
};
//-----------------------------------------------------------------------------
// A directional light
//-----------------------------------------------------------------------------
class CDmeDirectionalLight : public CDmeLight
{
DEFINE_ELEMENT( CDmeDirectionalLight, CDmeLight );
public:
// Sets up render state in the material system for rendering
virtual bool GetLightDesc( LightDesc_t *pDesc );
};
//-----------------------------------------------------------------------------
// A point light
//-----------------------------------------------------------------------------
class CDmePointLight : public CDmeLight
{
DEFINE_ELEMENT( CDmePointLight, CDmeLight );
public:
// Sets the attenuation factors
void SetAttenuation( float flConstant, float flLinear, float flQuadratic );
// Sets the maximum range
void SetMaxDistance( float flMaxDistance );
// Sets up render state in the material system for rendering
virtual bool GetLightDesc( LightDesc_t *pDesc );
protected:
CDmaVar< float > m_flAttenuation0;
CDmaVar< float > m_flAttenuation1;
CDmaVar< float > m_flAttenuation2;
CDmaVar< float > m_flMaxDistance;
};
//-----------------------------------------------------------------------------
// A spot light
//-----------------------------------------------------------------------------
class CDmeSpotLight : public CDmePointLight
{
DEFINE_ELEMENT( CDmeSpotLight, CDmePointLight );
public:
// Sets the spotlight angle factors
// Angles are specified in degrees, as full angles (as opposed to half-angles)
void SetAngles( float flInnerAngle, float flOuterAngle, float flAngularFalloff );
// Sets up render state in the material system for rendering
virtual bool GetLightDesc( LightDesc_t *pDesc );
private:
CDmaVar<float> m_flSpotInnerAngle;
CDmaVar<float> m_flSpotOuterAngle;
CDmaVar<float> m_flSpotAngularFalloff;
};
//-----------------------------------------------------------------------------
// An ambient light
//-----------------------------------------------------------------------------
class CDmeAmbientLight : public CDmeLight
{
DEFINE_ELEMENT( CDmeAmbientLight, CDmeLight );
};
#endif // DMELIGHT_H

1150
public/movieobjects/dmelog.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,237 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =====//
//
// Describes the way to compile a MDL file (eventual replacement for qc)
//
//===========================================================================//
#ifndef DMEMAKEFILE_H
#define DMEMAKEFILE_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "datamodel/dmehandle.h"
#include "vstdlib/iprocessutils.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeMakefile;
//-----------------------------------------------------------------------------
// Returns a list of source types and whether there can be only 1 or not
//-----------------------------------------------------------------------------
struct DmeMakefileType_t
{
const char *m_pTypeName;
const char *m_pHumanReadableName;
bool m_bIsSingleton;
const char *m_pDefaultDirectoryID; // NOTE: Use CDmeMakefile::GetDefaultDirectory, passing this in to crack it.
const char *m_pFileFilter;
const char *m_pFileFilterString;
};
//-----------------------------------------------------------------------------
// Describes an asset source; contains a source name + options
//-----------------------------------------------------------------------------
class CDmeSource : public CDmElement
{
DEFINE_ELEMENT( CDmeSource, CDmElement );
public:
// NOTE: Filenames are stored as relative file names in dmesource
// To resolve them to full paths, use CDmeMakefile::GetSourceFullPath
const char *GetRelativeFileName() const;
void SetRelativeFileName( const char *pFileName );
// If this source can be built by another makefile, return the type of makefile
// NOTE: This can be a base class of a number of makefile types
virtual const char **GetSourceMakefileTypes() { return NULL; }
// Sets/gets the makefile that was used to build this source
// NOTE: This information isn't saved and must be reconstructed each frame
void SetDependentMakefile( CDmeMakefile *pMakeFile );
CDmeMakefile *GetDependentMakefile();
// Call this to open the source file in an editor
void OpenEditor();
private:
// The makefile that built this source
CDmeHandle< CDmeMakefile > m_DependentMakefile;
};
inline const char *CDmeSource::GetRelativeFileName() const
{
return m_Name;
}
inline void CDmeSource::SetRelativeFileName( const char *pName )
{
m_Name = pName;
}
//-----------------------------------------------------------------------------
// Describes an asset: something that is compiled from sources
//-----------------------------------------------------------------------------
class CDmeMakefile : public CDmElement
{
DEFINE_ELEMENT( CDmeMakefile, CDmElement );
public:
// NOTE: Adding or removing sources of the specified type will invalidate the index
// NOTE: This index is the same index used in GetSources()
CDmeSource *AddSource( const char *pSourceType, const char *pFullPath );
template< class T >
T* AddSource( const char *pFullPath );
CDmeSource *SetSingleSource( const char *pSourceType, const char *pFullPath );
template< class T >
T* SetSingleSource( const char *pFullPath );
CDmeSource *FindSource( const char *pSourceType, const char *pFullPath );
void RemoveSource( const char *pSourceType, const char *pFullPath );
void RemoveSource( CDmeSource *pSource );
void RemoveAllSources( const char *pSourceType );
bool HasSourceOfType( const char *pSourceType );
// Gets/sets paths associated with sources
void SetSourceFullPath( CDmeSource *pSource, const char *pFullPath );
void GetSourceFullPath( CDmeSource *pSource, char *pFullPath, int nBufLen );
// Returns the output directory we expect to compile files into
bool GetOutputDirectory( char *pFullPath, int nBufLen );
// Returns the output name (output directory + filename, no extension)
bool GetOutputName( char *pFullPath, int nBufLen );
// Call this to change the file the makefile is stored in
// Will make all sources be relative to this path
bool SetFileName( const char *pFileName );
const char *GetFileName() const;
// Gets a list of all sources of a particular type
void GetSources( const char *pSourceType, CUtlVector< CDmeHandle< CDmeSource > > &sources );
template< class T >
void GetSources( CUtlVector< CDmeHandle<T> > &sources );
// Gets a list of all sources, regardless of type
int GetSourceCount();
CDmeSource *GetSource( int nIndex );
virtual DmeMakefileType_t *GetMakefileType() { return NULL; }
virtual DmeMakefileType_t* GetSourceTypes() { Assert(0); return NULL; }
// FIXME: Should we have output types? Not sure...
virtual void GetOutputs( CUtlVector<CUtlString> &fullPaths ) { Assert(0); }
// Converts the m_pDefaultDirectoryID field of the DmeMakefileType_t to a full path
bool GetDefaultDirectory( const char *pDefaultDirectoryID, char *pFullPath, int nBufLen );
// These methods are used to help traverse a dependency graph.
// They work with information that is not saved.
void SetAssociation( CDmeSource *pSource, CDmeMakefile *pSourceMakefile );
CDmeMakefile *FindDependentMakefile( CDmeSource *pSource );
CDmeSource *FindAssociatedSource( CDmeMakefile *pChildMakefile );
CDmElement *GetOutputElement( bool bCreateIfNecessary = false );
// Performs compilation steps
void PreCompile( );
void PostCompile( );
// Dirty, dirty!
bool IsDirty() const;
void SetDirty( bool bDirty );
protected:
// Make all outputs writeable
void MakeOutputsWriteable( );
// Gets the path of the makefile
void GetMakefilePath( char *pFullPath, int nBufLen );
private:
// Inherited classes should re-implement these methods
virtual CDmElement *CreateOutputElement( ) { return NULL; }
virtual void DestroyOutputElement( CDmElement *pOutput ) { }
virtual IProcess* PerformCompilation() { Assert(0); return NULL; }
virtual const char *GetOutputDirectoryID() { return "makefilegamedir:"; }
private:
// Relative path to full path
void RelativePathToFullPath( const char *pRelativePath, char *pFullPath, int nBufLen );
// Fullpath to relative path
void FullPathToRelativePath( const char *pFullPath, char *pRelativePath, int nBufLen );
// Updates the source names to be relative to a particular path
bool UpdateSourceNames( const char *pOldRootDir, const char *pNewRootDir, bool bApplyChanges );
CDmaElementArray< CDmeSource > m_Sources;
CDmeHandle< CDmElement > m_hOutput;
IProcess *m_hCompileProcess;
bool m_bIsDirty;
};
//-----------------------------------------------------------------------------
// Dirty, dirty!
//-----------------------------------------------------------------------------
inline bool CDmeMakefile::IsDirty() const
{
return m_bIsDirty;
}
inline void CDmeMakefile::SetDirty( bool bDirty )
{
m_bIsDirty = bDirty;
}
//-----------------------------------------------------------------------------
// Gets a list of all sources of a particular type
//-----------------------------------------------------------------------------
template< class T >
void CDmeMakefile::GetSources( CUtlVector< CDmeHandle<T> > &sources )
{
int nCount = m_Sources.Count();
sources.EnsureCapacity( nCount );
for ( int i = 0; i < nCount; ++i )
{
if ( m_Sources[i]->IsA( T::GetStaticTypeSymbol() ) )
{
int j = sources.AddToTail();
sources[j] = CastElement<T>( m_Sources[i] );
}
}
}
//-----------------------------------------------------------------------------
// Template version to add a source
//-----------------------------------------------------------------------------
template< class T >
T* CDmeMakefile::AddSource( const char *pFullPath )
{
return CastElement< T >( AddSource( T::GetStaticTypeSymbol().String(), pFullPath ) );
}
//-----------------------------------------------------------------------------
// Template version to set a single source
//-----------------------------------------------------------------------------
template< class T >
T* CDmeMakefile::SetSingleSource( const char *pFullPath )
{
return CastElement< T >( SetSingleSource( g_pDataModel->GetString( T::GetStaticTypeSymbol() ), pFullPath ) );
}
#endif // DMEMAKEFILE_H

View File

@@ -0,0 +1,301 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =====//
//
// Interface for makefiles to build differently depending on where they are run from
//
//===========================================================================//
#ifndef DMEMAKEFILEUTILS_H
#define DMEMAKEFILEUTILS_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/idmemakefileutils.h"
#include "datamodel/dmehandle.h"
#include "tier1/utlsymbol.h"
#include "tier3/tier3.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeMakefileUtils;
class CDmeMDLMakefile;
class CDmeMayaMakefile;
class CDmeSourceMayaFile;
class CDmeMakefile;
//-----------------------------------------------------------------------------
//
// This glue code here is to make it easy to create methods using various DmElement types
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Compilation steps
//-----------------------------------------------------------------------------
enum CompilationStep_t
{
BUILDING_STANDARD_DEPENDENCIES = 0,
BUILDING_ALL_DEPENDENCIES,
BEFORE_COMPILATION,
PERFORMING_COMPILATION,
AFTER_COMPILATION_FAILED,
AFTER_COMPILATION_SUCCEEDED,
NOT_COMPILING,
};
//-----------------------------------------------------------------------------
// Utility adapter class to hook compile funcs into the map
//-----------------------------------------------------------------------------
class CCompileFuncAdapterBase
{
public:
virtual void InitializeAdapter( ) = 0;
virtual bool PerformCompilationStep( CDmElement *pElement, CompilationStep_t step ) = 0;
protected:
// Constructor, protected because these should never be instanced directly
CCompileFuncAdapterBase( ) {}
public:
CUtlSymbolLarge m_ElementType;
CCompileFuncAdapterBase *m_pNext;
};
template< class U, class T >
class CCompileFuncAdapter : public CCompileFuncAdapterBase
{
typedef CCompileFuncAdapterBase BaseClass;
public:
CCompileFuncAdapter( )
{
// Hook into the list
m_pNext = U::m_CompileFuncTree.m_pFirstAdapter;
U::m_CompileFuncTree.m_pFirstAdapter = this;
}
virtual void InitializeAdapter( )
{
m_ElementType = T::GetStaticTypeSymbol();
if ( m_pNext )
{
m_pNext->InitializeAdapter();
}
}
virtual bool PerformCompilationStep( CDmElement *pElement, CompilationStep_t step )
{
T *pConverted = CastElement< T >( pElement );
if ( pConverted )
return U::m_pSingleton->PerformCompilationStep( pConverted, step );
return false;
}
};
//-----------------------------------------------------------------------------
// Utility adapter class to hook editor opening funcs into the map
//-----------------------------------------------------------------------------
class COpenEditorFuncAdapterBase
{
public:
virtual void InitializeAdapter( ) = 0;
virtual void OpenEditor( CDmElement *pElement ) = 0;
protected:
// Constructor, protected because these should never be instanced directly
COpenEditorFuncAdapterBase( ) {}
public:
CUtlSymbolLarge m_ElementType;
COpenEditorFuncAdapterBase *m_pNext;
};
template< class U, class T >
class COpenEditorFuncAdapter : public COpenEditorFuncAdapterBase
{
typedef COpenEditorFuncAdapterBase BaseClass;
public:
COpenEditorFuncAdapter( )
{
// Hook into the list
m_pNext = U::m_OpenEditorFuncTree.m_pFirstAdapter;
U::m_OpenEditorFuncTree.m_pFirstAdapter = this;
}
virtual void InitializeAdapter( )
{
m_ElementType = T::GetStaticTypeSymbol();
if ( m_pNext )
{
m_pNext->InitializeAdapter();
}
}
virtual void OpenEditor( CDmElement *pElement )
{
T *pConverted = CastElement< T >( pElement );
if ( pConverted )
{
U::m_pSingleton->OpenEditor( pConverted );
}
}
};
#define DECLARE_DMEMAKEFILE_UTIL_CLASS_BASE( _className ) \
protected: \
typedef _className ThisClass; \
static CompileFuncTree_t m_CompileFuncTree; \
static OpenEditorFuncTree_t m_OpenEditorFuncTree; \
static _className *m_pSingleton; \
template< typename U, typename T > friend class CCompileFuncAdapter; \
template< typename U, typename T > friend class COpenEditorFuncAdapter; \
virtual CompileFuncTree_t* GetCompileTree() \
{ \
return &m_CompileFuncTree; \
} \
virtual OpenEditorFuncTree_t* GetOpenEditorTree() \
{ \
return &m_OpenEditorFuncTree; \
} \
#define DECLARE_DMEMAKEFILE_UTIL_CLASS( _className, _baseClass ) \
DECLARE_DMEMAKEFILE_UTIL_CLASS_BASE( _className ) \
typedef _baseClass BaseClass; \
protected: \
virtual void InitializeFuncMaps() \
{ \
m_pSingleton = this; \
m_CompileFuncTree.m_pBaseAdapterTree = &BaseClass::m_CompileFuncTree; \
m_CompileFuncTree.m_pFirstAdapter->InitializeAdapter( ); \
m_OpenEditorFuncTree.m_pBaseAdapterTree = &BaseClass::m_OpenEditorFuncTree; \
m_OpenEditorFuncTree.m_pFirstAdapter->InitializeAdapter( ); \
BaseClass::InitializeFuncMaps(); \
} \
#define DECLARE_DMEMAKEFILE_UTIL_CLASS_ROOT( _className ) \
DECLARE_DMEMAKEFILE_UTIL_CLASS_BASE( _className ) \
protected: \
virtual void InitializeFuncMaps() \
{ \
m_pSingleton = this; \
m_CompileFuncTree.m_pBaseAdapterTree = NULL; \
m_CompileFuncTree.m_pFirstAdapter->InitializeAdapter( ); \
m_OpenEditorFuncTree.m_pBaseAdapterTree = NULL; \
m_OpenEditorFuncTree.m_pFirstAdapter->InitializeAdapter( ); \
} \
#define IMPLEMENT_DMEMAKEFILE_UTIL_CLASS( _className ) \
CDmeMakefileUtils::CompileFuncTree_t _className::m_CompileFuncTree; \
CDmeMakefileUtils::OpenEditorFuncTree_t _className::m_OpenEditorFuncTree; \
_className *_className::m_pSingleton; \
#define DECLARE_COMPILEFUNC( _className ) \
bool PerformCompilationStep( _className *pClassName, CompilationStep_t step ); \
CCompileFuncAdapter< ThisClass, _className > m_##_className##CompileAdapter
#define DECLARE_OPENEDITORFUNC( _className ) \
void OpenEditor( _className *pClassName ); \
COpenEditorFuncAdapter< ThisClass, _className > m_##_className##OpenEditorAdapter
//-----------------------------------------------------------------------------
// Interface for makefiles to build differently depending on where they are run from
//-----------------------------------------------------------------------------
class CDmeMakefileUtils : public CTier3AppSystem<IDmeMakefileUtils>
{
protected:
struct CompileFuncTree_t
{
CCompileFuncAdapterBase *m_pFirstAdapter;
CompileFuncTree_t *m_pBaseAdapterTree;
};
struct OpenEditorFuncTree_t
{
COpenEditorFuncAdapterBase *m_pFirstAdapter;
OpenEditorFuncTree_t *m_pBaseAdapterTree;
};
typedef CTier3AppSystem< IDmeMakefileUtils > BaseClass;
DECLARE_DMEMAKEFILE_UTIL_CLASS_ROOT( CDmeMakefileUtils );
public:
// Constructor, destructor
CDmeMakefileUtils();
virtual ~CDmeMakefileUtils();
// Inherited from IAppSystem
virtual void *QueryInterface( const char *pInterfaceName );
virtual InitReturnVal_t Init();
// Inherited from IDmeMakefileUtils
virtual void PerformCompile( CDmElement *pElement, bool bBuildAllDependencies );
virtual bool IsCurrentlyCompiling( );
virtual int GetCompileOutputSize();
virtual CompilationState_t UpdateCompilation( char *pOutputBuf, int nBufLen );
virtual void AbortCurrentCompilation();
virtual void PerformOpenEditor( CDmElement *pElement );
virtual int GetExitCode();
protected:
// Compile functions + editor functions
DECLARE_COMPILEFUNC( CDmElement );
DECLARE_COMPILEFUNC( CDmeMakefile );
DECLARE_COMPILEFUNC( CDmeMDLMakefile );
DECLARE_COMPILEFUNC( CDmeMayaMakefile );
DECLARE_OPENEDITORFUNC( CDmeSourceMayaFile );
// Queues up a compilation task
// ( Call only in BUILDING_STANDARD_DEPENDENCIES or BUILDING_ALL_DEPENDENCIES )
void AddCompilationTask( CDmElement* pElement );
// Sets the compilation process handle
// ( Call only in PERFORMING_COMPILATION )
void SetCompileProcess( IProcess *hProcess );
private:
struct CompileInfo_t
{
CDmeHandle< CDmElement > m_hElement;
CCompileFuncAdapterBase *m_pAdapter;
};
// Finds the adapter class associated with a particular element type
CCompileFuncAdapterBase *DetermineCompileAdapter( CDmElement *pElement );
COpenEditorFuncAdapterBase *DetermineOpenEditorAdapter( CDmElement *pElement );
// Dequeue the first compile task and start it up
void StartNextCompileTask();
// Performs the compilation step on all elements
bool PerformCompilationStep( CompilationStep_t step );
// Queues up a compilation task
void AddCompilationTask( CDmElement* pElement, CCompileFuncAdapterBase *pAdapter );
// Default implementatations for compile dependencies
bool AddCompileDependencies( CDmeMakefile *pMakefile, bool bBuildAllDependencies );
CUtlVector< CompileInfo_t > m_CompileTasks;
IProcess *m_hCompileProcess;
int m_nCurrentCompileTask;
int m_nExitCode;
CompilationStep_t m_CompilationStep;
};
#endif // DMEMAKEFILEUTILS_H

View File

@@ -0,0 +1,45 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class representing a material
//
//=============================================================================
#ifndef DMEMATERIAL_H
#define DMEMATERIAL_H
#ifdef _WIN32
#pragma once
#endif
// Valve includes
#include "datamodel/dmelement.h"
#include "materialsystem/materialsystemutil.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class IMaterial;
//-----------------------------------------------------------------------------
// A class representing a material
//-----------------------------------------------------------------------------
class CDmeMaterial : public CDmElement
{
DEFINE_ELEMENT( CDmeMaterial, CDmElement );
public:
IMaterial *GetCachedMTL();
void SetMaterial( const char *pMaterialName );
const char *GetMaterialName() const;
virtual void Resolve();
private:
CMaterialReference m_mtlRef;
CDmaString m_mtlName;
};
#endif // DMEMATERIAL_H

View File

@@ -0,0 +1,63 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMEMATERIALOVERLAYFXCLIP_H
#define DMEMATERIALOVERLAYFXCLIP_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmeclip.h"
#include "materialsystem/materialsystemutil.h"
#include "datamodel/dmelementfactoryhelper.h"
//-----------------------------------------------------------------------------
// An effect clip
//-----------------------------------------------------------------------------
class CDmeMaterialOverlayFXClip : public CDmeFXClip
{
DEFINE_ELEMENT( CDmeMaterialOverlayFXClip, CDmeFXClip );
public:
// All effects must be able to apply their effect
virtual void ApplyEffect( DmeTime_t time, Rect_t &currentRect, Rect_t &totalRect, ITexture *pTextures[MAX_FX_INPUT_TEXTURES] );
// Resolves changes
virtual void Resolve();
// Sets the overlay material
void SetOverlayEffect( const char *pMaterialName );
void SetAlpha( float flAlpha );
bool HasOpaqueOverlay();
IMaterial *GetMaterial();
float GetAlpha();
private:
CDmaString m_Material;
CDmaColor m_Color;
CDmaVar<int> m_nLeft;
CDmaVar<int> m_nTop;
CDmaVar<int> m_nWidth;
CDmaVar<int> m_nHeight;
CDmaVar<bool> m_bFullScreen;
CDmaVar<bool> m_bUseSubRect;
CDmaVar<int> m_nSubRectLeft;
CDmaVar<int> m_nSubRectTop;
CDmaVar<int> m_nSubRectWidth;
CDmaVar<int> m_nSubRectHeight;
CDmaVar<float> m_flMovementAngle;
CDmaVar<float> m_flMovementSpeed;
CMaterialReference m_OverlayMaterial;
CMaterialReference m_BltMaterial;
void DrawQuad( int x, int y, int w, int h, float u0, float v0, float u1, float v1 );
void DrawOneToOneQuad( int nWidth, int nHeight );
};
#endif // DMEMATERIALOVERLAYFXCLIP_H

View File

@@ -0,0 +1,84 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class representing an MDL
//
//=============================================================================
#ifndef DMEMDL_H
#define DMEMDL_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "movieobjects/dmeshape.h"
#include "datacache/imdlcache.h"
#include "tier3/mdlutils.h"
#include "mathlib/vector.h"
#include <string>
#include <vector>
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeTransform;
class IMorph;
class IMaterial;
struct SubdivMesh_t;
class IMesh;
class CDmeDrawSettings;
struct matrix3x4_t;
class CStudioHdr;
//-----------------------------------------------------------------------------
// A class representing an MDL
//-----------------------------------------------------------------------------
class CDmeMDL : public CDmeShape
{
DEFINE_ELEMENT( CDmeMDL, CDmeShape );
public:
virtual void Draw( const matrix3x4_t& shapeToWorld, CDmeDrawSettings *pDrawSettings = NULL );
void DrawInEngine( bool bDrawInEngine );
bool IsDrawingInEngine() const;
void ZUp( bool bZUp );
bool IsZUp() const;
void SetMDL( MDLHandle_t handle );
MDLHandle_t GetMDL( ) const;
float GetRadius() const; // NOTE: This radius is one that is centered at the origin
void GetBoundingSphere( Vector &vecCenter, float &flRadius );
void GetBoundingBox( Vector *pMins, Vector *pMaxs ) const;
// Computes bone-to-world transforms
void SetUpBones( const matrix3x4_t& shapeToWorld, int nMaxBoneCount, matrix3x4_t *pOutputMatrices );
public:
CDmaColor m_Color;
CDmaVar<int> m_nSkin;
CDmaVar<int> m_nBody;
CDmaVar<int> m_nSequence;
CDmaVar<int> m_nLOD;
CDmaVar<float> m_flPlaybackRate;
CDmaVar<float> m_flTime;
CDmaVar<Vector> m_vecViewTarget;
CDmaVar<bool> m_bWorldSpaceViewTarget;
virtual void GetBoundingBox( Vector &min, Vector &max ) const { return GetBoundingBox( &min, &max ); }
private:
void UpdateMDL();
CMDL m_MDL;
bool m_bDrawInEngine;
bool m_bZUp;
};
#endif // DMEMDL_H

View File

@@ -0,0 +1,102 @@
//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =====//
//
// Describes the way to compile a MDL file (eventual replacement for qc)
//
//===========================================================================//
#ifndef DMEMDLMAKEFILE_H
#define DMEMDLMAKEFILE_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmemakefile.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeMDL;
//-----------------------------------------------------------------------------
// Describes a skin source for MDL makefiles
//-----------------------------------------------------------------------------
class CDmeSourceSkin : public CDmeSource
{
DEFINE_ELEMENT( CDmeSourceSkin, CDmeSource );
public:
// These can be built from DCC makefiles
virtual const char **GetSourceMakefileTypes();
CDmaString m_SkinName;
CDmaVar<bool> m_bFlipTriangles;
CDmaVar<bool> m_bQuadSubd;
CDmaVar<float> m_flScale;
};
//-----------------------------------------------------------------------------
// Describes a skin source for MDL makefiles
//-----------------------------------------------------------------------------
class CDmeSourceCollisionModel : public CDmeSource
{
DEFINE_ELEMENT( CDmeSourceCollisionModel, CDmeSource );
public:
// These can be built from DCC makefiles
virtual const char **GetSourceMakefileTypes();
private:
};
//-----------------------------------------------------------------------------
// Describes an animation source for MDL makefiles
//-----------------------------------------------------------------------------
class CDmeSourceAnimation : public CDmeSource
{
DEFINE_ELEMENT( CDmeSourceAnimation, CDmeSource );
public:
// These can be built from DCC makefiles
virtual const char **GetSourceMakefileTypes();
CDmaString m_AnimationName;
CDmaString m_SourceAnimationName; // Name in the source file
private:
};
//-----------------------------------------------------------------------------
// Describes a MDL asset: something that is compiled from sources
//-----------------------------------------------------------------------------
class CDmeMDLMakefile : public CDmeMakefile
{
DEFINE_ELEMENT( CDmeMDLMakefile, CDmeMakefile );
public:
void SetSkin( const char *pFullPath );
void AddAnimation( const char *pFullPath );
void RemoveAnimation( const char *pFullPath );
void RemoveAllAnimations( );
virtual DmeMakefileType_t *GetMakefileType();
virtual DmeMakefileType_t* GetSourceTypes();
virtual void GetOutputs( CUtlVector<CUtlString> &fullPaths );
private:
// Inherited classes should re-implement these methods
virtual CDmElement *CreateOutputElement( );
virtual void DestroyOutputElement( CDmElement *pOutput );
virtual const char *GetOutputDirectoryID() { return "makefilegamedir:.."; }
CDmeHandle< CDmeMDL > m_hMDL;
bool m_bFlushMDL;
};
#endif // DMEMDLMAKEFILE_H

View File

@@ -0,0 +1,537 @@
//====== Copyright (c) 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class representing a mesh
//
//=============================================================================
#ifndef DMEMESH_H
#define DMEMESH_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmeshape.h"
#include "movieobjects/dmevertexdata.h"
#include "materialsystem/materialsystemutil.h"
#include "mathlib/vector.h"
#include "tier1/utllinkedlist.h"
#include "Color.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
class CDmeFaceSet;
class CDmeVertexData;
class IMaterial;
class IMorph;
class IMesh;
class Vector;
class Vector4D;
class Color;
class CDmeDag;
class CMeshBuilder;
class CDmeCombinationOperator;
class CDmeSingleIndexedComponent;
class CDmeDrawSettings;
class CDmMeshComp;
//-----------------------------------------------------------------------------
// Mesh weights
//-----------------------------------------------------------------------------
enum MeshDeltaWeightType_t
{
MESH_DELTA_WEIGHT_FIRST = 0,
MESH_DELTA_WEIGHT_NORMAL = 0,
MESH_DELTA_WEIGHT_LAGGED,
MESH_DELTA_WEIGHT_TYPE_COUNT,
};
//-----------------------------------------------------------------------------
// Mesh representation
//-----------------------------------------------------------------------------
class CDmeMesh : public CDmeShape
{
DEFINE_ELEMENT( CDmeMesh, CDmeShape );
public:
// resolve internal data from changed attributes
virtual void OnAttributeChanged( CDmAttribute *pAttribute );
void GetBoundingSphere( Vector &c, float &r, CDmeVertexData *pPassedBase, CDmeSingleIndexedComponent *pPassedSelection ) const;
virtual void GetBoundingSphere( Vector &c, float &r ) const { return GetBoundingSphere( c, r, NULL, NULL ); }
void GetBoundingBox( Vector &min, Vector &max, CDmeVertexData *pPassedBase /* = NULL */, CDmeSingleIndexedComponent *pPassedSelection /* = NULL */ ) const;
virtual void GetBoundingBox( Vector &min, Vector &max ) const { return GetBoundingBox( min, max, NULL, NULL ); }
// accessors
int FaceSetCount() const;
CDmeFaceSet *GetFaceSet( int nFaceSetIndex );
const CDmeFaceSet *GetFaceSet( int nFaceSetIndex ) const;
void AddFaceSet( CDmeFaceSet *faceSet );
void RemoveFaceSet( int nFaceSetIndex );
// Base states
int BaseStateCount() const;
CDmeVertexData *GetBaseState( int nBaseIndex ) const;
CDmeVertexData *FindBaseState( const char *pStateName ) const;
CDmeVertexData *FindOrCreateBaseState( const char *pStateName );
bool DeleteBaseState( const char *pStateName );
// Selects a particular base state to be current state
void SetCurrentBaseState( const char *pStateName );
CDmeVertexData *GetCurrentBaseState();
const CDmeVertexData *GetCurrentBaseState() const;
bool SetBindBaseState( CDmeVertexData *pBaseState );
CDmeVertexData *GetBindBaseState();
const CDmeVertexData *GetBindBaseState() const;
// Draws the mesh
void Draw( const matrix3x4_t &shapeToWorld, CDmeDrawSettings *pDrawSettings = NULL );
// Compute triangulated indices
void ComputeTriangulatedIndices( const CDmeVertexData *pBaseState, const CDmeFaceSet *pFaceSet, int nFirstIndex, int *pIndices, int nOutCount ) const;
// Compute a default per-vertex tangent given normal data + uv data for all vertex data referenced by this mesh
void ComputeDefaultTangentData( bool bSmoothTangents = false );
// Compute a default per-vertex tangent given normal data + uv data
void ComputeDefaultTangentData( CDmeVertexData *pVertexData, bool bSmoothTangents = false );
// Delta states
int DeltaStateCount() const;
CDmeVertexDeltaData *GetDeltaState( int nDeltaIndex ) const;
CDmeVertexDeltaData *FindDeltaState( const char *pDeltaName, bool bSortDeltaName = true ) const;
CDmeVertexDeltaData *FindOrCreateDeltaState( const char *pDeltaName, bool bSortDeltaName = true );
bool DeleteDeltaState( const char *pDeltaName );
bool ResetDeltaState( const char *pDeltaName );
int FindDeltaStateIndex( const char *pDeltaName, bool bSortDeltaName = true ) const;
void SetDeltaStateWeight( int nDeltaIndex, MeshDeltaWeightType_t type, float flMorphWeight );
void SetDeltaStateWeight( int nDeltaIndex, MeshDeltaWeightType_t type, float flLeftWeight, float flRightWeight );
CDmeVertexDeltaData *ModifyOrCreateDeltaStateFromBaseState( const char *pDeltaName, CDmeVertexData *pPassedBase = NULL, bool absolute = false );
// Sets all of the data in the current base state to be the bind state plus the corrected delta, if delta is NULL then it's set to the bind state
bool SetBaseStateToDelta( const CDmeVertexDeltaData *pDelta, CDmeVertexData *pPassedBase = NULL );
// Selects the vertices from the delta that change position
void SelectVerticesFromDelta( CDmeVertexDeltaData *pDelta, CDmeSingleIndexedComponent *pSelection );
// Selects all the vertices in the mesh
void SelectAllVertices( CDmeSingleIndexedComponent *pSelection, CDmeVertexData *pPassedBase = NULL );
enum SelectHalfType_t
{
kLeft,
kRight
};
// Selects all the vertices in the mesh
void SelectHalfVertices( SelectHalfType_t selectHalfType, CDmeSingleIndexedComponent *pSelection, CDmeVertexData *pPassedBase = NULL );
// Add the delta into the vertex data state weighted by the weight and masked by the weight map
bool AddMaskedDelta(
CDmeVertexDeltaData *pDelta,
CDmeVertexData *pDst = NULL,
float weight = 1.0f,
const CDmeSingleIndexedComponent *pMask = NULL );
// Add the delta into the vertex data state weighted by the weight and masked by the weight map
bool AddCorrectedMaskedDelta(
CDmeVertexDeltaData *pDelta,
CDmeVertexData *pDst = NULL,
float weight = 1.0f,
const CDmeSingleIndexedComponent *pMask = NULL );
// Interpolate between the current state and the specified delta by the specified percentage masked by the selection
bool InterpMaskedDelta(
CDmeVertexDeltaData *pDelta,
CDmeVertexData *pDst = NULL,
float weight = 1.0f,
const CDmeSingleIndexedComponent *pMask = NULL );
// Grows the selection by a specified amount
void GrowSelection( int nSize, CDmeSingleIndexedComponent *pSelection, CDmMeshComp *pPassedMeshComp );
// Shrinks the selection by a specified amount
void ShrinkSelection( int nSize, CDmeSingleIndexedComponent *pSelection, CDmMeshComp *pPassedMeshComp );
enum Falloff_t
{
STRAIGHT = 0,
LINEAR = STRAIGHT,
BELL,
SMOOTH = BELL,
SPIKE,
DOME
};
enum Distance_t
{
DIST_ABSOLUTE = 0,
DIST_RELATIVE,
DIST_DEFAULT
};
CDmeSingleIndexedComponent *FeatherSelection( float falloffDistance, Falloff_t falloffType, Distance_t distanceType, CDmeSingleIndexedComponent *pSelection, CDmMeshComp *pPassedMeshComp );
// Computes new normal deltas for all states based on position deltas
void ComputeDeltaStateNormals();
struct DeltaComputation_t
{
int m_nDeltaIndex;
int m_nDimensionality;
CUtlVector<int> m_DependentDeltas;
};
// Construct list of all n-1 -> 1 dimensional delta states that will be active when this delta state is active
void ComputeDependentDeltaStateList( CUtlVector< DeltaComputation_t > &compList );
// Construct list of all > n dimensional delta states that when active have the specified state as a dependent
bool ComputeSuperiorDeltaStateList( const char *pDeltaName, CUtlVector< int > &superiorDeltaStates );
void SetDeltaNormalDataFromActualNormals( int nDeltaIndex, const CUtlVector<int> &deltaStateList, int nNormalCount, Vector *pNormals );
void ComputeAllCorrectedPositionsFromActualPositions();
// Computes adds a delta to the passed data weighted by the passed weight
template < class T_t > void AddDelta(
const CDmeVertexDeltaData *pDelta, T_t *pFullData, int nFullData, FieldIndex_t fieldIndex, float weight = 1.0f, const CDmeSingleIndexedComponent *pMask = NULL );
template < class T_t > void AddDelta(
const CDmeVertexDeltaData *pDelta, T_t *pFullData, int nFullData, CDmeVertexData::StandardFields_t standardField, float weight = 1.0f, const CDmeSingleIndexedComponent *pMask = NULL );
bool SetBaseStateToDeltas( CDmeVertexData *pPassedBase = NULL );
template < class T_t >
bool SetBaseDataToDeltas( CDmeVertexData *pBase, CDmeVertexData::StandardFields_t nStandardField, CDmrArrayConst< T_t > &srcData, CDmrArray< T_t > &dstData, bool bDoStereo, bool bDoLag );
// Replace all instances of a material with a different material
void ReplaceMaterial( const char *pOldMaterialName, const char *pNewMaterialName );
// Reskins the mesh to new bones
// The joint index remap maps an initial bone index to a new bone index
void Reskin( const int *pJointTransformIndexRemap );
template < class T_t > static int GenerateCompleteDataForDelta( const CDmeVertexDeltaData *pDelta, T_t *pFullData, int nFullData, CDmeVertexData::StandardFields_t standardField );
// Normalizes all normals
void NormalizeNormals();
// Collapses redundant normals in the model
// flNormalBlend is the maximum difference in the dot product between two normals to consider them
// to be the same normal, a value of cos( DEG2RAD( 2.0 ) ) is the default studiomdl uses, for example
void CollapseRedundantNormals( float flNormalBlend );
// SWIG errors on the parsing of something in the private section of DmeMesh, it isn't exposed by SWIG anyway, so have SWIG ignore it
#ifndef SWIG
private:
friend class CDmMeshComp;
struct FaceSet_t
{
FaceSet_t() : m_bBuilt(false) {}
IMesh *m_pMesh;
bool m_bBuilt;
};
struct Triangle_t
{
int m_nIndex[3];
Vector m_vecTangentS;
Vector m_vecTangentT;
};
struct RenderVertexDelta_t
{
Vector m_vecDeltaPosition;
Vector m_vecDeltaNormal;
Vector2D m_vecDeltaUV;
Vector4D m_vecDeltaColor;
float m_flDeltaWrinkle;
};
VertexFormat_t ComputeHwMeshVertexFormat( void );
IMorph *CreateHwMorph( IMaterial *pMTL );
IMesh *CreateHwMesh( CDmeFaceSet *pFaceSet );
// Draws the mesh when it uses too many bones
void DrawDynamicMesh( CDmeFaceSet *pFaceSet, matrix3x4_t *pPoseToWorld, bool bHasActiveDeltaStates, CDmeDrawSettings *pDrawSettings = NULL );
// Build a map from vertex index to a list of triangles that share the vert.
void BuildTriangleMap( const CDmeVertexData *pBaseState, CDmeFaceSet* pFaceSet, CUtlVector<Triangle_t>& triangles, CUtlVector< CUtlVector<int> >* pVertToTriMap = NULL );
// Computes tangent space data for triangles
void ComputeTriangleTangets( const CDmeVertexData *pVertexData, CUtlVector<Triangle_t>& triangles );
// Build a map from vertex index to a list of triangles that share the vert.
void ComputeAverageTangent( CDmeVertexData *pVertexData, bool bSmoothTangents, CUtlVector< CUtlVector<int> >& vertToTriMap, CUtlVector<Triangle_t>& triangles );
// Do we have active delta state data?
bool HasActiveDeltaStates() const;
// Adds deltas into a delta mesh
template< class T > bool AddVertexDelta( CDmeVertexData *pBaseState, void *pVertexData, int nStride, CDmeVertexDataBase::StandardFields_t fieldId, int nIndex, bool bDoLag );
template< class T > bool AddStereoVertexDelta( CDmeVertexData *pBaseState, void *pVertexData, int nStride, CDmeVertexDataBase::StandardFields_t fieldId, int nIndex, bool bDoLag );
void AddTexCoordDelta( RenderVertexDelta_t *pRenderDelta, float flWeight, CDmeVertexDeltaData *pDeltaState );
void AddColorDelta( RenderVertexDelta_t *pRenderDelta, float flWeight, CDmeVertexDeltaData *pDeltaState );
// Builds deltas based on the current deltas, returns true if there was delta wrinkle data
bool BuildDeltaMesh( int nVertices, RenderVertexDelta_t *pDelta );
// Builds a map from vertex index to all triangles that use it
void BuildVertToTriMap( const CDmeVertexData *pVertexData, CUtlVector<Triangle_t> &triangles, CUtlVector< CUtlVector<int> > &vertToTriMap );
// Compute the dimensionality of the delta state (how many inputs affect it)
int ComputeDeltaStateDimensionality( int nDeltaIndex );
// Discovers the atomic controls used by the various delta states
void BuildAtomicControlLists( int nCount, DeltaComputation_t *pInfo, CUtlVector< CUtlVector< int > > &deltaStateUsage );
// Computes the aggregate position for all vertices after applying a set of delta states
void AddDelta( CDmeVertexData *pBaseState, Vector *pDeltaPosition, int nDeltaStateIndex, CDmeVertexData::StandardFields_t fieldId );
// Converts pose-space normals into deltas appropriate for correction delta states
void ComputeCorrectedNormalsFromActualNormals( const CUtlVector<int> &deltaStateList, int nNormalCount, Vector *pNormals );
// Copies the corrected normal data into a delta state
void SetDeltaNormalData( int nDeltaIndex, int nNormalCount, Vector *pNormals );
// Renders normals
void RenderNormals( matrix3x4_t *pPoseToWorld, RenderVertexDelta_t *pDelta );
void CacheHighlightVerts( matrix3x4_t *pPoseToWorld, RenderVertexDelta_t *pDelta, CDmeDrawSettings *pDmeDrawSettings );
// Writes triangulated indices for a face set into a meshbuilder
void WriteTriangluatedIndices( const CDmeVertexData *pBaseState, CDmeFaceSet *pFaceSet, CMeshBuilder &meshBuilder );
// Initializes the normal material
static void InitializeNormalMaterial();
// Initializes the wireframe material
static void InitializeWireframeMaterial();
// Sort function
static int DeltaStateLessFunc( const void * lhs, const void * rhs );
// Computes a list of the delta states ordered by dimensionality
void ComputeDeltaStateComputationList( CUtlVector< DeltaComputation_t > &compList );
// Compute the number of combinations of n items taken k at a time nCk - Probably doesn't belong here but it useful for combos
static void Combinations( int n, int k, CUtlVector< CUtlVector< int > > &combos, int *pTmpArray = NULL, int start = 0, int currentK = 0 );
// Splits the passed delta state name on '_' and finds all of the control Delta states which make up the name
bool GetControlDeltaIndices( CDmeVertexDeltaData *pDeltaState, CUtlVector< int > &controlDeltaIndices ) const;
// Splits the passed delta state name on '_' and finds all of the control Delta states which make up the name
bool GetControlDeltaIndices( const char *pDeltaStateName, CUtlVector< int > &controlDeltaIndices ) const;
// Builds a complete list of all of the delta states expressed as the control indices
bool BuildCompleteDeltaStateControlList( CUtlVector< CUtlVector< int > > &deltaStateControlList ) const;
// Given a list of control indices and a complete list of control indices for each delta state, returns the delta index or -1 if it doesn't exist
int FindDeltaIndexFromControlIndices( const CUtlVector< int > &controlIndices, const CUtlVector< CUtlVector< int > > &controlList ) const;
// Builds a list of all of the dependent delta states that do not already exist
bool BuildMissingDependentDeltaList( CDmeVertexDeltaData *pDeltaState, CUtlVector< int > &controlIndices, CUtlVector< CUtlVector< int > > &dependentStates ) const;
// Cleans up the hw meshes
void CleanupHWMesh();
static void ComputeCorrectedPositionsFromActualPositions( const CUtlVector< int > &deltaStateList, int nPositionCount, Vector *pPositions );
template < class T_t > void AddCorrectedDelta(
CDmrArray< T_t > &baseDataArray,
const CUtlVector< int > &baseIndices,
const DeltaComputation_t &deltaComputation,
const char *pFieldName,
float weight = 1.0f,
const CDmeSingleIndexedComponent *pMask = NULL );
template < class T_t > void AddCorrectedDelta(
CUtlVector< T_t > &baseData,
const CUtlVector< int > &baseIndices,
const DeltaComputation_t &deltaComputation,
const char *pFieldName,
float weight = 1.0f,
const CDmeSingleIndexedComponent *pMask = NULL );
template < class T_t > void AddRawDelta(
CDmeVertexDeltaData *pDelta,
CDmrArray< T_t > &baseDataArray,
FieldIndex_t nDeltaFieldIndex,
float weight = 1.0f,
const CDmeSingleIndexedComponent *pMask = NULL );
template < class T_t > void AddRawDelta(
CDmeVertexDeltaData *pDelta,
CUtlVector< T_t > &baseData,
FieldIndex_t nDeltaFieldIndex,
float weight = 1.0f,
const CDmeSingleIndexedComponent *pMask = NULL );
friend class CDmxEdit;
bool RemoveBaseState( CDmeVertexData *pBase );
CDmeVertexData *FindOrAddBaseState( CDmeVertexData *pBase );
// CFalloff functors map [0, 1] values to [0, 1] values
template < int T >
class CFalloff
{
public:
virtual inline float operator()( float x ) { return 1 - x; }
};
template<>
class CFalloff< CDmeMesh::LINEAR >
{
public:
virtual inline float operator()( float x ) { return 1 - x; }
};
template<>
class CFalloff< CDmeMesh::SMOOTH >
{
public:
virtual inline float operator()( float x ) {
return ( cosf( x * M_PI ) + 1.0f ) / 2.0f;
}
};
template<>
class CFalloff< CDmeMesh::DOME >
{
public:
virtual inline float operator()( float x ) {
return ( cosf( x * M_PI / 2.0 ) );
}
};
template<>
class CFalloff< CDmeMesh::SPIKE >
{
public:
virtual inline float operator()( float x ) {
return ( 1.0f - cosf( ( 1.0f - x ) * M_PI / 2.0 ) );
}
};
// Feather's the selection by a specified amount, creates a new CDmeSingleIndexedComponent or NULL if error
template < int T >
CDmeSingleIndexedComponent *FeatherSelection( float fFalloffDistance, Distance_t distanceType, CDmeSingleIndexedComponent *pSelection, CDmMeshComp *pPassedMeshComp );
bool CreateDeltaFieldFromBaseField( CDmeVertexData::StandardFields_t nStandardFieldIndex, const CDmrArrayConst< float > &baseArray, const CDmrArrayConst< float > &bindArray, CDmeVertexDeltaData *pDelta );
bool CreateDeltaFieldFromBaseField( CDmeVertexData::StandardFields_t nStandardFieldIndex, const CDmrArrayConst< Vector2D > &baseArray, const CDmrArrayConst< Vector2D > &bindArray, CDmeVertexDeltaData *pDelta );
bool CreateDeltaFieldFromBaseField( CDmeVertexData::StandardFields_t nStandardFieldIndex, const CDmrArrayConst< Vector > &baseArray, const CDmrArrayConst< Vector > &bindArray, CDmeVertexDeltaData *pDelta );
template< class T_t > bool InterpMaskedData(
CDmrArray< T_t > &aData,
const CUtlVector< T_t > &bData,
float weight,
const CDmeSingleIndexedComponent *pMask ) const;
// Interpolate between the current state and the specified delta by the specified percentage masked by the selection
bool InterpMaskedData(
CDmeVertexData *paData,
const CDmeVertexData *pbData,
float weight,
const CDmeSingleIndexedComponent *pMask ) const;
// Find the closest vertex in the specified selection to the passed vertex in the specified base state, if the passed base state is NULL is the current base state
int ClosestSelectedVertex( int vIndex, CDmeSingleIndexedComponent *pSelection, const CDmeVertexData *pPassedBase = NULL ) const;
// Return the distance between the two vertices in the specified base state, if the specified base state is NULL the current state is used
float DistanceBetween( int vIndex0, int vIndex1, const CDmeVertexData *pPassedBase = NULL ) const;
void DrawWireframeFaceSet( CDmeFaceSet *pFaceSet, matrix3x4_t *pPoseToWorld, bool bHasActiveDeltaStates, CDmeDrawSettings *pDrawSettings );
void ComputeNormalsFromPositions( CDmeVertexData *pBase, const Vector *pPosition, const CUtlVector<Triangle_t> &triangles, int nNormalCount, Vector *pNormals );
CDmaElement< CDmeVertexData > m_BindBaseState;
CDmaElement< CDmeVertexData > m_CurrentBaseState;
CDmaElementArray< CDmeVertexData > m_BaseStates;
CDmaElementArray< CDmeVertexDeltaData > m_DeltaStates;
CDmaElementArray< CDmeFaceSet > m_FaceSets;
// x is left value, y is right value. If the delta state isn't split, they are the same value
CDmaArray<Vector2D> m_DeltaStateWeights[MESH_DELTA_WEIGHT_TYPE_COUNT];
// Cached-off map of fields->
CUtlVector< FaceSet_t > m_hwFaceSets;
// Normal rendering materials
static bool s_bNormalMaterialInitialized;
static CMaterialReference s_NormalMaterial;
// Wireframe rendering materials
static bool s_bWireframeMaterialInitialized;
static CMaterialReference s_WireframeMaterial;
friend class CDmeMeshRenderInfo;
#endif // #ifndef SWIG
};
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
inline int CDmeMesh::BaseStateCount() const
{
return m_BaseStates.Count();
}
inline CDmeVertexData *CDmeMesh::GetBaseState( int nBaseIndex ) const
{
return m_BaseStates[ nBaseIndex ];
}
//-----------------------------------------------------------------------------
// Utility method to compute default tangent data on all meshes in the sub-dag hierarchy
//-----------------------------------------------------------------------------
void ComputeDefaultTangentData( CDmeDag *pDag, bool bSmoothTangents );
//-----------------------------------------------------------------------------
// Helper class to deal with software skinning
//-----------------------------------------------------------------------------
class CDmeMeshRenderInfo
{
public:
CDmeMeshRenderInfo( CDmeVertexData *pBaseState );
void ComputePosition( int nPosIndex, const matrix3x4_t *pPoseToWorld, Vector *pDeltaPosition, Vector *pPosition );
void ComputePosition( int nPosIndex, const matrix3x4_t *pPoseToWorld, CDmeMesh::RenderVertexDelta_t *pDelta, Vector *pPosition );
void ComputeVertex( int vi, const matrix3x4_t *pPoseToWorld, CDmeMesh::RenderVertexDelta_t *pDelta, Vector *pPosition, Vector *pNormal, Vector4D *pTangent );
inline bool HasPositionData() const { return m_bHasPositionData; }
inline bool HasNormalData() const { return m_bHasNormalData; }
inline bool HasTangentData() const { return m_bHasTangentData; }
private:
const CUtlVector<int>& m_PositionIndices;
const CUtlVector<Vector>& m_PositionData;
const CUtlVector<int>& m_NormalIndices;
const CUtlVector<Vector>& m_NormalData;
const CUtlVector<int>& m_TangentIndices;
const CUtlVector<Vector4D>& m_TangentData;
const CDmeVertexData *m_pBaseState;
int m_nJointCount;
bool m_bHasPositionData;
bool m_bHasNormalData;
bool m_bHasTangentData;
bool m_bHasSkinningData;
};
#endif // DMEMESH_H

View File

@@ -0,0 +1,18 @@
//===================== Copyright (c) Valve Corporation. All Rights Reserved. ======================
//
//
//
//==================================================================================================
#ifndef DMEMESHTYPES_H
#define DMEMESHTYPES_H
#ifdef _WIN32
#pragma once
#endif
typedef int DmeVertexIndex_t; // These only index into CDmeVertexData's index arrays.
typedef int DmeDataIndex_t; // These only index into CDmeVertexData's data arrays.
#endif // DMEMESHTYPES_H

View File

@@ -0,0 +1,211 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =====//
//
// Dme version of a skeletal model (gets compiled into a MDL)
//
//===========================================================================//
#ifndef DMEMODEL_H
#define DMEMODEL_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/utlstack.h"
#include "tier1/utlstringtoken.h"
#include "movieobjects/dmejoint.h"
#include "movieobjects/dmetransformlist.h"
#include "movieobjects/dmeaxissystem.h"
class CDmeDrawSettings;
class CDmeMesh;
//-----------------------------------------------------------------------------
// A class representing a skeletal model
//-----------------------------------------------------------------------------
class CDmeModel : public CDmeDag
{
DEFINE_ELEMENT( CDmeModel, CDmeDag );
public:
// Add joint
CDmeJoint *AddJoint( const char *pJointName, CDmeDag *pParent = NULL );
int AddJoint( CDmeDag *pJoint );
// Returns the number of joint transforms we know about
int GetJointCount() const;
// Returns the DmeDag for the specified joint index
CDmeDag *GetJoint( int nIndex );
const CDmeDag *GetJoint( int nIndex ) const;
// Returns the DmeTransform for the specified joint index
CDmeTransform *GetJointTransform( int nIndex );
const CDmeTransform *GetJointTransform( int nIndex ) const;
// Determines joint index of a given a joint
int GetJointIndex( CDmeDag *pJoint ) const;
int GetJointIndex( const char *pJointName ) const;
int GetJointIndex( CUtlStringToken nJointNameHash ) const;
// Captures the current joint transforms into a base state
void CaptureJointsToBaseState( const char *pBaseStateName );
// Sets the joint transforms to the values in the specified base state, if it exists
void PushBaseStateToJoints( const char *pBaseStateName );
// Finds a base state by name, returns NULL if not found
CDmeTransformList *FindBaseState( const char *pBaseStateName );
// Recursively render the Dag hierarchy
virtual void Draw( CDmeDrawSettings *pDrawSettings = NULL );
// NOTE: See comment for m_upAxis attribute below
// Set if Z is the up axis of the model
// Set to true if the data under the DmeModel is AS_VALVE_ENGINE space( Up: Z, Fwd: X, Left: Y )
// Set to false if the data under the DmeModel is AS_MAYA_YUP space ( Up: Y, Fwd: Z, Left: X )
// See SetAxisSystem() for anything other than AS_VALVE_ENGINE or AS_MAYA_YUP
void ZUp( bool bZUp );
// Returns true if the DmeModel is Z Up.
bool IsZUp() const;
// Returns the matrix that moves DmeModel data to engine space
void GetModelToEngineMat( matrix3x4_t &modelToEngineMat );
// Returns the matrix that moves engine data to DmeModel space
void GetEngineToModelMat( matrix3x4_t &engineToModelMat );
// Replace all instances of a material with a different material
// Using a NULL material name will replace *all* materials with the new material
void ReplaceMaterial( const char *pOldMaterialName, const char *pNewMaterialName );
// Collapses all joints below the specified joint name, reskinning any meshes
// referring to collapsed joints to use the specified joint instead
void CollapseJoints( const char *pJointName );
// Gets the joint with the specified name
CDmeDag *GetJoint( const char *pJointName );
// Reskin all meshes under the DmeModel
void ReskinMeshes( const int *pJointTransformIndexRemap );
// Sets the DmeAxisSystem, no reorientation is done, see ConvertToAxisSystem
bool SetAxisSystem( CDmeAxisSystem::PredefinedAxisSystem ePredefAxisSystem );
bool SetAxisSystem( CDmeAxisSystem::Axis_t eUpAxis, CDmeAxisSystem::ForwardParity_t eForwardParity, CDmeAxisSystem::CoordSys_t eCoordSys = CDmeAxisSystem::AS_RIGHT_HANDED );
// Sets the DmeAxisSystem and reorients all of the data under the DmeModel
// as necessary to change from the current DmeAxisSystem to the specified DmeAxisSystem
// Currently private, will be made public soon, upAxis is still authoritative
bool ConvertToAxisSystem( CDmeAxisSystem::PredefinedAxisSystem ePredefAxisSystem );
bool ConvertToAxisSystem( CDmeAxisSystem::Axis_t eUpAxis, CDmeAxisSystem::ForwardParity_t eForwardParity, CDmeAxisSystem::CoordSys_t eCoordSys = CDmeAxisSystem::AS_RIGHT_HANDED );
// Returns the matrix to convert data from the current axisSystem to the specified axisSystem
bool GetConversionMatrix( matrix3x4a_t &mConversion, CDmeAxisSystem::PredefinedAxisSystem eToPredefinedAxisSystem );
// Freeze child meshes, pushes transform into vertices of mesh, used to be part of Reorient
void FreezeChildMeshes();
// TransformScene
void TransformScene( const Vector &vScale = Vector( 1.0f, 1.0f, 1.0f ), const Vector &vTranslate = vec3_origin, const DegreeEuler &eRotation = DegreeEuler( 0.0f, 0.0f, 0.0f ), float flEps = 1.0e-4 );
void ScaleScene( const Vector &vScale );
// Updates all base states by adding missing joints
void UpdateBaseStates();
private:
// Reskin meshes based on bone collapse
void ReskinMeshes( CDmeDag *pDag, const int *pJointTransformIndexRemap );
// Remove joints
void RemoveJoints( int nNewJointCount, const int *pInvJointRemap );
// Removes all children from this joint, moving shapes to be
void RemoveAllChildren( CDmeDag *pDag, CDmeDag *pSubtreeRoot, const matrix3x4_t &jointToSubtreeRoot );
void RemoveAllChildren( CDmeDag *pSubtreeRoot );
// Helper functions for ReorientToEngineSpace() and ReorientToDCCToolSpace()
static void GetReorientData( matrix3x4_t &m, Quaternion &q, bool bMakeZUp );
static void ReorientDmeAnimation( CDmeDag *pDmeDag, const matrix3x4_t &mOrient, const Quaternion &qOrient );
static void ReorientDmeTransform( CDmeTransform *pDmeTransform, const matrix3x4_t &mOrient, const Quaternion &qOrient );
static void ReorientDmeModelChildren( CDmeModel *pDmeModel, const matrix3x4_t &mOrient, const Quaternion &qOrient );
static void ReorientChildDmeMeshes_R( CDmeDag *pDmeDag );
static void ReorientDmeMesh( CDmeMesh *pDmeMesh, matrix3x4_t absMat );
protected:
// The order in which the joint transform names appear in this list
// indicates the joint index for each dag
CDmaElementArray< CDmeDag > m_JointList;
// Stores a list of base poses for all the joint transforms
CDmaElementArray<CDmeTransformList> m_BaseStates;
// Stores the up axis of the model
// One of Y or Z
//
// NOTE: Y up is Maya's typical coordinate system. Setting the up axis to Z
// won't quite give you the engine's coordinate system (even though it
// has an Up Axis of Z as well). The difference is the forward axis.
//
// A DmeModel with m_UpAxis = Y gives the data in a coordinate system
// that is Maya's typical coordinate system. Y Up, Z Foward, X Right.
//
// A DmeModel with m_UpAxis = Z gives the data in a coordinate system
// that is compatible with typical SMD data. This is data that can
// be compiled in studiomdl without any special options.
//
// Neither Y up or Z up is engine space. Z up is closer but still
// requires another 90 degree rotation to align things. This can be
// changed in the future if required but Z up was added for legacy
// SMD compatibility.
//
// In this table, missing entries mean it's not required or isn't
// supported
//
// m_UpAxis Desc Up Forward Right studiomdl
// -------- ------------- ------- ------- ------- ---------
// Y Maya Y Up Y Z X $upaxis Y
// Z Maya Z Up/XSI Z -Y X
// Engine Z X Y $origin 0 0 0 0
//-----------------------------------------------------------------------------
CDmaString m_UpAxis;
CDmaElement< CDmeAxisSystem > m_eAxisSystem;
CDmaElement< CDmeModel > m_eModel;
CDmaElement< CDmeModel > m_eSkeleton;
private:
enum SetupBoneRetval_t
{
NO_SKIN_DATA = 0,
TOO_MANY_BONES,
BONES_SET_UP
};
// Sets up the render state for the model
SetupBoneRetval_t SetupBoneMatrixState( const matrix3x4_t& shapeToWorld, bool bForceSoftwareSkin );
// Loads up joint transforms for this model
void LoadJointTransform( CDmeDag *pJoint, CDmeTransformList *pBindPose, const matrix3x4_t &parentToWorld, const matrix3x4_t &parentToBindPose, bool bSetHardwareState );
// Implementation of ReplaceMaterial
void ReplaceMaterial( CDmeDag *pDag, const char *pOldMaterialName, const char *pNewMaterialName );
// Sets up the render state for the model
static matrix3x4_t *SetupModelRenderState( const matrix3x4_t& shapeToWorld, bool bHasSkinningData, bool bForceSoftwareSkin );
static void CleanupModelRenderState();
// Stack of DmeModels currently being rendered. Used to set up render state
static CUtlStack< CDmeModel * > s_ModelStack;
friend class CDmeMesh;
friend bool SetMeshFromSkeleton( CDmeMesh *pDmeMesh ); // dmx edit function - to do skin weights
};
#endif // DMEMODEL_H

View File

@@ -0,0 +1,53 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// The morph operator class - sets morph target weights on meshes
//
//=============================================================================
#ifndef DMEMORPHOPERATOR_H
#define DMEMORPHOPERATOR_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "movieobjects/dmeoperator.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeMesh;
//-----------------------------------------------------------------------------
// A class representing a camera
//-----------------------------------------------------------------------------
class CDmeMorphOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmeMorphOperator, CDmeOperator );
public:
virtual void Operate();
// need this until we have the EditApply message queue
void OnAttributeChanged( CDmAttribute *pAttribute );
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
// accessors
uint NumDeltaStateWeights();
CDmElement *GetDeltaStateWeight( uint i );
CDmeMesh *GetMesh();
protected:
CDmaElement< CDmeMesh > m_mesh;
CDmaElementArray< CDmElement > m_deltaStateWeights;
CDmaString m_baseStateName;
};
#endif // DMEMORPHOPERATOR_H

View File

@@ -0,0 +1,45 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// The abstract base operator class - all actions within the scenegraph happen via operators
//
//=============================================================================
#ifndef DMEMOUSEINPUT_H
#define DMEMOUSEINPUT_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmeinput.h"
//-----------------------------------------------------------------------------
// A class representing a camera
//-----------------------------------------------------------------------------
class CDmeMouseInput : public CDmeInput
{
DEFINE_ELEMENT( CDmeMouseInput, CDmeInput );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
// makes the current mouse position be the origin
void ResetOrigin() { ResetOrigin( 0.0f, 0.0f ); }
void ResetOrigin( float dx, float dy );
protected:
void GetNormalizedCursorPos( float &flX, float &flY );
float m_xOrigin;
float m_yOrigin;
CDmaVar< float > m_x;
CDmaVar< float > m_y;
};
#endif // DMEMOUSEINPUT_H

View File

@@ -0,0 +1,42 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// The abstract base operator class - all actions within the scenegraph happen via operators
//
//=============================================================================
#ifndef DMEOPERATOR_H
#define DMEOPERATOR_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattributevar.h"
#include "tier1/utlvector.h"
//-----------------------------------------------------------------------------
// A class representing an generic operator
//-----------------------------------------------------------------------------
class CDmeOperator : public IDmeOperator, public CDmElement
{
DEFINE_ELEMENT( CDmeOperator, CDmElement );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate() {}
virtual const char* GetOperatorName() const { return m_Name.Get(); }
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs ) {}
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs ) {}
virtual void GatherInputOperators( CUtlVector< CDmeOperator * > &operators );
virtual void SetSortKey( int key );
virtual int GetSortKey() const;
int m_nSortKey;
};
void GatherOperatorsForElement( CDmElement *pElement, CUtlVector< CDmeOperator * > &operators );
#endif // DMEOPERATOR_H

View File

@@ -0,0 +1,74 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class representing a transform
//
//=============================================================================
#ifndef DMEOVERLAY_H
#define DMEOVERLAY_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
struct matrix3x4_t;
class CDmeDag;
//-----------------------------------------------------------------------------
// A class representing a transformation matrix
//-----------------------------------------------------------------------------
class CDmeOverlay : public CDmElement
{
DEFINE_ELEMENT( CDmeOverlay, CDmElement );
public:
virtual void OnAttributeChanged( CDmAttribute *pAttribute );
float GetWeight() const;
float GetSequence() const;
float GetPrevCycle() const;
float GetCycle() const;
int GetOrder() const;
float GetPlaybackRate() const;
float GetLayerAnimtime() const;
float GetLayerFadeOuttime() const;
void SetWeight( float flWeight );
void SetSequence( int nSequence );
void SetPrevCycle( float flPrevCycle );
void SetCycle( float flCycle );
void SetOrder( int nOrder );
void SetPlaybackRate( float flPlaybackRate );
void SetLayerAnimttime( float flAnimttime );
void SetLayerFadeOuttime( float flLayerFadeOuttime );
CDmAttribute *GetWeightAttribute();
CDmAttribute *GetSequenceAttribute();
CDmAttribute *GetPrevCycleAttribute();
CDmAttribute *GetCycleAttribute();
CDmAttribute *GetOrderAttribute();
CDmAttribute *GetPlaybackRateAttribute();
CDmAttribute *GetLayerAnimtimeAttribute();
CDmAttribute *GetLayerFadeOuttimeAttribute();
// If transform is contained inside some kind of CDmeDag, return that (it's "parent")
CDmeDag *GetDag();
private:
CDmaVar<float> m_flWeight;
CDmaVar<int> m_nSequence;
CDmaVar<float> m_flPrevCycle;
CDmaVar<float> m_flCycle;
CDmaVar<int> m_nOrder;
CDmaVar<float> m_flPlaybackRate;
CDmaVar<float> m_flLayerAnimtime;
CDmaVar<float> m_flLayerFadeOuttime;
};
#endif // DMEOVERLAY_H

View File

@@ -0,0 +1,164 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// The morph operator class - sets morph target weights on meshes
//
//=============================================================================
#ifndef DMEPACKOPERATORS_H
#define DMEPACKOPERATORS_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmeoperator.h"
//-----------------------------------------------------------------------------
// CDmePackColorOperator - combines floats into a color
//-----------------------------------------------------------------------------
class CDmePackColorOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmePackColorOperator, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< Color > m_color;
CDmaVar< float> m_red;
CDmaVar< float> m_green;
CDmaVar< float> m_blue;
CDmaVar< float> m_alpha;
};
//-----------------------------------------------------------------------------
// CDmePackVector2Operator - combines floats into a vector2
//-----------------------------------------------------------------------------
class CDmePackVector2Operator : public CDmeOperator
{
DEFINE_ELEMENT( CDmePackVector2Operator, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< Vector2D > m_vector;
CDmaVar< float> m_x;
CDmaVar< float> m_y;
};
//-----------------------------------------------------------------------------
// CDmePackVector3Operator - combines floats into a vector
//-----------------------------------------------------------------------------
class CDmePackVector3Operator : public CDmeOperator
{
DEFINE_ELEMENT( CDmePackVector3Operator, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< Vector > m_vector;
CDmaVar< float> m_x;
CDmaVar< float> m_y;
CDmaVar< float> m_z;
};
//-----------------------------------------------------------------------------
// CDmePackVector4Operator - combines floats into a vector4
//-----------------------------------------------------------------------------
class CDmePackVector4Operator : public CDmeOperator
{
DEFINE_ELEMENT( CDmePackVector4Operator, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< Vector4D > m_vector;
CDmaVar< float> m_x;
CDmaVar< float> m_y;
CDmaVar< float> m_z;
CDmaVar< float> m_w;
};
//-----------------------------------------------------------------------------
// CDmePackQAngleOperator - combines floats into a qangle
//-----------------------------------------------------------------------------
class CDmePackQAngleOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmePackQAngleOperator, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< QAngle > m_qangle;
CDmaVar< float> m_x;
CDmaVar< float> m_y;
CDmaVar< float> m_z;
};
//-----------------------------------------------------------------------------
// CDmePackQuaternionOperator - combines floats into a quaternion
//-----------------------------------------------------------------------------
class CDmePackQuaternionOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmePackQuaternionOperator, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< Quaternion > m_quaternion;
CDmaVar< float> m_x;
CDmaVar< float> m_y;
CDmaVar< float> m_z;
CDmaVar< float> m_w;
};
//-----------------------------------------------------------------------------
// CDmePackVMatrixOperator - combines floats into a VMatrix
//-----------------------------------------------------------------------------
class CDmePackVMatrixOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmePackVMatrixOperator, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< VMatrix > m_vmatrix;
CDmaVar< float > m_cells[ 16 ];
};
#endif // DMEPACKOPERATORS_H

View File

@@ -0,0 +1,204 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose: A particle system definition
//
//=============================================================================
#ifndef DMEPARTICLESYSTEMDEFINITION_H
#define DMEPARTICLESYSTEMDEFINITION_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "datamodel/dmehandle.h"
#include "datamodel/dmattributevar.h"
#include "particles/particles.h"
// key names for clipboard keyvalues entries
#define PARTICLE_CLIPBOARD_FUNCTIONS_STR "fnc"
#define PARTICLE_CLIPBOARD_DEFINITION_STR "pcf"
#define PARTICLE_CLIPBOARD_DEF_BODY_STR "def"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeEditorTypeDictionary;
class CDmeParticleSystemDefinition;
//-----------------------------------------------------------------------------
// Base class for particle functions inside a particle system definition
//-----------------------------------------------------------------------------
class CDmeParticleFunction : public CDmElement
{
DEFINE_ELEMENT( CDmeParticleFunction, CDmElement );
public:
virtual const char *GetFunctionType() const { return NULL; }
virtual void Resolve();
virtual void OnElementUnserialized();
// Used for backward compat
void AddMissingFields( const DmxElementUnpackStructure_t *pUnpack );
// Returns the editor type dictionary
CDmeEditorTypeDictionary* GetEditorTypeDictionary();
// Marks a particle system as a new instance
// This is basically a workaround to prevent newly-copied particle functions
// from recompiling themselves a zillion times
void MarkNewInstance();
// should be called if a function was shallow-copied, so it has its own type dictionary
void InstanceTypeDictionary();
protected:
void UpdateAttributes( const DmxElementUnpackStructure_t *pUnpack );
private:
// Defines widgets to edit this bad boy
CDmaElement< CDmeEditorTypeDictionary > m_hTypeDictionary;
bool m_bSkipNextResolve;
};
//-----------------------------------------------------------------------------
// Something that updates particles
//-----------------------------------------------------------------------------
class CDmeParticleOperator : public CDmeParticleFunction
{
DEFINE_ELEMENT( CDmeParticleOperator, CDmeParticleFunction );
public:
// Sets the particle operator
void SetFunction( IParticleOperatorDefinition *pDefinition );
// Returns the function type
virtual const char *GetFunctionType() const;
private:
CDmaString m_FunctionName;
};
//-----------------------------------------------------------------------------
// A child of a particle system
//-----------------------------------------------------------------------------
class CDmeParticleChild : public CDmeParticleFunction
{
DEFINE_ELEMENT( CDmeParticleChild, CDmeParticleFunction );
public:
// Sets the particle operator
void SetChildParticleSystem( CDmeParticleSystemDefinition *pDef, IParticleOperatorDefinition *pDefinition );
// Returns the function type
virtual const char *GetFunctionType() const;
CDmaElement< CDmeParticleSystemDefinition > m_Child;
};
//-----------------------------------------------------------------------------
// Represents an editable entity; draws its helpers
//-----------------------------------------------------------------------------
class CDmeParticleSystemDefinition : public CDmElement
{
DEFINE_ELEMENT( CDmeParticleSystemDefinition, CDmElement );
public:
virtual void OnElementUnserialized();
virtual void Resolve();
// Add, remove
CDmeParticleFunction* AddOperator( ParticleFunctionType_t type, const char *pFunctionName );
CDmeParticleFunction* AddCopyOfOperator( CDmeParticleFunction *pFunc );
CDmeParticleFunction* AddChild( CDmeParticleSystemDefinition *pChild );
void RemoveFunction( ParticleFunctionType_t type, CDmeParticleFunction *pParticleFunction );
void OverrideAttributesFromOtherDefinition( CDmeParticleSystemDefinition *pDef );
// Find
int FindFunction( ParticleFunctionType_t type, CDmeParticleFunction *pParticleFunction );
int FindFunction( ParticleFunctionType_t type, const char *pFunctionName );
// Iteration
int GetParticleFunctionCount( ParticleFunctionType_t type ) const;
CDmeParticleFunction *GetParticleFunction( ParticleFunctionType_t type, int nIndex );
// Reordering
void MoveFunctionUp( ParticleFunctionType_t type, CDmeParticleFunction *pElement );
void MoveFunctionDown( ParticleFunctionType_t type, CDmeParticleFunction *pElement );
// Returns the editor type dictionary
CDmeEditorTypeDictionary* GetEditorTypeDictionary();
// Recompiles the particle system when a change occurs
void RecompileParticleSystem();
// Marks a particle system as a new instance
// This is basically a workaround to prevent newly-copied particle functions
// from recompiling themselves a zillion times
void MarkNewInstance();
// Should we use name-based lookup?
bool UseNameBasedLookup() const;
void RemoveInvalidFunctions();
// Remove DM attributes that aren't needed
void Compact();
private:
CDmaElementArray< CDmeParticleFunction > m_ParticleFunction[PARTICLE_FUNCTION_COUNT];
CDmaVar< bool > m_bPreventNameBasedLookup;
// Defines widgets to edit this bad boy
CDmeHandle< CDmeEditorTypeDictionary > m_hTypeDictionary;
};
//-----------------------------------------------------------------------------
// Should we use name-based lookup?
//-----------------------------------------------------------------------------
inline bool CDmeParticleSystemDefinition::UseNameBasedLookup() const
{
return !m_bPreventNameBasedLookup;
}
//-----------------------------------------------------------------------------
// Human readable string for the particle functions
//-----------------------------------------------------------------------------
const char *GetParticleFunctionTypeName( ParticleFunctionType_t type );
//-----------------------------------------------------------------------------
// Helper function
template<class T> T* ReadParticleClassFromKV( KeyValues *pKV, const char *pKeyName )
{
const char *pData = pKV->GetString( pKeyName );
int nLen = pData ? Q_strlen( pData ) : 0;
if ( nLen )
{
CUtlBuffer buf( pData, nLen, CUtlBuffer::TEXT_BUFFER | CUtlBuffer::READ_ONLY );
DmElementHandle_t hRoot;
if ( !g_pDataModel->Unserialize( buf, "keyvalues2", "pcf", NULL, "paste", CR_FORCE_COPY, hRoot ) )
{
return NULL;
}
return GetElement<T>( hRoot );
}
return NULL;
}
#endif // DMEPARTICLESYSTEMDEFINITION_H

View File

@@ -0,0 +1,24 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMEPHONEMEMAPPING_H
#define DMEPHONEMEMAPPING_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
class CDmePhonemeMapping : public CDmElement
{
DEFINE_ELEMENT( CDmePhonemeMapping, CDmElement );
public:
CDmaString m_Preset; // "preset" // map this item to this preset
CDmaVar< float > m_Weight; // "weight" // using this weight
};
#endif // DMEPHONEMEMAPPING_H

View File

@@ -0,0 +1,140 @@
//====== Copyright © 1996-2009, Valve Corporation, All rights reserved. =======
//
// Purpose: Contains the declaration of the CDmeRig, a class which groups a set
// of associated constraints and operators together, allowing operations to be
// performed on the group of elements. Also contains the declaration of
// CDmeRigAnimSetElements, a helper class used to store a list of elements which
// are all associated with a single animation set.
//
//=============================================================================
#ifndef DMERIG_H
#define DMERIG_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmattributevar.h"
#include "movieobjects/dmedag.h"
#include "movieobjects/dmecontrolgroup.h"
#include "movieobjects/dmeanimationset.h"
// Forward declarations
class CDmeAnimationSet;
class CDmeFilmClip;
//-------------------------------------------------------------------------------------------------
// CDmeRigAnimSetElements: A helper class used by CDmeRig to store a list of elements associated
// with a particular animation set.
//-------------------------------------------------------------------------------------------------
class CDmeRigAnimSetElements : public CDmElement
{
DEFINE_ELEMENT( CDmeRigAnimSetElements, CDmElement );
public:
// Set the animation set elements in the list are to be associated with, only allowed when empty.
void SetAnimationSet( CDmeAnimationSet* pAnimationSet );
// Add an element to the list
void AddElement( CDmElement *pElement );
// Remove the specified element from the list
bool RemoveElement( CDmElement *pElement );
// Remove all of the elements from the list
void RemoveAll();
// Add all of the elements to the provided array
void GetElements( CUtlVector< CDmElement* > &elementList ) const;
// Add a control group to the list of hidden control groups
void AddHiddenControlGroup( CDmeControlGroup *pControlGroup );
// Accessors
CDmeAnimationSet *AnimationSet() const { return m_AnimationSet; }
int NumElements() const { return m_ElementList.Count(); }
const CDmaElementArray< CDmElement > &Elements() const { return m_ElementList; }
const CDmaStringArray &HiddenControlGroups() const { return m_HiddenGroups; }
private:
CDmaElement< CDmeAnimationSet > m_AnimationSet; // "animationSet" : Animation set to which the elements belong
CDmaElementArray< CDmElement > m_ElementList; // "elementList" : List of elements assigned to the group
CDmaStringArray m_HiddenGroups; // "hiddenGroups" : List of names of the groups for which the rig disabled visibility
};
//-------------------------------------------------------------------------------------------------
// CDmeRig: The CDmeRig class represents a grouping of rig constraints, operators, controls and
// other elements which are conceptually a single rig, operating on one or more animation sets.
// By maintaining this grouping it is possible to perform operations such as detach on all of the
// elements associated with rig, even if the rig has elements in multiple animation sets and those
// animation sets have elements from more than one rig. The CDmeRig is no actually required for
// operation of the elements composing the rig, it is merely utility for managing the elements
// associated with a single rig.
//-------------------------------------------------------------------------------------------------
class CDmeRig : public CDmeDag
{
DEFINE_ELEMENT( CDmeRig, CDmeDag );
public:
// Add an element to the rig
void AddElement( CDmElement* pElement, CDmeAnimationSet *pAnimationSet );
// Set the state of the specified control group and add it to list of control group modified by the rig
void HideControlGroup( CDmeControlGroup *pGroup );
// Remove an element from the rig
void RemoveElement( CDmElement *pElement, CDmeAnimationSet *pAnimationSet );
// Remove an animation set and all associated elements from the rig
void RemoveAnimationSet( CDmeAnimationSet *pAnimationSet );
// Determine if the rig has any animation sets associated with it
bool HasAnyAnimationSets() const;
// Get the list of animation sets in the rig
void GetAnimationSets( CUtlVector< CDmeAnimationSet* > &animationSetList ) const;
// Get the list of elements for the specified animation set
void GetAnimationSetElements( const CDmeAnimationSet *pAnimationSet, CUtlVector< CDmElement* > &elementList ) const;
// Determine if the rig has any elements from the specified animation set
bool HasAnimationSet( const CDmeAnimationSet *pAnimationSet ) const;
// Build a list of all of the dag nodes which are influenced by rig
void FindInfluencedDags( CUtlVector< CDmeDag* > &dagList ) const;
// Remove all of elements in the rig from scene
void RemoveElementsFromShot( CDmeFilmClip *pShot );
// Hide all of the control groups in the rig's list of hidden control groups
void HideHiddenControlGroups( CDmeAnimationSet *pAnimationSet );
// Remove the specified element from any rig which it may be associated with.
static void RemoveElementFromRig( CDmElement *pElement );
private:
// Find the element list for the specified animation set
int FindAnimSetElementList( const CDmeAnimationSet *pAnimationSet ) const;
// Find the element list for the specified animation set or create one
CDmeRigAnimSetElements *FindOrCreateAnimSetElementList( CDmeAnimationSet *pAnimationSet );
// Set the visibility of the control groups in the hidden list
void SetHiddenControlGroupVisibility( CDmeRigAnimSetElements *pAnimSetElement, bool bHidden );
CDmaElementArray< CDmeRigAnimSetElements > m_AnimSetList; // "animSetList" : Array of animation set / element groupings
};
void CollectRigsOnAnimationSet( CDmeAnimationSet *pAnimSet, CUtlVector< CDmeRig* > &rigList );
#endif // DMERIGELEMENTGROUP_H

View File

@@ -0,0 +1,624 @@
//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =======
//
// Purpose: Declaration of the constraint operator classes. The constraint
// operators control the position and / or orientation of a specified slave dag
// node based on the position and orientation of a set of weighted target dag
// nodes. The relationship between the target dag node and the slave is
// determined by the type of the constraint. The Operate() function of each
// constraint class is responsible for enforcing its specific relationship.
//
//=============================================================================
#ifndef DMERIGCONSTRAINTOPERATORS_H
#define DMERIGCONSTRAINTOPERATORS_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmedag.h"
#include "movieobjects/dmeoperator.h"
// Forward declarations
class CDmAttribute;
class CDmeChannel;
class CDmeFilmClip;
class CDmeRigBaseConstraintOperator;
//-----------------------------------------------------------------------------
// Different rig operator modes (directions)
//-----------------------------------------------------------------------------
enum RigOperatorMode_t
{
RM_FORWARD = 0, // Data flows from handles to drive slaves
RM_REVERSE, // Slave transforms drive handle positions
};
//-----------------------------------------------------------------------------
// Constraint attribute attachment type, specifies which channels the
// constraint will apply to.
//-----------------------------------------------------------------------------
enum EAddType
{
AA_TYPE_UNKNOWN = 0,
AA_TYPE_POSITION = (1<<0),
AA_TYPE_ORIENTATION = (1<<1),
AA_TYPE_ALL = AA_TYPE_POSITION | AA_TYPE_ORIENTATION,
};
//-----------------------------------------------------------------------------
// General constraint types
//-----------------------------------------------------------------------------
enum EConstraintType
{
CT_UNKNOWN = 0,
CT_POINT, // Point constraint, slave position matches target position
CT_ORIENT, // Orient constraint, slave orientation matches target orientation
CT_AIM, // Aim constraint, slave orientation is adjusted to look point toward target position
CT_IK, // Inverse kinematics constraint, position and orientation are adjusted to reach a target
CT_PARENT, // Parent constraint, slave position and orientation are updated to behave as children of the target
CT_ROTATION, // Rotation constraint, slave orientation is set to the orientation generated from a set of rotations
CT_TWIST, // Twist constraint, takes a percentage of the rotation around the axis between a child & parent bone
NUM_CONSTRAINT_TYPES,
};
//-----------------------------------------------------------------------------
// CDmeConstraintTarget: Specifies a single target of a constraint and the
// weight of that target in the final result, as well as a position and
// orientation.
//-----------------------------------------------------------------------------
class CDmeConstraintTarget : public CDmElement
{
DEFINE_ELEMENT( CDmeConstraintTarget, CDmElement );
friend class CDmeRigBaseConstraintOperator;
public:
// Clear the position and rotation offset
void ClearOffset();
// Find the channel driving the weight value of the constraint
CDmeChannel *FindWeightChannel() const;
// Get the constraint to which the target belongs.
CDmeRigBaseConstraintOperator *GetConstraint();
// Find the control attached to constraint's weight
CDmElement *FindWeightControl() const;
// Get the dag node that is the source of the target
CDmeDag *GetDag() { return m_Handle; }
// Get the weight value for the target
float GetWeight() { return m_flWeight; }
// Get the position offset of the target
const Vector &GetPositionOfffset() { return m_vecOffset; }
// Get the orientation offset of the target
const Quaternion &GetOrientationOffset() { return m_qOffset; }
// Get the weight attribute of the target
CDmAttribute *GetWeightAttribute() { return m_flWeight.GetAttribute(); }
private:
CDmaElement< CDmeDag > m_Handle;
CDmaVar< float > m_flWeight;
CDmaVar< Vector > m_vecOffset;
CDmaVar< Quaternion > m_qOffset;
};
//-----------------------------------------------------------------------------
// CDmeConstraintSlave: A dag node which is being controlled by a constraint,
// also stores the original position and orientation of the dag which will be
// used if no weight is active.
//-----------------------------------------------------------------------------
class CDmeConstraintSlave : public CDmElement
{
DEFINE_ELEMENT( CDmeConstraintSlave, CDmElement );
friend class CDmeRigBaseConstraintOperator;
public:
// Get the transform of the dag assigned to the slave
CDmeTransform *GetTransform() { return m_Dag.GetElement() ? m_Dag->GetTransform() : NULL; }
// Set the dag node targeted by the slave
void SetDag( CDmeDag *pDag ) { m_Dag = pDag; }
// Get the dag node targeted by the slave.
CDmeDag *GetDag() const { return m_Dag; }
// Set the local space base position of the slave
void SetBasePosition( const Vector &positon ) { m_BasePosition = positon; }
// Get the local space base position of the slave
const Vector &GetBasePosition() const { return m_BasePosition; }
// Set the local space base orientation of the slave
void SetBaseOrientation( const Quaternion &orientation ) { m_BaseOrientation = orientation; }
// Get the local space base orientation of the slave
const Quaternion &GetBaseOrientation() const { return m_BaseOrientation; }
// Get the attribute for the base position
const CDmAttribute *GetBasePositionAttribute() const { return m_BasePosition.GetAttribute(); }
// Get the attribute for the base orientation
const CDmAttribute *GetBaseOrientationAttribute() const { return m_BaseOrientation.GetAttribute(); }
// Get the constraint to which the slave belongs.
CDmeRigBaseConstraintOperator *GetConstraint() const;
// Compute the base world space matrix
void GetBaseWorldTransform( matrix3x4_t &worldTransform ) const;
// Compute the base position and orientation in world space
void ComputeBaseWorldValues( Vector &wsPosition, Quaternion &wsOrientation ) const;
private:
CDmaElement< CDmeDag > m_Dag; // Dag node being controlled by the constraint
CDmaVar< Vector > m_BasePosition; // Position of the slave when no constraint target is active
CDmaVar< Quaternion> m_BaseOrientation; // Orientation of the slave when no constraint target is active
};
//-----------------------------------------------------------------------------
// CDmeRigBaseConstraintOperator: Base class from which all constraints are
// derived.
//-----------------------------------------------------------------------------
class CDmeRigBaseConstraintOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmeRigBaseConstraintOperator, CDmeOperator );
public:
// DERIVED CLASSES SHOULD OVERRIDE
virtual EConstraintType GetConstraintType() const { Error( "Derived must implement" ); return CT_UNKNOWN; }
virtual EAddType GetInputAttributeType() const { Error( "Derived must implement" ); return AA_TYPE_UNKNOWN; };
virtual EAddType GetOutputAttributeType() const { Error( "Derived must implement" ); return AA_TYPE_UNKNOWN; };
virtual void Operate() { Error( "Derived must implement" ); };
// Determine if data has changed and the operator needs to be updated
// FIXME: Each op type should check extra fields
virtual bool IsDirty() const { return true; }
// Perform any additional work which needs to be done after handles have been added
virtual void PostHandlesAdded( bool bPreserveOffset ) {}
// Determine if the the constraint has slave with the specified name
virtual bool IsSlaveObject( char const *pchName ) const;
// Get the attributes that the constraint reads data from, Inputs are CDmeDags (handles usually)
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
// Get the attributes to which the attribute writes, Outputs are CDmeDags (bones or other CDmeRigHandles usually)
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
// Disconnect the channels driving the slave dag nodes from the dag transforms and connect them to the constraint
virtual void DisconnectTransformChannels();
// Reconnect the base channels of each slave directly to the dag
virtual void ReconnectTransformChannels();
// Find all of the operators the evaluation of the constraint operator is dependent on
virtual void GatherInputOperators( CUtlVector< CDmeOperator * > &operatorList );
// Get a pointer to the dag node the constraint is controlling
virtual const CDmeDag *GetSlave() const;
// Add target handles to the the constraint with the specified weights
void AddHandles( int nCount, CDmeDag *const pRigHandles[], const float *pflWeights, bool bPreserveOffset, CUtlVector< CDmeConstraintTarget* > *pTargetList );
// Remove all target handles from the constraint
void ClearHandles();
// Set the dag node which the constraint is controlling
void SetSlave( CDmeDag *pSlave );
// Set the operating mode of the constraint
void SetMode( RigOperatorMode_t mode );
// Get the list of target handles used by the constraint
const CDmaElementArray< CDmeConstraintTarget > &GetTargets() const { return m_Targets; }
// Get the constraint slave
const CDmeConstraintSlave* GetConstraintSlave() const { return m_Slave.GetElement(); }
// Find the constraint target for the specified dag node
CDmeConstraintTarget *FindConstraintTargetForDag( CDmeDag* pDag ) const;
// Find all of the constraints that target the specified dag node
static void FindDagConstraints( const CDmeDag *pDagNode, CUtlVector< CDmeRigBaseConstraintOperator* > &constraintList );
// Find the constraint on the dag of the specified type
static CDmeRigBaseConstraintOperator *FindDagConstraint( CDmeDag *pDag, EConstraintType constraintType );
// Destroy the specified constraint and remove it from the animation set.
static void DestroyConstraint( CDmeRigBaseConstraintOperator *pConstraint );
// Remove all of the constraints from the specified dag node.
static void RemoveConstraintsFromDag( CDmeDag *pDag );
// Get the string name associated with the specified constraint type.
static char const *ConstraintTypeName( EConstraintType eType );
protected:
// Add the specified type of attributes from the provided transform
static void AddAttribute( CUtlVector< CDmAttribute * > &attrs, enum EAddType type, class CDmeTransform *pTxForm );
// Add the position and orientation attributes the entire ancestry of the dag node.
static void AddAncestorAttributes( CUtlVector< CDmAttribute * > &attrs, CDmeDag *pDag );
// Compute the offsets of the specified target based on the relative transforms of the target to the slave
virtual void ComputeOffset( Vector &vOffset, Quaternion &qOffset, CDmeConstraintTarget *pTarget, bool bPreserveOffset );
// Compute the aggregate target position from the weighted target list and return the total weight
float ComputeTargetPosition( Vector &wsTargetPosition );
// Compute the aggregate target orientation from the weighted target list and return the total weight
float ComputeTargetOrientation( Quaternion &wsTargetOrientation );
// Disconnect the channels driving the specified slave from the dag and connect them to the constraint
void DisconnectSlaveChannels( CDmeConstraintSlave *pSlave, int attributeFlags );
// Reconnect the transform channels associated with the specified slave directly to the dag
void ReconnectSlaveChannels( CDmeConstraintSlave *pSlave, int attributeFlags );
protected:
CDmaElementArray< CDmeConstraintTarget > m_Targets; // Set of target dag nodes used to calculate position and orientation
CDmaElement< CDmeConstraintSlave > m_Slave; // Dag node who's position and/or orientation are controlled by the constraint
CDmaVar< int > m_mode; // Operating mode of the constraint, determines data flow direction
};
//-----------------------------------------------------------------------------
// CDmeRigPointConstraintOperator
//-----------------------------------------------------------------------------
class CDmeRigPointConstraintOperator : public CDmeRigBaseConstraintOperator
{
public:
DEFINE_ELEMENT( CDmeRigPointConstraintOperator, CDmeRigBaseConstraintOperator );
public:
virtual EConstraintType GetConstraintType() const { return CT_POINT; }
virtual void Operate();
virtual EAddType GetInputAttributeType() const { return (EAddType)( AA_TYPE_POSITION | AA_TYPE_ORIENTATION ); } // Requires position and orientation, orientation is needed for offset
virtual EAddType GetOutputAttributeType() const { return AA_TYPE_POSITION; } // Only writes position of destination bone
};
//-----------------------------------------------------------------------------
// CDmeRigOrientConstraintOperator
//-----------------------------------------------------------------------------
class CDmeRigOrientConstraintOperator : public CDmeRigBaseConstraintOperator
{
public:
DEFINE_ELEMENT( CDmeRigOrientConstraintOperator, CDmeRigBaseConstraintOperator );
public:
virtual EConstraintType GetConstraintType() const { return CT_ORIENT; }
virtual void Operate();
virtual EAddType GetInputAttributeType() const { return AA_TYPE_ORIENTATION; } // Uses just orientations of handles
virtual EAddType GetOutputAttributeType() const { return AA_TYPE_ORIENTATION; } // Only writes orientation of destination bone
};
//-----------------------------------------------------------------------------
// CDmeRigAimConstraintOperator
//-----------------------------------------------------------------------------
class CDmeRigAimConstraintOperator : public CDmeRigBaseConstraintOperator
{
public:
DEFINE_ELEMENT( CDmeRigAimConstraintOperator, CDmeRigBaseConstraintOperator );
public:
virtual EConstraintType GetConstraintType() const { return CT_AIM; }
virtual void Operate();
virtual void GetInputAttributes( CUtlVector< CDmAttribute * > &attrs );
virtual EAddType GetInputAttributeType() const { return AA_TYPE_POSITION; } // Uses just positions of handles
virtual EAddType GetOutputAttributeType() const { return AA_TYPE_ORIENTATION; } // Only writes angle of destination bone
virtual void PostHandlesAdded( bool bPreserveOffset );
// Set the world up vector in the space of the provided dag node and update the offset
void SetUpVector( const Vector &upVector, bool bPreserveOffset, const CDmeDag *pUpSpaceTarget );
// Set the type of up vector, from CConstraintBones::AimConstraintUpType_t
void SetUpType( int nUpType );
private:
// Calculate the orientation needed to make a transform with the specified forward vector
void AimAt( const Vector &vecForward, const Vector &referenceUp, Quaternion &q );
// Re-calculate the offset value based on the target location and the current orientation of the slave
void UpdateOffset( bool bPreserveOffset );
// Calculate the orientation to apply to the slave to make it look at the target position.
float CalculateOrientation( Quaternion &targetOrientation );
CDmaVar< Quaternion > m_AimOffset;
CDmaVar< Vector > m_UpVector;
CDmaElement< const CDmeDag > m_UpSpaceTarget;
CDmaVar< int > m_UpType; // One of CConstraintBones::AimConstraintUpType_t
};
//-----------------------------------------------------------------------------
// CDmeRigRotationConstraintOperator -- An operator for controlling the
// orientation of a dag node using a series axis angle rotations.
//-----------------------------------------------------------------------------
class CDmeRigRotationConstraintOperator : public CDmeRigBaseConstraintOperator
{
public:
DEFINE_ELEMENT( CDmeRigRotationConstraintOperator, CDmeRigBaseConstraintOperator );
public:
virtual EConstraintType GetConstraintType() const { return CT_ROTATION; }
virtual EAddType GetInputAttributeType() const { return AA_TYPE_UNKNOWN; } // Does not use target input values
virtual EAddType GetOutputAttributeType() const { return AA_TYPE_ORIENTATION; } // Only writes orientation of destination dag
// Run the operator, this calculates the quaternion orientation by concatenating the axis angle rotations.
virtual void Operate();
// Get the list of input attributes the operation is dependent on this includes all of the axis values and rotations
virtual void GetInputAttributes( CUtlVector< CDmAttribute * > &attrs );
// Add a rotation axis
int AddAxis( const Vector &axis );
// Set the axis around which the rotation is to occur
void SetAxis( const Vector &axis, int index);
// Set current rotation value
void SetRotation( float rotation, int index );
private:
CDmaArray< float > m_Rotations; // "rotation" : Rotation around the specified axis in degrees
CDmaArray< Vector > m_Axies; // "axies" : Axis about which the rotation will occur
};
//-----------------------------------------------------------------------------
// CDmeRigParentConstraintOperator
//-----------------------------------------------------------------------------
class CDmeRigParentConstraintOperator : public CDmeRigBaseConstraintOperator
{
public:
DEFINE_ELEMENT( CDmeRigParentConstraintOperator, CDmeRigBaseConstraintOperator );
public:
virtual EConstraintType GetConstraintType() const { return CT_PARENT; }
virtual void Operate();
virtual EAddType GetInputAttributeType() const { return (EAddType)( AA_TYPE_POSITION | AA_TYPE_ORIENTATION); } // Uses both position and orientations of handles
virtual EAddType GetOutputAttributeType() const { return (EAddType)( AA_TYPE_POSITION | AA_TYPE_ORIENTATION); } // Writes full transform of destination object
private:
// Compute the aggregate target position and orientation from the weighted target list and return the total weight
float ComputeTargetPositionOrientation( Vector &wsTargetPos, Quaternion &wsTargetOrientation );
// Compute the offsets of the specified target based on the relative transforms of the target to the slave
virtual void ComputeOffset( Vector &vOffset, Quaternion &qOffset, CDmeConstraintTarget *pTarget, bool bPreserveOffset );
};
//-----------------------------------------------------------------------------
// CDmeRigIKConstraintOperator
//-----------------------------------------------------------------------------
class CDmeRigIKConstraintOperator : public CDmeRigBaseConstraintOperator
{
public:
DEFINE_ELEMENT( CDmeRigIKConstraintOperator, CDmeRigBaseConstraintOperator );
public:
virtual EConstraintType GetConstraintType() const { return CT_IK; }
virtual void Operate();
virtual EAddType GetInputAttributeType() const { return AA_TYPE_POSITION; } // Uses just positions of handles
virtual EAddType GetOutputAttributeType() const { Assert( 0 ); return AA_TYPE_UNKNOWN; } // Only writes angle of destination bone
// Overridden
virtual void GetInputAttributes( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
// Find all of the channels relevant to all of the target handles
virtual void GatherInputOperators( CUtlVector< CDmeOperator * > &operatorList );
// Disconnect the channels driving the slave dag nodes from the dag transforms and connect them to the constraint
virtual void DisconnectTransformChannels();
// Reconnect the base channels of each slave directly to the dag
virtual void ReconnectTransformChannels();
// Assign the joints that are to be controlled
void SetJoints( CDmeDag *pStartJoint, CDmeDag *pMidJoint, CDmeDag *pEndJoint );
// Set the pole vector which determines the direction the middle joint is to be moved within the plane
void SetPoleVector( const Vector &worldPos );
// Set the pole vector target, a dag node toward which the pole vector will point, overrides the standard pole vector.
void SetPoleVectorTarget( CDmeDag *pPoleVectorTarget );
// Validates that the start and end effector are set up and that there is only one intermediate bone between them forming a 2 bone ik chain.
bool Setup( bool bPreserveOffset );
// Get a pointer to the dag node the constraint is controlling
virtual const CDmeDag *GetSlave() const;
// Determine if the the constraint has slave with the specified name, for the ik constraint this is always false.
virtual bool IsSlaveObject( char const *pchName ) const;
private:
// Compute the offsets of the specified target based on the relative transforms of the target to the slave
virtual void ComputeOffset( Vector &vOffset, Quaternion &qOffset, CDmeConstraintTarget *pTarget, bool bPreserveOffset );
// Calculate the orientation needed to make a transform with the specified forward vector
void AimAt( const Vector &vecForward, const Vector &referenceUp, Quaternion &q );
// Perform the 2 bone ik solve to get target orientation for the start and mid bones
float CalculateOrientations( Quaternion &startBoneOrient, Quaternion &midBoneOrient, const Quaternion &startOffset, const Quaternion &midOffset );
public:
CDmaVar< Quaternion > m_StartOffsetRotation;
CDmaVar< Quaternion > m_MidOffsetRotation;
CDmaVar< Vector > m_PoleVector;
CDmaElement< CDmeDag > m_PoleVectorTarget;
CDmaElement< CDmeConstraintSlave > m_StartJoint;
CDmaElement< CDmeConstraintSlave > m_MidJoint;
CDmaElement< CDmeConstraintSlave > m_EndJoint;
};
//-----------------------------------------------------------------------------
// CDmeRigTwistSlave
//-----------------------------------------------------------------------------
class CDmeRigTwistSlave : public CDmeConstraintSlave
{
DEFINE_ELEMENT( CDmeRigTwistSlave, CDmeConstraintSlave );
public:
// Sets the weight for this slave
void SetWeight( float flWeight ) { m_flWeight = flWeight; }
// Gets the weight for this slave
float GetWeight() const { return m_flWeight; }
protected:
CDmaVar< float > m_flWeight;
};
//-----------------------------------------------------------------------------
// CDmeRigTwistConstraintOperator
//-----------------------------------------------------------------------------
class CDmeRigTwistConstraintOperator : public CDmeRigBaseConstraintOperator
{
public:
DEFINE_ELEMENT( CDmeRigTwistConstraintOperator, CDmeRigBaseConstraintOperator );
public:
// Returns the value of the m_bInverse attribute
bool GetInverse() const { return m_bInverse; }
// Sets the value of the m_bInverse attribute
void SetInverse( bool bInverse ) { m_bInverse = bInverse; }
// Returns the value of the m_vUpAxis attribute
const Vector &GetUpAxis() const { return m_vUpAxis; }
// Sets the value of the m_bInverse attribute
void SetUpAxis( const Vector &vUpAxis ) { m_vUpAxis = vUpAxis; }
// Get the Target dag that is the child joint
bool SetTargets( CDmeDag *pDmeDagParent, CDmeDag *pDmeDagChild );
// Get the Target dag that is the parent joint
CDmeDag *GetParentTarget() const;
// Get the Target dag that is the child joint
CDmeDag *GetChildTarget() const;
// Remove all slaves
void ClearSlaves();
// Add slave
int AddSlave( CDmeDag *pDmeDagSlave, float flWeight );
// Get slave count
int SlaveCount() const { return m_eSlaves.Count(); }
// Get slave count
CDmeDag *GetSlaveDag( int i ) const;
// Get slave count
float GetSlaveWeight( int i ) const;
// Get parent bind rotation
const Quaternion &GetParentBindRotation() const { return m_qParentBindRotation; }
// Get parent bind rotation
void SetParentBindRotation( const Quaternion &qBindRotation );
// Get child bind rotation
const Quaternion &GetChildBindRotation() const { return m_qChildBindRotation; }
// Get child bind rotation
void SetChildBindRotation( const Quaternion &qBindRotation );
// Get slave bind rotation
const Quaternion &GetSlaveBindOrientation( int i ) const;
// Get slave bind rotation
void SetSlaveBindOrientation( const Quaternion &qBindRotation, int i );
// From CDmeRigBaseConstraintOperator
virtual EConstraintType GetConstraintType() const { return CT_TWIST; }
virtual void Operate();
virtual EAddType GetInputAttributeType() const { return (EAddType)( AA_TYPE_POSITION | AA_TYPE_ORIENTATION ); } // Requires position and orientation
virtual EAddType GetOutputAttributeType() const { return AA_TYPE_ORIENTATION; } // Only writes orientation of destination bone
// Overridden
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
// Get a pointer to the dag node the constraint is controlling
virtual const CDmeDag *GetSlave() const;
// Determine if the the constraint has slave with the specified name, for the ik constraint this is always false.
virtual bool IsSlaveObject( char const *pchName ) const;
private:
// Compute the offsets of the specified target based on the relative transforms of the target to the slave
virtual void ComputeOffset( Vector &vOffset, Quaternion &qOffset, CDmeConstraintTarget *pTarget, bool bPreserveOffset );
// Disconnect the channels driving the slave dag nodes from the dag transforms and connect them to the constraint
virtual void DisconnectTransformChannels();
// Reconnect the base channels of each slave directly to the dag
virtual void ReconnectTransformChannels();
CDmaVar< bool > m_bInverse;
CDmaVar< Vector > m_vUpAxis;
CDmaArray< float > m_flWeights;
CDmaElementArray< CDmeRigTwistSlave > m_eSlaves;
CDmaVar< Quaternion > m_qParentBindRotation;
CDmaVar< Quaternion > m_qChildBindRotation;
};
#endif // DMERIGCONSTRAINTOPERATORS_H

View File

@@ -0,0 +1,25 @@
//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMERIGHANDLE_H
#define DMERIGHANDLE_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "movieobjects/dmedag.h"
#include "movieobjects/dmeoperator.h"
class CDmeRigHandle : public CDmeDag
{
DEFINE_ELEMENT( CDmeRigHandle, CDmeDag );
public:
};
#endif // DMERIGHANDLE_H

View File

@@ -0,0 +1,201 @@
//====== Copyright © 1996-2006, Valve Corporation, All rights reserved. =======
//
// A class representing a subselection of something like a mesh
//
//=============================================================================
#ifndef DMECOMPONENT_H
#define DMECOMPONENT_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattributevar.h"
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
class CDmeComponent : public CDmElement
{
DEFINE_ELEMENT( CDmeComponent, CDmElement );
public:
enum Component_t
{
COMP_INVALID = -1,
COMP_VTX,
COMP_FACE,
STANDARD_COMP_COUNT
};
// resolve internal data from changed attributes
virtual void Resolve();
// What type of component is this
Component_t Type() const;
// How many pieces are in this component
virtual int Count() const;
// Are there no pieces in this component
bool IsEmpty() const;
// Are all possible pieces in this component
bool IsComplete() const;
// Is this an equivalent component to another component
virtual bool IsEqual( const CDmeComponent *pRhs ) const;
// Reset to an empty selection
virtual void Clear();
protected:
CDmaVar< int > m_Type;
CDmaVar< bool > m_bComplete;
};
//-----------------------------------------------------------------------------
// The default type is invalid
//-----------------------------------------------------------------------------
inline CDmeComponent::Component_t CDmeComponent::Type() const
{
const int type( m_Type.Get() );
if ( type < 0 || type >= STANDARD_COMP_COUNT )
return COMP_INVALID;
return static_cast< Component_t >( type );
}
//-----------------------------------------------------------------------------
// Are there no pieces in this component
//-----------------------------------------------------------------------------
inline int CDmeComponent::Count() const
{
Assert( 0 );
return 0;
}
//-----------------------------------------------------------------------------
// Are there no pieces in this component
//-----------------------------------------------------------------------------
inline bool CDmeComponent::IsEmpty() const
{
return Count() == 0;
}
//-----------------------------------------------------------------------------
// Are all possible pieces in this component
//-----------------------------------------------------------------------------
inline bool CDmeComponent::IsEqual( const CDmeComponent *pRhs ) const
{
return Type() == pRhs->Type() && Count() == pRhs->Count() && IsComplete() == pRhs->IsComplete();
}
//-----------------------------------------------------------------------------
// Are all possible pieces in this component
//-----------------------------------------------------------------------------
inline bool CDmeComponent::IsComplete() const
{
return m_bComplete.Get();
}
//-----------------------------------------------------------------------------
// Reset to an empty selection
//-----------------------------------------------------------------------------
inline void CDmeComponent::Clear()
{
m_bComplete.Set( false );
}
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
class CDmeSingleIndexedComponent : public CDmeComponent
{
DEFINE_ELEMENT( CDmeSingleIndexedComponent, CDmeComponent );
public:
// resolve internal data from changed attributes
virtual void Resolve();
// From CDmeComponent
virtual int Count() const;
bool SetType( Component_t type );
void AddComponent( int component, float weight = 1.0f );
void AddComponents( const CUtlVector< int > &components );
void AddComponents( const CUtlVector< int > &components, const CUtlVector< float > &weights );
void RemoveComponent( int component );
bool GetComponent( int index, int &component, float &weight ) const;
bool GetWeight( int component, float &weight ) const;
void GetComponents( CUtlVector< int > &components ) const;
void GetComponents( CUtlVector< int > &components, CUtlVector< float > &weights ) const;
void SetComplete( int nComplete );
int GetComplete() const;
bool HasComponent( int component ) const;
virtual void Clear();
void Add( const CDmeSingleIndexedComponent &rhs );
void Add( const CDmeSingleIndexedComponent *pRhs ) { Assert( pRhs ); Add( *pRhs ); }
void Union( const CDmeSingleIndexedComponent &rhs ) { Add( rhs ); }
void Union( const CDmeSingleIndexedComponent *pRhs ) { Assert( pRhs ); Add( *pRhs ); }
CDmeSingleIndexedComponent &operator+=( const CDmeSingleIndexedComponent &rhs ) { Add( rhs ); return *this; }
void Subtract( const CDmeSingleIndexedComponent &rhs );
void Subtract( const CDmeSingleIndexedComponent *pRhs ) { Assert( pRhs ); Subtract( *pRhs ); }
void Complement( const CDmeSingleIndexedComponent &rhs ) { Subtract( rhs ); }
void Complement( const CDmeSingleIndexedComponent *pRhs ) { Assert( pRhs ); Subtract( *pRhs ); }
CDmeSingleIndexedComponent &operator-=( const CDmeSingleIndexedComponent &rhs ) { Subtract( rhs ); return *this; }
void Intersection( const CDmeSingleIndexedComponent &rhs );
void Intersection( const CDmeSingleIndexedComponent *pRhs ) { Assert( pRhs ); Intersection( *pRhs ); }
protected:
int BinarySearch( int component ) const;
CDmaVar< int > m_CompleteCount;
CDmaArray< int > m_Components;
CDmaArray< float > m_Weights;
};
#endif // DMECOMPONENT_H

View File

@@ -0,0 +1,53 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class representing a shader
//
//=============================================================================
#ifndef DMESHADER_H
#define DMESHADER_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class IShader;
//-----------------------------------------------------------------------------
// A class representing a material
//-----------------------------------------------------------------------------
class CDmeShader : public CDmElement
{
DEFINE_ELEMENT( CDmeShader, CDmElement );
public:
void SetShaderName( const char *pShaderName );
const char *GetShaderName() const;
// Resolve
virtual void Resolve();
private:
// Finds a shader
IShader *FindShader();
// Remove all shader parameters that don't exist in the new shader
void RemoveUnusedShaderParams( IShader *pShader );
// Add all shader parameters that don't currently exist
void AddNewShaderParams( IShader *pShader );
// Add attribute for shader parameter
CDmAttribute* AddAttributeForShaderParameter( IShader *pShader, int nIndex );
IShader *m_pShader;
CDmAttributeVarString m_ShaderName;
};
#endif // DMESHADER_H

View File

@@ -0,0 +1,54 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class representing an abstract shape (ie drawable object)
//
//=============================================================================
#ifndef DMESHAPE_H
#define DMESHAPE_H
#ifdef _WIN32
#pragma once
#endif
#include "mathlib/mathlib.h"
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeTransform;
class CDmeDrawSettings;
class CDmeDag;
//-----------------------------------------------------------------------------
// A class representing a camera
//-----------------------------------------------------------------------------
class CDmeShape : public CDmElement
{
DEFINE_ELEMENT( CDmeShape, CDmElement );
public:
virtual void Draw( const matrix3x4_t &shapeToWorld, CDmeDrawSettings *pDmeDrawSettings = NULL );
virtual void GetBoundingSphere( Vector &c, float &r ) const;
virtual void GetBoundingBox( Vector &min, Vector &max ) const { min.Zero(); max.Zero(); }
// Find out how many DmeDag's have this DmeShape as their shape, could be 0
int GetParentCount() const;
// Get the nth DmeDag that has this DmeShape as its shape. The order is defined by g_pDataModel->FirstAttributeReferencingElement/NextAttr...
CDmeDag *GetParent( int nParentIndex = 0 ) const;
// Get the Nth World Matrix for the shape (the world matrix of the Nth DmeDag parent)
void GetShapeToWorldTransform( matrix3x4_t &mat, int nParentIndex = 0 ) const;
protected:
CDmaVar< bool > m_visible;
};
#endif // DMESHAPE_H

View File

@@ -0,0 +1,53 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class representing a sound
//
//=============================================================================
#ifndef DMESOUND_H
#define DMESOUND_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
//-----------------------------------------------------------------------------
// A class representing a camera
//-----------------------------------------------------------------------------
class CDmeSound : public CDmElement
{
DEFINE_ELEMENT( CDmeSound, CDmElement );
public:
CDmaString m_SoundName;
CDmaString m_GameSoundName; // Only used if it's a gamesound
// Return false if it can't find the sound full path
bool ComputeSoundFullPath( char *pBuf, int nBufLen );
};
class CDmeGameSound : public CDmeSound
{
DEFINE_ELEMENT( CDmeGameSound, CDmeSound );
public:
CDmElement *FindOrAddPhonemeExtractionSettings();
CDmaVar< float > m_Volume;
CDmaVar< int > m_Level;
CDmaVar< int > m_Pitch;
CDmaVar< bool > m_IsStatic;
CDmaVar< int > m_Channel;
CDmaVar< int > m_Flags;
// CDmaElement m_Source;
// CDmaVar< bool > m_FollowSource;
CDmaVar< Vector > m_Origin;
CDmaVar< Vector > m_Direction;
};
#endif // DMESOUND_H

View File

@@ -0,0 +1,140 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class representing a mesh
//
//=============================================================================
#ifndef DMETESTMESH_H
#define DMETESTMESH_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmeshape.h"
#include "datacache/imdlcache.h"
#include "mathlib/vector.h"
#include <string>
#include <vector>
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeTransform;
class IMorph;
class IMaterial;
struct SubdivMesh_t;
class IMesh;
class CDmeDrawSettings;
//-----------------------------------------------------------------------------
// First attempt at making a hacky SMD loader - clean this up later
//-----------------------------------------------------------------------------
struct skinning_info_t
{
skinning_info_t() : index( -1 ), weight( 0.0f )
{
}
skinning_info_t( int i, float w ) : index( i ), weight( w )
{
}
int index;
float weight;
bool operator<( const skinning_info_t &info )
{
return weight < info.weight;
}
};
struct vertex_t
{
Vector coord;
Vector normal;
Vector2D texcoord;
std::vector< skinning_info_t > skinning;
static float normal_tolerance;
bool operator==( const vertex_t &vert )
{
return
// skinning == vert.skinning && // TODO - the original studiomdl doesn't do this, but...
coord == vert.coord &&
texcoord == vert.texcoord &&
DotProduct( normal, vert.normal ) > normal_tolerance;
}
};
struct submesh_t
{
submesh_t( const std::string &texture_name ) : texname( texture_name )
{
}
std::string texname;
std::vector< int > indices;
std::vector< vertex_t > vertices;
std::vector< CDmeTransform* > bones;
};
//-----------------------------------------------------------------------------
// A class representing a mesh
//-----------------------------------------------------------------------------
class CDmeTestMesh : public CDmeShape
{
DEFINE_ELEMENT( CDmeTestMesh, CDmeShape );
public:
virtual void Draw( const matrix3x4_t& shapeToWorld, CDmeDrawSettings *pDrawSettings = NULL );
static CDmeTestMesh *ReadMeshFromSMD( char *pFilename, DmFileId_t fileid );
virtual void Resolve();
private:
// Addref/Release the MDL handle
void ReferenceMDL( const char *pMDLName );
void UnreferenceMDL();
// Returns a mask indicating which bones to set up
int BoneMask( );
// Sets up the bones
void SetUpBones( CDmeTransform *pTransform, int nMaxBoneCount, matrix3x4_t *pBoneToWorld );
// For testing vertex textures
void LoadMorphData( const char *pMorphFile, int nVertexCount );
void UnloadMorphData();
void LoadModelMatrix( CDmeTransform *pTransform );
void DrawBox( CDmeTransform *pTransform );
// Draws a subdivided box
void DrawSubdivMesh( const SubdivMesh_t &mesh );
void DrawSubdividedBox();
// Creates/destroys the subdiv control cage
void CreateControlCage( );
void DestroyControlCage( );
// Creates/destroys the morphed mesh
void CreateMesh( );
void DestroyMesh( );
MDLHandle_t m_MDLHandle;
IMaterial *m_pMaterial;
IMesh *m_pMesh;
IMorph *m_pMorph;
SubdivMesh_t *m_pControlCage;
//-----------------------------------------------------------------------------
// First attempt at making a hacky SMD loader - clean this up later
//-----------------------------------------------------------------------------
std::vector< submesh_t* > m_submeshes;
std::vector< CDmeTransform* > m_bones;
};
#endif // DMETESTMESH_H

View File

@@ -0,0 +1,153 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMETIMEFRAME_H
#define DMETIMEFRAME_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattributevar.h"
//-----------------------------------------------------------------------------
// Time classes used to help disambiguate between local + parent time
//-----------------------------------------------------------------------------
typedef int LocalTime_t;
typedef int ParentTime_t;
class CDmeTimeFrame : public CDmElement
{
DEFINE_ELEMENT( CDmeTimeFrame, CDmElement );
public:
// Methods of IDmElement
virtual void OnAttributeChanged( CDmAttribute *pAttribute );
DmeTime_t ToChildMediaTime( DmeTime_t t, bool bClamp = true ) const;
DmeTime_t FromChildMediaTime( DmeTime_t t, bool bClamp = true ) const;
DmeTime_t ToChildMediaDuration( DmeTime_t dt ) const;
DmeTime_t FromChildMediaDuration( DmeTime_t dt ) const;
DmeTime_t GetStartTime() const;
DmeTime_t GetDuration() const;
DmeTime_t GetTimeOffset() const;
float GetTimeScale() const;
DmeTime_t GetStartInChildMediaTime() const;
DmeTime_t GetEndInChildMediaTime() const;
void SetStartTime( DmeTime_t startTime );
void SetDuration( DmeTime_t duration );
void SetTimeOffset( DmeTime_t offset );
void SetTimeScale( float flScale );
void SetEndTime( DmeTime_t endTime, bool bChangeDuration );
void SetTimeScale( float flScale, DmeTime_t scaleCenter, bool bChangeDuration );
private:
CDmaTime m_Start;
CDmaTime m_Duration;
CDmaTime m_Offset;
CDmaVar< float > m_Scale;
};
//-----------------------------------------------------------------------------
// inline methods
//-----------------------------------------------------------------------------
inline DmeTime_t CDmeTimeFrame::GetStartTime() const
{
return m_Start;
}
inline DmeTime_t CDmeTimeFrame::GetDuration() const
{
return m_Duration;
}
inline DmeTime_t CDmeTimeFrame::GetTimeOffset() const
{
return m_Offset;
}
inline float CDmeTimeFrame::GetTimeScale() const
{
return m_Scale;
}
inline void CDmeTimeFrame::SetStartTime( DmeTime_t startTime )
{
m_Start = startTime;
}
inline void CDmeTimeFrame::SetDuration( DmeTime_t duration )
{
Assert( duration >= DMETIME_ZERO ); // if you want a reversed clip, set the timescale negative
m_Duration = MAX( DMETIME_ZERO, duration );
}
inline void CDmeTimeFrame::SetTimeOffset( DmeTime_t offset )
{
m_Offset = offset;
}
inline void CDmeTimeFrame::SetTimeScale( float flScale )
{
m_Scale = flScale;
}
//-----------------------------------------------------------------------------
// Convert back + forth between my media time and child media time
//-----------------------------------------------------------------------------
inline DmeTime_t CDmeTimeFrame::ToChildMediaTime( DmeTime_t t, bool bClamp ) const
{
t -= m_Start;
if ( bClamp )
{
t.Clamp( DMETIME_ZERO, m_Duration );
}
return ( t + m_Offset ) * m_Scale;
}
inline DmeTime_t CDmeTimeFrame::FromChildMediaTime( DmeTime_t t, bool bClamp ) const
{
t = t / m_Scale - m_Offset;
if ( bClamp )
{
t.Clamp( DMETIME_ZERO, m_Duration );
}
return t + m_Start;
}
inline DmeTime_t CDmeTimeFrame::ToChildMediaDuration( DmeTime_t dt ) const
{
return dt * m_Scale;
}
inline DmeTime_t CDmeTimeFrame::FromChildMediaDuration( DmeTime_t dt ) const
{
return dt / m_Scale;
}
inline DmeTime_t CDmeTimeFrame::GetStartInChildMediaTime() const
{
DmeTime_t time = m_Offset.Get() * m_Scale;
Assert( time == ToChildMediaTime( GetStartTime() ) );
return time;
}
inline DmeTime_t CDmeTimeFrame::GetEndInChildMediaTime() const
{
DmeTime_t time = ( m_Offset.Get() + m_Duration.Get() ) * m_Scale;
Assert( time == ToChildMediaTime( GetStartTime() + GetDuration() ) );
return time;
}
#endif // DMETIMEFRAME_H

View File

@@ -0,0 +1,98 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMETIMESELECTION_H
#define DMETIMESELECTION_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattributevar.h"
#include "movieobjects/dmetimeselectiontimes.h"
enum RecordingState_t;
class CDmeTimeSelection : public CDmElement
{
DEFINE_ELEMENT( CDmeTimeSelection, CDmElement );
public:
bool IsEnabled() const;
void SetEnabled( bool state );
bool IsRelative() const;
void SetRelative( DmeTime_t time, bool state );
DmeTime_t GetAbsFalloff( DmeTime_t time, int side ) const;
DmeTime_t GetAbsHold( DmeTime_t time, int side ) const;
DmeTime_t GetRelativeFalloff( DmeTime_t time, int side ) const;
DmeTime_t GetRelativeHold( DmeTime_t time, int side ) const;
void SetAbsFalloff( DmeTime_t time, int side, DmeTime_t absfallofftime );
void SetAbsHold ( DmeTime_t time, int side, DmeTime_t absholdtime );
int GetFalloffInterpolatorType( int side ) const;
void SetFalloffInterpolatorType( int side, int interpolatorType );
void GetAlphaForTime( DmeTime_t t, DmeTime_t curtime, byte &alpha );
float GetAmountForTime( DmeTime_t t, DmeTime_t curtime );
float AdjustFactorForInterpolatorType( float factor, int side );
void CopyFrom( const CDmeTimeSelection &src );
void GetAbsTimes( DmeTime_t time, DmeTime_t pTimes[TS_TIME_COUNT] ) const;
void GetCurrent( DmeTime_t pTimes[TS_TIME_COUNT] ) const;
void SetCurrent( const TimeSelection_t &times );
float GetThreshold() const;
void SetThreshold( float threshold );
DmeTime_t GetResampleInterval() const;
void SetResampleInterval( DmeTime_t resampleInterval );
void SetRecordingState( RecordingState_t state );
RecordingState_t GetRecordingState() const;
void GetTimeSelectionTimes( DmeTime_t curtime, DmeTime_t t[ TS_TIME_COUNT ] ) const;
void SetTimeSelectionTimes( DmeTime_t curtime, DmeTime_t t[ TS_TIME_COUNT ] );
// Does selection extend to 'infinity' in this side?
bool IsInfinite( int side ) const;
void SetInfinite( int side );
bool IsFullyInfinite() const;
bool IsEitherInfinite() const;
void GetInfinite( bool bInfinite[ 2 ] ) const;
DmeTime_t GetAbsTime( DmeTime_t time, int tsType ) const;
DmeTime_t GetRelativeTime( DmeTime_t time, int tsType ) const;
void SetAbsTime( DmeTime_t time, int tsType, DmeTime_t absTime );
// helper to see if any of the times are really close to DME_MAXTIME/DME_MINTIME but not exactly on them
bool IsSuspicious( bool bCheckHoldAndFalloff = false );
private:
CDmeTimeSelection & operator =( const CDmeTimeSelection& src ) { Assert( 0 ); }
void ConvertToRelative( DmeTime_t time );
void ConvertToAbsolute( DmeTime_t time );
CDmaVar< bool > m_bEnabled;
CDmaVar< bool > m_bRelative;
// These are all offsets from the "current" head position in seconds, or they are absolute times if not using relative mode
CDmaTime m_falloff[ 2 ];
CDmaTime m_hold[ 2 ];
CDmaVar< int > m_nFalloffInterpolatorType[ 2 ];
CDmaVar< float > m_threshold;
CDmaTime m_resampleInterval;
CDmaVar< int > m_nRecordingState;
};
#endif // DMETIMESELECTION_H

View File

@@ -0,0 +1,70 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMETIMESELECTIONTIMES_H
#define DMETIMESELECTIONTIMES_H
#ifdef _WIN32
#pragma once
#endif
enum TimeSelectionTimes_t
{
TS_LEFT_FALLOFF = 0,
TS_LEFT_HOLD,
TS_RIGHT_HOLD,
TS_RIGHT_FALLOFF,
TS_TIME_COUNT,
};
struct TimeSelection_t
{
TimeSelection_t()
{
m_Times[ TS_LEFT_FALLOFF ] = DMETIME_INVALID;
m_Times[ TS_LEFT_HOLD ] = DMETIME_INVALID;
m_Times[ TS_RIGHT_HOLD ] = DMETIME_INVALID;
m_Times[ TS_RIGHT_FALLOFF] = DMETIME_INVALID;
}
const DmeTime_t &operator[]( int index ) const
{
Assert( index < TS_TIME_COUNT );
return m_Times[ index ];
}
DmeTime_t &operator[]( int index )
{
Assert( index < TS_TIME_COUNT );
return m_Times[ index ];
}
bool operator==( const TimeSelection_t &rhs )
{
for ( int i = 0; i < TS_TIME_COUNT; ++i )
{
if ( m_Times[ i ] != rhs.m_Times[ i ] )
return false;
}
return true;
}
bool operator!=( const TimeSelection_t &rhs )
{
return !operator==( rhs );
}
DmeTime_t m_Times[ TS_TIME_COUNT ];
};
// NOTE: _side == 0 means left, == 1 means right
#define TS_FALLOFF( _side ) ( ( TS_TIME_COUNT - (_side) ) & 0x3 )
#define TS_HOLD( _side ) ( TS_LEFT_HOLD + (_side) )
#endif // DMETIMESELECTIONTIMES_H

View File

@@ -0,0 +1,210 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMETRACK_H
#define DMETRACK_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/utlflags.h"
#include "datamodel/dmelement.h"
#include "datamodel/dmehandle.h"
#include "movieobjects/dmeclip.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeClip;
enum DmeClipType_t;
//-----------------------------------------------------------------------------
// Default track name
//-----------------------------------------------------------------------------
#define DMETRACK_DEFAULT_NAME "default"
//-----------------------------------------------------------------------------
// Constructor, destructor
//-----------------------------------------------------------------------------
class CDmeTrack : public CDmElement
{
DEFINE_ELEMENT( CDmeTrack, CDmElement );
public:
// Methods of IDmElement
virtual void OnAttributeChanged( CDmAttribute *pAttribute );
void SetCollapsed( bool state );
bool IsCollapsed() const;
void SetVolume( float state );
float GetVolume() const;
void SetMute( bool state );
bool IsMute( bool bCheckSoloing = true ) const;
// Is this track synched to the film track?
void SetSynched( bool bState );
bool IsSynched() const;
int GetClipCount() const;
CDmeClip *GetClip( int i ) const;
const CUtlVector< DmElementHandle_t > &GetClips( ) const;
void AddClip( CDmeClip *clip );
bool RemoveClip( CDmeClip *clip );
void RemoveClip( int i );
void RemoveAllClips();
int FindClip( CDmeClip *clip );
CDmeClip *FindNamedClip( const char *name );
DmeClipType_t GetClipType() const;
void SetClipType( DmeClipType_t type );
// Find clips at, intersecting or within a particular time interval
void FindClipsAtTime( DmeTime_t time, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
void FindClipsIntersectingTime( DmeTime_t startTime, DmeTime_t endTime, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
void FindClipsWithinTime( DmeTime_t startTime, DmeTime_t endTime, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
// Methods to shift clips around
// These methods shift clips that straddle the start/end time (NOTE: time is measured in local time)
// NOTE: bTestStartingTime true means if the starting time is after the start time, then shift
// Setting it to false means if the clip intersects the time at all, then shift
void ShiftAllClipsAfter ( DmeTime_t startTime, DmeTime_t dt, bool bTestStartingTime = true );
void ShiftAllClipsBefore( DmeTime_t endTime, DmeTime_t dt, bool bTestEndingTime = true );
void ShiftAllClips( DmeTime_t dt );
// A version that works only on film clips
void ShiftAllFilmClipsAfter ( CDmeClip *pClip, DmeTime_t dt, bool bShiftClip = false, bool bSortClips = true );
void ShiftAllFilmClipsBefore( CDmeClip *pClip, DmeTime_t dt, bool bShiftClip = false, bool bSortClips = true );
// Sorts all children so they ascend in time
void SortClipsByStartTime( );
// Shifts all clips to be non-overlapping
void FixOverlaps();
// Can this track contain clips that overlap in time?
// NOTE: Non-overlapping clips will be
bool IsNonoverlapping() const;
// Is this a film track?
bool IsFilmTrack() const;
// Returns the next/previous clip in a film track
CDmeClip* FindPrevFilmClip( CDmeClip *pClip );
CDmeClip* FindNextFilmClip( CDmeClip *pClip );
void FindAdjacentFilmClips( CDmeClip *pClip, CDmeClip *&pPrevClip, CDmeClip *&pNextClip );
void FindAdjacentFilmClips( DmeTime_t localTime, CDmeClip *&pPrevClip, CDmeClip *&pNextClip );
// Finds a clip at a particular time
CDmeClip* FindFilmClipAtTime( DmeTime_t localTime );
// Find first clip that intersects a specific time range
CDmeClip* FindFirstFilmClipIntesectingTime( DmeTime_t localStartTime, DmeTime_t localEndTime );
// Inserts space in a film track for a film clip
void InsertSpaceInFilmTrack( DmeTime_t localStartTime, DmeTime_t localEndTime );
// Singleton solo track (of the same clip type that this track is)
CDmeTrack *GetSoloTrack( ) const;
void SetSoloTrack( );
bool IsSoloTrack() const;
static CDmeTrack *GetSoloTrack( DmeClipType_t clipType );
static void SetSoloTrack( DmeClipType_t clipType, CDmeTrack *pTrack );
// Fills all gaps in a film track with slugs
void FillAllGapsWithSlugs( const char *pSlugName, DmeTime_t startTime, DmeTime_t endTime );
// Track vertical display scale
void SetDisplayScale( float flDisplayScale );
float GetDisplayScale() const;
private:
class CSuppressAutoFixup
{
public:
CSuppressAutoFixup( CDmeTrack *pTrack, int nFlags ) : m_pTrack( pTrack ), m_nFlags( nFlags )
{
m_pTrack->m_Flags.SetFlag( m_nFlags );
}
~CSuppressAutoFixup()
{
m_pTrack->m_Flags.ClearFlag( m_nFlags );
}
private:
CDmeTrack *m_pTrack;
int m_nFlags;
};
enum
{
IS_SORTED = 0x1,
SUPPRESS_OVERLAP_FIXUP = 0x2,
SUPPRESS_DIRTY_ORDERING = 0x4,
};
CDmaElementArray< CDmeClip > m_Clips;
CDmaVar< float > m_Volume;
CDmaVar< bool > m_Collapsed;
CDmaVar< bool > m_Mute;
CDmaVar< bool > m_Synched;
CDmaVar< int > m_ClipType;
CDmaVar< float > m_flDisplayScale;
CUtlFlags< unsigned char > m_Flags;
DmElementHandle_t m_hOwner;
static DmElementHandle_t m_hSoloTrack[DMECLIP_TYPE_COUNT];
friend class CSuppressAutoFixup;
};
//-----------------------------------------------------------------------------
// Indicates whether tracks contain clips that are non-overlapping in time
//-----------------------------------------------------------------------------
inline bool CDmeTrack::IsNonoverlapping() const
{
return m_ClipType == DMECLIP_FILM;
}
//-----------------------------------------------------------------------------
// Is this a film track?
//-----------------------------------------------------------------------------
inline bool CDmeTrack::IsFilmTrack() const
{
return m_ClipType == DMECLIP_FILM;
}
//-----------------------------------------------------------------------------
// Track vertical display scale
//-----------------------------------------------------------------------------
inline void CDmeTrack::SetDisplayScale( float flDisplayScale )
{
m_flDisplayScale = flDisplayScale;
}
inline float CDmeTrack::GetDisplayScale() const
{
return m_flDisplayScale;
}
//-----------------------------------------------------------------------------
// helper methods
//-----------------------------------------------------------------------------
CDmeTrackGroup *GetParentTrackGroup( CDmeTrack *pTrack );
#endif // DMETRACK_H

View File

@@ -0,0 +1,249 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef DMETRACKGROUP_H
#define DMETRACKGROUP_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/utlflags.h"
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "datamodel/dmehandle.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeClip;
class CDmeFilmClip;
class CDmeTrack;
enum DmeClipType_t;
enum DmeClipSkipFlag_t;
//-----------------------------------------------------------------------------
// Default track group name
//-----------------------------------------------------------------------------
#define DMETRACKGROUP_DEFAULT_NAME "default"
//-----------------------------------------------------------------------------
// A track group
//-----------------------------------------------------------------------------
class CDmeTrackGroup : public CDmElement
{
DEFINE_ELEMENT( CDmeTrackGroup, CDmElement );
public:
// Max track count
void SetMaxTrackCount( int nCount );
// Owning clip
CDmeClip *GetOwnerClip();
// track helper methods
void AddTrack( CDmeTrack *track );
CDmeTrack* AddTrack( const char *pTrackName, DmeClipType_t trackType );
CDmeTrack* FindOrAddTrack( const char *pTrackName, DmeClipType_t trackType );
void RemoveTrack( CDmeTrack *track );
void RemoveTrack( const char *pTrackName );
void RemoveTrack( int nIndex );
const CUtlVector< DmElementHandle_t > &GetTracks( ) const;
int GetTrackCount( ) const;
CDmeTrack *GetTrack( int nIndex ) const;
CDmeTrack *FindTrack( const char *pTrackName ) const;
int GetTrackIndex( CDmeTrack *pTrack ) const;
// Clip helper methods
// AddClip/ChangeTrack returns non-NULL if it was successfully added
CDmeTrack *AddClip( CDmeClip *pClip, const char *pTrackName );
bool RemoveClip( CDmeClip *pClip );
CDmeTrack *ChangeTrack( CDmeClip *pClip, const char *pNewTrack );
CDmeTrack *FindTrackForClip( CDmeClip *pClip ) const;
bool FindTrackForClip( CDmeClip *pClip, int *pTrackIndex, int *pClipIndex = NULL ) const;
// Finding clips at a particular time
void FindClipsAtTime( DmeClipType_t clipType, DmeTime_t time, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
void FindClipsIntersectingTime( DmeClipType_t clipType, DmeTime_t startTime, DmeTime_t endTime, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
void FindClipsWithinTime( DmeClipType_t clipType, DmeTime_t startTime, DmeTime_t endTime, DmeClipSkipFlag_t flags, CUtlVector< CDmeClip * >& clips ) const;
// Are we a film track group?
bool IsFilmTrackGroup();
// Gets the film track (if this is a film track group)
CDmeTrack *GetFilmTrack();
// Is a particular clip typed able to be added?
bool IsSubClipTypeAllowed( DmeClipType_t type );
// Is this track group visible?
void SetVisible( bool bVisible );
bool IsVisible() const;
// Is this track group minimized?
void SetMinimized( bool bLocked );
bool IsMinimized() const;
// Track vertical display scale
void SetDisplayScale( float flDisplayScale );
float GetDisplayScale() const;
// Creates the film track group [for internal use only]
CDmeTrack *CreateFilmTrack();
// Sort tracks by track type, then alphabetically
void SortTracksByType();
// Removes empty tracks
void RemoveEmptyTracks();
// Muting track groups
void SetMute( bool state );
bool IsMute( ) const;
// Volume for track group
void SetVolume( float state );
float GetVolume() const;
// Returns the flattened clip count
int GetSubClipCount() const;
void GetSubClips( CDmeClip **ppClips );
bool GetForceMultiTrack() const;
void SetForceMultiTrack( bool bForce );
private:
CDmaElementArray< CDmeTrack > m_Tracks;
CDmaVar<bool> m_bIsVisible;
CDmaVar<bool> m_bMinimized;
CDmaVar< bool > m_bMute;
CDmaVar< float > m_Volume;
CDmaVar< float > m_flDisplayScale;
// Forces film clip to use the "multitrack" (stacking) layout logic
CDmaVar< bool > m_bForceMultiTrack;
int m_nMaxTrackCount;
};
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
inline int CDmeTrackGroup::GetTrackCount( ) const
{
return m_Tracks.Count();
}
inline CDmeTrack *CDmeTrackGroup::GetTrack( int nIndex ) const
{
return m_Tracks[nIndex];
}
inline const CUtlVector< DmElementHandle_t > &CDmeTrackGroup::GetTracks( ) const
{
return m_Tracks.Get();
}
//-----------------------------------------------------------------------------
// Is this track group visible?
//-----------------------------------------------------------------------------
inline void CDmeTrackGroup::SetVisible( bool bVisible )
{
m_bIsVisible = bVisible;
}
inline bool CDmeTrackGroup::IsVisible() const
{
return m_bIsVisible;
}
//-----------------------------------------------------------------------------
// Is this track group minimized?
//-----------------------------------------------------------------------------
inline void CDmeTrackGroup::SetMinimized( bool bMinimized )
{
m_bMinimized = bMinimized;
}
inline bool CDmeTrackGroup::IsMinimized() const
{
return m_bMinimized;
}
//-----------------------------------------------------------------------------
// Track group vertical display scale
//-----------------------------------------------------------------------------
inline void CDmeTrackGroup::SetDisplayScale( float flDisplayScale )
{
m_flDisplayScale = flDisplayScale;
}
inline float CDmeTrackGroup::GetDisplayScale() const
{
return m_flDisplayScale;
}
//-----------------------------------------------------------------------------
// Iterator macro
//-----------------------------------------------------------------------------
#define DMETRACKGROUP_FOREACH_CLIP_START( _dmeTrackGroup, _dmeTrack, _dmeClip ) \
{ \
int _tc = (_dmeTrackGroup)->GetTrackCount(); \
for ( int _i = 0; _i < _tc; ++_i ) \
{ \
CDmeTrack *_dmeTrack = (_dmeTrackGroup)->GetTrack( _i ); \
if ( !_dmeTrack ) \
continue; \
\
int _cc = _dmeTrack->GetClipCount(); \
for ( int _j = 0; _j < _cc; ++_j ) \
{ \
CDmeClip *_dmeClip = _dmeTrack->GetClip( _j ); \
if ( !_dmeClip ) \
continue;
#define DMETRACKGROUP_FOREACH_CLIP_END( ) \
} \
} \
}
#define DMETRACKGROUP_FOREACH_CLIP_TYPE_START( _clipType, _dmeTrackGroup, _dmeTrack, _dmeClip ) \
{ \
int _tc = (_dmeTrackGroup)->GetTrackCount(); \
for ( int _i = 0; _i < _tc; ++_i ) \
{ \
CDmeTrack *_dmeTrack = (_dmeTrackGroup)->GetTrack( _i ); \
if ( !_dmeTrack ) \
continue; \
\
if ( _dmeTrack->GetClipType() != CDmeClipInfo< _clipType >::ClipType() ) \
continue; \
\
int _cc = _dmeTrack->GetClipCount(); \
for ( int _j = 0; _j < _cc; ++_j ) \
{ \
_clipType *_dmeClip = static_cast< _clipType* >( _dmeTrack->GetClip( _j ) ); \
if ( !_dmeClip ) \
continue;
#define DMETRACKGROUP_FOREACH_CLIP_TYPE_END( ) \
} \
} \
}
//-----------------------------------------------------------------------------
// helper methods
//-----------------------------------------------------------------------------
CDmeFilmClip *GetParentClip( CDmeTrackGroup *pTrackGroup );
#endif // DMETRACKGROUP_H

View File

@@ -0,0 +1,54 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class representing a transform
//
//=============================================================================
#ifndef DMETRANSFORM_H
#define DMETRANSFORM_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
static const char TRANSFORM_POSITION[] = "position";
static const char TRANSFORM_ORIENTATION[] = "orientation";
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
struct matrix3x4_t;
class CDmeDag;
//-----------------------------------------------------------------------------
// A class representing a transformation matrix
//-----------------------------------------------------------------------------
class CDmeTransform : public CDmElement
{
DEFINE_ELEMENT( CDmeTransform, CDmElement );
public:
virtual void OnAttributeChanged( CDmAttribute *pAttribute );
void SetTransform( const matrix3x4_t &transform );
void GetTransform( matrix3x4_t &transform );
const Vector &GetPosition() const;
void SetPosition( const Vector &vecPosition );
const Quaternion &GetOrientation() const;
void SetOrientation( const Quaternion &orientation );
CDmAttribute *GetPositionAttribute();
CDmAttribute *GetOrientationAttribute();
// If transform is contained inside some kind of CDmeDag, return that (it's "parent")
CDmeDag *GetDag();
private:
CDmaVar<Vector> m_Position;
CDmaVar<Quaternion> m_Orientation;
};
#endif // DMETRANSFORM_H

View File

@@ -0,0 +1,159 @@
//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =======
//
// Declaration of the CDmeTransform control class, a helper for modifying a
// transform.
//
//=============================================================================
#ifndef DMETRANSFORMCONTROL_H
#define DMETRANSFORMCONTROL_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmehandle.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeChannel;
class CDmeTransform;
class CDmeDag;
//-----------------------------------------------------------------------------
// The CDmeTransformControl class is a helper for modifying a transform, it is
// attached to a control CDmElement which has the transform bool set to true.
// It stores information about how the a transform is to be modified, such as
// the relative pivot offset, manipulation transform, and rotation delta
// information. The CDmeTransformControl class may be
//-----------------------------------------------------------------------------
class CDmeTransformControl : public CDmElement
{
DEFINE_ELEMENT( CDmeTransformControl, CDmElement );
public:
// Get the manipulation transform matrix
void GetManipulationTransform( matrix3x4_t &transform ) const;
// Set the manipulation transform matrix
void SetManipulationTransform( const matrix3x4_t &transform );
// Get the manipulation rotation amount in the local space of the transform
void GetManipulationRotationLocal( Quaternion &rotation ) const;
// Set the manipulation rotation amount in the local space of the transform
void SetManipulationRotationLocal( const Quaternion &rotation );
// Get the manipulation rotation amount in the parent space of the transform
void GetManipulationRotationParent( Quaternion &rotation ) const;
// Set the manipulation rotation amount in the parent space of the transform
void SetManipulationRotationParent( const Quaternion &rotation );
// Get the manipulation pivot position, this may differ from the pivot offset
void GetManipulationPivot( Vector &pivotPosition ) const;
// Set the manipulation pivot position
void SetManipulationPivot( const Vector &pivotPosition );
// Get the current local space pivot offset
const Vector &GetPivotOffset() const;
// Set the current local space pivot offset
void SetPivotOffset( const Vector &localOffset );
// Get the transform associated with the transform control
CDmeTransform *GetTransform() const;
// Get the dag node associated with the transform control
CDmeDag *GetDag() const;
// Get the position attribute of the control
CDmAttribute *GetPositionAttr();
// Get the orientation attribute of the control
CDmAttribute *GetOrientationAttr();
// Get the position value of the control
const Vector &GetPosition() const;
// Get the orientation value of the control
const Quaternion &GetOrientation() const;
// Determine if the control currently has a default position set
bool HasDefaultPosition() const;
// Determine if the control currently has a default orientation set
bool HasDefaultOrientation() const;
// Get the default position of the control
const Vector &GetDefaultPosition() const;
// Get the default orientation of the control
const Quaternion &GetDefaultOrientation() const;
// Get the default position attribute
const CDmAttribute *GetDefaultPositionAttr() const;
// Get the default position attribute
const CDmAttribute *GetDefaultOrientationAttr() const;
// Get the position channel targeting the control
CDmeChannel *GetPositionChannel() const;
// Get the orientation channel targeting the control
CDmeChannel *GetOrientationChannel() const;
// Set the position value of the control
void SetPosition( const Vector &position );
// Set the orientation value of the control
void SetOrientation( const Quaternion &orientation );
// Set the default position of the control
void SetDefaultPosition( const Vector &position );
// Set the default orientation of the control
void SetDefaultOrientation( const Quaternion &orientation );
// Set the position channel that is targeting the control
void SetPositionChannel( CDmeChannel *pChannel );
// Get the orientation channel that is targeting the control
void SetOrientationChannel( CDmeChannel *pChannel );
private:
// Allocate and initialize the manipulation parameters
bool InitManipulationParams();
struct ManipulationParams_t
{
matrix3x4_t Transform; // Transform used to apply the manipulation
Quaternion RotationLocal; // Rotation applied in manipulation ( Local space )
Quaternion RotationParent; // Rotation applied in manipulation ( Parent space )
Vector Pivot; // Pivot used in manipulation
};
Vector m_PivotOffset; // Current pivot offset to be used when manipulating the transform
ManipulationParams_t *m_pManipulationParams; // Parameters describing the last manipulation performed on the transform
CDmaVar< Vector > m_PositionValue; // "valuePosition": current position value of the control
CDmaVar< Quaternion > m_OrientationValue; // "valueOrientation": current orientation value of the control
CDmaElement< CDmeChannel > m_PositionChannel; // "positionChannel": channel which connects the position value to the transform
CDmaElement< CDmeChannel > m_OrientationChannel; // "orientationChannel": channel which connects the orientation value to the transform
};
#endif // DMETRANSFORMCONTROL_H

View File

@@ -0,0 +1,59 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// various transform-related inputs - translation, rotation, etc.
//
//=============================================================================
#ifndef DMETRANSFORMINPUT_H
#define DMETRANSFORMINPUT_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmeinput.h"
//-----------------------------------------------------------------------------
// translation input
//-----------------------------------------------------------------------------
class CDmeTranslationInput : public CDmeInput
{
DEFINE_ELEMENT( CDmeTranslationInput, CDmeInput );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< Vector > m_translation;
};
//-----------------------------------------------------------------------------
// rotation input
//-----------------------------------------------------------------------------
class CDmeRotationInput : public CDmeInput
{
DEFINE_ELEMENT( CDmeRotationInput, CDmeInput );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
// these should only be used by the application - not other dme's!
void SetRotation( const Quaternion& quat );
void SetRotation( const QAngle& qangle );
protected:
CDmaVar< Quaternion > m_orientation;
CDmaVar< QAngle > m_angles;
};
#endif // DMETRANSFORMINPUT_H

View File

@@ -0,0 +1,47 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =====//
//
// Snapshot of
//
//===========================================================================//
#ifndef DMETRANSFORMLIST_H
#define DMETRANSFORMLIST_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmedag.h"
//-----------------------------------------------------------------------------
// A class representing a skeletal model
//-----------------------------------------------------------------------------
class CDmeTransformList : public CDmElement
{
DEFINE_ELEMENT( CDmeTransformList, CDmElement );
public:
int GetTransformCount() const;
CDmeTransform *GetTransform( int nIndex );
void SetTransform( int nIndex, const matrix3x4_t& mat );
CDmaElementArray<CDmeTransform> m_Transforms;
};
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
inline int CDmeTransformList::GetTransformCount() const
{
return m_Transforms.Count();
}
inline CDmeTransform *CDmeTransformList::GetTransform( int nIndex )
{
return m_Transforms[nIndex];
}
#endif // DMETRANSFORMLIST_H

View File

@@ -0,0 +1,53 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// The transform operator class - shortcut to setting transform values from floats
//
//=============================================================================
#ifndef DMETRANSFORMOPERATOR_H
#define DMETRANSFORMOPERATOR_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmeoperator.h"
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeTransform;
//-----------------------------------------------------------------------------
// A class representing a camera
//-----------------------------------------------------------------------------
class CDmeTransformOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmeTransformOperator, CDmeOperator );
public:
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
void SetTransform( CDmeTransform *pTransform );
const CDmeTransform *GetTransform() const;
protected:
CDmaElement< CDmeTransform > m_transform;
CDmaVar< float > m_positionX;
CDmaVar< float > m_positionY;
CDmaVar< float > m_positionZ;
CDmaVar< float > m_orientationX;
CDmaVar< float > m_orientationY;
CDmaVar< float > m_orientationZ;
CDmaVar< float > m_orientationW;
};
#endif // DMETRANSFORMOPERATOR_H

View File

@@ -0,0 +1,164 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// The morph operator class - sets morph target weights on meshes
//
//=============================================================================
#ifndef DMEUNPACKOPERATORS_H
#define DMEUNPACKOPERATORS_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmeoperator.h"
//-----------------------------------------------------------------------------
// CDmeUnpackColorOperator - extracts floats from a color
//-----------------------------------------------------------------------------
class CDmeUnpackColorOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmeUnpackColorOperator, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< Color > m_color;
CDmaVar< float> m_red;
CDmaVar< float> m_green;
CDmaVar< float> m_blue;
CDmaVar< float> m_alpha;
};
//-----------------------------------------------------------------------------
// CDmeUnpackVector2Operator - extracts floats from a vector2
//-----------------------------------------------------------------------------
class CDmeUnpackVector2Operator : public CDmeOperator
{
DEFINE_ELEMENT( CDmeUnpackVector2Operator, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< Vector2D > m_vector;
CDmaVar< float> m_x;
CDmaVar< float> m_y;
};
//-----------------------------------------------------------------------------
// CDmeUnpackVector3Operator - extracts floats from a vector
//-----------------------------------------------------------------------------
class CDmeUnpackVector3Operator : public CDmeOperator
{
DEFINE_ELEMENT( CDmeUnpackVector3Operator, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< Vector > m_vector;
CDmaVar< float> m_x;
CDmaVar< float> m_y;
CDmaVar< float> m_z;
};
//-----------------------------------------------------------------------------
// CDmeUnpackVector4Operator - extracts floats from a vector4
//-----------------------------------------------------------------------------
class CDmeUnpackVector4Operator : public CDmeOperator
{
DEFINE_ELEMENT( CDmeUnpackVector4Operator, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< Vector4D > m_vector;
CDmaVar< float> m_x;
CDmaVar< float> m_y;
CDmaVar< float> m_z;
CDmaVar< float> m_w;
};
//-----------------------------------------------------------------------------
// CDmeUnpackQAngleOperator - extracts floats from a qangle
//-----------------------------------------------------------------------------
class CDmeUnpackQAngleOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmeUnpackQAngleOperator, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< QAngle > m_qangle;
CDmaVar< float> m_x;
CDmaVar< float> m_y;
CDmaVar< float> m_z;
};
//-----------------------------------------------------------------------------
// CDmeUnpackQuaternionOperator - extracts floats from a quaternion
//-----------------------------------------------------------------------------
class CDmeUnpackQuaternionOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmeUnpackQuaternionOperator, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< Quaternion > m_quaternion;
CDmaVar< float> m_x;
CDmaVar< float> m_y;
CDmaVar< float> m_z;
CDmaVar< float> m_w;
};
//-----------------------------------------------------------------------------
// CDmeUnpackVMatrixOperator - extracts floats from a VMatrix
//-----------------------------------------------------------------------------
class CDmeUnpackVMatrixOperator : public CDmeOperator
{
DEFINE_ELEMENT( CDmeUnpackVMatrixOperator, CDmeOperator );
public:
virtual bool IsDirty(); // ie needs to operate
virtual void Operate();
virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
protected:
CDmaVar< VMatrix > m_vmatrix;
CDmaVar< float > m_cells[ 16 ];
};
#endif // DMEUNPACKOPERATORS_H

View File

@@ -0,0 +1,114 @@
//============ Copyright (c) Valve Corporation, All rights reserved. ============
#ifndef DMEUSERSETTINGS_H
#define DMEUSERSETTINGS_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "idmeusersettingschangedlistener.h"
//-----------------------------------------------------------------------------
class CDmeUserSettings : public CDmElement
{
DEFINE_ELEMENT( CDmeUserSettings, CDmElement );
public:
static CDmeUserSettings *SharedUserSettings();
template< class T> static void InitSettingsValue( const char *pRegistryPath, const T& value);
template< class T> static void SetSettingsValue( const char *pRegistryPath, const T& value);
template< class T > static const T& GetSettingsValue( const char *pRegistryPath, const T& defaultValue );
virtual CDmeUserSettings *GetUserSettingsForRegistryPath( const char *pRegistryPath );
virtual void OnAttributeChanged( CDmAttribute *pAttribute );
virtual void AddUserSettingsChangedListener( IDmeUserSettingsChangedListener *pListener );
protected:
private:
CDmAttribute *FindAttributeForRegistryPath( const char *pRegistryPath );
const char *FindRegistryPathForAttribute( CDmAttribute *pAttribute );
bool RegistryPathHasValue( const char *pRegistryPath );
void SetAttributeFromRegistry( CDmAttribute *pAttribute, const char *pRegistryPath );
void SetRegistryFromAttribute( CDmAttribute *pAttribute, const char *pRegistryPath );
void GetAttributeNameFromRegistryPath( const char *pRegistryPath, char *pAttributeName, int nAttributeNameLength );
void SetAttributeForRegistryPathInDatabase( CDmAttribute *pAttribute, const char *pRegistryPath );
void CreateRegistryEntryAndValueKey( const char *pRegistryPath, char *pEntryKey, int nEntryKeyLength, char *pValueKey, int nValueKeyLength );
bool GetRegistryString(const char *pRegistryPath, char *pStringValue, int nStringValueLen);
bool SetRegistryString(const char *pRegistryPath, const char *pStringValue);
static CUtlVector< IDmeUserSettingsChangedListener * > s_UserSettingsChangedListeners;
};
//-----------------------------------------------------------------------------
template< class T >
void CDmeUserSettings::InitSettingsValue( const char *pRegistryPath, const T& value )
{
CDmAttribute *pAttribute = SharedUserSettings()->FindAttributeForRegistryPath( pRegistryPath );
if( pAttribute )
{
SharedUserSettings()->SetAttributeFromRegistry( pAttribute, pRegistryPath );
}
else
{
CDmElement *pUserSettingGroup = SharedUserSettings()->GetUserSettingsForRegistryPath( pRegistryPath );
char pAttributeName[255];
SharedUserSettings()->GetAttributeNameFromRegistryPath( pRegistryPath, pAttributeName, 255);
if( pUserSettingGroup )
{
pAttribute = pUserSettingGroup->InitValue( pAttributeName, value );
if( pAttribute )
{
pAttribute->AddFlag( FATTRIB_HAS_CALLBACK );
SharedUserSettings()->SetAttributeForRegistryPathInDatabase( pAttribute, pRegistryPath );
if( SharedUserSettings()->RegistryPathHasValue( pRegistryPath ) )
{
SharedUserSettings()->SetAttributeFromRegistry( pAttribute, pRegistryPath );
}
else
{
SharedUserSettings()->SetRegistryFromAttribute( pAttribute, pRegistryPath );
}
}
}
}
}
template< class T >
void CDmeUserSettings::SetSettingsValue( const char *pRegistryPath, const T& value )
{
CDmAttribute *pAttribute = SharedUserSettings()->FindAttributeForRegistryPath( pRegistryPath );
if( pAttribute )
{
pAttribute->SetValue( value );
}
else
{
InitSettingsValue( pRegistryPath, value );
}
}
template< class T >
const T& CDmeUserSettings::GetSettingsValue( const char *pRegistryPath, const T& defaultValue )
{
CDmAttribute *pAttribute = SharedUserSettings()->FindAttributeForRegistryPath( pRegistryPath );
if( pAttribute )
{
return pAttribute->GetValue< T >( defaultValue );
}
else
{
return defaultValue;
}
}
#endif // DMEUSERSETTINGS_H

View File

@@ -0,0 +1,348 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class representing vertex data
//
//=============================================================================
#ifndef DMEVERTEXDATA_H
#define DMEVERTEXDATA_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
#include "datamodel/dmattribute.h"
#include "datamodel/dmattributevar.h"
#include "mathlib/vector.h"
#include "Color.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class Vector;
class Vector4D;
class Color;
//-----------------------------------------------------------------------------
// Used to represent fields
//-----------------------------------------------------------------------------
typedef int FieldIndex_t;
class CDmeVertexDataBase : public CDmElement
{
DEFINE_ELEMENT( CDmeVertexDataBase, CDmElement );
public:
// NOTE: If you add fields to this, add to g_pStandardFieldNames in dmevertexdata.cpp
enum StandardFields_t
{
FIELD_POSITION,
FIELD_NORMAL,
FIELD_TANGENT,
FIELD_TEXCOORD,
FIELD_COLOR,
FIELD_JOINT_WEIGHTS,
FIELD_JOINT_INDICES,
FIELD_BALANCE, // Used by left/right delta states
FIELD_MORPH_SPEED, // Used to author morph speeds
FIELD_WRINKLE, // Used to author morphed wrinklemaps
FIELD_WEIGHT, // Weight is just the different between the base position and the delta position
FIELD_CLOTH_ENABLE,
STANDARD_FIELD_COUNT,
};
// resolve internal data from changed attributes
virtual void Resolve();
// Returns the number of joints per vertex
int JointCount() const;
// Vertex accessors
int VertexCount() const;
const Vector& GetPosition( int nVertexIndex ) const;
const Vector& GetNormal( int nVertexIndex ) const;
const Vector2D& GetTexCoord( int nVertexIndex ) const;
const Vector4D& GetTangent( int nVertexIndex ) const;
const Color& GetColor( int nVertexIndex ) const;
const float *GetJointWeights( int nVertexIndex ) const;
const float *GetJointPositionWeights( int nPositionIndex ) const;
const int *GetJointIndices( int nVertexIndex ) const;
const int *GetJointPositionIndices( int nPositionIndex ) const;
float GetBalance( int nVertexIndex ) const;
float GetMorphSpeed( int nVertexIndex ) const;
float GetWrinkle( int nVertexIndex ) const;
float GetWeight( int nVertexIndex ) const;
// Returns indices into the various fields
int GetPositionIndex( int nVertexIndex ) const;
int GetNormalIndex( int nVertexIndex ) const;
int GetTangentIndex( int nVertexIndex ) const;
int GetTexCoordIndex( int nVertexIndex ) const;
int GetColorIndex( int nVertexIndex ) const;
int GetBalanceIndex( int nVertexIndex ) const;
int GetMorphSpeedIndex( int nVertexIndex ) const;
int GetWrinkleIndex( int nVertexIndex ) const;
int GetWeightIndex( int nVertexIndex ) const;
// Creates a new vertex field. NOTE: This cannot be used to create joint weights + indices
template< class T >
FieldIndex_t CreateField( const char *pFieldName );
FieldIndex_t CreateField( const char *pFieldName, DmAttributeType_t type );
FieldIndex_t CreateField( StandardFields_t fieldId );
// Use this to create vertex fields for joint weights + indices
void CreateJointWeightsAndIndices( int nJointCount, FieldIndex_t *pJointWeightsField, FieldIndex_t *pJointIndicesField );
// Returns the field index of a particular field
FieldIndex_t FindFieldIndex( const char *pFieldName ) const;
FieldIndex_t FindFieldIndex( StandardFields_t nFieldIndex ) const;
// Adds a new vertex, returns the vertex index
// NOTE: This will also add vertex indices for DmeMeshDeltaData
int AddVertexData( FieldIndex_t nFieldIndex, int nCount );
// Sets vertex data
void SetVertexData( FieldIndex_t nFieldIndex, int nFirstVertex, int nCount, DmAttributeType_t valueType, const void *pData );
void SetVertexIndices( FieldIndex_t nFieldIndex, int nFirstIndex, int nCount, const int *pIndices );
// Removes all vertex data associated with a particular field
void RemoveAllVertexData( FieldIndex_t nFieldIndex );
// Returns arbitrary vertex + index data
CDmAttribute* GetVertexData( FieldIndex_t nFieldIndex );
const CDmAttribute* GetVertexData( FieldIndex_t nFieldIndex ) const;
CDmAttribute* GetIndexData( FieldIndex_t nFieldIndex );
const CDmAttribute* GetIndexData( FieldIndex_t nFieldIndex ) const;
// Returns well-known vertex data
const CUtlVector<Vector> &GetPositionData( ) const;
const CUtlVector<Vector> &GetNormalData( ) const;
const CUtlVector<Vector4D> &GetTangentData( ) const;
const CUtlVector<Vector2D> &GetTextureCoordData( ) const;
const CUtlVector<Color> &GetColorData( ) const;
const float *GetJointWeightData( int nDataIndex ) const;
const int *GetJointIndexData( int nDataIndex ) const;
const CUtlVector<float> &GetBalanceData( ) const;
const CUtlVector<float> &GetMorphSpeedData( ) const;
const CUtlVector<float> &GetWrinkleData( ) const;
const CUtlVector<float> &GetWeightData( ) const;
// Returns well-known index data
const CUtlVector<int> &GetVertexIndexData( FieldIndex_t nFieldIndex ) const;
const CUtlVector<int> &GetVertexIndexData( StandardFields_t fieldId ) const;
// Do we have skinning data?
bool HasSkinningData() const;
// Do we have cloth_enable data?
bool HasClothData();
// Do we need tangent data? (Utility method for applications to know if they should call ComputeDefaultTangentData)
bool NeedsTangentData() const;
// Should we flip the V coordinates?
bool IsVCoordinateFlipped() const;
void FlipVCoordinate( bool bFlip );
// Returns an inverse map from vertex data index to vertex index
const CUtlVector< int > &FindVertexIndicesFromDataIndex( FieldIndex_t nFieldIndex, int nDataIndex );
const CUtlVector< int > &FindVertexIndicesFromDataIndex( StandardFields_t nFieldIndex, int nDataIndex );
int FieldCount() const;
const char *FieldName( int i ) const;
void CopyFrom( CDmeVertexDataBase *pSrc );
void CopyTo( CDmeVertexDataBase *pDst ) const;
// Reskins the vertex data to new bones
// The joint index remap maps an initial bone index to a new bone index
void Reskin( const int *pJointTransformIndexRemap );
protected:
struct FieldInfo_t
{
CUtlString m_Name;
CDmAttribute *m_pVertexData;
CDmAttribute* m_pIndexData;
CUtlVector< CUtlVector< int > > m_InverseMap;
bool m_bInverseMapDirty;
};
// Derived classes must inherit
virtual bool IsVertexDeltaData() const { Assert(0); return false; }
// Computes the vertex count ( min of the index buffers )
void ComputeFieldInfo();
// Computes the vertex count ( min of the index buffers )
void ComputeVertexCount();
// Updates info for fast lookups for well-known fields
void UpdateStandardFieldInfo( int nFieldIndex, const char *pFieldName, DmAttributeType_t attrType );
// Adds a field to the vertex format
void FindOrAddVertexField( const char *pFieldName );
// Returns the index of a particular field
int GetFieldIndex( int nVertexIndex, StandardFields_t nFieldIndex ) const;
// List of names of attributes containing vertex data
CDmaStringArray m_VertexFormat;
CDmaVar< int > m_nJointCount;
CDmaVar< bool > m_bFlipVCoordinates;
CUtlVector< FieldInfo_t > m_FieldInfo;
FieldIndex_t m_pStandardFieldIndex[STANDARD_FIELD_COUNT];
int m_nVertexCount;
};
//-----------------------------------------------------------------------------
// Creates a particular vertex data field + associated index field
//-----------------------------------------------------------------------------
template< class T >
inline FieldIndex_t CDmeVertexDataBase::CreateField( const char *pFieldName )
{
return CreateField( pFieldName, CDmAttributeInfo< CUtlVector<T> >::AttributeType() );
}
//-----------------------------------------------------------------------------
// Returns a standard field index
//-----------------------------------------------------------------------------
inline FieldIndex_t CDmeVertexDataBase::FindFieldIndex( StandardFields_t nFieldIndex ) const
{
return m_pStandardFieldIndex[ nFieldIndex ];
}
//-----------------------------------------------------------------------------
// Vertex field accessors
//-----------------------------------------------------------------------------
inline int CDmeVertexDataBase::VertexCount() const
{
return m_nVertexCount;
}
//-----------------------------------------------------------------------------
// Returns the number of joints per vertex
//-----------------------------------------------------------------------------
inline int CDmeVertexDataBase::JointCount() const
{
return m_nJointCount;
}
//-----------------------------------------------------------------------------
// Should we flip the V coordinates?
//-----------------------------------------------------------------------------
inline bool CDmeVertexDataBase::IsVCoordinateFlipped() const
{
return m_bFlipVCoordinates;
}
inline void CDmeVertexDataBase::FlipVCoordinate( bool bFlip )
{
m_bFlipVCoordinates = bFlip;
}
//-----------------------------------------------------------------------------
// Returns arbitrary vertex data
//-----------------------------------------------------------------------------
inline CDmAttribute* CDmeVertexDataBase::GetVertexData( FieldIndex_t nFieldIndex )
{
return m_FieldInfo[ nFieldIndex ].m_pVertexData;
}
inline const CDmAttribute* CDmeVertexDataBase::GetVertexData( FieldIndex_t nFieldIndex ) const
{
return m_FieldInfo[ nFieldIndex ].m_pVertexData;
}
//-----------------------------------------------------------------------------
// Returns arbitrary index data
//-----------------------------------------------------------------------------
inline CDmAttribute* CDmeVertexDataBase::GetIndexData( FieldIndex_t nFieldIndex )
{
return m_FieldInfo[ nFieldIndex ].m_pIndexData;
}
inline const CDmAttribute* CDmeVertexDataBase::GetIndexData( FieldIndex_t nFieldIndex ) const
{
return m_FieldInfo[ nFieldIndex ].m_pIndexData;
}
//-----------------------------------------------------------------------------
// Utility method for getting at various vertex field indices
//-----------------------------------------------------------------------------
inline int CDmeVertexDataBase::GetFieldIndex( int nVertexIndex, StandardFields_t nFieldId ) const
{
Assert( nVertexIndex < m_nVertexCount );
FieldIndex_t nFieldIndex = m_pStandardFieldIndex[nFieldId];
if ( nFieldIndex < 0 )
return -1;
CDmrArrayConst<int> indices( GetIndexData( nFieldIndex ) );
return indices[ nVertexIndex ];
}
//-----------------------------------------------------------------------------
//
// Vertex Data for base states
//
//-----------------------------------------------------------------------------
class CDmeVertexData : public CDmeVertexDataBase
{
DEFINE_ELEMENT( CDmeVertexData, CDmeVertexDataBase );
public:
// Adds a new vertex; creates a new entry in all vertex data fields
int AddVertexIndices( int nCount );
private:
virtual bool IsVertexDeltaData() const { return false; }
};
//-----------------------------------------------------------------------------
//
// Vertex Data for delta states
//
//-----------------------------------------------------------------------------
class CDmeVertexDeltaData : public CDmeVertexDataBase
{
DEFINE_ELEMENT( CDmeVertexDeltaData, CDmeVertexDataBase );
public:
// Computes wrinkle data from position deltas
// NOTE: Pass in negative scales to get 'compression', positive to get 'expansion'
void GenerateWrinkleDelta( CDmeVertexData *pBindState, float flScale, bool bOverwrite, bool bUseNormalForSign = false );
// Updates existing data or generates new data
void UpdateWrinkleDelta( CDmeVertexData *pBindState, float flOldScale, float flNewScale );
// Computes a float map which is the distance between the base and delta position
// The maximum distance any vertex is moved is returned
float GenerateWeightDelta( CDmeVertexData *pBindState );
CDmaVar< bool > m_bCorrected;
CDmaVar< bool > m_bRenderVerts;
private:
virtual bool IsVertexDeltaData() const { return true; }
// Computes max positional delta length
float ComputeMaxDeflection( );
};
#endif // DMEVERTEXDATA_H

View File

@@ -0,0 +1,126 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// A class for computing things with CDmeMesh data
//
//=============================================================================
#ifndef DMMESHCOMP_H
#define DMMESHCOMP_H
#ifdef _WIN32
#pragma once
#endif
// Valve includes
#include "mathlib/mathlib.h"
#include "tier1/utlvector.h"
#include "tier1/utllinkedlist.h"
// Forward declarations
class CDmeMesh;
class CDmeVertexData;
//=============================================================================
// TODO: This works in the local space of the mesh... add option to transform
// the positions into world space
//=============================================================================
class CDmMeshComp
{
public:
CDmMeshComp( CDmeMesh *pMesh, CDmeVertexData *pPassedBase = NULL );
~CDmMeshComp();
class CVert;
class CEdge;
class CVert
{
public:
CVert( int nPositionIndex, const CUtlVector< int > *pVertexIndices, const Vector *pPosition );
CVert( const CVert &src );
int PositionIndex() const;
const Vector *Position() const;
const CUtlVector< int > *VertexIndices() const;
bool operator==( const CVert &rhs ) const;
protected:
friend class CDmMeshComp;
int m_positionIndex; // Index in the position data
const CUtlVector< int > *m_pVertexIndices; // Pointer to a list of the vertex indices for this vertex
const Vector *m_pPosition;
CUtlVector< CEdge * > m_edges; // An array of pointers to the edges containing this vertex
private:
CVert(); // Not used
};
class CEdge
{
public:
CEdge();
int GetVertPositionIndex( int edgeRelativeVertexIndex ) const;
CVert *GetVert( int edgeRelativeVertexIndex ) const;
bool IsBorderEdge() const { return m_faceCount == 1; }
bool ConnectedTo( const CEdge *pEdge ) const { return m_pVert0 == pEdge->m_pVert0 || m_pVert0 == pEdge->m_pVert1 || m_pVert1 == pEdge->m_pVert0 || m_pVert1 == pEdge->m_pVert1; }
Vector EdgeVector() const;
// Returns true if the edge starts and stops at the same point in local space
bool operator==( const CEdge &rhs ) const;
protected:
friend class CDmMeshComp;
CVert *m_pVert0;
CVert *m_pVert1;
int m_faceCount;
};
class CFace
{
public:
protected:
friend class CDmMeshComp;
CUtlVector< CVert * > m_verts;
CUtlVector< CEdge * > m_edges;
CUtlVector< bool > m_edgeReverseMap;
};
CDmeVertexData *BaseState() { return m_pBase; }
CEdge *FindOrCreateEdge( int vIndex0, int vIndex1, bool *pReverse = NULL );
CEdge *FindEdge( int vIndex0, int vIndex1, bool *pReverse = NULL );
CFace *CreateFace( const CUtlVector< CVert * > &verts, const CUtlVector< CEdge * > &edges, const CUtlVector< bool > &edgeReverseMap );
int FindFacesWithVert( int vIndex, CUtlVector< CFace * > &faces );
int FindNeighbouringVerts( int vIndex, CUtlVector< CVert * > &verts );
int GetBorderEdges( CUtlVector< CUtlVector< CEdge * > > &borderEdges );
CDmeMesh *m_pMesh;
CDmeVertexData *m_pBase;
CUtlVector< CVert * > m_verts;
CUtlVector< CEdge * > m_edges;
CUtlFixedLinkedList< CFace > m_faces;
};
#endif // DMEMESHCOMP_H

View File

@@ -0,0 +1,114 @@
//======= Copyright © 1996-2006, Valve Corporation, All rights reserved. ======
//
// Serialize and Unserialize Wavefront OBJ <-> DME Data
//
//=============================================================================
#ifndef DMOBJSERIALIZER_H
#define DMOBJSERIALIZER_H
#if defined( _WIN32 )
#pragma once
#endif
#include "datamodel/idatamodel.h"
#include "tier1/utlbuffer.h"
#include "tier1/utlstring.h"
#include "tier1/utlvector.h"
#include "tier1/UtlStringMap.h"
class CDmeMesh;
class CDmeDag;
class CDmeVertexDeltaData;
class CDmeCombinationOperator;
//-----------------------------------------------------------------------------
// Serialization class for OBJ files
//-----------------------------------------------------------------------------
class CDmObjSerializer : public IDmSerializer
{
public:
// Inherited from IDMSerializer
virtual const char *GetName() const { return "obj"; }
virtual const char *GetDescription() const { return "Wavefront OBJ"; }
virtual bool IsBinaryFormat() const { return false; }
virtual bool StoresVersionInFile() const { return false; }
virtual int GetCurrentVersion() const { return 0; } // doesn't store a version
virtual bool Serialize( CUtlBuffer &buf, CDmElement *pRoot );
virtual bool Unserialize( CUtlBuffer &buf, const char *pEncodingName, int nEncodingVersion,
const char *pSourceFormatName, int nSourceFormatVersion,
DmFileId_t fileid, DmConflictResolution_t idConflictResolution, CDmElement **ppRoot );
virtual const char *GetImportedFormat() const { return NULL; }
virtual int GetImportedVersion() const { return 1; }
CDmElement *ReadOBJ( const char *pFilename, CDmeMesh **ppCreatedMesh = NULL, bool bLoadAllDeltas = true, bool bAbsolute = true );
bool WriteOBJ( const char *pFilename, CDmElement *pRoot, bool bWriteDeltas, const char *pDeltaName = NULL, bool absolute = true );
void MeshToObj( CUtlBuffer &b, const matrix3x4_t &parentWorldMatrix, CDmeMesh *pMesh, const char *pDeltaName = NULL, bool absolute = true );
CDmeVertexDeltaData *GetDelta( const char *pDeltaName, bool bAbsolute );
private:
CDmElement *ReadOBJ(
CUtlBuffer &buf,
DmFileId_t dmFileId,
const char *pName,
const char *pFilename = NULL,
CDmeMesh *pBaseMesh = NULL,
CDmeMesh **ppCreatedMesh = NULL,
bool bAbsolute = true );
static int OutputVectors( CUtlBuffer &b, const char *pPrefix, const CUtlVector< Vector > &vData, const matrix3x4_t &matrix );
static int OutputVectors( CUtlBuffer &b, const char *pPrefix, const CUtlVector< Vector2D > &vData );
static void DeltaToObj( CUtlBuffer &b, const matrix3x4_t &parentWorldMatrix, CDmeMesh *pMesh, const char *pDeltaName = NULL );
void ParseMtlLib( CUtlBuffer &buf );
const char *FindMtlEntry( const char *pTgaName );
static bool ParseVertex( CUtlBuffer& bufParse, characterset_t &breakSet, int &v, int &t, int &n );
static const char *SkipSpace( const char *pBuf );
void DagToObj( CUtlBuffer &b, const matrix3x4_t &parentWorldMatrix, CDmeDag *pDag, const char *pDeltaName = NULL, bool absolute = true );
static void FindDeltaMeshes( CDmeDag *pDag, CUtlVector< CDmeMesh * > &meshes );
bool LoadDependentDeltas( const char *pDeltaName );
struct MtlInfo_t
{
CUtlString m_MtlName;
CUtlString m_TgaName;
};
CUtlVector< MtlInfo_t > m_mtlLib;
CUtlString m_objDirectory;
struct DeltaInfo_t
{
DeltaInfo_t()
: m_pComboOp( NULL )
, m_pMesh( NULL )
, m_pDeltaData( NULL )
{}
CUtlString m_filename;
CDmeMesh *m_pMesh;
CDmeCombinationOperator *m_pComboOp;
CDmeVertexDeltaData *m_pDeltaData;
};
CUtlStringMap< DeltaInfo_t > m_deltas;
int m_nPositionOffset;
int m_nTextureOffset;
int m_nNormalOffset;
};
#endif // DMOBJSERIALIZER_H

View File

@@ -0,0 +1,27 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef EXPORTFACIALANIMATION_H
#define EXPORTFACIALANIMATION_H
#ifdef _WIN32
#pragma once
#endif
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmeFilmClip;
class CDmeAnimationSet;
//-----------------------------------------------------------------------------
// Exports an .fac file
//-----------------------------------------------------------------------------
bool ExportFacialAnimation( const char *pFileName, CDmeFilmClip *pMovie, CDmeFilmClip *pShot, CDmeAnimationSet *pAnimationSet );
#endif // EXPORTFACIALANIMATION_H

View File

@@ -0,0 +1,69 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =====//
//
// Interface for makefiles to build differently depending on where they are run from
//
//===========================================================================//
#ifndef IDMEMAKEFILEUTILS_H
#define IDMEMAKEFILEUTILS_H
#ifdef _WIN32
#pragma once
#endif
#include "appframework/IAppSystem.h"
#include "vstdlib/iprocessutils.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
//-----------------------------------------------------------------------------
// Interface for makefiles to build differently depending on where they are run from
//-----------------------------------------------------------------------------
enum CompilationState_t
{
COMPILATION_SUCCESSFUL = 0,
COMPILATION_NOT_COMPLETE,
COMPILATION_FAILED,
};
abstract_class IDmeMakefileUtils : public IAppSystem
{
public:
// Methods related to compilation
virtual void PerformCompile( CDmElement *pElement, bool bBuildAllDependencies ) = 0;
// Are we in the middle of compiling something?
virtual bool IsCurrentlyCompiling( ) = 0;
// Returns the size of the buffer to pass into UpdateCompilation()
virtual int GetCompileOutputSize() = 0;
// Updates the compilation
virtual CompilationState_t UpdateCompilation( char *pOutputBuf, int nBufLen ) = 0;
// Aborts the compilation
virtual void AbortCurrentCompilation() = 0;
// Opens an external editor for this element
virtual void PerformOpenEditor( CDmElement *pElement ) = 0;
// Returns the exit code of the failed compilation (if COMPILATION_FAILED occurred)
virtual int GetExitCode() = 0;
// Somewhere in here, we need a method of populating choice lists
// for things like choosing vstInfoNodes to export for DCC makefiles
};
//-----------------------------------------------------------------------------
// Default implementation
//-----------------------------------------------------------------------------
IDmeMakefileUtils* GetDefaultDmeMakefileUtils();
#endif // IDMEMAKEFILEUTILS_H

View File

@@ -0,0 +1,25 @@
//============ Copyright (c) Valve Corporation, All rights reserved. ============
#ifndef DMEUSERSETTINGSCHANGEDLISTENER_H
#define DMEUSERSETTINGSCHANGEDLISTENER_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/KeyValues.h"
#define NameKey "name"
#define AttributeKey "attribute"
#define RegistryPathKey "registryPath"
//-----------------------------------------------------------------------------
class IDmeUserSettingsChangedListener
{
public:
virtual void OnUserSettingsChanged( KeyValues *message ) = 0;
};
#endif // DMEUSERSETTINGSCHANGEDLISTENER_H

View File

@@ -0,0 +1,81 @@
//====== Copyright (c) 1996-2004, Valve Corporation, All rights reserved. =======
//
// Purpose: See notes below
//
//=============================================================================
#include "movieobjects/movieobjects.h"
#include "movieobjects/movieobjects_compiletools.cpp"
#include "datamodel/dmelementfactoryhelper.h"
// YOU MUST INCLUDE THIS FILE INTO ANY PROJECT WHICH USES THE movieobjects.lib FILE
// This hack causes the class factories for the element types to be imported into the compiled code...
// Movie types
USING_ELEMENT_FACTORY( DmeCamera );
USING_ELEMENT_FACTORY( DmeSoundClip );
USING_ELEMENT_FACTORY( DmeFilmClip );
USING_ELEMENT_FACTORY( DmeMDL );
USING_ELEMENT_FACTORY( DmeMaterial );
USING_ELEMENT_FACTORY( DmeLight );
USING_ELEMENT_FACTORY( DmeGameModel );
USING_ELEMENT_FACTORY( DmeSound );
USING_ELEMENT_FACTORY( DmeGameSound );
USING_ELEMENT_FACTORY( DmeMorphOperator );
USING_ELEMENT_FACTORY( DmeTransformOperator );
USING_ELEMENT_FACTORY( DmeExpressionOperator );
USING_ELEMENT_FACTORY( DmeConnectionOperator );
USING_ELEMENT_FACTORY( DmeGamePortal );
USING_ELEMENT_FACTORY( DmeMouseInput );
USING_ELEMENT_FACTORY( DmeKeyboardInput );
USING_ELEMENT_FACTORY( DmeEditorAttributeInfo );
USING_ELEMENT_FACTORY( DmeEditorChoicesInfo );
USING_ELEMENT_FACTORY( DmeEditorType );
USING_ELEMENT_FACTORY( DmeEditorTypeDictionary );
USING_ELEMENT_FACTORY( DmePackColorOperator );
USING_ELEMENT_FACTORY( DmePackVector2Operator );
USING_ELEMENT_FACTORY( DmePackVector3Operator );
USING_ELEMENT_FACTORY( DmePackVector4Operator );
USING_ELEMENT_FACTORY( DmePackQAngleOperator );
USING_ELEMENT_FACTORY( DmePackQuaternionOperator );
USING_ELEMENT_FACTORY( DmePackVMatrixOperator );
USING_ELEMENT_FACTORY( DmeUnpackColorOperator );
USING_ELEMENT_FACTORY( DmeUnpackVector2Operator );
USING_ELEMENT_FACTORY( DmeUnpackVector3Operator );
USING_ELEMENT_FACTORY( DmeUnpackVector4Operator );
USING_ELEMENT_FACTORY( DmeUnpackQAngleOperator );
USING_ELEMENT_FACTORY( DmeUnpackQuaternionOperator );
USING_ELEMENT_FACTORY( DmeUnpackVMatrixOperator );
USING_ELEMENT_FACTORY( DmeAnimationSet );
USING_ELEMENT_FACTORY( DmePhonemeMapping );
USING_ELEMENT_FACTORY( DmeGlobalFlexControllerOperator );
USING_ELEMENT_FACTORY( DmeTransformControl );
USING_ELEMENT_FACTORY( DmeControlGroup );
USING_ELEMENT_FACTORY( DmeTimeSelection );
USING_ELEMENT_FACTORY( DmeConstraintTarget );
USING_ELEMENT_FACTORY( DmeConstraintSlave );
USING_ELEMENT_FACTORY( DmeRigPointConstraintOperator );
USING_ELEMENT_FACTORY( DmeRigOrientConstraintOperator );
USING_ELEMENT_FACTORY( DmeRigAimConstraintOperator );
USING_ELEMENT_FACTORY( DmeRigIKConstraintOperator );
USING_ELEMENT_FACTORY( DmeRigRotationConstraintOperator );
USING_ELEMENT_FACTORY( DmeRigHandle );
USING_ELEMENT_FACTORY( DmeRig );
USING_ELEMENT_FACTORY( DmeRigAnimSetElements );
USING_ELEMENT_FACTORY( DmeRigTwistSlave );
USING_ELEMENT_FACTORY( DmeRigTwistConstraintOperator );
USING_ELEMENT_FACTORY( DmeFlexRuleBase );
USING_ELEMENT_FACTORY( DmeFlexRulePassThrough );
USING_ELEMENT_FACTORY( DmeFlexRuleExpression );
USING_ELEMENT_FACTORY( DmeFlexRuleLocalVar );
USING_ELEMENT_FACTORY( DmeFlexRules );

View File

@@ -0,0 +1,68 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef MOVIEOBJECTS_H
#define MOVIEOBJECTS_H
#ifdef _WIN32
#pragma once
#endif
#include "movieobjects/dmeclip.h"
#include "movieobjects/dmetransform.h"
#include "movieobjects/dmeoverlay.h"
#include "movieobjects/dmetransformlist.h"
#include "movieobjects/dmedag.h"
#include "movieobjects/dmecamera.h"
#include "movieobjects/dmeshape.h"
#include "movieobjects/dmevertexdata.h"
#include "movieobjects/dmemesh.h"
#include "movieobjects/dmefaceset.h"
#include "movieobjects/dmematerial.h"
#include "movieobjects/dmetimeframe.h"
#include "movieobjects/dmelight.h"
#include "movieobjects/dmeoperator.h"
#include "movieobjects/dmegamemodel.h"
#include "movieobjects/dmemdl.h"
#include "movieobjects/dmesound.h"
#include "movieobjects/dmeanimationlist.h"
#include "movieobjects/dmeattachment.h"
#include "movieobjects/dmejoint.h"
#include "movieobjects/dmemorphoperator.h"
#include "movieobjects/dmecombinationoperator.h"
#include "movieobjects/dmetransformoperator.h"
#include "movieobjects/dmepackoperators.h"
#include "movieobjects/dmeunpackoperators.h"
#include "movieobjects/dmeexpressionoperator.h"
#include "movieobjects/dmeinput.h"
#include "movieobjects/dmekeyboardinput.h"
#include "movieobjects/dmemouseinput.h"
#include "movieobjects/dmechannel.h"
#include "movieobjects/dmelog.h"
#include "movieobjects/dmetrack.h"
#include "movieobjects/dmetrackgroup.h"
#include "movieobjects/dmeanimationset.h"
#include "movieobjects/dmemodel.h"
#include "movieobjects/dmemakefile.h"
#include "movieobjects/dmedccmakefile.h"
#include "movieobjects/dmemdlmakefile.h"
#include "movieobjects/dmeeditortypedictionary.h"
#include "movieobjects/dmephonememapping.h"
#include "movieobjects/dmetimeselection.h"
#include "movieobjects/dmeselection.h"
#include "movieobjects/dmedrawsettings.h"
#include "movieobjects/dmerig.h"
#include "movieobjects/dmerighandle.h"
#include "movieobjects/dmerigconstraintoperators.h"
#include "movieobjects/dmetransformcontrol.h"
#include "movieobjects/dmecontrolgroup.h"
#include "movieobjects/dmeconnectionoperator.h"
#include "movieobjects/dmeflexrules.h"
#define USING_ELEMENT_FACTORY( className ) \
extern C##className *g_##C##className##LinkerHack; \
C##className *g_##C##className##PullInModule = g_##C##className##LinkerHack;
#endif // MOVIEOBJECTS_H

View File

@@ -0,0 +1,92 @@
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
//
// Purpose: See notes below
//
//=============================================================================
#include "movieobjects/movieobjects.h"
#include "datamodel/dmelementfactoryhelper.h"
// YOU MUST INCLUDE THIS FILE INTO ANY PROJECT WHICH USES THE movieobjects.lib FILE
// This hack causes the class factories for the element types to be imported into the compiled code...
// Basic type (in datamodel)
USING_ELEMENT_FACTORY( DmElement );
// Movie types
USING_ELEMENT_FACTORY( DmeTransform );
USING_ELEMENT_FACTORY( DmeTransformList );
USING_ELEMENT_FACTORY( DmeVertexDataBase );
USING_ELEMENT_FACTORY( DmeVertexData );
USING_ELEMENT_FACTORY( DmeVertexDeltaData );
USING_ELEMENT_FACTORY( DmeShape );
USING_ELEMENT_FACTORY( DmeMesh );
USING_ELEMENT_FACTORY( DmeDag );
USING_ELEMENT_FACTORY( DmeFaceSet );
USING_ELEMENT_FACTORY( DmeModel );
USING_ELEMENT_FACTORY( DmeJoint );
USING_ELEMENT_FACTORY( DmeAttachment );
USING_ELEMENT_FACTORY( DmeMakefile );
USING_ELEMENT_FACTORY( DmeMDLMakefile );
USING_ELEMENT_FACTORY( DmeDCCMakefile );
USING_ELEMENT_FACTORY( DmeMayaAnimationMakefile );
USING_ELEMENT_FACTORY( DmeMayaCombinationOperator );
USING_ELEMENT_FACTORY( DmeMayaMakefile );
USING_ELEMENT_FACTORY( DmeMayaModelMakefile );
USING_ELEMENT_FACTORY( DmeXSIMakefile );
USING_ELEMENT_FACTORY( DmeSource );
USING_ELEMENT_FACTORY( DmeSourceDCCFile );
USING_ELEMENT_FACTORY( DmeSourceMayaFile );
USING_ELEMENT_FACTORY( DmeSourceMayaModelFile );
USING_ELEMENT_FACTORY( DmeSourceMayaAnimationFile );
USING_ELEMENT_FACTORY( DmeSourceXSIFile );
USING_ELEMENT_FACTORY( DmeAnimationList );
USING_ELEMENT_FACTORY( DmeClip );
USING_ELEMENT_FACTORY( DmeChannelsClip );
USING_ELEMENT_FACTORY( DmeChannel );
USING_ELEMENT_FACTORY( DmeTimeFrame );
USING_ELEMENT_FACTORY( DmeTrackGroup );
USING_ELEMENT_FACTORY( DmeTrack );
USING_ELEMENT_FACTORY( DmeCombinationDominationRule );
USING_ELEMENT_FACTORY( DmeCombinationInputControl );
USING_ELEMENT_FACTORY( DmeCombinationOperator );
USING_ELEMENT_FACTORY( DmeIntLog );
USING_ELEMENT_FACTORY( DmeFloatLog );
USING_ELEMENT_FACTORY( DmeBoolLog );
USING_ELEMENT_FACTORY( DmeColorLog );
USING_ELEMENT_FACTORY( DmeVector2Log );
USING_ELEMENT_FACTORY( DmeVector3Log );
USING_ELEMENT_FACTORY( DmeVector4Log );
USING_ELEMENT_FACTORY( DmeQAngleLog );
USING_ELEMENT_FACTORY( DmeQuaternionLog );
USING_ELEMENT_FACTORY( DmeVMatrixLog );
USING_ELEMENT_FACTORY( DmeIntLogLayer );
USING_ELEMENT_FACTORY( DmeFloatLogLayer );
USING_ELEMENT_FACTORY( DmeBoolLogLayer );
USING_ELEMENT_FACTORY( DmeColorLogLayer );
USING_ELEMENT_FACTORY( DmeVector2LogLayer );
USING_ELEMENT_FACTORY( DmeVector3LogLayer );
USING_ELEMENT_FACTORY( DmeVector4LogLayer );
USING_ELEMENT_FACTORY( DmeQAngleLogLayer );
USING_ELEMENT_FACTORY( DmeQuaternionLogLayer );
USING_ELEMENT_FACTORY( DmeVMatrixLogLayer );
USING_ELEMENT_FACTORY( DmeIntCurveInfo );
USING_ELEMENT_FACTORY( DmeFloatCurveInfo );
USING_ELEMENT_FACTORY( DmeBoolCurveInfo );
USING_ELEMENT_FACTORY( DmeColorCurveInfo );
USING_ELEMENT_FACTORY( DmeVector2CurveInfo );
USING_ELEMENT_FACTORY( DmeVector3CurveInfo );
USING_ELEMENT_FACTORY( DmeVector4CurveInfo );
USING_ELEMENT_FACTORY( DmeQAngleCurveInfo );
USING_ELEMENT_FACTORY( DmeQuaternionCurveInfo );
USING_ELEMENT_FACTORY( DmeVMatrixCurveInfo );
USING_ELEMENT_FACTORY( DmeComponent );
USING_ELEMENT_FACTORY( DmeSingleIndexedComponent );
USING_ELEMENT_FACTORY( DmeDrawSettings );

View File

@@ -0,0 +1,142 @@
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef PROCEDURALPRESETS_H
#define PROCEDURALPRESETS_H
#ifdef _WIN32
#pragma once
#endif
// IMPORTANT - only add preset enums to the END, and NEVER remove or replace any!!!
// (alternatively, fix up every dmx file with presets)
// The proper solution is to change CDmePreset::m_nProceduralType to be a bool m_bIsProceduralType
// and have a non-attribute int as a cached value inferred from the preset's name
enum
{
PROCEDURAL_PRESET_NOT = 0,
PROCEDURAL_PRESET_DEFAULT_CROSSFADE,
PROCEDURAL_PRESET_ZERO_CROSSFADE,
PROCEDURAL_PRESET_HALF_CROSSFADE,
PROCEDRUAL_PRESET_ONE_CROSSFADE,
PROCEDURAL_PRESET_HEAD_CROSSFADE,
PROCEDURAL_PRESET_IN_CROSSFADE,
PROCEDURAL_PRESET_OUT_CROSSFADE,
PROCEDURAL_PRESET_INOUT,
PROCEDURAL_PRESET_REVEAL,
PROCEDURAL_PRESET_PASTE,
PROCEDURAL_PRESET_DROP_LAYER, // Provides a blend value for finishing the current modification layer
PROCEDURAL_PRESET_JITTER,
PROCEDURAL_PRESET_SMOOTH,
PROCEDURAL_PRESET_SHARPEN,
PROCEDURAL_PRESET_SOFTEN,
PROCEDURAL_PRESET_STAGGER,
PROCEDURAL_PRESET_HOLD, // Pushes time samples in falloff toward the green selected region
PROCEDURAL_PRESET_RELEASE, // Pushes time samples in falloff toward the edges of the falloff
PROCEDURAL_PRESET_STEADY, // Smooths the "velocity" of samples in the time selection
PROCEDURAL_PRESET_SPLINE,
// Must be last
NUM_PROCEDURAL_PRESET_TYPES,
};
static const char *g_ProceduralPresetNames[ NUM_PROCEDURAL_PRESET_TYPES ] =
{
"NotProcedural!!!",
"Default",
"Zero",
"Half",
"One",
"Head",
"In",
"Out",
"Ramp",
"Reveal",
"Paste",
"Drop",
"Jitter",
"Smooth",
"Sharpen",
"Soften",
"Stagger",
"Hold",
"Release",
"Steady",
"Spline",
};
#define PROCEDURAL_PRESET_GROUP_NAME "Procedural"
inline char const *GetProceduralPresetName( int nPresetType )
{
if ( nPresetType < PROCEDURAL_PRESET_NOT || nPresetType >= NUM_PROCEDURAL_PRESET_TYPES )
return "???";
return g_ProceduralPresetNames[ nPresetType ];
}
inline int ProceduralTypeForPresetName( const char *pPresetName )
{
for ( int i = PROCEDURAL_PRESET_NOT; i < NUM_PROCEDURAL_PRESET_TYPES; ++i )
{
if ( !V_stricmp( pPresetName, g_ProceduralPresetNames[ i ] ) )
return i;
}
return -1;
}
// Does preset blending only affect timing of samples?
inline bool IsPresetTimeOperation( int nPresetType )
{
switch ( nPresetType )
{
default:
break;
case PROCEDURAL_PRESET_STAGGER:
case PROCEDURAL_PRESET_STEADY:
case PROCEDURAL_PRESET_HOLD:
case PROCEDURAL_PRESET_RELEASE:
return true;
}
return false;
}
// Does the preset blend towards a single value
inline bool IsPresetStaticValue( int nPresetType )
{
switch ( nPresetType )
{
case PROCEDURAL_PRESET_NOT:
case PROCEDURAL_PRESET_DEFAULT_CROSSFADE:
case PROCEDURAL_PRESET_ZERO_CROSSFADE:
case PROCEDURAL_PRESET_HALF_CROSSFADE:
case PROCEDRUAL_PRESET_ONE_CROSSFADE:
return true;
default:
return false;
}
return false;
}
// Should area under time selection be "resampled" into a smooth curve worth of samples before
// the preset operations?
inline bool ShouldPresetPreserveSamples( int nPresetType )
{
switch ( nPresetType )
{
default:
break;
case PROCEDURAL_PRESET_STAGGER:
case PROCEDURAL_PRESET_STEADY:
return true;
}
return false;
}
#endif // PROCEDURALPRESETS_H