File: PyraminxGLP.h

package info (click to toggle)
xpuzzles 8.9.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 18,900 kB
  • sloc: ansic: 153,737; makefile: 6,780; sh: 937; perl: 80
file content (141 lines) | stat: -rw-r--r-- 4,373 bytes parent folder | download | duplicates (2)
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
133
134
135
136
137
138
139
140
141
/*
 * @(#)PyraminxGLP.h
 *
 * Copyright 2023 - 2024  David A. Bagley, bagleyd AT verizon.net
 *
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and
 * its documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear in
 * supporting documentation, and that the name of the author not be
 * used in advertising or publicity pertaining to distribution of the
 * software without specific, written prior permission.
 *
 * 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.
 */

/* Private header file for PyraminxGL */

#ifndef _PyraminxGLP_h
#define _PyraminxGLP_h

#include "PyraminxGL.h"
#include <GL/gl.h>
#include <GL/glu.h>
#ifndef WINVER
#include <GL/glx.h>

/* This gets around C's inability to do inheritance */
typedef struct _PyraminxGLClassPart {
	int ignore;
} PyraminxGLClassPart;

typedef struct _PyraminxGLClassRec {
	CoreClassPart coreClass;
	PyraminxClassPart pyraminxClass;
	PyraminxGLClassPart pyraminxGLClass;
} PyraminxGLClassRec;

extern PyraminxGLClassRec pyraminxGLClassRec;
#endif

#define MAX_SIZE w->pyraminx.size
#define LAST (w->pyraminx.size-1)
#define FIRST 0
#define SCALE (float) (2.1/MAX_SIZE)

#define TOP_FACE 0
#define RIGHT_FACE 1
#define LEFT_FACE 2
#define BOTTOM_FACE 3

#define BORDER_FACE (MAX_FACES)
#define NO_FACE (MAX_FACES + 1)
#define NO_POSITION (IGNORE_DIR)
#define NO_ROTATION (2*MAX_ORIENT)
#define NO_FE (NO_ROTATION+1) /* 4 faces but 6 edges */
#define NO_DEPTH (IGNORE_DIR)
#define NO_STYLE (IGNORE_DIR)
#define REV(a) (MAX_SIZE-a-1)
#define MAX_TURN_INC 10

#define FACET_LENGTH (float) 0.5
#define SELECT_LENGTH2 (float) 0.5
#define STICKER_LENGTH2 (float) 0.485

#define FACET_TETRA (FACET_LENGTH-(float) 0.02)
#define STICKER_TETRA2 (FACET_TETRA-(float) 0.04)
#define STICKER_TETRA3 (STICKER_TETRA2-(float) 0.04)
#define SELECT_TETRA2 (STICKER_TETRA2-(float) 0.04)
#define SELECT_TETRA3 (STICKER_TETRA3-(float) 0.06)

#define BAR_WIDTH (FACET_LENGTH*(float) 0.05)
#define GAP_WIDTH (FACET_LENGTH*(float) 0.15)
#define GAP_WIDTH2 (FACET_LENGTH*(float) 0.2)

#define FACET_OCTA (FACET_LENGTH*(float) 1.90)
#define STICKER_OCTA2 (FACET_LENGTH*(float) 1.85)
#define SELECT_OCTA2 (FACET_LENGTH*(float) 1.81)

#define STICKER_LONG (FACET_TETRA-(float) 0.05)
#define STICKER_SHORT (STICKER_LONG-(float) 0.05)
#define STICKER_HALF ((STICKER_SHORT)*(float) 0.5)
#define STICKER_DEPTH (FACET_LENGTH+(float) 0.01)
#define SELECT_LONG (float) (4.5*FACET_TETRA/5.0-0.05)
#define SELECT_SHORT (float) (3.5*STICKER_LONG/5.0-0.05)
#define CUT (float) 0.04
#define CUT2 (float) 0.02
#define CUT_DEPTH (STICKER_DEPTH+(float) 0.001)
#define SELECT_DEPTH (STICKER_DEPTH+(float) 0.002)

typedef struct _PyraminxMove {
	int         face, direction;
	int         position;
	int         style;
	Boolean     control;
} PyraminxMove;

typedef struct _PyraminxSlice {
	int         fe, rotation; /* face or edge */
	int         depth;
} PyraminxSlice;

typedef struct _PyraminxGLPart {
	double      angleStep;
	double      rotateStep;
	int         numTurnInc;
	Position    faceDiagonal;
	Position    cubeDiagonalx, cubeDiagonaly, cubeDiagonalz;
	/*Point       cubeSizex, cubeSizey, cubeSizez;*/
	Point       faceSize, viewSize;
	Point       viewMiddle;
	PyraminxMove   movement;
	int         step;
} PyraminxGLPart;

typedef struct _PyraminxGLRec {
	CorePart    core;
	PyraminxPart   pyraminx;
	PyraminxGLPart pyraminxGL;
} PyraminxGLRec;

extern Boolean selectPiecesGL(PyraminxGLWidget w, int x, int y,
	int *face, int *position);
extern void narrowSelectionGL(PyraminxGLWidget w, int style,
	int *face, int *position, int *direction);
/*extern void drawFrameGL(PyraminxGLWidget w, Boolean focus);*/
extern void drawAllPiecesGL(PyraminxGLWidget w);
/*extern void moveAllPiecesGL(PyraminxGLWidget w, int face, int direction,
	int style, int fast);*/
extern void movePiecesGL(PyraminxGLWidget w, int face, int position,
	int direction, int style, Boolean control, int fast);
#ifdef WINVER
extern void resizePuzzleGL(PyraminxGLWidget w);
extern void exposePuzzleGL(PyraminxGLWidget w);
#endif

#endif /* _PyraminxGLP_h */