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

#include <star.h>

Inheritance diagram for PointStarVlist:
StarVlist

Public Member Functions

 PointStarVlist (int num, float spread, const std::string &our_system_name)
 
 ~PointStarVlist ()
 
bool BeginDrawState (const QVector &center, const Vector &vel, const Vector &angular_vel, bool rotate, bool yawpitch, int whichTexture)
 
void Draw (bool, int whichTexture)
 
void EndDrawState (bool, int whichTexture)
 
- Public Member Functions inherited from StarVlist
 StarVlist (float spread)
 
void UpdateGraphics ()
 
virtual ~StarVlist ()
 
virtual int NumTextures ()
 
void DrawAll (const QVector &center, const Vector &vel, const Vector &ang_vel, bool rot, bool yawpitch)
 

Additional Inherited Members

- Protected Attributes inherited from StarVlist
float spread
 
Vector newcamr
 
Vector newcamq
 
Vector camr
 
Vector camq
 
double lasttime
 

Detailed Description

Definition at line 48 of file star.h.

Constructor & Destructor Documentation

PointStarVlist::PointStarVlist ( int  num,
float  spread,
const std::string &  our_system_name 
)

Definition at line 292 of file star.cpp.

References AllocVerticesForSystem(), GFXLINE, GFXPOINT, i, and j.

292  : StarVlist( spread )
293 {
294  smoothstreak = 0;
295  //static bool StarStreaks=XMLSupport::parse_bool(vs_config->getVariable("graphics","star_streaks","false"));
296  GFXColorVertex *tmpvertex = AllocVerticesForSystem( sysnam, this->spread, &num, 2 );
297  //if(StarStreaks) {
298  vlist = new GFXVertexList( GFXLINE, num, tmpvertex, num, true, 0 );
299  //}else {
300  for (int i = 0, j = 1; i < num/2; ++i, j += 2)
301  tmpvertex[i] = tmpvertex[j];
302  nonstretchvlist = new GFXVertexList( GFXPOINT, num/2, tmpvertex, num/2, false, 0 );
303  //}
304  delete[] tmpvertex;
305 }
PointStarVlist::~PointStarVlist ( )

Definition at line 405 of file star.cpp.

406 {
407  delete vlist;
408  delete nonstretchvlist;
409 }

Member Function Documentation

bool PointStarVlist::BeginDrawState ( const QVector center,
const Vector vel,
const Vector angular_vel,
bool  rotate,
bool  yawpitch,
int  whichTexture 
)
virtual

Reimplemented from StarVlist.

Definition at line 319 of file star.cpp.

References AMBIENT, GFXVertexList::BeginDrawState(), GFXVertexList::BeginMutate(), GFXVertexList::VDAT::colors, DIFFUSE, e, GFXVertexList::EndMutate(), GetElapsedTime(), GFXVertexList::GetNumVertices(), VegaConfig::getVariable(), GFXColorMaterial(), i, j, GFXVertexList::LoadDrawState(), XMLSupport::parse_bool(), XMLSupport::parse_float(), RotateAxisAngle(), speed, Transform(), StarVlist::UpdateGraphics(), v, Vector, vs_config, x, GFXColorVertex::x, y, GFXColorVertex::y, z, and GFXColorVertex::z.

325 {
326  UpdateGraphics();
327  static bool StarStreaks = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "star_streaks", "false" ) );
329  bool ret = false;
330  if (StarStreaks) {
331  Matrix rollMatrix;
332  static float velstreakscale =
333  XMLSupport::parse_float( vs_config->getVariable( "graphics", "velocity_star_streak_scale", "5" ) );
334  static float minstreak = XMLSupport::parse_float( vs_config->getVariable( "graphics", "velocity_star_streak_min", "1" ) );
335  static float fov_smoothing =
336  XMLSupport::parse_float( vs_config->getVariable( "graphics", "warp.fovlink.smoothing", ".4" ) );
337  float fov_smoot = pow( double(fov_smoothing), GetElapsedTime() );
338  Vector vel( -velocity*velstreakscale );
339  float speed = vel.Magnitude();
340  if ( (smoothstreak >= minstreak || vel.MagnitudeSquared() >= minstreak*minstreak) && (speed > 1.0e-7) ) {
341  ret = true;
342  vel *= 1./speed;
343  speed = fov_smoot*speed+(1-fov_smoot)*smoothstreak;
344  if (speed < minstreak) speed = minstreak;
345  static float streakcap =
346  XMLSupport::parse_float( vs_config->getVariable( "graphics", "velocity_star_streak_max", "100" ) );
347  if (speed > streakcap)
348  speed = streakcap;
349  vel = vel*speed;
350  smoothstreak = speed;
351  GFXColorVertex *v = vlist->BeginMutate( 0 )->colors;
352  int numvertices = vlist->GetNumVertices();
353 
354  static float torquestreakscale =
355  XMLSupport::parse_float( vs_config->getVariable( "graphics", "torque_star_streak_scale", "1" ) );
356  for (int j = 0; j < numvertices-1; j += 2) {
357  int i = j;
358 //if (SlowStarStreaks)
359 //i=((rand()%numvertices)/2)*2;
360  Vector vpoint( v[i+1].x, v[i+1].y, v[i+1].z );
361  Vector recenter = ( vpoint-center.Cast() );
362  if (roll) {
363  RotateAxisAngle( rollMatrix, torque, torque.Magnitude()*torquestreakscale*.003 );
364  vpoint = Transform( rollMatrix, recenter )+center.Cast();
365  }
366  v[i].x = vpoint.i-vel.i;
367  v[i].y = vpoint.j-vel.j;
368  v[i].z = vpoint.k-vel.k;
369 //static float NumSlowStarStreaks=XMLSupport::parse_float(vs_config->getVariable("graphics","num_star_streaks",".05"));
370 //if (SlowStarStreaks&&j<NumSlowStarStreaks*numvertices)
371 //break;
372  }
373  vlist->EndMutate();
374  }
375  }
376  if (ret) {
377  vlist->LoadDrawState();
378  vlist->BeginDrawState();
379  } else {
380  nonstretchvlist->LoadDrawState();
381  nonstretchvlist->BeginDrawState();
382  }
383  return ret;
384 }
void PointStarVlist::Draw ( bool  stretch,
int  whichTexture 
)
virtual

Reimplemented from StarVlist.

Definition at line 386 of file star.cpp.

References GFXVertexList::Draw(), GFXVertexList::GetNumVertices(), and GFXPOINT.

387 {
388  if (stretch) {
389  vlist->Draw();
390  vlist->Draw( GFXPOINT, vlist->GetNumVertices() );
391  } else {
392  nonstretchvlist->Draw();
393  }
394 }
void PointStarVlist::EndDrawState ( bool  stretch,
int  whichTexture 
)
virtual

Reimplemented from StarVlist.

Definition at line 396 of file star.cpp.

References GFXVertexList::EndDrawState(), and GFXColorMaterial().

397 {
398  if (stretch)
399  vlist->EndDrawState();
400  else
401  nonstretchvlist->EndDrawState();
402  GFXColorMaterial( 0 );
403 }

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