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
vsbox.cpp
Go to the documentation of this file.
1 #include "vsbox.h"
2 #include "xml_support.h"
3 
4 /*
5  * inline ostream &operator<<(ostrstream os, const Vector &obj) {
6  * return os << "(" << obj.i << "," << obj.j << "," << obj.k << ")";
7  * }
8  */
9 string tostring( const Vector &v )
10 {
11  return std::string( "(" )+XMLSupport::tostring( v.i )+", "+XMLSupport::tostring( v.j )+", "+XMLSupport::tostring( v.k )+")";
12 }
13 
14 Box::Box( const Vector &corner1, const Vector &corner2 ) : corner_min( corner1 )
15  , corner_max( corner2 )
16 {
17  InitUnit();
18  draw_sequence = 3;
20  blendSrc = ONE;
21  blendDst = ONE;
22  Box *oldmesh;
23  string hash_key = string( "@@Box" )+"#"+tostring( corner1 )+"#"+tostring( corner2 );
24  //cerr << "hashkey: " << hash_key << endl;
25  if ( 0 != ( oldmesh = (Box*) meshHashTable.Get( hash_key ) ) ) {
26  *this = *oldmesh;
27  oldmesh->refcount++;
28  orig = oldmesh;
29  return;
30  }
31  int a = 0;
32  GFXVertex *vertices = new GFXVertex[18];
33 
34 #define VERTEX( ax, ay, az ) \
35  do {vertices[a].x = ax; \
36  vertices[a].y = ay; \
37  vertices[a].z = az; \
38  vertices[a].i = ax; \
39  vertices[a].j = ay; \
40  vertices[a].k = az; \
41  vertices[a].s = 0; \
42  vertices[a].t = 0; \
43  a++; \
44  } \
45  while (0)
46 
51 
56 
57  a = 8;
58 
63 
66 
69 
72 
73  int offsets[2];
74  offsets[0] = 8;
75  offsets[1] = 10;
76  enum POLYTYPE polys[2];
77  polys[0] = GFXQUAD;
78  polys[1] = GFXQUADSTRIP;
79  vlist = new GFXVertexList( polys, 18, vertices, 2, offsets );
80  //quadstrips[0] = new GFXVertexList(GFXQUADSTRIP,10,vertices);
81  delete[] vertices;
82 
83  meshHashTable.Put( hash_key, this );
84  orig = this;
85  refcount++;
86  draw_queue = new vector< MeshDrawContext >[NUM_ZBUF_SEQ+1];
87 #undef VERTEX
88 }
89 
91 {
92  if ( !draw_queue[0].size() ) return;
94  GFXColor( 0.0, .90, .3, .4 );
100  //GFXBlendMode(ONE, ONE);
101  while ( draw_queue[0].size() ) {
102  GFXLoadMatrixModel( draw_queue[0].back().mat );
103  draw_queue[0].pop_back();
104 
105  GFXBegin( GFXQUAD );
106  GFXColor4f( 0.0, 1.0, 0.0, 0.2 );
107 
112 
113  GFXColor4f( 0.0, 1.0, 0.0, 0.2 );
118 
119  GFXColor4f( 0.0, .70, 0.0, 0.2 );
120 
125 
126  GFXColor4f( 0.0, .70, 0.0, 0.2 );
131 
132  GFXColor4f( 0.0, .90, .3, 0.2 );
137 
138  GFXColor4f( 0.0, .90, .3, 0.2 );
143  GFXEnd();
144 
145  /*
146  * vlist->Draw();
147  * if(quadstrips!=NULL) {
148  * for(int a=0; a<numQuadstrips; a++)
149  * quadstrips[a]->Draw()
150  * ;
151  * }
152  */
153  }
155 }
156