summaryrefslogtreecommitdiff
path: root/public/movieobjects
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/movieobjects
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'public/movieobjects')
-rw-r--r--public/movieobjects/dmeanimationlist.h59
-rw-r--r--public/movieobjects/dmeanimationset.h237
-rw-r--r--public/movieobjects/dmeattachment.h41
-rw-r--r--public/movieobjects/dmebalancetostereocalculatoroperator.h45
-rw-r--r--public/movieobjects/dmebookmark.h35
-rw-r--r--public/movieobjects/dmecamera.h91
-rw-r--r--public/movieobjects/dmechannel.h283
-rw-r--r--public/movieobjects/dmeclip.h544
-rw-r--r--public/movieobjects/dmecombinationoperator.h459
-rw-r--r--public/movieobjects/dmedag.h107
-rw-r--r--public/movieobjects/dmedccmakefile.h131
-rw-r--r--public/movieobjects/dmedrawsettings.h195
-rw-r--r--public/movieobjects/dmeeditortypedictionary.h132
-rw-r--r--public/movieobjects/dmeexpressionoperator.h106
-rw-r--r--public/movieobjects/dmeeyeball.h76
-rw-r--r--public/movieobjects/dmeeyeposition.h73
-rw-r--r--public/movieobjects/dmefaceset.h87
-rw-r--r--public/movieobjects/dmegamemodel.h184
-rw-r--r--public/movieobjects/dmegamemodelinput.h112
-rw-r--r--public/movieobjects/dmeimage.h57
-rw-r--r--public/movieobjects/dmeinput.h28
-rw-r--r--public/movieobjects/dmejoint.h39
-rw-r--r--public/movieobjects/dmekeyboardinput.h36
-rw-r--r--public/movieobjects/dmelight.h135
-rw-r--r--public/movieobjects/dmelog.h918
-rw-r--r--public/movieobjects/dmemakefile.h237
-rw-r--r--public/movieobjects/dmemakefileutils.h301
-rw-r--r--public/movieobjects/dmematerial.h41
-rw-r--r--public/movieobjects/dmematerialoverlayfxclip.h59
-rw-r--r--public/movieobjects/dmemdl.h79
-rw-r--r--public/movieobjects/dmemdlmakefile.h101
-rw-r--r--public/movieobjects/dmemesh.h496
-rw-r--r--public/movieobjects/dmemodel.h94
-rw-r--r--public/movieobjects/dmemorphoperator.h53
-rw-r--r--public/movieobjects/dmemouseinput.h45
-rw-r--r--public/movieobjects/dmeoperator.h34
-rw-r--r--public/movieobjects/dmepackoperators.h164
-rw-r--r--public/movieobjects/dmeparticlesystemdefinition.h165
-rw-r--r--public/movieobjects/dmephonememapping.h24
-rw-r--r--public/movieobjects/dmeselection.h200
-rw-r--r--public/movieobjects/dmeshader.h53
-rw-r--r--public/movieobjects/dmeshape.h53
-rw-r--r--public/movieobjects/dmesound.h53
-rw-r--r--public/movieobjects/dmetestmesh.h140
-rw-r--r--public/movieobjects/dmetexture.h184
-rw-r--r--public/movieobjects/dmetimeframe.h153
-rw-r--r--public/movieobjects/dmetimeselection.h72
-rw-r--r--public/movieobjects/dmetimeselectiontimes.h28
-rw-r--r--public/movieobjects/dmetrack.h191
-rw-r--r--public/movieobjects/dmetrackgroup.h249
-rw-r--r--public/movieobjects/dmetransform.h49
-rw-r--r--public/movieobjects/dmetransforminput.h59
-rw-r--r--public/movieobjects/dmetransformlist.h47
-rw-r--r--public/movieobjects/dmetransformoperator.h53
-rw-r--r--public/movieobjects/dmeunpackoperators.h164
-rw-r--r--public/movieobjects/dmevertexdata.h337
-rw-r--r--public/movieobjects/dmmeshcomp.h126
-rw-r--r--public/movieobjects/dmmeshutils.h199
-rw-r--r--public/movieobjects/dmobjserializer.h114
-rw-r--r--public/movieobjects/dmsmdserializer.h188
-rw-r--r--public/movieobjects/dmx_to_vcd.h22
-rw-r--r--public/movieobjects/idmemakefileutils.h75
-rw-r--r--public/movieobjects/importintovcd.h33
-rw-r--r--public/movieobjects/movieobjects.cpp60
-rw-r--r--public/movieobjects/movieobjects.h64
-rw-r--r--public/movieobjects/movieobjects_compiletools.cpp82
-rw-r--r--public/movieobjects/proceduralpresets.h30
-rw-r--r--public/movieobjects/timeutils.h158
68 files changed, 9339 insertions, 0 deletions
diff --git a/public/movieobjects/dmeanimationlist.h b/public/movieobjects/dmeanimationlist.h
new file mode 100644
index 0000000..9c9a026
--- /dev/null
+++ b/public/movieobjects/dmeanimationlist.h
@@ -0,0 +1,59 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmeanimationset.h b/public/movieobjects/dmeanimationset.h
new file mode 100644
index 0000000..ad7678b
--- /dev/null
+++ b/public/movieobjects/dmeanimationset.h
@@ -0,0 +1,237 @@
+//========= Copyright 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/timeutils.h"
+#include "movieobjects/proceduralpresets.h"
+
+class CDmeBookmark;
+
+//-----------------------------------------------------------------------------
+// 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 );
+
+ // See the enumeration above
+ void SetProceduralPresetType( int nType );
+ bool IsProcedural() const;
+ int GetProceduralPresetType() const;
+
+private:
+ int FindControlValueIndex( const char *pControlName );
+
+ CDmaElementArray< CDmElement > m_ControlValues;
+ CDmaVar< int > m_nProceduralType;
+};
+
+
+class CDmeProceduralPresetSettings : public CDmElement
+{
+ DEFINE_ELEMENT( CDmeProceduralPresetSettings, CDmElement );
+public:
+
+ CDmaVar< float > m_flJitterScale;
+ CDmaVar< float > m_flSmoothScale;
+ CDmaVar< float > m_flSharpenScale;
+ CDmaVar< float > m_flSoftenScale;
+
+ CDmaVar< int > m_nJitterIterations;
+ CDmaVar< int > m_nSmoothIterations;
+ CDmaVar< int > m_nSharpenIterations;
+ CDmaVar< int > m_nSoftenIterations;
+
+ CDmaVar< int > m_nStaggerInterval;
+};
+
+//-----------------------------------------------------------------------------
+// A class used to copy preset values from one preset group to another
+//-----------------------------------------------------------------------------
+class CDmePresetRemap : public CDmElement
+{
+ DEFINE_ELEMENT( CDmePresetRemap, CDmElement );
+
+public:
+ CDmaString m_SourcePresetGroup;
+
+ const char *FindSourcePreset( const char *pDestPresetName );
+ int GetRemapCount();
+ const char *GetRemapSource( int i );
+ const char *GetRemapDest( int i );
+ void AddRemap( const char *pSourcePresetName, const char *pDestPresetName );
+ void RemoveAll();
+
+private:
+ CDmaStringArray m_SrcPresets;
+ CDmaStringArray m_DestPresets;
+};
+
+
+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, int nProceduralType = PROCEDURAL_PRESET_NOT );
+ bool RemovePreset( CDmePreset *pPreset );
+ void MovePresetUp( CDmePreset *pPreset );
+ void MovePresetDown( CDmePreset *pPreset );
+ void MovePresetInFrontOf( CDmePreset *pPreset, CDmePreset *pInFrontOf );
+ CDmePresetRemap *GetPresetRemap();
+ CDmePresetRemap *GetOrAddPresetRemap();
+
+ 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 *pGroupName );
+
+ CDmaElementArray< CDmePreset > m_Presets; // "presets"
+};
+
+
+//-----------------------------------------------------------------------------
+// The main controlbox for controlling animation
+//-----------------------------------------------------------------------------
+class CDmeAnimationSet : public CDmElement
+{
+ DEFINE_ELEMENT( CDmeAnimationSet, CDmElement );
+
+public:
+ CDmaElementArray< CDmElement > &GetControls(); // raw access to the array
+ CDmaElementArray< CDmElement > &GetSelectionGroups(); // 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 );
+ CDmElement *FindControl( const char *pControlName );
+ CDmElement *FindOrAddControl( const char *pControlName );
+
+ // Methods pertaining to preset groups
+ CDmePresetGroup *FindPresetGroup( const char *pGroupName );
+ CDmePresetGroup *FindOrAddPresetGroup( const char *pGroupName );
+ bool RemovePresetGroup( CDmePresetGroup *pPresetGroup );
+ void MovePresetGroupUp( CDmePresetGroup *pPresetGroup );
+ void MovePresetGroupDown( CDmePresetGroup *pPresetGroup );
+ void MovePresetGroupInFrontOf( CDmePresetGroup *pPresetGroup, CDmePresetGroup *pInFrontOf );
+
+ CDmePreset *FindOrAddPreset( const char *pGroupName, const char *pPresetName, int nProceduralType = PROCEDURAL_PRESET_NOT );
+ bool RemovePreset( CDmePreset *pPreset );
+
+ const CDmaElementArray< CDmeBookmark > &GetBookmarks() const;
+ CDmaElementArray< CDmeBookmark > &GetBookmarks();
+
+ CDmElement *FindSelectionGroup( const char *pSelectionGroupName );
+ CDmElement *FindOrAddSelectionGroup( const char *pSelectionGroupName );
+
+ virtual void OnElementUnserialized();
+
+ void CollectOperators( CUtlVector< DmElementHandle_t > &operators );
+ void AddOperator( CDmeOperator *pOperator );
+ void RemoveOperator( CDmeOperator *pOperator );
+
+ void EnsureProceduralPresets();
+
+private:
+ int FindPresetGroupIndex( CDmePresetGroup *pGroup );
+ int FindPresetGroupIndex( const char *pGroupName );
+
+ CDmaElementArray< CDmElement > m_Controls; // "controls"
+ CDmaElementArray< CDmElement > m_SelectionGroups; // "selectionGroups"
+ CDmaElementArray< CDmePresetGroup > m_PresetGroups; // "presetGroups"
+ CDmaElementArray< CDmePhonemeMapping > m_PhonemeMap; // "phonememap"
+ CDmaElementArray< CDmeOperator > m_Operators; // "operators"
+ CDmaElementArray< CDmeBookmark > m_Bookmarks; // "bookmarks"
+
+ friend class CModelPresetGroupManager;
+};
+
+
+//-----------------------------------------------------------------------------
+// Utility methods to convert between L/R and V/B
+//-----------------------------------------------------------------------------
+inline void ValueBalanceToLeftRight( float *pLeft, float *pRight, float flValue, float flBalance )
+{
+ *pLeft = ( flBalance <= 0.5f ) ? 1.0f : ( ( 1.0f - flBalance ) / 0.5f );
+ *pLeft *= flValue;
+ *pRight = ( flBalance >= 0.5f ) ? 1.0f : ( flBalance / 0.5f );
+ *pRight *= flValue;
+}
+
+inline void LeftRightToValueBalance( float *pValue, float *pBalance, float flLeft, float flRight, float flDefaultBalance = 0.5f )
+{
+ *pValue = max( flRight, flLeft );
+ if ( *pValue <= 1e-6 )
+ {
+ // Leave target balance at input value if target == 0 and on the dest side of blending
+ *pBalance = flDefaultBalance;
+ return;
+ }
+
+ if ( flRight < flLeft )
+ {
+ *pBalance = 0.5f * flRight / flLeft;
+ }
+ else
+ {
+ *pBalance = 1.0f - ( 0.5f * flLeft / flRight );
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// A cache of preset groups to be associated with specific models
+//-----------------------------------------------------------------------------
+abstract_class IModelPresetGroupManager
+{
+public:
+ virtual void AssociatePresetsWithFile( DmFileId_t fileId ) = 0;
+ virtual void ApplyModelPresets( const char *pModelName, CDmeAnimationSet *pAnimationSet ) = 0;
+};
+
+
+extern IModelPresetGroupManager *g_pModelPresetGroupMgr;
+
+
+#endif // DMEANIMATIONSET_H
diff --git a/public/movieobjects/dmeattachment.h b/public/movieobjects/dmeattachment.h
new file mode 100644
index 0000000..b781cf7
--- /dev/null
+++ b/public/movieobjects/dmeattachment.h
@@ -0,0 +1,41 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Dme version of a model attachment point
+//
+//===========================================================================//
+
+#ifndef DMEATTACHMENT_H
+#define DMEATTACHMENT_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "movieobjects/dmeshape.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:
+ CMaterialReference m_AttachmentMaterial;
+};
+
+
+#endif // DMEATTACHMENT_H
diff --git a/public/movieobjects/dmebalancetostereocalculatoroperator.h b/public/movieobjects/dmebalancetostereocalculatoroperator.h
new file mode 100644
index 0000000..d6d8c86
--- /dev/null
+++ b/public/movieobjects/dmebalancetostereocalculatoroperator.h
@@ -0,0 +1,45 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef DMEBALANCETOSTEREOCALCULATOROPERATOR_H
+#define DMEBALANCETOSTEREOCALCULATOROPERATOR_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "movieobjects/dmeoperator.h"
+
+class CDmeBalanceToStereoCalculatorOperator : public CDmeOperator
+{
+ DEFINE_ELEMENT( CDmeBalanceToStereoCalculatorOperator, CDmeOperator );
+
+public:
+ virtual void Operate();
+
+ virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs );
+ virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
+
+ void SetSpewResult( bool state );
+
+protected:
+ float ComputeDefaultValue();
+
+ CDmaVar< float > m_result_left;
+ CDmaVar< float > m_result_right;
+ CDmaVar< float > m_result_multi;
+
+ CDmaVar< float > m_value; // input value
+ CDmaVar< float > m_balance; // balance value
+ CDmaVar< float > m_multilevel; // multilevel value
+
+ // Debuggin
+ CDmaVar< bool > m_bSpewResult;
+
+ float m_flDefaultValue;
+};
+
+
+#endif // DMEBALANCETOSTEREOCALCULATOROPERATOR_H
diff --git a/public/movieobjects/dmebookmark.h b/public/movieobjects/dmebookmark.h
new file mode 100644
index 0000000..142851e
--- /dev/null
+++ b/public/movieobjects/dmebookmark.h
@@ -0,0 +1,35 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef DMEBOOKMARK_H
+#define DMEBOOKMARK_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "datamodel/dmelement.h"
+#include "movieobjects/timeutils.h"
+
+class CDmeBookmark : public CDmElement
+{
+ DEFINE_ELEMENT( CDmeBookmark, CDmElement );
+
+public:
+ const char *GetNote() const { return m_Note; }
+ DmeTime_t GetTime() const { return DmeTime_t( m_Time ); }
+ DmeTime_t GetDuration() const { return DmeTime_t( m_Duration ); }
+
+ void SetNote( const char *pNote ) { m_Note = pNote; }
+ void SetTime( DmeTime_t time ) { m_Time = time.GetTenthsOfMS(); }
+ void SetDuration( DmeTime_t duration ) { m_Duration = duration.GetTenthsOfMS(); }
+
+private:
+ CDmaString m_Note;
+ CDmaVar< int > m_Time;
+ CDmaVar< int > m_Duration;
+};
+
+#endif // DMEBOOKMARK_H
diff --git a/public/movieobjects/dmecamera.h b/public/movieobjects/dmecamera.h
new file mode 100644
index 0000000..2496025
--- /dev/null
+++ b/public/movieobjects/dmecamera.h
@@ -0,0 +1,91 @@
+//========= Copyright 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"
+#include "movieobjects/timeutils.h"
+
+
+//-----------------------------------------------------------------------------
+// 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 );
+
+ // Returns the focal distance in inches
+ float GetFocalDistance() const;
+
+ // Sets the focal distance in inches
+ void SetFocalDistance( const float &fFocalDistance );
+
+ // Returns the aperture size in inches
+ float GetAperture() const;
+
+ // Returns the shutter speed in seconds
+ float GetShutterSpeed() const;
+
+ // Returns the tone map scale
+ float GetToneMapScale() const;
+
+ // Returns the tone map scale
+ float GetBloomScale() 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;
+
+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_fieldOfView;
+ CDmaVar< float > m_zNear;
+ CDmaVar< float > m_zFar;
+
+ CDmaVar< float > m_fFocalDistance;
+ CDmaVar< float > m_fAperture;
+ CDmaVar< float > m_fShutterSpeed;
+ CDmaVar< float > m_fToneMapScale;
+ CDmaVar< float > m_fBloomScale;
+
+ CDmaVar< int > m_nDoFQuality;
+ CDmaVar< int > m_nMotionBlurQuality;
+};
+
+
+#endif // DMECAMERA_H
diff --git a/public/movieobjects/dmechannel.h b/public/movieobjects/dmechannel.h
new file mode 100644
index 0000000..2873bd7
--- /dev/null
+++ b/public/movieobjects/dmechannel.h
@@ -0,0 +1,283 @@
+//========= Copyright 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/dmeoperator.h"
+#include "movieobjects/dmelog.h"
+#include "movieobjects/dmeclip.h"
+#include "movieobjects/proceduralpresets.h"
+#include "datamodel/idatamodel.h"
+#include "datamodel/dmehandle.h"
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+class CDmeClip;
+class CDmeChannel;
+
+
+//-----------------------------------------------------------------------------
+// different channel modes of operation
+//-----------------------------------------------------------------------------
+enum ChannelMode_t
+{
+ CM_OFF,
+ CM_PASS,
+ CM_RECORD,
+ CM_PLAY,
+};
+
+enum PlayMode_t
+{
+ PM_HOLD,
+ PM_LOOP,
+};
+
+
+//-----------------------------------------------------------------------------
+// A class managing channel recording
+//-----------------------------------------------------------------------------
+class CDmeChannelRecordingMgr
+{
+public:
+ // constructor
+ CDmeChannelRecordingMgr();
+
+ // Activates, deactivates layer recording.
+ void StartLayerRecording( const char *pUndoRedoDesc, const DmeLog_TimeSelection_t *pTimeSelection = NULL );
+ void FinishLayerRecording( float flThreshold, bool bFlattenLayers = true );
+
+ // Adds a channel to the recording layer
+ void AddChannelToRecordingLayer( CDmeChannel *pChannel, CDmeClip *pRoot = NULL, CDmeClip *pShot = NULL );
+
+ // 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 );
+
+ // Methods which control various aspects of recording
+ void UpdateTimeAdvancing( bool bPaused, DmeTime_t tCurTime );
+ void UpdateRecordingTimeSelectionTimes( const DmeLog_TimeSelection_t& timeSelection );
+ void SetIntensityOnAllLayers( float flIntensity );
+ void SetRecordingMode( RecordingMode_t mode );
+ void SetPresetValue( CDmeChannel* pChannel, CDmAttribute *pPresetValue );
+
+ void SetProceduralTarget( int nProceduralMode, const CDmAttribute *pTarget );
+ void SetProceduralTarget( int nProceduralMode, const CUtlVector< KeyValues * >& list );
+ int GetProceduralType() const;
+ const CDmAttribute *GetProceduralTarget() const;
+ const CUtlVector< KeyValues * > &GetPasteTarget() const;
+
+ // Methods to query aspects of recording
+ bool IsTimeAdvancing() const;
+ bool IsUsingDetachedTimeSelection() const;
+ bool IsUsingTimeSelection() const;
+
+private:
+ struct LayerChannelInfo_t
+ {
+ LayerChannelInfo_t() : m_pPresetValue( 0 ) {}
+
+ CDmeHandle< CDmeChannel > m_Channel;
+ DmeClipStack_t m_ClipStack;
+ CDmAttribute* m_pPresetValue;
+ };
+
+ // Methods available for CDmeChannel
+ bool ShouldRecordUsingTimeSelection() const;
+
+ // Internal methods
+ void FlattenLayers( float flThreshhold );
+ void RemoveAllChannelsFromRecordingLayer( );
+
+ bool m_bActive : 1;
+ bool m_bSavedUndoState : 1;
+ bool m_bUseTimeSelection : 1;
+ CUtlVector< LayerChannelInfo_t > m_LayerChannels;
+ DmeLog_TimeSelection_t m_TimeSelection;
+ int m_nRevealType;
+ const CDmAttribute *m_pRevealTarget;
+ CUtlVector< KeyValues * > m_PasteTarget;
+
+ friend CDmeChannel;
+};
+
+// Singleton
+extern CDmeChannelRecordingMgr *g_pChannelRecordingMgr;
+
+
+//-----------------------------------------------------------------------------
+// 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;
+
+ 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;
+
+ void SetChannelToPlayToSelf( const char *outputAttributeName, float defaultValue, bool force = false );
+
+ // need this until we have the EditApply message queue
+ void OnAttributeChanged( CDmAttribute *pAttribute );
+
+ template< class T >
+ bool GetCurrentPlaybackValue( T& value );
+ template< class T >
+ bool GetPlaybackValueAtTime( DmeTime_t time, T& value );
+
+ void Play();
+
+ void SetNextKeyCurveType( int nCurveType );
+
+ // Builds a clip stack for the channel
+ CDmeClip* FindOwnerClipForChannel( CDmeClip *pRoot );
+ bool BuildClipStack( DmeClipStack_t *pClipStack, CDmeClip *pRoot, CDmeClip *pShot );
+
+protected:
+ // Used to cache off handles to attributes
+ CDmAttribute* SetupFromAttribute();
+ CDmAttribute* SetupToAttribute();
+
+ void Record();
+ 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;
+
+ DmeTime_t m_timeOutsideTimeframe;
+ DmeTime_t m_tCurrentTime;
+ DmeTime_t m_tPreviousTime;
+
+ int m_nRecordLayerIndex;
+ int m_nNextCurveType;
+
+ friend class CDmeChannelRecordingMgr;
+};
+
+
+//-----------------------------------------------------------------------------
+// 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::GetCurrentPlaybackValue( T& value )
+{
+ return GetPlaybackValueAtTime( GetCurrentTime(), value );
+}
+
+#endif // DMECHANNEL_H
diff --git a/public/movieobjects/dmeclip.h b/public/movieobjects/dmeclip.h
new file mode 100644
index 0000000..51cd337
--- /dev/null
+++ b/public/movieobjects/dmeclip.h
@@ -0,0 +1,544 @@
+//========= Copyright 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 "video/ivideoservices.h"
+#include "materialsystem/MaterialSystemUtil.h"
+#include "tier1/utlmap.h"
+#include "movieobjects/timeutils.h"
+
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+class CDmeClip;
+class CDmeTimeFrame;
+class CDmeBookmark;
+class CDmeSound;
+class CDmeChannel;
+class CDmeCamera;
+class CDmeLight;
+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 Rect_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 )
+
+
+typedef CUtlVector< CDmeHandle< CDmeClip > > DmeClipStack_t;
+
+
+//-----------------------------------------------------------------------------
+// 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_offset;
+};
+
+
+//-----------------------------------------------------------------------------
+// Constructor, destructor
+//-----------------------------------------------------------------------------
+class CDmeClip : public CDmElement
+{
+ DEFINE_ELEMENT( CDmeClip, CDmElement );
+
+public:
+ // Inherited from IDmElement
+ virtual void OnAttributeArrayElementAdded( CDmAttribute *pAttribute, int nFirstElem, int nLastElem );
+ virtual void OnAttributeArrayElementRemoved( CDmAttribute *pAttribute, int nFirstElem, int nLastElem );
+
+ // 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 );
+
+ // 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, CDmeClip *pRoot, CDmeClip *pShot = NULL );
+
+ // Clip stack versions of time conversion
+ static DmeTime_t ToChildMediaTime ( const DmeClipStack_t& stack, DmeTime_t globalTime, bool bClamp = true );
+ static DmeTime_t FromChildMediaTime ( const DmeClipStack_t& stack, DmeTime_t localTime, bool bClamp = true );
+ static DmeTime_t ToChildMediaDuration ( const DmeClipStack_t& stack, DmeTime_t globalDuration );
+ static DmeTime_t FromChildMediaDuration( const DmeClipStack_t& stack, DmeTime_t localDuration );
+ static void ToChildMediaTime( DmeLog_TimeSelection_t &params, const DmeClipStack_t& stack );
+
+ 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 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;
+
+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;
+ 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;
+}
+
+
+//-----------------------------------------------------------------------------
+// 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;
+
+ CDmaElement< CDmeSound > m_Sound;
+ CDmaVar< bool > m_bShowWave;
+
+};
+
+
+//-----------------------------------------------------------------------------
+// Clip containing recorded data from the game
+//-----------------------------------------------------------------------------
+class CDmeChannelsClip : public CDmeClip
+{
+ DEFINE_ELEMENT( CDmeChannelsClip, CDmeClip );
+
+public:
+ virtual DmeClipType_t GetClipType() { return DMECLIP_CHANNEL; }
+
+ CDmeChannel *CreatePassThruConnection
+ (
+ char const *passThruName,
+ CDmElement *pFrom,
+ char const *pFromAttribute,
+ CDmElement *pTo,
+ char const *pToAttribute,
+ int index = 0
+ );
+
+ void RemoveChannel( CDmeChannel *pChannel );
+
+ 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 = 2
+ };
+
+ // 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; }
+
+ // Attribute changed
+ virtual void OnElementUnserialized( );
+ virtual void PreAttributeChanged( CDmAttribute *pAttribute );
+ 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 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;
+
+ // 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 );
+
+ // Light helper methods
+ int GetLightCount();
+ CDmeLight *GetLight( int nIndex );
+ void AddLight( CDmeLight *pLight );
+
+ // Scene / Dag helper methods
+ void SetScene( CDmeDag *pDag );
+ CDmeDag *GetScene();
+
+ // helper for inputs and operators
+ int GetInputCount();
+ CDmeInput *GetInput( int nIndex );
+ void AddInput( CDmeInput *pInput );
+ void RemoveAllInputs();
+ void AddOperator( CDmeOperator *pOperator );
+ void CollectOperators( CUtlVector< DmElementHandle_t > &operators );
+
+ // 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;
+ IVideoMaterial *GetCachedVideoMaterial();
+ void SetCachedAVI( const char *pAVIFile );
+
+ int GetAnimationSetCount();
+ CDmeAnimationSet *GetAnimationSet( int idx );
+ void AddAnimationSet( CDmeAnimationSet *element );
+ void RemoveAllAnimationSets();
+ CDmaElementArray< CDmElement > &GetAnimationSets(); // raw access to the array
+ const CDmaElementArray< CDmElement > &GetAnimationSets() const;
+
+ const CDmaElementArray< CDmeBookmark > &GetBookmarks() const;
+ CDmaElementArray< CDmeBookmark > &GetBookmarks();
+
+ void SetFadeTimes( DmeTime_t fadeIn, DmeTime_t fadeOut ) { m_fadeInDuration = fadeIn.GetTenthsOfMS(); m_fadeOutDuration = fadeOut.GetTenthsOfMS(); }
+ void SetFadeInTime( DmeTime_t t ) { m_fadeInDuration = t.GetTenthsOfMS(); }
+ void SetFadeOutTime( DmeTime_t t ) { m_fadeOutDuration = t.GetTenthsOfMS(); }
+ DmeTime_t GetFadeInTime() const { return DmeTime_t( m_fadeInDuration.Get() ); }
+ DmeTime_t GetFadeOutTime() const { return DmeTime_t( m_fadeOutDuration.Get() ); }
+
+ // 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 );
+
+ // Rolls associated clips so they remain in the same relative time
+ void RollAssociatedClips( CDmeClip *pClip, CUtlVector< ClipAssociation_t > &association, DmeTime_t dt );
+
+ // Shifts associated clips so they remain in the same relative time when pClip is scaled
+ void ScaleAssociatedClips( CDmeClip *pClip, CUtlVector< ClipAssociation_t > &association, float ratio, DmeTime_t oldOffset );
+
+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< CDmeLight > m_Lights;
+
+ CDmaElementArray< CDmeInput > m_Inputs;
+ CDmaElementArray< CDmeOperator > m_Operators;
+
+ CDmaString m_AVIFile;
+
+ CDmaVar< int > m_fadeInDuration;
+ CDmaVar< int > m_fadeOutDuration;
+
+ CDmaElement< CDmeMaterialOverlayFXClip >m_MaterialOverlayEffect;
+ CDmaVar< bool > m_bIsUsingCachedVersion;
+
+ CDmaElementArray< CDmElement > m_AnimationSets; // "animationSets"
+ CDmaElementArray< CDmeBookmark > m_Bookmarks;
+
+ CDmaVar< float > m_Volume;
+
+ IVideoMaterial *m_pCachedVersion;
+ bool m_bReloadCachedVersion;
+ CMaterialReference m_FadeMaterial;
+};
+
+
+//-----------------------------------------------------------------------------
+// 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( 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 );
+
+#endif // DMECLIP_H
diff --git a/public/movieobjects/dmecombinationoperator.h b/public/movieobjects/dmecombinationoperator.h
new file mode 100644
index 0000000..ee40735
--- /dev/null
+++ b/public/movieobjects/dmecombinationoperator.h
@@ -0,0 +1,459 @@
+//========= Copyright 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;
+
+ // Do we have a raw control?
+ bool HasRawControl( const char *pRawControlName ) 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 flLevel, float flBalance, 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 );
+
+ // FIXME: Remove soon!
+ // This is a very short-term solution to the problem of autogenerating
+ // wrinkle data; when we have real editors we can remove it
+ void GenerateWrinkleDeltas( bool bOverwrite = true );
+
+ 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 );
+
+ 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
diff --git a/public/movieobjects/dmedag.h b/public/movieobjects/dmedag.h
new file mode 100644
index 0000000..408f4fd
--- /dev/null
+++ b/public/movieobjects/dmedag.h
@@ -0,0 +1,107 @@
+//========= Copyright 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/dmelement.h"
+#include "datamodel/dmattribute.h"
+#include "datamodel/dmattributevar.h"
+#include "movieobjects/dmeshape.h"
+#include "movieobjects/dmetransform.h"
+
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+class CDmeTransform;
+class CDmeShape;
+class CDmeDrawSettings;
+
+
+//-----------------------------------------------------------------------------
+// A class representing a camera
+//-----------------------------------------------------------------------------
+class CDmeDag : public CDmElement
+{
+ DEFINE_ELEMENT( CDmeDag, CDmElement );
+
+public:
+ // Accessors
+ CDmeTransform *GetTransform();
+ 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;
+ void 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 );
+
+ // 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 GetShapeToWorldTransform( matrix3x4_t &mat );
+
+ void GetLocalMatrix( matrix3x4_t &mat );
+
+ void GetWorldMatrix( matrix3x4_t &mat );
+
+ void GetParentWorldMatrix( matrix3x4_t &mat );
+
+ static void DrawUsingEngineCoordinates( bool bEnable );
+
+ // Transform from DME to engine coordinates
+ static void DmeToEngineMatrix( matrix3x4_t& dmeToEngine );
+ static void EngineToDmeMatrix( matrix3x4_t& engineToDme );
+
+protected:
+ void GetBoundingSphere( Vector &center, float &radius, const matrix3x4_t &pMat ) const;
+
+ void PushDagTransform();
+ void PopDagTransform();
+ CDmAttribute *GetVisibilityAttribute();
+
+ CDmaVar< bool > m_Visible;
+ 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;
+};
+
+
+#endif // DMEDAG_H
diff --git a/public/movieobjects/dmedccmakefile.h b/public/movieobjects/dmedccmakefile.h
new file mode 100644
index 0000000..c8578ff
--- /dev/null
+++ b/public/movieobjects/dmedccmakefile.h
@@ -0,0 +1,131 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmedrawsettings.h b/public/movieobjects/dmedrawsettings.h
new file mode 100644
index 0000000..ebc2a31
--- /dev/null
+++ b/public/movieobjects/dmedrawsettings.h
@@ -0,0 +1,195 @@
+//========= Copyright 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< CUtlSymbol > s_KnownDrawableTypes;
+ CUtlRBTree< CUtlSymbol > 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 \ No newline at end of file
diff --git a/public/movieobjects/dmeeditortypedictionary.h b/public/movieobjects/dmeeditortypedictionary.h
new file mode 100644
index 0000000..ad53279
--- /dev/null
+++ b/public/movieobjects/dmeeditortypedictionary.h
@@ -0,0 +1,132 @@
+//========= Copyright 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
+
+
+
diff --git a/public/movieobjects/dmeexpressionoperator.h b/public/movieobjects/dmeexpressionoperator.h
new file mode 100644
index 0000000..9a5de80
--- /dev/null
+++ b/public/movieobjects/dmeexpressionoperator.h
@@ -0,0 +1,106 @@
+//========= Copyright 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 "tier1/utlstack.h" // for calculator
+#include "tier1/utlvector.h" // for calculator
+
+
+//-----------------------------------------------------------------------------
+// Calculator Parsing class
+// precedence order:
+// unary operators: + - ! func var
+// * / %
+// + -
+// < > <= >=
+// == !=
+// &&
+// ||
+// ?:
+//-----------------------------------------------------------------------------
+class CExpressionCalculator
+{
+public:
+ CExpressionCalculator( const char *expr = NULL ) : m_expr( expr ) {}
+ void SetExpression( const char *expr )
+ {
+ m_expr = expr;
+ }
+
+ void SetVariable( const char *var, float value );
+ void SetVariable( int nVariableIndex, float value );
+ int FindVariableIndex( const char *var );
+
+ bool Evaluate( float &value );
+
+ // Builds a list of variable names from the expression
+ bool BuildVariableListFromExpression( );
+
+ // Iterate over variables
+ int VariableCount();
+ const char *VariableName( int nIndex );
+
+private:
+ bool ParseExpr ( const char *&expr );
+ bool ParseConditional( const char *&expr );
+ bool ParseOr ( const char *&expr );
+ bool ParseAnd ( const char *&expr );
+ bool ParseEquality ( const char *&expr );
+ bool ParseLessGreater( const char *&expr );
+ bool ParseAddSub ( const char *&expr );
+ bool ParseDivMul ( const char *&expr );
+ bool ParseUnary ( const char *&expr );
+ bool ParsePrimary ( const char *&expr );
+ bool Parse1ArgFunc ( const char *&expr );
+ bool Parse2ArgFunc ( const char *&expr );
+ bool Parse3ArgFunc ( const char *&expr );
+ // bool Parse4ArgFunc ( const char *&expr );
+ bool Parse5ArgFunc ( const char *&expr );
+
+ CUtlString m_expr;
+ CUtlVector< CUtlString > m_varNames;
+ CUtlVector<float> m_varValues;
+ CUtlStack<float> m_stack;
+ bool m_bIsBuildingArgumentList;
+};
+
+
+//-----------------------------------------------------------------------------
+// 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 );
+
+ CDmaVar< float > m_result;
+ CDmaString m_expr;
+ CDmaVar< bool > m_bSpewResult;
+};
+
+
+#endif // DMEEXPRESSIONOPERATOR_H
diff --git a/public/movieobjects/dmeeyeball.h b/public/movieobjects/dmeeyeball.h
new file mode 100644
index 0000000..f149569
--- /dev/null
+++ b/public/movieobjects/dmeeyeball.h
@@ -0,0 +1,76 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Model eyeposition node, kind of a top level
+//
+//=============================================================================
+
+#ifndef DMEEYEBALL_H
+#define DMEEYEBALL_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "movieobjects/dmedag.h"
+
+/*
+$eyeposition 0 83.274592 0
+$attachment "eyes" "bip_head" 0 83.274592 1.41954 absolute
+$attachment "righteye" "bip_head" -1.425952 83.274592 1.41954 absolute
+$attachment "lefteye" "bip_head" 1.425952 83.274592 1.41954 absolute
+
+$cdmaterials "models/player/hvyweapon/"
+$model heavy "parts/dmx/heavy_reference_lo.dmx"{
+
+eyeball righteye "bip_head" -1.425952 83.274592 1.41954 "eyeball_r" 1.80
+356 -1 "pupil_r" 0.6
+eyeball lefteye "bip_head" 1.425952 83.274592 1.41954 "eyeball_l" 1.80
+356 1 "pupil_l" 0.6
+
+localvar %dummy_eyelid_flex
+
+flexcontroller eyes range -30 30 eyes_updown
+flexcontroller eyes range -30 30 eyes_rightleft
+
+}
+
+$model eyeball
+
+(name) Name of eyeball, used to match eyelid rules.
+
+(bone name) Name of bone that the eye is parented to, typically the head.
+
+(X) (Y) (Z) World location of the center of the ball of the eye.
+
+(material name) Material name to use when searching for vertices to consider as the �white� of the eye (used in dynamically texture mapping the iris and cornea onto the eye).
+
+(diameter) Diameter of the ball of the eye
+
+(angle) Default yaw offset from �forward� for iris. Humans are typically 2-4 degrees walleyed. Not setting this correctly will result in your either characters appearing cross-eyed, or if you�ve compensated by misplacing the ball of the eye, them not tracking side to side.
+
+(iris material) no longer used but still in the option list.
+
+(pupil scale) World scale of the iris texture
+[edit]
+Syntax
+
+eyeball (name) (bone name) (X) (Y) (Z) (material name) (diameter) (angle) (iris material) (pupil scale)
+
+*/
+
+//-----------------------------------------------------------------------------
+// A class representing a transformation matrix
+//-----------------------------------------------------------------------------
+class CDmeEyeball : public CDmeDag
+{
+ DEFINE_ELEMENT( CDmeEyeball, CDmeDag );
+
+public:
+ void GetWorldPosition( Vector &worldPosition );
+
+ CDmaVar< float > m_flDiameter; // Diameter of the ball of the eye
+ CDmaVar< float > m_flYawAngle; // Yaw offset from "forward" for iris. Humans are typically 2-4 degrees walleyed.
+ CDmaVar< float > m_flPupilScale; // Scale of the iris texture
+};
+
+
+#endif // DMEEYEBALL_H
diff --git a/public/movieobjects/dmeeyeposition.h b/public/movieobjects/dmeeyeposition.h
new file mode 100644
index 0000000..cd0c411
--- /dev/null
+++ b/public/movieobjects/dmeeyeposition.h
@@ -0,0 +1,73 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Model eyeposition node
+//
+//=============================================================================
+
+#ifndef DMEEYEPOSITION_H
+#define DMEEYEPOSITION_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "movieobjects/dmedag.h"
+
+
+//-----------------------------------------------------------------------------
+/*
+$eyeposition 0 83.274592 0
+$attachment "eyes" "bip_head" 0 83.274592 1.41954 absolute
+$attachment "righteye" "bip_head" -1.425952 83.274592 1.41954 absolute
+$attachment "lefteye" "bip_head" 1.425952 83.274592 1.41954 absolute
+
+$cdmaterials "models/player/hvyweapon/"
+$model heavy "parts/dmx/heavy_reference_lo.dmx"{
+
+ eyeball righteye "bip_head" -1.425952 83.274592 1.41954 "eyeball_r" 1.80
+ 356 -1 "pupil_r" 0.6
+ eyeball lefteye "bip_head" 1.425952 83.274592 1.41954 "eyeball_l" 1.80
+ 356 1 "pupil_l" 0.6
+
+ localvar %dummy_eyelid_flex
+
+ flexcontroller eyes range -30 30 eyes_updown
+ flexcontroller eyes range -30 30 eyes_rightleft
+
+}
+
+$model eyeball
+
+(name) Name of eyeball, used to match eyelid rules.
+
+(bone name) Name of bone that the eye is parented to, typically the head.
+
+(X) (Y) (Z) World location of the center of the ball of the eye.
+
+(material name) Material name to use when searching for vertices to consider as the �white� of the eye (used in dynamically texture mapping the iris and cornea onto the eye).
+
+(diameter) Diameter of the ball of the eye
+
+(angle) Default yaw offset from �forward� for iris. Humans are typically 2-4 degrees walleyed. Not setting this correctly will result in your either characters appearing cross-eyed, or if you�ve compensated by misplacing the ball of the eye, them not tracking side to side.
+
+(iris material) no longer used but still in the option list.
+
+(pupil scale) World scale of the iris texture
+[edit]
+Syntax
+
+eyeball (name) (bone name) (X) (Y) (Z) (material name) (diameter) (angle) (iris material) (pupil scale)
+
+*/
+//
+//-----------------------------------------------------------------------------
+class CDmeEyePosition : public CDmeDag
+{
+ DEFINE_ELEMENT( CDmeEyePosition, CDmeDag );
+
+public:
+
+ void GetWorldPosition( Vector &worldPosition );
+};
+
+
+#endif // DMEEYEPOSITION_H
diff --git a/public/movieobjects/dmefaceset.h b/public/movieobjects/dmefaceset.h
new file mode 100644
index 0000000..1028586
--- /dev/null
+++ b/public/movieobjects/dmefaceset.h
@@ -0,0 +1,87 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmegamemodel.h b/public/movieobjects/dmegamemodel.h
new file mode 100644
index 0000000..f794dfa
--- /dev/null
+++ b/public/movieobjects/dmegamemodel.h
@@ -0,0 +1,184 @@
+//========= Copyright 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 "tier1/utldict.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:
+ void AddBone( CDmeTransform* pTransform );
+ void AddBones( studiohdr_t *pStudioHdr, const char *pBaseName, 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 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 );
+
+ const Vector& GetViewTarget() const;
+ void SetViewTarget( const Vector &viewTarget );
+
+ void SetFlags( int nFlags );
+
+ void SetSkin( int nSkin );
+ void SetBody( int nBody );
+ void SetSequence( int nSequence );
+
+ int GetSkin() const;
+ int GetBody() const;
+ int GetSequence() const;
+ const char *GetModelName() const;
+
+ 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;
+
+public:
+ CDmaVar< bool > m_bComputeBounds;
+
+protected:
+ void PopulateExistingDagList( CDmeDag** pDags, int nCount );
+
+ // 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)
+ CDmaVar< Vector > m_viewTarget;
+ CDmaString m_modelName;
+ CDmaVar< int > m_skin;
+ CDmaVar< int > m_body;
+ CDmaVar< int > m_sequence;
+ CDmaVar< int > m_flags;
+
+ // 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;
+};
+
+
+//-----------------------------------------------------------------------------
+// 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< bool > m_bIsPortal2;
+};
+
+#endif // DMEGAMEMODEL_H
diff --git a/public/movieobjects/dmegamemodelinput.h b/public/movieobjects/dmegamemodelinput.h
new file mode 100644
index 0000000..fcd4db9
--- /dev/null
+++ b/public/movieobjects/dmegamemodelinput.h
@@ -0,0 +1,112 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// game model input - gets its values from an MDL within the game
+//
+//=============================================================================
+
+#ifndef DMEGAMEMODELINPUT_H
+#define DMEGAMEMODELINPUT_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "datamodel/dmelement.h"
+#include "datamodel/dmattribute.h"
+#include "datamodel/dmattributevar.h"
+#include "movieobjects/dmeinput.h"
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+class CDmeGameModelInput : public CDmeInput
+{
+ DEFINE_ELEMENT( CDmeGameModelInput, CDmeInput );
+
+public:
+ virtual bool IsDirty(); // ie needs to operate
+ virtual void Operate();
+
+ virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
+
+public:
+ void AddBone( const Vector& pos, const Quaternion& rot );
+ void SetBone( uint index, const Vector& pos, const Quaternion& rot );
+ void SetRootBone( const Vector& pos, const Quaternion& rot );
+ uint NumBones() const;
+
+ void SetFlexWeights( uint nFlexWeights, const float* flexWeights );
+ uint NumFlexWeights() const;
+
+ const Vector& GetViewTarget() const;
+ void SetViewTarget( const Vector &viewTarget );
+
+ void SetFlags( int nFlags );
+
+public:
+ CDmaVar< int > m_skin;
+ CDmaVar< int > m_body;
+ CDmaVar< int > m_sequence;
+ CDmaVar< bool > m_visible;
+
+protected:
+ CDmaVar< int > m_flags;
+ CDmaArray< float > m_flexWeights;
+ CDmaVar< Vector > m_viewTarget;
+ CDmaArray< Vector > m_bonePositions;
+ CDmaArray< Quaternion > m_boneRotations;
+ CDmaVar< Vector > m_position;
+ CDmaVar< Quaternion > m_rotation;
+};
+
+
+class CDmeGameSpriteInput : public CDmeInput
+{
+ DEFINE_ELEMENT( CDmeGameSpriteInput, CDmeInput );
+
+public:
+ virtual bool IsDirty(); // ie needs to operate
+ virtual void Operate();
+
+ virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
+
+public:
+ void SetState( bool bVisible, float nFrame, int nRenderMode, int nRenderFX, float flRenderScale, float flProxyRadius, const Vector &pos, const Quaternion &rot, const Color &color );
+
+protected:
+
+ CDmaVar< bool > m_visible;
+ CDmaVar< float > m_frame;
+ CDmaVar< int > m_rendermode;
+ CDmaVar< int > m_renderfx;
+ CDmaVar< float > m_renderscale;
+ CDmaVar< float > m_proxyRadius;
+ CDmaVar< Vector > m_position;
+ CDmaVar< Quaternion > m_rotation;
+ CDmaVar< Color > m_color;
+};
+
+
+class CDmeGameCameraInput : public CDmeInput
+{
+ DEFINE_ELEMENT( CDmeGameCameraInput, CDmeInput );
+
+public:
+ virtual bool IsDirty(); // ie needs to operate
+ virtual void Operate();
+
+ virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs );
+
+public:
+ void SetPosition( const Vector& pos );
+ void SetOrientation( const Quaternion& rot );
+ void SetFOV( float fov );
+
+protected:
+ CDmaVar< Vector > m_position;
+ CDmaVar< Quaternion > m_rotation;
+ CDmaVar< float > m_fov;
+};
+
+
+#endif // DMEGAMEMODELINPUT_H
diff --git a/public/movieobjects/dmeimage.h b/public/movieobjects/dmeimage.h
new file mode 100644
index 0000000..e30b109
--- /dev/null
+++ b/public/movieobjects/dmeimage.h
@@ -0,0 +1,57 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// A class representing an image
+//
+//=============================================================================
+
+#ifndef DMEIMAGE_H
+#define DMEIMAGE_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "datamodel/dmelement.h"
+
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+enum ImageFormat;
+
+
+//-----------------------------------------------------------------------------
+// A class representing an image (2d or 3d bitmap)
+//-----------------------------------------------------------------------------
+class CDmeImage : public CDmElement
+{
+ DEFINE_ELEMENT( CDmeImage, CDmElement );
+
+public:
+ // Methods related to image format
+ ImageFormat Format() const;
+ const char *FormatName() const;
+
+ // returns a pointer to the image bits buffer
+ const void *ImageBits() const;
+
+public:
+ CDmAttributeVar<int> m_Width;
+ CDmAttributeVar<int> m_Height;
+ CDmAttributeVar<int> m_Depth;
+
+private:
+ CDmAttributeVar<int> m_Format;
+ CDmAttributeVarBinaryBlock m_Bits;
+};
+
+
+//-----------------------------------------------------------------------------
+// returns a pointer to the image bits buffer
+//-----------------------------------------------------------------------------
+inline const void *CDmeImage::ImageBits() const
+{
+ return m_Bits.Get();
+}
+
+
+#endif // DMEIMAGE_H
diff --git a/public/movieobjects/dmeinput.h b/public/movieobjects/dmeinput.h
new file mode 100644
index 0000000..e88b8d4
--- /dev/null
+++ b/public/movieobjects/dmeinput.h
@@ -0,0 +1,28 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmejoint.h b/public/movieobjects/dmejoint.h
new file mode 100644
index 0000000..a862a6b
--- /dev/null
+++ b/public/movieobjects/dmejoint.h
@@ -0,0 +1,39 @@
+//========= Copyright 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
+
+#include "movieobjects/dmedag.h"
+#include "materialsystem/MaterialSystemUtil.h"
+
+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();
+
+ CMaterialReference m_JointMaterial;
+ static bool s_bDrawJoints;
+};
+
+
+#endif // DMEJOINT_H
diff --git a/public/movieobjects/dmekeyboardinput.h b/public/movieobjects/dmekeyboardinput.h
new file mode 100644
index 0000000..c4c6a5f
--- /dev/null
+++ b/public/movieobjects/dmekeyboardinput.h
@@ -0,0 +1,36 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmelight.h b/public/movieobjects/dmelight.h
new file mode 100644
index 0000000..4ec544a
--- /dev/null
+++ b/public/movieobjects/dmelight.h
@@ -0,0 +1,135 @@
+//========= Copyright 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 void SetupRenderState( int nLightIndex );
+ 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:
+ void SetDirection( const Vector &direction );
+ const Vector &GetDirection() const { return m_Direction; }
+
+ // Sets up render state in the material system for rendering
+ virtual bool GetLightDesc( LightDesc_t *pDesc );
+
+private:
+ CDmaVar<Vector> m_Direction;
+};
+
+
+//-----------------------------------------------------------------------------
+// A point light
+//-----------------------------------------------------------------------------
+class CDmePointLight : public CDmeLight
+{
+ DEFINE_ELEMENT( CDmePointLight, CDmeLight );
+
+public:
+ void SetPosition( const Vector &pos ) { m_Position = pos; }
+ const Vector &GetPosition() const { return m_Position; }
+
+ // 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< Vector > m_Position;
+ 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 direction
+ void SetDirection( const Vector &direction );
+
+ // 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<Vector> m_Direction;
+ CDmaVar<float> m_flSpotInnerAngle;
+ CDmaVar<float> m_flSpotOuterAngle;
+ CDmaVar<float> m_flSpotAngularFalloff;
+};
+
+
+//-----------------------------------------------------------------------------
+// An ambient light
+//-----------------------------------------------------------------------------
+class CDmeAmbientLight : public CDmeLight
+{
+ DEFINE_ELEMENT( CDmeAmbientLight, CDmeLight );
+
+public:
+ // Sets up render state in the material system for rendering
+ virtual void SetupRenderState( int nLightIndex );
+};
+
+
+#endif // DMELIGHT_H
diff --git a/public/movieobjects/dmelog.h b/public/movieobjects/dmelog.h
new file mode 100644
index 0000000..a0e85b0
--- /dev/null
+++ b/public/movieobjects/dmelog.h
@@ -0,0 +1,918 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef DMELOG_H
+#define DMELOG_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "datamodel/dmelement.h"
+#include "datamodel/dmattribute.h"
+#include "datamodel/dmattributevar.h"
+#include "datamodel/dmehandle.h"
+#include "interpolatortypes.h"
+#include "movieobjects/timeutils.h"
+#include "movieobjects/dmetimeselectiontimes.h"
+
+class IUniformRandomStream;
+
+template < class T > class CDmeTypedLog;
+
+enum
+{
+ FILTER_SMOOTH = 0,
+ FILTER_JITTER,
+ FILTER_SHARPEN,
+ FILTER_SOFTEN,
+
+ NUM_FILTERS
+};
+
+enum RecordingMode_t
+{
+ RECORD_PRESET = 0, // Preset/fader slider being dragged
+ RECORD_ATTRIBUTESLIDER, // Single attribute slider being dragged
+};
+
+#define DMELOG_DEFAULT_THRESHHOLD 0.0001f
+
+class DmeLog_TimeSelection_t
+{
+public:
+ DmeLog_TimeSelection_t() :
+ m_flIntensity( 1.0f ),
+ m_bAttachedMode( true ),
+ m_bTimeAdvancing( false ),
+ m_bResampleMode( true ),
+ m_nResampleInterval( DmeTime_t( .05f ) ),// 50 msec sampling interval by default
+ m_flThreshold( DMELOG_DEFAULT_THRESHHOLD ),
+ m_pPresetValue( 0 ),
+ m_RecordingMode( RECORD_PRESET )
+ {
+ m_nTimes[ TS_LEFT_FALLOFF ] = m_nTimes[ TS_LEFT_HOLD ] =
+ m_nTimes[ TS_RIGHT_HOLD ] = m_nTimes[ TS_RIGHT_FALLOFF ] = DmeTime_t( 0 );
+ m_nFalloffInterpolatorTypes[ 0 ] = m_nFalloffInterpolatorTypes[ 1 ] = INTERPOLATE_LINEAR_INTERP;
+ }
+
+ inline void ResetTimeAdvancing()
+ {
+ // Reset the time advancing flag
+ m_bTimeAdvancing = false;
+ }
+
+ inline void StartTimeAdvancing()
+ {
+ m_bTimeAdvancing = true;
+ }
+
+ inline bool IsTimeAdvancing() const
+ {
+ return m_bTimeAdvancing;
+ }
+
+ inline RecordingMode_t GetRecordingMode() const
+ {
+ return m_RecordingMode;
+ }
+
+ void SetRecordingMode( RecordingMode_t mode )
+ {
+ m_RecordingMode = mode;
+ }
+
+ float GetAmountForTime( DmeTime_t curtime ) const;
+ float AdjustFactorForInterpolatorType( float factor, int side ) const;
+
+ // NOTE: See DmeTimeSelectionTimes_t for return values, 0 means before, 1= left fallof, 2=hold, 3=right falloff, 4=after
+ int ComputeRegionForTime( DmeTime_t curtime ) const;
+
+ DmeTime_t m_nTimes[ TS_TIME_COUNT ];
+ int m_nFalloffInterpolatorTypes[ 2 ];
+ DmeTime_t m_nResampleInterval; // Only used if m_bResampleMode is true
+ float m_flIntensity; // How much to drive values toward m_HeadValue (generally 1.0f)
+ float m_flThreshold;
+ CDmAttribute* m_pPresetValue;
+
+ bool m_bAttachedMode : 1; // Is the current time "attached" to the head position
+
+ // Adds new, evenly spaced samples based on m_nResampleInterval
+ // Also adds zero intensity samples at the falloff edges
+ bool m_bResampleMode : 1;
+
+private:
+ bool m_bTimeAdvancing : 1; // Has time ever been advancing
+ RecordingMode_t m_RecordingMode;
+};
+
+class CDmeChannel;
+class CDmeChannelsClip;
+class CDmeFilmClip;
+class CDmeLog;
+class CDmeLogLayer;
+
+struct LayerSelectionData_t
+{
+ LayerSelectionData_t();
+ void Release();
+
+ CDmeHandle< CDmeChannel > m_hChannel;
+ CDmeHandle< CDmeChannelsClip > m_hOwner;
+ CDmeHandle< CDmeFilmClip > m_hShot;
+ CDmeHandle< CDmeLog > m_hLog;
+ DmAttributeType_t m_DataType;
+ int m_nDuration;
+ int m_nHoldTimes[ 2 ];
+ DmeTime_t m_tStartOffset;
+
+ // This is dynamic and needs to be released
+ struct DataLayer_t
+ {
+ DataLayer_t( float frac, CDmeLogLayer *layer );
+
+ float m_flStartFraction;
+ CDmeHandle< CDmeLogLayer, true > m_hData;
+ };
+
+ CUtlVector< DataLayer_t > m_vecData;
+};
+
+//-----------------------------------------------------------------------------
+// CDmeLogLayer - abstract base class
+//-----------------------------------------------------------------------------
+abstract_class CDmeLogLayer : public CDmElement
+{
+ friend class CDmeLog;
+
+ DEFINE_ELEMENT( CDmeLogLayer, CDmElement );
+
+public:
+ virtual void CopyLayer( const CDmeLogLayer *src ) = 0;
+ virtual void CopyPartialLayer( const CDmeLogLayer *src, DmeTime_t startTime, DmeTime_t endTime, bool bRebaseTimestamps ) = 0;
+ virtual void ExplodeLayer( const CDmeLogLayer *src, DmeTime_t startTime, DmeTime_t endTime, bool bRebaseTimestamps, DmeTime_t tResampleInterval ) = 0;
+ virtual void InsertKeyFromLayer( DmeTime_t keyTime, const CDmeLogLayer *src, DmeTime_t srcKeyTime ) = 0;
+
+ DmeTime_t GetBeginTime() const;
+ DmeTime_t GetEndTime() const;
+ int GetKeyCount() const;
+
+ // Returns the index of a key closest to this time, within tolerance
+ // NOTE: Insertion or removal may change this index!
+ // Returns -1 if the time isn't within tolerance.
+ int FindKeyWithinTolerance( DmeTime_t time, DmeTime_t nTolerance );
+
+ // Returns the type of attribute being logged
+ virtual DmAttributeType_t GetDataType() const = 0;
+
+ // Sets a key, removes all keys after this time
+ virtual void SetKey( DmeTime_t time, const CDmAttribute *pAttr, uint index = 0, int curveType = CURVE_DEFAULT ) = 0;
+ virtual bool SetDuplicateKeyAtTime( DmeTime_t time ) = 0;
+ // This inserts a key using the current values to construct the proper value for the time
+ virtual int InsertKeyAtTime( DmeTime_t nTime, int curveType = CURVE_DEFAULT ) = 0;
+
+ // Sets the interpolated value of the log at the specified time into the attribute
+ virtual void GetValue( DmeTime_t time, CDmAttribute *pAttr, uint index = 0 ) const = 0;
+
+ virtual float GetComponent( DmeTime_t time, int componentIndex ) const = 0;
+
+ // Returns the time at which a particular key occurs
+ DmeTime_t GetKeyTime( int nKeyIndex ) const;
+ void SetKeyTime( int nKeyIndex, DmeTime_t keyTime );
+
+ // Scale + bias key times
+ void ScaleBiasKeyTimes( double flScale, DmeTime_t nBias );
+
+ // Removes a single key by index
+ virtual void RemoveKey( int nKeyIndex, int nNumKeysToRemove = 1 ) = 0;
+
+ // Removes all keys
+ virtual void ClearKeys() = 0;
+
+ virtual bool IsConstantValued() const = 0;
+ virtual void RemoveRedundantKeys() = 0;
+ virtual void RemoveRedundantKeys( float threshold ) = 0;
+
+ // resampling and filtering
+ virtual void Resample( DmeFramerate_t samplerate ) = 0;
+ virtual void Filter( int nSampleRadius ) = 0;
+ virtual void Filter2( DmeTime_t sampleRadius ) = 0;
+
+ virtual void SetOwnerLog( CDmeLog *owner ) = 0;
+ CDmeLog *GetOwnerLog();
+ const CDmeLog *GetOwnerLog() const;
+
+ bool IsUsingCurveTypes() const;
+ int GetDefaultCurveType() const;
+
+ // Override curvetype for specific key
+ void SetKeyCurveType( int nKeyIndex, int curveType );
+ int GetKeyCurveType( int nKeyIndex ) const;
+
+ // Validates that all keys are correctly sorted in time
+ bool ValidateKeys() const;
+
+ // Removes all keys outside the specified time range
+ void RemoveKeysOutsideRange( DmeTime_t tStart, DmeTime_t tEnd );
+
+protected:
+ int FindKey( DmeTime_t time ) const;
+
+ void OnUsingCurveTypesChanged();
+
+ CDmeLog *m_pOwnerLog;
+
+ mutable int m_lastKey;
+ CDmaArray< int > m_times;
+ CDmaArray< int > m_CurveTypes;
+};
+
+template< class T >
+CDmeLogLayer *CreateLayer( CDmeTypedLog< T > *ownerLog );
+
+
+//-----------------------------------------------------------------------------
+// CDmeLogLayer - abstract base class
+//-----------------------------------------------------------------------------
+abstract_class CDmeCurveInfo : public CDmElement
+{
+ DEFINE_ELEMENT( CDmeCurveInfo, CDmElement );
+
+public:
+ // Global override for all keys unless overriden by specific key
+ void SetDefaultCurveType( int curveType );
+ int GetDefaultCurveType() const;
+
+ void SetMinValue( float val );
+ float GetMinValue() const;
+ void SetMaxValue( float val );
+ float GetMaxValue() const;
+
+protected:
+ CDmaVar< int > m_DefaultCurveType;
+
+ CDmaVar< float > m_MinValue;
+ CDmaVar< float > m_MaxValue;
+};
+
+template <class T > class CDmeTypedLogLayer;
+
+//-----------------------------------------------------------------------------
+// CDmeLog - abstract base class
+//-----------------------------------------------------------------------------
+abstract_class CDmeLog : public CDmElement
+{
+ DEFINE_ELEMENT( CDmeLog, CDmElement );
+
+public:
+ int FindLayerForTime( DmeTime_t time ) const;
+ int FindLayerForTimeSkippingTopmost( DmeTime_t time ) const;
+ void FindLayersForTime( DmeTime_t time, CUtlVector< int >& list ) const;
+
+ virtual void FinishTimeSelection( DmeTime_t tHeadPosition, DmeLog_TimeSelection_t& params ) = 0; // in attached, timeadvancing mode, we need to blend out of the final sample over the fadeout interval
+ virtual void StampKeyAtHead( DmeTime_t tHeadPosition, DmeTime_t tPreviousHeadPosition, const DmeLog_TimeSelection_t& params, const CDmAttribute *pAttr, uint index = 0 ) = 0;
+ virtual void FilterUsingTimeSelection( IUniformRandomStream *random, float flScale, const DmeLog_TimeSelection_t& params, int filterType, bool bResample, bool bApplyFalloff, const CDmeLogLayer *baseLayer, CDmeLogLayer *writeLayer ) = 0;
+ virtual void FilterUsingTimeSelection( IUniformRandomStream *random, const DmeLog_TimeSelection_t& params, int filterType, bool bResample, bool bApplyFalloff ) = 0;
+ virtual void StaggerUsingTimeSelection( const DmeLog_TimeSelection_t& params, DmeTime_t tStaggerAmount, const CDmeLogLayer *baseLayer, CDmeLogLayer *writeLayer ) = 0;
+ virtual void RevealUsingTimeSelection( const DmeLog_TimeSelection_t &params, CDmeLogLayer *savedLayer ) = 0;
+ virtual void BlendLayersUsingTimeSelection( const DmeLog_TimeSelection_t &params ) = 0;
+ virtual void BlendLayersUsingTimeSelection( const CDmeLogLayer *firstLayer, const CDmeLogLayer *secondLayer, CDmeLogLayer *outputLayer, const DmeLog_TimeSelection_t &params, bool bUseBaseLayerSamples, DmeTime_t tStartOffset ) = 0;
+ virtual void BlendTimesUsingTimeSelection( const CDmeLogLayer *firstLayer, const CDmeLogLayer *secondLayer, CDmeLogLayer *outputLayer, const DmeLog_TimeSelection_t &params, DmeTime_t tStartOffset ) = 0;
+ virtual void PasteAndRescaleSamples( const CDmeLogLayer *src, const DmeLog_TimeSelection_t& srcParams, const DmeLog_TimeSelection_t& destParams, bool bBlendAreaInFalloffRegion ) = 0;
+ virtual void PasteAndRescaleSamples( const CDmeLogLayer *pBaseLayer, const CDmeLogLayer *pDataLayer, CDmeLogLayer *pOutputLayer, const DmeLog_TimeSelection_t& srcParams, const DmeLog_TimeSelection_t& destParams, bool bBlendAreaInFalloffRegion ) = 0;
+ virtual void BuildNormalizedLayer( CDmeTypedLogLayer< float > *target ) = 0;
+ virtual void BuildCorrespondingLayer( const CDmeLogLayer *pReferenceLayer, const CDmeLogLayer *pDataLayer, CDmeLogLayer *pOutputLayer ) = 0;
+
+ int GetTopmostLayer() const;
+ int GetNumLayers() const;
+ CDmeLogLayer *GetLayer( int index );
+ const CDmeLogLayer *GetLayer( int index ) const;
+
+ DmeTime_t GetBeginTime() const;
+ DmeTime_t GetEndTime() const;
+ int GetKeyCount() const;
+
+ bool IsEmpty() const;
+
+ // Returns the index of a key closest to this time, within tolerance
+ // NOTE: Insertion or removal may change this index!
+ // Returns -1 if the time isn't within tolerance.
+ virtual int FindKeyWithinTolerance( DmeTime_t time, DmeTime_t nTolerance ) = 0;
+
+ // Returns the type of attribute being logged
+ virtual DmAttributeType_t GetDataType() const = 0;
+
+ // Sets a key, removes all keys after this time
+ virtual void SetKey( DmeTime_t time, const CDmAttribute *pAttr, uint index = 0, int curveType = CURVE_DEFAULT ) = 0;
+ virtual bool SetDuplicateKeyAtTime( DmeTime_t time ) = 0;
+ virtual int InsertKeyAtTime( DmeTime_t nTime, int curveType = CURVE_DEFAULT ) = 0;
+ // Sets the interpolated value of the log at the specified time into the attribute
+ virtual void GetValue( DmeTime_t time, CDmAttribute *pAttr, uint index = 0 ) const = 0;
+ virtual void GetValueSkippingTopmostLayer( DmeTime_t time, CDmAttribute *pAttr, uint index = 0 ) const = 0;
+
+ virtual float GetComponent( DmeTime_t time, int componentIndex ) const = 0;
+
+ // Returns the time at which a particular key occurs
+ virtual DmeTime_t GetKeyTime( int nKeyIndex ) const = 0;
+ virtual void SetKeyTime( int nKeyIndex, DmeTime_t keyTime ) = 0;
+
+ // Override curvetype for specific key
+ void SetKeyCurveType( int nKeyIndex, int curveType );
+ int GetKeyCurveType( int nKeyIndex ) const;
+
+ // Removes a single key by index
+ virtual void RemoveKey( int nKeyIndex, int nNumKeysToRemove = 1 ) = 0;
+
+ // Removes all keys within the time range, returns true if keys were removed
+ bool RemoveKeys( DmeTime_t tStartTime, DmeTime_t tEndTime );
+
+ // Removes all keys
+ virtual void ClearKeys() = 0;
+
+ // Scale + bias key times
+ void ScaleBiasKeyTimes( double flScale, DmeTime_t nBias );
+
+ virtual float GetValueThreshold() const = 0;
+ virtual void SetValueThreshold( float thresh ) = 0;
+ virtual bool IsConstantValued() const = 0;
+ virtual void RemoveRedundantKeys() = 0;
+ virtual void RemoveRedundantKeys( float threshold ) = 0;
+
+ // resampling and filtering
+ virtual void Resample( DmeFramerate_t samplerate ) = 0;
+ virtual void Filter( int nSampleRadius ) = 0;
+ virtual void Filter2( DmeTime_t sampleRadius ) = 0;
+
+ // Creates a log of a requested type
+ static CDmeLog *CreateLog( DmAttributeType_t type, DmFileId_t fileid );
+
+ virtual CDmeLogLayer *AddNewLayer() = 0;
+ enum
+ {
+ FLATTEN_NODISCONTINUITY_FIXUP = (1<<0), // Don't add "helper" samples to preserve discontinuities. This occurs when the time selection is "detached" from the head position
+ FLATTEN_SPEW = (1<<1),
+ };
+ virtual void FlattenLayers( float threshold, int flags ) = 0;
+
+ // Only used by undo system!!!
+ virtual void AddLayerToTail( CDmeLogLayer *layer ) = 0;
+ virtual CDmeLogLayer *RemoveLayerFromTail() = 0;
+ virtual CDmeLogLayer *RemoveLayer( int iLayer ) = 0;
+
+
+ // Resolve
+ virtual void Resolve();
+
+ // curve info helpers
+ bool IsUsingCurveTypes() const;
+ const CDmeCurveInfo *GetCurveInfo() const;
+ CDmeCurveInfo *GetCurveInfo();
+ virtual CDmeCurveInfo *GetOrCreateCurveInfo() = 0;
+ virtual void SetCurveInfo( CDmeCurveInfo *pCurveInfo ) = 0;
+
+ // accessors for CurveInfo data
+ int GetDefaultCurveType() const;
+
+ // FIXME - this should really be in the CurveInfo
+ // but the animset editor currently asks for these, without having set a curveinfo...
+ void SetMinValue( float val );
+ void SetMaxValue( float val );
+ float GetMinValue() const;
+ float GetMaxValue() const;
+
+ virtual bool HasDefaultValue() const = 0;
+
+
+protected:
+// int FindKey( DmeTime_t time ) const;
+
+ void OnUsingCurveTypesChanged();
+
+ virtual void OnAttributeChanged( CDmAttribute *pAttribute );
+
+ CDmaElementArray< CDmeLogLayer > m_Layers;
+ CDmaElement< CDmeCurveInfo > m_CurveInfo;
+};
+
+
+
+//-----------------------------------------------------------------------------
+// CDmeTypedCurveInfo - implementation class for all logs
+//-----------------------------------------------------------------------------
+template< class T >
+class CDmeTypedCurveInfo : public CDmeCurveInfo
+{
+ DEFINE_ELEMENT( CDmeTypedCurveInfo, CDmeCurveInfo );
+
+public:
+ // For "faceposer" style left/right edges, this controls whether interpolators try to mimic faceposer left/right edge behavior
+ void SetUseEdgeInfo( bool state );
+ bool IsUsingEdgeInfo() const;
+
+ void SetEdgeInfo( int edge, bool active, const T& val, int curveType );
+ void GetEdgeInfo( int edge, bool& active, T& val, int& curveType ) const;
+
+ void SetDefaultEdgeZeroValue( const T& val );
+ const T& GetDefaultEdgeZeroValue() const;
+
+ void SetRightEdgeTime( DmeTime_t time );
+ DmeTime_t GetRightEdgeTime() const;
+
+ bool IsEdgeActive( int edge ) const;
+ void GetEdgeValue( int edge, T& value ) const;
+
+ int GetEdgeCurveType( int edge ) const;
+ void GetZeroValue( int side, T& val ) const;
+
+protected:
+ CDmaVar< bool > m_bUseEdgeInfo;
+ // Array of 2 for left/right edges...
+ CDmaVar< bool > m_bEdgeActive[ 2 ];
+ CDmaVar< T > m_EdgeValue[ 2 ];
+ CDmaVar< int > m_EdgeCurveType[ 2 ];
+ CDmaVar< int > m_RightEdgeTime;
+ CDmaVar< T > m_DefaultEdgeValue;
+};
+
+
+// forward declaration
+template< class T > class CDmeTypedLog;
+
+
+//-----------------------------------------------------------------------------
+// CDmeTypedLogLayer - implementation class for all logs
+//-----------------------------------------------------------------------------
+template< class T >
+class CDmeTypedLogLayer : public CDmeLogLayer
+{
+ DEFINE_ELEMENT( CDmeTypedLogLayer, CDmeLogLayer );
+
+public:
+ virtual void CopyLayer( const CDmeLogLayer *src );
+ virtual void CopyPartialLayer( const CDmeLogLayer *src, DmeTime_t startTime, DmeTime_t endTime, bool bRebaseTimestamps );
+ virtual void ExplodeLayer( const CDmeLogLayer *src, DmeTime_t startTime, DmeTime_t endTime, bool bRebaseTimestamps, DmeTime_t tResampleInterval );
+ virtual void InsertKeyFromLayer( DmeTime_t keyTime, const CDmeLogLayer *src, DmeTime_t srcKeyTime );
+
+ // Finds a key within tolerance, or adds one. Unlike SetKey, this will *not* delete keys after the specified time
+ int FindOrAddKey( DmeTime_t nTime, DmeTime_t nTolerance, const T& value, int curveType = CURVE_DEFAULT );
+
+ // Sets a key, removes all keys after this time
+ void SetKey( DmeTime_t time, const T& value, int curveType = CURVE_DEFAULT );
+ // This inserts a key using the current values to construct the proper value for the time
+ virtual int InsertKeyAtTime( DmeTime_t nTime, int curveType = CURVE_DEFAULT );
+
+ void SetKeyValue( int nKey, const T& value );
+
+ const T& GetValue( DmeTime_t time ) const;
+
+ const T& GetKeyValue( int nKeyIndex ) const;
+ const T& GetValueSkippingKey( int nKeyToSkip ) const;
+
+ // This inserts a key. Unlike SetKey, this will *not* delete keys after the specified time
+ int InsertKey( DmeTime_t nTime, const T& value, int curveType = CURVE_DEFAULT );
+
+ // inherited from CDmeLog
+ virtual void ClearKeys();
+ virtual void SetKey( DmeTime_t time, const CDmAttribute *pAttr, uint index = 0, int curveType = CURVE_DEFAULT );
+ virtual bool SetDuplicateKeyAtTime( DmeTime_t time );
+ virtual void GetValue( DmeTime_t time, CDmAttribute *pAttr, uint index = 0 ) const;
+ virtual float GetComponent( DmeTime_t time, int componentIndex ) const;
+ virtual DmAttributeType_t GetDataType() const;
+ virtual bool IsConstantValued() const;
+ virtual void RemoveRedundantKeys();
+ virtual void RemoveRedundantKeys( float threshold );
+
+ virtual void RemoveKey( int nKeyIndex, int nNumKeysToRemove = 1 );
+ virtual void Resample( DmeFramerate_t samplerate );
+ virtual void Filter( int nSampleRadius );
+ virtual void Filter2( DmeTime_t sampleRadius );
+
+ void RemoveKeys( DmeTime_t starttime );
+
+ // curve info helpers
+ const CDmeTypedCurveInfo< T > *GetTypedCurveInfo() const;
+ CDmeTypedCurveInfo< T > *GetTypedCurveInfo();
+
+ bool IsUsingEdgeInfo() const;
+ void GetEdgeInfo( int edge, bool& active, T& val, int& curveType ) const;
+ const T& GetDefaultEdgeZeroValue() const;
+ DmeTime_t GetRightEdgeTime() const;
+
+ void SetOwnerLog( CDmeLog *owner );
+
+ CDmeTypedLog< T > *GetTypedOwnerLog();
+ const CDmeTypedLog< T > *GetTypedOwnerLog() const;
+
+protected:
+
+ int GetEdgeCurveType( int edge ) const;
+ void GetZeroValue( int side, T& val ) const;
+
+ void GetValueUsingCurveInfo( DmeTime_t time, T& out ) const;
+ void GetValueUsingCurveInfoSkippingKey( int nKeyToSkip, T& out ) const;
+ void GetBoundedSample( int keyindex, DmeTime_t& time, T& val, int& curveType ) const;
+
+ void CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< T > *output );
+
+ friend CDmeTypedLog< T >;
+
+protected:
+ CDmaArray< T > m_values;
+};
+
+
+//-----------------------------------------------------------------------------
+// CDmeTypedLog - implementation class for all logs
+//-----------------------------------------------------------------------------
+template< class T >
+class CDmeTypedLog : public CDmeLog
+{
+ DEFINE_ELEMENT( CDmeTypedLog, CDmeLog );
+
+public:
+
+ virtual void OnAttributeArrayElementAdded( CDmAttribute *pAttribute, int nFirstElem, int nLastElem );
+
+ CDmeTypedLogLayer< T > *GetLayer( int index );
+ const CDmeTypedLogLayer< T > *GetLayer( int index ) const;
+
+ void StampKeyAtHead( DmeTime_t tHeadPosition, DmeTime_t tPreviousHeadPosition, const DmeLog_TimeSelection_t& params, const T& value );
+ void StampKeyAtHead( DmeTime_t tHeadPosition, DmeTime_t tPreviousHeadPosition, const DmeLog_TimeSelection_t& params, const CDmAttribute *pAttr, uint index = 0 );
+ void FinishTimeSelection( DmeTime_t tHeadPosition, DmeLog_TimeSelection_t& params ); // in attached, timeadvancing mode, we need to blend out of the final sample over the fadeout interval
+ void FilterUsingTimeSelection( IUniformRandomStream *random, float flScale, const DmeLog_TimeSelection_t& params, int filterType, bool bResample, bool bApplyFalloff, const CDmeLogLayer *baseLayer, CDmeLogLayer *writeLayer );
+ void FilterUsingTimeSelection( IUniformRandomStream *random, const DmeLog_TimeSelection_t& params, int filterType, bool bResample, bool bApplyFalloff );
+ void StaggerUsingTimeSelection( const DmeLog_TimeSelection_t& params, DmeTime_t tStaggerAmount, const CDmeLogLayer *baseLayer, CDmeLogLayer *writeLayer );
+ void RevealUsingTimeSelection( const DmeLog_TimeSelection_t &params, CDmeLogLayer *savedLayer );
+ void BlendLayersUsingTimeSelection( const DmeLog_TimeSelection_t &params );
+ void BlendLayersUsingTimeSelection( const CDmeLogLayer *firstLayer, const CDmeLogLayer *secondLayer, CDmeLogLayer *outputLayer, const DmeLog_TimeSelection_t &params, bool bUseBaseLayerSamples, DmeTime_t tStartOffset );
+ void BlendTimesUsingTimeSelection( const CDmeLogLayer *firstLayer, const CDmeLogLayer *secondLayer, CDmeLogLayer *outputLayer, const DmeLog_TimeSelection_t &params, DmeTime_t tStartOffset );
+
+ virtual void PasteAndRescaleSamples( const CDmeLogLayer *src, const DmeLog_TimeSelection_t& srcParams, const DmeLog_TimeSelection_t& destParams, bool bBlendAreaInFalloffRegion );
+ virtual void PasteAndRescaleSamples( const CDmeLogLayer *pBaseLayer, const CDmeLogLayer *pDataLayer, CDmeLogLayer *pOutputLayer, const DmeLog_TimeSelection_t& srcParams, const DmeLog_TimeSelection_t& destParams, bool bBlendAreaInFalloffRegion );
+ virtual void BuildCorrespondingLayer( const CDmeLogLayer *pReferenceLayer, const CDmeLogLayer *pDataLayer, CDmeLogLayer *pOutputLayer );
+
+ virtual void BuildNormalizedLayer( CDmeTypedLogLayer< float > *target );
+
+ // Finds a key within tolerance, or adds one. Unlike SetKey, this will *not* delete keys after the specified time
+ int FindOrAddKey( DmeTime_t nTime, DmeTime_t nTolerance, const T& value, int curveType = CURVE_DEFAULT );
+
+ // Sets a key, removes all keys after this time
+ void SetKey( DmeTime_t time, const T& value, int curveType = CURVE_DEFAULT );
+ int InsertKeyAtTime( DmeTime_t nTime, int curveType = CURVE_DEFAULT );
+ bool ValuesDiffer( const T& a, const T& b ) const;
+ const T& GetValue( DmeTime_t time ) const;
+ const T& GetValueSkippingTopmostLayer( DmeTime_t time ) const;
+
+ const T& GetKeyValue( int nKeyIndex ) const;
+
+ // This inserts a key. Unlike SetKey, this will *not* delete keys after the specified time
+ int InsertKey( DmeTime_t nTime, const T& value, int curveType = CURVE_DEFAULT );
+
+ // inherited from CDmeLog
+ virtual void ClearKeys();
+ virtual void SetKey( DmeTime_t time, const CDmAttribute *pAttr, uint index = 0, int curveType = CURVE_DEFAULT );
+ virtual bool SetDuplicateKeyAtTime( DmeTime_t time );
+ virtual void GetValue( DmeTime_t time, CDmAttribute *pAttr, uint index = 0 ) const;
+ virtual void GetValueSkippingTopmostLayer( DmeTime_t time, CDmAttribute *pAttr, uint index = 0 ) const;
+ virtual float GetComponent( DmeTime_t time, int componentIndex ) const;
+ virtual DmAttributeType_t GetDataType() const;
+ virtual float GetValueThreshold() const { return m_threshold; }
+ virtual void SetValueThreshold( float thresh );
+ virtual bool IsConstantValued() const;
+ virtual void RemoveRedundantKeys();
+ virtual void RemoveRedundantKeys( float threshold );
+ virtual void RemoveKey( int nKeyIndex, int nNumKeysToRemove = 1 );
+ virtual void Resample( DmeFramerate_t samplerate );
+ virtual void Filter( int nSampleRadius );
+ virtual void Filter2( DmeTime_t sampleRadius );
+
+ virtual int FindKeyWithinTolerance( DmeTime_t time, DmeTime_t nTolerance );
+ virtual DmeTime_t GetKeyTime( int nKeyIndex ) const;
+ virtual void SetKeyTime( int nKeyIndex, DmeTime_t keyTime );
+
+ virtual CDmeLogLayer *AddNewLayer();
+ virtual void FlattenLayers( float threshhold, int flags );
+
+ // Only used by undo system!!!
+ virtual void AddLayerToTail( CDmeLogLayer *layer );
+ virtual CDmeLogLayer *RemoveLayerFromTail();
+ virtual CDmeLogLayer *RemoveLayer( int iLayer );
+
+ // curve info helpers
+ const CDmeTypedCurveInfo< T > *GetTypedCurveInfo() const;
+ CDmeTypedCurveInfo< T > *GetTypedCurveInfo();
+ virtual CDmeCurveInfo *GetOrCreateCurveInfo();
+ virtual void SetCurveInfo( CDmeCurveInfo *pCurveInfo );
+
+ // For "faceposer" style left/right edges, this controls whether interpolators try to mimic faceposer left/right edge behavior
+ void SetUseEdgeInfo( bool state );
+ bool IsUsingEdgeInfo() const;
+
+ void SetEdgeInfo( int edge, bool active, const T& val, int curveType );
+ void GetEdgeInfo( int edge, bool& active, T& val, int& curveType ) const;
+
+ void SetDefaultEdgeZeroValue( const T& val );
+ const T& GetDefaultEdgeZeroValue() const;
+
+ void SetRightEdgeTime( DmeTime_t time );
+ DmeTime_t GetRightEdgeTime() const;
+
+ bool IsEdgeActive( int edge ) const;
+ void GetEdgeValue( int edge, T& value ) const;
+
+ int GetEdgeCurveType( int edge ) const;
+ void GetZeroValue( int side, T& val ) const;
+
+ T ClampValue( const T& value );
+
+ void SetDefaultValue( const T& value );
+ const T& GetDefaultValue() const;
+ bool HasDefaultValue() const;
+ void ClearDefaultValue();
+
+ static void SetDefaultValueThreshold( float thresh );
+ static float GetDefaultValueThreshold();
+
+ static float s_defaultThreshold;
+
+protected:
+ void RemoveKeys( DmeTime_t starttime );
+
+ void _StampKeyAtHeadResample( DmeTime_t tHeadPosition, const DmeLog_TimeSelection_t & params, const T& value, bool bSkipToHead, bool bClearPreviousKeys );
+ void _StampKeyAtHeadFilteredByTimeSelection( DmeTime_t tHeadPosition, DmeTime_t tPreviousHeadPosition, const DmeLog_TimeSelection_t & params, const T& value );
+ void _StampKeyFilteredByTimeSelection( CDmeTypedLogLayer< T > *pWriteLayer, DmeTime_t t, const DmeLog_TimeSelection_t &params, const T& value, bool bForce = false );
+
+protected:
+ // this really only makes sense for some of our subclasses, basically those which have float data
+ // anything else's threshhold is almost certainly 0, and that class just ignores m_threshold
+ float m_threshold;
+
+ CDmaVar< bool > m_UseDefaultValue;
+ CDmaVar< T > m_DefaultValue;
+};
+
+
+//-----------------------------------------------------------------------------
+// Template methods
+//-----------------------------------------------------------------------------
+template< class T >
+DmAttributeType_t CDmeTypedLogLayer<T>::GetDataType() const
+{
+ return CDmAttributeInfo< T >::AttributeType();
+}
+
+template< class T >
+bool CDmeTypedLogLayer<T>::IsConstantValued() const
+{
+ if ( m_values.Count() < 2 )
+ return true;
+
+ if ( m_values.Count() == 2 && !GetTypedOwnerLog()->ValuesDiffer( m_values[ 0 ], m_values[ 1 ] ) )
+ return true;
+
+ // we're throwing away duplicate values during recording, so this is generally correct
+ // although there are paths to set keys that don't use the duplicate test, so it's not 100%
+ return false;
+}
+
+//-----------------------------------------------------------------------------
+// Template methods
+//-----------------------------------------------------------------------------
+template< class T >
+DmAttributeType_t CDmeTypedLog<T>::GetDataType() const
+{
+ return CDmAttributeInfo< T >::AttributeType();
+}
+
+template< class T >
+void CDmeTypedLog<T>::SetDefaultValueThreshold( float thresh )
+{
+ s_defaultThreshold = thresh;
+}
+
+template< class T >
+float CDmeTypedLog<T>::GetDefaultValueThreshold()
+{
+ return s_defaultThreshold;
+}
+
+template< class T >
+void CDmeTypedLog<T>::SetValueThreshold( float thresh )
+{
+ m_threshold = thresh;
+}
+
+template< class T >
+bool CDmeTypedLog<T>::IsConstantValued() const
+{
+ int c = m_Layers.Count();
+ for ( int i = 0; i < c; ++i )
+ {
+ if ( !GetLayer( i )->IsConstantValued() )
+ return false;
+ }
+
+ return true;
+}
+
+template< class T >
+void CDmeTypedLog<T>::RemoveRedundantKeys()
+{
+ int bestLayer = GetTopmostLayer();
+ if ( bestLayer < 0 )
+ return;
+
+ GetLayer( bestLayer )->RemoveRedundantKeys();
+}
+
+template< class T >
+inline float Normalize( const T& val )
+{
+ Assert( 0 );
+ return 0.5f;
+}
+
+// AT_INT
+// AT_FLOAT
+// AT_VECTOR*
+
+template<>
+inline float Normalize( const bool& val )
+{
+ return val ? 1.0f : 0.0f;
+}
+
+template<>
+inline float Normalize( const Color& val )
+{
+ float sum = 0.0f;
+ for ( int i = 0 ; i < 4; ++i )
+ {
+ sum += val[ i ];
+ }
+ sum /= 4.0f;
+ return clamp( sum / 255.0f, 0.0f, 1.0f );
+}
+
+template<>
+inline float Normalize( const QAngle& val )
+{
+ float sum = 0.0f;
+ for ( int i = 0 ; i < 3; ++i )
+ {
+ float ang = val[ i ];
+ if ( ang < 0.0f )
+ {
+ ang += 360.0f;
+ }
+
+ sum += ang;
+ }
+ return clamp( ( sum / 3.0f ) / 360.0f, 0.0f, 1.0f );
+}
+
+template<>
+inline float Normalize( const Quaternion& val )
+{
+ QAngle angle;
+ QuaternionAngles( val, angle );
+ return Normalize( angle );
+}
+
+template< class T >
+inline void CDmeTypedLog< T >::BuildNormalizedLayer( CDmeTypedLogLayer< float > *pTarget )
+{
+ Assert( pTarget );
+ Assert( GetDataType() != AT_FLOAT );
+
+ CDmeTypedLogLayer< T > *pBaseLayer = static_cast< CDmeTypedLogLayer< T > * >( GetLayer( 0 ) );
+ if ( !pBaseLayer )
+ return;
+
+ int kc = pBaseLayer->GetKeyCount();
+ for ( int i = 0; i < kc; ++i )
+ {
+ DmeTime_t tKeyTime = pBaseLayer->GetKeyTime( i );
+ T keyValue = pBaseLayer->GetKeyValue( i );
+ float flNormalized = Normalize( keyValue );
+
+ pTarget->InsertKey( tKeyTime, flNormalized );
+ }
+
+ if ( HasDefaultValue() )
+ {
+ pTarget->GetTypedOwnerLog()->SetDefaultValue( Normalize( GetDefaultValue() ) );
+ }
+}
+
+// Generic implementations all stubbed
+// Forward declare specific typed instantiations for float types
+
+template< class T > T CDmeTypedLog< T >::ClampValue( const T& value ) { return value; }
+template<> float CDmeTypedLog< float >::ClampValue( const float& value );
+
+
+template< class T > void CDmeTypedCurveInfo< T >::GetZeroValue( int side, T& val ) const{ Assert( 0 ); }
+template< class T > bool CDmeTypedCurveInfo< T >::IsEdgeActive( int edge ) const{ Assert( 0 ); return false; }
+template< class T > void CDmeTypedCurveInfo< T >::GetEdgeValue( int edge, T &value ) const{ Assert( 0 ); }
+
+template<> void CDmeTypedCurveInfo< float >::GetZeroValue( int side, float& val ) const;
+template<> bool CDmeTypedCurveInfo< float >::IsEdgeActive( int edge ) const;
+template<> void CDmeTypedCurveInfo< float >::GetEdgeValue( int edge, float &value ) const;
+
+template<> void CDmeTypedCurveInfo< Vector >::GetZeroValue( int side, Vector& val ) const;
+template<> void CDmeTypedCurveInfo< Quaternion >::GetZeroValue( int side, Quaternion& val ) const;
+
+template< class T > void CDmeTypedLogLayer< T >::GetValueUsingCurveInfo( DmeTime_t time, T& out ) const { Assert( 0 ); }
+template< class T > void CDmeTypedLogLayer< T >::GetValueUsingCurveInfoSkippingKey( int nKeyToSkip, T& out ) const { Assert( 0 ); }
+template<> void CDmeTypedLogLayer< float >::GetValueUsingCurveInfo( DmeTime_t time, float& out ) const;
+template<> void CDmeTypedLogLayer< float >::GetValueUsingCurveInfoSkippingKey( int nKeyToSkip, float& out ) const;
+
+template<> void CDmeTypedLogLayer< Vector >::GetValueUsingCurveInfo( DmeTime_t time, Vector& out ) const;
+template<> void CDmeTypedLogLayer< Vector >::GetValueUsingCurveInfoSkippingKey( int nKeyToSkip, Vector& out ) const;
+
+template<> void CDmeTypedLogLayer< Quaternion >::GetValueUsingCurveInfo( DmeTime_t time, Quaternion& out ) const;
+template<> void CDmeTypedLogLayer< Quaternion >::GetValueUsingCurveInfoSkippingKey( int nKeyToSkip, Quaternion& out ) const;
+
+template<class T> void CDmeTypedLogLayer< T >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< T > *output );
+template<> void CDmeTypedLogLayer< bool >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< bool > *output );
+template<> void CDmeTypedLogLayer< int >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< int > *output );
+template<> void CDmeTypedLogLayer< Color >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< Color > *output );
+template<> void CDmeTypedLogLayer< Quaternion >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< Quaternion > *output );
+template<> void CDmeTypedLogLayer< VMatrix >::CurveSimplify_R( float thresholdSqr, int startPoint, int endPoint, CDmeTypedLogLayer< VMatrix > *output );
+
+template<> void CDmeTypedLog< Vector >::BuildNormalizedLayer( CDmeTypedLogLayer< float > *target );
+template<> void CDmeTypedLog< Vector2D >::BuildNormalizedLayer( CDmeTypedLogLayer< float > *target );
+template<> void CDmeTypedLog< Vector4D >::BuildNormalizedLayer( CDmeTypedLogLayer< float > *target );
+template<> void CDmeTypedLog< float >::BuildNormalizedLayer( CDmeTypedLogLayer< float > *target );
+template<> void CDmeTypedLog< int >::BuildNormalizedLayer( CDmeTypedLogLayer< float > *target );
+
+//template<> void CDmeTypedLog< float >::FinishTimeSelection( DmeTime_t tHeadPosition, DmeLog_TimeSelection_t& params );
+//template<> void CDmeTypedLog< bool >::_StampKeyAtHeadResample( const DmeLog_TimeSelection_t& params, const bool& value ) { Assert( 0 ); }
+
+//-----------------------------------------------------------------------------
+// typedefs for convenience (and so the user-supplied names match the programmer names)
+//-----------------------------------------------------------------------------
+typedef CDmeTypedLog<int> CDmeIntLog;
+typedef CDmeTypedLog<float> CDmeFloatLog;
+typedef CDmeTypedLog<bool> CDmeBoolLog;
+typedef CDmeTypedLog<Color> CDmeColorLog;
+typedef CDmeTypedLog<Vector2D> CDmeVector2Log;
+typedef CDmeTypedLog<Vector> CDmeVector3Log;
+typedef CDmeTypedLog<Vector4D> CDmeVector4Log;
+typedef CDmeTypedLog<QAngle> CDmeQAngleLog;
+typedef CDmeTypedLog<Quaternion> CDmeQuaternionLog;
+typedef CDmeTypedLog<VMatrix> CDmeVMatrixLog;
+typedef CDmeTypedLog<CUtlString> CDmeStringLog;
+
+//-----------------------------------------------------------------------------
+// typedefs for convenience (and so the user-supplied names match the programmer names)
+//-----------------------------------------------------------------------------
+typedef CDmeTypedLogLayer<int> CDmeIntLogLayer;
+typedef CDmeTypedLogLayer<float> CDmeFloatLogLayer;
+typedef CDmeTypedLogLayer<bool> CDmeBoolLogLayer;
+typedef CDmeTypedLogLayer<Color> CDmeColorLogLayer;
+typedef CDmeTypedLogLayer<Vector2D> CDmeVector2LogLayer;
+typedef CDmeTypedLogLayer<Vector> CDmeVector3LogLayer;
+typedef CDmeTypedLogLayer<Vector4D> CDmeVector4LogLayer;
+typedef CDmeTypedLogLayer<QAngle> CDmeQAngleLogLayer;
+typedef CDmeTypedLogLayer<Quaternion> CDmeQuaternionLogLayer;
+typedef CDmeTypedLogLayer<VMatrix> CDmeVMatrixLogLayer;
+typedef CDmeTypedLogLayer<CUtlString> CDmeStringLogLayer;
+
+//-----------------------------------------------------------------------------
+// typedefs for convenience (and so the user-supplied names match the programmer names)
+//-----------------------------------------------------------------------------
+typedef CDmeTypedCurveInfo<int> CDmeIntCurveInfo;
+typedef CDmeTypedCurveInfo<float> CDmeFloatCurveInfo;
+typedef CDmeTypedCurveInfo<bool> CDmeBoolCurveInfo;
+typedef CDmeTypedCurveInfo<Color> CDmeColorCurveInfo;
+typedef CDmeTypedCurveInfo<Vector2D> CDmeVector2CurveInfo;
+typedef CDmeTypedCurveInfo<Vector> CDmeVector3CurveInfo;
+typedef CDmeTypedCurveInfo<Vector4D> CDmeVector4CurveInfo;
+typedef CDmeTypedCurveInfo<QAngle> CDmeQAngleCurveInfo;
+typedef CDmeTypedCurveInfo<Quaternion> CDmeQuaternionCurveInfo;
+typedef CDmeTypedCurveInfo<VMatrix> CDmeVMatrixCurveInfo;
+typedef CDmeTypedCurveInfo<CUtlString> CDmeStringCurveInfo;
+
+// the following types are not supported
+// AT_ELEMENT,
+// AT_VOID,
+// AT_OBJECTID,
+// <all array types>
+
+//-----------------------------------------------------------------------------
+// Helpers for particular types of log layers
+//-----------------------------------------------------------------------------
+void GenerateRotationLog( CDmeQuaternionLogLayer *pLayer, const Vector &vecAxis, DmeTime_t pTime[4], float pRevolutionsPerSec[4] );
+
+// rotates a position log
+void RotatePositionLog( CDmeVector3LogLayer *pPositionLog, const matrix3x4_t& matrix );
+
+// rotates an orientation log
+void RotateOrientationLog( CDmeQuaternionLogLayer *pOrientationLog, const matrix3x4_t& matrix, bool bPreMultiply );
+
+
+#endif // DMELOG_H
diff --git a/public/movieobjects/dmemakefile.h b/public/movieobjects/dmemakefile.h
new file mode 100644
index 0000000..527b410
--- /dev/null
+++ b/public/movieobjects/dmemakefile.h
@@ -0,0 +1,237 @@
+//========= Copyright 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 ProcessHandle_t PerformCompilation() { Assert(0); return PROCESS_HANDLE_INVALID; }
+ 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;
+ ProcessHandle_t 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( g_pDataModel->GetString( T::GetStaticTypeSymbol() ), 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
diff --git a/public/movieobjects/dmemakefileutils.h b/public/movieobjects/dmemakefileutils.h
new file mode 100644
index 0000000..e2d47c8
--- /dev/null
+++ b/public/movieobjects/dmemakefileutils.h
@@ -0,0 +1,301 @@
+//========= Copyright 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:
+ CUtlSymbol 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:
+ CUtlSymbol 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( ProcessHandle_t 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;
+ ProcessHandle_t m_hCompileProcess;
+ int m_nCurrentCompileTask;
+ int m_nExitCode;
+ CompilationStep_t m_CompilationStep;
+};
+
+
+#endif // DMEMAKEFILEUTILS_H
diff --git a/public/movieobjects/dmematerial.h b/public/movieobjects/dmematerial.h
new file mode 100644
index 0000000..3bf9922
--- /dev/null
+++ b/public/movieobjects/dmematerial.h
@@ -0,0 +1,41 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// A class representing a material
+//
+//=============================================================================
+
+#ifndef DMEMATERIAL_H
+#define DMEMATERIAL_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "datamodel/dmelement.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:
+ IMaterial *m_pMTL;
+ CDmaString m_mtlName;
+};
+
+#endif // DMEMATERIAL_H
diff --git a/public/movieobjects/dmematerialoverlayfxclip.h b/public/movieobjects/dmematerialoverlayfxclip.h
new file mode 100644
index 0000000..ba7c56e
--- /dev/null
+++ b/public/movieobjects/dmematerialoverlayfxclip.h
@@ -0,0 +1,59 @@
+//========= Copyright 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;
+};
+
+
+#endif // DMEMATERIALOVERLAYFXCLIP_H
diff --git a/public/movieobjects/dmemdl.h b/public/movieobjects/dmemdl.h
new file mode 100644
index 0000000..1d79f86
--- /dev/null
+++ b/public/movieobjects/dmemdl.h
@@ -0,0 +1,79 @@
+//========= Copyright 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 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;
+
+private:
+ void UpdateMDL();
+
+ CMDL m_MDL;
+ bool m_bDrawInEngine;
+};
+
+#endif // DMEMDL_H
diff --git a/public/movieobjects/dmemdlmakefile.h b/public/movieobjects/dmemdlmakefile.h
new file mode 100644
index 0000000..df95257
--- /dev/null
+++ b/public/movieobjects/dmemdlmakefile.h
@@ -0,0 +1,101 @@
+//========= Copyright 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<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
diff --git a/public/movieobjects/dmemesh.h b/public/movieobjects/dmemesh.h
new file mode 100644
index 0000000..8b4830c
--- /dev/null
+++ b/public/movieobjects/dmemesh.h
@@ -0,0 +1,496 @@
+//========= Copyright 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, CDmeFaceSet *pFaceSet, int nFirstIndex, int *pIndices, int nOutCount );
+
+ // 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 ) const;
+ CDmeVertexDeltaData *FindOrCreateDeltaState( const char *pDeltaName );
+ bool DeleteDeltaState( const char *pDeltaName );
+ bool ResetDeltaState( const char *pDeltaName );
+ int FindDeltaStateIndex( const char *pDeltaName ) 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 );
+
+ // 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 );
+
+ // makes all the normals in the mesh unit length
+ 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
+ template < class T_t > static int GenerateCompleteDataForDelta( const CDmeVertexDeltaData *pDelta, T_t *pFullData, int nFullData, CDmeVertexData::StandardFields_t standardField );
+
+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 );
+
+ // 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();
+
+ // 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;
+
+ 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 );
+
+ // 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 );
+
+ 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;
+ static CMaterialReference s_NormalErrorMaterial;
+
+ static bool s_bMaterialsInitialized;
+ static CMaterialReference s_WireframeMaterial;
+ static CMaterialReference s_WireframeOnShadedMaterial;
+
+ friend class CRenderInfo;
+
+#endif // ndef 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 );
+
+
+#endif // DMEMESH_H
diff --git a/public/movieobjects/dmemodel.h b/public/movieobjects/dmemodel.h
new file mode 100644
index 0000000..fd181a1
--- /dev/null
+++ b/public/movieobjects/dmemodel.h
@@ -0,0 +1,94 @@
+//========= Copyright 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 "movieobjects/dmejoint.h"
+#include "movieobjects/dmetransformlist.h"
+
+
+class CDmeDrawSettings;
+
+//-----------------------------------------------------------------------------
+// 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 GetJointTransformCount() const;
+
+ // Determines joint transform index given a joint name
+ int GetJointTransformIndex( CDmeTransform *pTransform ) const;
+
+ // Determines joint transform index given a joint
+ int GetJointTransformIndex( CDmeDag *pJoint ) const;
+
+ // Determines joint transform index given a joint name
+ CDmeTransform *GetJointTransform( int nIndex );
+ const CDmeTransform *GetJointTransform( int nIndex ) const;
+
+ // Captures the current joint transforms into a base state
+ void CaptureJointsToBaseState( 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 );
+
+ // Set if Z is the up axis of the model
+ void ZUp( bool bYUp );
+
+ // Returns true if the DmeModel is Z Up.
+ bool IsZUp() const;
+
+protected:
+ // The order in which the joint transform names appear in this list
+ // indicates the joint index for each dag
+ CDmaElementArray<CDmeTransform> m_JointTransforms;
+
+ // Stores a list of base poses for all the joint transforms
+ CDmaElementArray<CDmeTransformList> m_BaseStates;
+
+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 );
+
+ // 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;
+};
+
+
+#endif // DMEMODEL_H
diff --git a/public/movieobjects/dmemorphoperator.h b/public/movieobjects/dmemorphoperator.h
new file mode 100644
index 0000000..0479a5a
--- /dev/null
+++ b/public/movieobjects/dmemorphoperator.h
@@ -0,0 +1,53 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmemouseinput.h b/public/movieobjects/dmemouseinput.h
new file mode 100644
index 0000000..9b60586
--- /dev/null
+++ b/public/movieobjects/dmemouseinput.h
@@ -0,0 +1,45 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmeoperator.h b/public/movieobjects/dmeoperator.h
new file mode 100644
index 0000000..503b4cc
--- /dev/null
+++ b/public/movieobjects/dmeoperator.h
@@ -0,0 +1,34 @@
+//========= Copyright 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 "tier1/utlvector.h"
+
+
+//-----------------------------------------------------------------------------
+// A class representing a camera
+//-----------------------------------------------------------------------------
+class CDmeOperator : public IDmeOperator, public CDmElement
+{
+ DEFINE_ELEMENT( CDmeOperator, CDmElement );
+
+public:
+ virtual bool IsDirty(); // ie needs to operate
+ virtual void Operate() {}
+
+ virtual void GetInputAttributes ( CUtlVector< CDmAttribute * > &attrs ) {}
+ virtual void GetOutputAttributes( CUtlVector< CDmAttribute * > &attrs ) {}
+};
+
+
+#endif // DMEOPERATOR_H
diff --git a/public/movieobjects/dmepackoperators.h b/public/movieobjects/dmepackoperators.h
new file mode 100644
index 0000000..ebf17af
--- /dev/null
+++ b/public/movieobjects/dmepackoperators.h
@@ -0,0 +1,164 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmeparticlesystemdefinition.h b/public/movieobjects/dmeparticlesystemdefinition.h
new file mode 100644
index 0000000..d2bee4f
--- /dev/null
+++ b/public/movieobjects/dmeparticlesystemdefinition.h
@@ -0,0 +1,165 @@
+//========= Copyright 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 "particles/particles.h"
+
+
+//-----------------------------------------------------------------------------
+// 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();
+
+protected:
+ void UpdateAttributes( const DmxElementUnpackStructure_t *pUnpack );
+
+private:
+ // Defines widgets to edit this bad boy
+ CDmeHandle< 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* AddChild( CDmeParticleSystemDefinition *pChild );
+ void RemoveFunction( ParticleFunctionType_t type, CDmeParticleFunction *pParticleFunction );
+ void RemoveFunction( ParticleFunctionType_t type, int nIndex );
+
+ // 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;
+
+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 );
+
+
+#endif // DMEPARTICLESYSTEMDEFINITION_H
diff --git a/public/movieobjects/dmephonememapping.h b/public/movieobjects/dmephonememapping.h
new file mode 100644
index 0000000..d8d620f
--- /dev/null
+++ b/public/movieobjects/dmephonememapping.h
@@ -0,0 +1,24 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmeselection.h b/public/movieobjects/dmeselection.h
new file mode 100644
index 0000000..02f2625
--- /dev/null
+++ b/public/movieobjects/dmeselection.h
@@ -0,0 +1,200 @@
+//========= Copyright 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"
+
+
+//-----------------------------------------------------------------------------
+//
+//
+//
+//-----------------------------------------------------------------------------
+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 \ No newline at end of file
diff --git a/public/movieobjects/dmeshader.h b/public/movieobjects/dmeshader.h
new file mode 100644
index 0000000..f8bee53
--- /dev/null
+++ b/public/movieobjects/dmeshader.h
@@ -0,0 +1,53 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmeshape.h b/public/movieobjects/dmeshape.h
new file mode 100644
index 0000000..fc13b2f
--- /dev/null
+++ b/public/movieobjects/dmeshape.h
@@ -0,0 +1,53 @@
+//========= Copyright 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;
+
+ // 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
diff --git a/public/movieobjects/dmesound.h b/public/movieobjects/dmesound.h
new file mode 100644
index 0000000..10cfcaa
--- /dev/null
+++ b/public/movieobjects/dmesound.h
@@ -0,0 +1,53 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmetestmesh.h b/public/movieobjects/dmetestmesh.h
new file mode 100644
index 0000000..a0278ac
--- /dev/null
+++ b/public/movieobjects/dmetestmesh.h
@@ -0,0 +1,140 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmetexture.h b/public/movieobjects/dmetexture.h
new file mode 100644
index 0000000..5b889a4
--- /dev/null
+++ b/public/movieobjects/dmetexture.h
@@ -0,0 +1,184 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// A class representing a procedural texture
+//
+//=============================================================================
+
+#ifndef DMETEXTURE_H
+#define DMETEXTURE_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "datamodel/dmelement.h"
+#include "materialsystem/MaterialSystemUtil.h"
+#include "movieobjects/dmeimage.h"
+
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+class ITexture;
+class IMesh;
+enum ImageFormat;
+class IVTFTexture;
+
+
+//-----------------------------------------------------------------------------
+// Compression types
+//-----------------------------------------------------------------------------
+enum DmeTextureCompress_t
+{
+ DMETEXTURE_COMPRESS_DEFAULT = 0,
+ DMETEXTURE_COMPRESS_NONE,
+ DMETEXTURE_COMPRESS_DXT1,
+ DMETEXTURE_COMPRESS_DXT5,
+};
+
+
+//-----------------------------------------------------------------------------
+// Filter types
+//-----------------------------------------------------------------------------
+enum DmeTextureFilter_t
+{
+ DMETEXTURE_FILTER_DEFAULT = 0,
+ DMETEXTURE_FILTER_ANISOTROPIC,
+ DMETEXTURE_FILTER_TRILINEAR,
+ DMETEXTURE_FILTER_BILINEAR,
+ DMETEXTURE_FILTER_POINT,
+};
+
+
+//-----------------------------------------------------------------------------
+// Mipmap types
+//-----------------------------------------------------------------------------
+enum DmeTextureMipmap_t
+{
+ DMETEXTURE_MIPMAP_DEFAULT = 0,
+ DMETEXTURE_MIPMAP_ALL_LEVELS,
+ DMETEXTURE_MIPMAP_NONE,
+};
+
+
+//-----------------------------------------------------------------------------
+// A base class for textures
+//-----------------------------------------------------------------------------
+class CDmeBaseTexture : public CDmElement
+{
+ DEFINE_ELEMENT( CDmeBaseTexture, CDmElement );
+
+public:
+ ITexture *GetCachedTexture();
+
+ // Compression type
+ void SetCompressionType( DmeTextureCompress_t type );
+ DmeTextureCompress_t GetCompressionType() const;
+
+ // Filter type
+ void SetFilterType( DmeTextureFilter_t type );
+ DmeTextureFilter_t GetFilterType() const;
+
+ // Mipmap type
+ void SetMipmapType( DmeTextureMipmap_t type );
+ DmeTextureMipmap_t GetMipmapType() const;
+
+public:
+ CDmAttributeVar<bool> m_bClampS;
+ CDmAttributeVar<bool> m_bClampT;
+ CDmAttributeVar<bool> m_bClampU;
+ CDmAttributeVar<bool> m_bNoDebugOverride;
+ CDmAttributeVar<bool> m_bNoLod;
+ CDmAttributeVar<bool> m_bNiceFiltered;
+ CDmAttributeVar<bool> m_bNormalMap;
+ CDmAttributeVar<float> m_flBumpScale;
+
+protected:
+ // Computes texture flags
+ int CalcTextureFlags( int nDepth ) const;
+
+ // Computes the desired texture format based on flags
+ ImageFormat ComputeDesiredImageFormat( ImageFormat srcFormat, int nWidth, int nHeight, int nDepth, int nFlags );
+
+ CDmAttributeVar<int> m_nCompressType;
+ CDmAttributeVar<int> m_nFilterType;
+ CDmAttributeVar<int> m_nMipmapType;
+
+ // Computed values
+ CTextureReference m_Texture;
+ IVTFTexture *m_pVTFTexture;
+ Vector m_vecReflectivity;
+};
+
+
+//-----------------------------------------------------------------------------
+// Inline methods
+//-----------------------------------------------------------------------------
+inline void CDmeBaseTexture::SetCompressionType( DmeTextureCompress_t type )
+{
+ m_nCompressType = type;
+}
+
+inline DmeTextureCompress_t CDmeBaseTexture::GetCompressionType() const
+{
+ return (DmeTextureCompress_t)m_nCompressType.Get();
+}
+
+inline void CDmeBaseTexture::SetFilterType( DmeTextureFilter_t type )
+{
+ m_nFilterType = type;
+}
+
+inline DmeTextureFilter_t CDmeBaseTexture::GetFilterType() const
+{
+ return (DmeTextureFilter_t)m_nFilterType.Get();
+}
+
+inline void CDmeBaseTexture::SetMipmapType( DmeTextureMipmap_t type )
+{
+ m_nMipmapType = type;
+}
+
+inline DmeTextureMipmap_t CDmeBaseTexture::GetMipmapType() const
+{
+ return (DmeTextureMipmap_t)m_nMipmapType.Get();
+}
+
+
+//-----------------------------------------------------------------------------
+// A class representing a texture
+//-----------------------------------------------------------------------------
+class CDmeTexture : public CDmeBaseTexture
+{
+ DEFINE_ELEMENT( CDmeTexture, CDmeBaseTexture );
+
+public:
+ virtual void Resolve();
+
+private:
+ // Array of images in an animated texture
+ CDmAttributeVarElementArray< CDmeImage > m_Images;
+};
+
+
+//-----------------------------------------------------------------------------
+// A class representing a cube texture
+//-----------------------------------------------------------------------------
+class CDmeCubeTexture : public CDmeBaseTexture
+{
+ DEFINE_ELEMENT( CDmeCubeTexture, CDmeBaseTexture );
+
+public:
+ virtual void Resolve();
+
+private:
+ // Array of images in an animated texture
+ CDmAttributeVarElementArray< CDmeImage > m_ImagesPosX;
+ CDmAttributeVarElementArray< CDmeImage > m_ImagesNegX;
+ CDmAttributeVarElementArray< CDmeImage > m_ImagesPosY;
+ CDmAttributeVarElementArray< CDmeImage > m_ImagesNegY;
+ CDmAttributeVarElementArray< CDmeImage > m_ImagesPosZ;
+ CDmAttributeVarElementArray< CDmeImage > m_ImagesNegZ;
+};
+
+
+#endif // DMETEXTURE_H
diff --git a/public/movieobjects/dmetimeframe.h b/public/movieobjects/dmetimeframe.h
new file mode 100644
index 0000000..b385c0e
--- /dev/null
+++ b/public/movieobjects/dmetimeframe.h
@@ -0,0 +1,153 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef DMETIMEFRAME_H
+#define DMETIMEFRAME_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "datamodel/dmelement.h"
+#include "movieobjects/timeutils.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:
+ CDmaVar< int > m_Start;
+ CDmaVar< int > m_Duration;
+ CDmaVar< int > m_Offset;
+ CDmaVar< float > m_Scale;
+};
+
+
+//-----------------------------------------------------------------------------
+// inline methods
+//-----------------------------------------------------------------------------
+inline DmeTime_t CDmeTimeFrame::GetStartTime() const
+{
+ return DmeTime_t( m_Start );
+}
+
+inline DmeTime_t CDmeTimeFrame::GetDuration() const
+{
+ return DmeTime_t( m_Duration );
+}
+
+inline DmeTime_t CDmeTimeFrame::GetTimeOffset() const
+{
+ return DmeTime_t( m_Offset );
+}
+
+inline float CDmeTimeFrame::GetTimeScale() const
+{
+ return m_Scale;
+}
+
+inline void CDmeTimeFrame::SetStartTime( DmeTime_t flStartTime )
+{
+ m_Start = flStartTime.GetTenthsOfMS();
+}
+
+inline void CDmeTimeFrame::SetDuration( DmeTime_t flDuration )
+{
+ Assert( m_Duration >= 0 ); // if you want a reversed clip, set the timescale negative
+ m_Duration = flDuration.GetTenthsOfMS();
+}
+
+inline void CDmeTimeFrame::SetTimeOffset( DmeTime_t flOffset )
+{
+ m_Offset = flOffset.GetTenthsOfMS();
+}
+
+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 -= DmeTime_t( m_Start );
+ if ( bClamp )
+ {
+ t.Clamp( DMETIME_ZERO, DmeTime_t( m_Duration ) );
+ }
+ return ( t + DmeTime_t( m_Offset ) ) * m_Scale;
+}
+
+inline DmeTime_t CDmeTimeFrame::FromChildMediaTime( DmeTime_t t, bool bClamp ) const
+{
+ t = DmeTime_t( t ) / m_Scale - DmeTime_t( m_Offset );
+ if ( bClamp )
+ {
+ t.Clamp( DMETIME_ZERO, DmeTime_t( m_Duration ) );
+ }
+ return t + DmeTime_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 = DmeTime_t( m_Offset ) * m_Scale;
+ Assert( time == ToChildMediaTime( GetStartTime() ) );
+ return time;
+}
+
+inline DmeTime_t CDmeTimeFrame::GetEndInChildMediaTime() const
+{
+ DmeTime_t time = DmeTime_t( m_Offset + m_Duration ) * m_Scale;
+ Assert( time == ToChildMediaTime( GetStartTime() + GetDuration() ) );
+ return time;
+}
+
+
+#endif // DMETIMEFRAME_H
diff --git a/public/movieobjects/dmetimeselection.h b/public/movieobjects/dmetimeselection.h
new file mode 100644
index 0000000..5eb1d93
--- /dev/null
+++ b/public/movieobjects/dmetimeselection.h
@@ -0,0 +1,72 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef DMETIMESELECTION_H
+#define DMETIMESELECTION_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "datamodel/dmelement.h"
+#include "movieobjects/timeutils.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 );
+ DmeTime_t GetAbsHold( DmeTime_t time, int side );
+
+ DmeTime_t GetRelativeFalloff( DmeTime_t time, int side );
+ DmeTime_t GetRelativeHold( DmeTime_t time, int side );
+
+ void SetAbsFalloff( DmeTime_t time, int side, DmeTime_t absfallofftime );
+ void SetAbsHold ( DmeTime_t time, int side, DmeTime_t absholdtime );
+
+ int GetFalloffInterpolatorType( int side );
+ 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 GetCurrent( DmeTime_t pTimes[TS_TIME_COUNT] );
+ void SetCurrent( DmeTime_t* pTimes );
+
+ float GetThreshold();
+
+ void SetRecordingState( RecordingState_t state );
+ RecordingState_t GetRecordingState() const;
+
+private:
+ CDmeTimeSelection & operator =( const CDmeTimeSelection& src );
+
+ 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
+ CDmaVar< int > m_falloff[ 2 ];
+ CDmaVar< int > m_hold[ 2 ];
+ CDmaVar< int > m_nFalloffInterpolatorType[ 2 ];
+ CDmaVar< float > m_threshold;
+ CDmaVar< int > m_nRecordingState;
+};
+
+#endif // DMETIMESELECTION_H
diff --git a/public/movieobjects/dmetimeselectiontimes.h b/public/movieobjects/dmetimeselectiontimes.h
new file mode 100644
index 0000000..d64a6b9
--- /dev/null
+++ b/public/movieobjects/dmetimeselectiontimes.h
@@ -0,0 +1,28 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef DMETIMESELECTIONTIMES_H
+#define DMETIMESELECTIONTIMES_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+enum DmeTimeSelectionTimes_t
+{
+ TS_LEFT_FALLOFF = 0,
+ TS_LEFT_HOLD,
+ TS_RIGHT_HOLD,
+ TS_RIGHT_FALLOFF,
+
+ 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
diff --git a/public/movieobjects/dmetrack.h b/public/movieobjects/dmetrack.h
new file mode 100644
index 0000000..b7afd96
--- /dev/null
+++ b/public/movieobjects/dmetrack.h
@@ -0,0 +1,191 @@
+//========= Copyright 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 );
+ void ShiftAllFilmClipsBefore( CDmeClip *pClip, DmeTime_t dt, bool bShiftClip = false );
+
+ // 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 );
+
+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;
+
+ 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;
+}
+
+//-----------------------------------------------------------------------------
+// helper methods
+//-----------------------------------------------------------------------------
+CDmeTrackGroup *GetParentTrackGroup( CDmeTrack *pTrack );
+
+#endif // DMETRACK_H
diff --git a/public/movieobjects/dmetrackgroup.h b/public/movieobjects/dmetrackgroup.h
new file mode 100644
index 0000000..8e029c3
--- /dev/null
+++ b/public/movieobjects/dmetrackgroup.h
@@ -0,0 +1,249 @@
+//========= Copyright 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"
+#include "movieobjects/timeutils.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();
+ void SetOwnerClip( CDmeClip *pClip );
+
+ // 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 group display size
+ void SetDisplaySize( int nDisplaySize );
+ int GetDisplaySize() 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 );
+
+private:
+ CDmaElementArray< CDmeTrack > m_Tracks;
+ CDmaVar<bool> m_bIsVisible;
+ CDmaVar<bool> m_bMinimized;
+ CDmaVar< bool > m_bMute;
+ CDmaVar< float > m_Volume;
+ CDmaVar<int> m_nDisplaySize;
+
+ DmElementHandle_t m_hOwner;
+ 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 display size
+//-----------------------------------------------------------------------------
+inline void CDmeTrackGroup::SetDisplaySize( int nDisplaySize )
+{
+ m_nDisplaySize = nDisplaySize;
+}
+
+inline int CDmeTrackGroup::GetDisplaySize() const
+{
+ return m_nDisplaySize;
+}
+
+
+//-----------------------------------------------------------------------------
+// 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
diff --git a/public/movieobjects/dmetransform.h b/public/movieobjects/dmetransform.h
new file mode 100644
index 0000000..d539ab5
--- /dev/null
+++ b/public/movieobjects/dmetransform.h
@@ -0,0 +1,49 @@
+//========= Copyright 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"
+
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+struct matrix3x4_t;
+
+
+//-----------------------------------------------------------------------------
+// A class representing a transformation matrix
+//-----------------------------------------------------------------------------
+class CDmeTransform : public CDmElement
+{
+ DEFINE_ELEMENT( CDmeTransform, CDmElement );
+
+public:
+ // FIXME: Replace this with actual methods to do editing
+ // (scale/shear, etc.)
+ 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();
+
+private:
+ CDmaVar<Vector> m_Position;
+ CDmaVar<Quaternion> m_Orientation;
+};
+
+
+#endif // DMETRANSFORM_H
diff --git a/public/movieobjects/dmetransforminput.h b/public/movieobjects/dmetransforminput.h
new file mode 100644
index 0000000..59a965f
--- /dev/null
+++ b/public/movieobjects/dmetransforminput.h
@@ -0,0 +1,59 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmetransformlist.h b/public/movieobjects/dmetransformlist.h
new file mode 100644
index 0000000..26a1517
--- /dev/null
+++ b/public/movieobjects/dmetransformlist.h
@@ -0,0 +1,47 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmetransformoperator.h b/public/movieobjects/dmetransformoperator.h
new file mode 100644
index 0000000..fa7ffda
--- /dev/null
+++ b/public/movieobjects/dmetransformoperator.h
@@ -0,0 +1,53 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmeunpackoperators.h b/public/movieobjects/dmeunpackoperators.h
new file mode 100644
index 0000000..4df657b
--- /dev/null
+++ b/public/movieobjects/dmeunpackoperators.h
@@ -0,0 +1,164 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmevertexdata.h b/public/movieobjects/dmevertexdata.h
new file mode 100644
index 0000000..466df4c
--- /dev/null
+++ b/public/movieobjects/dmevertexdata.h
@@ -0,0 +1,337 @@
+//========= Copyright 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
+ 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 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;
+
+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 );
+
+ // 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;
+
+private:
+ virtual bool IsVertexDeltaData() const { return true; }
+
+ // Computes max positional delta length
+ float ComputeMaxDeflection( );
+};
+
+
+#endif // DMEVERTEXDATA_H
diff --git a/public/movieobjects/dmmeshcomp.h b/public/movieobjects/dmmeshcomp.h
new file mode 100644
index 0000000..43207c1
--- /dev/null
+++ b/public/movieobjects/dmmeshcomp.h
@@ -0,0 +1,126 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmmeshutils.h b/public/movieobjects/dmmeshutils.h
new file mode 100644
index 0000000..26c4349
--- /dev/null
+++ b/public/movieobjects/dmmeshutils.h
@@ -0,0 +1,199 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Mesh Manipulation Utilities
+//
+//=============================================================================
+
+
+#ifndef DMMESHUTILS_H
+#define DMMESHUTILS_H
+
+#if defined( _WIN32 )
+#pragma once
+#endif
+
+#include "movieobjects/dmevertexdata.h"
+#include "tier1/utlstring.h"
+#include "tier1/UtlStringMap.h"
+#include "tier1/utlvector.h"
+
+class CDmeMesh;
+class CDmMeshComp::CEdge;
+
+
+//-----------------------------------------------------------------------------
+// Mesh Utility function class (more like a namespace)
+//-----------------------------------------------------------------------------
+class CDmMeshUtils
+{
+public:
+
+ static bool RemoveLargeAxisAlignedPlanarFaces( CDmeMesh *pMesh );
+
+ static bool RemoveFacesWithMaterial( CDmeMesh *pMesh, const char *pMaterialName );
+
+ static bool RemoveFacesWithMoreThanNVerts( CDmeMesh *pMesh, const int nVertexCount );
+
+ enum Axis_t
+ {
+ kXAxis,
+ kYAxis,
+ kZAxis
+ };
+
+ static bool Mirror( CDmeMesh *pMesh, int axis = kXAxis );
+
+ static bool RemapMaterial( CDmeMesh *pMesh, const CUtlString &src, const CUtlString &dst );
+
+ static bool RemapMaterial( CDmeMesh *pMesh, const int nMaterialIndex, const CUtlString &dst );
+
+ // Merge the specified mesh onto the first mesh under pRoot that fits it
+ static bool Merge( CDmeMesh *pSrcMesh, CDmElement *pRoot );
+
+ static bool Merge( CDmeMesh *pSrcMesh, CDmeMesh *pDstMesh, int nSkinningJointIndex );
+
+ static bool CreateDeltasFromPresets( CDmeMesh *pMesh, CDmeVertexData *pPassedDst, const CUtlStringMap< CUtlString > &presetMap, bool bPurge, const CUtlVector< CUtlString > *pPurgeAllButThese = NULL );
+
+ static bool PurgeUnusedDeltas( CDmeMesh *pMesh );
+
+ enum WrinkleOp
+ {
+ kReplace,
+ kAdd
+ };
+
+ static bool CreateWrinkleDeltaFromBaseState( CDmeVertexDeltaData *pDelta, float flScale = 1.0f, WrinkleOp wrinkleOp = kReplace, CDmeMesh *pMesh = NULL, CDmeVertexData *pBind = NULL, CDmeVertexData *pCurrent = NULL );
+
+ static int FindMergeSocket(
+ const CUtlVector< CUtlVector< CDmMeshComp::CEdge * > > &srcBorderEdgesList,
+ CDmeMesh *pDstMesh );
+
+ static bool Merge( CDmMeshComp &srcComp, const CUtlVector< CDmMeshComp::CEdge * > &edgeList, CDmeMesh *pDstMesh );
+
+protected:
+ static const int *BuildDataMirrorMap( CDmeVertexData *pBase, int axis, CDmeVertexData::StandardFields_t standardField, CUtlVector< int > &dataMirrorMap );
+
+ static bool MirrorVertices( CDmeMesh *pMesh, CDmeVertexData *pBase, int axis, CUtlVector< int > &mirrorMap );
+
+ static bool MirrorVertices( CDmeVertexData *pBase, int axis, int nOldVertexCount, int nMirrorCount, const CUtlVector< int > &mirrorMap, const CUtlVector< int > &posMirrorMap, const CUtlVector< int > &normalMirrorMap, const CUtlVector< int > &uvMirrorMap );
+
+ static void MirrorVertices( CDmeVertexData *pBase, FieldIndex_t fieldIndex, int nOldVertexCount, int nMirrorCount, const CUtlVector< int > &baseIndices, const CUtlVector< int > &mirrorMap );
+
+ static bool MirrorDelta( CDmeVertexDeltaData *pDelta, int axis, const CUtlVector< int > &posMirrorMap, const CUtlVector< int > &normalMirrorMap, const CUtlVector< int > &uvMirrorMap );
+
+ static bool PurgeUnusedData( CDmeMesh *pMesh );
+
+ static void CreateDeltasFromPresetGroup( CDmePresetGroup *pPresetGroup, CDmeCombinationOperator * pComboOp, const CUtlVector< CUtlString > * pPurgeAllButThese, CDmeMesh * pMesh, CDmeVertexData * pDst, CUtlStringMap< CUtlString > &conflictingNames, CUtlStringMap< CDmePreset * > &presetMap );
+
+ static void PurgeUnreferencedDeltas( CDmeMesh *pMesh, CUtlStringMap< CDmePreset * > &presetMap, const CUtlVector< CUtlString > *pPurgeAllButThese, CDmeCombinationOperator *pComboOp );
+};
+
+
+//-----------------------------------------------------------------------------
+// Iterate over all of the faces in a mesh. Use it like this:
+//
+// for ( CDmMeshFaceIt fIt( pMesh ); !fIt.IsDone(); fIt.Next() )
+// {
+// }
+//-----------------------------------------------------------------------------
+class CDmMeshFaceIt
+{
+public:
+ // Constructs a new face iterator for the specified mesh
+ CDmMeshFaceIt( const CDmeMesh *pMesh, const CDmeVertexData *pVertexData = NULL );
+
+ // Resets the iterator to the start of the specified mesh or for another iteration of the
+ // current mesh if the specified mesh is NULL
+ bool Reset( const CDmeMesh *pMesh = NULL, const CDmeVertexData *pVertexData = NULL );
+
+ // Returns the total number of faces in the mesh
+ int Count() const;
+
+ // The number of vertices in the face
+ int VertexCount() const;
+
+ // Is the iterator at the end of the mesh?
+ bool IsDone() const;
+
+ // Move the iterator to the next face
+ bool Next();
+
+ // The face index of the current face in the range [ 0, Count() ]
+ int Index() const;
+
+ // Returns opposite sense of IsDone(), i.e. !IsDone() so true if iterator still has stuff to do
+ operator bool() const { return !IsDone(); }
+
+ // Prefix ++ which just calls Next() for syntax sugar
+ CDmMeshFaceIt &operator ++() { Next(); return *this; }
+
+ // Postfix ++ which just calls Next() for syntax sugar
+ CDmMeshFaceIt operator ++( int ) { const CDmMeshFaceIt thisCopy( *this ); ++( *this ); return thisCopy; }
+
+ // Gets the vertex indices for the vertices of this face
+ bool GetVertexIndices( int *pIndices, int nIndices ) const;
+
+ // Gets the vertex indices for the vertices of this face
+ bool GetVertexIndices( CUtlVector< int > &vertexIndices ) const;
+
+ // Gets the mesh relative vertex index given the face relative vertex index
+ int GetVertexIndex( int nFaceRelativeVertexIndex ) const;
+
+ // Gets the specified vertex data for the vertices of this face (if it exists) and the type matches
+ template < class T_t >
+ bool GetVertexData(
+ CUtlVector< T_t > &vertexData,
+ CDmeVertexDataBase::StandardFields_t nStandardField,
+ CDmeVertexData *pPassedBase = NULL ) const;
+
+protected:
+ bool SetFaceSet();
+
+ const CDmeMesh *m_pMesh; // Current Mesh
+ const CDmeVertexData *m_pVertexData; // Current Vertex Data
+
+ int m_nFaceSetCount; // Number of face sets in current mesh: m_pMesh->FaceSetCount();
+ int m_nFaceSetIndex; // Index of current face set: [ 0, m_nFaceSetCount ]
+
+ const CDmeFaceSet *m_pFaceSet; // Current face set: m_pMesh->GetFaceSet( m_nFaceSetIndex )
+
+ int m_nFaceSetIndexCount; // Number of indices in current face set: m_pFaceSet->NumIndices();
+ int m_nFaceSetIndexIndex; // Index of current face set's indices: [ 0, m_nFaceSetIndexCount ]
+
+ int m_nFaceCount; // Number of faces in current mesh
+ int m_nFaceIndex; // The current face in the iteration [ 0, m_nFaceCount ]
+};
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+template < class T_t >
+inline bool CDmMeshFaceIt::GetVertexData(
+ CUtlVector< T_t > &vertexData,
+ CDmeVertexDataBase::StandardFields_t nStandardField,
+ CDmeVertexData *pPassedBase /* = NULL */ ) const
+{
+ vertexData.RemoveAll();
+
+ if ( IsDone() )
+ return false;
+
+ CDmeVertexData *pBase = pPassedBase ? pPassedBase : m_pMesh->GetCurrentBaseState();
+ if ( !pBase )
+ return false;
+
+ const FieldIndex_t nFieldIndex = pBase->FindFieldIndex( nStandardField );
+ if ( nFieldIndex < 0 )
+ return false;
+
+ CDmAttribute *pDataAttr = pBase->GetVertexData( nFieldIndex );
+ if ( pDataAttr->GetType() != CDmAttributeInfo< CUtlVector< T_t > >().AttributeType() )
+ return false;
+
+ const CDmrArrayConst< T_t > data( pDataAttr );
+ const CUtlVector< int > &indices( pBase->GetVertexIndexData( nFieldIndex ) );
+}
+
+
+#endif // DMMESHUTILS_H \ No newline at end of file
diff --git a/public/movieobjects/dmobjserializer.h b/public/movieobjects/dmobjserializer.h
new file mode 100644
index 0000000..d92728a
--- /dev/null
+++ b/public/movieobjects/dmobjserializer.h
@@ -0,0 +1,114 @@
+//========= Copyright 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
diff --git a/public/movieobjects/dmsmdserializer.h b/public/movieobjects/dmsmdserializer.h
new file mode 100644
index 0000000..8bcff4e
--- /dev/null
+++ b/public/movieobjects/dmsmdserializer.h
@@ -0,0 +1,188 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Read SMD and create DMX data
+//
+//=============================================================================
+
+
+#ifndef DMSMDSERIALIZER_H
+#define DMSMDSERIALIZER_H
+
+
+#if defined( _WIN32 )
+#pragma once
+#endif
+
+
+// Valve includes
+#include "datamodel/idatamodel.h"
+#include "tier1/utlbuffer.h"
+#include "tier1/utlstring.h"
+#include "tier1/utlvector.h"
+
+
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+class CDmeDag;
+class CDmeMesh;
+class CPolygonData;
+
+
+//-----------------------------------------------------------------------------
+// Serialization class for SMD files
+//-----------------------------------------------------------------------------
+class CDmSmdSerializer : public IDmSerializer
+{
+public:
+ enum Axis_t
+ {
+ X_AXIS = 0,
+ Y_AXIS = 1,
+ Z_AXIS = 2
+ };
+
+ CDmSmdSerializer()
+ : m_bOptAutoStripPrefix( false )
+ , m_bOptImportSkeleton( true )
+ , m_bOptAnimation( false )
+ , m_flFrameRate( 30.0f )
+ {
+ SetUpAxis( Z_AXIS );
+ }
+
+ // Inherited from IDMSerializer
+ virtual const char *GetName() const { return "smd"; }
+ virtual const char *GetDescription() const { return "VALVe SMD"; }
+ virtual bool IsBinaryFormat() const { return false; }
+ virtual bool StoresVersionInFile() const { return true; }
+ virtual int GetCurrentVersion() const { return 1; }
+ virtual bool Serialize( CUtlBuffer &buf, CDmElement *pRoot ) { return false; } // No DMX -> SMD support
+
+ virtual bool Unserialize(
+ CUtlBuffer &utlBuf,
+ const char *pszEncodingName,
+ int nEncodingVersion,
+ const char *pszSourceFormatName,
+ int nSourceFormatVersion,
+ DmFileId_t nDmFileId,
+ DmConflictResolution_t nDmConflictResolution,
+ CDmElement **ppDmRoot );
+
+ // Methods used for importing (only should return non-NULL for serializers that return false from StoresVersionInFile)
+ virtual const char *GetImportedFormat() const { return NULL; }
+ virtual int GetImportedVersion() const { return 1; }
+
+ // CDmSmdSerializer
+ CDmElement *ReadSMD( const char *pszFilename, CDmeMesh **ppDmeMeshCreated = NULL );
+
+ void SetUpAxis( Axis_t nUpAxis );
+ Axis_t GetUpAxis() const { return m_nUpAxis; }
+
+ void SetIsAnimation( bool bOptAnimation ) { m_bOptAnimation = bOptAnimation; }
+ bool IsReadAnimation() const { return m_bOptAnimation; }
+
+ void SetFrameRate( float flFrameRate ) { m_flFrameRate = MAX( 0.1f, flFrameRate ); } // Don't allow 0 or negative frame rate
+ float GetFrameRate() const { return m_flFrameRate; }
+
+ //-----------------------------------------------------------------------------
+ //
+ //-----------------------------------------------------------------------------
+ struct SmdJoint_t
+ {
+ int m_nId; // The id parsed from the SMD file
+ int m_nActualId; // The actual node id which is created after sorting and creating all joints in order with no gaps in numbering, corresponds to joitnIndex in DmeModel
+ CUtlString m_sName;
+ int m_nParentId;
+ int m_nLineNumber;
+ CDmeDag *m_pDmeDag;
+
+ SmdJoint_t()
+ : m_nId( -1 )
+ , m_nActualId( -1 )
+ , m_nParentId( -1 )
+ , m_nLineNumber( -1 )
+ , m_pDmeDag( NULL )
+ {}
+
+ };
+
+
+ //-----------------------------------------------------------------------------
+ //
+ //-----------------------------------------------------------------------------
+ typedef CUtlMap< int, SmdJoint_t > SmdJointMap_t;
+
+protected:
+ void ParserGetNodeName( const char *pszBuf, CUtlString &sName ) const;
+
+ bool ParserHandleSkeletonLine(
+ const char *pszBuf,
+ CUtlString &sName,
+ int &nId,
+ int &nParentId ) const;
+
+ CDmElement *CDmSmdSerializer::ReadSMD(
+ CUtlBuffer &inUtlBuf,
+ DmFileId_t nDmFileId,
+ const char *pszFilename,
+ CDmeMesh **ppDmeMeshCreated );
+
+
+ //-----------------------------------------------------------------------------
+ //
+ //-----------------------------------------------------------------------------
+ class CNodeData
+ {
+ public:
+ CNodeData()
+ : m_nParentIndex( -1 )
+ , m_bSkinned( false )
+ , m_nInfluenceIndex( 0 )
+ , m_pDmeDag( NULL )
+ {
+ }
+
+ bool Valid() const
+ {
+ return m_pDmeDag != NULL;
+ }
+
+ void Reset()
+ {
+ m_pDmeDag = NULL;
+ }
+
+ int m_nParentIndex;
+ bool m_bSkinned;
+ int m_nInfluenceIndex;
+ CDmeDag *m_pDmeDag;
+
+ CUtlVector< Vector > m_positions;
+ };
+
+ void FixNodeName( CUtlString &sName ) const;
+
+ void ParserSetJoint(
+ const SmdJointMap_t &smdJointMap,
+ int nFrame, int nId,
+ const Vector &vPosition, const RadianEuler &eRadianEulerXYZ,
+ const char *pszFilename, int nLineNumber );
+
+ Axis_t m_nUpAxis; // 0 == X, 1 == Y, 2 == Z
+ matrix3x4_t m_mAdj; // Matrix to adjust for SMD source orientation to DMX Y up
+ matrix3x4_t m_mAdjNormal; // Matrix to adjust normals, inverse transpose of m_mAdj
+
+public:
+ bool m_bOptImportSkeleton;
+ bool m_bOptAutoStripPrefix;
+ bool m_bOptAnimation;
+ float m_flFrameRate;
+ CUtlString m_sNodeDelPrefix;
+ CUtlString m_sNodeAddPrefix;
+
+};
+
+
+#endif // DMSMDSERIALIZER_H \ No newline at end of file
diff --git a/public/movieobjects/dmx_to_vcd.h b/public/movieobjects/dmx_to_vcd.h
new file mode 100644
index 0000000..679801c
--- /dev/null
+++ b/public/movieobjects/dmx_to_vcd.h
@@ -0,0 +1,22 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef DMX_TO_VCD_H
+#define DMX_TO_VCD_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+class CDmeFilmClip;
+class CChoreoScene;
+
+bool ConvertSceneToDmx( CChoreoScene *scene, CDmeFilmClip *dmx );
+bool ConvertDmxToScene( CDmeFilmClip *dmx, CChoreoScene *scene );
+
+#define VCD_SCENE_RAMP_TRACK_GROUP_NAME "scene_ramp"
+#define VCD_GLOBAL_EVENTS_TRACK_GROUP_NAME "global_events"
+
+#endif // DMX_TO_VCD_H
diff --git a/public/movieobjects/idmemakefileutils.h b/public/movieobjects/idmemakefileutils.h
new file mode 100644
index 0000000..7145f30
--- /dev/null
+++ b/public/movieobjects/idmemakefileutils.h
@@ -0,0 +1,75 @@
+//========= Copyright 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 version
+//-----------------------------------------------------------------------------
+#define DMEMAKEFILE_UTILS_INTERFACE_VERSION "VDmeMakeFileUtils001"
+
+
+//-----------------------------------------------------------------------------
+// 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
diff --git a/public/movieobjects/importintovcd.h b/public/movieobjects/importintovcd.h
new file mode 100644
index 0000000..b7c532d
--- /dev/null
+++ b/public/movieobjects/importintovcd.h
@@ -0,0 +1,33 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef IMPORTINTOVCD_H
+#define IMPORTINTOVCD_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+class CChoreoScene;
+
+
+//-----------------------------------------------------------------------------
+// Compression info
+//-----------------------------------------------------------------------------
+struct ImportVCDInfo_t
+{
+ float m_flSimplificationThreshhold;
+ int m_nInterpolationType;
+ bool m_bIgnorePhonemes;
+};
+
+//-----------------------------------------------------------------------------
+// Main entry point for importing a .fac file into a .vcd file
+//-----------------------------------------------------------------------------
+bool ImportLogsIntoVCD( const char *pFacFullPath, CChoreoScene *pChoreoScene, const ImportVCDInfo_t& info );
+bool ImportLogsIntoVCD( const char *pFacFullPath, const char *pVCDInPath, const char *pVCDOutPath, const ImportVCDInfo_t& info );
+
+
+#endif // IMPORTINTOVCD_H
diff --git a/public/movieobjects/movieobjects.cpp b/public/movieobjects/movieobjects.cpp
new file mode 100644
index 0000000..c60337f
--- /dev/null
+++ b/public/movieobjects/movieobjects.cpp
@@ -0,0 +1,60 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: See notes below
+//
+//=============================================================================
+
+#include "movieobjects/movieobjects.h"
+
+#include "movieobjects/movieobjects_compiletools.cpp"
+
+// 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( DmeGameModelInput );
+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( DmeBalanceToStereoCalculatorOperator );
+USING_ELEMENT_FACTORY( DmeGlobalFlexControllerOperator );
+
+USING_ELEMENT_FACTORY( DmeTimeSelection );
diff --git a/public/movieobjects/movieobjects.h b/public/movieobjects/movieobjects.h
new file mode 100644
index 0000000..0fedaf2
--- /dev/null
+++ b/public/movieobjects/movieobjects.h
@@ -0,0 +1,64 @@
+//========= Copyright 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/dmetransformlist.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/dmedag.h"
+#include "movieobjects/dmelight.h"
+#include "movieobjects/dmegamemodel.h"
+#include "movieobjects/dmemdl.h"
+#include "movieobjects/dmesound.h"
+#include "movieobjects/dmeoperator.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/dmegamemodelinput.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/dmebalancetostereocalculatoroperator.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/dmeeyeposition.h"
+#include "movieobjects/dmeeyeball.h"
+#include "movieobjects/dmedrawsettings.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
diff --git a/public/movieobjects/movieobjects_compiletools.cpp b/public/movieobjects/movieobjects_compiletools.cpp
new file mode 100644
index 0000000..495d69d
--- /dev/null
+++ b/public/movieobjects/movieobjects_compiletools.cpp
@@ -0,0 +1,82 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: See notes below
+//
+//=============================================================================
+
+#include "movieobjects/movieobjects.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( DmeVertexData );
+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( DmeMayaMakefile );
+USING_ELEMENT_FACTORY( DmeXSIMakefile );
+USING_ELEMENT_FACTORY( DmeSourceDCCFile );
+USING_ELEMENT_FACTORY( DmeSourceMayaFile );
+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 );
+USING_ELEMENT_FACTORY( DmeEyePosition );
+USING_ELEMENT_FACTORY( DmeEyeball );
diff --git a/public/movieobjects/proceduralpresets.h b/public/movieobjects/proceduralpresets.h
new file mode 100644
index 0000000..a7b5da3
--- /dev/null
+++ b/public/movieobjects/proceduralpresets.h
@@ -0,0 +1,30 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef PROCEDURALPRESETS_H
+#define PROCEDURALPRESETS_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+enum
+{
+ PROCEDURAL_PRESET_NOT = 0,
+ PROCEDURAL_PRESET_IN_CROSSFADE,
+ PROCEDURAL_PRESET_OUT_CROSSFADE,
+ PROCEDURAL_PRESET_REVEAL,
+ PROCEDURAL_PRESET_PASTE,
+ PROCEDURAL_PRESET_JITTER,
+ PROCEDURAL_PRESET_SMOOTH,
+ PROCEDURAL_PRESET_SHARPEN,
+ PROCEDURAL_PRESET_SOFTEN,
+ PROCEDURAL_PRESET_STAGGER,
+
+ // Must be last
+ NUM_PROCEDURAL_PRESET_TYPES,
+};
+
+#endif // PROCEDURALPRESETS_H
diff --git a/public/movieobjects/timeutils.h b/public/movieobjects/timeutils.h
new file mode 100644
index 0000000..caf0633
--- /dev/null
+++ b/public/movieobjects/timeutils.h
@@ -0,0 +1,158 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef TIMEUTILS_H
+#define TIMEUTILS_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include <limits.h>
+#include <math.h>
+#include "platform.h"
+#include "tier0/dbg.h"
+
+
+class DmeTime_t;
+#define DMETIME_TO_SECONDS( t ) ((t) * 0.0001f)
+
+class DmeFramerate_t
+{
+public:
+ DmeFramerate_t( float fps );
+ DmeFramerate_t( int fps = 0 );
+ DmeFramerate_t( const DmeFramerate_t& src ) : m_num( src.m_num ), m_den( src.m_den ) {}
+
+ void SetFramerate( float flFrameRate );
+ void SetFramerate( int fps );
+ // other (uncommon) options besides 30(29.97 - ntsc video) are 24 (23.976 - ntsc film) and 60 (59.94 - ntsc progressive)
+ void SetFramerateNTSC( int multiplier = 30 );
+
+ float GetFramesPerSecond() const;
+
+ bool operator==( DmeFramerate_t f ) const { return m_num == f.m_num && m_den == f.m_den; }
+ bool operator!=( DmeFramerate_t f ) const { return m_num != f.m_num && m_den != f.m_den; }
+ bool operator< ( DmeFramerate_t f ) const { return m_num * ( int )f.m_den < f.m_num * ( int )m_den; }
+ bool operator> ( DmeFramerate_t f ) const { return m_num * ( int )f.m_den > f.m_num * ( int )m_den; }
+ bool operator<=( DmeFramerate_t f ) const { return m_num * ( int )f.m_den <= f.m_num * ( int )m_den; }
+ bool operator>=( DmeFramerate_t f ) const { return m_num * ( int )f.m_den >= f.m_num * ( int )m_den; }
+
+ DmeFramerate_t operator*( int i ) const { return DmeFramerate_t( m_num * i, m_den ); }
+ DmeFramerate_t operator/( int i ) const { return DmeFramerate_t( m_num, m_den * i ); }
+
+ unsigned short abs( unsigned short i ) { return i >= 0 ? i : -i; }
+
+ DmeFramerate_t operator*=( int i ) { Assert( abs( m_num * i ) <= USHRT_MAX ); m_num *= ( unsigned short )i; return *this; }
+ DmeFramerate_t operator/=( int i ) { Assert( abs( m_den * i ) <= USHRT_MAX ); m_den *= ( unsigned short )i; return *this; }
+
+private:
+ DmeFramerate_t( int nNumerator, int nDenominator );
+
+ unsigned short m_num;
+ unsigned short m_den;
+
+ friend class DmeTime_t;
+};
+
+#define DMETIME_ZERO DmeTime_t(0)
+#define DMETIME_MINDELTA DmeTime_t::MinTimeDelta()
+#define DMETIME_MINTIME DmeTime_t::MinTime()
+#define DMETIME_MAXTIME DmeTime_t::MaxTime()
+#define DMETIME_INVALID DmeTime_t::InvalidTime()
+
+class DmeTime_t
+{
+public:
+ DmeTime_t() : m_tms( INT_MIN ) {} // invalid time
+ explicit DmeTime_t( int tms ) : m_tms( tms ) {}
+ explicit DmeTime_t( float sec ) : m_tms( RoundSecondsToTMS( sec ) ) {}
+ explicit DmeTime_t( double sec ) : m_tms( RoundSecondsToTMS( sec ) ) {}
+ DmeTime_t( int frame, DmeFramerate_t framerate );
+
+
+ // time operators
+
+ bool operator==( DmeTime_t t ) const { return m_tms == t.m_tms; }
+ bool operator!=( DmeTime_t t ) const { return m_tms != t.m_tms; }
+ bool operator< ( DmeTime_t t ) const { return m_tms < t.m_tms; }
+ bool operator> ( DmeTime_t t ) const { return m_tms > t.m_tms; }
+ bool operator<=( DmeTime_t t ) const { return m_tms <= t.m_tms; }
+ bool operator>=( DmeTime_t t ) const { return m_tms >= t.m_tms; }
+
+ DmeTime_t operator%( DmeTime_t t ) const { return DmeTime_t( m_tms % t.m_tms ); }
+ DmeTime_t operator+( DmeTime_t t ) const { return DmeTime_t( m_tms + t.m_tms ); }
+ DmeTime_t operator-( DmeTime_t t ) const { return DmeTime_t( m_tms - t.m_tms ); }
+ DmeTime_t operator-() const { return DmeTime_t( -m_tms ); }
+
+ DmeTime_t operator+=( DmeTime_t t ) { m_tms += t.m_tms; return *this; }
+ DmeTime_t operator-=( DmeTime_t t ) { m_tms -= t.m_tms; return *this; }
+
+ // float operators - comment these out to find potentially incorrect uses of DmeTime_t
+
+ friend DmeTime_t operator*( DmeTime_t t, float f ) { t *= f; return t; }
+ friend DmeTime_t operator*( float f, DmeTime_t t ) { t *= f; return t; }
+ friend DmeTime_t operator/( DmeTime_t t, float f ) { t /= f; return t; }
+ friend float operator/( DmeTime_t n, DmeTime_t d ) { return float( n.m_tms / double( d.m_tms ) ); }
+
+ DmeTime_t operator*=( float f );
+ DmeTime_t operator/=( float f );
+
+
+ // limits, special values and validity
+
+ bool IsValid() const { return m_tms != INT_MIN; }
+
+ static DmeTime_t InvalidTime() { return DmeTime_t( INT_MIN ); }
+ static DmeTime_t MinTime() { return DmeTime_t( INT_MIN + 1 ); }
+ static DmeTime_t MaxTime() { return DmeTime_t( INT_MAX ); }
+ static DmeTime_t MinTimeDelta() { return DmeTime_t( 1 ); }
+
+
+ // conversions between other time representations
+
+ int GetTenthsOfMS() const { return m_tms; }
+ float GetSeconds() const { return DMETIME_TO_SECONDS( m_tms ); }
+ void SetTenthsOfMS( int tms ) { m_tms = tms; }
+ void SetSeconds( float sec ) { m_tms = RoundSecondsToTMS( sec ); }
+
+
+ // helper methods
+
+ void Clamp( DmeTime_t lo, DmeTime_t hi );
+ bool IsInRange( DmeTime_t lo, DmeTime_t hi ) const;
+
+
+ // helper functions
+ friend float GetFractionOfTime( DmeTime_t t, DmeTime_t duration, bool bClamp );
+ friend int FrameForTime( DmeTime_t t, DmeFramerate_t framerate );
+
+
+ // standard arithmetic methods
+
+ friend DmeTime_t abs( DmeTime_t t ) { return t.m_tms >= 0 ? t : -t; }
+
+
+ // framerate-dependent conversions to/from frames
+
+ int CurrentFrame( DmeFramerate_t framerate, bool bRoundDown = true ) const;
+ DmeTime_t TimeAtCurrentFrame( DmeFramerate_t framerate, bool bRoundDown = true ) const;
+ DmeTime_t TimeAtNextFrame( DmeFramerate_t framerate ) const;
+ DmeTime_t TimeAtPrevFrame( DmeFramerate_t framerate ) const;
+
+private:
+ DmeTime_t( int64 tms ) : m_tms( int( tms ) ) {}
+
+ // conversion helper methods - implementation
+ static int RoundSecondsToTMS( float sec );
+ static int RoundSecondsToTMS( double sec );
+
+ int m_tms;
+};
+
+float GetFractionOfTimeBetween( DmeTime_t t, DmeTime_t start, DmeTime_t end, bool bClamp = false );
+
+
+#endif // TIMEUTILS_H