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

#include <animation.h>

Inheritance diagram for Animation:
AnimatedTexture Texture

Public Member Functions

 Animation ()
 
 Animation (VSFileSystem::VSFile *f, bool Rep=0, float priority=.1, enum FILTER ismipmapped=MIPMAP, bool camorient=false, bool appear_near_by_radius=false, const GFXColor &col=GFXColor(1, 1, 1, 1))
 
 Animation (const char *, bool Rep=0, float priority=.1, enum FILTER ismipmapped=MIPMAP, bool camorient=false, bool appear_near_by_radius=false, const GFXColor &col=GFXColor(1, 1, 1, 1))
 
 ~Animation ()
 
void Draw ()
 
void SetFaceCam (bool face)
 
void SetInterpolate (bool interp)
 
bool CalculateOrientation (Matrix &result)
 
void DrawNow (const Matrix &final_orientation)
 
void DrawNoTransform (bool cross=true, bool blendoption=false)
 
void DrawAsVSSprite (class VSSprite *spr)
 
void SetDimensions (float wid, float hei)
 
void GetDimensions (float &wid, float &hei)
 
QVector Position ()
 
void SetPosition (const QVector &)
 
void SetOrientation (const Vector &p, const Vector &q, const Vector &r)
 
- Public Member Functions inherited from AnimatedTexture
virtual void setTime (double tim)
 
virtual double curTime () const
 
virtual unsigned int numFrames () const
 
virtual float framesPerSecond () const
 
virtual unsigned int numLayers () const
 
virtual unsigned int numPasses () const
 
virtual bool canMultiPass () const
 
virtual bool constFrameRate () const
 
 AnimatedTexture ()
 
 AnimatedTexture (int stage, enum FILTER imm, bool detailtexture=false)
 
 AnimatedTexture (const char *file, int stage, enum FILTER imm, bool detailtexture=false)
 
 AnimatedTexture (VSFileSystem::VSFile &openedfile, int stage, enum FILTER imm, bool detailtexture=false)
 
void Load (VSFileSystem::VSFile &f, int stage, enum FILTER ismipmapped, bool detailtex=false)
 
void LoadAni (VSFileSystem::VSFile &f, int stage, enum FILTER ismipmapped, bool detailtex=false)
 
void LoadVideoSource (VSFileSystem::VSFile &f)
 
virtual void LoadFrame (int num)
 
void Destroy ()
 
virtual const TextureOriginal () const
 
virtual TextureOriginal ()
 
 ~AnimatedTexture ()
 
virtual TextureClone ()
 
virtual void MakeActive ()
 Binds the texture in the GFX library. More...
 
virtual void MakeActive (int stage)
 
virtual void MakeActive (int stage, int pass)
 
bool SetupPass (int pass, int stage, const enum BLENDFUNC src, const enum BLENDFUNC dst)
 
bool SetupPass (int pass, const enum BLENDFUNC src, const enum BLENDFUNC dst)
 
void SetInterpolateFrames (bool set)
 
void SetInterpolateTCoord (bool set)
 
void SetLoopInterp (bool set)
 
void SetLoop (bool set)
 
bool GetInterpolateFrames () const
 
bool GetInterpolateTCoord () const
 
bool GetLoopInterp () const
 
bool GetLoop () const
 
SharedPtr< Audio::SourceGetTimeSource () const
 
void SetTimeSource (SharedPtr< Audio::Source > source)
 
void ClearTimeSource ()
 
void Reset ()
 
bool Done () const
 
virtual bool LoadSuccess ()
 If the texture has loaded properly returns true. More...
 
- Public Member Functions inherited from Texture
void FileNotFound (const std::string &)
 
GFXBOOL checkold (const std::string &s, bool shared, std::string &hashname)
 Returns if this texture is actually already loaded. More...
 
void modold (const std::string &s, bool shared, std::string &hashname)
 
void setold ()
 Loads the old texture. More...
 
bool checkbad (const string &s)
 
void setbad (const string &s)
 
void InitTexture ()
 Inits the class with default values. More...
 
int Bind (Texture *other, int maxdimension=65536, GFXBOOL detailtexture=GFXFALSE)
 Binds this texture to the same name as the given texture - for multipart textures. More...
 
 Texture (int stage=0, enum FILTER mipmap=MIPMAP, enum TEXTURE_TARGET target=TEXTURE2D, enum TEXTURE_IMAGE_TARGET imagetarget=TEXTURE_2D, enum ADDRESSMODE address_mode=DEFAULT_ADDRESS_MODE)
 Creates an unbounded texture. Set data and dimensions before binding. Or explicitly load a file. More...
 
 Texture (const char *, const char *, int stage=0, enum FILTER mipmap=MIPMAP, enum TEXTURE_TARGET target=TEXTURE2D, enum TEXTURE_IMAGE_TARGET imagetarget=TEXTURE_2D, float alpha=1, int zeroval=0, GFXBOOL force=GFXFALSE, int max_dimension_size=65536, GFXBOOL detail_texture=GFXFALSE, GFXBOOL nocache=false, enum ADDRESSMODE address_mode=DEFAULT_ADDRESS_MODE, Texture *main=0)
 Creates a texture with a single bitmap as color data and another grayscale .bmp as alpha data. More...
 
 Texture (const char *FileName, int stage=0, enum FILTER mipmap=MIPMAP, enum TEXTURE_TARGET target=TEXTURE2D, enum TEXTURE_IMAGE_TARGET imagetarget=TEXTURE_2D, GFXBOOL force=GFXFALSE, int max_dimension_size=65536, GFXBOOL detail_texture=GFXFALSE, GFXBOOL nocache=false, enum ADDRESSMODE address_mode=DEFAULT_ADDRESS_MODE, Texture *main=0)
 Creates a texture with only color data as a single bitmap. More...
 
 Texture (VSFileSystem::VSFile *f, int stage=0, enum FILTER mipmap=MIPMAP, enum TEXTURE_TARGET target=TEXTURE2D, enum TEXTURE_IMAGE_TARGET imagetarget=TEXTURE_2D, GFXBOOL force=GFXFALSE, int max_dimension_size=65536, GFXBOOL detail_texture=GFXFALSE, GFXBOOL nocache=false, enum ADDRESSMODE address_mode=DEFAULT_ADDRESS_MODE, Texture *main=0)
 
void Load (const char *, const char *, int stage=0, enum FILTER mipmap=MIPMAP, enum TEXTURE_TARGET target=TEXTURE2D, enum TEXTURE_IMAGE_TARGET imagetarget=TEXTURE_2D, float alpha=1, int zeroval=0, GFXBOOL force=GFXFALSE, int max_dimension_size=65536, GFXBOOL detail_texture=GFXFALSE, GFXBOOL nocache=false, enum ADDRESSMODE address_mode=DEFAULT_ADDRESS_MODE, Texture *main=0)
 
void Load (const char *FileName, int stage=0, enum FILTER mipmap=MIPMAP, enum TEXTURE_TARGET target=TEXTURE2D, enum TEXTURE_IMAGE_TARGET imagetarget=TEXTURE_2D, GFXBOOL force=GFXFALSE, int max_dimension_size=65536, GFXBOOL detail_texture=GFXFALSE, GFXBOOL nocache=false, enum ADDRESSMODE address_mode=DEFAULT_ADDRESS_MODE, Texture *main=0)
 
virtual ~Texture ()
 Texture copy constructor that increases appropriate refcounts. More...
 
int getStage () const
 
int getFilter () const
 
int getTarget () const
 
int getImageTarget () const
 
bool operator< (const Texture &b) const
 A way to sort the texture by the original address (to make sure like textures stick togehter. More...
 
bool operator== (const Texture &b) const
 A way to test if the texture is equal to another based on original values. More...
 
void setReference (Texture *other)
 Make this instance a reference of "other". More...
 
virtual void Prioritize (float)
 Changes priority of texture. More...
 

Static Public Member Functions

static void ProcessDrawQueue (std::vector< Animation * > &, float)
 
static void ProcessDrawQueue ()
 
static bool NeedsProcessDrawQueue ()
 
static void ProcessFarDrawQueue (float)
 
static bool NeedsProcessFarDrawQueue ()
 
- Static Public Member Functions inherited from AnimatedTexture
static void UpdateAllPhysics ()
 
static void UpdateAllFrame ()
 
static AnimatedTextureCreateVideoTexture (const std::string &fname, int stage=0, enum FILTER ismipmapped=BILINEAR, bool detailtex=false)
 
- Static Public Member Functions inherited from Texture
static TextureExists (std::string s)
 Whether or not the string exists as a texture. More...
 
static TextureExists (std::string s, std::string a)
 Whether or not the color and alpha data already exist. More...
 

Additional Inherited Members

- Public Attributes inherited from Texture
StringPool::Reference texfilename
 The file name used to load this texture. More...
 
enum FILTER ismipmapped
 the filter mode of this texture More...
 
unsigned char * data
 The data of this texture (used in between functions, deleted) More...
 
int name
 The GFXname of this texture. More...
 
int stage
 The multitexture stage of this texture. More...
 
Vector mintcoord
 The minimum/maximum texturing coordinates for this texture (have in mind that it is not always enforce, ie. for meshes) (i=s, j=t, k=u) More...
 
Vector maxtcoord
 
Textureoriginal
 The original data that would represent this texture. More...
 
bool bound
 For re-biding. More...
 
uint boundSizeX
 
uint boundSizeY
 
VSImageMode boundMode
 
int refcount
 The number of references on the original data. More...
 
enum TEXTURE_TARGET texture_target
 The target this will go to (cubemap or otherwise) More...
 
enum TEXTURE_IMAGE_TARGET image_target
 
enum ADDRESSMODE address_mode
 The address mode being used with this texture. More...
 
- Protected Member Functions inherited from Texture
int Bind (int maxdimension, GFXBOOL detailtexture)
 Binds this texture to GFX library. More...
 
void UnBind ()
 UnBinds from GFX library. More...
 
void Transfer (int maxdimension, GFXBOOL detailtexture)
 Transfers this texture to GFX library. More...
 
- Protected Attributes inherited from AnimatedTexture
unsigned int numframes
 
float timeperframe
 
unsigned int active
 
unsigned int nextactive
 
float active_fraction
 
double curtime
 
double lastcurtime
 
double lastrealtime
 
bool constframerate
 
bool done
 

Detailed Description

Definition at line 41 of file animation.h.

Constructor & Destructor Documentation

Animation::Animation ( )

Definition at line 56 of file animation.cpp.

References VSCONSTRUCT2.

57 {
58  VSCONSTRUCT2( 'a' )
59  height = 0.001F;
60  width = 0.001F;
61 }
Animation::Animation ( VSFileSystem::VSFile f,
bool  Rep = 0,
float  priority = .1,
enum FILTER  ismipmapped = MIPMAP,
bool  camorient = false,
bool  appear_near_by_radius = false,
const GFXColor col = GFXColor( 1, 1, 1,                                                                                             1 ) 
)

Definition at line 72 of file animation.cpp.

78  : mycolor( c )
79 {}
Animation::Animation ( const char *  FileName,
bool  Rep = 0,
float  priority = .1,
enum FILTER  ismipmapped = MIPMAP,
bool  camorient = false,
bool  appear_near_by_radius = false,
const GFXColor col = GFXColor( 1, 1, 1,                                                                                  1 ) 
)

Definition at line 81 of file animation.cpp.

References ani_alpha, ani_close, ani_repeat, ani_up, VSFileSystem::AnimFile, VSFileSystem::VSFile::Close(), f, VSFileSystem::VSFile::Fscanf(), Identity(), AnimatedTexture::Load(), VSFileSystem::Ok, VSFileSystem::VSFile::OpenReadOnly(), AnimatedTexture::SetLoop(), AnimatedTexture::SetLoopInterp(), and VSCONSTRUCT2.

87  : mycolor( c )
88 {
89  Identity( local_transformation );
90  VSCONSTRUCT2( 'a' )
91  //repeat = Rep;
92  options = 0;
93  if (Rep)
94  options |= ani_repeat;
95  if (camorient)
96  options |= ani_up;
97  if (appear_near_by_radius)
98  options |= ani_close;
99  SetLoop( Rep ); //setup AnimatedTexture's loop flag - NOTE: Load() will leave it like this unless a force(No)Loop option is present
100  SetLoopInterp( Rep ); //Default interpolation method == looping method
101  VSFile f;
102  VSError err = f.OpenReadOnly( FileName, AnimFile );
103  if (err > Ok) {
104  //load success already set false
105  } else {
106  f.Fscanf( "%f %f", &width, &height );
107  if (width > 0)
108  options |= ani_alpha;
109  width = fabs( width*0.5F );
110  height = height*0.5F;
111  Load( f, 0, ismipmapped );
112  f.Close();
113  }
114  //VSFileSystem::ResetCurrentPath();
115 }
Animation::~Animation ( )

Definition at line 116 of file animation.cpp.

References animationdrawqueue, far_animationdrawqueue, i, and VSDESTRUCT2.

117 {
118  vector< Animation* >::iterator i;
119  while ( ( i =
120  std::find( far_animationdrawqueue.begin(), far_animationdrawqueue.end(),
121  this ) ) != far_animationdrawqueue.end() )
122  far_animationdrawqueue.erase( i );
123  while ( ( i = std::find( animationdrawqueue.begin(), animationdrawqueue.end(), this ) ) != animationdrawqueue.end() )
124  animationdrawqueue.erase( i );
126 }

Member Function Documentation

bool Animation::CalculateOrientation ( Matrix result)

Definition at line 214 of file animation.cpp.

References ani_close, ani_up, VegaConfig::getVariable(), XMLSupport::parse_float(), Position(), QVector, Vector, VectorAndPositionToMatrix(), and vs_config.

215 {
216  Vector camp, camq, camr;
217  QVector pos( Position() );
218  float hei = height;
219  float wid = width;
220  static float HaloOffset = XMLSupport::parse_float( vs_config->getVariable( "graphics", "HaloOffset", ".1" ) );
221  bool retval =
223  camp,
224  camq,
225  camr,
226  wid,
227  hei,
228  (options&ani_close) ? HaloOffset : 0,
229  false,
230  (options&ani_up) ? NULL : &local_transformation );
231 
232  /*
233  * Camera* TempCam = _Universe->AccessCamera();
234  * TempCam->GetPQR(camp,camq,camr);
235  * if (!camup){
236  * Vector q1 (local_transformation[1],local_transformation[5],local_transformation[9]);
237  * Vector p1 ((q1.Dot(camq))*camq);
238  * camq = (q1.Dot(camp))*camp+p1;
239  * Vector posit;
240  * TempCam->GetPosition (posit);
241  * camr.i = -local_transformation[12]+posit.i;
242  * camr.j = -local_transformation[13]+posit.j;
243  * camr.k = -local_transformation[14]+posit.k;
244  * Normalize (camr);
245  * ScaledCrossProduct (camq,camr,camp);
246  * ScaledCrossProduct (camr,camp,camq);
247  * //if the vectors are linearly dependant we're phucked :) fun fun fun
248  * }
249  */
250  VectorAndPositionToMatrix( result, camp, camq, camr, pos );
251  return retval;
252 }
void Animation::Draw ( )

Definition at line 454 of file animation.cpp.

References _Universe, Universe::AccessCamera(), animationdrawqueue, far_animationdrawqueue, g_game, Camera::GetPosition(), Camera::GetR(), VegaConfig::getVariable(), Magnitude(), XMLSupport::parse_float(), Position(), QVector, R, game_data_t::use_animations, game_data_t::use_textures, Vector, vs_config, and game_data_t::zfar.

Referenced by CoordinateSelect::Draw(), LocationSelect::Draw(), and GamePlanet::Draw().

455 {
456  if (g_game.use_animations != 0 || g_game.use_textures != 0) {
457  Vector camp, camq, camr;
458  QVector pos( Position() );
459  float hei = height;
460  float wid = width;
461  static float HaloOffset = XMLSupport::parse_float( vs_config->getVariable( "graphics", "HaloOffset", ".1" ) );
462 
463 
464  //Why do all this if we can use ::CalculateOrientation?
465  //-- well one reason is that the code change broke it :-/ Until suns display properly or we switch to ogre we should keep it as it was (problem was, flare wouldn't display--- or would display behind the sun)
467  _Universe->AccessCamera()->GetR().k );
468  static float too_far_dist = XMLSupport::parse_float( vs_config->getVariable( "graphics", "anim_far_percent", ".8" ) );
469  if ( ( /*R.Dot*/ ( Position()
470  -_Universe->AccessCamera()->GetPosition() ).Magnitude()+HaloOffset
471  *(height > width ? height : width) ) < too_far_dist*g_game.zfar )
472  //if (::CalculateOrientation (pos,camp,camq,camr,wid,hei,(options&ani_close)?HaloOffset:0,false)) {ss
473  animationdrawqueue.push_back( this );
474  else
475  far_animationdrawqueue.push_back( this );
476  }
477 }
void Animation::DrawAsVSSprite ( class VSSprite spr)

Definition at line 309 of file animation.cpp.

References ani_alpha, CULLFACE, VSSprite::DrawHere(), g_game, GFXBegin(), GFXBlendMode(), GFXDisable(), GFXEnable(), GFXEnd(), GFXGetBlendMode(), GFXMODULATETEXTURE, GFXPopBlendMode(), GFXPushBlendMode(), GFXQUAD, GFXTexCoord2f(), GFXTexCoord4f(), GFXTextureCoordGenMode(), GFXTextureEnv(), GFXToggleTexture(), GFXVertexf(), gl_options, INVSRCALPHA, AnimatedTexture::MakeActive(), Texture::maxtcoord, Texture::mintcoord, gl_options_t::Multitexture, NO_GEN, AnimatedTexture::numLayers(), AnimatedTexture::numPasses(), ONE, AnimatedTexture::SetupPass(), SRCALPHA, game_data_t::use_animations, game_data_t::use_textures, Vector, and ZERO.

310 {
311  if (!spr)
312  return;
313  if (g_game.use_animations != 0 || g_game.use_textures != 0) {
314  //unsigned char alphamaps=ani_alpha;
316  if (options&ani_alpha)
318  else
319  GFXBlendMode( ONE, ZERO );
320  size_t lyr;
321  size_t numlayers = numLayers();
322  bool multitex = (numlayers > 1);
323  size_t numpasses = numPasses();
324  float ms = mintcoord.i, Ms = maxtcoord.i;
325  float mt = mintcoord.j, Mt = maxtcoord.j;
326  GFXDisable( CULLFACE );
327  Vector ll, lr, ur, ul;
328  spr->DrawHere( ll, lr, ur, ul );
329  BLENDFUNC src, dst;
330  GFXGetBlendMode( src, dst );
331  for (lyr = 0; (lyr < gl_options.Multitexture) || (lyr < numlayers); lyr++) {
332  GFXToggleTexture( (lyr < numlayers), lyr );
333  if (lyr < numlayers) GFXTextureCoordGenMode( lyr, NO_GEN, NULL, NULL );
334  }
335  for (size_t pass = 0; pass < numpasses; pass++)
336  if ( SetupPass( pass, 0, src, dst ) ) {
337  MakeActive( 0, pass );
339  GFXBegin( GFXQUAD );
340  if (!multitex) GFXTexCoord2f( ms, Mt );
341 
342  else GFXTexCoord4f( ms, Mt, ms, Mt );
343  GFXVertexf( ll );
344  if (!multitex) GFXTexCoord2f( Ms, Mt );
345 
346  else GFXTexCoord4f( Ms, Mt, Ms, Mt );
347  GFXVertexf( lr );
348  if (!multitex) GFXTexCoord2f( Ms, mt );
349 
350  else GFXTexCoord4f( Ms, mt, Ms, mt );
351  GFXVertexf( ur );
352  if (!multitex) GFXTexCoord2f( ms, mt );
353 
354  else GFXTexCoord4f( ms, mt, ms, mt );
355  GFXVertexf( ul );
356  GFXEnd();
357  }
358  SetupPass( -1, 0, src, dst );
359  for (lyr = 0; lyr < numlayers; lyr++)
360  GFXToggleTexture( false, lyr );
361  GFXEnable( CULLFACE );
362  GFXPopBlendMode();
363  }
364 }
void Animation::DrawNoTransform ( bool  cross = true,
bool  blendoption = false 
)

Definition at line 365 of file animation.cpp.

References ani_alpha, ani_repeat, DEPTHWRITE, AnimatedTexture::Done(), f, g_game, GFXBegin(), GFXBlendMode(), GFXDisable(), GFXEnable(), GFXEnd(), GFXGetBlendMode(), GFXMODULATETEXTURE, GFXQUAD, GFXTexCoord2f(), GFXTexCoord4f(), GFXTextureCoordGenMode(), GFXTextureEnv(), GFXToggleTexture(), GFXVertex3f(), gl_options, INVSRCALPHA, AnimatedTexture::MakeActive(), Texture::maxtcoord, Texture::mintcoord, gl_options_t::Multitexture, NO_GEN, AnimatedTexture::numLayers(), AnimatedTexture::numPasses(), ONE, AnimatedTexture::SetupPass(), SRCALPHA, game_data_t::use_animations, and game_data_t::use_textures.

Referenced by Bolt::Draw().

366 {
367  bool doitagain = false;
368  if (g_game.use_animations == 0 && g_game.use_textures == 0) {} else if ( !Done() || (options&ani_repeat) ) {
369  size_t lyr;
370  size_t numlayers = numLayers();
371  bool multitex = (numlayers > 1);
372  size_t numpasses = numPasses();
373  float ms = mintcoord.i, Ms = maxtcoord.i;
374  float mt = mintcoord.j, Mt = maxtcoord.j;
375  if (blendoption) {
376  if (options&ani_alpha) {
379  } else {
380  GFXBlendMode( ONE, ONE );
381  }
382  }
383  BLENDFUNC src, dst;
384  GFXGetBlendMode( src, dst );
385  for (lyr = 0; (lyr < gl_options.Multitexture) || (lyr < numlayers); lyr++) {
386  GFXToggleTexture( (lyr < numlayers), lyr );
387  if (lyr < numlayers) GFXTextureCoordGenMode( lyr, NO_GEN, NULL, NULL );
388  }
389  for (size_t pass = 0; pass < numpasses; pass++)
390  if ( SetupPass( pass, 0, src, dst ) ) {
391  MakeActive( 0, pass );
393  GFXBegin( GFXQUAD );
394  if (!multitex) GFXTexCoord2f( ms, Mt );
395 
396  else GFXTexCoord4f( ms, Mt, ms, Mt );
397  GFXVertex3f( -width, -height, 0.0f ); //lower left
398  if (!multitex) GFXTexCoord2f( Ms, Mt );
399 
400  else GFXTexCoord4f( Ms, Mt, Ms, Mt );
401  GFXVertex3f( width, -height, 0.0f ); //upper left
402  if (!multitex) GFXTexCoord2f( Ms, mt );
403 
404  else GFXTexCoord4f( Ms, mt, Ms, mt );
405  GFXVertex3f( width, height, 0.0f ); //upper right
406  if (!multitex) GFXTexCoord2f( ms, mt );
407 
408  else GFXTexCoord4f( ms, mt, ms, mt );
409  GFXVertex3f( -width, height, 0.0f ); //lower right
410  if (cross) {
411  if (!multitex) GFXTexCoord2f( ms, Mt );
412 
413  else GFXTexCoord4f( ms, Mt, ms, Mt );
414  GFXVertex3f( -width, 0.0f, -height ); //lower left
415  if (!multitex) GFXTexCoord2f( Ms, Mt );
416 
417  else GFXTexCoord4f( Ms, Mt, Ms, Mt );
418  GFXVertex3f( width, 0.0f, -height ); //upper left
419  if (!multitex) GFXTexCoord2f( Ms, mt );
420 
421  else GFXTexCoord4f( Ms, mt, Ms, mt );
422  GFXVertex3f( width, 0.0f, height ); //upper right
423  if (!multitex) GFXTexCoord2f( ms, mt );
424 
425  else GFXTexCoord4f( ms, mt, ms, mt );
426  GFXVertex3f( -width, 0.0f, height ); //lower right
427  if (!multitex) GFXTexCoord2f( ms, Mt );
428 
429  else GFXTexCoord4f( ms, Mt, ms, Mt );
430  GFXVertex3f( 0.0f, -height, -height ); //lower left
431  if (!multitex) GFXTexCoord2f( Ms, Mt );
432 
433  else GFXTexCoord4f( Ms, Mt, Ms, Mt );
434  GFXVertex3f( 0.0f, height, -height ); //upper left
435  if (!multitex) GFXTexCoord2f( Ms, mt );
436 
437  else GFXTexCoord4f( Ms, mt, Ms, mt );
438  GFXVertex3f( 0.0f, height, height ); //upper right
439  if (!multitex) GFXTexCoord2f( ms, mt );
440 
441  else GFXTexCoord4f( ms, mt, ms, mt );
442  GFXVertex3f( 0.0f, -height, height ); //lower right
443  }
444  GFXEnd();
445  }
446  SetupPass( -1, 0, src, dst );
447  for (lyr = 0; lyr < numlayers; lyr++)
448  GFXToggleTexture( false, lyr );
449  if (blendoption)
450  if (options&ani_alpha)
452  }
453 }
void Animation::DrawNow ( const Matrix final_orientation)

Definition at line 253 of file animation.cpp.

References ani_repeat, AnimatedTexture::Done(), f, g_game, GFXBegin(), GFXEnd(), GFXGetBlendMode(), GFXLoadMatrixModel(), GFXMODULATETEXTURE, GFXQUAD, GFXTexCoord2f(), GFXTexCoord4f(), GFXTextureCoordGenMode(), GFXTextureEnv(), GFXToggleTexture(), GFXVertex3f(), gl_options, AnimatedTexture::MakeActive(), Texture::maxtcoord, Texture::mintcoord, gl_options_t::Multitexture, NO_GEN, AnimatedTexture::numLayers(), AnimatedTexture::numPasses(), AnimatedTexture::SetupPass(), game_data_t::use_animations, and game_data_t::use_textures.

Referenced by bootstrap_draw().

254 {
255 // if (g_game.use_animations == 0 && g_game.use_textures == 0)
256 // {
257 // }
258 // else if ( !Done() || (options&ani_repeat) )
259 // { //chuck_starchaser simplifying...
260  if ( (g_game.use_animations || g_game.use_textures) && (!Done() || (options&ani_repeat)) )
261  {
262  GFXLoadMatrixModel( final_orientation );
263  size_t lyr;
264  size_t numlayers = numLayers();
265  bool multitex = (numlayers > 1);
266  size_t numpasses = numPasses();
267  float ms = mintcoord.i, Ms = maxtcoord.i;
268  float mt = mintcoord.j, Mt = maxtcoord.j;
269  BLENDFUNC src, dst;
270  GFXGetBlendMode( src, dst );
271  for (lyr = 0; (lyr < gl_options.Multitexture) || (lyr < numlayers); lyr++) {
272  GFXToggleTexture( (lyr < numlayers), lyr );
273  if (lyr < numlayers)
274  GFXTextureCoordGenMode( lyr, NO_GEN, NULL, NULL );
275  }
276  for (size_t pass = 0; pass < numpasses; pass++) {
277  if ( SetupPass( pass, 0, src, dst ) ) {
278  MakeActive( 0, pass );
280  GFXBegin( GFXQUAD );
281  if (!multitex)
282  GFXTexCoord2f( ms, Mt );
283  else
284  GFXTexCoord4f( ms, Mt, ms, Mt );
285  GFXVertex3f( -width, -height, 0.0f ); //lower left
286  if (!multitex)
287  GFXTexCoord2f( Ms, Mt );
288  else
289  GFXTexCoord4f( Ms, Mt, Ms, Mt );
290  GFXVertex3f( width, -height, 0.0f ); //upper left
291  if (!multitex)
292  GFXTexCoord2f( Ms, mt );
293  else
294  GFXTexCoord4f( Ms, mt, Ms, mt );
295  GFXVertex3f( width, height, 0.0f ); //upper right
296  if (!multitex)
297  GFXTexCoord2f( ms, mt );
298  else
299  GFXTexCoord4f( ms, mt, ms, mt );
300  GFXVertex3f( -width, height, 0.0f ); //lower right
301  GFXEnd();
302  }
303  }
304  for (lyr = 0; lyr < numlayers; lyr++)
305  GFXToggleTexture( false, lyr );
306  SetupPass( -1, 0, src, dst );
307  }
308 }
void Animation::GetDimensions ( float wid,
float hei 
)

Definition at line 144 of file animation.cpp.

145 {
146  wid = width;
147  hei = height;
148 }
bool Animation::NeedsProcessDrawQueue ( )
static

Definition at line 159 of file animation.cpp.

References AnimationsLeftInQueue().

160 {
161  return AnimationsLeftInQueue();
162 }
bool Animation::NeedsProcessFarDrawQueue ( )
static

Definition at line 173 of file animation.cpp.

References AnimationsLeftInFarQueue().

174 {
175  return AnimationsLeftInFarQueue();
176 }
QVector Animation::Position ( )

Definition at line 135 of file animation.cpp.

References Matrix::p.

Referenced by CalculateOrientation(), Draw(), and ProcessDrawQueue().

136 {
137  return local_transformation.p;
138 }
void Animation::ProcessDrawQueue ( std::vector< Animation * > &  animationdrawqueue,
float  limit 
)
static

Definition at line 177 of file animation.cpp.

References _Universe, Universe::AccessCamera(), ani_alpha, FOG_OFF, g_game, Camera::GetPosition(), GFXBlendMode(), GFXColorf(), GFXFogMode(), i, INVSRCALPHA, j, Magnitude(), ONE, Position(), QVector, SRCALPHA, game_data_t::use_animations, and game_data_t::use_textures.

178 {
179  if (g_game.use_animations == 0 && g_game.use_textures == 0)
180  return;
181  unsigned char alphamaps = ani_alpha;
182  int i, j; //NOT UNSIGNED
183  for (i = animationdrawqueue.size()-1; i >= 0; i--) {
184  GFXColorf( animationdrawqueue[i]->mycolor ); //fixme, should we need this? we get som egreenie explosions
185  Matrix result;
186  if ( alphamaps != (animationdrawqueue[i]->options&ani_alpha) ) {
187  alphamaps = (animationdrawqueue[i]->options&ani_alpha);
188  GFXBlendMode( (alphamaps != 0) ? SRCALPHA : ONE, (alphamaps != 0) ? INVSRCALPHA : ONE );
189  }
190  QVector campos = _Universe->AccessCamera()->GetPosition();
191  animationdrawqueue[i]->CalculateOrientation( result );
192  if ( (limit
193  <= -FLT_MAX) || (animationdrawqueue[i]->Position()-campos).Magnitude()-animationdrawqueue[i]->height > limit ) {
194  //other way was inconsistent about what was far and what was not--need to use the same test for putting to far queueu and drawing it--otherwise graphical glitches
195  GFXFogMode( FOG_OFF );
196  animationdrawqueue[i]->DrawNow( result );
197  animationdrawqueue[i] = 0; //Flag for deletion: gets called multiple times with decreasing values, and eventually is called with limit=-FLT_MAX.
198  }
199  }
200  //Delete flagged ones
201  i = 0;
202  while (i < static_cast<int>(animationdrawqueue.size()) && animationdrawqueue[i])
203  ++i;
204  j = i;
205  while ( i < static_cast<int>(animationdrawqueue.size()) ) {
206  while (i < static_cast<int>(animationdrawqueue.size()) && !animationdrawqueue[i])
207  ++i;
208  while (i < static_cast<int>(animationdrawqueue.size()) && animationdrawqueue[i])
210  }
211  if( j >= 0 )
212  animationdrawqueue.resize( j );
213 }
void Animation::ProcessDrawQueue ( )
static
void Animation::ProcessFarDrawQueue ( float  farval)
static

Definition at line 163 of file animation.cpp.

References far_animationdrawqueue, GFXBlendMode(), GFXDisable(), GFXEnable(), INVSRCALPHA, LIGHTING, ProcessDrawQueue(), SRCALPHA, TEXTURE0, and TEXTURE1.

Referenced by Mesh::ProcessZFarMeshes().

164 {
165  //set farshit
167  GFXDisable( LIGHTING );
168  GFXEnable( TEXTURE0 );
169  GFXDisable( TEXTURE1 );
170 
172 }
void Animation::SetDimensions ( float  wid,
float  hei 
)

Definition at line 139 of file animation.cpp.

Referenced by Bolt::Draw(), and GameUnit< UnitType >::Explode().

140 {
141  width = wid;
142  height = hei;
143 }
void Animation::SetFaceCam ( bool  face)

Definition at line 62 of file animation.cpp.

References ani_up.

Referenced by GameUnit< UnitType >::Explode().

63 {
64  if (face)
65  options |= ani_up;
66  else
67  options &= (~ani_up);
68 }
void Animation::SetInterpolate ( bool  interp)
void Animation::SetOrientation ( const Vector p,
const Vector q,
const Vector r 
)

Definition at line 131 of file animation.cpp.

References Matrix::p, and VectorAndPositionToMatrix().

Referenced by GamePlanet::Draw(), and GameUnit< UnitType >::Explode().

132 {
133  VectorAndPositionToMatrix( local_transformation, p, q, r, local_transformation.p );
134 }
void Animation::SetPosition ( const QVector p)

Definition at line 127 of file animation.cpp.

References Matrix::p.

Referenced by CoordinateSelect::Draw(), LocationSelect::Draw(), and GamePlanet::Draw().

128 {
129  local_transformation.p = p;
130 }

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