-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcube.h~
120 lines (100 loc) · 3.15 KB
/
cube.h~
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
/*
cube.h
Copyright 2007 Sebastien Delestaing
This file is part of "the_cube".
"the_cube" 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 3 of the License, or
(at your option) any later version.
"the_cube" 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CUBE_H_
#define _CUBE_H_
#include "common.h"
// define serialized cube
#define MAX_NB_FACES 6
#define MAX_NB_STRUCTS 30
typedef enum
{
SPIN_NONE,
SPIN_CCW,
SPIN_CW
}SPIN_T;
typedef enum
{
CF_TOP,
CF_BOTTOM,
CF_LEFT,
CF_RIGHT,
CF_FRONT,
CF_BACK,
// misc
CF_SLICEX,
CF_SLICEY,
CF_SLICEZ,
CF_NONE
}FACE_T;
typedef struct s_face
{
TCNPVertex vertices[4]; // actual geometry of the face, textured
unsigned char *texture; // texture buffer (ie. face color)
FACE_T type; // type is only used for cube resolution
}face_t;
typedef struct s_structure
{
CNPVertex vertices[4]; // actual geometry of the structure, non textured
}structure_t;
typedef struct s_piece
{
face_t *faces; // textured faces (up to 3)
int nb_faces; // number of faces
structure_t *structs; // piece structure, non textured
int nb_structs; // number of structs
ScePspSVector3 position; // Position of the piece in the cube
}piece_t;
typedef struct s_cube
{
piece_t pieces[27]; // cube geometry
}cube_t;
typedef struct s_serialized_face
{
TCNPVertex vertices[4]; // actual geometry of the face, textured
FACE_T type; // type is only used for cube resolution
}serialized_face_t;
typedef struct s_serialized_structure
{
CNPVertex vertices[4]; // actual geometry of the structure, non textured
}serialized_structure_t;
typedef struct s_serialized_piece
{
int nb_faces; // number of faces
int nb_structs; // number of structs
ScePspSVector3 position; // Position of the piece in the cube
serialized_face_t faces[MAX_NB_FACES]; // textured faces (up to 3)
serialized_structure_t structs[MAX_NB_STRUCTS]; // piece structure, non textured
}serialized_piece_t;
typedef struct s_serialized_cube
{
serialized_piece_t pieces[27];
}serialized_cube_t;
void cubeInit (void);
void cubeRender (void);
int cubeRotate (void);
void cubeApplySpin (FACE_T, SPIN_T);
void cubeUpdate (void);
void cubeSelectFace (FACE_T);
int cubeSpinFace (FACE_T, SPIN_T);
int cubeIsRotating (void);
int cubeIsSpinning (void);
int cubeIsSolved (void);
int cubeSaveToFile (char *);
void cubeDeserialize (serialized_cube_t *);
void cubeSerialize (serialized_cube_t *);
void cubeSetSpinSpeed (float);
void cubeDispose (void);
#endif //#ifndef _CUBE_H_