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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include "dme_controls/dmedagrenderpanel.h"
#include "movieobjects/dmedag.h"
#include "movieobjects/dmemodel.h"
#include "movieobjects/timeutils.h"
#include "movieobjects/dmeanimationlist.h"
#include "movieobjects/dmeclip.h"
#include "movieobjects/dmechannel.h"
#include "movieobjects/dmemdlmakefile.h"
#include "movieobjects/dmedccmakefile.h"
#include "movieobjects/dmemesh.h"
#include "movieobjects/dmedrawsettings.h"
#include "dme_controls/dmepanel.h"
#include "tier1/KeyValues.h"
#include "VGuiMatSurface/IMatSystemSurface.h"
#include "tier3/tier3.h"
#include "materialsystem/imaterialsystemhardwareconfig.h"
#include "materialsystem/imesh.h"
#include "vgui_controls/Menu.h"
#include "vgui_controls/MenuBar.h"
#include "vgui_controls/MenuButton.h"
#include "vgui/IVGui.h"
//-----------------------------------------------------------------------------
//
// Hook into the dme panel editor system
//
//-----------------------------------------------------------------------------
IMPLEMENT_DMEPANEL_FACTORY( CDmeDagRenderPanel, DmeDag, "DmeDagRenderer", "DmeDag Preview Renderer", false );
IMPLEMENT_DMEPANEL_FACTORY( CDmeDagRenderPanel, DmeSourceSkin, "DmeSourceSkinPreview", "MDL Skin Previewer", false );
IMPLEMENT_DMEPANEL_FACTORY( CDmeDagRenderPanel, DmeSourceAnimation, "DmeSourceAnimationPreview", "MDL Animation Previewer", false );
IMPLEMENT_DMEPANEL_FACTORY( CDmeDagRenderPanel, DmeDCCMakefile, "DmeMakeFileOutputPreview", "DCC MakeFile Output Preview", false );
//-----------------------------------------------------------------------------
// Constructor, destructor
//-----------------------------------------------------------------------------
CDmeDagRenderPanel::CDmeDagRenderPanel( vgui::Panel *pParent, const char *pName ) : BaseClass( pParent, pName )
{
// Used to poll input
vgui::ivgui()->AddTickSignal( GetVPanel() );
m_bDrawJointNames = false;
m_bDrawJoints = false;
m_bDrawGrid = true;
// Deal with the default cubemap
ITexture *pCubemapTexture = g_pMaterialSystem->FindTexture( "editor/cubemap", NULL, true );
m_DefaultEnvCubemap.Init( pCubemapTexture );
pCubemapTexture = g_pMaterialSystem->FindTexture( "editor/cubemap.hdr", NULL, true );
m_DefaultHDREnvCubemap.Init( pCubemapTexture );
m_pDrawSettings = CreateElement< CDmeDrawSettings >( "drawSettings", g_pDataModel->FindOrCreateFileId( "DagRenderPanelDrawSettings" ) );
m_hDrawSettings = m_pDrawSettings;
m_pMenuBar = new vgui::MenuBar( this, "Dag Render Panel Menu Bar" );
m_pShadingMenu = new vgui::Menu( NULL, "Shading Menu" );
m_nMenuSmoothShade = m_pShadingMenu->AddCheckableMenuItem( "&Smooth Shade", new KeyValues( "SmoothShade" ), this );
m_nMenuFlatShade = m_pShadingMenu->AddCheckableMenuItem( "&Flat Shade", new KeyValues( "FlatShade" ), this );
m_nMenuWireframe = m_pShadingMenu->AddCheckableMenuItem( "&Wireframe", new KeyValues( "Wireframe" ), this );
m_pShadingMenu->AddSeparator();
m_nMenuBoundingBox = m_pShadingMenu->AddCheckableMenuItem( "&Bounding Box", new KeyValues( "BoundingBox" ), this );
m_pShadingMenu->AddSeparator(); // Bug is visibility
m_nMenuNormals = m_pShadingMenu->AddCheckableMenuItem( "&Normals", new KeyValues( "Normals" ), this );
m_nMenuWireframeOnShaded = m_pShadingMenu->AddCheckableMenuItem( "WireFrame &On Shaded", new KeyValues( "WireframeOnShaded" ), this );
m_nMenuBackfaceCulling = m_pShadingMenu->AddCheckableMenuItem( "&Backface Culling", new KeyValues( "BackfaceCulling" ), this );
m_nMenuXRay = m_pShadingMenu->AddCheckableMenuItem( "&X-Ray", new KeyValues( "XRay" ), this );
m_nMenuGrayShade = m_pShadingMenu->AddCheckableMenuItem( "&Gray Shade", new KeyValues( "GrayShade" ), this );
// For now...
m_pShadingMenu->SetItemVisible( m_nMenuFlatShade, false );
m_pShadingMenu->SetItemEnabled( m_nMenuFlatShade, false );
m_pShadingMenu->SetItemVisible( m_nMenuBoundingBox, false );
m_pShadingMenu->SetItemEnabled( m_nMenuBoundingBox, false );
m_pShadingMenu->SetItemVisible( m_nMenuBackfaceCulling, false );
m_pShadingMenu->SetItemEnabled( m_nMenuBackfaceCulling, false );
m_pShadingMenu->SetItemVisible( m_nMenuXRay, false );
m_pShadingMenu->SetItemEnabled( m_nMenuXRay, false );
m_pMenuBar->AddMenu( "&Shading", m_pShadingMenu );
UpdateMenu();
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
CDmeDagRenderPanel::~CDmeDagRenderPanel()
{
}
//-----------------------------------------------------------------------------
// Scheme settings
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::ApplySchemeSettings( vgui::IScheme *pScheme )
{
BaseClass::ApplySchemeSettings( pScheme );
SetBorder( pScheme->GetBorder( "MenuBorder") );
m_hFont = pScheme->GetFont( "DmePropertyVerySmall", IsProportional() );
}
//-----------------------------------------------------------------------------
// Set the scene
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::SetDmeElement( CDmeDag *pScene )
{
m_hDag = pScene;
ComputeDefaultTangentData( m_hDag, false );
}
//-----------------------------------------------------------------------------
// Other methods which hook into DmePanel
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::SetDmeElement( CDmeSourceSkin *pSkin )
{
// First, try to grab the dependent makefile
CDmeMakefile *pSourceMakefile = pSkin->GetDependentMakefile();
if ( !pSourceMakefile )
{
m_hDag = NULL;
return;
}
// Next, try to grab the output of that makefile
CDmElement *pOutput = pSourceMakefile->GetOutputElement( true );
if ( !pOutput )
{
m_hDag = NULL;
return;
}
// Finally, grab the 'skin' attribute of that makefile
m_hDag = pOutput->GetValueElement< CDmeDag >( "model" );
ComputeDefaultTangentData( m_hDag, false );
DrawJoints( false );
DrawJointNames( false );
}
void CDmeDagRenderPanel::SetDmeElement( CDmeSourceAnimation *pAnimation )
{
// First, try to grab the dependent makefile
CDmeMakefile *pSourceMakefile = pAnimation->GetDependentMakefile();
if ( !pSourceMakefile )
{
m_hDag = NULL;
return;
}
// Next, try to grab the output of that makefile
CDmElement *pOutput = pSourceMakefile->GetOutputElement( true );
if ( !pOutput )
{
m_hDag = NULL;
return;
}
// Finally, grab the 'model' or 'skeleton' attribute of that makefile
CDmeDag *pDag = pOutput->GetValueElement< CDmeDag >( "model" );
if ( !pDag )
{
pDag = pOutput->GetValueElement< CDmeDag >( "skeleton" );
}
if ( !pDag )
return;
CDmeAnimationList *pAnimationList = pOutput->GetValueElement< CDmeAnimationList >( "animationList" );
if ( !pAnimationList )
return;
if ( pAnimationList->FindAnimation( pAnimation->m_SourceAnimationName ) < 0 )
return;
m_hDag = pDag;
ComputeDefaultTangentData( m_hDag, false );
m_hAnimationList = pAnimationList;
SelectAnimation( pAnimation->m_SourceAnimationName );
DrawJoints( true );
DrawJointNames( true );
}
void CDmeDagRenderPanel::SetDmeElement( CDmeDCCMakefile *pDCCMakefile )
{
// First, try to grab the dependent makefile
CDmElement *pOutputElement = pDCCMakefile->GetOutputElement( true );
if ( !pOutputElement )
{
m_hDag = NULL;
return;
}
// Finally, grab the 'model' or 'skeleton' attribute of that makefile
CDmeDag *pDag = pOutputElement->GetValueElement< CDmeDag >( "model" );
if ( !pDag )
{
pDag = pOutputElement->GetValueElement< CDmeDag >( "skeleton" );
}
if ( !pDag )
return;
CDmeAnimationList *pAnimationList = pOutputElement->GetValueElement< CDmeAnimationList >( "animationList" );
m_hDag = pDag;
ComputeDefaultTangentData( m_hDag, false );
m_hAnimationList = pAnimationList;
SelectAnimation( 0 );
DrawJoints( pAnimationList != NULL );
DrawJointNames( pAnimationList != NULL );
}
CDmeDag *CDmeDagRenderPanel::GetDmeElement()
{
return m_hDag;
}
//-----------------------------------------------------------------------------
// Draw joint names
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::DrawJointNames( CDmeDag *pRoot, CDmeDag *pDag, const matrix3x4_t& parentToWorld )
{
CDmeTransform *pJointTransform = pDag->GetTransform();
int nJointIndex = -1;
CDmeModel *pRootModel = CastElement<CDmeModel>( pRoot );
if ( pRootModel )
{
nJointIndex = pRootModel->GetJointTransformIndex( pJointTransform );
if ( nJointIndex < 0 && pRootModel != pDag )
return;
}
matrix3x4_t jointToParent, jointToWorld;
pJointTransform->GetTransform( jointToParent );
ConcatTransforms( parentToWorld, jointToParent, jointToWorld );
CDmeJoint *pJoint = CastElement< CDmeJoint >( pDag );
if ( pJoint )
{
Vector vecJointOrigin;
MatrixGetColumn( jointToWorld, 3, &vecJointOrigin );
Vector2D vecPanelPos;
ComputePanelPosition( vecJointOrigin, &vecPanelPos );
char pJointName[512];
if ( nJointIndex >= 0 )
{
Q_snprintf( pJointName, sizeof(pJointName), "%d : %s", nJointIndex, pJoint->GetName() );
}
else
{
Q_snprintf( pJointName, sizeof(pJointName), "%s", pJoint->GetName() );
}
g_pMatSystemSurface->DrawColoredText( m_hFont, vecPanelPos.x + 5, vecPanelPos.y, 255, 255, 255, 255, pJointName );
}
int nCount = pDag->GetChildCount();
for ( int i = 0; i < nCount; ++i )
{
CDmeDag *pChild = pDag->GetChild(i);
if ( !pChild )
continue;
DrawJointNames( pRoot, pChild, jointToWorld );
}
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::OnSmoothShade()
{
if ( m_pShadingMenu->IsChecked( m_nMenuSmoothShade ) )
{
m_pDrawSettings->SetDrawType( CDmeDrawSettings::DRAW_SMOOTH );
}
UpdateMenu();
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::OnFlatShade()
{
if ( m_pShadingMenu->IsChecked( m_nMenuFlatShade ) )
{
m_pDrawSettings->SetDrawType( CDmeDrawSettings::DRAW_FLAT );
}
UpdateMenu();
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::OnWireframe()
{
if ( m_pShadingMenu->IsChecked( m_nMenuWireframe ) )
{
m_pDrawSettings->SetDrawType( CDmeDrawSettings::DRAW_WIREFRAME );
}
UpdateMenu();
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::OnBoundingBox()
{
if ( m_pShadingMenu->IsChecked( m_nMenuBoundingBox ) )
{
m_pDrawSettings->SetDrawType( CDmeDrawSettings::DRAW_BOUNDINGBOX );
}
UpdateMenu();
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::OnNormals()
{
m_pDrawSettings->SetNormals( m_pShadingMenu->IsChecked( m_nMenuNormals ) );
UpdateMenu();
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::OnWireframeOnShaded()
{
m_pDrawSettings->SetWireframeOnShaded( m_pShadingMenu->IsChecked( m_nMenuWireframeOnShaded ) );
UpdateMenu();
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::OnBackfaceCulling()
{
m_pDrawSettings->SetBackfaceCulling( m_pShadingMenu->IsChecked( m_nMenuBackfaceCulling ) );
UpdateMenu();
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::OnXRay()
{
m_pDrawSettings->SetXRay( m_pShadingMenu->IsChecked( m_nMenuXRay ) );
UpdateMenu();
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::OnGrayShade()
{
m_pDrawSettings->SetGrayShade( m_pShadingMenu->IsChecked( m_nMenuGrayShade ) );
UpdateMenu();
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::OnFrame()
{
if ( !m_hDag )
return;
float flRadius;
Vector vecCenter, vecWorldCenter;
m_hDag->GetBoundingSphere( vecCenter, flRadius );
matrix3x4_t dmeToEngine;
CDmeDag::DmeToEngineMatrix( dmeToEngine );
VectorTransform( vecCenter, dmeToEngine, vecWorldCenter );
LookAt( vecWorldCenter, flRadius );
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::PerformLayout()
{
BaseClass::PerformLayout();
if ( m_pMenuBar->IsVisible() )
{
int iWidth;
int iHeight;
GetSize( iWidth, iHeight );
int iMenuWidth; // Unused
int iMenuHeight;
m_pMenuBar->GetSize( iMenuWidth, iMenuHeight );
m_pMenuBar->SetSize( iWidth, iMenuHeight );
}
}
//-----------------------------------------------------------------------------
// paint it!
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::Paint()
{
if ( m_hCurrentAnimation.Get() )
{
DmeTime_t currentTime( Plat_FloatTime() - m_flStartTime );
if ( m_hCurrentAnimation->GetDuration() != DMETIME_ZERO )
{
currentTime = currentTime % m_hCurrentAnimation->GetDuration();
}
else
{
currentTime = DMETIME_ZERO;
}
currentTime += m_hCurrentAnimation->GetStartTime();
DmeTime_t mediaTime = m_hCurrentAnimation->ToChildMediaTime( currentTime, true );
int nChannelCount = m_hCurrentAnimation->m_Channels.Count();
for ( int i = 0; i < nChannelCount; ++i )
{
m_hCurrentAnimation->m_Channels[i]->SetCurrentTime( mediaTime );
}
}
if ( m_hCurrentVertexAnimation.Get() )
{
DmeTime_t currentTime( Plat_FloatTime() - m_flStartTime );
currentTime = currentTime % m_hCurrentVertexAnimation->GetDuration();
currentTime += m_hCurrentVertexAnimation->GetStartTime();
DmeTime_t mediaTime = m_hCurrentVertexAnimation->ToChildMediaTime( currentTime, true );
int nChannelCount = m_hCurrentVertexAnimation->m_Channels.Count();
for ( int i = 0; i < nChannelCount; ++i )
{
m_hCurrentVertexAnimation->m_Channels[i]->SetCurrentTime( mediaTime );
}
}
// FIXME: Shouldn't this happen at the application level?
// run the machinery - apply, resolve, dependencies, operate, resolve
{
CDisableUndoScopeGuard guard;
g_pDmElementFramework->SetOperators( m_operators );
g_pDmElementFramework->Operate( true );
}
// allow elements and attributes to be edited again
g_pDmElementFramework->BeginEdit();
BaseClass::Paint();
// Overlay the joint names
if ( m_bDrawJointNames && m_hDag )
{
matrix3x4_t modelToWorld;
CDmeDag::DmeToEngineMatrix( modelToWorld );
DrawJointNames( m_hDag, m_hDag, modelToWorld );
}
}
//-----------------------------------------------------------------------------
// Indicate we should draw joint names
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::DrawJointNames( bool bDrawJointNames )
{
m_bDrawJointNames = bDrawJointNames;
}
//-----------------------------------------------------------------------------
// Indicate we should draw joints
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::DrawJoints( bool bDrawJoint )
{
m_bDrawJoints = bDrawJoint;
}
//-----------------------------------------------------------------------------
// Indicate we should draw the grid
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::DrawGrid( bool bDrawGrid )
{
m_bDrawGrid = bDrawGrid;
}
//-----------------------------------------------------------------------------
// paint it!
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::OnPaint3D()
{
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
ITexture *pLocalCube = pRenderContext->GetLocalCubemap();
if ( g_pMaterialSystemHardwareConfig->GetHDRType() == HDR_TYPE_NONE )
{
pRenderContext->BindLocalCubemap( m_DefaultEnvCubemap );
}
else
{
pRenderContext->BindLocalCubemap( m_DefaultHDREnvCubemap );
}
if ( m_bDrawGrid )
{
BaseClass::DrawGrid();
}
if ( m_bDrawJoints )
{
CDmeJoint::DrawJointHierarchy( true );
}
pRenderContext->CullMode( MATERIAL_CULLMODE_CW );
CDmeDag::DrawUsingEngineCoordinates( true );
m_pDrawSettings->DrawDag( m_hDag );
CDmeDag::DrawUsingEngineCoordinates( false );
pRenderContext->Flush();
pRenderContext->BindLocalCubemap( pLocalCube );
}
//-----------------------------------------------------------------------------
// input
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::OnMouseDoublePressed( vgui::MouseCode code )
{
OnFrame();
BaseClass::OnMouseDoublePressed( code );
}
//-----------------------------------------------------------------------------
// TODO: Have a whole groovy keybinding thingy like SFM
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::OnKeyCodePressed( vgui::KeyCode code )
{
BaseClass::OnKeyCodePressed( code );
if ( code == KEY_F )
{
OnFrame();
}
}
//-----------------------------------------------------------------------------
// Rebuilds the list of operators
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::RebuildOperatorList( )
{
m_operators.RemoveAll();
if ( m_hCurrentAnimation.Get() )
{
int nChannelCount = m_hCurrentAnimation->m_Channels.Count();
for ( int i = 0; i < nChannelCount; ++i )
{
m_hCurrentAnimation->m_Channels[i]->SetMode( CM_PLAY );
m_operators.AddToTail( m_hCurrentAnimation->m_Channels[i] );
}
}
if ( m_hCurrentVertexAnimation.Get() )
{
int nChannelCount = m_hCurrentVertexAnimation->m_Channels.Count();
for ( int i = 0; i < nChannelCount; ++i )
{
m_hCurrentVertexAnimation->m_Channels[i]->SetMode( CM_PLAY );
m_operators.AddToTail( m_hCurrentVertexAnimation->m_Channels[i] );
}
}
m_flStartTime = Plat_FloatTime();
}
//-----------------------------------------------------------------------------
// Select animation by index
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::SelectAnimation( int nIndex )
{
m_hCurrentAnimation = NULL;
if ( m_hAnimationList.Get() && ( nIndex >= 0 ) )
{
// FIXME: How is this actually going to work?
m_hCurrentAnimation = m_hAnimationList->GetAnimation( nIndex );
}
RebuildOperatorList();
}
void CDmeDagRenderPanel::SelectVertexAnimation( int nIndex )
{
m_hCurrentVertexAnimation = NULL;
if ( m_hVertexAnimationList.Get() && ( nIndex >= 0 ) )
{
// FIXME: How is this actually going to work?
m_hCurrentVertexAnimation = m_hVertexAnimationList->GetAnimation( nIndex );
}
RebuildOperatorList();
}
//-----------------------------------------------------------------------------
// Select animation by name
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::SelectAnimation( const char *pAnimName )
{
if ( !pAnimName[0] )
{
SelectAnimation( -1 );
return;
}
if ( m_hAnimationList )
{
int nIndex = m_hAnimationList->FindAnimation( pAnimName );
if ( nIndex >= 0 )
{
SelectAnimation( nIndex );
}
}
}
void CDmeDagRenderPanel::SelectVertexAnimation( const char *pAnimName )
{
if ( !pAnimName[0] )
{
SelectVertexAnimation( -1 );
return;
}
if ( m_hVertexAnimationList )
{
int nIndex = m_hVertexAnimationList->FindAnimation( pAnimName );
if ( nIndex >= 0 )
{
SelectVertexAnimation( nIndex );
}
}
}
//-----------------------------------------------------------------------------
// Sets animation
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::SetAnimationList( CDmeAnimationList *pAnimationList )
{
m_hAnimationList = pAnimationList;
int nCount = pAnimationList ? pAnimationList->GetAnimationCount() : 0;
if ( nCount == 0 )
{
m_hCurrentAnimation = NULL;
return;
}
SelectAnimation( 0 );
}
void CDmeDagRenderPanel::SetVertexAnimationList( CDmeAnimationList *pAnimationList )
{
m_hVertexAnimationList = pAnimationList;
int nCount = pAnimationList ? pAnimationList->GetAnimationCount() : 0;
if ( nCount == 0 )
{
m_hCurrentVertexAnimation = NULL;
return;
}
SelectVertexAnimation( 0 );
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void CDmeDagRenderPanel::UpdateMenu()
{
switch ( m_pDrawSettings->GetDrawType() )
{
case CDmeDrawSettings::DRAW_FLAT:
m_pShadingMenu->SetMenuItemChecked( m_nMenuSmoothShade, false );
m_pShadingMenu->SetMenuItemChecked( m_nMenuFlatShade, true );
m_pShadingMenu->SetMenuItemChecked( m_nMenuWireframe, false );
m_pShadingMenu->SetMenuItemChecked( m_nMenuBoundingBox, false );
break;
case CDmeDrawSettings::DRAW_WIREFRAME:
m_pShadingMenu->SetMenuItemChecked( m_nMenuSmoothShade, false );
m_pShadingMenu->SetMenuItemChecked( m_nMenuFlatShade, false );
m_pShadingMenu->SetMenuItemChecked( m_nMenuWireframe, true );
m_pShadingMenu->SetMenuItemChecked( m_nMenuBoundingBox, false );
break;
case CDmeDrawSettings::DRAW_BOUNDINGBOX:
m_pShadingMenu->SetMenuItemChecked( m_nMenuSmoothShade, false );
m_pShadingMenu->SetMenuItemChecked( m_nMenuFlatShade, false );
m_pShadingMenu->SetMenuItemChecked( m_nMenuWireframe, false );
m_pShadingMenu->SetMenuItemChecked( m_nMenuBoundingBox, true );
break;
default:
m_pShadingMenu->SetMenuItemChecked( m_nMenuSmoothShade, true );
m_pShadingMenu->SetMenuItemChecked( m_nMenuFlatShade, false );
m_pShadingMenu->SetMenuItemChecked( m_nMenuWireframe, false );
m_pShadingMenu->SetMenuItemChecked( m_nMenuBoundingBox, false );
break;
}
m_pShadingMenu->SetMenuItemChecked( m_nMenuNormals, m_pDrawSettings->GetNormals() );
m_pShadingMenu->SetMenuItemChecked( m_nMenuWireframeOnShaded, m_pDrawSettings->GetWireframeOnShaded() );
m_pShadingMenu->SetMenuItemChecked( m_nMenuBackfaceCulling, m_pDrawSettings->GetBackfaceCulling() );
m_pShadingMenu->SetMenuItemChecked( m_nMenuXRay, m_pDrawSettings->GetXRay() );
m_pShadingMenu->SetMenuItemChecked( m_nMenuGrayShade, m_pDrawSettings->GetGrayShade() );
}
|