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

#include <vsbox.h>

Inheritance diagram for Box:
Mesh

Public Member Functions

 Box (const Vector &cornermin, const Vector &cornermax)
 
void ProcessDrawQueue (int whichdrawqueue)
 
- Public Member Functions inherited from Mesh
void initTechnique (const string &technique)
 
TechniquePtr getTechnique () const
 
void setTechnique (TechniquePtr tech)
 
bool LoadExistant (Mesh *mesh)
 Loads a mesh that has been found in the hash table into this mesh (copying original data) More...
 
bool LoadExistant (const string filehash, const Vector &scale, int faction)
 
 Mesh ()
 
 Mesh (const Mesh &m)
 
GFXVertexListgetVertexList () const
 
void setVertexList (GFXVertexList *_vlist)
 
float getFramesPerSecond () const
 
float getCurrentFrame () const
 
void setCurrentFrame (float)
 
int getNumAnimationFrames (const string &which=string()) const
 
int getNumLOD () const
 
int getNumTextureFrames () const
 
float getTextureFramesPerSecond () const
 
double getTextureCumulativeTime () const
 
void setTextureCumulativeTime (double)
 
bool getConvex () const
 
void setConvex (bool b)
 
virtual int MeshType () const
 
BLENDFUNC getBlendSrc () const
 
BLENDFUNC getBlendDst () const
 
void Fork (Mesh *&one, Mesh *&two, float a, float b, float c, float d)
 Forks the mesh across the plane a,b,c,d into two separate meshes...upon which this may be deleted. More...
 
virtual ~Mesh ()
 Destructor... kills orig if refcount of orig becomes zero. More...
 
unsigned int numFX () const
 Gets number of specialFX. More...
 
void EnableSpecialFX ()
 Turns on SpecialFX. More...
 
unsigned int numTextures () const
 
Texturetexture (int i) const
 
void SetBlendMode (BLENDFUNC src, BLENDFUNC dst, bool lodcascade=false)
 
void GetPolys (vector< mesh_polygon > &)
 Gets all polygons in this mesh for collision computation. More...
 
void SetMaterial (const GFXMaterial &mat)
 Sets the material of this mesh to mat (affects original as well) More...
 
const GFXMaterialGetMaterial () const
 
GFXBOOL HasBeenDrawn () const
 If it has already been drawn this frame. More...
 
void UnDraw ()
 so one can query if it has or not been drawn More...
 
Vector const & Position () const
 Returns center of this mesh. More...
 
void Draw (float lod, const Matrix &m=identity_matrix, float toofar=1, int cloak=-1, float nebdist=0, unsigned char damage=0, bool renormalize_normals=false, const MeshFX *mfx=NULL)
 Draws lod pixel wide mesh at Transformation LATER. More...
 
void DrawNow (float lod, bool centered, const Matrix &m=identity_matrix, int cloak=-1, float nebdist=0)
 Draws lod pixels wide, mesh at Transformation NOW. If centered, then will center on camera and disable cull. More...
 
virtual void ProcessDrawQueue (size_t whichpass, int whichdrawqueue, bool zsort, const QVector &sortctr)
 Will draw all undrawn meshes of this type. More...
 
virtual void SelectCullFace (int whichdrawqueue)
 Will draw all undrawn far meshes beyond the range of zbuffer (better be convex). More...
 
virtual void RestoreCullFace (int whichdrawqueue)
 
void forceCullFace (GFXBOOL newValue)
 Sets whether or not this unit should be environment mapped. More...
 
GFXBOOL getCullFaceForcedOn () const
 
GFXBOOL getCullFaceForcedOff () const
 
void setEnvMap (GFXBOOL newValue, bool lodcascade=false)
 
GFXBOOL getEnvMap () const
 
void setLighting (GFXBOOL newValue, bool lodcascade=false)
 
GFXBOOL getLighting () const
 
Vector corner_min ()
 Returns bounding box values. More...
 
Vector corner_max ()
 
BoundingBox * getBoundingBox ()
 Returns a physical boudning box in 3space instead of in current unit space. More...
 
bool queryBoundingBox (const QVector &start, const float err) const
 queries this bounding box with a vector and radius More...
 
bool queryBoundingBox (const QVector &start, const QVector &end, const float err) const
 Queries bounding box with a ray. More...
 
float rSize () const
 returns the radial size of this More...
 
virtual float clipRadialSize () const
 
void UpdateFX (float ttime)
 based on TTL, etc, updates shield effects More...
 
void AddDamageFX (const Vector &LocalPos, const Vector &LocalNorm, const float percentage, const GFXColor &color=GFXColor(1, 1, 1, 1))
 Adds a new damage effect with age damage to the part of the unit. Color specifies the shield oclor. More...
 
void setVirtualBoundingBox (const Vector &mn, const Vector &mx, float rsize)
 

Additional Inherited Members

- Static Public Member Functions inherited from Mesh
static MeshLoadMesh (const char *filename, const Vector &scalex, int faction, class Flightgroup *fg, const std::vector< std::string > &textureOverride=std::vector< std::string >())
 Loading a mesh from an XML file. faction specifies the logos. Orig is for internal (LOD) use only! More...
 
static vector< Mesh * > LoadMeshes (const char *filename, const Vector &scalex, int faction, class Flightgroup *fg, const std::vector< std::string > &textureOverride=std::vector< std::string >())
 
static vector< Mesh * > LoadMeshes (VSFileSystem::VSFile &f, const Vector &scalex, int faction, class Flightgroup *fg, std::string hash_name, const std::vector< std::string > &textureOverride=std::vector< std::string >())
 
static void ProcessZFarMeshes (bool nocamerasetup=false)
 
static void ProcessUndrawnMeshes (bool pushSpecialEffects=false, bool nocamerasetup=false)
 Will draw all undrawn meshes in total If pushSpclFX, the last series of meshes will be drawn with other lighting off. More...
 
- Protected Member Functions inherited from Mesh
void PostProcessLoading (struct MeshXML *xml, const vector< string > &overrideTexture)
 
 Mesh (std::string filename, const Vector &scalex, int faction, class Flightgroup *fg, bool orig=false)
 
void InitUnit ()
 Setting all values to defaults (good for mesh copying and stuff) More...
 
MeshgetLOD (float lod, bool bBypassDamping=true)
 Returing the mesh relevant to "size" pixels LOD of this mesh. More...
 
- Protected Attributes inherited from Mesh
Vector local_pos
 the position of the center of this mesh for collision detection More...
 
int refcount
 The refcount:: how many meshes are referencing the appropriate original. More...
 
Vector mx
 bounding box More...
 
Vector mn
 
float radialSize
 The radial size of this mesh. More...
 
int numlods
 num lods contained in the array of Mesh "orig" More...
 
float framespersecond
 
Meshorig
 
float lodsize
 The size that this LOD (if original) comes into effect. More...
 
Logoforcelogos
 The number of force logos on this mesh (original) More...
 
int numforcelogo
 
Logosquadlogos
 The number of squad logos on this mesh (original) More...
 
int numsquadlogo
 
GFXVertexListvlist
 tri,quad,line, strips, etc More...
 
unsigned int myMatNum
 The number of the appropriate material for this mesh (default 0) More...
 
TechniquePtr technique
 The technique used to render this mesh. More...
 
vector< Texture * > Decal
 The decal relevant to this mesh. More...
 
TexturedetailTexture
 
vector< VectordetailPlanes
 
float polygon_offset
 
char envMapAndLit
 whether this should be environment mapped 0x1 and 0x2 for if it should be lit (ored together) More...
 
GFXBOOL will_be_drawn
 Whether this original will be drawn this frame. More...
 
bool convex
 The blend functions. More...
 
unsigned char alphatest
 
enum BLENDFUNC blendSrc
 
enum BLENDFUNC blendDst
 
vector< MeshDrawContext > * draw_queue
 Support for reorganized rendering. More...
 
int draw_sequence
 How transparent this mesh is (in what order should it be rendered in. More...
 
string hash_name
 The name of this unit. More...
 
vector< MeshFXLocalFX
 The enabled light effects on this mesh. More...
 
- Static Protected Attributes inherited from Mesh
static Hashtable< std::string,
Mesh, MESH_HASTHABLE_SIZE
meshHashTable
 The hash table of all meshes. More...
 
static Hashtable< std::string,
std::vector< int >
, MESH_HASTHABLE_SIZE
animationSequences
 

Detailed Description

Definition at line 6 of file vsbox.h.

Constructor & Destructor Documentation

Box::Box ( const Vector cornermin,
const Vector cornermax 
)

Definition at line 14 of file vsbox.cpp.

References a, Mesh::blendDst, Mesh::blendSrc, Mesh::corner_max(), Mesh::corner_min(), Mesh::draw_queue, Mesh::draw_sequence, Hashtable< KEY, VALUE, SIZ >::Get(), GFXFALSE, GFXQUAD, GFXQUADSTRIP, Mesh::InitUnit(), Mesh::meshHashTable, NUM_ZBUF_SEQ, ONE, Mesh::orig, Hashtable< KEY, VALUE, SIZ >::Put(), Mesh::refcount, Mesh::setEnvMap(), tostring(), VERTEX, and Mesh::vlist.

14  : 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 }

Member Function Documentation

void Box::ProcessDrawQueue ( int  whichdrawqueue)

Definition at line 90 of file vsbox.cpp.

References Mesh::corner_max(), Mesh::corner_min(), CULLFACE, DEPTHWRITE, Mesh::draw_queue, GFXBegin(), GFXBlendMode(), GFXColor4f(), GFXDisable(), GFXEnable(), GFXEnd(), GFXLoadMatrixModel(), GFXQUAD, GFXVertex3f(), INVSRCALPHA, LIGHTING, size, SRCALPHA, TEXTURE0, and TEXTURE1.

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 }

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