1 /*---------------------------------------------------------------------------*
2 Project: NintendoWare
3 File: demo_Utility.cpp
4
5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Revision: 28443 $
14 *---------------------------------------------------------------------------*/
15
16 #include <nw/types.h>
17 #include <nw/os.h>
18 #include <nw/ut/ut_Inlines.h>
19 #include <nw/demo/demo_Utility.h>
20 #include <nw/gfx.h>
21
22 #include <nn/fs.h>
23 #include <nn/pl.h>
24
25 namespace nw {
26 namespace demo {
27
28 const nw::math::VEC3 Utility::CAMERA_POSITION = nw::math::VEC3(7.0f, 3.5f, -5.0f);
29 const nw::math::VEC3 Utility::TARGET_POSITION = nw::math::VEC3(0.0f, 0.0f, 0.0f);
30 const f32 Utility::NEAR_CLIP = 0.1f;
31 const f32 Utility::FAR_CLIP = 1000.0f;
32 const f32 Utility::FOVY_RADIAN = NW_MATH_DEG_TO_RAD(37.8f);
33 const nw::math::VEC2 Utility::PROJECTION_CENTER = nw::math::VEC2(0.0f, 0.0f);
34 const f32 Utility::PROJECTION_HEIGHT = 1.0f;
35
36 const wchar_t* Utility::FONT_SHADER_FILE_NAME = NW_DEMO_FILE_PATH(L"nwfont_RectDrawerShader.shbin");
37 const wchar_t* Utility::SHAPE_2D_SHADER_FILE_NAME = NW_DEMO_FILE_PATH(L"nwdemo_Common.shbin");
38 bool Utility::s_SharedFontAlreadyInitialized = false;
39
40 //----------------------------------------
41 void
InitializeGraphicsDrawing(os::IAllocator * allocator,nw::demo::GraphicsDrawing & graphicsDrawing)42 Utility::InitializeGraphicsDrawing(
43 os::IAllocator* allocator,
44 nw::demo::GraphicsDrawing& graphicsDrawing
45 )
46 {
47 bool result = false;
48
49 result = InitializeSharedFont(allocator, graphicsDrawing);
50 NN_ASSERTMSG(result, "Fail to load Font.");
51
52 result = graphicsDrawing.InitializeShape(allocator, SHAPE_2D_SHADER_FILE_NAME);
53 NN_ASSERTMSG(result, "Fail to initialize shape drawing.");
54
55 NW_UNUSED_VARIABLE(result);
56 }
57
58 //----------------------------------------
59 ResourceSet*
LoadResources(ResourceArray & resourceArray,const wchar_t * resourcePath,os::IAllocator * allocator)60 Utility::LoadResources(ResourceArray& resourceArray, const wchar_t* resourcePath, os::IAllocator* allocator)
61 {
62 ResourceSet resourceSet;
63 // 現在、デバイスメモリ上に読み込む方式にのみ対応しています。
64 // テクスチャをロードするには128byteアライメントを行う必要があります。
65 const int resourceAlignment = 128;
66 resourceSet.buffer = nw::demo::Utility::LoadFile(allocator, resourcePath, resourceAlignment);
67
68 if (!resourceSet.buffer)
69 {
70 return NULL;
71 }
72
73 resourceSet.resource = nw::gfx::ResGraphicsFile(&(resourceSet.buffer.front()));
74
75 bool isPushed = resourceArray.push_back(resourceSet);
76
77 NW_ASSERT(isPushed);
78
79 return &(resourceArray.back());
80 }
81
82 //----------------------------------------
83 nw::gfx::Camera*
CreateCamera(os::IAllocator * allocator,const nw::math::VEC3 & cameraPosition,const nw::math::VEC3 & targetPosition,f32 nearClip,f32 farClip,f32 fovyRadian,nw::math::PivotDirection pivotDirection,f32 wScale)84 Utility::CreateCamera(
85 os::IAllocator* allocator,
86 const nw::math::VEC3& cameraPosition,
87 const nw::math::VEC3& targetPosition,
88 f32 nearClip,
89 f32 farClip,
90 f32 fovyRadian,
91 nw::math::PivotDirection pivotDirection,
92 f32 wScale
93 )
94 {
95 NW_POINTER_ASSERT(allocator);
96
97 nw::gfx::LookAtTargetViewUpdater* viewUpdater =
98 nw::gfx::LookAtTargetViewUpdater::Create(allocator);
99 NW_POINTER_ASSERT(viewUpdater);
100
101 nw::gfx::ResLookAtTargetViewUpdater resViewUpdater =
102 nw::gfx::ResStaticCast<nw::gfx::ResLookAtTargetViewUpdater>(viewUpdater->GetResource());
103
104 resViewUpdater.SetTargetPosition(targetPosition);
105 resViewUpdater.SetUpwardVector(0.0f,1.0f,0.0f);
106
107 nw::gfx::PerspectiveProjectionUpdater* projectionUpdater =
108 nw::gfx::PerspectiveProjectionUpdater::Create(allocator);
109 NW_POINTER_ASSERT(projectionUpdater);
110
111 projectionUpdater->SetPivotDirection(pivotDirection);
112
113 nw::gfx::ResPerspectiveProjectionUpdater resProjectionUpdater =
114 nw::gfx::ResStaticCast<nw::gfx::ResPerspectiveProjectionUpdater>(
115 projectionUpdater->GetResource());
116 resProjectionUpdater.SetNear(nearClip);
117 resProjectionUpdater.SetFar(farClip);
118 resProjectionUpdater.SetFovy(fovyRadian);
119
120 nw::gfx::Camera* camera =
121 nw::gfx::Camera::DynamicBuilder()
122 .MaxChildren(0)
123 .MaxCallbacks(0)
124 .ViewUpdater(viewUpdater)
125 .ProjectionUpdater(projectionUpdater)
126 .Create(allocator);
127
128 NW_POINTER_ASSERT(camera);
129
130 camera->Transform().SetTranslate(cameraPosition);
131 camera->SetWScale(wScale);
132
133 return camera;
134 }
135
136 //----------------------------------------
137 nw::gfx::Camera*
CreateAimCamera(os::IAllocator * allocator,const nw::math::VEC3 & cameraPosition,const nw::math::VEC3 & targetPosition,f32 nearClip,f32 farClip,f32 fovyRadian,nw::math::PivotDirection pivotDirection,f32 wScale)138 Utility::CreateAimCamera(
139 os::IAllocator* allocator,
140 const nw::math::VEC3& cameraPosition,
141 const nw::math::VEC3& targetPosition,
142 f32 nearClip,
143 f32 farClip,
144 f32 fovyRadian,
145 nw::math::PivotDirection pivotDirection,
146 f32 wScale
147 )
148 {
149 NW_POINTER_ASSERT(allocator);
150
151 nw::gfx::AimTargetViewUpdater* viewUpdater =
152 nw::gfx::AimTargetViewUpdater::Create(allocator);
153 NW_POINTER_ASSERT(viewUpdater);
154
155 nw::gfx::ResAimTargetViewUpdater resViewUpdater =
156 nw::gfx::ResStaticCast<nw::gfx::ResAimTargetViewUpdater>(viewUpdater->GetResource());
157
158 resViewUpdater.SetTargetPosition(targetPosition);
159 resViewUpdater.SetTwist(0.0f);
160
161 nw::gfx::PerspectiveProjectionUpdater* projectionUpdater =
162 nw::gfx::PerspectiveProjectionUpdater::Create(allocator);
163 NW_POINTER_ASSERT(projectionUpdater);
164
165 projectionUpdater->SetPivotDirection(pivotDirection);
166
167 nw::gfx::ResPerspectiveProjectionUpdater resProjectionUpdater =
168 nw::gfx::ResStaticCast<nw::gfx::ResPerspectiveProjectionUpdater>(
169 projectionUpdater->GetResource());
170 resProjectionUpdater.SetNear(nearClip);
171 resProjectionUpdater.SetFar(farClip);
172 resProjectionUpdater.SetFovy(fovyRadian);
173
174 nw::gfx::Camera* camera =
175 nw::gfx::Camera::DynamicBuilder()
176 .MaxChildren(0)
177 .MaxCallbacks(0)
178 .ViewUpdater(viewUpdater)
179 .ProjectionUpdater(projectionUpdater)
180 .Create(allocator);
181
182 NW_POINTER_ASSERT(camera);
183
184 camera->Transform().SetTranslate(cameraPosition);
185 camera->SetWScale(wScale);
186
187 return camera;
188 }
189
190 //----------------------------------------
191 nw::gfx::Camera*
CreateFrustumCamera(os::IAllocator * allocator,const nw::math::VEC3 & cameraPosition,const nw::math::VEC3 & targetPosition,f32 nearClip,f32 farClip,const nw::math::VEC2 & projectionCenter,f32 projectionHeight,nw::math::PivotDirection pivotDirection,f32 wScale)192 Utility::CreateFrustumCamera(
193 os::IAllocator* allocator,
194 const nw::math::VEC3& cameraPosition,
195 const nw::math::VEC3& targetPosition,
196 f32 nearClip,
197 f32 farClip,
198 const nw::math::VEC2& projectionCenter,
199 f32 projectionHeight,
200 nw::math::PivotDirection pivotDirection,
201 f32 wScale
202 )
203 {
204 NW_POINTER_ASSERT(allocator);
205
206 nw::gfx::LookAtTargetViewUpdater* viewUpdater =
207 nw::gfx::LookAtTargetViewUpdater::Create(allocator);
208 NW_POINTER_ASSERT(viewUpdater);
209
210 nw::gfx::ResLookAtTargetViewUpdater resViewUpdater =
211 nw::gfx::ResStaticCast<nw::gfx::ResLookAtTargetViewUpdater>(viewUpdater->GetResource());
212
213 resViewUpdater.SetTargetPosition(targetPosition);
214 resViewUpdater.SetUpwardVector(0.0f,1.0f,0.0f);
215
216 nw::gfx::FrustumProjectionUpdater* projectionUpdater =
217 nw::gfx::FrustumProjectionUpdater::Create(allocator);
218 NW_POINTER_ASSERT(projectionUpdater);
219
220 projectionUpdater->SetPivotDirection(pivotDirection);
221
222 nw::gfx::ResFrustumProjectionUpdater resProjectionUpdater =
223 nw::gfx::ResStaticCast<nw::gfx::ResFrustumProjectionUpdater>(
224 projectionUpdater->GetResource());
225 resProjectionUpdater.SetNear(nearClip);
226 resProjectionUpdater.SetFar(farClip);
227 nw::gfx::ResProjectionRect rect = resProjectionUpdater.GetRect();
228 rect.m_Center = projectionCenter;
229 rect.m_Height = projectionHeight;
230 resProjectionUpdater.SetRect(rect);
231
232 nw::gfx::Camera* camera =
233 nw::gfx::Camera::DynamicBuilder()
234 .MaxChildren(0)
235 .MaxCallbacks(0)
236 .ViewUpdater(viewUpdater)
237 .ProjectionUpdater(projectionUpdater)
238 .Create(allocator);
239
240 NW_POINTER_ASSERT(camera);
241
242 camera->Transform().SetTranslate(cameraPosition);
243 camera->SetWScale(wScale);
244
245 return camera;
246 }
247
248 //----------------------------------------
249 nw::gfx::Camera*
CreateOrthoCamera(os::IAllocator * allocator,const nw::math::VEC3 & cameraPosition,const nw::math::VEC3 & targetPosition,f32 nearClip,f32 farClip,const nw::math::VEC2 & projectionCenter,f32 projectionHeight,nw::math::PivotDirection pivotDirection,f32 wScale)250 Utility::CreateOrthoCamera(
251 os::IAllocator* allocator,
252 const nw::math::VEC3& cameraPosition,
253 const nw::math::VEC3& targetPosition,
254 f32 nearClip,
255 f32 farClip,
256 const nw::math::VEC2& projectionCenter,
257 f32 projectionHeight,
258 nw::math::PivotDirection pivotDirection,
259 f32 wScale
260 )
261 {
262 NW_POINTER_ASSERT(allocator);
263
264 nw::gfx::LookAtTargetViewUpdater* viewUpdater =
265 nw::gfx::LookAtTargetViewUpdater::Create(allocator);
266 NW_POINTER_ASSERT(viewUpdater);
267
268 nw::gfx::ResLookAtTargetViewUpdater resViewUpdater =
269 nw::gfx::ResStaticCast<nw::gfx::ResLookAtTargetViewUpdater>(viewUpdater->GetResource());
270
271 resViewUpdater.SetTargetPosition(targetPosition);
272 resViewUpdater.SetUpwardVector(0.0f,1.0f,0.0f);
273
274 nw::gfx::OrthoProjectionUpdater* projectionUpdater =
275 nw::gfx::OrthoProjectionUpdater::Create(allocator);
276 NW_POINTER_ASSERT(projectionUpdater);
277
278 projectionUpdater->SetPivotDirection(pivotDirection);
279
280 nw::gfx::ResOrthoProjectionUpdater resProjectionUpdater =
281 nw::gfx::ResStaticCast<nw::gfx::ResOrthoProjectionUpdater>(
282 projectionUpdater->GetResource());
283 resProjectionUpdater.SetNear(nearClip);
284 resProjectionUpdater.SetFar(farClip);
285 nw::gfx::ResProjectionRect rect = resProjectionUpdater.GetRect();
286 rect.m_Center = projectionCenter;
287 rect.m_Height = projectionHeight;
288 resProjectionUpdater.SetRect(rect);
289
290 nw::gfx::Camera* camera =
291 nw::gfx::Camera::DynamicBuilder()
292 .MaxChildren(0)
293 .MaxCallbacks(0)
294 .ViewUpdater(viewUpdater)
295 .ProjectionUpdater(projectionUpdater)
296 .Create(allocator);
297
298 NW_POINTER_ASSERT(camera);
299
300 camera->Transform().SetTranslate(cameraPosition);
301 camera->SetWScale(wScale);
302
303 return camera;
304 }
305
306 //----------------------------------------
307 void
CreateStereoCameras(nw::gfx::Camera ** ppBaseCamera,nw::gfx::Camera ** ppLeftCamera,nw::gfx::Camera ** ppRightCamera,os::IAllocator * allocator,const nw::math::VEC3 & cameraPosition,const nw::math::VEC3 & targetPosition,f32 nearClip,f32 farClip,f32 fovyRadian,f32 wScale)308 Utility::CreateStereoCameras(
309 nw::gfx::Camera** ppBaseCamera,
310 nw::gfx::Camera** ppLeftCamera,
311 nw::gfx::Camera** ppRightCamera,
312 os::IAllocator* allocator,
313 const nw::math::VEC3& cameraPosition,
314 const nw::math::VEC3& targetPosition,
315 f32 nearClip,
316 f32 farClip,
317 f32 fovyRadian,
318 f32 wScale
319 )
320 {
321 NW_POINTER_ASSERT(ppBaseCamera);
322 NW_POINTER_ASSERT(ppLeftCamera);
323 NW_POINTER_ASSERT(ppRightCamera);
324 NW_POINTER_ASSERT(allocator);
325
326 *ppBaseCamera = nw::demo::Utility::CreateCamera(
327 allocator,
328 cameraPosition,
329 targetPosition,
330 nearClip,
331 farClip,
332 fovyRadian,
333 nw::math::PIVOT_NONE
334 );
335 (*ppBaseCamera)->SetWScale(wScale);
336
337 *ppLeftCamera =
338 nw::gfx::Camera::DynamicBuilder()
339 .MaxChildren(0)
340 .MaxCallbacks(0)
341 .Create(allocator);
342
343 NW_POINTER_ASSERT(*ppLeftCamera);
344
345 (*ppLeftCamera)->SetWScale(wScale);
346
347 *ppRightCamera =
348 nw::gfx::Camera::DynamicBuilder()
349 .MaxChildren(0)
350 .MaxCallbacks(0)
351 .Create(allocator);
352
353 NW_POINTER_ASSERT(*ppRightCamera);
354
355 (*ppRightCamera)->SetWScale(wScale);
356 }
357
358
359 //----------------------------------------
360 void
SetCameraAspectRatio(nw::gfx::Camera * camera,f32 aspectRatio)361 Utility::SetCameraAspectRatio(
362 nw::gfx::Camera* camera,
363 f32 aspectRatio
364 )
365 {
366 NW_POINTER_ASSERT(camera);
367
368 f32 fovy;
369 f32 near;
370 f32 far;
371 camera->GetPerspective(&fovy, NULL, &near, &far);
372
373 camera->SetPerspective(fovy, aspectRatio, near, far);
374
375 camera->UpdateCameraMatrix();
376 }
377
378 //----------------------------------------
379 nw::gfx::IRenderTarget*
CreateUpperScreenBuffer(os::IAllocator * allocator,nw::demo::RenderSystem::Description & renderDescription)380 Utility::CreateUpperScreenBuffer(
381 os::IAllocator* allocator,
382 nw::demo::RenderSystem::Description& renderDescription
383 )
384 {
385 // オンスクリーンバッファは縦と横が逆になっているため、
386 // 幅と高さを逆に設定しています。
387 return nw::gfx::IRenderTarget::Builder()
388 .BufferSize(
389 renderDescription.upperScreenDescription.height,
390 renderDescription.upperScreenDescription.width
391 )
392 .ColorFormat(renderDescription.renderColorFormat)
393 .Create(allocator);
394 }
395
396 //----------------------------------------
397 nw::gfx::IRenderTarget*
CreateLowerScreenBuffer(os::IAllocator * allocator,nw::demo::RenderSystem::Description & renderDescription)398 Utility::CreateLowerScreenBuffer(
399 os::IAllocator* allocator,
400 nw::demo::RenderSystem::Description& renderDescription
401 )
402 {
403 // オンスクリーンバッファは縦と横が逆になっているため、
404 // 幅と高さを逆に設定しています。
405 return nw::gfx::IRenderTarget::Builder()
406 .BufferSize(
407 renderDescription.lowerScreenDescription.height,
408 renderDescription.lowerScreenDescription.width
409 )
410 .ColorFormat(renderDescription.renderColorFormat)
411 .Create(allocator);
412 }
413
414 //----------------------------------------
415 nw::gfx::SceneNode*
CreateSceneNode(os::IAllocator * deviceAllocator,nw::gfx::ResSceneObject resource,bool isAnimationEnabled,nw::gfx::Model::BufferOption bufferOption,s32 maxAnimObjects)416 Utility::CreateSceneNode(
417 os::IAllocator* deviceAllocator,
418 nw::gfx::ResSceneObject resource,
419 bool isAnimationEnabled,
420 nw::gfx::Model::BufferOption bufferOption,
421 s32 maxAnimObjects
422 )
423 {
424 nw::gfx::SceneObject* sceneObject = nw::gfx::SceneBuilder()
425 .Resource(resource)
426 .BufferOption(bufferOption)
427 .MaxAnimObjectsPerGroup(maxAnimObjects)
428 .IsAnimationEnabled(isAnimationEnabled)
429 .CreateObject(deviceAllocator, deviceAllocator);
430
431 nw::gfx::SceneNode* node = nw::ut::DynamicCast<nw::gfx::SceneNode*>(sceneObject);
432
433 return node;
434 }
435
436 //----------------------------------------
437 ut::MoveArray<u8>
LoadFile(os::IAllocator * allocator,const wchar_t * filePath,u32 align)438 Utility::LoadFile(
439 os::IAllocator* allocator,
440 const wchar_t* filePath,
441 u32 align /* = 32 */
442 )
443 {
444 nn::fs::FileReader fileReader;
445
446 nn::Result result = fileReader.TryInitialize(filePath);
447 if (result.IsFailure())
448 {
449 return nw::ut::MoveArray<u8>();
450 }
451 s32 fileSize = static_cast<s32>(fileReader.GetSize());
452
453 void* memory = allocator->Alloc(fileSize, static_cast<u8>(align));
454 nw::ut::MoveArray<u8> buffer(memory, fileSize, allocator);
455 buffer.resize(fileSize);
456
457 fileReader.Read(&buffer.front(), fileSize);
458
459 fileReader.Finalize();
460
461 // コンテナを返してますが、バッファはコピーされません。
462 // 所有権が移動します。
463 return buffer;
464 }
465
466 //----------------------------------------
467 nw::gfx::AnimGroup*
GetAnimGroup(nw::gfx::SceneObject * object,AnimationType animationType)468 Utility::GetAnimGroup(
469 nw::gfx::SceneObject* object,
470 AnimationType animationType
471 )
472 {
473 // アニメーショングループを取得します。
474 nw::gfx::AnimGroup* animGroup = NULL;
475
476 switch (animationType)
477 {
478 case SKELETAL_ANIMATION:
479 {
480 nw::gfx::SkeletalModel* skeletalModel = nw::ut::DynamicCast<nw::gfx::SkeletalModel*>(object);
481 NW_ASSERT(skeletalModel);
482 animGroup = skeletalModel->GetSkeletalAnimGroup();
483 }
484 break;
485 case MATERIAL_ANIMATION:
486 {
487 nw::gfx::Model* model = nw::ut::DynamicCast<nw::gfx::Model*>(object);
488 NW_ASSERT(model);
489 animGroup = model->GetMaterialAnimGroup();
490 }
491 break;
492 case VISIBILITY_ANIMATION:
493 {
494 nw::gfx::Model* model = nw::ut::DynamicCast<nw::gfx::Model*>(object);
495 NW_ASSERT(model);
496 animGroup = model->GetVisibilityAnimGroup();
497 }
498 break;
499 case CAMERA_ANIMATION:
500 {
501 nw::gfx::Camera* camera = nw::ut::DynamicCast<nw::gfx::Camera*>(object);
502 NW_ASSERT(camera);
503 animGroup = camera->GetAnimGroup();
504 }
505 break;
506 case LIGHT_ANIMATION:
507 {
508 nw::gfx::Light* light = nw::ut::DynamicCast<nw::gfx::Light*>(object);
509 NW_ASSERT(light);
510 animGroup = light->GetAnimGroup();
511 }
512 break;
513 default:
514 NW_FATAL_ERROR("Invalid animation type");
515 }
516
517 return animGroup;
518 }
519
520
521 //----------------------------------------
522 bool
InitializeSharedFont(os::IAllocator * allocator,nw::demo::GraphicsDrawing & graphicsDrawing)523 Utility::InitializeSharedFont(
524 os::IAllocator* allocator,
525 nw::demo::GraphicsDrawing& graphicsDrawing
526 )
527 {
528 if (!s_SharedFontAlreadyInitialized)
529 {
530 nn::pl::Initialize();
531
532 NN_UTIL_PANIC_IF_FAILED(nn::pl::InitializeSharedFont());
533
534 // 共有フォントのロードが完了するまで待機します。
535 while (nn::pl::GetSharedFontLoadState() != nn::pl::SHARED_FONT_LOAD_STATE_LOADED &&
536 nn::pl::GetSharedFontLoadState() != nn::pl::SHARED_FONT_LOAD_STATE_FAILED)
537 {
538 NN_LOG("loading SharedFont ...\n");
539 nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(10));
540 }
541 NW_ASSERT(nn::pl::GetSharedFontLoadState() != nn::pl::SHARED_FONT_LOAD_STATE_FAILED);
542
543 nn::pl::Finalize();
544
545 s_SharedFontAlreadyInitialized = true;
546 }
547
548 void* fontBuffer = nn::pl::GetSharedFontAddress();
549 size_t fontSize = nn::pl::GetSharedFontSize();
550
551 return graphicsDrawing.InitializeFont( allocator, FONT_SHADER_FILE_NAME, fontBuffer, fontSize );
552 }
553
554
555 //----------------------------------------
556 bool
BindAnimationObject(nw::gfx::SceneObject * object,nw::gfx::AnimObject * animObject,AnimationType animationType)557 Utility::BindAnimationObject(
558 nw::gfx::SceneObject* object,
559 nw::gfx::AnimObject* animObject,
560 AnimationType animationType
561 )
562 {
563 nw::gfx::AnimGroup* animGroup = GetAnimGroup(object, animationType);
564 if (!animGroup)
565 {
566 return false;
567 }
568
569 if (animObject->TryBind( animGroup ).IsFailure())
570 {
571 return false;
572 }
573
574 switch (animationType)
575 {
576 case SKELETAL_ANIMATION:
577 {
578 nw::gfx::SkeletalModel* skeletalModel = nw::ut::DynamicCast<nw::gfx::SkeletalModel*>(object);
579 NW_ASSERT(skeletalModel);
580 skeletalModel->SetSkeletalAnimObject(animObject);
581 }
582 break;
583 case MATERIAL_ANIMATION:
584 {
585 nw::gfx::Model* model = nw::ut::DynamicCast<nw::gfx::Model*>(object);
586 NW_ASSERT(model);
587 model->SetMaterialAnimObject(animObject);
588 }
589 break;
590 case VISIBILITY_ANIMATION:
591 {
592 nw::gfx::Model* model = nw::ut::DynamicCast<nw::gfx::Model*>(object);
593 NW_ASSERT(model);
594 model->SetVisibilityAnimObject(animObject);
595 }
596 break;
597 case CAMERA_ANIMATION:
598 {
599 nw::gfx::Camera* camera = nw::ut::DynamicCast<nw::gfx::Camera*>(object);
600 NW_ASSERT(camera);
601 camera->SetAnimObject(animObject);
602 }
603 break;
604 case LIGHT_ANIMATION:
605 {
606 nw::gfx::Light* light = nw::ut::DynamicCast<nw::gfx::Light*>(object);
607 NW_ASSERT(light);
608 light->SetAnimObject(animObject);
609 }
610 break;
611 default:
612 NW_FATAL_ERROR("Invalid animation type");
613 }
614
615 return true;
616 }
617
618
619 namespace internal {
620
621 //----------------------------------------
622 bool
IsTerminatingImpl()623 IsTerminatingImpl()
624 {
625 return false;
626 }
627
628 } // namespace internal
629
630 } /* namespace demo */
631 } /* namespace nw */
632