1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
/*
File: Pit.h
Description: Pit management
Program: BlockOut
Author: Jean-Luc PONS
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "PolyCube.h"
#define NBTCUBE 16
class Pit
{
public:
Pit();
// Initialise pit dimension
void SetDimension(int gWidth,int gHeight,int gDepth);
// Get dimension
int GetWidth();
int GetHeight();
int GetDepth();
// Create Pit device objects
int Create(int scrWidth,int scrHeight,int style);
// Return the cubeSide (3D space)
float GetCubeSide();
// Return the Origin (3D space)
VERTEX GetOrigin();
// Render the pit
void Render(BOOL renderCube,BOOL zBuffer);
// Render the pit level
void RenderLevel();
// Release device objects
void InvalidateDeviceObjects();
// Clear the pit
void Clear();
// Get the value at the specified coordinates
// Return 1 when (x,y,z) if out of the pit
int GetValue(int x,int y,int z);
// Get the value at the specified coordinates
// Return 0 when (x,y,z) if out of the pit
int GetValue2(int x,int y,int z);
// Add a value at the specified coordinates
void AddCube(int x,int y,int z);
// Get "out of bounds" values
void GetOutOfBounds(int x,int y,int z,int *ox,int *oy,int *oz);
// Remove full line
int RemoveLines();
// Return true if the pit is empty
BOOL IsEmpty();
private:
int CreateGrid();
int CreateBack();
int CreateFillingCube();
int CreatePitLevel(int scrWidth,int scrHeight);
GLuint CreateTexturedFillingCube(int i);
void SetValue(int x,int y,int z,int value);
void ChooseMapping(int i,float *sx,float *sy,float *ex,float *ey);
GLMATERIAL *GetMaterial(int level);
void RenderCube(int x,int y,int z);
void RenderEdge(int x,int y,int z,int edge);
void InitOrderMatrix();
BOOL IsVisible(int x,int y,int z);
BOOL IsVisible2(int x,int y,int z);
BOOL IsLineFull(int z);
BOOL IsLineEmpty(int z);
void RemoveLine(int idx);
void DrawPitLevelCubes(int x,int y,int w,int h,GLMATERIAL *mat);
void SetPix(int x,int y,GLMATERIAL *mat);
BOOL inited;
GLuint gridList;
GLuint cubeList;
GLuint cubeTList[NBTCUBE];
GLuint lcubeList[12];
GLuint backList;
GLuint sideList;
GLuint hGridList;
int pitLevelX;
int pitLevelY;
int pitLevelW;
int pitLevelH;
GLfloat *pitLevelSurf;
int width;
int height;
int depth;
int mSize;
int tcubeIdx;
float cubeSide;
int style;
GLMATERIAL gridMaterial;
GLMATERIAL blackMaterial;
GLMATERIAL darkMaterial;
GLMATERIAL backMaterial;
GLMATERIAL backTexMaterial;
GLMATERIAL whiteMaterial;
VERTEX origin;
int *matrix;
BLOCKITEM *orderMatrix;
float fWidth;
float fHeight;
float fDepth;
GLuint backTexture;
GLuint cubeTexture;
};
|