Visual Computing Library  devel
Loading...
Searching...
No Matches
drawable_trackball.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_BGFX_DRAWABLE_DRAWABLE_TRACKBALL_H
24#define VCL_BGFX_DRAWABLE_DRAWABLE_TRACKBALL_H
25
26#include "uniforms/drawable_trackball_uniforms.h"
27
28#include <vclib/algorithms/core.h>
29#include <vclib/bgfx/buffers.h>
30#include <vclib/render/drawable/drawable_object.h>
31#include <vclib/space/core.h>
32
33namespace vcl {
35{
36 bool mVisible = true;
37
38 VertexBuffer mVertexPosColorBuffer;
39 IndexBuffer mEdgeIndexBuffer;
40
42
43 vcl::Matrix44f mTransform = vcl::Matrix44f::Identity();
44
45public:
47
49
50 // default move constructor - buffers can be moved
52
53 // default destructor - buffers are destroyed by their destructor
54 ~DrawableTrackBall() = default;
55
63
64 friend void swap(DrawableTrackBall& a, DrawableTrackBall& b) { a.swap(b); }
65
71 void updateDragging(bool isDragging);
72
73 void setTransform(const vcl::Matrix44f& mtx);
74
75 // copy and swap idiom
77
78 // DrawableObject interface
79
80 void draw(uint viewId) const override;
81
82 Box3d boundingBox() const override;
83
84 std::shared_ptr<DrawableObject> clone() const& override;
85
86 std::shared_ptr<DrawableObject> clone() && override;
87
88 bool isVisible() const override;
89
90 void setVisibility(bool vis) override;
91
92private:
93 void createBuffers();
94};
95
96} // namespace vcl
97
98#endif // VCL_BGFX_DRAWABLE_DRAWABLE_TRACKBALL_H
A class representing a box in N-dimensional space.
Definition box.h:46
The DrawableObject class is the base class for all the objects that can be drawn in a 3D viewer.
Definition drawable_object.h:55
Definition drawable_trackball.h:35
std::shared_ptr< DrawableObject > clone() const &override
This member function is used to create a new copy of the DrawableObject. Each derived class must impl...
Definition drawable_trackball.cpp:182
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
Box3d boundingBox() const override
This member function is used to find a good camera position to render object. It should return the th...
Definition drawable_trackball.cpp:177
void swap(DrawableTrackBall &other)
Swap the content of this object with another DrawableTrackBall object.
Definition drawable_trackball.cpp:123
Definition drawable_trackball_uniforms.h:32
The IndexBuffer manages the lifetime of a bgfx::IndexBufferHandle.
Definition index_buffer.h:43
Definition matrix.h:34
The VertexBuffer manages the lifetime of a bgfx::VertexBufferHandle.
Definition vertex_buffer.h:43