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
60 settings.viewId = viewId;
62 ParentViewer::onDraw(viewId);
64 setDirectionalLightVisibility(
65 ParentViewer::currentMotion() ==
66 ParentViewer::TrackBallType::DIR_LIGHT_ARC);
73 mDrawTrackBall.
draw(settings);
76 if (mDrawableDirectionalLight.
isVisible()) {
77 mDrawableDirectionalLight.
draw(settings);
81 void onDrawContent(uint viewId)
override
83 ParentViewer::onDrawContent(viewId);
85 updateDrawableTrackball();
86 updateDrawableDirectionalLight();
95 case Key::A: toggleAxisVisibility();
break;
97 case Key::T: toggleTrackBallVisibility();
break;
105 void toggleTrackBallVisibility()
111 void updateDrawableTrackball()
113 auto v = ParentViewer::gizmoMatrix();
114 mDrawTrackBall.setTransform(v);
118 bool isDirectionalLightVisible()
const
120 return mDrawableDirectionalLight.
isVisible();
123 void setDirectionalLightVisibility(
bool b)
128 void updateDrawableDirectionalLight()
130 auto v = ParentViewer::lightGizmoMatrix();
131 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:118
void draw(const DrawObjectSettings &settings) 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:116
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(const DrawObjectSettings &settings) const override
This member function must draw the object. It will be called at every frame.
Definition drawable_directional_light.cpp:111
virtual void init()
This member function is called after the initialization of the Context. It must initialize and bind d...
Definition drawable_object.h:73
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:191
void setVisibility(bool vis) override
This member function is used to set the visibility of the object.
Definition drawable_trackball.cpp:196
void updateDragging(bool isDragging)
Update the dragging status of the trackball.
Definition drawable_trackball.cpp:137
void draw(const DrawObjectSettings &settings) const override
This member function must draw the object. It will be called at every frame.
Definition drawable_trackball.cpp:153
Definition trackball_viewer_drawer_bgfx.h:38
Definition viewer_drawer_bgfx.h:36