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
|
/*
File: PolyCube.h
Description: PolyCube 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 "Types.h"
#ifndef POLYCUBEH
#define POLYCUBEH
class PolyCube
{
public:
PolyCube();
~PolyCube();
// Add a cube to the polycube
void AddCube(int x,int y,int z);
// Set polycube info
void SetInfo(int highScore,int lowScore,BOOL flat,BOOL basic);
// Create polycube device objects
int Create(float cubeSide,VERTEX origin,int ghost,float wEdge = 0.0f);
// Render the polycube
void Render(BOOL redMode);
// Release device objects
void InvalidateDeviceObjects();
// Return the rotation center
VERTEX GetRCenter();
BLOCKITEM GetICenter();
// Copy the polycube cube coordinates
void CopyCube(BLOCKITEM *c,int *nb);
// Get number of cube
int GetNbCube();
// Get High score
int GetHighScore();
// Get Low score
int GetLowScore();
// Check if the polycube belongs to the set
BOOL IsInSet(int set);
// Get dimension
int GetWidth();
int GetHeight();
int GetDepth();
int GetMaxDim();
//Initialise rotation center
void InitRotationCenter();
// Orientation stuff (Used by AI player)
void AddOrientation(int r0,int r1,int r2);
ORIENTATION *GetOrientationAt(int idx);
int GetNbOrientation();
private:
int hScore; // score (dropped from top position)
int lScore; // score (non dropped)
BOOL isFlat; // Into the flat set
BOOL isBasic; // Into the basic set
BOOL hasGhost; // PolyCube transparent side
BOOL hasBigEdge; // PolyCube cylinder edge
float cubeSide; // Cube side length
VERTEX origin; // Origin
VERTEX center; // Rotation center (space coordinates)
BLOCKITEM iCenter; // Rotation center (cube coordinates)
// Cube coordinates
BLOCKITEM cubes[MAX_CUBE];
int nbCube;
// Edge list (avoid edge duplication)
EDGE *edges;
int nbEdge;
// Possible orientation array
ORIENTATION *allRot;
int nbOrientation;
// Big edge corner
void GetEdgesAtCorner(int x,int y,int z,int *nb,int *direction);
BOOL IsPermut(int d1,int d2,int d3,int *dir);
BOOL GetCornerAt(int x,int y,int z,VERTEX *o);
// Graphics stuff
GLuint lineList;
GLuint ghostList;
GLuint bigEdgeList;
GLMATERIAL whiteMaterial;
GLMATERIAL ghostMaterial;
GLMATERIAL redMaterial;
GLMATERIAL grayMaterial;
int CreateGhost(int value);
BOOL IsEdgeVisible(int cubeIdx,int edge);
BOOL IsFaceVisible(int cubeIdx,int face);
BOOL FindCube(int x,int y,int z);
void gV(int cubeIdx,int x,int y,int z,float nx,float ny,float nz);
int CreateLineEdge();
int CreateCylinderEdges(float wEdge);
BOOL EdgeEqual(EDGE e1,EDGE e2);
BOOL EdgeExist(EDGE e);
};
#endif /* POLYCUBEH */
|