Fillwave  10.0.0
Scene.h
1 #pragma once
2 
3 /*
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2018 Filip Wasil and Fillwave community members
7  *
8  * Permission is hereby granted, free of charge, to any person
9  * obtaining a copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
12  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 
24 #include <flw/flf/hud/base/HUD.h>
25 #include <flw/flf/models/Entity.h>
26 #include <flw/flf/models/Skybox.h>
27 #include <flw/flf/models/Cursor.h>
28 #include <flw/flc/renderers/mRendererFR.h>
29 #include <flw/cmn/pointers/PointerProtected.h>
30 
31 #include <unordered_map>
32 
33 namespace flw {
34 namespace flf {
35 
40 class Scene : public TreePtr<Entity> {
41 public:
42  Scene(flc::IRenderer* renderer = new flc::RendererFR());
43 
44  ~Scene() override;
45 
46  void updateDependencies();
47 
48  void updateRenderer();
49 
50  void setRenderer(flc::IRenderer *renderer);
51 
52  void resetRenderer(GLuint screenWidth, GLuint screenHeight);
53 
54  /* Cursor */
55  pn<Cursor> getCursor();
56 
57  void setCursor(pu<Cursor>&& cursor);
58 
59  void drawCursor();
60 
61  /* Camera */
62  pn<ICamera> getCamera();
63 
64  void setCamera(pu<ICamera>&& camera);
65 
66  /* Scene */
67  void setSkybox(pu<Skybox>&& skybox);
68 
69  void setHUD(pu<HUD>&& hud);
70 
71  void setAmbient(glm::vec3 cursor);
72 
73  /* Pickable */
74  void registerPickable(Entity* entity);
75 
76  void pick(glm::ivec4 color);
77 
78  /* Events */
79  void onEvent(const Event& event);
80 
81  void stepInTime(float timePassedInSeconds);
82 
83  void draw(ICamera& c);
84 
85  void drawHUD();
86 
87  void drawDepth(ICamera& camera);
88 
89  void drawDepthColor(ICamera& camera, glm::vec3& position);
90 
91  /* Draw */
92  void draw();
93 
94  void drawDepthInt();
95 
96  void drawPicking();
97 
98  void drawOcclusion();
99 
100  /* Interface */
101  virtual void onShow();
102  virtual void onHide();
103 
104 protected:
105  pu<Skybox> mSkybox;
106  pu<Cursor> mCursor;
107  pu<HUD> mHeadUpDisplay;
108  pu<flc::IRenderer> mRenderer;
109  pu<ICamera> mCamera;
110 
111  std::unordered_map<GLint, Entity* > mPickingTable;
112  Entity* mLastPicked;
113  GLint mCurrentPicableColor;
114  glm::vec3 mAmbientGlobal;
115 };
116 
117 } /* flf */
118 } /* flw */
119 
Definition: Aliases.h:30
Base for all renderers.
Definition: IRenderer.h:42
Base for all Scene nodes.
Definition: Entity.h:48
Event.
Definition: Event.h:154
Entity to be a root of Entity tree.
Definition: Scene.h:40
Basic tree template class. Enables attaching and detaching nodes.
Definition: TreePtr.h:41
Stores camera view parameters.
Definition: ICamera.h:32
Forward IRenderer.
Definition: mRendererFR.h:34