Download presentation
Presentation is loading. Please wait.
Published byPiers August Bailey Modified over 9 years ago
1
GAM531 DPS931 – Week 5 The Scene
2
Reviewing the Engine Engine DX11 Device GL 4.3 Device ControllerManagerModel DX11 Object GL 4.3 Object DX 11 API GL 4.3 API DX 11 API GL 4.3 API 1 m 1 1 or 1 1 or 1 1 iEngine iController iModel
3
Expanding the Engine Engine iEngine Engine Engine iEngine Singleton > class Engine : public iEngine, public Singleton >
4
Expanding the Controllers Controller iControlleriSceneControlleriResourceController SceneController ResourceController WindowController class ResourceController : public iResourceController class SceneController : public iSceneController class WindowController
5
Expanding the Managers Manager Singleton > NodeManager BaseManager > class NodeManager : public Singleton >, public BaseManager >
6
Expanding the Manager Bases BaseManager template class BaseManager { protected: ArrayList objects; ArrayList activeObjects; … } IterativeManager template class IterativeManager : public BaseManager { protected: typename ArrayList ::iterator it; … } template class ResourceManager { protected: HashMap resources; … } ResourceManager BMIM RM
7
Expanding all Managers S MeshManager S ActorManager IM S SamplerManager S CameraManager IM S TextureManager S LightManager IM S VertexFormatMa nager RM S NodeManager BM S WindowManager BM S BlendStateMana ger S ShaderManager S MaterialManager RM RM RM RM RM
8
Expanding the Models Model iModel Resource iResource Node iNode SModel iSModel SceneObject
9
Expanding the Resource Models BlendState BlendState iBlendState Material Material iMaterial Mesh Mesh iMesh Texture Texture iTextureiTextureSampler TextureSampler iVertexFormat VertexFormat Shader VertexShader FragmentShader
10
Expanding the Scene Models Actor Actor iActor Camera Camera iCamera Light Light iLight Node Node iNode SceneObject iSceneObject
11
One last look at the simple engine… Engine DX11 Device GL 4.3 Device ControllerManagerModel DX11 Object GL 4.3 Object DX 11 API GL 4.3 API DX 11 API GL 4.3 API 1 m 1 1 or 1 1 or 1 1 iEngine iController iModel
12
Engine Engine SceneController ResourceController MeshManager ActorManager SamplerManager CameraManager BlendStateManager ShaderManager VertexFormatManag er RM RM MaterialManager RM RM RM TextureManager RM NodeManager BM IM IM LightManager IM DX11 Device GL 4.3 Device Node m Light SO Camera SO Actor SO m m m BlendState m Texture m Mesh m TextureSampler m VertexFormat m Material m m m m Sh Sh VertexShader FragmentShader Interface Singleton Contains (m = many) Either or (only one) Base Class RM = Resource Manager BM = Base Manager IM = Iterative Manager Sh = Shader SO = SceneObject DX/GL API Wrapper DX/GL Uniform Buffer
13
Looking into the code Engine.hpp template class Engine: public iEngine, public Singleton > { private: … //Controllers SceneController sCont; ResourceController rCont; //Devices Device dev; … } SceneController.hpp template class SceneController : public iSceneController { … public: ActorManager actMan; CameraManager camMan; LightManager lgtMan; NodeManager nodMan; … } Managers.hpp template class LightManager : public Singleton >, public IterativeManager > { … }
14
Looking into the code… Light.hpp template class Light : public SceneObject { private: LightType type; Color diffuse; Color specular; Vector attenuation; Vector spot; … } SceneObject.hpp template class SceneObject : public I { protected: bool active; Node * node; UniformBuffer buffer; … } Buffers.hpp template class UniformBuffer : public Buffer {…} template class Buffer { protected: APIBuffer * buffer; ArrayList dynamIndex; uint32 byteSize; uint32 indexSize; uint32 padding; … }
15
Graphics Buffers Struct Light { int type; int state; } Light a; type state Light a System Memory type state Light a Graphics Memory UniformBuffer lb; lb.addType (); lb.addType (); lb.fill((byte*)&a, sizeof(Light));
16
Engine Engine SceneController ResourceController MeshManager ActorManager SamplerManager CameraManager BlendStateManager ShaderManager VertexFormatManag er RM RM MaterialManager RM RM RM TextureManager RM NodeManager BM IM IM LightManager IM DX11 Device GL 4.3 Device Node m Light SO Camera SO Actor SO m m m BlendState m Texture m Mesh m TextureSampler m VertexFormat m Material m m m m Sh Sh VertexShader FragmentShader Interface Singleton Contains (m = many) Either of (only one) Base Class RM = Resource Manager BM = Base Manager IM = Iterative Manager Sh = Shader DX/GL API Wrapper DX/GL Uniform Buffer The Scene
17
What is the Scene? Actor NodeID: 1029 MeshID: 32192 MaterialID: 212 Light NodeID: 909 Diffuse: 0 0 1 0 Type: Point Camera NodeID: 123 Field of View: 1.2 Aspect: 1.25
18
Scene Node Node Matrix localT; Scene Object ArrayList *> objects; Node ArrayList children;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Matrix localT; Matrix _tempAbs; uint32 nIndex; Node* parent; ArrayList children; ArrayList *> objects; public: … void _addChild(Node* a); void _removeChild(Node*); void _notifyAttach(SceneObject * a); void _notifyDetach(SceneObject *); }; The local transformation of Node The calculated absolute transformation of the Node for this frame, refreshed before each render The parent of the node, null if the node is a root node All of the nodes to which this node is the parent node All of the scene objects that are attached to this node Adds/Removes a node from the children list Adds/Removes a scene object from the objects list
22
Scene Node Scene Object Node Node Node Node
23
SceneObject Class template class SceneObject : public I { protected: bool active; Node * node; UniformBuffer buffer; SceneObject(); virtual ~SceneObject(); public: void attachTo(const iNode* n); const iNode* getNode() const; bool isActive(); inline void _bindVertex(uint32 slot); inline void _bindFragment(uint32 slot); }; Indicates if the object is part of it’s manager’s active objects list The node that the scene object is attached to, null if it is not in the scene A Uniform Buffer which enables the scene object to store information on the graphics card for use when rendering Protected Ctor and Dtor to prevent scene objects from being instantiated Used to attach the scene object to a node Returns the node the object is attached to Binds the data in “buffer” to a specific slot in the graphics card (for vertex and fragment shaders)
24
Scene Node Scene Object Node Node Node Node Actor
25
What is an Actor? Everything you see in the game world is an actor! Things that are not actors: - The sky - The HUD (heads up display)
26
What makes up an Actor? template class Actor : public SceneObject { private: Material * mat; Mesh * mesh; … }; MeshMesh + Material
27
Scene Node Node Node Node Node Scene Object Actor Light
28
What is a Light? template class Light : public SceneObject { private: LightType type; Color diffuse; Color specular; Vector attenuation; Vector spot; … }; Directional Light Point LightSpot Light
29
What does a light do? 1 Actor, 0 Lights 0 Actors, 1 Light 1 Actor, 1 Light 1 Actor, 2 Lights
30
Scene Node Node Node Node Node Scene Object Actor Light Camera
31
What is a Camera? template class Camera : public SceneObject { private: Matrix projMatrix; float fov; float aspect; float nearClip; float farClip; RasterizerState rend; … }; Field of View Field of View * Aspect Ratio Near Clipping Plane Far Clipping Plane
32
How does the camera work? Clipping Planes Field of View & Aspect Ratio Large FOV (1.57 rad) Small FOV (0.39 rad) Wide Aspect Ratio (5.71)
33
Scene Node Node Node Node Node Scene Object Actor Light Camera
34
To Do Do some basic research on your team’s enhancement Begin writing your enhancement proposal document (due Oct 18 th ) Read course notes (week 1 – 6) in preparation for Mid-term next week
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.