GlistEngine
Loading...
Searching...
No Matches
gLight Class Reference

#include <gLight.h>

Inheritance diagram for gLight:
Collaboration diagram for gLight:

Public Member Functions

 gLight (int lightType=LIGHTTYPE_POINT)
 
virtual ~gLight ()
 
void enable ()
 
void disable ()
 
bool isEnabled () const
 
bool isChanged () const
 
void setChanged (bool isChanged)
 
void setType (int lightType)
 
int getType () const
 
void rotate (float radians, float ax, float ay, float az)
 
void rotateDeg (float degrees, float ax, float ay, float az)
 
const glm::vec3 & getDirection () const
 
void setAmbientColor (int r, int g, int b, int a=255)
 
void setAmbientColor (gColor *color)
 
void setAmbientColor (const gColor &color)
 
gColorgetAmbientColor ()
 
float getAmbientColorRed () const
 
float getAmbientColorGreen () const
 
float getAmbientColorBlue () const
 
float getAmbientColorAlpha () const
 
void setDiffuseColor (int r, int g, int b, int a=255)
 
void setDiffuseColor (gColor *color)
 
void setDiffuseColor (const gColor &color)
 
gColorgetDiffuseColor ()
 
float getDiffuseColorRed () const
 
float getDiffuseColorGreen () const
 
float getDiffuseColorBlue () const
 
float getDiffuseColorAlpha () const
 
void setSpecularColor (int r, int g, int b, int a=255)
 
void setSpecularColor (gColor *color)
 
void setSpecularColor (const gColor &color)
 
gColorgetSpecularColor ()
 
float getSpecularColorRed () const
 
float getSpecularColorGreen () const
 
float getSpecularColorBlue () const
 
float getSpecularColorAlpha () const
 
void setAttenuation (float constant, float linear, float quadratic)
 
void setAttenuation (glm::vec3 attenuation)
 
const glm::vec3 & getAttenuation () const
 
float getAttenuationConstant () const
 
float getAttenuationLinear () const
 
float getAttenuationQuadratic () const
 
void setSpotCutOff (glm::vec2 spotCutOff)
 
const glm::vec2 & getSpotCutOff () const
 
void setSpotCutOffAngle (float cutOffAngle)
 
float getSpotCutOffAngle () const
 
float getSpotOuterCutOffAngle () const
 
void setSpotCutOffSpread (float cutOffSpreadAngle)
 
float getSpotCutOffSpread () const
 
void setOrientation (const glm::quat &o)
 
void setOrientation (const glm::vec3 &angles)
 
void rotateAround (float radians, const glm::vec3 &axis, const glm::vec3 &point)
 
void rotateAroundDeg (float degrees, const glm::vec3 &axis, const glm::vec3 &point)
 
- Public Member Functions inherited from gNode
 gNode ()
 
virtual ~gNode ()
 
void move (float dx, float dy, float dz)
 
void move (const glm::vec3 &dv)
 
void rotate (const glm::quat &q)
 
void rotate (float radians, float ax, float ay, float az)
 
void rotateDeg (float degrees, float ax, float ay, float az)
 
void rotateAround (float radians, const glm::vec3 &axis, const glm::vec3 &point)
 
void rotateAroundDeg (float degrees, const glm::vec3 &axis, const glm::vec3 &point)
 
void scale (float sx, float sy, float sz)
 
void scale (float s)
 
void setPosition (float px, float py, float pz)
 
void setPosition (const glm::vec3 &pv)
 
void setOrientation (const glm::quat &o)
 
void setOrientation (const glm::vec3 &angles)
 
void setScale (const glm::vec3 &s)
 
void setScale (float sx, float sy, float sz)
 
void setScale (float s)
 
void truck (float distance)
 
void boom (float distance)
 
void dolly (float distance)
 
void tilt (float radians)
 
void tiltDeg (float degrees)
 
void pan (float radians)
 
void panDeg (float degrees)
 
void roll (float radians)
 
void rollDeg (float degrees)
 
float getPosX () const
 
float getPosY () const
 
float getPosZ () const
 
const glm::vec3 & getPosition () const
 
const glm::quat & getOrientation () const
 
const glm::vec3 & getScale () const
 
glm::vec3 getScalarDirectionX () const
 
glm::vec3 getScalarDirectionY () const
 
glm::vec3 getScalarDirectionZ () const
 
void setTransformationMatrix (const glm::mat4 &transformationMatrix)
 
const glm::mat4 & getTransformationMatrix () const
 
int getId () const
 
void setParent (gNode *parent)
 
gNodegetParent () const
 
void removeParent ()
 
void addChild (gNode *child)
 
void removeChild (gNode *child)
 
void removeChild (int gObjectId)
 
void setEnabled (bool isEnabled)
 
bool isEnabled () const
 
void pushMatrix () const
 
void popMatrix () const
 
- Public Member Functions inherited from gRenderObject
 gRenderObject ()
 
int getScreenWidth ()
 
int getScreenHeight ()
 
void pushMatrix ()
 
void popMatrix ()
 
- Public Member Functions inherited from gObject
 gObject ()
 
void logi (std::string message)
 
void logd (std::string message)
 
void logw (std::string message)
 
void loge (std::string message)
 
void logi (std::string tag, std::string message)
 
void logd (std::string tag, std::string message)
 
void logw (std::string tag, std::string message)
 
void loge (std::string tag, std::string message)
 

Static Public Attributes

static const int LIGHTTYPE_AMBIENT = 0
 
static const int LIGHTTYPE_DIRECTIONAL = 1
 
static const int LIGHTTYPE_POINT = 2
 
static const int LIGHTTYPE_SPOT = 3
 
- Static Public Attributes inherited from gObject
static const int LOGLEVEL_SILENT
 
static const int LOGLEVEL_DEBUG
 
static const int LOGLEVEL_INFO
 
static const int LOGLEVEL_WARNING
 
static const int LOGLEVEL_ERROR
 

Protected Member Functions

void processTransformationMatrix () override
 

Friends

class gRenderer
 

Additional Inherited Members

- Static Public Member Functions inherited from gRenderObject
static void setScreenSize (int screenWidth, int screenHeight)
 
static void setUnitScreenSize (int unitWidth, int unitHeight)
 
static void setScreenScaling (int screenScaling)
 
static void enableShadowMapping ()
 
static void disableShadowMapping ()
 
static bool isShadowMappingEnabled ()
 
static gRenderergetRenderer ()
 
static void destroyRenderer ()
 
static void createRenderer ()
 
- Static Public Member Functions inherited from gObject
static std::string gGetAppDir ()
 
static std::string gGetAssetsDir ()
 
static void gSetAssetsDir (std::string assetsDir)
 
static std::string gGetFilesDir ()
 
static std::string gGetImagesDir ()
 
static std::string gGetFontsDir ()
 
static std::string gGetModelsDir ()
 
static std::string gGetTexturesDir ()
 
static std::string gGetShadersDir ()
 
static std::string gGetSoundsDir ()
 
static std::string gGetDatabasesDir ()
 
static std::string gGetVideosDir ()
 
static void setCurrentResolution (int scalingNo, int currentResolutionNo)
 
- Protected Attributes inherited from gNode
gNodeparent
 
std::deque< gNode * > children
 
glm::mat4 localtransformationmatrix
 
bool isenabled
 
glm::vec3 position
 
glm::quat orientation
 
glm::vec3 scalevec
 
glm::vec3 prevposition
 
glm::quat prevorientation
 
glm::vec3 prevscalevec
 
- Static Protected Attributes inherited from gRenderObject
static bool isshadowmappingenabled
 
- Static Protected Attributes inherited from gObject
static int renderpassnum
 
static int renderpassno
 
static int releasescaling
 
static int releaseresolution
 

Detailed Description

Glist Engine has four light types: Ambient, Directional, Point, and Spot. Ambient lights have a small amount of light. Directional lights are sun like light. Point lights are bulb like light. Spot lights emit light from a single point. If light type is not changed, light type will be point light because of default constructor.

Constructor & Destructor Documentation

◆ gLight()

gLight::gLight ( int  lightType = LIGHTTYPE_POINT)

◆ ~gLight()

virtual gLight::~gLight ( )
virtual

Member Function Documentation

◆ disable()

void gLight::disable ( )

Removing the light to the scene. This function should be using before camera.end() function.

◆ enable()

void gLight::enable ( )

Adding the light to the scene. This function should be using after camera.begin() function.

◆ getAmbientColor()

gColor * gLight::getAmbientColor ( )

Gives ambient color RGBA component. This function can be use two type. Using directly giving memory address. Other way, Typing like function.r, function.g, function.b, function.a giving value of color component.

Returns
color object memory address or RGBA value

◆ getAmbientColorAlpha()

float gLight::getAmbientColorAlpha ( ) const

Gives alpha component value range is [0,1].

Returns
ambient color alpha component.

◆ getAmbientColorBlue()

float gLight::getAmbientColorBlue ( ) const

Gives blue component value range is [0,1].

Returns
ambient color blue component.

◆ getAmbientColorGreen()

float gLight::getAmbientColorGreen ( ) const

Gives green component value range is [0,1].

Returns
ambient color green component.

◆ getAmbientColorRed()

float gLight::getAmbientColorRed ( ) const

Gives red component value range is [0,1].

Returns
ambient color red component.

◆ getAttenuation()

const glm::vec3 & gLight::getAttenuation ( ) const

For example, can be using function.x, function.y, function.z. This typing showing light constant, linear, quadratic values. If this function using more than 1, copy constructor called.

Returns
attenuation with three dimensional floating point vector

◆ getAttenuationConstant()

float gLight::getAttenuationConstant ( ) const
Returns
light attenuation constant value

◆ getAttenuationLinear()

float gLight::getAttenuationLinear ( ) const
Returns
light attenuation linear value

◆ getAttenuationQuadratic()

float gLight::getAttenuationQuadratic ( ) const
Returns
light attenuation quadratic value

◆ getDiffuseColor()

gColor * gLight::getDiffuseColor ( )

Gives diffuse color RGBA value.

This function can be use two type. Using directly giving memory address. Other way, Typing like function.r, function.g, function.b, function.a giving value of color component.

Returns
color object memory address or RGBA value

◆ getDiffuseColorAlpha()

float gLight::getDiffuseColorAlpha ( ) const

Gives alpha component value range is [0,1].

Returns
diffuse color alpha component.

◆ getDiffuseColorBlue()

float gLight::getDiffuseColorBlue ( ) const

Gives blue component value the range is

Returns
diffuse color blue component.

◆ getDiffuseColorGreen()

float gLight::getDiffuseColorGreen ( ) const

Gives green component value range is [0,1].

Returns
diffuse color green component.

◆ getDiffuseColorRed()

float gLight::getDiffuseColorRed ( ) const

Gives red component value range is [0,1].

Returns
diffuse color red component.

◆ getDirection()

const glm::vec3 & gLight::getDirection ( ) const

Gives light direction x, y, z coordinate. For example, can be using function.x, function.y, function.z. This typing showing light x, y, z direction. If this function using more than 1, copy constructor called.

Returns
Light direction with three dimensional floating point vector

◆ getSpecularColor()

gColor * gLight::getSpecularColor ( )

Gives specular color RGBA value.

This function can be use two type. Using directly giving memory address. Other way, Typing like function.r, function.g, function.b, function.a giving value of color component.

Returns
color object memory address or RGBA value

◆ getSpecularColorAlpha()

float gLight::getSpecularColorAlpha ( ) const

Gives alpha component value range is [0,1].

Returns
specular color alpha component.

◆ getSpecularColorBlue()

float gLight::getSpecularColorBlue ( ) const

Gives blue component value range is [0,1].

Returns
specular color blue component.

◆ getSpecularColorGreen()

float gLight::getSpecularColorGreen ( ) const

Gives green component value range is [0,1].

Returns
specular color green component.

◆ getSpecularColorRed()

float gLight::getSpecularColorRed ( ) const

Gives red component value range is [0,1].

Returns
specular color red component.

◆ getSpotCutOff()

const glm::vec2 & gLight::getSpotCutOff ( ) const

For example, can be using function.x and function.y. This typing showing light spot cutoff angle. If this function using more than 1, copy constructor called.

Returns
spot cut off angles

◆ getSpotCutOffAngle()

float gLight::getSpotCutOffAngle ( ) const
Returns
spot angle between minimum angle

◆ getSpotCutOffSpread()

float gLight::getSpotCutOffSpread ( ) const
Returns
spot angle between maximum angle

◆ getSpotOuterCutOffAngle()

float gLight::getSpotOuterCutOffAngle ( ) const
Returns
spot angle between minimum angle and maximum angle

◆ getType()

int gLight::getType ( ) const

Gives using type of light id

Returns
light type id no

◆ isChanged()

bool gLight::isChanged ( ) const
Returns
true if light data is changed and not uploaded to the GPU yet, false if not

◆ isEnabled()

bool gLight::isEnabled ( ) const
Returns
true if light is enable, false if not

◆ processTransformationMatrix()

void gLight::processTransformationMatrix ( )
overrideprotectedvirtual

Reimplemented from gNode.

◆ rotate()

void gLight::rotate ( float  radians,
float  ax,
float  ay,
float  az 
)

Rotates light objects around the given vector.

The vector (ax, ay, az) should be a unit vector (e.g., (1, 0, 0), (0, 1, 1), etc.) because the function multiplies this vector by the rotation amount in radians. For example, rotate(PI / 2, 0, 0, 1) rotates the object 90 degrees around the Z axis. All rotations are relative to the object's pivot point.

Parameters
radiansthe amount of rotation in radians
axthe x component of the rotation axis (unit vector)
aythe y component of the rotation axis (unit vector)
azthe z component of the rotation axis (unit vector)

◆ rotateAround()

void gLight::rotateAround ( float  radians,
const glm::vec3 &  axis,
const glm::vec3 &  point 
)

◆ rotateAroundDeg()

void gLight::rotateAroundDeg ( float  degrees,
const glm::vec3 &  axis,
const glm::vec3 &  point 
)

◆ rotateDeg()

void gLight::rotateDeg ( float  degrees,
float  ax,
float  ay,
float  az 
)

Same as rotate(), but the angle is specified in degrees.

Parameters
degreesthe amount of rotation in degrees
axthe x component of the rotation axis (unit vector)
aythe y component of the rotation axis (unit vector)
azthe z component of the rotation axis (unit vector)

◆ setAmbientColor() [1/3]

void gLight::setAmbientColor ( const gColor color)

Ambient color changing with gColor object.

Parameters
colorgColor object to use changing color

◆ setAmbientColor() [2/3]

void gLight::setAmbientColor ( gColor color)

Ambient color changing with gColor object.

Parameters
colorgColor object to use changing color

◆ setAmbientColor() [3/3]

void gLight::setAmbientColor ( int  r,
int  g,
int  b,
int  a = 255 
)

Ambient color changing with RGBA. The range of the value [0,255]

Parameters
rambient color red component.
gambient color green component.
bambient color blue component.
aambient color alpha component.

◆ setAttenuation() [1/2]

void gLight::setAttenuation ( float  constant,
float  linear,
float  quadratic 
)

When blending between these three types of attenuation, set the proportions of each attenuation type against the other two types. To avoid confusion, a proportion of 3:6:1 gives the exact same, which can easily be translated to 30%, 60% and 10%.

Parameters
constantThe intensity, represented by the brigtness setting of the light entity, will be totally unaffected by distance, continuing until it hits a surface, theoretically capable of illuminating an infinite area.
linearLight intensity (set by its brightness) will diminish (at a fixed rate) as it travels from its source.
quadraticMathematically, the attenuation of a 100% quadratic light is exponential (quadratic), expressed as "I = 1/d^2", meaning that the further the light travels from its source, the more it will be diminished.

◆ setAttenuation() [2/2]

void gLight::setAttenuation ( glm::vec3  attenuation)

Alternative version to blending between these three types of attenuation, using three dimensional of the vector type.

Parameters
attenuationthree dimensional floating point vector

◆ setChanged()

void gLight::setChanged ( bool  isChanged)

◆ setDiffuseColor() [1/3]

void gLight::setDiffuseColor ( const gColor color)

Diffuse color changing with gColor object.

Parameters
colorgColor object to use changing color

◆ setDiffuseColor() [2/3]

void gLight::setDiffuseColor ( gColor color)

Diffuse color changing with gColor object.

Parameters
colorgColor object to use changing color

◆ setDiffuseColor() [3/3]

void gLight::setDiffuseColor ( int  r,
int  g,
int  b,
int  a = 255 
)

Diffuse color changing with RGBA. The range of the value [0,255].

Parameters
rdiffuse color red component.
gdiffuse color green component.
bdiffuse color blue component.
adiffuse color alpha component.

◆ setOrientation() [1/2]

void gLight::setOrientation ( const glm::quat &  o)

◆ setOrientation() [2/2]

void gLight::setOrientation ( const glm::vec3 &  angles)

◆ setSpecularColor() [1/3]

void gLight::setSpecularColor ( const gColor color)

Specular color changing with gColor object.

Parameters
colorgColor object to use changing color

◆ setSpecularColor() [2/3]

void gLight::setSpecularColor ( gColor color)

Specular color changing with gColor object.

Parameters
colorgColor object to use changing color

◆ setSpecularColor() [3/3]

void gLight::setSpecularColor ( int  r,
int  g,
int  b,
int  a = 255 
)

Specular color changing with RGBA. The range of the value [0,255]

Parameters
rspecular color red component.
gspecular color green component.
bspecular color blue component.
aspecular color alpha component.

◆ setSpotCutOff()

void gLight::setSpotCutOff ( glm::vec2  spotCutOff)

Value that specifies the maximum spread angle of a light source. Only values in the range 0 90 and the special value 180 are accepted. If the angle between the direction of the light and the direction from the light to the vertex being lighted is greater than the spot cutoff angle, the light is completely masked. Otherwise, its intensity is controlled by the spot exponent and the attenuation factors. The initial spot cutoff is 180, resulting in uniform light distribution.

Parameters
spotCutOffTwo dimensional of the vector type

◆ setSpotCutOffAngle()

void gLight::setSpotCutOffAngle ( float  cutOffAngle)
Parameters
cutOffAnglechanging minimum angle

◆ setSpotCutOffSpread()

void gLight::setSpotCutOffSpread ( float  cutOffSpreadAngle)
Parameters
cutOffSpreadAnglechanging maximum angle

◆ setType()

void gLight::setType ( int  lightType)

Changing type of light using id

Parameters
lightTypelight id no

Friends And Related Symbol Documentation

◆ gRenderer

friend class gRenderer
friend

Member Data Documentation

◆ LIGHTTYPE_AMBIENT

const int gLight::LIGHTTYPE_AMBIENT = 0
static

◆ LIGHTTYPE_DIRECTIONAL

const int gLight::LIGHTTYPE_DIRECTIONAL = 1
static

◆ LIGHTTYPE_POINT

const int gLight::LIGHTTYPE_POINT = 2
static

◆ LIGHTTYPE_SPOT

const int gLight::LIGHTTYPE_SPOT = 3
static

The documentation for this class was generated from the following file: