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

#include <aux_logo.h>

Public Member Functions

 Logo (int numberlogos, Vector *center, Vector *normal, float *sizes, float *rotations, float offset, Texture *Dec, Vector *Ref)
 
 Logo (const Logo &rval)
 
 ~Logo ()
 
void SetDecal (Texture *decal)
 
void Draw (const Matrix &m)
 

Protected Member Functions

void ProcessDrawQueue ()
 

Protected Attributes

int refcount
 
Logoowner_of_draw_queue
 
vector< DrawContext > * draw_queue
 
bool will_be_drawn
 

Friends

class Mesh
 

Detailed Description

Definition at line 33 of file aux_logo.h.

Constructor & Destructor Documentation

Logo::Logo ( int  numberlogos,
Vector center,
Vector normal,
float sizes,
float rotations,
float  offset,
Texture Dec,
Vector Ref 
)

backwards compatibility shit

Definition at line 34 of file aux_logo.cpp.

References draw_queue, GFXQUAD, i, j, k, q, refcount, Roll(), SetDecal(), Vector, will_be_drawn, and y.

42 {
43  offset = 0;
44  refcount = -1;
45  draw_queue = NULL;
46 
47  numlogos = numberlogos;
48  GFXVertex *vertices = new GFXVertex[numlogos*4];
49  GFXVertex *LogoCorner = vertices;
50  //LogoCorner = new glVertex* [numlogos]; //hope to hell we have enough mem
51  Vector p, q, r, v1, v2, v3, v4; //temps
52  will_be_drawn = false;
53  for (int i = 0; i < numlogos; i++, LogoCorner += 4) {
54  r = normal[i];
55  Normalize( r );
56  Vector translation = r*offset;
57  if (Ref[i].i || Ref[i].j || Ref[i].k) {
58  p = Ref[i];
59  Normalize( p );
60  ScaledCrossProduct( r, p, q );
61  ::Roll( rotation[i], p, q, r );
62  float tsize = size[i]*0.50F;
63  Vector tcenter = center[i]+translation;
64  v4 = p* -tsize-q*tsize+tcenter;
65  v3 = p* -tsize+q*tsize+tcenter;
66  v2 = p*tsize+q*tsize+tcenter;
67  v1 = p*tsize-q*tsize+tcenter;
68  } else {
70  Vector y;
71  if ( (r.i == 1 || r.i == -1) && !r.j && !r.k )
72  y = Vector( 0, 1, 0 );
73  else
74  y = Vector( 1, 0, 0 );
75  ScaledCrossProduct( r, y, p );
76  ScaledCrossProduct( r, p, q );
77  ::Roll( rotation[i], p, q, r );
78  float tsize = size[i]*0.50F;
79  Vector tcenter = center[i]+translation;
80  v1 = q*tsize+tcenter;
81  v2 = p* -tsize+tcenter;
82  v3 = q* -tsize+tcenter;
83  v4 = p*tsize+tcenter;
84  }
85  LogoCorner[0].SetVertex( v1 ).SetNormal( r ).SetTexCoord( 0, 0 );
86  LogoCorner[1].SetVertex( v2 ).SetNormal( r ).SetTexCoord( 0, 1 );
87  LogoCorner[2].SetVertex( v3 ).SetNormal( r ).SetTexCoord( 1, 1 );
88  LogoCorner[3].SetVertex( v4 ).SetNormal( r ).SetTexCoord( 1, 0 );
89  //LogoCorner[4] = LogoCorner[2];
90  //LogoCorner[5] = LogoCorner[1];
91  }
92  vlist = new GFXVertexList( GFXQUAD, 4*numlogos, vertices, 4*numlogos );
93  delete[] vertices;
94  SetDecal( Dec );
95 }
Logo::Logo ( const Logo rval)
inline

Definition at line 56 of file aux_logo.h.

57  {
58  *this = rval;
59  }
Logo::~Logo ( )

Definition at line 176 of file aux_logo.cpp.

References Hashtable< KEY, VALUE, SIZ >::Delete(), draw_queue, Texture::name, owner_of_draw_queue, and refcount.

177 {
178  if (owner_of_draw_queue != this)
179  delete vlist;
180  //if(LogoCorner!=NULL)
181  //delete [] LogoCorner;
182  if (owner_of_draw_queue != NULL) {
183  if (owner_of_draw_queue != this)
185  if (owner_of_draw_queue->refcount == 0 && owner_of_draw_queue != this)
186  delete owner_of_draw_queue;
187  }
188  if (owner_of_draw_queue == this) {
189  assert( refcount == 0 );
190  decalHash.Delete( Decal->name );
191  delete draw_queue;
192  }
193 }

Member Function Documentation

void Logo::Draw ( const Matrix m)

Definition at line 133 of file aux_logo.cpp.

References draw_queue, owner_of_draw_queue, undrawn_logos, and will_be_drawn.

134 {
135  if (!numlogos)
136  return;
137  //Matrix m;
138  //GFXGetMatrix(MODEL, m);
139  draw_queue->push_back( DrawContext( m, vlist ) );
141  undrawn_logos.push_back( owner_of_draw_queue );
143  }
144 }
void Logo::ProcessDrawQueue ( )
protected

Definition at line 146 of file aux_logo.cpp.

References GFXVertexList::BeginDrawState(), c, DEPTHWRITE, GFXVertexList::Draw(), draw_queue, GFXVertexList::EndDrawState(), g_game, VegaConfig::getVariable(), GFXBlendMode(), GFXColor4f(), GFXDisable(), GFXEnable(), GFXFALSE, GFXLoadMatrixModel(), GFXPolygonOffset(), INVSRCALPHA, LIGHTING, GFXVertexList::LoadDrawState(), DrawContext::m, Texture::MakeActive(), XMLSupport::parse_float(), SRCALPHA, TEXTURE0, TEXTURE1, game_data_t::use_logos, DrawContext::vlist, and vs_config.

Referenced by Mesh::ProcessUndrawnMeshes().

147 {
148  if ( !g_game.use_logos || draw_queue->empty() )
149  return;
150  static float offs = XMLSupport::parse_float( vs_config->getVariable( "graphics", "LogoOffset", "-1" ) );
151  static float scl = XMLSupport::parse_float( vs_config->getVariable( "graphics", "LogoOffsetScale", "-4.0" ) );
152 
153  GFXEnable( TEXTURE0 );
154  GFXEnable( TEXTURE1 );
155  Decal->MakeActive();
157  GFXDisable( LIGHTING );
158  GFXColor4f( 1, 1, 1, 1 );
159  GFXPolygonOffset( offs, scl );
161  //GFXBlendMode(ONE,ZERO);
162  DrawContext c = draw_queue->back();
163  c.vlist->LoadDrawState();
164  while ( draw_queue->size() ) {
165  c = draw_queue->back();
166  draw_queue->pop_back();
167  GFXLoadMatrixModel( c.m );
169  c.vlist->Draw();
171  }
173  GFXPolygonOffset( 0, 0 );
174 }
void Logo::SetDecal ( Texture decal)

Definition at line 97 of file aux_logo.cpp.

References draw_queue, Hashtable< KEY, VALUE, SIZ >::Get(), Texture::name, owner_of_draw_queue, Hashtable< KEY, VALUE, SIZ >::Put(), and refcount.

Referenced by Logo().

98 {
99  Decal = decal;
100  //Check which draw_queue to use:
101  Logo *l;
102  if ( ( l = decalHash.Get( decal->name ) ) != NULL ) {
103  draw_queue = l->draw_queue;
105  l->refcount++;
106  } else {
107  l = new Logo( *this ); //(Logo*)malloc (sizeof (Logo));
108  //memcpy (l,this,sizeof(Logo));
109  decalHash.Put( decal->name, l );
110  draw_queue = l->draw_queue = new vector< DrawContext > ();
112  l->refcount = 1;
113  }
114 }

Friends And Related Function Documentation

friend class Mesh
friend

Definition at line 42 of file aux_logo.h.

Member Data Documentation

vector< DrawContext >* Logo::draw_queue
protected

Definition at line 45 of file aux_logo.h.

Referenced by Draw(), Logo(), ProcessDrawQueue(), SetDecal(), and ~Logo().

Logo* Logo::owner_of_draw_queue
protected

Definition at line 44 of file aux_logo.h.

Referenced by Draw(), SetDecal(), and ~Logo().

int Logo::refcount
protected

Definition at line 43 of file aux_logo.h.

Referenced by Logo(), SetDecal(), and ~Logo().

bool Logo::will_be_drawn
protected

Definition at line 46 of file aux_logo.h.

Referenced by Draw(), Logo(), and Mesh::ProcessUndrawnMeshes().


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