Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GFXLight Class Reference

Holds all information for a single light object. More...

#include <gfxlib_struct.h>

Inheritance diagram for GFXLight:
gfx_light MeshFX

Public Member Functions

 GFXLight ()
 
 GFXLight (const bool enabled, const GFXColor &vect, const GFXColor &diffuse=GFXColor(0, 0, 0, 1), const GFXColor &specular=GFXColor(0, 0, 0, 1), const GFXColor &ambient=GFXColor(0, 0, 0, 1), const GFXColor &attenuate=GFXColor(1, 0, 0), const GFXColor &direction=GFXColor(0, 0, 0), float exp=0.0f, float cutoff=180.0f, float size=0.0f)
 
void SetProperties (enum LIGHT_TARGET, const GFXColor &color)
 
GFXColor GetProperties (enum LIGHT_TARGET) const
 
void setSize (float size_)
 
float getSize () const
 
Vector getPosition () const
 
void disable ()
 
void enable ()
 
bool attenuated () const
 
void apply_attenuate (bool attenuated)
 

Public Attributes

int target
 physical GL light its saved in More...
 
float vect [3]
 last is w for positional, otherwise 3 for spec More...
 
int options
 
float diffuse [4]
 
float specular [4]
 
float ambient [4]
 
float attenuate [3]
 
float direction [3]
 
float exp
 
float cutoff
 
float size
 

Detailed Description

Holds all information for a single light object.

Definition at line 341 of file gfxlib_struct.h.

Constructor & Destructor Documentation

GFXLight::GFXLight ( )
inline

Definition at line 359 of file gfxlib_struct.h.

References ambient, attenuate, cutoff, diffuse, direction, exp, options, size, specular, target, and vect.

360  {
361  //vect[0]=vect[1]=vect[2]=vect[3]=0;
362  vect[0] = vect[1] = vect[2] = 0;
363  attenuate[0] = 1;
364  attenuate[1] = attenuate[2] = 0;
365  diffuse[0] = diffuse[1] = diffuse[2] = 0; //openGL defaults
366  specular[0] = specular[1] = specular[2] = 0; //openGL defaults
367  ambient[0] = ambient[1] = ambient[2] = options = 0;
368  diffuse[3] = specular[3] = ambient[3] = 1;
369  target = -1; //physical GL light its saved in
370 
371  direction[0] = direction[1] = direction[2] = 0.0;
372  exp = 0.0f;
373  cutoff = 180.0f;
374  size = 0.0f;
375  }
GFXLight::GFXLight ( const bool  enabled,
const GFXColor vect,
const GFXColor diffuse = GFXColor( 0, 0, 0, 1 ),
const GFXColor specular = GFXColor( 0, 0, 0, 1 ),
const GFXColor ambient = GFXColor( 0, 0, 0, 1 ),
const GFXColor attenuate = GFXColor( 1, 0, 0 ),
const GFXColor direction = GFXColor( 0, 0, 0 ),
float  exp = 0.0f,
float  cutoff = 180.0f,
float  size = 0.0f 
)

Definition at line 4 of file gfxlib_struct_server.cpp.

13  {}

Member Function Documentation

void GFXLight::apply_attenuate ( bool  attenuated)

Definition at line 131 of file gl_light.cpp.

References GFX_ATTENUATED, and options.

Referenced by gfx_light::ResetProperties(), and SetProperties().

132 {
135  : ( options&(~GFX_ATTENUATED) );
136 }
bool GFXLight::attenuated ( ) const

Definition at line 126 of file gl_light.cpp.

Referenced by gfx_light::FinesseClobberLight(), picklight(), gfx_light::ResetProperties(), and SetProperties().

127 {
128  return (attenuate[0] != 1) || (attenuate[1] != 0) || (attenuate[2] != 0);
129 }
void GFXLight::disable ( )

Definition at line 116 of file gl_light.cpp.

References GFX_LIGHT_ENABLED, and options.

Referenced by gfx_light::Create(), and gfx_light::Disable().

117 {
119 }
void GFXLight::enable ( )

Definition at line 121 of file gl_light.cpp.

References GFX_LIGHT_ENABLED, and options.

Referenced by gfx_light::Enable().

122 {
124 }
Vector GFXLight::getPosition ( ) const
inline

Definition at line 393 of file gfxlib_struct.h.

References Vector.

Referenced by GFXUploadLightState().

393 { return Vector(vect[0], vect[1], vect[2]); }
GFXColor GFXLight::GetProperties ( enum LIGHT_TARGET  lighttarg) const

Definition at line 177 of file gl_light.cpp.

References AMBIENT, ATTENUATE, DIFFUSE, POSITION, and SPECULAR.

178 {
179  switch (lighttarg)
180  {
181  case SPECULAR:
182  return GFXColor( specular[0],
183  specular[1],
184  specular[2],
185  specular[3] );
186 
187  case AMBIENT:
188  return GFXColor( ambient[0],
189  ambient[1],
190  ambient[2],
191  ambient[3] );
192 
193  case POSITION:
194  return GFXColor( vect[0],
195  vect[1],
196  vect[2] );
197 
198  break;
199  case ATTENUATE:
200  return GFXColor(
201  attenuate[0],
202  attenuate[1],
203  attenuate[2] );
204 
205  case DIFFUSE:
206  default: //just for kicks
207  return GFXColor( diffuse[0],
208  diffuse[1],
209  diffuse[2],
210  diffuse[3] );
211  }
212 }
float GFXLight::getSize ( ) const
inline

Definition at line 391 of file gfxlib_struct.h.

References size.

Referenced by GFXUploadLightState().

391 { return size; }
void GFXLight::SetProperties ( enum LIGHT_TARGET  lighttarg,
const GFXColor color 
)

Definition at line 138 of file gl_light.cpp.

References GFXColor::a, AMBIENT, apply_attenuate(), ATTENUATE, attenuated(), GFXColor::b, DIFFUSE, EMISSION, GFXColor::g, POSITION, GFXColor::r, and SPECULAR.

Referenced by gfx_light::ResetProperties(), and Atmosphere::Update().

139 {
140  switch (lighttarg)
141  {
142  case DIFFUSE:
143  diffuse[0] = color.r;
144  diffuse[1] = color.g;
145  diffuse[2] = color.b;
146  diffuse[3] = color.a;
147  break;
148  case SPECULAR:
149  specular[0] = color.r;
150  specular[1] = color.g;
151  specular[2] = color.b;
152  specular[3] = color.a;
153  break;
154  case AMBIENT:
155  ambient[0] = color.r;
156  ambient[1] = color.g;
157  ambient[2] = color.b;
158  ambient[3] = color.a;
159  break;
160  case POSITION:
161  vect[0] = color.r;
162  vect[1] = color.g;
163  vect[2] = color.b;
164  break;
165  case ATTENUATE:
166  attenuate[0] = color.r;
167  attenuate[1] = color.g;
168  attenuate[2] = color.b;
169  break;
170  case EMISSION:
171  default:
172  break;
173  }
175 }
void GFXLight::setSize ( float  size_)
inline

Definition at line 390 of file gfxlib_struct.h.

References size.

Referenced by GetLights().

390 { size = size_; }

Member Data Documentation

float GFXLight::cutoff
float GFXLight::direction[3]

Definition at line 353 of file gfxlib_struct.h.

Referenced by NetBuffer::addGFXLight(), NetBuffer::getGFXLight(), and GFXLight().

float GFXLight::exp

Definition at line 354 of file gfxlib_struct.h.

Referenced by NetBuffer::addGFXLight(), NetBuffer::getGFXLight(), and GFXLight().

float GFXLight::size

Definition at line 356 of file gfxlib_struct.h.

Referenced by getSize(), GFXLight(), and setSize().


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