Visual Computing Library
Loading...
Searching...
No Matches
drawable_directional_light.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_DIRECTIONAL_LIGHT_H
24#define VCL_BGFX_DRAWABLE_DRAWABLE_DIRECTIONAL_LIGHT_H
25
26#include "uniforms/drawable_directional_light_uniforms.h"
27
28#include <vclib/render/drawable/drawable_object.h>
29#include <vclib/render/viewer/lights/directional_light.h>
30#include <vclib/space/core/matrix.h>
31
32#include <vclib/bgfx/buffers/vertex_buffer.h>
33#include <vclib/bgfx/context.h>
34
35#include <bgfx/bgfx.h>
36
37namespace vcl {
38
40{
41 bool mVisible = false;
42
43 Matrix44f mTransform = vcl::Matrix44f::Identity();
44
45 std::vector<float> mVertices; // vertices of the drawn lines
46 vcl::Color mColor = vcl::Color::Yellow; // color of the lines
47
48 VertexBuffer mVertexCoordBuffer;
49
51
52 // TODO: can we be sure that this is called after the context initialization
53 // triggered by a window?
54 bgfx::ProgramHandle mProgram =
56 .programManager()
57 .getProgram<VertFragProgram::DRAWABLE_DIRECTIONAL_LIGHT>();
58
59public:
61
63
65
67
69
71
73 {
74 a.swap(b);
75 }
76
77 void updateRotation(const vcl::Matrix44f& rot);
78
79 const vcl::Color& linesColor() const { return mColor; }
80
81 void setLinesColor(const vcl::Color& c);
82
83 // DrawableObject interface
84
85 void draw(uint viewId) const override;
86
87 Box3d boundingBox() const override;
88
89 std::shared_ptr<DrawableObject> clone() const& override;
90
91 std::shared_ptr<DrawableObject> clone() && override;
92
93 bool isVisible() const override { return mVisible; }
94
95 void setVisibility(bool vis) override { mVisible = vis; }
96
97private:
98 void createVertexBuffer();
99};
100
101} // namespace vcl
102
103#endif // VCL_BGFX_DRAWABLE_DRAWABLE_DIRECTIONAL_LIGHT_H
The Color class represents a 32 bit color.
Definition color.h:48
static Context & instance(void *windowHandle=nullptr, void *displayHandle=nullptr)
Return the context instance.
Definition context.cpp:365
Definition drawable_directional_light_uniforms.h:32
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:95
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_directional_light.cpp:131
bool isVisible() const override
This member function is used to check if the object is visible.
Definition drawable_directional_light.h:93
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_directional_light.cpp:136
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:111
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 matrix.h:36
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
The VertexBuffer manages the lifetime of a bgfx::VertexBufferHandle.
Definition vertex_buffer.h:43