Debian Codegraph @

apps/demos/drop/TsPiece.c++

raw
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 /*
38 _______________________________________________________________________
39 ______________ S I L I C O N G R A P H I C S I N C . ____________
40 |
41 | $Revision: 1.1.1.1 $
42 |
43 | Classes : TsPiece
44 |
45 | Author : Dave Immel
46 |
47 ______________ S I L I C O N G R A P H I C S I N C . ____________
48 _______________________________________________________________________
49 */
50
51 //--------------------------- Include ----------------------------------
52 #include <cstdio>
53 #include <Inventor/nodes/SoTransform.h>
54 #include "TsPiece.h"
55
56 ////////////////////////////////////////////////////////////////////////
57 //
58 // Description:
59 // Constructor for the TsPiece.
60 //
61 // Use: public
62
63 TsPiece::TsPiece()
64
65 //
66 ////////////////////////////////////////////////////////////////////////
67 {
68 orientation = 0;
69 numBlocks = 0;
70 }
71
72
73 ////////////////////////////////////////////////////////////////////////
74 //
75 // Description:
76 // Destructor for TsPiece.
77 //
78 // Use: public
79
80 TsPiece::~TsPiece()
81
82 //
83 ////////////////////////////////////////////////////////////////////////
84 {
85 }
86
87
88 ////////////////////////////////////////////////////////////////////////
89 //
90 // Description:
91 // This routine returns the list of positions of the blocks for the
92 // piece in its current orientation. The positions are specified as
93 // indices into the standard 27-cube. This method assumes that space
94 // to store the returned indices is passed in.
95 //
96 // Use: public
97
98 int
99 TsPiece::getPosition(
100 int pos[] ) // (out) the list of positions
101
102 // Values Returned:
103 // number of blocks in the piece
104 //
105 ////////////////////////////////////////////////////////////////////////
106 {
107 int i;
108
109 for (i=0; i<numBlocks; i++)
110 pos[i] = piecePositionTable[orientation][i];
111
112 return numBlocks;
113 }
114
115
116 ////////////////////////////////////////////////////////////////////////
117 //
118 // Description:
119 // This routine returns the list of positions of the blocks for the
120 // piece in the given orientation. The positions are specified as
121 // indices into the standard 27-cube. This method assumes that space
122 // to store the returned indices is passed in.
123 //
124 // Use: public
125
126 int
127 TsPiece::getPosition(
128 int newOrientation,
129 int pos[]) // (out) the list of positions
130
131 // Values Returned:
132 // number of blocks in the piece
133 //
134 ////////////////////////////////////////////////////////////////////////
135 {
136 int i;
137
138 for (i=0; i<numBlocks; i++)
139 pos[i] = piecePositionTable[newOrientation][i];
140
141 return numBlocks;
142 }
143
144
145
146