1 /*---------------------------------------------------------------------------*
2 Project: NintendoWare
3 File: gfx_SceneContext.cpp
4
5 Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain proprietary
8 information of Nintendo and/or its licensed developers and are protected by
9 national and international copyright laws. They may not be disclosed to third
10 parties or copied or duplicated in any form, in whole or in part, without the
11 prior written consent of Nintendo.
12
13 The content herein is highly confidential and should be handled accordingly.
14
15 $Revision: 31311 $
16 *---------------------------------------------------------------------------*/
17
18 #include "precompiled.h"
19
20 #include <nw/gfx/gfx_SceneContext.h>
21
22 namespace nw
23 {
24 namespace gfx
25 {
26
27 //----------------------------------------
28 SceneContext*
Create(os::IAllocator * allocator)29 SceneContext::Builder::Create(
30 os::IAllocator* allocator
31 )
32 {
33 NW_NULL_ASSERT(allocator);
34
35 SceneNodeArray sceneNodes(allocator);
36 UserRenderNodeArray userRenderNodes(allocator);
37 ModelArray models(allocator);
38 SkeletalModelArray skeletalModels(allocator);
39 LightArray lights(allocator);
40 FragmentLightArray fragmentLights(allocator);
41 VertexLightArray vertexLights(allocator);
42 HemiSphereLightArray hemiSphereLights(allocator);
43 AmbientLightArray ambientLights(allocator);
44 CameraArray cameras(allocator);
45 FogArray fogs(allocator);
46 ParticleSetArray particleSets(allocator);
47 ParticleEmitterArray particleEmitters(allocator);
48 ParticleModelArray particleModels(allocator);
49 AnimatableNodeArray animatableNodes(allocator);
50
51 if (m_IsFixedSizeMemory)
52 {
53 sceneNodes = SceneNodeArray(this->m_MaxSceneNodes, allocator);
54 userRenderNodes = UserRenderNodeArray(this->m_MaxUserRenderNodes, allocator);
55 models = ModelArray(this->m_MaxModels, allocator);
56 skeletalModels = SkeletalModelArray(this->m_MaxSkeletalModels, allocator);
57 lights = LightArray(this->m_MaxLights, allocator);
58 fragmentLights = FragmentLightArray(this->m_MaxFragmentLights, allocator);
59 vertexLights = VertexLightArray(this->m_MaxVertexLights, allocator);
60 hemiSphereLights = HemiSphereLightArray(this->m_MaxHemiSphereLights, allocator);
61 ambientLights = AmbientLightArray(this->m_MaxAmbientLights, allocator);
62 cameras = CameraArray(this->m_MaxCameras, allocator);
63 fogs = FogArray(this->m_MaxFogs, allocator);
64 particleSets = ParticleSetArray(this->m_MaxParticleSets, allocator);
65 particleEmitters = ParticleEmitterArray(this->m_MaxParticleEmitters, allocator);
66 particleModels = ParticleModelArray(this->m_MaxParticleModels, allocator);
67 animatableNodes = AnimatableNodeArray(this->m_MaxAnimatableNodes, allocator);
68 }
69
70 void* memory = allocator->Alloc(sizeof(SceneContext));
71 NW_NULL_ASSERT(memory);
72
73 SceneContext* context = new(memory) SceneContext(
74 allocator, sceneNodes, userRenderNodes, models, skeletalModels, cameras, fogs,
75 lights, fragmentLights, vertexLights, hemiSphereLights, ambientLights,
76 particleSets, particleEmitters, particleModels, animatableNodes );
77
78 return context;
79 }
80
81 } // namespace gfx
82 } // namespace nw
83