i6engine  1.0
GraphicsNode.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_MODULES_GRAPHICSNODE_H__
26 #define __I6ENGINE_MODULES_GRAPHICSNODE_H__
27 
30 
32 
33 namespace Ogre {
34  class SceneNode;
35 } /* namespace Ogre */
36 
37 namespace i6e {
38 namespace api {
39 namespace graphics {
40  enum class BillboardOrigin;
41 } /* namespace graphics */
42 } /* namespace api */
43 namespace modules {
44 
45  class BillboardComponent;
46  class BoundingBoxComponent;
47  class CameraComponent;
48  class GraphicsManager;
49  class LineComponent;
50  class LuminousComponent;
51  class MeshComponent;
53  class ParticleComponent;
54 
61  class GraphicsNode {
62  friend class GraphicsManager;
63  friend class MeshComponent;
64 
65  public:
72  inline Ogre::SceneNode * getSceneNode() const {
73  return _sceneNode;
74  }
75 
76  void addTicker(MeshComponent * mesh);
77  void addTicker(MovableTextComponent * movableText);
78 
79  void removeTicker(MeshComponent * mesh);
80  void removeTicker(MovableTextComponent * movableText);
81 
82  private:
90  GraphicsNode(GraphicsManager * manager, const int64_t goid, const Vec3 & position, const Quaternion & rotation, const Vec3 & scale);
91 
98  ~GraphicsNode();
99 
108  void createMeshComponent(const int64_t coid, const std::string & meshName, const bool visible, const Vec3 & position, const Quaternion & rotation, const Vec3 & scale);
109  void updateMeshComponent(const int64_t coid, const std::string & meshName, const bool visible);
110 
114  void updateMeshComponentVisibility(const int64_t coid, const bool visible);
115 
119  void updateMeshComponentShadowCasting(const int64_t coid, const bool enabled);
120 
128  void setMaterial(const int64_t coid, const std::string & materialName);
129 
139  void setCustomParameter(uint32_t num, const Vec4 & value);
140 
144  void playAnimation(const int64_t coid, const std::string & anim, bool looping, double offsetPercent);
145 
149  void setAnimationSpeed(int64_t coid, double animationSpeed);
150 
154  void stopAnimation(int64_t coid);
155 
160  void addAnimationFrameEvent(int64_t coid, uint64_t frame, const std::function<void(void)> & func);
161 
167  void deleteMeshComponent(const int64_t coid);
168 
176  void createCameraComponent(const int64_t coid, const Vec3 & position, const Vec3 & lookAt, const double nC, double aspect, const double fov);
177  void updateCameraComponent(const int64_t coid, const Vec3 & position, const Vec3 & lookAt, const double nC, double aspect, const double fov);
178 
182  void updateCameraFrustumComponent(const int64_t coid, const double left, const double right, const double top, const double bottom);
183 
187  void enableCompositor(int64_t coid, const std::string & compositor, bool enabled);
188 
194  void createOrUpdateViewport(const int64_t coid, int zOrder, const double left, const double top, const double width, const double height, const double red, const double green, const double blue, const double alpha);
195 
201  void deleteCameraComponent(const int64_t coid);
202 
212  void createLuminousComponent(const int64_t coid, const api::LuminousAppearanceComponent::LightType type, const Vec3 & diffuse, const Vec3 & specular, const Vec4 & attenuation, const Vec3 & direction, const Vec3 & position, double spotLightRangeInner, double spotLightRangeOuter);
213 
223  void updateLuminousComponent(const int64_t coid, const api::LuminousAppearanceComponent::LightType type, const Vec3 & diffuse, const Vec3 & specular, const Vec4 & attenuation, const Vec3 & direction, const Vec3 & position, double spotLightRangeInner, double spotLightRangeOuter);
224 
228  void deleteLuminousComponent(const int64_t coid);
229 
236  void createParticleComponent(const int64_t coid, const std::string & emitterName, const Vec3 & pos);
237 
241  void particleFadeOut(int64_t coid);
242 
246  void deleteParticleComponent(const int64_t coid);
247 
251  void createBilldboardSetComponent(int64_t coid, const std::string & material, double width, double height, api::graphics::BillboardOrigin bo);
252 
256  void createOrUpdateBillboard(int64_t coid, const std::string & identifier, const Vec3 & offset, double width, double height, double u0, double v0, double u1, double v1);
257 
261  void deleteBillboard(int64_t coid, const std::string & identifier);
262 
266  void deleteBillboardSetComponent(int64_t coid);
267 
271  void createMovableText(int64_t coid, const std::string & font, const std::string & text, double size, const Vec3 & colour);
272 
276  void updateMovableText(int64_t coid, const std::string & font, const std::string & text, double size, const Vec3 & colour);
277 
281  void updateMovableTextSetAutoScaleCallback(int64_t coid, const std::function<double(const Vec3 &, const Vec3 &)> & callback);
282 
286  void deleteMovableText(int64_t coid);
287 
291  void drawBoundingBox(int64_t coid, const Vec3 & colour);
292 
296  void removeBoundingBox(int64_t coid);
297 
301  void createLine(int64_t coid, const Vec3 & from, const Vec3 & to, const Vec3 & colour);
302 
306  void removeLine(int64_t coid);
307 
308  /*
309  * \brief attaches an other GraphicsNode to a bone of a mesh of this GraphicsNode
310  */
311  void attachToBone(int64_t coid, GraphicsNode * otherNode, const std::string & boneName);
312 
316  void detachFromBone(int64_t coid, GraphicsNode * otherNode, const std::string & boneName);
317 
321  void listenAttachment(GraphicsNode * otherNode, int64_t coid, const std::string & boneName);
322 
326  void stopListenAttachment();
327 
331  void Tick();
332 
336  GraphicsNode(const GraphicsNode &) = delete;
337 
341  const GraphicsNode & operator=(const GraphicsNode &) = delete;
342 
346  GraphicsManager * _manager;
347 
351  int64_t _gameObjectID;
352 
356  Ogre::SceneNode * _sceneNode;
357 
361  std::map<int64_t, CameraComponent *> _cameras;
362 
366  std::map<int64_t, LuminousComponent *> _lights;
367 
371  std::map<int64_t, ParticleComponent *> _particles;
372 
376  std::map<int64_t, MeshComponent *> _meshes;
377 
378  std::map<int64_t, BillboardComponent *> _billboardSets;
379 
380  std::map<int64_t, MovableTextComponent *> _movableTexts;
381 
382  std::map<int64_t, BoundingBoxComponent *> _boundingBoxes;
383 
384  std::map<int64_t, LineComponent *> _lines;
385  GraphicsNode * _attachedTo;
386  int64_t _attachedCoid;
387  std::string _attachedBone;
388 
389  api::WeakGOPtr _go;
390 
391  bool _ticking;
392 
393  std::vector<MeshComponent *> _tickingMeshes;
394  std::vector<MovableTextComponent *> _tickingMovableTexts;
395 
397  };
398 
399 } /* namespace modules */
400 } /* namespace i6e */
401 
402 #endif /* __I6ENGINE_MODULES_GRAPHICSNODE_H__ */
403 
Implements 4-dimensional vectors.
Definition: i6eVector4.h:56
Saves all graphics-related data associated with one GameObject.
Definition: GraphicsNode.h:61
Class describing a 3d rotation.
Definition: i6eQuaternion.h:58
Implements 3-dimensional vectors.
Definition: i6eVector.h:48
#define ASSERT_THREAD_SAFETY_HEADER
Ogre::SceneNode * getSceneNode() const
Gets SceneNode of the object.
Definition: GraphicsNode.h:72
Handles all light related functionality.
Definition: MeshComponent.h:64
void addTicker(MeshComponent *mesh)
void removeTicker(MeshComponent *mesh)