23#ifndef VCL_BGFX_DRAWERS_TRACKBALL_VIEWER_DRAWER_BGFX_H
24#define VCL_BGFX_DRAWERS_TRACKBALL_VIEWER_DRAWER_BGFX_H
26#include "viewer_drawer_bgfx.h"
28#include <vclib/bgfx/drawable/drawable_axis.h>
29#include <vclib/bgfx/drawable/drawable_directional_light.h>
30#include <vclib/bgfx/drawable/drawable_trackball.h>
31#include <vclib/render/drawers/trackball_event_drawer.h>
35template<
typename DerivedRenderApp>
49 void onInit(uint viewId)
override
51 ParentViewer::onInit(viewId);
53 mDrawTrackBall.
init();
54 mDrawableDirectionalLight.
init();
57 void onDraw(uint viewId)
override
59 ParentViewer::onDraw(viewId);
61 setDirectionalLightVisibility(
62 ParentViewer::currentMotion() ==
63 ParentViewer::TrackBallType::DIR_LIGHT_ARC);
70 mDrawTrackBall.
draw(viewId);
73 if (mDrawableDirectionalLight.
isVisible()) {
74 mDrawableDirectionalLight.
draw(viewId);
78 void onDrawContent(uint viewId)
override
80 ParentViewer::onDrawContent(viewId);
82 updateDrawableTrackball();
83 updateDrawableDirectionalLight();
92 case Key::A: toggleAxisVisibility();
break;
94 case Key::T: toggleTrackBallVisibility();
break;
102 void toggleTrackBallVisibility()
108 void updateDrawableTrackball()
110 auto v = ParentViewer::gizmoMatrix();
111 mDrawTrackBall.setTransform(v);
115 bool isDirectionalLightVisible()
const
117 return mDrawableDirectionalLight.
isVisible();
120 void setDirectionalLightVisibility(
bool b)
125 void updateDrawableDirectionalLight()
127 auto v = ParentViewer::lightGizmoMatrix();
128 mDrawableDirectionalLight.updateRotation(v);
A class representing a box in N-dimensional space.
Definition box.h:46
Definition drawable_axis.h:41
void setVisibility(bool vis) override
This member function is used to set the visibility of the object.
Definition drawable_axis.h:119
void draw(uint viewId) const override
This member function must draw the object. It will be called at every frame.
Definition drawable_axis.cpp:41
bool isVisible() const override
This member function is used to check if the object is visible.
Definition drawable_axis.h:117
Definition drawable_directional_light.h:40
void setVisibility(bool vis) override
This member function is used to set the visibility of the object.
Definition drawable_directional_light.h:88
bool isVisible() const override
This member function is used to check if the object is visible.
Definition drawable_directional_light.h:86
void draw(uint viewId) const override
This member function must draw the object. It will be called at every frame.
Definition drawable_directional_light.cpp:110
virtual void init()
This member function is called after the initialization of the Context. It must initialize and bind d...
Definition drawable_object.h:71
Definition drawable_trackball.h:35
bool isVisible() const override
This member function is used to check if the object is visible.
Definition drawable_trackball.cpp:192
void setVisibility(bool vis) override
This member function is used to set the visibility of the object.
Definition drawable_trackball.cpp:197
void updateDragging(bool isDragging)
Update the dragging status of the trackball.
Definition drawable_trackball.cpp:138
void draw(uint viewId) const override
This member function must draw the object. It will be called at every frame.
Definition drawable_trackball.cpp:154
Definition trackball_viewer_drawer_bgfx.h:38
Definition viewer_drawer_bgfx.h:36