31 #ifndef VP_PANDA3D_LIGHT_H
32 #define VP_PANDA3D_LIGHT_H
34 #include <visp3/core/vpConfig.h>
36 #if defined(VISP_HAVE_PANDA3D)
39 #include <visp3/core/vpPoint.h>
40 #include <visp3/core/vpRGBf.h>
41 #include <visp3/ar/vpPanda3DBaseRenderer.h>
44 #include "ambientLight.h"
45 #include "directionalLight.h"
46 #include "pointLight.h"
47 #include "directionalLight.h"
78 const std::string &
getName()
const {
return m_name; }
116 PT(AmbientLight) light =
new AmbientLight(m_name);
117 light->set_color(LColor(m_color.R, m_color.G, m_color.B, 1));
118 NodePath alnp = scene.attach_new_node(light);
119 scene.set_light(alnp);
151 if (position.
size() != 3) {
154 m_position.resize(4,
false);
155 m_position.insert(0, position);
157 if (attenuation.
size() != 3) {
164 PT(PointLight) light =
new PointLight(m_name);
165 light->set_color(LColor(m_color.R, m_color.G, m_color.B, 1));
166 light->set_attenuation(LVecBase3(m_attenuation[0], m_attenuation[1], m_attenuation[2]));
167 NodePath np = scene.attach_new_node(light);
169 np.set_pos(m_position[0], m_position[1], m_position[2]);
201 if (m_direction.size() != 3) {
204 m_direction.normalize();
209 PT(DirectionalLight) light =
new DirectionalLight(m_name);
210 light->set_color(LColor(m_color.R, m_color.G, m_color.B, 1));
212 light->set_direction(LVector3f(m_direction[0], m_direction[1], m_direction[2]));
213 NodePath np = scene.attach_new_node(light);
260 if (m_lightableScene.is_empty()) {
263 light.addToScene(m_lightableScene);
268 NodePath m_lightableScene;
unsigned int size() const
Return the number of elements of the 2D array.
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
@ notInitialized
Used to indicate that a parameter is not initialized.
@ dimensionError
Bad dimension.
Class representing an ambient light.
void addToScene(NodePath &scene) const VP_OVERRIDE
Add the light to the scene.
vpPanda3DAmbientLight(const std::string &name, const vpRGBf &color)
static vpColVector vispVectorToPanda(const vpColVector &vec)
Class representing a directional light.
void addToScene(NodePath &scene) const VP_OVERRIDE
Add the light to the scene.
vpPanda3DDirectionalLight(const std::string &name, const vpRGBf &color, const vpColVector &direction)
Build a new directional light.
Base class for a Light that can be added to a Panda3D scene.
const vpRGBf & getColor() const
Get the light's color.
virtual void addToScene(NodePath &scene) const =0
Add the light to the scene.
vpRGBf m_color
Name of the light. Should be unique in the scene.
const std::string & getName() const
Get the name of the light.
vpPanda3DLight(const std::string &name, const vpRGBf &color)
Build a new Panda3D light, given a unique name and an RGB color.
Implementation of vpPanda3DLightable for a panda scene with a root node.
void addLight(const vpPanda3DLight &light) VP_OVERRIDE
Add a light to the scene. All of the objects in the scene will be lit.
vpPanda3DLightableScene()
void setLightableScene(NodePath &scene)
vpPanda3DLightableScene(NodePath &scene)
Interface for objects, scenes or other Panda3D related data that can be lit by a vpPanda3DLight.
virtual ~vpPanda3DLightable()=default
virtual void addLight(const vpPanda3DLight &light)=0
Light this lightable object with a new light.
Class representing a Point Light.
void addToScene(NodePath &scene) const VP_OVERRIDE
Add the light to the scene.
vpPanda3DPointLight(const std::string &name, const vpRGBf &color, const vpColVector &position, const vpColVector &attenuation)
Build a new point light.