1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// A class representing session state for the SFM
//
//=============================================================================
#ifndef SFMSESSION_H
#define SFMSESSION_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmehandle.h"
#include "datamodel/dmelement.h"
#include "tier1/utlvector.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CDmElement;
class CDmeFilmClip;
class CDmeClip;
struct studiohdr_t;
class Vector;
class Quaternion;
class CDmeGameModel;
class CDmeCamera;
class CDmeDag;
class CDmeAnimationSet;
//-----------------------------------------------------------------------------
// Camera creation paramaters
//-----------------------------------------------------------------------------
struct DmeCameraParams_t
{
DmeCameraParams_t() : fov( 90.0f )
{
name[ 0 ] = 0;
origin.Init();
angles.Init();
}
DmeCameraParams_t( const char *pszName ) : fov( 90.0f )
{
Q_strncpy( name, pszName ? pszName : "", sizeof( name ) );
origin.Init();
angles.Init();
}
DmeCameraParams_t( const char *pszName, const Vector &org, const QAngle &ang ) :
fov( 90.0f ), origin( org ), angles( ang )
{
Q_strncpy( name, pszName ? pszName : "", sizeof( name ) );
}
char name[ 128 ];
Vector origin;
QAngle angles;
float fov;
};
//-----------------------------------------------------------------------------
// A class representing the SFM Session
// FIXME: Should this be a dmelement? Maybe!
//-----------------------------------------------------------------------------
class CSFMSession
{
public:
CSFMSession();
// Creates a new (empty) session
void Init();
void Shutdown();
// Creates session settings
void CreateSessionSettings();
// Gets/sets the root
CDmElement *Root();
const CDmElement *Root() const;
void SetRoot( CDmElement *pRoot );
// Methods to get at session settings
template< class T > const T& GetSettings( const char *pSettingName ) const;
CDmAttribute * GetSettingsAttribute( const char *pSettingName, DmAttributeType_t type );
template< class E > E* GetSettingsElement( const char *pSettingName ) const;
template< class T > void SetSettings( const char *pSettingName, const T& value );
// Creates a game model
CDmeGameModel *CreateEditorGameModel( studiohdr_t *hdr, const Vector &vecOrigin, Quaternion &qOrientation );
// Creates a camera
CDmeCamera *CreateCamera( const DmeCameraParams_t& params );
// Finds or creates a scene
CDmeDag *FindOrCreateScene( CDmeFilmClip *pShot, const char *pSceneName );
private:
void CreateRenderSettings( CDmElement *pSettings, float flLegacyFramerate );
void CreateProgressiveRefinementSettings( CDmElement *pRenderSettings );
CDmeHandle< CDmElement > m_hRoot;
// CDmeHandle< CDmeFilmClip > m_hCurrentMovie;
// CUtlVector< CDmeHandle< CDmeClip > > m_hClipStack;
// CUtlVector< CDmeHandle< CDmeClip > > m_hSelectedClip[ NUM_SELECTION_TYPES ];
};
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
inline CDmElement *CSFMSession::Root()
{
return m_hRoot;
}
inline const CDmElement *CSFMSession::Root() const
{
return m_hRoot;
}
//-----------------------------------------------------------------------------
// Method to get at various settings
//-----------------------------------------------------------------------------
template< class T >
inline const T& CSFMSession::GetSettings( const char *pSettingName ) const
{
CDmElement *pSettings = m_hRoot.Get() ? m_hRoot->GetValueElement< CDmElement >( "settings" ) : NULL;
if ( pSettings )
return pSettings->GetValue< T >( pSettingName );
static T defaultVal;
CDmAttributeInfo<T>::SetDefaultValue( defaultVal );
return defaultVal;
}
inline CDmAttribute *CSFMSession::GetSettingsAttribute( const char *pSettingName, DmAttributeType_t type )
{
CDmElement *pSettings = m_hRoot.Get() ? m_hRoot->GetValueElement< CDmElement >( "settings" ) : NULL;
if ( pSettings )
return pSettings->GetAttribute( pSettingName, type );
return NULL;
}
template< class T >
inline void CSFMSession::SetSettings( const char *pSettingName, const T& value )
{
CDmElement *pSettings = m_hRoot.Get() ? m_hRoot->GetValueElement< CDmElement >( "settings" ) : NULL;
if ( pSettings )
{
pSettings->SetValue( pSettingName, value );
}
}
template< class E >
inline E* CSFMSession::GetSettingsElement( const char *pSettingName ) const
{
CDmElement *pSettings = m_hRoot->GetValueElement< CDmElement >( "settings" );
return pSettings ? pSettings->GetValueElement< E >( pSettingName ) : NULL;
}
#endif // SFMSESSION_H
|