DI-Guy SDK Documentation  13.7
diguyViewLight Class Reference

The diguyViewLight provides a interface around a scene light useful in diguy scenario and the opengl renderer, you will probably just use your own lighting system. More...

#include <diguyViewLight.h>

Public Member Functions

General Functions

All functions in this section are callable from:

  • C++
  • Script
const char * get_name ()
 Returns the name of the object. More...
 
const char * get_type_name ()
 Returns the type name of the object. More...
 
void set_direction (float x, float y, float z)
 This function sets the direction of this light. More...
 
void get_direction (float *x, float *y, float *z)
 This function gets the direction of this light. More...
 
void set_position (float x, float y, float z)
 This function sets the position of this light. More...
 
void get_position (float *x, float *y, float *z)
 This function gets the position of this light. More...
 
void set_ambient_color (float r, float g, float b, float a)
 This function sets the ambient color. More...
 
void get_ambient_color (float *r, float *g, float *b, float *a)
 This function gets the ambient color of this light. More...
 
void set_diffuse_color (float r, float g, float b, float a)
 This function sets the diffuse color. More...
 
void get_diffuse_color (float *r, float *g, float *b, float *a)
 This function gets the diffuse color of this light. More...
 
void set_specular_color (float r, float g, float b, float a)
 This function sets the specular color. More...
 
void get_specular_color (float *r, float *g, float *b, float *a)
 This function gets the specular color of this light. More...
 
int get_casts_shadows ()
 Returns if a light will cast shadow; this is limited to DI-Guy Scenario. More...
 
int set_scene_objects_cast_shadows (int value)
 Gets/Sets if a scene object be rendered when the shadow map is rendered. More...
 
int get_scene_objects_cast_shadows ()
 
int set_brightness_multiplier (float multiplier)
 Allows setting the brightness of the primary light beyond 1.0,1.0,1.0, can better emulate daylight when set to 1.5-3. More...
 
float get_brightness_multiplier ()
 
void set_spot_exponent (float exponent)
 edge fade off equivalent to GL_SPOT_EXPONENT More...
 
float get_spot_exponent ()
 
void set_falloff_const (float falloff_const)
 constant distance falloff equivalent to GL_CONSTANT_ATTENUATION More...
 
float get_falloff_const ()
 
void set_falloff_rsq (float falloff_rsq)
 distance squared falloff equivalent to GL_QUADRATIC_ATTENUATION More...
 
float get_falloff_rsq ()
 
Load and Apply Functions

All functions in this section are callable from:

  • C++
  • Script
int load_settings (const char *settings_name)
 Loads the specified settings into this light. More...
 
int load_settings (diguyViewLightSettings *settings)
 Loads the specified settings into this light. More...
 
void apply (int i=0)
 Applies the light to OpenGL state. More...
 
Experimental Functions

The following functions are experimental and may change or disappear with no warning.

void set_casts_shadows (int casts_shadows, bool clear_shadow_map=false)
 Sets if a light will cast shadow; this will only work in DI-Guy Scenario. More...
 
void set_shadow_volume_size (float volume)
 Gets/Sets size of 0th shadow map cascade, defaults to 40m. More...
 
float get_shadow_volume_size ()
 
void set_shadow_offset_multiplier (float multiplier)
 Gets/sets shadow offset multiplier to attempt to compensate for shadow map acne. More...
 
float get_shadow_offset_multiplier ()
 
void set_spotlight_angle (float angle)
 Gets/sets angle in degrees of spot light angle, only used for particle based lights. More...
 
float get_spotlight_angle ()
 
void bind_shadow_map (int shadow_map_size)
 activates and resizes shadow map fbo More...
 
void clear_shadow_map ()
 
void unbind_shadow_map ()
 
void set_active (int active)
 Gets/sets whether light is active or not. More...
 
int get_active ()
 
int set_shadow_map_update_paused (int pause)
 
int get_shadow_map_update_paused ()
 
int set_shadow_map_update_frequency (int frame_frequency)
 
int get_shadow_map_update_frequency ()
 
void set_near_plane (float near_plane)
 
float get_near_plane ()
 
void set_far_plane (float far_plane)
 
float get_far_plane ()
 

Callback Functions

enum  { CALLBACK_ID_SETTINGS_CHANGED = 1 }
 This is an enumeration of the different callbacks that can be registered with add_callback() and add_callback_script(). More...
 
int add_callback (int callback_id, diguyViewLightCallback *callback, void *callback_params=0, void *callback_user_data=0)
 This function adds a user callback. More...
 
int remove_callback (int callback_id, diguyViewLightCallback *callback)
 This function removes a user callback. More...
 
int remove_callback_with_user_data (int callback_id, void *callback_user_data)
 This function removes a user callback. More...
 
int add_callback_script (int callback_id, const char *callback_script, const char *callback_script_type=NULL)
 This function adds a user callback script. More...
 
int remove_callback_script (int callback_id, const char *callback_script, const char *callback_script_type=NULL)
 This function removes a user callback script previously added with add_callback_script(). More...
 

Private Functions

The functions and variables past this point are for internal use only.

No external access to them is expected or necessary.

bdiLightm_light
 
class bdiLight
 
bdiLightget_scripted_object ()
 
 diguyViewLight (bdiLight *light)
 Private constructor. More...
 

Detailed Description

The diguyViewLight provides a interface around a scene light useful in diguy scenario and the opengl renderer, you will probably just use your own lighting system.

Link against: libdiguy

Member Enumeration Documentation

anonymous enum

This is an enumeration of the different callbacks that can be registered with add_callback() and add_callback_script().

Usable From:

  • C++
  • Script
Enumerator
CALLBACK_ID_SETTINGS_CHANGED 

Constructor & Destructor Documentation

diguyViewLight::diguyViewLight ( bdiLight light)
private

Private constructor.

Member Function Documentation

const char* diguyViewLight::get_name ( )

Returns the name of the object.

This pointer will never be NULL.

Returns:

name of the object

const char* diguyViewLight::get_type_name ( )

Returns the type name of the object.

This pointer will never be NULL.

Returns:

type name of the object

void diguyViewLight::set_direction ( float  x,
float  y,
float  z 
)

This function sets the direction of this light.

Parameters
x,y,zx,y,z direction, in meters
void diguyViewLight::get_direction ( float *  x,
float *  y,
float *  z 
)

This function gets the direction of this light.

Values are returned via the passed pointers.

Parameters
x,y,zx,y,z direction, in meters
void diguyViewLight::set_position ( float  x,
float  y,
float  z 
)

This function sets the position of this light.

Parameters
x,y,zx,y,z position, in meters
void diguyViewLight::get_position ( float *  x,
float *  y,
float *  z 
)

This function gets the position of this light.

Values are returned via the passed pointers.

Parameters
x,y,zx,y,z position, in meters
void diguyViewLight::set_ambient_color ( float  r,
float  g,
float  b,
float  a 
)

This function sets the ambient color.

Parameters
r,g,b,ared, green, blue, alpha components
void diguyViewLight::get_ambient_color ( float *  r,
float *  g,
float *  b,
float *  a 
)

This function gets the ambient color of this light.

Values are returned via the passed pointers.

Parameters
r,g,b,ared, green, blue, alpha components
void diguyViewLight::set_diffuse_color ( float  r,
float  g,
float  b,
float  a 
)

This function sets the diffuse color.

Parameters
r,g,b,ared, green, blue, alpha components
void diguyViewLight::get_diffuse_color ( float *  r,
float *  g,
float *  b,
float *  a 
)

This function gets the diffuse color of this light.

Values are returned via the passed pointers.

Parameters
r,g,b,ared, green, blue, alpha components
void diguyViewLight::set_specular_color ( float  r,
float  g,
float  b,
float  a 
)

This function sets the specular color.

Parameters
r,g,b,ared, green, blue, alpha components
void diguyViewLight::get_specular_color ( float *  r,
float *  g,
float *  b,
float *  a 
)

This function gets the specular color of this light.

Values are returned via the passed pointers.

Parameters
r,g,b,ared, green, blue, alpha components
int diguyViewLight::get_casts_shadows ( )

Returns if a light will cast shadow; this is limited to DI-Guy Scenario.

int diguyViewLight::set_scene_objects_cast_shadows ( int  value)

Gets/Sets if a scene object be rendered when the shadow map is rendered.

int diguyViewLight::get_scene_objects_cast_shadows ( )
int diguyViewLight::set_brightness_multiplier ( float  multiplier)

Allows setting the brightness of the primary light beyond 1.0,1.0,1.0, can better emulate daylight when set to 1.5-3.

float diguyViewLight::get_brightness_multiplier ( )
void diguyViewLight::set_spot_exponent ( float  exponent)

edge fade off equivalent to GL_SPOT_EXPONENT

float diguyViewLight::get_spot_exponent ( )
void diguyViewLight::set_falloff_const ( float  falloff_const)

constant distance falloff equivalent to GL_CONSTANT_ATTENUATION

float diguyViewLight::get_falloff_const ( )
void diguyViewLight::set_falloff_rsq ( float  falloff_rsq)

distance squared falloff equivalent to GL_QUADRATIC_ATTENUATION

float diguyViewLight::get_falloff_rsq ( )
int diguyViewLight::load_settings ( const char *  settings_name)

Loads the specified settings into this light.

Returns:

0 on success, -1 on failure

int diguyViewLight::load_settings ( diguyViewLightSettings settings)

Loads the specified settings into this light.

Returns:

0 on success, -1 on failure

void diguyViewLight::apply ( int  i = 0)

Applies the light to OpenGL state.

Currently DI-Guy only supports one light in it's default OpenGL implementation.

At least one light must be applied for advanced DI-Guy reference shaders to work.

int diguyViewLight::add_callback ( int  callback_id,
diguyViewLightCallback callback,
void *  callback_params = 0,
void *  callback_user_data = 0 
)

This function adds a user callback.

Parameters
callbackpointer to function with prototype diguyViewLightCallback (typedefed above)
callback_idinteger id of when this callback is to be called
callback_paramsstruct containing additional parameters needed by some callbacks; actual type depends on callback_id
callback_user_datapointer for user's own use; DI-Guy will do nothing to the contents of this pointer beyond passing it back when the callback is invoked

callback_id should be one of the following values:

CALLBACK_ID_SETTINGS_CHANGED

 This callback will be called if the current settings of this
 light change

Callbacks return a value of type diguyCallbackReturn, which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE. If the callback returns DIGUY_CALLBACK_STOP, the default handler of the function will not be called; the callback is asserting that it has done everything necessary for the function call. If the callback returns DIGUY_CALLBACK_CONTINUE, the default handler for the function will be called after the callback.

Returns:

0 on success, -1 on failure

Callable From:

  • C++
int diguyViewLight::remove_callback ( int  callback_id,
diguyViewLightCallback callback 
)

This function removes a user callback.

All callbacks matching the specified callback_id and callback function will be removed.

Parameters
callback_idinteger id of when this callback is to be called
callbackpointer to function with prototype diguyViewLightCallback (typedefed above)

Returns:

0 on success, -1 on failure

Callable From:

  • C++
int diguyViewLight::remove_callback_with_user_data ( int  callback_id,
void *  callback_user_data 
)

This function removes a user callback.

All callbacks matching the specified callback_id and callback_user_data pointer will be removed.

Parameters
callback_idinteger id of when this callback is to be called
callback_user_datapointer for user's own use

Returns:

0 on success, -1 on failure

Callable From:

  • C++
int diguyViewLight::add_callback_script ( int  callback_id,
const char *  callback_script,
const char *  callback_script_type = NULL 
)

This function adds a user callback script.

Callback scripts can be removed with remove_callback_script().

Parameters
callback_idinteger id of the callback
callback_scriptscript text of callback to be added
callback_script_typethe type of script contained in callback_script

If NULL is passed for callback_script_type, a default script type will be derived based on the default script interpreter of the scenario.

lua specific:

When the script is called, the object for which it is being called will be in the callback_object global.

To pass NULL when calling from a lua script, use nil.

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
int diguyViewLight::remove_callback_script ( int  callback_id,
const char *  callback_script,
const char *  callback_script_type = NULL 
)

This function removes a user callback script previously added with add_callback_script().

Parameters
callback_idinteger id of the callback
callback_scriptscript text of callback previously added
callback_script_typethe type of script contained in callback_script

If NULL is passed for callback_script, all callback scripts whose ids match callback_id and whose types match callback_script_type will be removed.

If NULL is passed for callback_script_type, a default script type will be derived based on the default script interpreter of the scenario.

lua specific:

To pass NULL when calling from a lua script, use nil.

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
void diguyViewLight::set_casts_shadows ( int  casts_shadows,
bool  clear_shadow_map = false 
)

Sets if a light will cast shadow; this will only work in DI-Guy Scenario.

void diguyViewLight::set_shadow_volume_size ( float  volume)

Gets/Sets size of 0th shadow map cascade, defaults to 40m.

Larger values will cover more space but will trade off shadow detail.

float diguyViewLight::get_shadow_volume_size ( )
void diguyViewLight::set_shadow_offset_multiplier ( float  multiplier)

Gets/sets shadow offset multiplier to attempt to compensate for shadow map acne.

Defaults to 1.0f

float diguyViewLight::get_shadow_offset_multiplier ( )
void diguyViewLight::set_spotlight_angle ( float  angle)

Gets/sets angle in degrees of spot light angle, only used for particle based lights.

float diguyViewLight::get_spotlight_angle ( )
void diguyViewLight::bind_shadow_map ( int  shadow_map_size)

activates and resizes shadow map fbo

void diguyViewLight::clear_shadow_map ( )
void diguyViewLight::unbind_shadow_map ( )
void diguyViewLight::set_active ( int  active)

Gets/sets whether light is active or not.

int diguyViewLight::get_active ( )
int diguyViewLight::set_shadow_map_update_paused ( int  pause)
int diguyViewLight::get_shadow_map_update_paused ( )
int diguyViewLight::set_shadow_map_update_frequency ( int  frame_frequency)
int diguyViewLight::get_shadow_map_update_frequency ( )
void diguyViewLight::set_near_plane ( float  near_plane)
float diguyViewLight::get_near_plane ( )
void diguyViewLight::set_far_plane ( float  far_plane)
float diguyViewLight::get_far_plane ( )
bdiLight* diguyViewLight::get_scripted_object ( )
inline

Friends And Related Function Documentation

friend class bdiLight
friend

Member Data Documentation

bdiLight* diguyViewLight::m_light
private

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