AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
LightSource.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXOSG_LIGHTSOURCE_H
18#define AGXOSG_LIGHTSOURCE_H
19
20#include <agx/config.h>
21#include <agx/Vec4.h>
22#include <agxOSG/export.h>
23
24#include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
25#include <osg/Light>
26#include <osg/LightSource>
27#include <agx/PopDisableWarnings.h> // End of disabled warnings.
28
29
30namespace agxOSG
31{
33 {
34 public:
35
36 LightSource( osg::LightSource *lightSource )
37 {
38 if (lightSource)
39 m_light = lightSource->getLight();
40 }
41
43 int getLightNum() const { if (m_light) return m_light->getLightNum(); else return -1; }
44
46 inline void setAmbient( const agx::Vec4f& ambient ) { if (m_light) m_light->setAmbient( AGX_VEC4_TO_OSG(ambient)); }
47
49 inline agx::Vec4f getAmbient() const { if (m_light) return OSG_VEC4F_TO_AGX(m_light->getAmbient()); else return agx::Vec4f(); }
50
52 inline void setDiffuse( const agx::Vec4f& diffuse ) { if (m_light) m_light->setDiffuse( AGX_VEC4_TO_OSG(diffuse)); }
53
55 inline agx::Vec4f getDiffuse() const { if (m_light) return OSG_VEC4F_TO_AGX(m_light->getDiffuse()); else return agx::Vec4f(); }
56
58 inline void setSpecular( const agx::Vec4f& specular ) { if (m_light) m_light->setSpecular( AGX_VEC4_TO_OSG(specular)); }
59
61 inline agx::Vec4f getSpecular() const { if (m_light) return OSG_VEC4F_TO_AGX(m_light->getSpecular()); else return agx::Vec4f(); }
62
64 inline void setPosition( const agx::Vec4& position ) { if (m_light) m_light->setPosition( AGX_VEC4_TO_OSG(position)); }
65
67 inline agx::Vec4 getPosition() const { if (m_light) return OSG_VEC4_TO_AGX(m_light->getPosition()); else return agx::Vec4(); }
68
70 inline void setDirection( const agx::Vec3& direction ) { if (m_light) m_light->setDirection(AGX_VEC3_TO_OSG(direction)); }
71
73 inline agx::Vec3 getDirection() const { if (m_light) return OSG_VEC3_TO_AGX(m_light->getDirection()); else return agx::Vec3(); }
74
76 inline void setConstantAttenuation( float constant_attenuation ) { if (m_light) m_light->setConstantAttenuation(constant_attenuation);}
77
79 inline float getConstantAttenuation() const { if (m_light) return m_light->getConstantAttenuation(); else return 0; }
80
82 inline void setLinearAttenuation ( float linear_attenuation ) { if (m_light) m_light->setLinearAttenuation( linear_attenuation ); }
83
85 inline float getLinearAttenuation () const { if (m_light) return m_light->getLinearAttenuation(); else return 0; }
86
88 inline void setQuadraticAttenuation ( float quadratic_attenuation ) { if (m_light) m_light->setQuadraticAttenuation(quadratic_attenuation); }
89
91 inline float getQuadraticAttenuation() const { if (m_light) return m_light->getQuadraticAttenuation(); else return 0;}
92
94 inline void setSpotExponent( float spot_exponent ) { if (m_light) m_light->setSpotExponent(spot_exponent); }
95
97 inline float getSpotExponent() const { if (m_light) return m_light->getSpotExponent(); else return 0; }
98
100 inline void setSpotCutoff( float spot_cutoff ) { if (m_light) m_light->setSpotCutoff(spot_cutoff); }
101
103 inline float getSpotCutoff() const { if (m_light) return m_light->getSpotCutoff(); return 0; }
104
106
107 protected:
108 osg::ref_ptr<osg::Light> m_light;
109
110 };
111}
112
113#endif
#define OSG_VEC3_TO_AGX(X)
#define AGX_VEC4_TO_OSG(X)
#define AGXOSG_EXPORT
#define AGX_VEC3_TO_OSG(X)
#define OSG_VEC4F_TO_AGX(X)
#define OSG_VEC4_TO_AGX(X)
void setSpotExponent(float spot_exponent)
Set the spot exponent of the light.
Definition: LightSource.h:94
float getSpotCutoff() const
Get the spot cutoff of the light.
Definition: LightSource.h:103
void setLinearAttenuation(float linear_attenuation)
Set the linear attenuation of the light.
Definition: LightSource.h:82
float getLinearAttenuation() const
Get the linear attenuation of the light.
Definition: LightSource.h:85
void setSpecular(const agx::Vec4f &specular)
Set the specular component of the light.
Definition: LightSource.h:58
agx::Vec4f getDiffuse() const
Get the diffuse component of the light.
Definition: LightSource.h:55
agx::Vec4 getPosition() const
Get the position of the light.
Definition: LightSource.h:67
void setDirection(const agx::Vec3 &direction)
Set the direction of the light.
Definition: LightSource.h:70
void setPosition(const agx::Vec4 &position)
Set the position of the light.
Definition: LightSource.h:64
osg::ref_ptr< osg::Light > m_light
Definition: LightSource.h:108
float getConstantAttenuation() const
Get the constant attenuation of the light.
Definition: LightSource.h:79
float getSpotExponent() const
Get the spot exponent of the light.
Definition: LightSource.h:97
void setQuadraticAttenuation(float quadratic_attenuation)
Set the quadratic attenuation of the light.
Definition: LightSource.h:88
agx::Vec4f getSpecular() const
Get the specular component of the light.
Definition: LightSource.h:61
void setSpotCutoff(float spot_cutoff)
Set the spot cutoff of the light.
Definition: LightSource.h:100
LightSource(osg::LightSource *lightSource)
Definition: LightSource.h:36
void setConstantAttenuation(float constant_attenuation)
Set the constant attenuation of the light.
Definition: LightSource.h:76
int getLightNum() const
Get which OpenGL light this osg::Light operates on.
Definition: LightSource.h:43
void setDiffuse(const agx::Vec4f &diffuse)
Set the diffuse component of the light.
Definition: LightSource.h:52
float getQuadraticAttenuation() const
Get the quadratic attenuation of the light.
Definition: LightSource.h:91
agx::Vec4f getAmbient() const
Get the ambient component of the light.
Definition: LightSource.h:49
agx::Vec3 getDirection() const
Get the direction of the light.
Definition: LightSource.h:73
void setAmbient(const agx::Vec4f &ambient)
Set the ambient component of the light.
Definition: LightSource.h:46
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:35
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
Vec4T< Real32 > Vec4f
Definition: Vec4.h:26
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition: agx/Vec3.h:36
Vec4T< Real > Vec4
Definition: Vec4.h:25