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
MeshFX Class Reference

#include <mesh.h>

Inheritance diagram for MeshFX:
GFXLight

Public Member Functions

 MeshFX ()
 
 MeshFX (const float TTL, const float delta, 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))
 Makes a meshFX given TTL and delta values. More...
 
void MergeLights (const MeshFX &other)
 Merges two MeshFX in a given way to seamlessly blend multiple hits on a shield. More...
 
bool Update (float ttime)
 updates the growth and death of the FX. Returns false if dead More...
 
- Public Member Functions inherited from GFXLight
 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

float delta
 The ammt of change that such meshFX objects attenuation get. More...
 
float TTL
 The Time to live of the current light effect. More...
 
float TTD
 After it has achieved its time to live max it has to slowly fade out and die. More...
 
- Public Attributes inherited from GFXLight
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

Mesh FX stores various lights that light up shield or hull for damage They may be merged and they grow and shring based on their TTL and TTD and delta values They must be updated every frame or every physics frame if not drawn (pass in time

Definition at line 61 of file mesh.h.

Constructor & Destructor Documentation

MeshFX::MeshFX ( )
inline

Definition at line 70 of file mesh.h.

References delta, TTD, and TTL.

70  : GFXLight()
71  {
72  TTL = TTD = delta = 0;
73  }
MeshFX::MeshFX ( const float  TTL,
const float  delta,
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 ) 
)

Makes a meshFX given TTL and delta values.

Definition at line 15 of file mesh_fx.cpp.

References delta, TTD, and TTL.

22  :
23  GFXLight( enabled, vect, diffuse, specular, ambient, attenuate )
24 {
25  this->TTL = TTL;
26  this->TTD = this->TTL;
27  this->delta = delta;
28 }

Member Function Documentation

void MeshFX::MergeLights ( const MeshFX other)

Merges two MeshFX in a given way to seamlessly blend multiple hits on a shield.

Definition at line 29 of file mesh_fx.cpp.

References GFXLight::ambient, AvLights(), delta, GFXLight::diffuse, GFXLight::options, GFXLight::specular, TTD, TTL, GFXLight::vect, and Vector.

30 {
31  //if (TTL>0) {
32  delta = .5*(other.delta+this->delta);
33  /* TTL = (TTL>other.TTL)
34  * ?
35  * (.666667*TTL+.33333*other.TTL)
36  * :
37  * (.666667*other.TTL+.333333*TTL);*/
38  TTL = .5*(TTL+other.TTL);
39  TTD = .5*(TTD+other.TTD);
40  Vector vec( vect[0], vect[1], vect[2] );
41  vec *= .5;
42  Vector othervec( other.vect[0], other.vect[1], other.vect[2] );
43  othervec *= .5;
44  //float distsqr = ((vec-othervec)).Dot ((vec-othervec));
45  options |= other.options;
46  vec = vec+othervec;
47  vect[0] = vec.i;
48  vect[1] = vec.j;
49  vect[2] = vec.k;
50  AvLights( diffuse, other.diffuse );
51  AvLights( specular, other.specular );
52  AvLights( ambient, other.ambient );
53  /* attenuate[2]=1./attenuate[2];
54  * attenuate[2]+=1./other.attenuate[2]+distsqr;
55  * attenuate[2]= 1./attenuate[2];
56  *
57  * attenuate[1]=1./attenuate[1];
58  * attenuate[1]+=1./other.attenuate[1]+sqrtf(distsqr);
59  * attenuate[1]= 1./attenuate[1];*/
60  //} else {
61  //memcpy(this, &other, sizeof (MeshFX));
62  //}
63 }
bool MeshFX::Update ( float  ttime)

updates the growth and death of the FX. Returns false if dead

Definition at line 64 of file mesh_fx.cpp.

References GFXLight::attenuate, delta, TTD, and TTL.

65 {
66  TTL -= howmuchtime;
67  if (TTL < 0) {
68  TTL = 0;
69  TTD -= howmuchtime;
70  attenuate[2] += 1.5*delta*howmuchtime;
71  //attenuate[1]+=2*delta*GetElapsedTime();
72 
73  //attenuate[2]*=1+2*delta*GetElapsedTime();
74  //attenuate[1]*=1+2*delta*GetElapsedTime();
75  } else {
76  attenuate[2] -= delta*howmuchtime;
77  if (attenuate[2] < delta) attenuate[2] = delta/4;
78  //attenuate[1]-=1.25*delta*GetElapsedTime();
79  //attenuate[2]*=1- .5*delta*GetElapsedTime();
80  //attenuate[1]*=1- .5*delta*GetElapsedTime();
81  }
82  return TTD > 0;
83 }

Member Data Documentation

float MeshFX::delta

The ammt of change that such meshFX objects attenuation get.

Definition at line 65 of file mesh.h.

Referenced by MergeLights(), MeshFX(), and Update().

float MeshFX::TTD

After it has achieved its time to live max it has to slowly fade out and die.

Definition at line 69 of file mesh.h.

Referenced by MergeLights(), MeshFX(), and Update().

float MeshFX::TTL

The Time to live of the current light effect.

Definition at line 67 of file mesh.h.

Referenced by MergeLights(), MeshFX(), and Update().


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