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

#include <star.h>

Public Member Functions

 Stars (int num, float spread)
 
void SetBlend (bool blendit, bool fadeit)
 
void Draw ()
 
 ~Stars ()
 

Detailed Description

Definition at line 84 of file star.h.

Constructor & Destructor Documentation

Stars::Stars ( int  num,
float  spread 
)

Definition at line 411 of file star.cpp.

References VegaConfig::getVariable(), XMLSupport::parse_float(), QVector, STARnumvlist, and vs_config.

411  : vlist( NULL )
412  , spread( spread )
413 {
414  static string starspritetextures = vs_config->getVariable( "graphics", "near_stars_sprite_texture", "" );
415  static float starspritesize =
416  XMLSupport::parse_float( vs_config->getVariable( "graphics", "near_stars_sprite_size", "2" ) );
417  if (starspritetextures.length() == 0)
418  vlist = new PointStarVlist( (num/STARnumvlist)+1, spread, "" );
419  else
420  vlist = new SpriteStarVlist( (num/STARnumvlist)+1, spread, "", starspritetextures, starspritesize );
421  fade = blend = true;
422  ResetPosition( QVector( 0, 0, 0 ) );
423 }
Stars::~Stars ( )

Definition at line 580 of file star.cpp.

581 {
582  delete vlist;
583 }

Member Function Documentation

void Stars::Draw ( )

Definition at line 431 of file star.cpp.

References _Universe, Universe::AccessCamera(), ALWAYS, StarVlist::BeginDrawState(), DEPTHTEST, DEPTHWRITE, StarVlist::Draw(), StarVlist::EndDrawState(), Camera::GetAngularVelocity(), Camera::GetPosition(), Camera::GetR(), VegaConfig::getVariable(), Camera::GetVelocity(), GFXAlphaTest(), GFXBlendMode(), GFXCreateLight(), GFXDeleteLight(), GFXDisable(), GFXEnable(), GFXFALSE, GFXLoadIdentity(), GFXPopGlobalEffects(), GFXPushGlobalEffects(), GFXSelectMaterial(), GFXTranslateModel(), GFXTRUE, GREATER, i, INVSRCALPHA, LIGHTING, MODEL, StarVlist::NumTextures(), ONE, XMLSupport::parse_bool(), XMLSupport::parse_float(), QVector, SRCALPHA, STARnumvlist, TEXTURE0, TEXTURE1, Camera::UpdateGFX(), vs_config, and ZERO.

Referenced by GameStarSystem::Draw().

432 {
433  static bool stars_dont_move = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "stars_dont_move", "false" ) );
434  if (stars_dont_move) return;
435  const QVector cp( _Universe->AccessCamera()->GetPosition() );
436  UpdatePosition( cp );
437  //GFXLightContextAmbient(GFXColor(0,0,0,1));
438  GFXColor( 1, 1, 1, 1 );
441  GFXDisable( TEXTURE0 );
442  GFXDisable( TEXTURE1 );
443  GFXEnable( DEPTHTEST );
444  static bool near_stars_alpha =
445  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "near_stars_alpha", "false" ) );
446  static bool near_stars_alpha_blend =
447  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "near_stars_alpha_blend", "false" ) );
448  static float AlphaTestingCutoff =
449  XMLSupport::parse_float( vs_config->getVariable( "graphics", "stars_alpha_test_cutoff", ".2" ) );
450  if (near_stars_alpha) {
451  GFXAlphaTest( GREATER, AlphaTestingCutoff );
452  if (!near_stars_alpha_blend)
453  GFXBlendMode( ONE, ZERO );
454  else
457  } else {
458  if (blend)
459  GFXBlendMode( ONE, ONE );
460  else
461  GFXBlendMode( ONE, ZERO );
462  }
463  int ligh;
464  GFXSelectMaterial( 0 );
465  if (fade) {
466  static float star_spread_attenuation =
467  XMLSupport::parse_float( vs_config->getVariable( "graphics", "star_spread_attenuation", ".2" ) );
469  GFXLight fadeLight( true, GFXColor( cp.i, cp.j, cp.k ),
470  GFXColor( 0, 0, 0, 1 ),
471  GFXColor( 0, 0, 0, 1 ),
472  GFXColor( 1, 1, 1, 1 ),
473  GFXColor( .01, 0, 1/(star_spread_attenuation*star_spread_attenuation*spread*spread) ) );
474  GFXCreateLight( ligh, fadeLight, true );
475  GFXEnable( LIGHTING );
476  } else {
477  GFXDisable( LIGHTING );
478  }
480  int LC = 0, LN = vlist->NumTextures();
481  for (LC = 0; LC < LN; ++LC) {
482  bool stretch = vlist->BeginDrawState( _Universe->AccessCamera()->GetR().Scale(
483  -spread ).Cast(), _Universe->AccessCamera()->GetVelocity(),
484  _Universe->AccessCamera()->GetAngularVelocity(), false, false, LC );
485  int i;
486  for (i = 0; i < STARnumvlist; i++) {
487  if (i >= 1)
488  GFXTranslateModel( pos[i]-pos[i-1] );
489  else
490  GFXTranslateModel( pos[i] );
491  vlist->Draw( stretch, LC );
492  }
493  GFXTranslateModel( -pos[i-1] );
494  vlist->EndDrawState( stretch, LC );
495  }
496  if (near_stars_alpha)
497  GFXAlphaTest( ALWAYS, 0 );
498  else
500  GFXBlendMode( ONE, ZERO );
502 
503  GFXEnable( TEXTURE0 );
504  GFXEnable( TEXTURE1 );
505  if (fade) {
506  GFXDeleteLight( ligh );
508  }
510 }
void Stars::SetBlend ( bool  blendit,
bool  fadeit 
)

Definition at line 425 of file star.cpp.

426 {
427  blend = true; //blendit;
428  fade = true; //fadeit;
429 }

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