home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 July & August
/
PCWorld_2006-07-08_cd.bin
/
temacd
/
planearcade
/
planearcade.exe
/
Tank3.bmp
/
q3bsp.h
< prev
next >
Wrap
C/C++ Source or Header
|
2004-01-21
|
5KB
|
190 lines
///////////////////////////////////////////////
//original zdrojak: Jan Koci (koci.opengl.cz)//
//upravil: Peter AdamΦφk //
///////////////////////////////////////////////
#ifndef _Q3BSP_H_
#define _Q3BSP_H_
#include "q3bitset.h"
#include "q3enums.h"
#include "q3structs.h"
//---------------------------------------------------
//CUSTOM VERTEX QBSP
//---------------------------------------------------
struct CUSTOMVERTEXQBSP
{
D3DXVECTOR3 pos; // pozicia
DWORD color; // farba
FLOAT tu, tv; // texturove suradnice
FLOAT tu2, tv2; // suradnice lightmapy
};
#define D3DFVF_CUSTOMVERTEXQBSP (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX2)
//------------------------------------------------------------------
// Name: QBSP class
// Desc: Trieda Q3 BSP
//------------------------------------------------------------------
class QBSP
{
private:
LPDIRECT3DVERTEXBUFFER9 g_pVB ; //vertex buffer
LPDIRECT3DTEXTURE9 *Texture ; //texturovy zasobnik
LPDIRECT3DTEXTURE9 *LightMap ; //lightmapy
public:
//konÜtruktor deÜtruktor
QBSP();
~QBSP();
// The number of verts in the model
// PoΦet vrchol∙ scΘny
int m_iNumOfVerts;
// The number of faces in the model
// PoΦet ploÜek scΘny
int m_iNumOfFaces;
// The number of texture maps
// PoΦet textur
int m_iNumOfTextures;
// The number of light maps
// PoΦet lightmap textur
int m_iNumOfLightmaps;
// The number of nodes
// PoΦet uzl∙
int m_iNumOfNodes;
// The number of leafs
// PoΦe list∙
int m_iNumOfLeafs;
// The number of leaf faces
// PoΦet ploÜek v listu
int m_iNumOfLeafFaces;
// The number of planes
// PoΦet d∞licφch ploch
int m_iNumOfPlanes;
// This will store how many faces are drawn and are seen by the camera
// Kontrolnφ prom∞nnß, kterß uklßdß, kolik ploÜek se renderuje
int m_iVisibleFaces;
// PoΦet koliznφch srß₧ek v listu
int m_iNumOfLeafBrushes;
// PoΦet koliznφch srß₧ek
int m_iNumOfBrushes;
// PoΦet koliznφch ploch srß₧ek
int m_iNumOfBrushSides;
// Kontrolnφ prom∞nnß, kterß uklßdß, kolik kolizφ se provßdφ
int m_iVisibleBrushes;
int m_pppiBoundingBox[6][4][3]; // [6]poΦet stran, [4]poΦet vrchol∙ strany, [3]xyz pozice vrcholu
int m_iNumSkyTex; // PoΦet textur nebe
int m_piSkyTex[10]; // Id hodnoty textur nebe
int m_iNumOfShaders; // PoΦet efekt∙
int *m_piShaderBrushIndex; // Index efektu, pot°ebnß pro zamezenφ detekce kolize nap°. z mlhou
int m_iNumOfModels; // PoΦet model∙
int *m_piModelBrushIndex; // Index modelu, pot°ebnß pro zamezenφ detekce kolize
int m_iNumOfMeshVertices; // PoΦet vrchol∙ meÜφ
int *m_piMeshVertices; // Pole vrchol∙ meÜφ
// The object's vertices
// Vrcholy scΘny
TBspVertex *m_ptBspVertex;
// The faces information of the object
// PloÜky scΘny
TBspFace *m_ptBspFace;
// The nodes information of the BSP scene
// Uzly BSP scΘny
TBspNode *m_ptBspNode;
// The leafs information of the BSP scene
// Listy BSP scΘny
TBspLeaf *m_ptBspLeaf;
// The splitter planes of the BSP scene
// D∞licφ plochy BSP scΘny
TBspPlane *m_ptBspPlane;
// The Brushes
// Koliznφ srß₧ky
TBspBrush *m_ptBspBrush;
// The splitter planes of the Brush side
// D∞licφ plochy koliznφch srß₧ek
TBspBrushSides *m_ptBspBrushSides;
// The leaf faces of the BSP scene
// PloÜky list∙ BSP scΘny
int *m_piLeafFaces;
// The clusters of the BSP scene
// Data pro detekci viditelnosti portßl∙
TBspVisData m_tBspVisData;
// The brushes
// Koliznφ srß₧ky listu
int *m_piLeafBrushes;
TBspShader *m_ptBspShader; // Efekty
TBspModel *m_ptBspModel; // Modely
// The bitset for the faces that have/haven't been drawn
// Prom∞nnß pro detekci, zda mß b²t ploÜka vykreslena Φi ne
K_CBitset m_BitsetFacesDrawn;
////////////////////
//POMOCNE FUNKCIE //
////////////////////
void FillVertexBuffer();
void RenderFace(int i_face_index);
int FindLeaf(VECTOR3D CamPos);
bool CheckBrushCollision(int i_leaf_index);
int IsClusterVisible(int i_camera_in_cluster, int i_test_cluster);
////////////////////
// FUNKCIE //
////////////////////
bool LoadBSP(const char *pc_filename,float Gamma);
void RenderBSP();
bool ColliseBSP(VECTOR3D Point);
};
#endif //_Q3BSP_H_