1 /*---------------------------------------------------------------------------*
2 Project: NintendoWare
3 File: gfx_SceneContext.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: 24971 $
14 *---------------------------------------------------------------------------*/
15
16 #include "precompiled.h"
17
18 #include <nw/gfx/gfx_SceneContext.h>
19
20 namespace nw
21 {
22 namespace gfx
23 {
24
25 //----------------------------------------
26 SceneContext*
Create(os::IAllocator * allocator)27 SceneContext::Builder::Create(
28 os::IAllocator* allocator
29 )
30 {
31 NW_NULL_ASSERT(allocator);
32
33 SceneNodeArray sceneNodes(allocator);
34 ModelArray models(allocator);
35 SkeletalModelArray skeletalModels(allocator);
36 LightArray lights(allocator);
37 FragmentLightArray fragmentLights(allocator);
38 VertexLightArray vertexLights(allocator);
39 HemiSphereLightArray hemiSphereLights(allocator);
40 AmbientLightArray ambientLights(allocator);
41 CameraArray cameras(allocator);
42 FogArray fogs(allocator);
43 ParticleSetArray particleSets(allocator);
44 ParticleEmitterArray particleEmitters(allocator);
45 ParticleModelArray particleModels(allocator);
46 AnimatableNodeArray animatableNodes(allocator);
47
48 if (m_IsFixedSizeMemory)
49 {
50 sceneNodes = SceneNodeArray(this->m_MaxSceneNodes, allocator);
51 models = ModelArray(this->m_MaxModels, allocator);
52 skeletalModels = SkeletalModelArray(this->m_MaxSkeletalModels, allocator);
53 lights = LightArray(this->m_MaxLights, allocator);
54 fragmentLights = FragmentLightArray(this->m_MaxFragmentLights, allocator);
55 vertexLights = VertexLightArray(this->m_MaxVertexLights, allocator);
56 hemiSphereLights = HemiSphereLightArray(this->m_MaxHemiSphereLights, allocator);
57 ambientLights = AmbientLightArray(this->m_MaxAmbientLights, allocator);
58 cameras = CameraArray(this->m_MaxCameras, allocator);
59 fogs = FogArray(this->m_MaxFogs, allocator);
60 particleSets = ParticleSetArray(this->m_MaxParticleSets, allocator);
61 particleEmitters = ParticleEmitterArray(this->m_MaxParticleEmitters, allocator);
62 particleModels = ParticleModelArray(this->m_MaxParticleModels, allocator);
63 animatableNodes = AnimatableNodeArray(this->m_MaxAnimatableNodes, allocator);
64 }
65
66 void* memory = allocator->Alloc(sizeof(SceneContext));
67 NW_NULL_ASSERT(memory);
68
69 SceneContext* context = new(memory) SceneContext(
70 allocator, sceneNodes, models, skeletalModels, cameras, fogs,
71 lights, fragmentLights, vertexLights, hemiSphereLights, ambientLights,
72 particleSets, particleEmitters, particleModels, animatableNodes);
73
74 return context;
75 }
76
77 } // namespace gfx
78 } // namespace nw
79