소스 검색

Initial commit from SF CVS

Thomas Buck 11 년 전
커밋
f3fb7db04d
100개의 변경된 파일57364개의 추가작업 그리고 0개의 파일을 삭제
  1. 76
    0
      BUGS
  2. 339
    0
      COPYING
  3. 1087
    0
      ChangeLog
  4. 501
    0
      Makefile
  5. 395
    0
      README
  6. 26
    0
      Requirements
  7. 95
    0
      TODO
  8. 4
    0
      autogen.sh
  9. 86
    0
      data/OpenRaider.init
  10. BIN
      data/font-0.tga
  11. BIN
      data/particle.tga
  12. BIN
      data/sample.wav
  13. BIN
      data/snow.tga
  14. BIN
      data/snow2.tga
  15. BIN
      data/splash.tga
  16. BIN
      data/test.ttf
  17. BIN
      data/white.tga
  18. 13
    0
      deps.sh
  19. 308
    0
      doc/TR4-Format.html
  20. 473
    0
      doc/TR4-Notes.html
  21. 531
    0
      doc/TR5-Format.html
  22. 116
    0
      doc/TR5-Format.txt
  23. 344
    0
      doc/TR5-Notes.txt
  24. 263
    0
      doc/TR5.spec
  25. 7012
    0
      doc/TRosettaStone.html
  26. 82
    0
      doc/ankrace.notes
  27. 18
    0
      fix-gcc3.sh
  28. 211
    0
      msvc/OpenRaider/OpenRaider.dsp
  29. 29
    0
      msvc/OpenRaider/OpenRaider.dsw
  30. BIN
      msvc/OpenRaider/OpenRaider.ncb
  31. BIN
      msvc/OpenRaider/OpenRaider.opt
  32. 674
    0
      msvc/OpenRaider/OpenRaider.plg
  33. 13
    0
      setup.sh
  34. 398
    0
      src/Camera.cpp
  35. 370
    0
      src/Camera.h
  36. 346
    0
      src/Emitter.cpp
  37. 289
    0
      src/Emitter.h
  38. 736
    0
      src/GLString.cpp
  39. 244
    0
      src/GLString.h
  40. 180
    0
      src/GLUTSystem.cpp
  41. 100
    0
      src/GLUTSystem.h
  42. 52
    0
      src/Light.cpp
  43. 91
    0
      src/Light.h
  44. 972
    0
      src/Md3.cpp
  45. 509
    0
      src/Md3.h
  46. 2302
    0
      src/Md3AnimModel.cpp
  47. 466
    0
      src/Md3AnimModel.h
  48. 852
    0
      src/MtkImage.cpp
  49. 243
    0
      src/MtkImage.h
  50. 791
    0
      src/Network.cpp
  51. 329
    0
      src/Network.h
  52. 652
    0
      src/OpenGLMesh.cpp
  53. 420
    0
      src/OpenGLMesh.h
  54. 3593
    0
      src/OpenRaider.cpp
  55. 473
    0
      src/OpenRaider.h
  56. 2589
    0
      src/PSKModel.cpp
  57. 589
    0
      src/PSKModel.h
  58. 177
    0
      src/Particle.cpp
  59. 210
    0
      src/Particle.h
  60. 2298
    0
      src/Render.cpp
  61. 599
    0
      src/Render.h
  62. 591
    0
      src/SDLSystem.cpp
  63. 237
    0
      src/SDLSystem.h
  64. 597
    0
      src/SDLUnitTest.cpp
  65. 194
    0
      src/SkeletalModel.cpp
  66. 166
    0
      src/SkeletalModel.h
  67. 336
    0
      src/Sound.cpp
  68. 181
    0
      src/Sound.h
  69. 785
    0
      src/System.cpp
  70. 553
    0
      src/System.h
  71. 1320
    0
      src/Texture.cpp
  72. 510
    0
      src/Texture.h
  73. 6839
    0
      src/TombRaider.cpp
  74. 2770
    0
      src/TombRaider.h
  75. 548
    0
      src/TombRaider1.h
  76. 486
    0
      src/TombRaider5.h
  77. 1253
    0
      src/UTPackage.cpp
  78. 222
    0
      src/UTPackage.h
  79. 795
    0
      src/World.cpp
  80. 583
    0
      src/World.h
  81. 137
    0
      src/endian.cpp
  82. 34
    0
      src/endian.h
  83. 81
    0
      src/hel/BoundingVolume.cpp
  84. 112
    0
      src/hel/BoundingVolume.h
  85. 79
    0
      src/hel/Entity.cpp
  86. 113
    0
      src/hel/Entity.h
  87. 117
    0
      src/hel/Mass.cpp
  88. 151
    0
      src/hel/Mass.h
  89. 726
    0
      src/hel/Matrix.cpp
  90. 381
    0
      src/hel/Matrix.h
  91. 121
    0
      src/hel/ParticleMass.h
  92. 425
    0
      src/hel/Quaternion.cpp
  93. 366
    0
      src/hel/Quaternion.h
  94. 452
    0
      src/hel/Simulation.cpp
  95. 308
    0
      src/hel/Simulation.h
  96. 235
    0
      src/hel/Vector3d.cpp
  97. 297
    0
      src/hel/Vector3d.h
  98. 403
    0
      src/hel/ViewVolume.cpp
  99. 294
    0
      src/hel/ViewVolume.h
  100. 0
    0
      src/hel/math.cpp

+ 76
- 0
BUGS 파일 보기

@@ -0,0 +1,76 @@
1
+
2
+ OpenRaider 
3
+ BUGS ( Updated 2002.12.24 )
4
+ ==================================================================
5
+
6
+ ### Open bugs  ###################################################
7
+
8
+ [2003.05.11]
9
+	* New animation code can cause segfault on pushing wall
10
+	  repeatedly to cause a bad event animation ( rare )
11
+
12
+ [Short list] No 'Z' in kb system?
13
+        * Working on System wrappers soon so that will be looked at
14
+
15
+ [Short list] OpenAL has problems with gdb and segfaults
16
+	* Disable OpenAL in OpenRaider.init if this happens,
17
+	  this is considered a bug in OpenAL
18
+	* Try a different version of OpenAL package
19
+
20
+ [2002.12.22] SkyMesh isn't loaded or rendered correctly
21
+        * New World/Render style is to blame
22
+
23
+ [2002.08.16] Many levels have room polygons misrendered
24
+	* Likely caused by the new room mesh cache system
25
+	  which is still being retooled
26
+	* Black walls caused by other than vertex color values
27
+        * Vertex colors for TR3-TR4 rooms messed up
28
+          ( Temp hack adjusts to bright values )
29
+
30
+
31
+ ### Closed bugs  #################################################
32
+
33
+ [????.??.??] TR4, TR3 Segfault on some level's load in ModelSetup
34
+        * Seems several meshes w/o vertices are followed by
35
+	  an invalid mesh that claims to have polygons
36
+	  yet doesn't
37
+	* Note some TR 'meshes' are just markers for
38
+	  particle fx and etc
39
+        * Reproducable with karnak1.tr4
40
+	* FIXED by accounting for -1 for NULL counter use in 
41
+	  some TR paks
42
+
43
+ [2002.01.04] TR4 Some levels segfault on load
44
+	* More animation frames generated than exist
45
+	  caused by invalid frame_offset
46
+	* Reproducable with angkor1.tr4
47
+	* FIXED by using new algothrim for anim frame loading
48
+
49
+ [2002.01.04] TR3 rendering white in textures with alpha black
50
+ [2002.01.04] TR1 rendering all textures black
51
+	* Used to work fine, but so much as changed...
52
+	* Try looking at texture loading first
53
+	* Then try looking at vertex lighting
54
+	* Reproducable with level1.phd, shore.tr2
55
+	* FIXED fast texture cache for older tombraider data
56
+	  loaded textures before they were generated as
57
+	  32bpp textures ( they were all alpha )
58
+
59
+ [2002.01.03] TR4 'Killed'
60
+	* FIXED try not loading OpenAL to save some memory
61
+	  can't really 'fix' lack of memory
62
+
63
+ [????.??.??] TR2, TR3 Polygon coloring is wrong
64
+	* Seems to be caused by vertex coloring
65
+	* FIXED ambient light wasn't set back to WHITE
66
+	  before mesh rendering
67
+
68
+ [????.??.??] TR4 fread(buffer, 2, 1546, fp) returned 3092
69
+        * Bad fread emulation checking? ( TR4 uses compressed data )
70
+        * Seems to be bad linking, works correctly after rebuilds
71
+	* FIXED uncompressed buffer size wasn't passed in DEBUG code
72
+
73
+ [????.??.??] NormalArray segfault
74
+        * Only happens in FastGL mode OR when Sky meshes are enabled
75
+        * mesh->oglTexturedRectangleNormals becomes NULL after first frame
76
+        * FIXED No longer using tombraider normal arrays in new renderer

+ 339
- 0
COPYING 파일 보기

@@ -0,0 +1,339 @@
1
+		    GNU GENERAL PUBLIC LICENSE
2
+		       Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
+                          675 Mass Ave, Cambridge, MA 02139, USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+			    Preamble
10
+
11
+  The licenses for most software are designed to take away your
12
+freedom to share and change it.  By contrast, the GNU General Public
13
+License is intended to guarantee your freedom to share and change free
14
+software--to make sure the software is free for all its users.  This
15
+General Public License applies to most of the Free Software
16
+Foundation's software and to any other program whose authors commit to
17
+using it.  (Some other Free Software Foundation software is covered by
18
+the GNU Library General Public License instead.)  You can apply it to
19
+your programs, too.
20
+
21
+  When we speak of free software, we are referring to freedom, not
22
+price.  Our General Public Licenses are designed to make sure that you
23
+have the freedom to distribute copies of free software (and charge for
24
+this service if you wish), that you receive source code or can get it
25
+if you want it, that you can change the software or use pieces of it
26
+in new free programs; and that you know you can do these things.
27
+
28
+  To protect your rights, we need to make restrictions that forbid
29
+anyone to deny you these rights or to ask you to surrender the rights.
30
+These restrictions translate to certain responsibilities for you if you
31
+distribute copies of the software, or if you modify it.
32
+
33
+  For example, if you distribute copies of such a program, whether
34
+gratis or for a fee, you must give the recipients all the rights that
35
+you have.  You must make sure that they, too, receive or can get the
36
+source code.  And you must show them these terms so they know their
37
+rights.
38
+
39
+  We protect your rights with two steps: (1) copyright the software, and
40
+(2) offer you this license which gives you legal permission to copy,
41
+distribute and/or modify the software.
42
+
43
+  Also, for each author's protection and ours, we want to make certain
44
+that everyone understands that there is no warranty for this free
45
+software.  If the software is modified by someone else and passed on, we
46
+want its recipients to know that what they have is not the original, so
47
+that any problems introduced by others will not reflect on the original
48
+authors' reputations.
49
+
50
+  Finally, any free program is threatened constantly by software
51
+patents.  We wish to avoid the danger that redistributors of a free
52
+program will individually obtain patent licenses, in effect making the
53
+program proprietary.  To prevent this, we have made it clear that any
54
+patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+  The precise terms and conditions for copying, distribution and
57
+modification follow.
58
+
59
+		    GNU GENERAL PUBLIC LICENSE
60
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+  0. This License applies to any program or other work which contains
63
+a notice placed by the copyright holder saying it may be distributed
64
+under the terms of this General Public License.  The "Program", below,
65
+refers to any such program or work, and a "work based on the Program"
66
+means either the Program or any derivative work under copyright law:
67
+that is to say, a work containing the Program or a portion of it,
68
+either verbatim or with modifications and/or translated into another
69
+language.  (Hereinafter, translation is included without limitation in
70
+the term "modification".)  Each licensee is addressed as "you".
71
+
72
+Activities other than copying, distribution and modification are not
73
+covered by this License; they are outside its scope.  The act of
74
+running the Program is not restricted, and the output from the Program
75
+is covered only if its contents constitute a work based on the
76
+Program (independent of having been made by running the Program).
77
+Whether that is true depends on what the Program does.
78
+
79
+  1. You may copy and distribute verbatim copies of the Program's
80
+source code as you receive it, in any medium, provided that you
81
+conspicuously and appropriately publish on each copy an appropriate
82
+copyright notice and disclaimer of warranty; keep intact all the
83
+notices that refer to this License and to the absence of any warranty;
84
+and give any other recipients of the Program a copy of this License
85
+along with the Program.
86
+
87
+You may charge a fee for the physical act of transferring a copy, and
88
+you may at your option offer warranty protection in exchange for a fee.
89
+
90
+  2. You may modify your copy or copies of the Program or any portion
91
+of it, thus forming a work based on the Program, and copy and
92
+distribute such modifications or work under the terms of Section 1
93
+above, provided that you also meet all of these conditions:
94
+
95
+    a) You must cause the modified files to carry prominent notices
96
+    stating that you changed the files and the date of any change.
97
+
98
+    b) You must cause any work that you distribute or publish, that in
99
+    whole or in part contains or is derived from the Program or any
100
+    part thereof, to be licensed as a whole at no charge to all third
101
+    parties under the terms of this License.
102
+
103
+    c) If the modified program normally reads commands interactively
104
+    when run, you must cause it, when started running for such
105
+    interactive use in the most ordinary way, to print or display an
106
+    announcement including an appropriate copyright notice and a
107
+    notice that there is no warranty (or else, saying that you provide
108
+    a warranty) and that users may redistribute the program under
109
+    these conditions, and telling the user how to view a copy of this
110
+    License.  (Exception: if the Program itself is interactive but
111
+    does not normally print such an announcement, your work based on
112
+    the Program is not required to print an announcement.)
113
+
114
+These requirements apply to the modified work as a whole.  If
115
+identifiable sections of that work are not derived from the Program,
116
+and can be reasonably considered independent and separate works in
117
+themselves, then this License, and its terms, do not apply to those
118
+sections when you distribute them as separate works.  But when you
119
+distribute the same sections as part of a whole which is a work based
120
+on the Program, the distribution of the whole must be on the terms of
121
+this License, whose permissions for other licensees extend to the
122
+entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+Thus, it is not the intent of this section to claim rights or contest
125
+your rights to work written entirely by you; rather, the intent is to
126
+exercise the right to control the distribution of derivative or
127
+collective works based on the Program.
128
+
129
+In addition, mere aggregation of another work not based on the Program
130
+with the Program (or with a work based on the Program) on a volume of
131
+a storage or distribution medium does not bring the other work under
132
+the scope of this License.
133
+
134
+  3. You may copy and distribute the Program (or a work based on it,
135
+under Section 2) in object code or executable form under the terms of
136
+Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+    a) Accompany it with the complete corresponding machine-readable
139
+    source code, which must be distributed under the terms of Sections
140
+    1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+    b) Accompany it with a written offer, valid for at least three
143
+    years, to give any third party, for a charge no more than your
144
+    cost of physically performing source distribution, a complete
145
+    machine-readable copy of the corresponding source code, to be
146
+    distributed under the terms of Sections 1 and 2 above on a medium
147
+    customarily used for software interchange; or,
148
+
149
+    c) Accompany it with the information you received as to the offer
150
+    to distribute corresponding source code.  (This alternative is
151
+    allowed only for noncommercial distribution and only if you
152
+    received the program in object code or executable form with such
153
+    an offer, in accord with Subsection b above.)
154
+
155
+The source code for a work means the preferred form of the work for
156
+making modifications to it.  For an executable work, complete source
157
+code means all the source code for all modules it contains, plus any
158
+associated interface definition files, plus the scripts used to
159
+control compilation and installation of the executable.  However, as a
160
+special exception, the source code distributed need not include
161
+anything that is normally distributed (in either source or binary
162
+form) with the major components (compiler, kernel, and so on) of the
163
+operating system on which the executable runs, unless that component
164
+itself accompanies the executable.
165
+
166
+If distribution of executable or object code is made by offering
167
+access to copy from a designated place, then offering equivalent
168
+access to copy the source code from the same place counts as
169
+distribution of the source code, even though third parties are not
170
+compelled to copy the source along with the object code.
171
+
172
+  4. You may not copy, modify, sublicense, or distribute the Program
173
+except as expressly provided under this License.  Any attempt
174
+otherwise to copy, modify, sublicense or distribute the Program is
175
+void, and will automatically terminate your rights under this License.
176
+However, parties who have received copies, or rights, from you under
177
+this License will not have their licenses terminated so long as such
178
+parties remain in full compliance.
179
+
180
+  5. You are not required to accept this License, since you have not
181
+signed it.  However, nothing else grants you permission to modify or
182
+distribute the Program or its derivative works.  These actions are
183
+prohibited by law if you do not accept this License.  Therefore, by
184
+modifying or distributing the Program (or any work based on the
185
+Program), you indicate your acceptance of this License to do so, and
186
+all its terms and conditions for copying, distributing or modifying
187
+the Program or works based on it.
188
+
189
+  6. Each time you redistribute the Program (or any work based on the
190
+Program), the recipient automatically receives a license from the
191
+original licensor to copy, distribute or modify the Program subject to
192
+these terms and conditions.  You may not impose any further
193
+restrictions on the recipients' exercise of the rights granted herein.
194
+You are not responsible for enforcing compliance by third parties to
195
+this License.
196
+
197
+  7. If, as a consequence of a court judgment or allegation of patent
198
+infringement or for any other reason (not limited to patent issues),
199
+conditions are imposed on you (whether by court order, agreement or
200
+otherwise) that contradict the conditions of this License, they do not
201
+excuse you from the conditions of this License.  If you cannot
202
+distribute so as to satisfy simultaneously your obligations under this
203
+License and any other pertinent obligations, then as a consequence you
204
+may not distribute the Program at all.  For example, if a patent
205
+license would not permit royalty-free redistribution of the Program by
206
+all those who receive copies directly or indirectly through you, then
207
+the only way you could satisfy both it and this License would be to
208
+refrain entirely from distribution of the Program.
209
+
210
+If any portion of this section is held invalid or unenforceable under
211
+any particular circumstance, the balance of the section is intended to
212
+apply and the section as a whole is intended to apply in other
213
+circumstances.
214
+
215
+It is not the purpose of this section to induce you to infringe any
216
+patents or other property right claims or to contest validity of any
217
+such claims; this section has the sole purpose of protecting the
218
+integrity of the free software distribution system, which is
219
+implemented by public license practices.  Many people have made
220
+generous contributions to the wide range of software distributed
221
+through that system in reliance on consistent application of that
222
+system; it is up to the author/donor to decide if he or she is willing
223
+to distribute software through any other system and a licensee cannot
224
+impose that choice.
225
+
226
+This section is intended to make thoroughly clear what is believed to
227
+be a consequence of the rest of this License.
228
+
229
+  8. If the distribution and/or use of the Program is restricted in
230
+certain countries either by patents or by copyrighted interfaces, the
231
+original copyright holder who places the Program under this License
232
+may add an explicit geographical distribution limitation excluding
233
+those countries, so that distribution is permitted only in or among
234
+countries not thus excluded.  In such case, this License incorporates
235
+the limitation as if written in the body of this License.
236
+
237
+  9. The Free Software Foundation may publish revised and/or new versions
238
+of the General Public License from time to time.  Such new versions will
239
+be similar in spirit to the present version, but may differ in detail to
240
+address new problems or concerns.
241
+
242
+Each version is given a distinguishing version number.  If the Program
243
+specifies a version number of this License which applies to it and "any
244
+later version", you have the option of following the terms and conditions
245
+either of that version or of any later version published by the Free
246
+Software Foundation.  If the Program does not specify a version number of
247
+this License, you may choose any version ever published by the Free Software
248
+Foundation.
249
+
250
+  10. If you wish to incorporate parts of the Program into other free
251
+programs whose distribution conditions are different, write to the author
252
+to ask for permission.  For software which is copyrighted by the Free
253
+Software Foundation, write to the Free Software Foundation; we sometimes
254
+make exceptions for this.  Our decision will be guided by the two goals
255
+of preserving the free status of all derivatives of our free software and
256
+of promoting the sharing and reuse of software generally.
257
+
258
+			    NO WARRANTY
259
+
260
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
262
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
266
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
267
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+REPAIR OR CORRECTION.
269
+
270
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+POSSIBILITY OF SUCH DAMAGES.
279
+
280
+		     END OF TERMS AND CONDITIONS
281
+
282
+	    How to Apply These Terms to Your New Programs
283
+
284
+  If you develop a new program, and you want it to be of the greatest
285
+possible use to the public, the best way to achieve this is to make it
286
+free software which everyone can redistribute and change under these terms.
287
+
288
+  To do so, attach the following notices to the program.  It is safest
289
+to attach them to the start of each source file to most effectively
290
+convey the exclusion of warranty; and each file should have at least
291
+the "copyright" line and a pointer to where the full notice is found.
292
+
293
+    <one line to give the program's name and a brief idea of what it does.>
294
+    Copyright (C) 19yy  <name of author>
295
+
296
+    This program is free software; you can redistribute it and/or modify
297
+    it under the terms of the GNU General Public License as published by
298
+    the Free Software Foundation; either version 2 of the License, or
299
+    (at your option) any later version.
300
+
301
+    This program is distributed in the hope that it will be useful,
302
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
304
+    GNU General Public License for more details.
305
+
306
+    You should have received a copy of the GNU General Public License
307
+    along with this program; if not, write to the Free Software
308
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
309
+
310
+Also add information on how to contact you by electronic and paper mail.
311
+
312
+If the program is interactive, make it output a short notice like this
313
+when it starts in an interactive mode:
314
+
315
+    Gnomovision version 69, Copyright (C) 19yy name of author
316
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+    This is free software, and you are welcome to redistribute it
318
+    under certain conditions; type `show c' for details.
319
+
320
+The hypothetical commands `show w' and `show c' should show the appropriate
321
+parts of the General Public License.  Of course, the commands you use may
322
+be called something other than `show w' and `show c'; they could even be
323
+mouse-clicks or menu items--whatever suits your program.
324
+
325
+You should also get your employer (if you work as a programmer) or your
326
+school, if any, to sign a "copyright disclaimer" for the program, if
327
+necessary.  Here is a sample; alter the names:
328
+
329
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+  <signature of Ty Coon>, 1 April 1989
333
+  Ty Coon, President of Vice
334
+
335
+This General Public License does not permit incorporating your program into
336
+proprietary programs.  If your program is a subroutine library, you may
337
+consider it more useful to permit linking proprietary applications with the
338
+library.  If this is what you want to do, use the GNU Library General
339
+Public License instead of this License.

+ 1087
- 0
ChangeLog
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 501
- 0
Makefile 파일 보기

@@ -0,0 +1,501 @@
1
+###############################################################
2
+# Mongoose <stu7440@westga.edu>
3
+###############################################################
4
+# + Cleaner clean
5
+# + Add new include tree
6
+# + Add new flags
7
+# + Install/Uninstall
8
+# + Debian and Redhat packaging
9
+# + Lots of misc new features
10
+###############################################################
11
+BUILD_SELECT=debug
12
+
13
+NAME=OpenRaider
14
+NAME_DEB=openraider
15
+MAJOR_VERSION=0
16
+MINOR_VERSION=1
17
+MICRO_VERSION=1
18
+BUILD_ID=20030713
19
+PRE=
20
+VERSION=$(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)$(PRE)
21
+VERSION_DEB=$(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION).$(BUILD_ID)
22
+BUILD_HOST=$(shell uname -s -n -r -m)
23
+#ARCH=$(shell uname -m)
24
+ARCH=i386
25
+
26
+###############################################################
27
+
28
+# -DUSING_OPENAL		Add OpenAL sound support
29
+# -DMULTITEXTURE		Add OpenGL multitexturing
30
+# -DUNICODE_SUPPORT		Add unicode/internation keyboard support
31
+# -DUSING_EMITTER_IN_GAME	Run particle test in game
32
+BASE_DEFS=$(shell sdl-config --cflags) -DSDL_INTERFACE \
33
+	-DUSING_OPENGL -DZLIB_SUPPORT -DUSING_EMITTER \
34
+	-DUSING_OPENAL -DUSING_MTK_TGA -DUSING_PTHREADS \
35
+	-DUSING_HEL -DHAVE_SDL_TTF -DHAVE_OPENGL
36
+
37
+BASE_LIBS=$(shell sdl-config --libs) -lz -lstdc++ \
38
+	-lopenal -lpthread -lSDL_ttf
39
+
40
+# -DDEBUG_GL
41
+DEBUG_DEFS=-DDEBUG -DEXPERIMENTAL
42
+DEBUG_OBJ=
43
+
44
+###############################################################
45
+# OpenAL, Sound support
46
+BASE_DEFS += -DHAVE_OPENAL
47
+BASE_LIBS += -lopenal
48
+
49
+# libferit, File transfer via HTTP/FTP/etc support
50
+LIBFERIT_LIB=/usr/local/lib/libferit.so
51
+LIBFERIT=$(shell if test -e $(LIBFERIT_LIB) > /dev/null; then echo -n yes; fi)
52
+
53
+ifeq ($(LIBFERIT), yes)
54
+	BASE_DEFS += -DHAVE_LIBFERIT
55
+	BASE_LIBS += -lferit
56
+endif
57
+
58
+###############################################################
59
+
60
+TREE_DIR=OpenRaider.cvs
61
+BUILD_DEBUG_DIR=bin/debug
62
+BUILD_RELEASE_DIR=bin/release
63
+BUILD_PROF_DIR=bin/prof
64
+BUILD_TEST_DIR=bin/test
65
+BUILD_MEM_DIR=bin/mem
66
+BUILD_INSTALL_DIR=bin/$(BUILD_SELECT)
67
+DEB_DIR=/tmp/$(NAME).deb
68
+
69
+# Edited for Debian GNU/Linux.
70
+DESTDIR =
71
+INSTALL_BIN=$(DESTDIR)/usr/games
72
+INSTALL_LIB=$(DESTDIR)/usr/lib
73
+INSTALL_DOC=$(DESTDIR)/usr/share/doc/$(NAME)
74
+INSTALL_SHARE=$(DESTDIR)/usr/share/$(NAME)
75
+INSTALL_INCLUDE=$(DESTDIR)/usr/include
76
+
77
+###############################################################
78
+CC=gcc
79
+
80
+BASE_CFLAGS=-Wall -Isrc $(BASE_DEFS) \
81
+	-DVERSION=\"\\\"$(NAME)-$(VERSION)-$(BUILD_ID)\\\"\" \
82
+	-DBUILD_HOST=\"\\\"$(BUILD_HOST)\\\"\"
83
+
84
+LD_FLAGS=-L/usr/X11R6/lib -lXmu -lXt -lSM -lICE -lXext -lX11 -lXi \
85
+	-lGL -lGLU -lm $(BASE_LIBS)
86
+
87
+RELEASE_CFLAGS=$(BASE_CFLAGS) -ffast-math -funroll-loops \
88
+	-fomit-frame-pointer -fexpensive-optimizations -O2
89
+
90
+DEBUG_CFLAGS=$(BASE_CFLAGS) -g -O0 $(DEBUG_DEFS)
91
+
92
+################################################################
93
+
94
+DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
95
+DO_SHLIB_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $<
96
+
97
+TARGETS=$(BUILDDIR)/$(NAME)
98
+
99
+################################################################
100
+auto: $(BUILD_SELECT)
101
+
102
+targets: $(TARGETS)
103
+
104
+all: debug release prof
105
+
106
+debug:
107
+	@-mkdir -p $(BUILD_DEBUG_DIR)
108
+	$(MAKE) targets BUILDDIR=$(BUILD_DEBUG_DIR) \
109
+	CFLAGS="$(DEBUG_CFLAGS)" \
110
+	LD_FLAGS="$(LD_FLAGS)"
111
+
112
+prof:
113
+	@-mkdir -p $(BUILD_PROF_DIR)
114
+	$(MAKE) targets BUILDDIR=$(BUILD_PROF_DIR) \
115
+	CFLAGS="$(DEBUG_CFLAGS) -pg" \
116
+	LD_FLAGS="$(LD_FLAGS) -pg"
117
+
118
+release:
119
+	@-mkdir -p $(BUILD_RELEASE_DIR)
120
+	$(MAKE) targets BUILDDIR=$(BUILD_RELEASE_DIR) \
121
+	CFLAGS="$(RELEASE_CFLAGS)" \
122
+	LD_FLAGS="$(LD_FLAGS)"
123
+
124
+#####################################
125
+
126
+ded:
127
+	@-mkdir -p $(BUILD_DEBUG_DIR)/ded
128
+	$(MAKE) targets BUILDDIR=$(BUILD_DEBUG_DIR)/ded \
129
+	CFLAGS="$(DEBUG_CFLAGS) -DDEDICATED_SERVER" \
130
+	LD_FLAGS="$(LD_FLAGS)"
131
+
132
+md3:
133
+	@-mkdir -p $(BUILD_DEBUG_DIR)
134
+	$(MAKE) targets BUILDDIR=$(BUILD_DEBUG_DIR) \
135
+	DEBUG_OBJ="$(BUILD_DEBUG_DIR)/endian.o $(BUILD_DEBUG_DIR)/Md3.o $(BUILD_DEBUG_DIR)/Md3AnimModel.o" \
136
+	CFLAGS="$(DEBUG_CFLAGS) -DUSING_MD3" \
137
+	LD_FLAGS="$(LD_FLAGS)"
138
+
139
+# -DDEBUG_MEMEORY_VERBOSE
140
+# -DDEBUG_MEMEORY
141
+memory:
142
+	@-mkdir -p $(BUILD_MEM_DIR)
143
+	$(MAKE) targets BUILDDIR=$(BUILD_MEM_DIR) \
144
+	DEBUG_OBJ="$(BUILD_MEM_DIR)/memeory_test.o" \
145
+	CFLAGS="$(DEBUG_CFLAGS) -DDEBUG_MEMEORY" \
146
+	LD_FLAGS="$(LD_FLAGS)"
147
+
148
+depend:
149
+	@-echo -n "Making deps..."
150
+	@-echo "# Autogenerated dependency file" > depend
151
+	@-find ./src -name "*.cpp" -exec ./deps.sh $(BASE_DEFS) {} \; >> depend
152
+	@-echo "       [done]"
153
+
154
+################################################################
155
+
156
+# Later hel will become a seperate library once it matures
157
+HEL_OBJ = \
158
+	$(BUILDDIR)/Mass.o \
159
+	$(BUILDDIR)/Simulation.o \
160
+	$(BUILDDIR)/Vector3d.o \
161
+	$(BUILDDIR)/Matrix.o \
162
+	$(BUILDDIR)/ViewVolume.o \
163
+	$(BUILDDIR)/Spring.o \
164
+	$(BUILDDIR)/CollisionObject.o \
165
+	$(BUILDDIR)/BoundingVolume.o \
166
+	$(BUILDDIR)/Quaternion.o \
167
+	$(BUILDDIR)/math.o
168
+
169
+
170
+OBJS = \
171
+	$(DEBUG_OBJ) \
172
+	$(HEL_OBJ) \
173
+	$(BUILDDIR)/mtk_tga.o \
174
+	$(BUILDDIR)/System.o \
175
+	$(BUILDDIR)/SDLSystem.o \
176
+	$(BUILDDIR)/OpenRaider.o \
177
+	$(BUILDDIR)/World.o \
178
+	$(BUILDDIR)/TombRaider.o \
179
+	$(BUILDDIR)/GLString.o \
180
+	$(BUILDDIR)/Camera.o \
181
+	$(BUILDDIR)/OpenGLMesh.o \
182
+	$(BUILDDIR)/Render.o \
183
+	$(BUILDDIR)/Sound.o \
184
+	$(BUILDDIR)/Network.o \
185
+	$(BUILDDIR)/Texture.o \
186
+	$(BUILDDIR)/Emitter.o \
187
+	$(BUILDDIR)/Particle.o \
188
+	$(BUILDDIR)/SkeletalModel.o \
189
+	$(BUILDDIR)/Light.o
190
+
191
+
192
+$(BUILDDIR)/$(NAME) : $(OBJS)
193
+	$(CC) $(CFLAGS) $(LD_FLAGS) -o $@ $(OBJS)
194
+
195
+#################################################################
196
+
197
+-include depend
198
+
199
+#################################################################
200
+
201
+clean: clean-emacs clean-build clean-test clean-obj clean-dep
202
+
203
+clean-dep:
204
+	@-echo -n "Cleaning dependencies                        "
205
+	@-rm -f depend
206
+	@-echo "[DONE]"
207
+
208
+clean-test:
209
+	@-echo -n "Cleaning test builds                         "
210
+	@-rm -f $(BUILD_TEST_DIR)/*.o
211
+	@-rm -f $(BUILD_TEST_DIR)/*.test
212
+	@-rm -rf $(BUILD_TEST_DIR)/*.build
213
+	@-echo "[DONE]"
214
+
215
+clean-obj:
216
+	@-echo -n "Cleaning objects                             "
217
+	@-rm -f $(BUILD_PROF_DIR)/*.o
218
+	@-rm -f $(BUILD_DEBUG_DIR)/*.o
219
+	@-rm -f $(BUILD_RELEASE_DIR)/*.o
220
+	@-rm -f $(BUILD_TEST_DIR)/*.o
221
+	@-rm -f $(BUILD_MEM_DIR)/*.o
222
+	@-echo "[DONE]"
223
+
224
+clean-emacs:
225
+	@-echo -n "Cleaning emacs files                         "
226
+	@-rm -f `find . -name "*~" -print`
227
+	@-echo "[DONE]"
228
+
229
+clean-build:
230
+	@-echo -n "Cleaning builds                              "
231
+	@-rm -f $(BUILD_PROF_DIR)/$(NAME)
232
+	@-rm -f $(BUILD_DEBUG_DIR)/$(NAME)
233
+	@-rm -f $(BUILD_RELEASE_DIR)/$(NAME)
234
+	@-rm -f $(BUILD_MEM_DIR)/$(NAME)
235
+	@-echo "[DONE]"
236
+
237
+clean-deb:
238
+	@-echo -n "Cleaning DEBs                                "
239
+	@-rm -rf $(DEB_DIR)
240
+	@-echo "[DONE]"
241
+
242
+#################################################################
243
+
244
+redhat:
245
+	cd $(DEB_DIR) && \
246
+		alien --to-rpm $(NAME_DEB)_$(VERSION_DEB)-1_$(ARCH).deb
247
+
248
+debian:
249
+	$(MAKE) tarball
250
+	$(MAKE) clean-deb
251
+	mkdir -p $(DEB_DIR)
252
+	cp ../$(NAME_DEB)-$(VERSION_DEB).tar.gz $(DEB_DIR)
253
+	cd $(DEB_DIR) && tar zxvf $(NAME_DEB)-$(VERSION_DEB).tar.gz && mv $(TREE_DIR) $(NAME_DEB)-$(VERSION_DEB) && cd $(NAME_DEB)-$(VERSION_DEB) && make deb-init && make deb
254
+
255
+deb-init:
256
+	dh_make -c gpl -s \
257
+	-e mongoose@icculus.org -f ../$(NAME_DEB)-$(VERSION_DEB).tar.gz
258
+	@-cp debian/control debian/control.old
259
+	@-sed -e "s/<insert up to 60 chars description>/Open source Tomb Raider series clone/g" debian/control.old > debian/control
260
+	@-rm -f debian/control.old
261
+	@-cp debian/control debian/control.old
262
+	@-sed -e "s/<insert long description, indented with spaces>/OpenRaider is an open source multiplayer and single player Tomb Raider clone for linux and Playstation 2. It uses the game data such as models, sound, levels,  and animation from the popular 3d series Tomb Raider by Core Design./g" debian/control.old > debian/control
263
+	@-rm -f debian/control.old
264
+
265
+deb:
266
+	dpkg-buildpackage -rfakeroot
267
+
268
+apt:
269
+	cd $(DEB_DIR) && dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
270
+	cd $(DEB_DIR) && dpkg-scansources . /dev/null | gzip -9c > Sources.gz
271
+
272
+apt-upload:
273
+	scp $(DEB_DIR)/Packages.gz \
274
+		$(DEB_DIR)/Sources.gz \
275
+		$(DEB_DIR)/$(NAME_DEB)*.diff.gz  \
276
+		$(DEB_DIR)/$(NAME_DEB)*.deb \
277
+		$(DEB_DIR)/$(NAME_DEB)*.dsc \
278
+		$(DEB_DIR)/$(NAME_DEB)*.orig.tar.gz \
279
+	orbital.sf.net:~/openraider/htdocs/debian/
280
+
281
+install:
282
+	mkdir -p $(INSTALL_SHARE)/data
283
+	cp setup.sh $(INSTALL_SHARE)
284
+	cp data/* $(INSTALL_SHARE)/data
285
+	mkdir -p $(INSTALL_DOC)
286
+	cp README ChangeLog BUGS TODO $(INSTALL_DOC)
287
+	mkdir -p $(INSTALL_BIN)
288
+	cp bin/$(BUILD_SELECT)/OpenRaider $(INSTALL_BIN)
289
+
290
+bin-tarball:
291
+	$(MAKE) clean-obj
292
+	@-cd .. && tar zcvf $(NAME_DEB)-$(VERSION_DEB)-$(ARCH).tar.gz \
293
+		$(TREE_DIR)/Makefile $(TREE_DIR)/data \
294
+		$(TREE_DIR)/bin/$(BUILD_SELECT)/OpenRaider \
295
+		$(TREE_DIR)/README $(TREE_DIR)/ChangeLog \
296
+		$(TREE_DIR)/BUGS $(TREE_DIR)/TODO
297
+
298
+tarball:
299
+	@-echo "Making tarball                                  " 
300
+	@-cd .. && tar zcvf $(NAME_DEB)-$(VERSION_DEB).tar.gz \
301
+		$(TREE_DIR) --exclude old --exclude models \
302
+		--exclude semantic.cache --exclude TAGS \
303
+		--exclude bin --exclude CVS --exclude *~ 
304
+	@-echo "[DONE]"
305
+
306
+PSKModel.zip:
307
+	@-echo "Making PSKModel pak                             " 
308
+	@-zip ../pskmodel-$(BUILD_ID)-src.zip \
309
+		Makefile deps.sh README.PSKModel \
310
+		src/PSKModel.h src/PSKModel.cpp \
311
+		src/UTPackage.h src/UTPackage.cpp \
312
+		src/Texture.h src/Texture.cpp \
313
+		src/mtk_tga.cpp src/mtk_tga.h
314
+	@-echo "[DONE]"
315
+	@-echo "Making test data pak                            " 
316
+	@-zip -r ../pskmodel-$(BUILD_ID)-data.zip \
317
+		data/models/test/ 
318
+	@-echo "[DONE]"
319
+
320
+backup:
321
+	$(MAKE) tarball
322
+	@-cd .. && cp $(NAME)-$(VERSION)-$(BUILD_ID).tar.gz ~/Backup
323
+
324
+
325
+#################################################################
326
+# Unit Test builds
327
+#################################################################
328
+TEST_FLAGS=-Wall -g -O0 -DDEBUG -lstdc++
329
+
330
+TEST_MAP_TR5=~/projects/Data/models/tombraider/tr5/demo.trc
331
+TEST_MAP_TR4=~/projects/Data/models/tombraider/tr4/angkor1.tr4
332
+TEST_MAP_TR3=~/projects/Data/models/tombraider/tr3/scotland.tr2
333
+TEST_MAP_TR2=~/projects/Data/models/tombraider/tr2/unwater.tr2
334
+TEST_MAP_TR1=~/projects/Data/models/tombraider/tr1/level1.phd
335
+
336
+TombRaider.reg_test:
337
+	$(MAKE) TombRaider.test
338
+	$(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR1) > /tmp/log.tr1
339
+	$(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR2) > /tmp/log.tr2
340
+	$(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR3) > /tmp/log.tr3
341
+	$(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR4) > /tmp/log.tr4
342
+	$(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR5) > /tmp/log.tr5
343
+
344
+
345
+TombRaider.test:
346
+	@-mkdir -p $(BUILD_TEST_DIR)
347
+	$(MAKE) targets NAME=TombRaider.test BUILDDIR=$(BUILD_TEST_DIR) \
348
+	OBJS="$(BUILD_TEST_DIR)/TombRaider.o $(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/memeory_test.o" \
349
+	CFLAGS="$(BASE_CFLAGS) -g -D__TOMBRAIDER_TEST__ -D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES -DDEBUG_MEMEORY" \
350
+	LD_FLAGS="-lz"
351
+
352
+#################################################################
353
+
354
+MD3ANIMMODEL_CFLAGS=-DUSING_OPENGL -DUNIT_TEST_MD3ANIMMODEL_SDL \
355
+	-DUSING_MTK_TGA -DUSING_HEL $(shell sdl-config --cflags) \
356
+	-DHAVE_SDL_TTF
357
+MD3ANIMMODEL_LDFLAGS=-lm -lstdc++ -lGL -lGLU $(shell sdl-config --libs) \
358
+	-lSDL_ttf
359
+MD3ANIMMODEL_OBJS=$(BUILD_TEST_DIR)/mtk_tga.o \
360
+	$(BUILD_TEST_DIR)/Texture.o $(BUILD_TEST_DIR)/endian.o \
361
+	$(BUILD_TEST_DIR)/Quaternion.o \
362
+	$(BUILD_TEST_DIR)/Md3.o $(BUILD_TEST_DIR)/Md3AnimModel.o
363
+
364
+Md3AnimModel.test:
365
+	mkdir -p $(BUILD_TEST_DIR)
366
+	$(MAKE) targets \
367
+	NAME=Md3AnimModel.test \
368
+	BUILDDIR=$(BUILD_TEST_DIR) \
369
+	OBJS="$(MD3ANIMMODEL_OBJS)" \
370
+	CFLAGS=" -Wall -O0 -g -Isrc $(MD3ANIMMODEL_CFLAGS)" \
371
+	LD_FLAGS="$(MD3ANIMMODEL_LDFLAGS)"
372
+
373
+#################################################################
374
+
375
+GLString.test:
376
+	mkdir -p $(BUILD_TEST_DIR)
377
+	$(CC) -Wall -Isrc -D__TEST__ -DHAVE_MTK -DHAVE_SDL -DUSING_MTK_TGA \
378
+	$(shell sdl-config --cflags) $(shell sdl-config --libs) \
379
+	-lGL -lGLU -lm \
380
+	src/Texture.cpp src/mtk_tga.cpp \
381
+	src/GLString.cpp -o $(BUILD_TEST_DIR)/GLString.test
382
+
383
+#################################################################
384
+SIMULATION_CFLAGS=-Wall -O0 -g -Isrc $(shell sdl-config --cflags) \
385
+		-DUSING_OPENGL -DUSING_HEL -DUSING_MTK_TGA \
386
+		-DUNIT_TEST_SIMULATION
387
+SIMULATION_OBJS=$(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/Texture.o \
388
+		$(BUILD_TEST_DIR)/Mass.o \
389
+		$(BUILD_TEST_DIR)/CollisionObject.o \
390
+		$(BUILD_TEST_DIR)/Simulation.o \
391
+		$(BUILD_TEST_DIR)/Vector3d.o \
392
+		$(BUILD_TEST_DIR)/Matrix.o \
393
+		$(BUILD_TEST_DIR)/ViewVolume.o \
394
+		$(BUILD_TEST_DIR)/BoundingVolume.o \
395
+		$(BUILD_TEST_DIR)/Quaternion.o \
396
+		$(BUILD_TEST_DIR)/math.o
397
+
398
+Simulation.test:
399
+	mkdir -p $(BUILD_TEST_DIR)
400
+	$(MAKE) targets NAME=Simulation.test BUILDDIR=$(BUILD_TEST_DIR) \
401
+		OBJS="$(SIMULATION_OBJS)" \
402
+		CFLAGS="$(SIMULATION_CFLAGS)" \
403
+		LD_FLAGS="-lm -lstdc++ -lGL -lGLU $(shell sdl-config --libs)"
404
+
405
+#################################################################
406
+HEL_PARTICLE_CFLAGS=-Wall -O0 -g -Isrc $(shell sdl-config --cflags) \
407
+		-DUSING_OPENGL -DUSING_HEL -DUSING_MTK_TGA \
408
+		-DUNIT_TEST_SPRING -DHAVE_SDL_TTF -lSDL_ttf
409
+HEL_PARTICLE_OBJS=$(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/Texture.o \
410
+		$(BUILD_TEST_DIR)/Mass.o \
411
+		$(BUILD_TEST_DIR)/Spring.o \
412
+		$(BUILD_TEST_DIR)/CollisionObject.o \
413
+		$(BUILD_TEST_DIR)/Simulation.o \
414
+		$(BUILD_TEST_DIR)/Vector3d.o \
415
+		$(BUILD_TEST_DIR)/Matrix.o \
416
+		$(BUILD_TEST_DIR)/ViewVolume.o \
417
+		$(BUILD_TEST_DIR)/BoundingVolume.o \
418
+		$(BUILD_TEST_DIR)/Quaternion.o \
419
+		$(BUILD_TEST_DIR)/math.o
420
+
421
+Spring.test:
422
+	mkdir -p $(BUILD_TEST_DIR)
423
+	$(MAKE) targets NAME=Spring.test BUILDDIR=$(BUILD_TEST_DIR) \
424
+		OBJS="$(HEL_PARTICLE_OBJS)" \
425
+		CFLAGS="$(HEL_PARTICLE_CFLAGS)" \
426
+		LD_FLAGS="-lm -lstdc++ -lGL -lGLU $(shell sdl-config --libs)"
427
+
428
+#################################################################
429
+
430
+Hel.test: Quaternion.test Matrix.test Math.test
431
+
432
+Matrix.test:
433
+	@-echo "Building Matrix unit test"
434
+	mkdir -p $(BUILD_TEST_DIR)
435
+	$(CC) -Wall -g -DMATRIX_UNIT_TEST -lm -lstdc++ -Isrc \
436
+	src/hel/Matrix.cpp src/hel/Quaternion.cpp src/hel/Vector3d.cpp \
437
+	-o $(BUILD_TEST_DIR)/Matrix.test
438
+	@-echo "================================================="
439
+	@-echo "Running Matrix unit test"
440
+	$(BUILD_TEST_DIR)/Matrix.test
441
+
442
+Quaternion.test:
443
+	@-echo "Building Quaternion unit test"
444
+	mkdir -p $(BUILD_TEST_DIR)
445
+	$(CC) -Wall -g -DQUATERNION_UNIT_TEST -lm -lstdc++ -Isrc \
446
+	src/hel/Quaternion.cpp -o $(BUILD_TEST_DIR)/Quaternion.test
447
+	@-echo "================================================="
448
+	@-echo "Running Quaternion unit test"
449
+	$(BUILD_TEST_DIR)/Quaternion.test
450
+
451
+Math.test:
452
+	@-echo "Building Math unit test"
453
+	mkdir -p $(BUILD_TEST_DIR)
454
+	$(CC) -Wall -g -DMATH_UNIT_TEST -lm -lstdc++ -Isrc \
455
+	src/hel/math.cpp -o $(BUILD_TEST_DIR)/Math.test
456
+	@-echo "================================================="
457
+	@-echo "Running hel unit test"
458
+	$(BUILD_TEST_DIR)/Math.test
459
+
460
+#################################################################
461
+
462
+Memeory.test:
463
+	mkdir -p $(BUILD_TEST_DIR)
464
+	$(CC) -Wall -g -D__TEST__ -lstdc++ \
465
+	-DDEBUG_MEMEORY -DDEBUG_MEMEORY_ERROR \
466
+	src/memeory_test.cpp -o $(BUILD_TEST_DIR)/memeory_test.test
467
+
468
+#################################################################
469
+
470
+Network.test:
471
+	mkdir -p $(BUILD_TEST_DIR)
472
+	$(CC) $(TEST_FLAGS) -DUNIT_TEST_NETWORK \
473
+	src/Network.cpp -o $(BUILD_TEST_DIR)/Network.test
474
+
475
+#################################################################
476
+
477
+Sound.test:
478
+	mkdir -p $(BUILD_TEST_DIR)
479
+	$(CC) $(TEST_FLAGS) -DUNIT_TEST_SOUND \
480
+		-DUSING_OPENAL -lopenal \
481
+		src/Sound.cpp -o $(BUILD_TEST_DIR)/Sound.test
482
+
483
+#################################################################
484
+
485
+PSKModel.test:
486
+	mkdir -p $(BUILD_TEST_DIR)
487
+	$(MAKE) targets NAME=PSKModel.test BUILDDIR=$(BUILD_TEST_DIR) \
488
+	OBJS="$(BUILD_TEST_DIR)/PSKModel.o $(BUILD_TEST_DIR)/UTPackage.o $(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/Texture.o" \
489
+	CFLAGS="-Wall -O0 -g -Isrc -DUNIT_TEST_PSKMODEL -DUSING_OPENGL $(shell sdl-config --cflags) -DUSING_MTK_TGA -DHAVE_SDL_TTF" \
490
+	LD_FLAGS="-lm -lstdc++ -lGL -lGLU $(shell sdl-config --libs) -lSDL_ttf"
491
+
492
+#################################################################
493
+
494
+UTPackage.test:
495
+	mkdir -p $(BUILD_TEST_DIR)
496
+	$(MAKE) targets NAME=UTPackage.test BUILDDIR=$(BUILD_TEST_DIR) \
497
+	OBJS="$(BUILD_TEST_DIR)/UTPackage.o $(BUILD_TEST_DIR)/mtk_tga.o" \
498
+	CFLAGS="-Wall -O0 -g -Isrc -DUNIT_TEST_UTPACKAGE -DUSING_MTK_TGA" \
499
+	LD_FLAGS="-lm -lstdc++"
500
+
501
+#################################################################

+ 395
- 0
README 파일 보기

@@ -0,0 +1,395 @@
1
+
2
+ OpenRaider FAQ/README  (2003.07.05)
3
+ -----------------------------------------------------------------
4
+
5
+ NOTES
6
+ -----------------------------------------------------------------
7
+ Build 0.1.2pre series
8
+
9
+
10
+ INSTALL
11
+ -----------------------------------------------------------------
12
+
13
+ You may choose to use either apt if you have debian, or use the 
14
+ source installation.  The binary tarballs may be provided with an
15
+ install script later.
16
+
17
+ Installation with deb:
18
+
19
+	1. If you're in debian:
20
+
21
+		dpkg -iE openraider_x.x.x.x-1_i386.deb
22
+
23
+	2. If you run RedHat or an RPM distro use alien:
24
+
25
+		alien --to-rpm openraider_x.x.x.x-1_i386.deb
26
+
27
+	   This makes an rpm for you to install:
28
+
29
+		rpm -Uhv openraider-x.x.x.x-2.i386.rpm
30
+
31
+
32
+ Installation with apt:
33
+
34
+	1. Add these lines to /etc/apt/sources.list
35
+
36
+		# OpenRaider
37
+		deb http://openraider.sourceforge.net/debian/ ./
38
+		deb-src http://openraider.sourceforge.net/debian/ ./ 
39
+
40
+	2. Install the openraider package:
41
+
42
+		apt-get update
43
+		apt-get install -u openraider
44
+
45
+
46
+ Installation from source archive:
47
+
48
+	1. Extract source from tarball:
49
+
50
+		tar zxvf openraider-x.x.x.x.tar.gz
51
+
52
+	2. Change to source directory:
53
+
54
+		cd openraider-x.x.x.x/
55
+
56
+	3. Build game source:
57
+
58
+		make
59
+
60
+	4. Install game, data files, and default config:
61
+
62
+		make install
63
+
64
+
65
+
66
+ SETUP
67
+ -----------------------------------------------------------------
68
+
69
+ 1. Setup for the user that will play the game:
70
+
71
+	cd /usr/share/OpenRaider
72
+	sh setup.sh
73
+
74
+
75
+ 2. You can use paks from any Tomb Raider version supported and
76
+    most user made paks for Tomb Raider.  Only PHD, TR1, TR2, TR3, 
77
+    and TR4 paks are supported as of this writing.
78
+
79
+    If you don't own a Tomb Raider game or demo, then you can
80
+    download a pak from:
81
+
82
+	 http://home01.wxs.nl/~eland037/index.htm
83
+
84
+    I suggest 'Yvel Woods' from the 'TR2' section.  It's small,
85
+    but very nice looking still.  Takes only 6-8mins over a 28.8.
86
+    Also Villa Mortal 2 from the 'TR1' section is nice.
87
+
88
+
89
+ 3. Edit your ~/.OpenRaider/OpenRaider.init
90
+
91
+    Edit 'Driver' to your libGL for hardware acceleration:
92
+
93
+       Driver=/usr/lib/libGL.so.1
94
+
95
+    Edit 'Map' lines as needed.  I suggest removing all your
96
+    Map=... lines to begin with, since no maps are bundled with
97
+    this release.  Then add maps as you get them like so:
98
+
99
+    If you got Yvel.zip, then unzip it into ~/.OpenRaider/paks/,
100
+    then add the line:
101
+
102
+       Map=Yvel.tr2
103
+
104
+ 4. Setting up external sound SFX, for TR2 and TR3 paks only.
105
+
106
+    TR2 and TR3 ( both have file extension '.tr2' ) paks don't
107
+    have sound data contained in the pak itself, but instead
108
+    they share a common SFX file ( often MAIN.SFX ) for each
109
+    pak from a given Tomb Raider version.
110
+
111
+    eg 'The Lost Artifact' has a SFX for all it's pak files.
112
+
113
+    Simply link to your SFX file in the same directory as
114
+    your map files using it's name as the base like so:
115
+
116
+	cd ~/.OpenRaider/paks/tr3/
117
+	cp /mnt/cdrom/data/MAIN.SFX .
118
+	for i in *.tr2; do ln -s MAIN.SFX $i.sfx; done
119
+
120
+    This copies your SFX file off the cdrom to your tr3 pak
121
+    directory, then symlinks to all your sfx aliases to MAIN.SFX.
122
+
123
+    OpenRaider currently looks for mapfilename.sfx to find the
124
+    external sound paks for TR2 and TR3 - the other tombraider
125
+    versions have sounds files contained in their own paks. There
126
+    are plans for a metafile wrapper for maps/paks to have better
127
+    control over in game thumbnails, SFX options, and more.
128
+
129
+ 5. Font setup
130
+    
131
+    New for OpenRaider 1.2, OpenRaider now uses TTF fonts to
132
+    generate font textures on the fly.  Just copy a TTF to
133
+    ~/.OpenRaider/data/test.ttf to use it in game. 
134
+
135
+
136
+ KEY BINDINGS
137
+ -----------------------------------------------------------------
138
+
139
+   <Alt><Enter>  - Toggle fullscreen
140
+   <Esc>         - Interactive Level load menu
141
+   `             - Console toggle on/off
142
+   Mouse         - Turn
143
+   MouseBtn Left - Shoot
144
+   w             - Move forward
145
+   s             - Move back
146
+   e             - Move down
147
+   q             - Move up
148
+   r             - Play sound quick test
149
+   /             - Drop a waypoint test ( formally undocumented )
150
+   [ ]           - Adjust idle animation for testing
151
+
152
+
153
+ CONSOLE COMMANDS
154
+ ---------------------------------------------------------------------
155
+     
156
+ Console commands ( w/o "", BOOL is now '0' or '1' for less typing )
157
+ Pressing <UP> will go back to last command entered ( saves typing )
158
+
159
+
160
+    Network
161
+    ------------------------------------------------------------------
162
+    "server"              - Start network listen server
163
+    "killserver"          - Stop network listen server
164
+    "port INT"            - Set network port number
165
+    "connect HOSTNAME"    - Connect to network server at HOSTNAME
166
+    "disconnect"          - Disconnect from network server
167
+
168
+    Game
169
+    ------------------------------------------------------------------
170
+    "quit"                - Quit the game
171
+    "sshot"               - Take screenshot
172
+    "play INT"            - Play sound fx 'NUM'
173
+    "loadlevel STRING"    - Load level with mapname STRING
174
+    "sensitivity.x FLOAT" - Set mouse sens for X movement
175
+    "sensitivity.y FLOAT" - Set mouse sens for Y movement
176
+    "fullscreen"          - Toggle's fullscreen mode
177
+    "walk"                - Toggle world clipping on
178
+    "ghost"               - Toggle world clipping off
179
+    "fly"                 - Toggle world clipping off w/o gravity
180
+    "noclip"              - Toggle world clipping in cycle
181
+    "hop"                 - Toggle room hopping hack
182
+    "showfps BOOL"        - Show FPS
183
+    "mem ARG"             - Where ARG is usage or report
184
+    "resize STRING"       - Change resolution to "xga", "svga", "vga"
185
+
186
+
187
+    Render
188
+    ------------------------------------------------------------------
189
+    "wireframe"           - Render in wireframe ( For debugging )
190
+    "solid"               - Render solid color polygons
191
+    "texture"             - Render with textures
192
+    "vertexlight"         - Render with vertexlights
193
+    "titlescreen"         - Render titlescreen
194
+    "r_animate BOOL"      - Animate all models at once
195
+    "r_upf BOOL"          - Update room render list once per frame
196
+    "r_ponytail BOOL"     - Render ponytail on lara
197
+    "r_pigtails BOOL"     - Render ponytails as pigtails on lara
198
+    "r_ponyangle INT"     - Set rotation of ponytail on lara
199
+    "r_ponyx INT"         - Set Y offset of ponytail on lara
200
+    "r_ponyy INT"         - Set Y offset of ponytail on lara
201
+    "r_ponyz INT"         - Set Z offset of ponytail on lara
202
+    "r_viewmodel INT"     - Load skeletal model with index 'NUM'
203
+    "r_fog BOOL"          - Render fog toggle
204
+    "r_portal BOOL"       - Render 'portals' in rooms
205
+    "r_particle BOOL"     - Render particles
206
+    "r_vmodel BOOL"       - Render view model
207
+    "r_sprite BOOL"       - Render sprites ( room fx and items )
208
+    "r_roommodel BOOL"    - Render room models
209
+    "r_entmodel BOOL"     - Render entity models
210
+    "r_light BOOL"        - Render with GL lights
211
+    "r_ralpha BOOL"       - Render alpha pass for rooms
212
+    "r_vis BOOL"          - Render using visiblity checking
213
+    "r_oneroom"           - Render only the current room
214
+    "r_allrooms"          - Render all rooms in the level ( debug/stress )
215
+
216
+
217
+	Set commands
218
+	------------------------------------------------------------------
219
+	mousegrab <bool>		- Set mouse grabbing on/off
220
+
221
+
222
+
223
+	Stat commands
224
+	------------------------------------------------------------------
225
+	fps				- Toggle showing FPS
226
+	pos				- Show current location
227
+	room
228
+		flags			- Show room flags in hex
229
+
230
+ 
231
+
232
+ REPORT BUGS
233
+ -----------------------------------------------------------------
234
+ When submitting bugs please try to include:
235
+    
236
+    1. Operating system and type of computer 
237
+          eg Linux, x86
238
+
239
+    2. Make and model of your graphics card
240
+          eg Nvidia GeForce 3
241
+
242
+    3. Version of OpenRaider, and any odd libraries
243
+          eg OpenRaider-0.1.0pre6-20020997 built with OpenGL 1.3
244
+
245
+    4. Screenshot for visual bugs
246
+          eg Use 'sshot' in game, zip screenshot and email it
247
+
248
+    5. Text of an errors output by OpenRaider
249
+          eg ERROR: Gates of hell unleashed on world, Hell.cpp:123
250
+
251
+
252
+ ABOUT
253
+ -----------------------------------------------------------------
254
+
255
+ OpenRaider is based on code, specs, and alogrithms from:
256
+ * GooseEgg/Freyja 3d Modelers by Mongoose
257
+ * TR Rosetta Stone spec sheet by Anonymous
258
+ * TRView 1.0.0 by Yuri Zhivago, with patches by Mongoose
259
+
260
+ All code should be GPLed, unless otherwise noted.
261
+
262
+ If you're interested in helping, donating resources, or just
263
+ offer moral support drop me an email or visit irc.linux.com 
264
+ channel #freyja. 
265
+
266
+ -- Terry 'Mongoose' Hendrix II <stu7440@westga.edu>
267
+
268
+
269
+
270
+
271
+ -----------------------------------------------------------------
272
+ OpenRaider FAQ
273
+ -----------------------------------------------------------------
274
+
275
+ 0. How do I build OpenRaider?
276
+
277
+ 1. Will OpenRaider get support for my platform?
278
+
279
+ 2. What cards and drivers have been tested?
280
+
281
+ 3. I don't hear sound, can you help me?
282
+
283
+ 4. I'm getting sefaults loading sounds or debugging OpenRaider.
284
+
285
+ 5. What are all those colors for in Wireframe mode?
286
+
287
+ 6. Why does OpenRaider use TTF fonts?
288
+
289
+ -----------------------------------------------------------------
290
+
291
+ 0. How do I build OpenRaider?
292
+
293
+ 0.1. OpenRaider requires the following as of 2002.01.02; other
294
+      packages may work just as well but haven't been tested:
295
+      + Linux 2.4.16 SMP kernel (Debian distrobution)
296
+      + GCC 2.95.2 compiler and supporting development packages
297
+      + X11 4.1.0 with X11 development package
298
+      + OpenGL 1.2 core and utils development packages
299
+      + SDL 1.2.1 development package
300
+      + OpenAL 0.0.6 development package
301
+      + libz 1.1.3 development package
302
+
303
+ 0.2. If you're missing some of these packages you can install 
304
+      them from your distrobution or source.  There are so many
305
+      distrobutions it wouldn't be practical to have step by step
306
+      information here.  I'll instead list places to get source
307
+      for less commonly installed packages.
308
+
309
+ 0.3. X11 GLX ( Hardware accelerated drivers )
310
+      (X11 4.1.x) Comes bundled with 3d drivers
311
+      (X11 4.0.x) http://dri.sourceforge.net
312
+      (X11 3.3.6) http://utah-glx.sourceforge.net
313
+
314
+      If your 3d card isn't supported in 4.1.x try 3.3.6.
315
+
316
+ 0.4. OpenAL CVS
317
+      cvs -d :pserver:guest@cvs.lokigames.com:/cvs login
318
+      cvs -d :pserver:guest@cvs.lokigames.com:/cvs checkout openal
319
+
320
+ 0.5. SDL CVS
321
+      cvs -d :pserver:guest@cvs.lokigames.com:/cvs login
322
+      cvs -d :pserver:guest@cvs.lokigames.com:/cvs checkout SDL
323
+
324
+ -----------------------------------------------------------------
325
+
326
+ 1. Will OpenRaider get support for my platform?
327
+
328
+ 1.1. It's possible.  I'm only supporting Linux until I get closer
329
+      to a Beta release.  Other platforms that are planned are
330
+      Mac OS X, FreeBSD, Windows NT/9x, and Linux PPC in no order.
331
+ 
332
+      Some of these may already work, but aren't tested.
333
+
334
+ -----------------------------------------------------------------
335
+
336
+ 2. What cards and drivers have been tested?
337
+
338
+ 2.1. DRI ( GLX )
339
+      * Matrox G400 ( Reference card and driver ) 
340
+        * BUG: None known
341
+
342
+      * ATI Radeon ( Last tested 0.0.3-20010604 )
343
+        * BUG: 'lineloop' or polygon outline in solid color
344
+
345
+      * Voodoo 3 ( Last tested 0.0.3-20020104 )
346
+        * BUG: None known
347
+
348
+ -----------------------------------------------------------------
349
+
350
+ 3. I don't hear sound, can you help me?
351
+
352
+ 3.1. Make sure you built in OpenAL support.
353
+
354
+      Make sure you have OpenAL enabled in your OpenRaider.init:
355
+
356
+         [Audio.OpenAL]
357
+         Enable=true
358
+
359
+      Make sure your TR pak type is supported to play sounds.
360
+
361
+      Make sure you have sound files, you can't get sound files 
362
+      redistributed with any other homemade paks besides TR4 paks.
363
+
364
+ -----------------------------------------------------------------
365
+
366
+ 4. I'm getting sefaults loading sounds or debugging OpenRaider.
367
+
368
+ 4.1. Disable OpenAL in your OpenRaider.init:
369
+
370
+         [Audio.OpenAL]
371
+         Enable=false
372
+
373
+      Ever so often this happens with various versions of OpenAL,
374
+      so I consider an OpenAL bug.
375
+
376
+
377
+ 5. What are all those colors for in Wireframe mode?
378
+
379
+ 5.1. Red (thick) lines are portal outlines.
380
+      Red (thin) lines are triangle room polygons.
381
+      Black lines are quadralateral room polygons.
382
+      White meshes are entities.
383
+      Blue meshes are sprites.
384
+      Yellow meshes are room models.
385
+      Green lines with red endpoints are room bboxes.
386
+      Pink dots are visibility checks.
387
+
388
+ -----------------------------------------------------------------
389
+
390
+ 6. Why does OpenRaider use TTF fonts?
391
+
392
+ 6.1. There a few reasons OpenRaider now uses TTF fonts:
393
+      * Lots of quality free TTF fonts on the web these days
394
+      * Custom fonts without the hassle of textile gridding
395
+      * Unicode rendering support ( International text )

+ 26
- 0
Requirements 파일 보기

@@ -0,0 +1,26 @@
1
+
2
+ OpenRaider 
3
+ Requirements ( Updated 2003.07.04 )
4
+ ==================================================================
5
+
6
+ OpenRaider (0.1.2 'Back in Black') Requirements
7
+
8
+	* Object/Entity typing  ( Hel Entity system not required )
9
+	* Hel game physics: jumping, running, swimming, landing
10
+	* Portal transitions corrected based on type and working
11
+	* Damage tracing ( Simple room to room, unblocked by objects )
12
+	* Multiple client support for network play fully working
13
+	* Ability to remove certian object types from a game
14
+	  ( eg Remove single player enemies during DM multiplayer )
15
+	* Timer based event system, like in UR
16
+
17
+ OpenRaider (0.1.2 'Back in Black') Wishlist
18
+	* Using unified Raider engine
19
+	* Console based rebinding
20
+	* Real Menu system
21
+	* Patch up animation
22
+	* Fix colored polygon renderer
23
+	* Timer based animation
24
+	* Seperate System and OpenGL?
25
+	* Automake system?
26
+

+ 95
- 0
TODO 파일 보기

@@ -0,0 +1,95 @@
1
+
2
+ OpenRaider 
3
+ TODO ( Updated 2003.05.17 )
4
+ ==================================================================
5
+
6
+ [Short list]
7
+  * Replace USING_ defs with HAVE_ for the autoconf nutjobs
8
+  * Ponytail loader back in
9
+  * Var system, maybe using mlisp, to control entity/game
10
+    attributes in realtime
11
+  * Use new unified sector/fd system to have better world clipping
12
+  * Get event system up
13
+  * Animatated textures (tr2_opengl_ref:2027) 
14
+  * Any little bit of abstraction to reduce interfacing
15
+    with TombRaider's complexity ( Offload more work to
16
+    TombRaider class, but hide it behind abstract API )
17
+  * Replace Render::drawModelMesh with OpenGLMesh use
18
+  * Move OpenGLMesh array use back in...
19
+  * Replace color_tri_t, texture_tri_t, and model_mesh_t
20
+    with OpenGLMesh?
21
+  * Weapons animations
22
+  * Better user interface
23
+  * System abstractions should be agregates not inherited
24
+    also remove static members and force singleton
25
+    Split OpenGL dep from System
26
+  * Text subsystem needs looking at for possible overhaul soon
27
+  * Checksum matches on torsos to do special animation per 
28
+    known models like in my freyja demo  ;)
29
+
30
+ [OpenRaider.cpp]
31
+  * Remove skeletal_model_t dependency
32
+  * Add client system
33
+  * Add event system
34
+  * Remove all Tomb Raider format dependence, move to generics
35
+    * processMoveable needs to use generics
36
+    * processMoveables needs to use generics and metadata
37
+    * processSprites needs to use generics 
38
+    * processPakSounds needs to use generics and metadata
39
+    * loadLevel's looping loaders need to move into the methods 
40
+      which would reduce function calls and section off better
41
+
42
+ ==================================================================
43
+
44
+ [General]
45
+  * Automatic unit testing per system/agent
46
+  * Scrict time based event/animation frames
47
+  * Sound sampling to allow various rates traded off for ram
48
+  * Account for TR3+ alpha in polygon building  
49
+  * AutoAim for 3rd person view
50
+  * Metadata pak wrappers for sfx linking and previews
51
+
52
+ [ TombRaider API ]
53
+  * Add TR5 support and rewrite Room structures and etc as
54
+    seperate classes as collections inside TombRaider class
55
+    Move parsing into TombRaider as much as possible and improve
56
+    memory use of TombRaider to perhaps read a room at a time
57
+    off disk ( PS2 has limited memory )
58
+
59
+ [Interface]
60
+  * Multilevel menu system
61
+  * Keyboard setup in RC
62
+  * Key command event system needed, move it into System
63
+  * Improve menu system and map select screens
64
+  * Factor out a CVARS/RC system 
65
+  * Gobal options (CVARS) class
66
+  * Model and Map selection via preview of some kind like a pic
67
+  * Improve console: history, autocomplete
68
+
69
+ [Network]
70
+  * Playable multiplayer release
71
+  * TCP use for moving data like HTML and models perhaps
72
+  * HTML forms filler for automatic bug reporting ala 'talkback'
73
+  * Handle cheat proxies: Bad yaws, pos, firing rates
74
+  * Have server maintain game state
75
+  * Allow client checks to remove players clientside on peer mode
76
+
77
+ [Renderer]
78
+  * Animation blending ( Rewrite of translator/animator )
79
+    Seperate animations from models also add multibone support
80
+    and weld TR4+ lara vertices ( skin )
81
+  * New skeletal animation system ( current one mem wasteful )
82
+  * Use room light intensity level for static mesh (room model) rendering
83
+  * Add particles for weather, water drip/splash, metal material collisions, 
84
+    gunfire, etc
85
+  * Account for room attrib flags for base visual and special fx in that room
86
+  * Account for room vertices attrib flag for visual and special fx
87
+  * Needs real portal visibility system
88
+  * TR4 lara may needs to have mesh generation to fill in her gaps by
89
+    looking for vertex 'rings' that match from the 2 meshes where gaps happen
90
+  * Animated textures
91
+  * Fix lighting to work in vertexlight as well as texture
92
+     modes better
93
+  * Better visiblity with full portal system
94
+  * Better out of world camera handling, add smooth pan, drags
95
+

+ 4
- 0
autogen.sh 파일 보기

@@ -0,0 +1,4 @@
1
+#!/bin/sh
2
+rm -f depend
3
+make depend 2> /dev/null
4
+make $@

+ 86
- 0
data/OpenRaider.init 파일 보기

@@ -0,0 +1,86 @@
1
+# This is the Open Raider RC file
2
+#####################################
3
+
4
+[Video.OpenGL]
5
+Driver=/usr/lib/libGL.so.1
6
+Width=640
7
+Height=480
8
+FastCard=true
9
+FullScreen=false
10
+Font=~/.OpenRaider/data/test.ttf
11
+
12
+[Audio.OpenAL]
13
+Enable=true
14
+
15
+[Network.Server]
16
+Enable=false
17
+#Name=OpenRaider Server Beta 1
18
+#Dedicated=true
19
+Port=27910
20
+
21
+[Input.Mouse]
22
+SensitivityX=2.0
23
+SensitivityY=0.5
24
+
25
+[OpenRaider.Engine]
26
+PakDir=~/.OpenRaider/paks/
27
+AudioDir=~/.OpenRaider/music/
28
+HomeDir=~/.OpenRaider/data/
29
+DisplayFPS=false
30
+MapDebug=false
31
+ModelDebug=false
32
+DumpTexture=false
33
+#Script=tr3/tombPC.dat
34
+#Music=tr4/039_TR4_Title_Q10.wav
35
+#Music=tr4/103_A3_Out_Night.wav
36
+#Music=tr4/108_A8_Coastal.wav
37
+Map=custom/Yvel.tr2
38
+Map=custom/villa2.phd
39
+Map=custom/fenician1.phd
40
+Map=custom/1984.tr2
41
+Map=custom/bigchamber.tr4
42
+Map=custom/cleopal.tr4
43
+Map=custom/khysos.tr4
44
+Map=custom/Nasa.tr2
45
+Map=custom/mansionfrost.tr2
46
+Map=tr1/gym.phd
47
+Map=tr1/level1.phd
48
+Map=tr1/level2.phd
49
+Map=tr2/unwater.tr2
50
+Map=tr3/willsden.tr2
51
+Map=tr3/undersea.tr2
52
+Map=tr3/scotland.tr2
53
+Map=tr3/HOUSE.TR2
54
+Map=tr3/zoo.tr2
55
+Map=tr3/slinc.tr2
56
+Map=tr3/temple.tr2
57
+Map=tr3/shore.tr2
58
+Map=tr3/chunnel.tr2
59
+Map=tr4/angkor1.tr4
60
+Map=tr4/ang_race.tr4
61
+Map=tr4/karnak1.tr4
62
+Map=tr4/lake.tr4
63
+Map=tr4/settomb1.tr4
64
+Map=tr4/settomb2.tr4
65
+Map=tr4/title.tr4
66
+Map=tr5/demo.trc
67
+
68
+[OpenRaider.Console]
69
+bind +console 96
70
+bind +forward 119
71
+bind +backward 115
72
+bind +jump 32
73
+bind +crouch 99
74
+bind +left 97
75
+bind +right 100
76
+#bind +attack 122
77
+#md3 data/models/players/laracroft	# Load this Md3 directory
78
+#r_light 1				# Enable GL Lighting
79
+#r_fog 1				# Enable depth fog
80
+#r_particle 1				# Enable particle test
81
+#r_portal 1				# Enable portal rendering
82
+#set mousegrab 1			# Enable mouse grabbing
83
+
84
+
85
+# Support for external configs
86
+@include ~/.OpenRaider/custom.cfg

BIN
data/font-0.tga 파일 보기


BIN
data/particle.tga 파일 보기


BIN
data/sample.wav 파일 보기


BIN
data/snow.tga 파일 보기


BIN
data/snow2.tga 파일 보기


BIN
data/splash.tga 파일 보기


BIN
data/test.ttf 파일 보기


BIN
data/white.tga 파일 보기


+ 13
- 0
deps.sh 파일 보기

@@ -0,0 +1,13 @@
1
+# Mongoose - This is a simple dep line generator
2
+#
3
+# Call it passing CFLAGS and a source filename
4
+# to generate a dep line
5
+
6
+echo "# deps.sh was passed:"
7
+echo -n "# "
8
+echo $@
9
+
10
+echo "# Then made this line:"
11
+echo -n "\$(BUILDDIR)/"
12
+cc -MM $@
13
+printf "\t \$(DO_CC)\n\n"

+ 308
- 0
doc/TR4-Format.html 파일 보기

@@ -0,0 +1,308 @@
1
+<html>
2
+<head>
3
+<style>
4
+H2 { background-color:#A0DAFE }
5
+table.code	{ background-color:#FECEA0 }
6
+td.type_data { width:80; font-weight:bold }
7
+td.comment { background-color:#FFB369 }
8
+</style>
9
+</head>
10
+<body>
11
+
12
+<center>
13
+<h1>TR4 file format</h1>
14
+</center>
15
+
16
+<br>
17
+<h3>Contributors: Rgbold, Turbo Pascal, Yuri Zhivago, Dr. Willard, TRWad, Popov, others ?</h3>
18
+
19
+This document describes only differences between TR3 and TR4 file format. Please, refer to the TRosetta Stone document
20
+to get informations about TR1 / TR2 and TR3 file format.<br>
21
+This document is not complete, there are yet some unknowns. Feel free to fill in the blanks and let us know that we can
22
+modify this document.
23
+<br><br>
24
+<ul>
25
+<li><a href="#TypesUsed">Types used</a></li>
26
+<li><a href="#GeneralFormat">General format of a .TR4 file</a></li>
27
+<li><a href="#GeometryBlock">Format of the geometry block</a></li>
28
+	<ul>
29
+		<li><a href="#RoomLights">Room Lights</a></li>
30
+		<li><a href="#TriQuads">Tri & Quad polys in mesh objects</a></li>
31
+		<li><a href="#FlyByCameras">Flyby cameras</a></li>
32
+		<li><a href="#AIData">Cinematic frames replaced by AI data</a></li>
33
+		<li><a href="#SpriteTexture">Changes in tr2_sprite_texture</a></li>
34
+		<li><a href="#MeshObjects">Mesh objects</a></li>
35
+		<li><a href="#ObjectTextures">Object textures</a></li>
36
+		<li><a href="#Animations">Animations</a></li>
37
+		<li><a href="#Miscellaneous">Miscellaneous</a></li>
38
+	</ul>
39
+</ul>
40
+<br>
41
+<hr>
42
+<h2><a name="TypesUsed">Types used</a></h2>
43
+
44
+<table border="1">
45
+<tr bgcolor="#e0e0e0"><th>name</th><th>size</th></tr>
46
+<tr><th>bit8</th><td>a signed 8 bits</td></tr>
47
+<tr><th>bitu8</th><td>an unsigned 8 bits</td></tr>
48
+<tr><th>bit16</th><td>a signed 16 bits</td></tr>
49
+<tr><th>bitu16</th><td>an unsigned 16 bits</td></tr>
50
+<tr><th>bit32</th><td>a signed 32 bits</td></tr>
51
+<tr><th>bitu32</th><td>an unsigned 32 bits</td></tr>
52
+<tr><th>float</th><td>a 4 bytes float</td></tr>
53
+</table>
54
+<br>
55
+Other types can be used: if it's the case, refer to the TRosetta Stone document to have their definitions (for eg: tr2_color)
56
+
57
+<h2><a name="GeneralFormat">General format of a .TR4 file</a></h2>
58
+
59
+<table class="code" cellspacing="0">
60
+<tr><td class="type_data">bitu32</td><td>"TR4",0</td><td>&nbsp;</td></tr>
61
+<tr><td class="type_data">bitu16</td><td>Number of non bumped room tiles</td><td>&nbsp;</td></tr>
62
+<tr><td class="type_data">bitu16</td><td>Number of tiles for objects</td><td>&nbsp;</td></tr>
63
+<tr><td class="type_data">bitu16</td><td>Number of bumped room tiles</td><td>&nbsp;</td></tr>
64
+<tr><td class="type_data">bitu32</td><td>Uncompressed size of texture 1</td><td>&nbsp;</td></tr>
65
+<tr><td class="type_data">bitu32</td><td>Compressed size of texture 1</td><td>&nbsp;</td></tr>
66
+<tr><td class="type_data">bitu8[]</td><td>(compressed) Texture 1 (32 bits texture)</td><td>&nbsp;</td></tr>
67
+<tr><td class="type_data">bitu32</td><td>Uncompressed size of texture 2</td><td>&nbsp;</td></tr>
68
+<tr><td class="type_data">bitu32</td><td>Compressed size of texture 2</td><td>&nbsp;</td></tr>
69
+<tr><td class="type_data">bitu8[]</td><td>(compressed) Texture 2 (16 bits texture)</td><td>&nbsp;</td></tr>
70
+<tr><td class="type_data">bitu32</td><td>Uncompressed size of texture 3</td><td>&nbsp;</td></tr>
71
+<tr><td class="type_data">bitu32</td><td>Compressed size of texture 3</td><td>&nbsp;</td></tr>
72
+<tr><td class="type_data">bitu8[]</td><td>(compressed) Texture 3 (32 bits texture)<td>-> a 256x512 texture with the font & sky</td></tr>
73
+<tr><td class="type_data">bitu32</td><td>Uncompressed size of geometry</td><td>&nbsp;</td></tr>
74
+<tr><td class="type_data">bitu32</td><td>Compressed size of geometry</td><td>&nbsp;</td></tr>
75
+<tr><td class="type_data">bitu8[]</td><td>(compressed) <a href="#GeometryBlock">Geometry</a></td><td>&nbsp;</td></tr>
76
+<tr><td class="type_data">bitu32</td><td>num_sounds</td><td>&nbsp;</td></tr>
77
+<tr><td colspan="3"><b>num_sounds * struct TR4_TrailingSound</b></td></tr>
78
+<tr><td colspan="3">{</td></tr>
79
+<tr><td class="type_data">bitu32</td><td>UncompSize;</td><td class="comment">// Uncompressed sound size</td></tr>
80
+<tr><td class="type_data">bitu32</td><td>CompSize;</td><td class="comment">// Compressed sound size -> compression is ADPCM (WAV format)</td></tr>
81
+<tr><td class="type_data">bitu8</td><td>sound_data[];</td><td class="comment">// data of the sound - size is CompSize bitu8</td></tr>
82
+<tr><td colspan="3">}</td></tr>
83
+</table>
84
+<br>
85
+<u>Notes</u>
86
+
87
+<ul>
88
+<li>the compression used is the zlib one</li>
89
+<li>sounds have a Riff wave format</li>
90
+<li>for the level to be played correctly with the TRLE engine, sounds must not be compressed.
91
+In addition, they must be at 22.05 Khz / 16 bits per sample / mono (at least, this format works !)</li>
92
+</ul>
93
+
94
+<h2><a name="GeometryBlock">Format of the geometry block</a></h2>
95
+
96
+-> same structures than in TR3 format, except:
97
+
98
+<h3><a name="RoomLights">Room Lights</a></h3>
99
+
100
+<table class="code" cellspacing="0">
101
+<tr><td colspan="3" class="comment">// Follows a D3D light structure, I think, could be wrong (46 bytes)</td></tr>
102
+<tr><td colspan="3">typedef struct</td></tr>
103
+<tr><td colspan="3">{</td></tr>
104
+<tr><td class="type_data">bit32</td><td>Xposition;</td><td class="comment">// world coords</td></tr>
105
+<tr><td class="type_data">bit32</td><td>Yposition;</td><td class="comment">// world coords</td></tr>
106
+<tr><td class="type_data">bit32</td><td>Zposition;</td><td class="comment">// world coords</td></tr>
107
+<tr><td class="type_data">tr2_colour</td><td>Color;</td><td class="comment">// three bytes rgb values</td></tr>
108
+<tr><td class="type_data">bitu8</td><td>LightType;</td><td class="comment">// same as D3D (i.e. 2 is for spotlight)</td></tr>
109
+<tr><td class="type_data">bitu8</td><td>unknown;</td><td class="comment">// always 0xff?</td></tr>
110
+<tr><td class="type_data">bitu8</td><td>Intensity;</td><td class="comment">&nbsp;</td></tr>
111
+<tr><td class="type_data">float</td><td>In;</td><td class="comment">&nbsp;</td></tr>
112
+<tr><td class="type_data">float</td><td>Out;</td><td class="comment">&nbsp;</td></tr>
113
+<tr><td class="type_data">float</td><td>Length;</td><td class="comment">&nbsp;</td></tr>
114
+<tr><td class="type_data">float</td><td>Cutoff;</td><td class="comment">&nbsp;</td></tr>
115
+<tr><td class="type_data">float</td><td>X,Y,Z;<td class="comment">// direction??</td></tr>
116
+<tr><td colspan="3">} <b>tr4_room_light</b>;</td></tr>
117
+</table>
118
+
119
+<h3><a name="TriQuads">Tri & Quad polys in mesh objects</a></h3>
120
+
121
+<table class="code" cellspacing="0">
122
+<tr><td colspan="3" class="comment">// Triangle surface (10 bytes)</td></tr>
123
+<tr><td colspan="3">typedef struct</td></tr>
124
+<tr><td colspan="3">{</td></tr>
125
+<tr><td class="type_data">bitu16</td><td>Vertices[3];</td><td class="comment">// The 3 vertices of a tri</td></tr>
126
+<tr><td class="type_data">bitu16</td><td>Texture;</td><td class="comment">// Object-texture index</td></tr>
127
+<tr><td class="type_data">bitu16</td><td>Lighting;</td><td class="comment">// transparency flag & strength of the hilight</td></tr>
128
+<tr><td colspan="3">} <b>tr4_face3</b>;</td></tr>
129
+</table>
130
+<br>
131
+<table class="code" cellspacing="0">
132
+<tr><td colspan="3" class="comment">// Quadrangle surface (12 bytes)</td></tr>
133
+<tr><td colspan="3">typedef struct</td></tr>
134
+<tr><td colspan="3">{</td></tr>
135
+<tr><td class="type_data">bitu16</td><td>Vertices[4];</td><td class="comment">// The 4 vertices of a quad</td></tr>
136
+<tr><td class="type_data">bitu16</td><td>Texture;</td><td class="comment">// Object-texture index</td></tr>
137
+<tr><td class="type_data">bitu16</td><td>Lighting;</td><td class="comment">// transparency flag & strength of the hilight</td></tr>
138
+<tr><td colspan="3">} <b>tr4_face4</b>;</td></tr>
139
+</table>
140
+<br>
141
+The new field Lighting has this layout:<br><br>
142
+
143
+<table border="1">
144
+<td><nobr>Bit 0</nobr></td><td>if set, alpha channel = intensity (same meaning that when the Attribute field of tr2_object_texture is 2. Cf TRosetta stone document)</td></tr>
145
+<td valign="top"><nobr>Bits 1->7</nobr></td><td>strength of the hilight. In TR4, objects can exhibit some kind of light reflection when seen from some particular angles.
146
+These bits give the strength of this effect: the more bigger the value is, the more visible is the effect.</td></tr>
147
+</table>
148
+<br>
149
+<u>Notes</u>
150
+
151
+<ul>
152
+<li>As in TR3, the Texture field can have its bit 15 set -> only for tris & quads used by rooms - unknown meaning</li>
153
+<li>The extra field Lighting exists only for tris / quads making <u>meshes</u> (used by moveables and static meshes), <u>not</u>
154
+for tris / quads making rooms !</li>
155
+</ul>
156
+
157
+<h3><a name="FlyByCameras">Flyby cameras</a></h3>
158
+
159
+Before SoundSources (cf. TRosetta stone document) is a new field for Flyby_Camera data:<br><br>
160
+
161
+<table class="code" cellspacing="0">
162
+<tr><td class="type_data">bitu32</td><td>Number_of_FBCameras;</td><td>&nbsp;</td></tr>
163
+<tr><td colspan="3" class="comment">// Data for a flyby camera (40 bytes)</td></tr>
164
+<tr><td colspan="3">typedef struct</td></tr>
165
+<tr><td colspan="3">{</td></tr>
166
+<tr><td class="type_data">bit32</td><td>pos[6];</td><td class="comment">// Positions ? (x1,y1,z1,x2,y2,z2)</td></tr>
167
+<tr><td class="type_data">bitu8</td><td>index[2];</td><td class="comment">// A pair of indices</td></tr>
168
+<tr><td class="type_data">bitu16</td><td>Unknown[5];</td><td class="comment">// ??</td></tr>
169
+<tr><td class="type_data">bit32</td><td>ID;</td><td class="comment">// Index of something</td></tr>
170
+<tr><td colspan="3">} <b>tr4_extra_camera</b>;</td></tr>
171
+</table>
172
+
173
+<h3><a name="AIData">Cinematic frames replaced by AI data</a></h3>
174
+
175
+There are no cinematic frames in TR4. Instead of that, there is the following structure:<br><br>
176
+
177
+<table class="code" cellspacing="0">
178
+<tr><td class="type_data">bitu32</td><td>num_AIData;</td><td>// this field replaces the bitu16 NumCinematicFrames of TR1/2/3 levels</td></tr>
179
+<tr><td colspan="3" class="comment">// Data for a AI object (24 bytes)</td></tr>
180
+<tr><td colspan="3">typedef struct</td></tr>
181
+<tr><td colspan="3">{</td></tr>
182
+<tr><td class="type_data">bitu16</td><td>ObjectID;</td><td class="comment">// the objectID from the AI object (AI_FOLLOW is 402)</td></tr>
183
+<tr><td class="type_data">bitu16</td><td>Room;</td><td class="comment">&nbsp;</td></tr>
184
+<tr><td class="type_data">bit32</td><td>X,Y,A;</td><td class="comment">&nbsp;</td></tr>
185
+<tr><td class="type_data">bitu16</td><td>OCB;</td><td class="comment">&nbsp;</td></tr>
186
+<tr><td class="type_data">bitu16</td><td>Flags;</td><td class="comment">// The trigger flags (button 1-5, first button has value 2)</td></tr>
187
+<tr><td class="type_data">bit32</td><td>Angle;</td><td class="comment">// rotation</td></tr>
188
+<tr><td colspan="3">} <b>tr4_AI_object</b>;</td></tr>
189
+</table>
190
+
191
+<h3><a name="SpriteTexture">Changes in tr2_sprite_texture</a></h3>
192
+
193
+This structure has the same size than before but some of its fields have changed of meaning:<br><br>
194
+
195
+<table class="code" cellspacing="0">
196
+<tr><td colspan="3" class="comment">// Data for a sprite (16 bytes)</td></tr>
197
+<tr><td colspan="3">typedef struct</td></tr>
198
+<tr><td colspan="3">{</td></tr>
199
+<tr><td class="type_data">bitu16</td><td>Tile;</td><td class="comment">&nbsp;</td></tr>
200
+<tr><td class="type_data">bitu8</td><td>unknown1;</td><td class="comment">// ??</td></tr>
201
+<tr><td class="type_data">bitu8</td><td>unknown2;</td><td class="comment">// ??</td></tr>
202
+<tr><td class="type_data">bit16</td><td>Width;</td><td class="comment">// = (real_width-1) * 256</td></tr>
203
+<tr><td class="type_data">bit16</td><td>Height;</td><td class="comment">// = (real_height-1) * 256</td></tr>
204
+<tr><td class="type_data">bit16</td><td>x1,y1;</td><td class="comment">// top-left corner of the texture</td></tr>
205
+<tr><td class="type_data">bit16</td><td>x2,y2;</td><td class="comment">// bottom-right corner of the texture</td></tr>
206
+<tr><td colspan="3">} <b>tr4_sprite_texture</b>;</td></tr>
207
+</table>
208
+<br>
209
+In addition, the NumSpriteTextures field (see TRosetta stone) is preceeded by the 3 ASCII bytes 'SPR'
210
+
211
+<h3><a name="MeshObjects">Mesh objects</a></h3>
212
+
213
+Meshes have no longer colored tris / quads. So, NumColoredRectangles, ColoredRectangles[], NumColoredTriangles, ColoredTriangles[]
214
+no longer exist in the tr2_mesh structure (cf. TRosetta stone document for the tr2_mesh_structure).
215
+
216
+<h3><a name="ObjectTextures">Object textures</a></h3>
217
+
218
+The NumObjectTextures field (see TRosetta stone) is now preceeded by \0TEX (4 bytes -> \0 is the bitu8 value 0). The structure
219
+tr2_object_texture itself has changed:<br><br>
220
+
221
+<table class="code" cellspacing="0">
222
+<tr><td colspan="3" class="comment">// Data for an object texture (38 bytes vice 20 in TR1/2/3)</td></tr>
223
+<tr><td colspan="3">typedef struct</td></tr>
224
+<tr><td colspan="3">{</td></tr>
225
+<tr><td class="type_data">bitu16</td><td>Attribute;</td><td class="comment">// same meaning than in TR3</td></tr>
226
+<tr><td class="type_data">bitu16</td><td>Tile;</td><td class="comment">// same meaning than in TR3</td></tr>
227
+<tr><td class="type_data">bitu16</td><td>Flags;</td><td class="comment">// new in TR4</td></tr>
228
+<tr><td class="type_data">tr2_object_texture_vert</td><td>Vertices[4];</td><td class="comment">// same meaning than in TR3</td></tr>
229
+<tr><td class="type_data">bitu32</td><td>Unknown1,Unknown2;</td><td class="comment">// new in TR4: x & y offset in something ?</td></tr>
230
+<tr><td class="type_data">bitu32</td><td>XSize,YSize;</td><td class="comment">// new in TR4: width-1 & height-1 of the object texture</td></tr>
231
+<tr><td colspan="3">} <b>tr4_object_texture</b>;</td></tr>
232
+</table>
233
+<br>
234
+Meaning of Flags:<br><br>
235
+
236
+<table border="1">
237
+<tr><td><nobr>Bits 0->2</nobr></td><td>mapping correction. It seems that these bits change the way the texture is applied...</td></tr>
238
+<tr><td><nobr>Bit 11->12</nobr></td><td>2 bits giving the bump mapping type. Can be 0x01 or 0x10. It's 0x00 if not bump mapped. Only textures
239
+for room or animated textures can be bump mapped, not meshes</td></tr>
240
+<tr><td><nobr>Bit 15</nobr></td><td>if set, the texture is for a tri/quad from a room or animated texture. If not set, the texture
241
+is for a mesh</td></tr>
242
+</table>
243
+<br>
244
+<u>Notes</u>
245
+
246
+<ul>
247
+<li>rgbold said that the Attribute field could have a value of "2" for 2-sided textures, but it seems wrong: this field has not changed in
248
+TR4 and the value "2" seems to mean alpha=intensity as in TR3</li>
249
+<li>Unknown1 and Unknown2 are said as beeing "XOffset and YOffset" by Dr.Willard, but it seems that changing these values do nothing...
250
+In addition, they seem not related to a second texturing as thought by Dr.Willard</li>
251
+<li>Tile is really bits 0 through 14: bit 15 is a flag which says, if set, that this object texture is for a triangle. If not set,
252
+the object texture is for a quad.</li>
253
+<li>In the texture coords now 0 is used for low value vice 1 (see the Xcoordinate and Ycoordinate fields of the
254
+tr2_object_texture_vert structure in the TRosetta Stone document)</li>
255
+</ul>
256
+
257
+<h3><a name="Animations">Animations</a></h3>
258
+
259
+The tr2_animation structure has changed a little:<br><br>
260
+
261
+<table class="code" cellspacing="0">
262
+<tr><td colspan="3" class="comment">// Data for an animation structure (40 bytes vice 32 in TR1/2/3)</td></tr>
263
+<tr><td colspan="3">typedef struct</td></tr>
264
+<tr><td colspan="3">{</td></tr>
265
+<tr><td class="type_data">bitu32</td><td>dwFrameOffset;</td><td class="comment">// same meaning than in TR3</td></tr>
266
+<tr><td class="type_data">bitu8</td><td>bFrameRate;</td><td class="comment">// same meaning than in TR3</td></tr>
267
+<tr><td class="type_data">bitu8</td><td>bFrameSize;</td><td class="comment">// same meaning than in TR3</td></tr>
268
+<tr><td class="type_data">bitu16</td><td>wStateId;</td><td class="comment">// same meaning than in TR3</td></tr>
269
+<tr><td class="type_data">bit16</td><td>Unknown;</td><td class="comment">// same meaning than in TR3</td></tr>
270
+<tr><td class="type_data">bit16</td><td>sSpeed;</td><td class="comment">// same meaning than in TR3</td></tr>
271
+<tr><td class="type_data">bitu16</td><td>wAccelLo;</td><td class="comment">// same meaning than in TR3</td></tr>
272
+<tr><td class="type_data">bit16</td><td>sAccelHi;</td><td class="comment">// same meaning than in TR3</td></tr>
273
+<tr><td class="type_data">bitu8</td><td>Unknown2[8];</td><td class="comment">// new in TR4</td></tr>
274
+<tr><td class="type_data">bitu16</td><td>wFrameStart;</td><td class="comment">// same meaning than in TR3</td></tr>
275
+<tr><td class="type_data">bitu16</td><td>wFrameEnd;</td><td class="comment">// same meaning than in TR3</td></tr>
276
+<tr><td class="type_data">bitu16</td><td>wNextAnimation;</td><td class="comment">// same meaning than in TR3</td></tr>
277
+<tr><td class="type_data">bitu16</td><td>wNextFrame;</td><td class="comment">// same meaning than in TR3</td></tr>
278
+<tr><td class="type_data">bitu16</td><td>wNumStateChanges;</td><td class="comment">// same meaning than in TR3</td></tr>
279
+<tr><td class="type_data">bitu16</td><td>wStateChangeOffset;</td><td class="comment">// same meaning than in TR3</td></tr>
280
+<tr><td class="type_data">bitu16</td><td>wNumAnimCommands;</td><td class="comment">// same meaning than in TR3</td></tr>
281
+<tr><td class="type_data">bitu16</td><td>wAnimCommand;</td><td class="comment">// same meaning than in TR3</td></tr>
282
+<tr><td colspan="3">} <b>tr4_animation</b>;</td></tr>
283
+</table>
284
+<br>
285
+<u>Notes</u>
286
+
287
+<ul>
288
+<li>The Unknown2[8] are not always 0 as thought by rgbold. When non zero, it seems that these bytes have the same sort of values than
289
+the existing (Unknown, sSpeed, wAccelLo, sAccelHi) fields (which count 8 bytes too). So these 8 unknowns could be
290
+(Unknown2,sSpeed2,wAccelLo2, sAccelHi2) fields...</li>
291
+<li>The wNumAnimCommands field can have wrong values (0xaaaa or 0xaaa7 for eg): don't know why, but if > 256, you could consider
292
+it to be 0 (that's what is done in TrViewer, but the real value is recorded to be use later when the level is saved: maybe
293
+the TR Engine needs this value...)</li>
294
+<li>Angles in animation frames have changed: in the single axe rotation case, you must multiply by 360/4096 instead
295
+of 360/1024 to get the angle in degrees (see the TRosetta Stone document for more informations about animation frames)</li>
296
+</ul>
297
+
298
+<h3><a name="Miscellaneous">Miscellaneous</a></h3>
299
+
300
+<ul>
301
+<li>There are no 8bit or 16 bit palettes</li>
302
+<li>There is no lightmap</li>
303
+<li>There are no 8 bits textures</li>
304
+<li>TR4 levels have an additional 6 bytes at the end of the uncompressed geometry block that seem to be always 0</li>
305
+</ul>
306
+
307
+</body>
308
+</html>

+ 473
- 0
doc/TR4-Notes.html
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 531
- 0
doc/TR5-Format.html 파일 보기

@@ -0,0 +1,531 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
2
+<!-- ================================================================================  -->
3
+<!-- This HTML file was created by AbiWord.                                            -->
4
+<!-- AbiWord is a free, Open Source word processor.                                    -->
5
+<!-- You may obtain more information about AbiWord at www.abisource.com                -->
6
+<!-- ================================================================================  -->
7
+
8
+<html>
9
+<head>
10
+<meta http-equiv="content-type" content="text/html; charset=UTF-8" >
11
+<title>/home/mongoose/download/TR5format.html</title>
12
+<style type="text/css">
13
+body
14
+{
15
+	font-family: "Times New Roman";
16
+	margin-top: 0pt;
17
+	font-variant: normal;
18
+	margin-left: 0pt;
19
+	text-indent: 0in;
20
+	widows: 2;
21
+	font-style: normal;
22
+	font-weight: normal;
23
+	text-decoration: none;
24
+	color: 000000;
25
+	text-align: left;
26
+	margin-bottom: 0pt;
27
+	margin-right: 0pt;
28
+	font-size: 12pt;
29
+	font-stretch: normal;
30
+	background-color: #ffffff;
31
+}
32
+
33
+@media print
34
+{
35
+	body
36
+	{
37
+		padding-top: 1in; padding-bottom: 1in;
38
+		padding-left: 1in; padding-right: 1in;
39
+	}
40
+}
41
+
42
+.Default
43
+{
44
+	color: #000000;
45
+	font-family: "MS Sans Serif";
46
+	font-size: 10pt;
47
+}
48
+
49
+</style>
50
+</head>
51
+<body><div>
52
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'Times New Roman'; font-size: 16.000000pt">TR5 file format</span></p>
53
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
54
+</p>
55
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 14.000000pt">Note:</span></p>
56
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; items in </span><span style="text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">blue</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> are described in the TRosettaStone document.</span></p>
57
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; items in </span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">red</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> are unique/different and are described, if known,</span></p>
58
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 14.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in this document. </span></p>
59
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
60
+</p>
61
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">Disclaimer:&nbsp; This document is at a very early stage and all attempts to verify this information have been made.</span></p>
62
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HOWEVER, I do not guarantee any of the information to be correct. If you find something wrong, or better, if you find something new, please share it.&nbsp;</span></p>
63
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
64
+</p>
65
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This document describes a possible file format. It does not contain any algorithims. It does not contain any computer program&nbsp; source code. As such this document and it's contents cannot be copyrighted and cannot be considered a copyright infringement. HOWEVER, I am not a lawyer.</span></p>
66
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
67
+</p>
68
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thanks,</span></p>
69
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Roy</span></p>
70
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
71
+</p>
72
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
73
+</p>
74
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
75
+</p>
76
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">Note: Structures are NOT C++ structures.</span></p>
77
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Terminology for consistency with TRosettaStone document:&nbsp;</span></p>
78
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">	bit8	char</span></p>
79
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">	bitu8	unsigned char</span></p>
80
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">	bit16	short int</span></p>
81
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">	bitu16	unsigned short int</span></p>
82
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">	bit32	long</span></p>
83
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">	bitu32	unsigned long</span></p>
84
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
85
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">*********************************************************************</span></p>
86
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32 Version</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // version "TR4",0 (4 bytes)</span></p>
87
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu16 NumRoomTextiles</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // number of room texture tiles (2 bytes)</span></p>
88
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu16 NumObjectTextiles</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // number of object texture tiles (2 bytes)</span></p>
89
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu16 NumBumpMapTextiles</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // number of bump map texture tiles (2 bytes)</span></p>
90
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32 Textile32UncompressedSize</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // 32 bit textures uncompressed size</span></p>
91
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32 Textile32CompressedSize</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // 32 bit textures compressed size </span></p>
92
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu8</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">&nbsp;</span><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> Textile32[Textile32CompressedSize]</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // data bytes for the 32 bit textures (ZLIB compressed data)</span></p>
93
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32 Textile16UncompressedSize</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // 16 bit textures uncompressed size </span></p>
94
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32 Textile16CompressedSize</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // 16 bit textures compressed size </span></p>
95
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu8 Textile16[Textile16CompressedSize]</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // data bytes for the 16 bit textures (ZLIB compressed data)</span></p>
96
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32 Textile32MiscUncompressedSize</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // 32 bit misc. (lettering, sky, etc) textures uncompressed size</span></p>
97
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32 Textile32MiscCompressedSize</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // 32 bit misc.textures compressed size </span></p>
98
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu8 Textile32Misc[Textile32MiscCompressedSize]</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // data bytes for the 32 bit misc textures (ZLIB compressed data)</span></p>
99
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">32*bit8 Seperator</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // 32 bytes of 0x00 (Late Note: Michiel has discovered the first 4 bytes here are 2 bitu16 flags</span></p>
100
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">for Lara type and weather, msg posted on the 'F*cking Pop Ups'&nbsp; board somewhere )</span></p>
101
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32 LevelDataSize1</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // size of level data (count after LevelDataSize2 bitu32)</span></p>
102
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32 LevelDataSize2</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; //&nbsp; repeat of above</span></p>
103
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32 Seperator</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // 4 bytes of 0x00</span></p>
104
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32 NumRooms</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // number of rooms (maximum 255 rooms (0-254)) (4 bytes)</span></p>
105
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 room</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> Rooms[NumRooms]; // the actual room data </span></p>
106
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumFloorData; // number of floor data bitu16's to follow (4 bytes) </span></p>
107
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu16</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> FloorData[NumFloorData]; // floor data (NumFloorData * 2 bytes) </span></p>
108
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
109
+</p>
110
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumMeshData; // number of bitu16's of mesh data to follow (=Meshes[]) (4 bytes) </span></p>
111
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">struct { </span></p>
112
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr2_vertex</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> Centre; // relative coordinates of mesh centre (6 bytes) </span></p>
113
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu8</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> Unknown1[4]; // unknown (4 bytes) </span></p>
114
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bit16</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumVertices; // number of vertices to follow (2 bytes) </span></p>
115
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr2_vertex</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> Vertices[NumVertices]; // list of vertices (NumVertices * 6 bytes) </span></p>
116
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bit16</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumNormals; // number of normals to follow (2 bytes) </span></p>
117
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr2_vertex</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> Normals[NumNormals]; // list of normals (NumNormals * 6 bytes) (becomes Lights if NumNormals &lt; 0; 2 bytes) </span></p>
118
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bit16</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumTexturedRectangles; // number of textured rectangles to follow (2 bytes) </span></p>
119
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5_face4</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">TexturedRectangles[NumTexturedRectangles]; // list of textured rectangles (NumTexturedRectangles * 12 bytes) </span></p>
120
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bit16</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumTexturedTriangles; // number of textured triangles to follow (2 bytes) </span></p>
121
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5_face3</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">TexturedTriangles[NumTexturedTriangles]; // list of textured triangles (NumTexturedTriangles * 10 bytes) </span></p>
122
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">} Meshes[NumMeshPointers]; // note that NumMeshPointers comes </span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">AFTER</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> Meshes[] </span></p>
123
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
124
+</p>
125
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
126
+</p>
127
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumMeshPointers; // number of mesh pointers to follow (4 bytes) </span></p>
128
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> MeshPointers[NumMeshPointers]; // mesh pointer list (NumMeshPointers * 4 bytes) </span></p>
129
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumAnimations; // number of animations to follow (4 bytes) </span></p>
130
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5_animation</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">Animations[NumAnimations]; // animation list (NumAnimations * 40 bytes) </span></p>
131
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumStateChanges; // number of state changes to follow (4 bytes) </span></p>
132
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr2_state_change</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> StateChanges[NumStateChanges]; // state-change list (NumStructures * 6 bytes) </span></p>
133
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumAnimDispatches; // number of animation dispatches to follow (4 bytes) </span></p>
134
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr2_anim_dispatch</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> AnimDispatches[NumAnimDispatches]; // animation-dispatch list list (NumAnimDispatches * 8 bytes) </span></p>
135
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumAnimCommands; // number of animation commands to follow (4 bytes) </span></p>
136
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr2_anim_command</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> AnimCommands[NumAnimCommands]; // animation-command list (NumAnimCommands * 2 bytes) </span></p>
137
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumMeshTrees; // number of MeshTrees to follow (4 bytes) </span></p>
138
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr2_meshtree</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> MeshTrees[NumMeshTrees]; // MeshTree list (NumMeshTrees * 4 bytes) </span></p>
139
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumFrames; // number of words of frame data to follow (4 bytes) </span></p>
140
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu16</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> Frames[NumFrames]; // frame data (NumFrames * 2 bytes) </span></p>
141
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumMoveables; // number of moveables to follow (4 bytes) </span></p>
142
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5_moveable</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">Moveables[NumMoveables]; // moveable list (NumMoveables * 20 bytes) </span></p>
143
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumStaticMeshes; // number of StaticMesh data records to follow (4 bytes) </span></p>
144
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr2_staticmesh</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> StaticMeshes[NumStaticMeshes]; // StaticMesh data (NumStaticMesh * 32 bytes) </span></p>
145
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">4*bitu8</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">&nbsp; </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">SPR; // "SPR" (4 bytes)</span></p>
146
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumSpriteTextures; // number of sprite textures to follow (4 bytes) </span></p>
147
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr2_sprite_texture</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> SpriteTextures[NumSpriteTextures]; // sprite texture list (NumSpriteTextures * 16 bytes) </span></p>
148
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumSpriteSequences; // number of sprite sequences records to follow (4 bytes) </span></p>
149
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr2_sprite_sequence</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> SpriteSequences[NumSpriteSequences]; // sprite sequence data (NumSpriteSequences * 8 bytes) </span></p>
150
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumCameras; // number of camera data records to follow (4 bytes) </span></p>
151
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr2_camera</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> Cameras[NumCameras]; // camera data (NumCameras * 16 bytes) </span></p>
152
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">NumFlyByCameras; // number of fly by camera data records to follow (4 bytes)</span></p>
153
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 fly by camera </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">FlyByCameras[NumFlyByCameras];// fly by camera data (NumFlyByCameras * 40 bytes)</span></p>
154
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumSoundSources; // number of sound source data records to follow (4 bytes) </span></p>
155
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5_sound_source</span><span style="text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">SoundSources[NumSoundSources]; // sound source data (NumSoundSources * 16 bytes) </span></p>
156
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumBoxes; // number of box data records to follow (4 bytes) </span></p>
157
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr2_box</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> Boxes[NumBoxes]; // box data (NumBoxes * 8 bytes) </span></p>
158
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumOverlaps; // number of overlap records to follow (4 bytes) </span></p>
159
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu16</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> Overlaps[NumOverlaps]; // overlap data (NumOverlaps * 2 bytes) </span></p>
160
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">10*bit16</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> Zones[NumBoxes]; // zone data (NumBoxes * 20 bytes) </span></p>
161
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumAnimatedTextures; // number of animated texture records to follow (4 bytes) </span></p>
162
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu16</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> AnimatedTextures[NumAnimatedTextures]; // animated texture data (NumAnimatedTextures * 2 bytes) </span></p>
163
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">5*bitu8</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">TEX; "TEX" (5 bytes)</span></p>
164
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumObjectTextures; // number of object textures to follow (4 bytes)&nbsp; </span></p>
165
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5_object_texture</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">ObjectTextures[NumObjectTextures]; // object texture list (NumObjectTextures * 40 bytes) </span></p>
166
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumItems; // number of items to follow (4 bytes) </span></p>
167
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr2_item</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> Items[NumItems]; // item list (NumItems * 24 bytes) </span></p>
168
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumCinematicFrames; // number of cinematic frame records to follow (4 bytes) </span></p>
169
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5_cinematic_frame</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">CinematicFrames[NumCinematicFrames]; // (NumCinematicFrames * 24 bytes) </span></p>
170
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu16</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumDemoData; // number of demo data records to follow (2 bytes) </span></p>
171
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu8</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> DemoData[NumDemoData]; // demo data (NumDemoData bytes) </span></p>
172
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bit16</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> SoundMap[450]; // sound map (900 bytes) </span></p>
173
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumSoundDetails; // number of sound-detail records to follow (4 bytes) </span></p>
174
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr2_sample_info</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> SoundDetails[NumSoundDetails]; // sound-detail list (NumSoundDetails * 8 bytes) </span></p>
175
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> NumSampleIndices; // number of sample indices to follow (4 bytes) </span></p>
176
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#0000ff; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> SampleIndices[NumSampleIndices]; // sample indices (NumSampleIndices * 4 bytes) </span></p>
177
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
178
+</p>
179
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">//////////////////////////////////////////////////////</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">TR5 ROOMS</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">///////////////////////////////////////////////////////////////////////////////////////////</span></p>
180
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
181
+</p>
182
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">In TR5 the room format was drastically changed. The room itself is made up of 'sections'. These sections</span></p>
183
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">encompass a 3 block by 3 block grid (actually 3069 pixels by 3069 pixels ). I will refer to these sections as </span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">layers</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">.</span></p>
184
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">Some 'rooms' do not actually contain visible mesh data. I will refer to these rooms as </span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">null rooms</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">.&nbsp;</span><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span></p>
185
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
186
+</p>
187
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
188
+</p>
189
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 room</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> structure [ FIRST NUMBER IS OFFSET IN BYTES FROM START OF ROOM STRUCTURE]</span></p>
190
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">{</span></p>
191
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">0&nbsp;&nbsp;&nbsp; bitu32 XELA; // "XELA" (4 bytes)</span></p>
192
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">4&nbsp;&nbsp;&nbsp; bitu32 RoomDataSize; // size of the following data ( use this vice 'walking thru' to get next room) (4 bytes)</span></p>
193
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">8&nbsp;&nbsp;&nbsp; bitu32 Seperator; // 0xCDCDCDCD (4 bytes)</span></p>
194
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">12&nbsp; bitu32 EndSDOffset; // usually this number +&nbsp; 216 will give you the offset from the start of the room data to the end</span></p>
195
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; of the Sector Data. HOWEVER have seen where this bitu32 is equal to -1 so it is better</span></p>
196
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; to use the following bitu32 and + 216 + ((NumXSectors * NumZSectors)*8) if you need</span></p>
197
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; to obtain this information. (4 bytes)</span></p>
198
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">16&nbsp;&nbsp; bitu32 StartSDOffset; // this number + 216 will give you the offset from the start of the room to the start of the&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sector data. (4 bytes)</span></p>
199
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">20</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">&nbsp;&nbsp; </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu32 Seperator; // will either be 0x00000000 or 0xCDCDCDCD (4 bytes)</span></p>
200
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">24&nbsp;&nbsp; bitu32 EndPortalOffset; // this number + 216 will give you the offset from the start of the room to the end of the&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; portal data. (4 bytes)</span></p>
201
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">28&nbsp;&nbsp; bit32 x; // X position of room ( world coordinates) (4 bytes)</span></p>
202
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">32&nbsp;&nbsp; bit32 Seperator; // 0x00000000 (4 bytes)</span></p>
203
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">36&nbsp;&nbsp; bit32 z; // Z position of room (world coordinates) (4 bytes)</span></p>
204
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">40&nbsp;&nbsp; bit32 yBottom; // lowest point in room (4 bytes)</span></p>
205
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">44&nbsp;&nbsp; bit32 yTop; // highest point in room (4 bytes)</span></p>
206
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">48&nbsp;&nbsp; bitu16 NumZSectors; // sector table width (2 bytes)</span></p>
207
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">50&nbsp;&nbsp; bitu16 NumXSectors; // sector table height (2 bytes)</span></p>
208
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">52&nbsp;&nbsp; bitu32 RoomColor; // ARGB format (blue is least significant byte) (4 bytes)</span></p>
209
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">56&nbsp;&nbsp; bitu16 NumRoomLights; // number of lights in this room (2 bytes)</span></p>
210
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">58&nbsp;&nbsp; bitu16 NumRoomStaticMeshes; // number of static meshes in this room (2 bytes)</span></p>
211
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">60&nbsp;&nbsp; bitu16 </span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">UnknownR1</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // usually 0x0001 however high byte is sometimes non zero (2 bytes)</span></p>
212
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">62&nbsp;&nbsp; bitu16 </span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">UnknownR2</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // usually 0x0000 however low byte is sometimes non zero (2 bytes)</span></p>
213
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">64&nbsp;&nbsp; bitu32 Filler; // always 0x00007FFF (4 bytes)</span></p>
214
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">68&nbsp;&nbsp; bitu32 Filler2; // always 0x00007FFF (4 bytes)</span></p>
215
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">72&nbsp;&nbsp; bitu32 Seperator; // 0xCDCDCDCD (4 bytes)</span></p>
216
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">76&nbsp;&nbsp; bitu32 Seperator; // 0xCDCDCDCD (4 bytes)</span></p>
217
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">80&nbsp;&nbsp; 6*bitu8 Seperator; // 6 bytes 0xFF </span></p>
218
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">86&nbsp;&nbsp;</span><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> bitu16 RoomFlag</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // 0x01 = water, 0x20 = wind, others unknown (2 bytes)</span></p>
219
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">88&nbsp; bitu16 </span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">UnknownR5</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // unknown (2 bytes)</span></p>
220
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">90&nbsp; 10*bitu8 Seperator; // 10 bytes 0x00</span></p>
221
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">100 bitu32 Seperator; // 0xCDCDCDCD (4 bytes)</span></p>
222
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">104 bitu32 </span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">UnknownR6</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // unknown (4 bytes)</span></p>
223
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">108&nbsp; float RoomX; // X position of room in world coordinates * If&nbsp; null room then this data will be 0xCDCDCDCD (4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bytes)</span></p>
224
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">112&nbsp; bitu32 Seperator; // 0x00000000 or 0xCDCDCDCD if null room. (4 bytes)</span></p>
225
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">116&nbsp; float RoomZ; // Z position of room in world coordinates * If null room then will be bitu32 0xCDCDCDCD (4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bytes)</span></p>
226
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">120&nbsp; bitu32 Seperator; // 0xCDCDCDCD (4 bytes)</span></p>
227
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">124&nbsp; bitu32 Seperator; // 0xCDCDCDCD (4 bytes)</span></p>
228
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">128&nbsp; bitu32 Seperator; // 0xCDCDCDCD (4 bytes)</span></p>
229
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">132&nbsp; bitu32 Seperator; // 0xCDCDCDCD (4 bytes)</span></p>
230
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">136&nbsp; bitu32 Seperator; // 0x00000000 unless null room then 0xCDCDCDCD (4 bytes)</span></p>
231
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">140&nbsp; bitu32 Seperator; // 0xCDCDCDCD (4 bytes)</span></p>
232
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">144&nbsp; bitu32 NumRoomTriangles; // total number of triangles this room (4 bytes)</span></p>
233
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">148&nbsp; bitu32 NumRoomRectangles; // total number of rectangles this room (4 bytes)</span></p>
234
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">152&nbsp; bitu32 Seperator; // 0x00000000 (4 bytes) </span></p>
235
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">156&nbsp; bitu32 LightSize; //&nbsp; size of light data (number of lights * 88) (4 bytes)</span></p>
236
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">160&nbsp; bitu32 NumRoomLights; // total number of lights this room (4 bytes)</span></p>
237
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">164&nbsp; bitu32 </span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">UnknownR7</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // unknown, usually equals 0, 1, 2, or 3 (4 bytes)</span></p>
238
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">168&nbsp; bit32 UnknownR8; // usually equals room yTop. Sometimes a few blocks off. If null room then 0xCDCDCDCD</span></p>
239
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">172&nbsp; bit32 lyBottom; // equals room yBottom. If null room then 0xCDCDCDCD (4 bytes)</span></p>
240
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">176&nbsp; bitu32 NumLayers; // number of layers (pieces) this room (4 bytes)</span></p>
241
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">180&nbsp; bitu32 LayerOffset; // this number + 216 will give you an offset from the start of the room data to the start of the&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; layer data (4 bytes)</span></p>
242
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">184&nbsp; bitu32 VerticesOffset; // this number + 216 will give you an offset from the start of the room data to the start of the</span></p>
243
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; verex data (4 bytes)</span></p>
244
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">188&nbsp; bitu32 PolyOffset; // this number + 216 will give you an offset from the start of the room data to the start of the&nbsp;</span></p>
245
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rectangle/triangle data (4 bytes)</span></p>
246
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">192&nbsp; bitu32 PolyOffset2; // same as above ? (4 bytes)</span></p>
247
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">196&nbsp; bitu32 VerticesSize; // size of vertices data block (4 bytes)</span></p>
248
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">200&nbsp; bitu32 Seperator; // 0xCDCDCDCD (4 bytes)</span></p>
249
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">204&nbsp; bitu32 Seperator; // 0xCDCDCDCD (4 bytes)</span></p>
250
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">208&nbsp; bitu32 Seperator; // 0xCDCDCDCD (4 bytes)</span></p>
251
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">212&nbsp; bitu32 Seperator; // 0xCDCDCDCD (4 bytes)</span></p>
252
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">216&nbsp; </span><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 lights[LightSize]</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // data for the lights (88 bytes * NumRoomLights) </span></p>
253
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">tr2 SectorData[(NumXSectors * NumZSectors) * 8]; // normal sector data structure</span></p>
254
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu16 NumDoors; // number of portals (2 bytes)</span></p>
255
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">tr2 room door[NumDoors]; // normal portal structure (32 bytes * NumDoors)</span></p>
256
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu16 Seperator; // 0xCDCD (2 bytes)</span></p>
257
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">tr2 room static mesh[NumStaticMeshes]; // normal room static mesh structure (20 bytes * NumRoomStaticMeshes)</span></p>
258
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 room layer[NumLayers]</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // data for the room layers (pieces) (56 bytes * NumLayers)</span></p>
259
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 room polygons[NumRoomRectangles + NumRoomTriangles]</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // data for the room polys (face4 and face3).&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Structured as</span></p>
260
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; first layers rectangles then triangles, followed by the next layers rectangles and triangles,</span></p>
261
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; etc., until all layers are done. (12 bytes each rectangle. 10 bytes each triangle)</span></p>
262
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 room vertices[VerticesSize]</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // data for the room vertices. Structured as vertices for the first layer, then</span></p>
263
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vertices for the second layer, etc., until all layers are done. (28 bytes each</span></p>
264
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vertex.</span></p>
265
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
266
+</p>
267
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">}</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 room</span></p>
268
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
269
+</p>
270
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 room layer</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> structure (56 bytes)</span></p>
271
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">{</span></p>
272
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">0&nbsp;&nbsp; bitu32 NumLayerVertices; // number of vertices in this layer (4 bytes)</span></p>
273
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">4&nbsp;&nbsp; bitu16 </span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">UnknownL1</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // unknown (2 bytes)</span></p>
274
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">6&nbsp;&nbsp; bitu16 NumLayerRectangles; // number of rectangles in this layer (2 bytes)</span></p>
275
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">8&nbsp;&nbsp; bitu16 NumLayerTriangles; // number of triangles in this layer (2 bytes)</span></p>
276
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">10 bitu16 UnknownL2; // appears to be the number of 2 sided textures in this layer, however is sometimes 1 off (2 bytes)</span></p>
277
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">12 bitu16 Filler; // always 0 (2 bytes)</span></p>
278
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">14 bitu16 Filler2; // always 0 (2 bytes)</span></p>
279
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
280
+</p>
281
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">///////&nbsp; The following 6 floats (4 bytes each) define the bounding box for the layer //////////</span></p>
282
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">16 float LayerBoundingBoxX1; </span></p>
283
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">20 float LayerBoundingBoxY1;</span></p>
284
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">24 float LayerBoundingBoxZ1;</span></p>
285
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">28 float LayerBoundingBoxX2;</span></p>
286
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">32 float LayerBoundingBoxY2;</span></p>
287
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">36 float LayerBoundingBoxZ2;</span></p>
288
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
289
+</p>
290
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">40 bitu32 Filler3; // always 0 (4 bytes)</span></p>
291
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">44 bitu32 </span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">UnknownL6</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // unknown (4 bytes)</span></p>
292
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">48 bitu32 </span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">UnknownL7</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // unknown (4 bytes)</span></p>
293
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">52 bitu32 </span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">UnknownL8</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // unknown. Always the same throughout the level. (4 bytes)</span></p>
294
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">}</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 room layer</span></p>
295
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
296
+</p>
297
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 face4</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> structure (12 bytes)</span></p>
298
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">{</span></p>
299
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu16 Vertices[4]; // the values are the indices into the appropriate layer vertice list. (2 bytes each)</span></p>
300
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu16 Texture; // the texture number for this face. Needs to be masked with 0xFFF as the high 4 bits are flags.(2 bytes)</span></p>
301
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu16 </span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">UnknownF4</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // unknown (2 bytes)</span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span></p>
302
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">}</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 room rectangle</span></p>
303
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
304
+</p>
305
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 face3 </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">structure (10 bytes)</span></p>
306
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">{</span></p>
307
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu16 Vertices[3]; // the values are the indices into the appropriate layer vertice list (2 bytes each)</span></p>
308
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu16 Texture; // the texture number for this face. Needs to be masked with 0xFFF as the high 4 bits are flags (2 bytes)</span></p>
309
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bitu16 </span><span style="text-decoration: underline; text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">UnknownF3</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // unknown (2 bytes)</span></p>
310
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">}</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 room triangle</span></p>
311
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
312
+</p>
313
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 vertex</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> structure (28 bytes)</span></p>
314
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">{</span></p>
315
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float x; // x of vertex (4 bytes)</span></p>
316
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float y; // y of vertex (4 bytes)</span></p>
317
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float z; // z of vertex (4 bytes)</span></p>
318
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float nx; // x of vertex normal (4 bytes)</span></p>
319
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float ny; // y of vertex normal (4 bytes)</span></p>
320
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float nz; // z of vertex normal (4 bytes)</span></p>
321
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu32 vColor; // vertex color ARGB format (4 bytes)</span></p>
322
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">}</span><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 vertex</span></p>
323
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
324
+</p>
325
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
326
+</p>
327
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 light </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">structure (88 bytes)</span></p>
328
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">{</span></p>
329
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
330
+</p>
331
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">// The following is preliminary info. Appears to be correct, however I'm having strange findings</span></p>
332
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">// on some early testing. Proceed at your own risk on this one.</span></p>
333
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
334
+</p>
335
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">// The first three floats specify the position of the light in world coordinates</span></p>
336
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">// The sun type light should not use these but seems to have a large x value (9 million, give or take)</span></p>
337
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">// a zero y value, and a small z value (4 - 20) in the original TR5 levels</span></p>
338
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
339
+</p>
340
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float x; // x position of light (4 bytes)</span></p>
341
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float y; // y position of light (4 bytes)</span></p>
342
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float z; // z position of light (4 bytes)</span></p>
343
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
344
+</p>
345
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">// The next three specify the color of the light</span></p>
346
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
347
+</p>
348
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float Red; // color of red spectrum (4 bytes)</span></p>
349
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float Green; // color of green spectrum (4 bytes)</span></p>
350
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float Blue; // color of blue spectrum (4 bytes)</span></p>
351
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
352
+</p>
353
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">// Another 'filler'</span></p>
354
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
355
+</p>
356
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu32 Seperator; // not used 0xCDCDCDCD (4 bytes)</span></p>
357
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
358
+</p>
359
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">// At this point the following info diverges dependant on which type of light being used:</span></p>
360
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">// 0 = sun,&nbsp; 1 = light,&nbsp; 2 = spot,&nbsp; 3 = shadow</span></p>
361
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
362
+</p>
363
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">//&nbsp;&nbsp; The sun type doesn't use the next two.</span></p>
364
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">//&nbsp;&nbsp; For the spot type these are the hotspot and falloff angle cosines</span></p>
365
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">//&nbsp;&nbsp; For the light and shadow types these are the TR units for the hotspot/falloff (1024=1sector)</span></p>
366
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
367
+</p>
368
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float Input; // cosine of the IN value for light / size of IN value (4 bytes)</span></p>
369
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float Output; // cosine of the OUT value for light / size of OUT value (4 bytes)</span></p>
370
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
371
+</p>
372
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">//&nbsp; The next two are only used by the spot type light</span></p>
373
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
374
+</p>
375
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float RadInput; // (IN radians) * 2 (4 bytes)</span></p>
376
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float RadOutput; // (OUT radians) * 2 (4 bytes)</span></p>
377
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
378
+</p>
379
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">//&nbsp; The next is also only used by the spot type light</span></p>
380
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
381
+</p>
382
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float Range; // Range of light (4 bytes)</span></p>
383
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
384
+</p>
385
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">//	The final 3 floats are used only by the 'sun' and 'spot' type lights.</span></p>
386
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">//	They describe the directional vector of the light.</span></p>
387
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">//	This can be obtained by :</span></p>
388
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">//&nbsp;&nbsp;	if both x and y	LightDirectionVectorX = cosX * sinY </span></p>
389
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">//&nbsp;&nbsp;&nbsp;&nbsp;	LightDirectionVectorY = sinX</span></p>
390
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">//&nbsp;&nbsp;&nbsp;&nbsp;	LightDirectionVectorZ = cosX * cosY</span></p>
391
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">//</span></p>
392
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
393
+</p>
394
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float DirectionVectorX; // light direction (4 bytes)</span></p>
395
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float DirectionVectorY; // light direction (4 bytes)</span></p>
396
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">float DirectionVectorZ; // light direction (4 bytes)</span></p>
397
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
398
+</p>
399
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">//&nbsp; The next six values repeat some of the previous information in long data types vice floats</span></p>
400
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
401
+</p>
402
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bit32 x; // x position of light (4 bytes)</span></p>
403
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bit32 y; // y position of light (4 bytes)</span></p>
404
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bit32 z; // z position of light (4 bytes)</span></p>
405
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
406
+</p>
407
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">//&nbsp; 16384 = 1.0 for the rotations ( 1/16384 )</span></p>
408
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
409
+</p>
410
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bit32 DirectionVectorX;&nbsp; // light direction (4 bytes)</span></p>
411
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bit32 DirectionVectorY; // light direction (4 bytes)</span></p>
412
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bit32 DirectionVectorZ; // light direction (4 bytes)</span></p>
413
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
414
+</p>
415
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">//&nbsp; The next char specifies the type of light as specified above</span></p>
416
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
417
+</p>
418
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu8 LightType; // type of light. (1 byte)</span></p>
419
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
420
+</p>
421
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">//&nbsp; Another filler</span></p>
422
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
423
+</p>
424
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">3*bitu8 Seperator; // 0xCDCDCD (3 bytes)</span></p>
425
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">}</span><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 light</span></p>
426
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
427
+</p>
428
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5_object_texture</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">structure (40 bytes)</span></p>
429
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">{</span></p>
430
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu16 Attribute; //0, 1, or 2 (2 means 2 sided) (2 bytes)</span></p>
431
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu32 Tile; // need to mask with 0xFF as other bits are flags. ie bit15 seems to indicate triangle (4 bytes)</span></p>
432
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 object texture vert</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">; // Vertices[4] (16 bytes)</span></p>
433
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu32 UV1; // unknown how used (4 bytes)</span></p>
434
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu32 UV2; // unknown how used (4 bytes)</span></p>
435
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu32 Xsize; // unknown how used, x size (4 bytes)</span></p>
436
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu32 Ysize; // unknown how used, y size (4 bytes)</span></p>
437
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu16 Seperator; // always 0x0000 (2 bytes)</span></p>
438
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">}</span><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5_object_texture</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span></p>
439
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
440
+</p>
441
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 object texture vert</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> structure (4 bytes)</span></p>
442
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">{</span></p>
443
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu8 Xcoordinate; // 0 if Xpixel is the low value, 255 if Xpixel is the high value in the object texture (1 byte)</span></p>
444
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu8 Xpixel; // (1 byte)</span></p>
445
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu8 Ycoordinate; // 0 if Ypixel is the low value, 255 if Ypixel is the high value in the object texture (1 byte)</span></p>
446
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu8 Ypixel; // (1 byte)</span></p>
447
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">}</span><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 object texture vert</span></p>
448
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
449
+</p>
450
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
451
+</p>
452
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 fly by camera</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> structure (40 bytes)</span></p>
453
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">{</span></p>
454
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">bit32 CameraX; // x position of camera in world coordinates (4 bytes)</span></p>
455
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bit32 CameraY; // y position of camera in world coordinates (4 bytes)</span></p>
456
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bit32 CameraZ; // z&nbsp; position of camera in world coordinates (4 bytes)</span></p>
457
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
458
+</p>
459
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bit32 TargetX; // x position of aiming point in world coordinates (4 bytes)</span></p>
460
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bit32 TargetY; // y position of aiming point in world coordinates (4 bytes)</span></p>
461
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bit32 TargetZ; // z&nbsp; position of aiming point in world coordinates (4 bytes)</span></p>
462
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
463
+</p>
464
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bit8&nbsp; Sequence; // sequence # of camera (1 byte)</span></p>
465
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bit8&nbsp; CameraNumber; // camera # (1 byte)</span></p>
466
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
467
+</p>
468
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu16 FOV; // fov of camera ( .0054945 for each degree ) (2 bytes)</span></p>
469
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu16 Roll; // roll of camera ( .0054945 for each degree ) (2 bytes)</span></p>
470
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
471
+</p>
472
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu16 Timer; // timer number (2 bytes)</span></p>
473
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu16 Speed; // ( .000015259 each ) (2 bytes)</span></p>
474
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu16 Flags; // ( see your handy TRLE manual for the specs ) (2 bytes)</span></p>
475
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">bitu32 Room; // room number (4 bytes)</span></p>
476
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">}</span><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 fly by camera</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span></p>
477
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
478
+</p>
479
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
480
+</p>
481
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 moveable</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> structure ( 20 bytes ) ( same as old structure but has bitu16 filler at the end )</span></p>
482
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">{</span></p>
483
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu32 ObjectId; // object identifier ( matched in Items[] )</span></p>
484
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu16 NumMeshes; // number of meshes in this object&nbsp;</span></p>
485
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu16 StartingMesh; // starting mesh ( offset into MeshPointers[] )&nbsp;</span></p>
486
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu32 MeshTree; // offset into MeshTree[] )</span></p>
487
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu32 FrameOffset; // byte offset into Frames[] ( divide by 2 for Frames[i] )</span></p>
488
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu16 Animation; // offset into Animations[]</span></p>
489
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu16 Filler; // always equal to 65519 ( 0xFFEF )</span></p>
490
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">}</span><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 moveable</span></p>
491
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
492
+</p>
493
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 animation</span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> structure ( 40 bytes ) ( same as old structure but has 8 bytes before FrameStart )</span></p>
494
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">{</span></p>
495
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu32&nbsp; FrameOffset; // byte offset into Frames[] ( divide by 2 for Frames[i] )</span></p>
496
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu8&nbsp;&nbsp;&nbsp; FrameRate; // Engine ticks per frame</span></p>
497
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu8&nbsp;&nbsp;&nbsp; FrameSize; // number of bit16's in Frames[] used by this animation</span></p>
498
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu16&nbsp; StateId; //&nbsp;</span></p>
499
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bit16&nbsp;&nbsp;&nbsp; Unknown;</span></p>
500
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bit16&nbsp;&nbsp;&nbsp; Speed; // Evengi Popov found this but I never seen what he said it was for</span></p>
501
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu16&nbsp; AccelLo; // same as above</span></p>
502
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bit16&nbsp;&nbsp;&nbsp; AccelHi; // same as above</span></p>
503
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu8&nbsp;&nbsp;&nbsp; AUnknown[8]; // Unknown</span></p>
504
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu16&nbsp; FrameStart; // first frame in this animation</span></p>
505
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu16&nbsp; FrameEnd; // last frame in this animation ( numframes = ( End - Start) + 1 )</span></p>
506
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu16&nbsp; NextAnimation;</span></p>
507
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu16&nbsp; NextFrame;</span></p>
508
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu16&nbsp; NumStateChanges;</span></p>
509
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu16&nbsp; StateChangeOffset; // offset into StateChanges[]</span></p>
510
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu16&nbsp; NumAnimCommands; // how many of them to use</span></p>
511
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">&nbsp;&nbsp;&nbsp; bitu16&nbsp; AnimCommand; // offset into AnimCommand[]</span></p>
512
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">}</span><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5 animation</span></p>
513
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
514
+</p>
515
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
516
+</p>
517
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
518
+</p>
519
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-position: ; color:#000000; font-family: 'Times New Roman'; font-size: 12.000000pt">/////////////////////////// The following structures have changed from the TR3 version //////////////////////</span></p>
520
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
521
+</p>
522
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><span style="text-decoration: underline; text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">tr5_cinematic_frame</span><span style="text-position: ; color:#ff0000; font-family: 'MS Sans Serif'; font-size: 10.000000pt"> </span><span style="text-position: ; color:#000000; font-family: 'MS Sans Serif'; font-size: 10.000000pt">now 24 bytes vice 16 bytes. Unknown how format was changed.</span></p>
523
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
524
+</p>
525
+<p class="Default" style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
526
+</p>
527
+<p style="text-align: left; margin-bottom: 0.0000in; margin-top: 0.0000in; margin-right: 0.0000in"><br>
528
+</p>
529
+</div>
530
+</body>
531
+</html>

+ 116
- 0
doc/TR5-Format.txt 파일 보기

@@ -0,0 +1,116 @@
1
+
2
+TR4:
3
+* amount_cinematic_frames is bitu32, not bitu16
4
+* object_texture last 2 longs are xsize and ysize of texture
5
+* object_texture::
6
+I gess that in TR4 files the object textures Id used for the movables are the same used in the WAD file.
7
+The object texture is interpreted some different,
8
+
9
+
10
+First word in the texture ID:
11
+
12
+for rectangles in model:
13
+
14
+Bits 0-11 texture Id (signed) if negative the texture is fliped.
15
+Bits 12-15 unused, (0000 if Id is positive, 1111 if negative)
16
+
17
+for Triangles in model:
18
+
19
+Bits 0-11 texture Id (always positive)
20
+Bits 12-14 Triangle kind.
21
+Bits 15 normal/flip
22
+
23
+for secound word:
24
+
25
+0= texture opaque
26
+1=texture semi-transparent
27
+2=transparent.
28
+
29
+TR5:
30
+* object_textures are now 40 bytes
31
+* after "SPR" is an unknown byte
32
+* before "TEX" is an unknown byte
33
+* moveable after each is unknown int 
34
+* object_texture last 2 longs are xsize and ysize of texture
35
+
36
+
37
+/////////////////////////////////////
38
+//  TR5 Format
39
+/////////////////////////////////////
40
+
41
+
42
+unsigned long Version
43
+unsigned char Unknown[6]
44
+
45
+
46
+// 32 bits textures
47
+unsigned long UCompSize
48
+unsigned long CompSize
49
+unsigned char *CompData
50
+
51
+// 16 bits textures
52
+unsigned long UCompSize
53
+unsigned long CompSize
54
+unsigned char *CompData
55
+
56
+// Sprite textures
57
+unsigned long UCompSize
58
+unsigned long CompSize
59
+unsigned char *CompData
60
+
61
+unsigned char Unknown[44]
62
+unsigned int NumRooms
63
+
64
+
65
+// Rooms
66
+// All rooms start with the following header:
67
+
68
+unsigned int Unknown
69
+unsigned long RoomCode (0x0414C4558)
70
+unsigned char Unknowm[24]
71
+
72
+// After the header comes the following format:
73
+
74
+unsigned long RoomX
75
+unsigned long Unknown (Maybe RoomY?)
76
+unsigned long RoomZ
77
+unsigned long Unknown[2]
78
+unsigned int XSize
79
+unsigned int ZSize
80
+
81
+// The room color. It uses 4 bytes and it's in RGB format (I don't know what byte 4 is)
82
+TR_Color4 RoomColor
83
+
84
+// After here comes a unknown format that contains the number of static meshes, vertices,
85
+// rectangles and more. They uses 30 bytes, but 28 are unknown for me. There is maybe a
86
+// pointer to the 'real' structure, or maybe a special code like the RoomCode. (It looks
87
+// like TR5 uses come sort of chunks)
88
+
89
+
90
+// Static Meshes
91
+unsigned int Unknown
92
+unsigned int NumStaticMeshes
93
+unsigned char Unknown[26]
94
+
95
+// Vertices
96
+unsigned int Unknown
97
+unsigned int NumVertices
98
+unsigned char Unknown[26]
99
+
100
+// Unknown, but format looks the same. Sometimes 0 and sometimes very large (Maybe the
101
+// value is signed?).
102
+unsigned int Unknown
103
+unsigned int Unknown
104
+unsigned char Unknown[26]
105
+
106
+// Rectangles
107
+unsigned int Unknown
108
+unsigned int NumVertices
109
+unsigned char Unknown[26]
110
+
111
+
112
+// This is all I know! I can see the sectors, but there are many unknown before it. A way 
113
+// to search for the sectors is searching for a value of 129 (A wall). The sectors uses
114
+// 8 bytes for each sector. Use XSize and ZSize to read it and remember that the four
115
+// corners must be a wall (129, 5th byte). If you search for the 4 corners with a value of
116
+// 129 (byte 7 is 129 too), the change that you find it is very large.

+ 344
- 0
doc/TR5-Notes.txt 파일 보기

@@ -0,0 +1,344 @@
1
+// Mongoose, Terms in this file related to what we use:
2
+//  Int   :  unsigned short  : bitu16
3
+//  Dword :  unsigned int    : bitu32
4
+//
5
+// Also, I'm appending TP's findings to the format
6
+
7
+*******************************************************
8
+      TR4 Possible File Format
9
+rgbold March '01
10
+
11
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
12
+
13
+Dword "TR4",0
14
+Int   number of RoomTextures?
15
+Int   number of OtherTextures?
16
+Int   number of BumpMapTextures?
17
+Dword UncompressedSize1
18
+Dword CompressedSize1
19
+TextureBlock1
20
+Dword UncompressedSize2
21
+Dword CompressedSize2
22
+TextureBlock2
23
+Dword UncompressedSize3
24
+Dword CompressedSize3
25
+TextureBlock3
26
+
27
+/// Other data follows after textures structures are same as TR3 except
28
+    where noted
29
+
30
+NOTES:
31
+Texture needs to be masked with 0xfff (high 4 bits are flags)
32
+
33
+
34
+Room Lights now 46 bytes:
35
+
36
+TR4_RoomLight //
37
+  //Follows a D3D light structure, I think, could be wrong
38
+
39
+  Dword Xposition  // world coords
40
+  Dword Yposition  // world coords
41
+  Dword Zposition  // world coords
42
+  TR2_Color        // three bytes rgb values
43
+  bitu8 LightType  // same as D3D (i.e. 2 is for spotlight)
44
+  bitu8 unknown    // always 0xff?
45
+  byte  Intensity
46
+  float In
47
+  float Out
48
+  float Length
49
+  float Cutoff
50
+  floats X,Y,Z    //direction??
51
+
52
+
53
+Before SoundSources is a new field for Flyby_Camera data
54
+bitu32 Number_of_FBCameras
55
+followed by data for each camera. Data field is 40 bytes.
56
+[Andy had previously stated NumXYZ as a new field incorrectly.
57
+His NumXYZ field was the SoundSources in normal structure format]
58
+
59
+
60
+Cinematic Frames now 24 bytes
61
+
62
+There are no colored rectangles or triangles in mesh data.
63
+Mesh Rectangles and Triangles now
64
+  MeshRects: v0,v1,v2,v3,texture,int unknown
65
+  MeshTris:  v0,v1,v2,texture,int unknown
66
+Texture Objects now preceeded by TEX/0 (4bytes)
67
+Object Textures now 38 bytes vice 20
68
+Tile is now a bitu32 vice bitu16 seems need to mask with 0xff as other
69
+       bits are flags. Seems bit15 set means triangle.
70
+In the texture coords now 0 is used for low value vice 1
71
+The extra 16 bytes are at the end of ObjectTexture structure
72
+
73
+Attributes using 1 or 2 for transparent. 2 used for 2 sided textures
74
+               (water surface,etc)
75
+
76
+
77
+Animation now 40 vice 32 bytes. extra 8 seem to be zero right before
78
+/after the old 8 unknowns
79
+
80
+"SPR"  3 byte ascii before sprite textures
81
+
82
+There are no 8bit or 16 bit palettes (no colored rects or tris)
83
+No lightmap
84
+No 8bit textures
85
+Following level data are Riff Wave Formats.
86
+
87
+Lara 2 meshes , skin and joints.
88
+
89
+
90
+
91
+#############################################################################
92
+#
93
+#        TR5 Possible File Format
94
+#        rgbold March '01
95
+#
96
+#############################################################################
97
+
98
+
99
+// Header ///////////////////
100
+Dword "TR4",0
101
+
102
+// Textures /////////////////
103
+Int   number of RoomTextures?
104
+Int   number of OtherTextures?
105
+Int   number of BumpMapTextures?
106
+Dword UncompressedSize1
107
+Dword CompressedSize1
108
+TextureBlock1
109
+Dword UncompressedSize2
110
+Dword CompressedSize2
111
+TextureBlock2
112
+Dword UncompressedSize3
113
+Dword CompressedSize3
114
+TextureBlock3
115
+
116
+/// Follows after textures
117
+
118
+
119
+32 bytes unknown //mostly zero
120
+Dword SizeData    // size of file to Riffs
121
+Dword SizeData    // repeat of above
122
+Dword Unknown     // seems always zero
123
+Dword NumberRooms // number of rooms this level
124
+
125
+{ Following Repeats for each Room in level
126
+
127
+Dword "XELA" (someone named Alex or "dirX Enhanced Level Archive"
128
+Dword size //size to next XELA block
129
+Dword CDCDCDCD
130
+
131
+Block1 60 bytes
132
+{
133
+
134
+Dword ublock1 //mostly: start of "XELA" +216 + ublock1 = FD end,
135
+                but have seen 0xffffffff. Better using next data
136
+                and compute FD size the old way of X*Z*8
137
+Dword ublock2 //  start of "XELA" + 216 + ublock2 = FD start
138
+Dword ublock3 // unknown
139
+Dword ublock4 // possibly start of "XELA" + 216 + ublock4 = end portals
140
+
141
+Dword Room X      // room's x position in world coords
142
+Dword unknown1    // always seems to be 0000
143
+Dword Room Z      // room's z position in world coords
144
+Dword Ybottom     // room's y bottom positon in world coords
145
+Dword Ytop        // room's y top positon in world coords
146
+
147
+Int  NumZSectors // number of z sectors
148
+Int  NumXSectors // number of x sectors
149
+
150
+tr2_color4        // 4 bytes color info rgba
151
+
152
+Int  NumLights
153
+Int  NumStaticMeshes
154
+
155
+Dword Unknown2    // seems always 0x0001
156
+Dword Unknown3    // seems always 0x7fff
157
+Dword Unknown4    // seems always 0x7fff
158
+
159
+}close 60 byte block
160
+
161
+Dword CDCDCDCD
162
+Dword CDCDCDCD
163
+
164
+20 byte block
165
+{
166
+6 bytes 0xff
167
+Int Room_Flag    //room attributes (rain,etc)
168
+Int unknown5
169
+10 bytes 0x00
170
+} close 20 byte block
171
+
172
+Dword CDCDCDCD
173
+
174
+16 byte block
175
+{
176
+unknown 16 bytes
177
+}close 16 byte block
178
+
179
+Dword CDCDCDCD
180
+Dword CDCDCDCD
181
+Dword CDCDCDCD
182
+Dword CDCDCDCD
183
+
184
+Dword Unknown6
185
+
186
+Dword CDCDCDCD
187
+
188
+56 byte block
189
+{
190
+Dword NumberTriangles
191
+Dword NumberRectangles
192
+Dword Unknown7 // always 0x0000 ??
193
+Dword LightSize // number lights times 88 bytes
194
+Dword NumberLights
195
+Dword NumUnknown_36_byte_struct
196
+Dword Unknown9
197
+Dword Unknown10
198
+Dword NumberLayers //TR5 'layers' room pieces
199
+Dword Unknown11    // start of "XELA" + 216 + Unknown11 = start of 
200
+layer 
201
+info
202
+Dword Unknown12    // start of "XELA" + 216 + Unknown12 = start of 
203
+vertices
204
+Dword Unknown13    // start of "XELA" + 216 + Unknown13 = start of 
205
+rect/tri
206
+Dword Unknown14    // same as Unknown13???
207
+Dword Unknown15    // start of vertices + Unknown15 = start of next 
208
+"XELA"
209
+}close 56 byte block
210
+
211
+Dword CDCDCDCD
212
+Dword CDCDCDCD
213
+Dword CDCDCDCD
214
+Dword CDCDCDCD
215
+
216
+// Lights //////////////////////////
217
+if lights then 85 bytes light data followed by CDCDCD for each light
218
+
219
+// Unknown /////////////////////////
220
+if NumUnknown_36_byte_struct then read them too
221
+
222
+// Sectors /////////////////////////
223
+Sector Data (sectors times 8 bytes) normal sector data structure
224
+
225
+// Portals /////////////////////////
226
+Int NumberDoors
227
+
228
+NumberDoors times 32 bytes (normal portal structure)
229
+
230
+Int CDCD
231
+
232
+// Static meshes //////////////////
233
+if StaticMeshes than numberofstatics times 20 bytes each (normal 
234
+structure)
235
+
236
+
237
+// Layers ////////////////////////
238
+Layer Data blocks. 56 bytes each.
239
+{
240
+   Dword NumberVertices
241
+   Int  Unknown16
242
+   Int  NumberRectangles
243
+   Int  NumberTriangles
244
+
245
+   unknown 46 bytes // was 48 in older docs
246
+
247
+}close Layer Data block
248
+
249
+following the Layer Data block are:
250
+  rectangles for Layer1 // see format under NOTES
251
+  triangles  for Layer1 // see format under NOTES
252
+  rectangles for Layer2
253
+  triangles  for Layer2
254
+
255
+  ...and so on untill all layers are done
256
+
257
+after the rectangle and triangle information are the room vertices
258
+which are described under NOTES
259
+
260
+
261
+}Close Rooms Loop
262
+
263
+
264
+NOTES:
265
+
266
+Room Vertices are 28 bytes each
267
+3 floats representing the x,y,z values of vertex
268
+3 floats probably the vertex normals
269
+1 DWORD  probably diffuse color for the vertex
270
+
271
+Rectangles are same old format of V0,V1,V2,V3,Texture, followed by
272
+Int unknown, usually zero.
273
+Texture needs to be masked with 0xfff (high 4 bits are flags)
274
+
275
+Triangles are same old format of V0,V1,V2,Texture, followed by
276
+Int unknown, usually zero.
277
+Texture needs to be masked with 0xfff (high 4 bits are flags)
278
+
279
+TR5 uses D3D extensively. The light format is a prime example. The last
280
+byte in the light field before the CDCDCD is the light type which in
281
+D3d is 1,2, or 3 for point, spot, or directional lights respectively.
282
+Also somewhere in the unknowns must be the fog values.
283
+
284
+Sound Map is now 900 bytes
285
+
286
+Before SoundSources is a new field for Flyby_Camera data
287
+bitu32 Number_of_FBCameras
288
+followed by data for each camera. Data field is 40 bytes.
289
+[Andy had previously stated NumXYZ as a new field incorrectly.
290
+His NumXYZ field was the SoundSources in normal structure format]
291
+
292
+
293
+Cinematic Frames now 24 bytes
294
+
295
+There are no colored rectangles or triangles in mesh data.
296
+Mesh Rectangles and Triangles now same format as room rects and tris,
297
+MeshRects: v0,v1,v2,v3,texture,int unknown
298
+MeshTris:  v0,v1,v2,texture,int unknown
299
+Texture Objects now preceeded by TEX/0 (4bytes)
300
+Object Textures now 38 bytes vice 20
301
+Tile is now a bitu32 vice bitu16 seems need to mask with 0xff as other
302
+       bits are flags. Seems bit15 set means triangle.
303
+In the texture coords now 0 is used for low value vice 1
304
+The extra 16 bytes at the end of ObjectTexture structure are 4 Dword
305
+       coords, UV?.
306
+Attributes using 1 or 2 for transparent. 2 used for 2 sided textures
307
+               (water surface,etc)
308
+
309
+
310
+Animation now 40 vice 32 bytes. extra 8 seem to be zero right before
311
+/after the old 8 unknowns
312
+
313
+"SPR"  3 byte ascii before sprite textures
314
+
315
+As TR4 there are no 8bit or 16 bit palettes (no colored rects or tris)
316
+No lightmap
317
+No 8bit textures
318
+3 blocks of zlib compressed textures (32bit,16bit,sprite/misc)before
319
+level data.
320
+Level data not compressed.
321
+
322
+Following level data are Riff Wave Formats.
323
+
324
+Lara 2 meshes as TR4, skin and joints.
325
+
326
+also , I was just reading thru the rectanges and triangles and
327
+thought the vertices always followed right after but appears
328
+that sometimes there is a 'pad' int of 0xCDCD.
329
+
330
+
331
+  Also as Michiel has just posted the Object Textures for TR5 are
332
+40bytes, sorry about that.
333
+
334
+
335
+
336
+
337
+
338
+
339
+************************************************************
340
+
341
+          Good Luck,
342
+                       Roy...
343
+
344
+

+ 263
- 0
doc/TR5.spec 파일 보기

@@ -0,0 +1,263 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+#############################################################################
3
+#
4
+#  TR5 File Format?
5
+#  rgbold, Turbo Pascal, and Mongoose spec merge
6
+#
7
+#  NOTES: 
8
+#  I use ISO style types to be more clear, not word sizes
9
+#       
10
+#     Int   :  unsigned short  : bitu16
11
+#     Dword :  unsigned int    : bitu32
12
+#
13
+#  Some other markers?  I think these may be:
14
+#  
15
+#  58 50 50 FF    "XPP."   |  "PPX"
16
+#  58 50 48 FF    "XPH."   |  "HPX"
17
+#  50 50 48 FF    "PPH."   |  "PPH"
18
+#
19
+#  They appear in a patern like:
20
+#  ALEX
21
+#     XPP XPP ...
22
+#  ALEX
23
+#  
24
+#
25
+#  - Mongoose
26
+#
27
+# Room Vertices are 28 bytes each
28
+# 3 floats representing the x,y,z values of vertex
29
+# 3 floats probably the vertex normals
30
+# 1 DWORD  probably diffuse color for the vertex
31
+# 
32
+# Rectangles are same old format of V0,V1,V2,V3,Texture, followed by
33
+# Int unknown, usually zero.
34
+# Texture needs to be masked with 0xfff (high 4 bits are flags)
35
+# 
36
+# Triangles are same old format of V0,V1,V2,Texture, followed by
37
+# Int unknown, usually zero.
38
+# Texture needs to be masked with 0xfff (high 4 bits are flags)
39
+# 
40
+# TR5 uses D3D extensively. The light format is a prime example. The last
41
+# byte in the light field before the CDCDCD is the light type which in
42
+# D3d is 1,2, or 3 for point, spot, or directional lights respectively.
43
+# Also somewhere in the unknowns must be the fog values.
44
+# 
45
+# Sound Map is now 900 bytes
46
+# 
47
+# Before SoundSources is a new field for Flyby_Camera data
48
+# bitu32 Number_of_FBCameras
49
+# followed by data for each camera. Data field is 40 bytes.
50
+# [Andy had previously stated NumXYZ as a new field incorrectly.
51
+# His NumXYZ field was the SoundSources in normal structure format]
52
+# 
53
+# 
54
+# Cinematic Frames now 24 bytes
55
+# 
56
+# There are no colored rectangles or triangles in mesh data.
57
+# Mesh Rectangles and Triangles now same format as room rects and tris,
58
+# MeshRects: v0,v1,v2,v3,texture,int unknown
59
+# MeshTris:  v0,v1,v2,texture,int unknown
60
+# Texture Objects now preceeded by TEX/0 (4bytes)
61
+# Object Textures now 38 bytes vice 20
62
+# Tile is now a bitu32 vice bitu16 seems need to mask with 0xff as other
63
+#        bits are flags. Seems bit15 set means triangle.
64
+# In the texture coords now 0 is used for low value vice 1
65
+# The extra 16 bytes at the end of ObjectTexture structure are 4 Dword
66
+#        coords, UV?.
67
+# Attributes using 1 or 2 for transparent. 2 used for 2 sided textures
68
+#                (water surface,etc)
69
+# 
70
+# 
71
+# Animation now 40 vice 32 bytes. extra 8 seem to be zero right before
72
+# /after the old 8 unknowns
73
+# 
74
+# "SPR"  3 byte ascii before sprite textures
75
+# 
76
+# As TR4 there are no 8bit or 16 bit palettes (no colored rects or tris)
77
+# No lightmap
78
+# No 8bit textures
79
+# 3 blocks of zlib compressed textures (32bit,16bit,sprite/misc)before
80
+# level data.
81
+# Level data not compressed.
82
+# 
83
+# Following level data are Riff Wave Formats.
84
+# 
85
+# Lara 2 meshes as TR4, skin and joints.
86
+# 
87
+# also , I was just reading thru the rectanges and triangles and
88
+# thought the vertices always followed right after but appears
89
+# that sometimes there is a 'pad' int of 0xCDCD.
90
+# 
91
+# 
92
+# Also as Michiel has just posted the Object Textures for TR5 are
93
+# 40bytes, sorry about that.
94
+#  - Roy
95
+#
96
+#############################################################################
97
+
98
+
99
+uint32 version;                   //  Will be "TR4\0" for valid header
100
+
101
+// Textures /////////////////
102
+bitu16 num_room_textures
103
+bitu16 number of num_other_textures
104
+bitu16 number of num_bump_map_textures
105
+bitu32 UncompressedSize1
106
+bitu32 CompressedSize1
107
+TextureBlock1
108
+bitu32 UncompressedSize2
109
+bitu32 CompressedSize2
110
+TextureBlock2
111
+bitu32 UncompressedSize3
112
+bitu32 CompressedSize3
113
+TextureBlock3
114
+
115
+/// Follows after textures
116
+
117
+
118
+32 bytes unknown //mostly zero
119
+bitu32 SizeData    // size of file to Riffs
120
+bitu32 SizeData    // repeat of above
121
+bitu32 Unknown     // seems always zero
122
+bitu32 NumberRooms // number of rooms this level
123
+
124
+{ Following Repeats for each Room in level
125
+
126
+bitu32 "XELA" (someone named Alex or "dirX Enhanced Level Archive"
127
+bitu32 size //size to next XELA block
128
+bitu32 CDCDCDCD
129
+
130
+Block1 60 bytes
131
+{
132
+
133
+bitu32 ublock1 //mostly: start of "XELA" +216 + ublock1 = FD end,
134
+                but have seen 0xffffffff. Better using next data
135
+                and compute FD size the old way of X*Z*8
136
+bitu32 ublock2 //  start of "XELA" + 216 + ublock2 = FD start
137
+bitu32 ublock3 // unknown
138
+bitu32 ublock4 // possibly start of "XELA" + 216 + ublock4 = end portals
139
+
140
+bitu32 Room X      // room's x position in world coords
141
+bitu32 unknown1    // always seems to be 0000
142
+bitu32 Room Z      // room's z position in world coords
143
+bitu32 Ybottom     // room's y bottom positon in world coords
144
+bitu32 Ytop        // room's y top positon in world coords
145
+
146
+Int  NumZSectors // number of z sectors
147
+Int  NumXSectors // number of x sectors
148
+
149
+tr2_color4        // 4 bytes color info rgba
150
+
151
+Int  NumLights
152
+Int  NumStaticMeshes
153
+
154
+bitu32 Unknown2    // seems always 0x0001
155
+bitu32 Unknown3    // seems always 0x7fff
156
+bitu32 Unknown4    // seems always 0x7fff
157
+
158
+}close 60 byte block
159
+
160
+bitu32 CDCDCDCD
161
+bitu32 CDCDCDCD
162
+
163
+20 byte block
164
+{
165
+6 bytes 0xff
166
+Int Room_Flag    //room attributes (rain,etc)
167
+Int unknown5
168
+10 bytes 0x00
169
+} close 20 byte block
170
+
171
+bitu32 CDCDCDCD
172
+
173
+16 byte block
174
+{
175
+unknown 16 bytes
176
+}close 16 byte block
177
+
178
+bitu32 CDCDCDCD
179
+bitu32 CDCDCDCD
180
+bitu32 CDCDCDCD
181
+bitu32 CDCDCDCD
182
+
183
+bitu32 Unknown6
184
+
185
+bitu32 CDCDCDCD
186
+
187
+56 byte block
188
+{
189
+bitu32 NumberTriangles
190
+bitu32 NumberRectangles
191
+bitu32 Unknown7 // always 0x0000 ??
192
+bitu32 LightSize // number lights times 88 bytes
193
+bitu32 NumberLights
194
+bitu32 NumUnknown_36_byte_struct
195
+bitu32 Unknown9
196
+bitu32 Unknown10
197
+bitu32 NumberLayers //TR5 'layers' room pieces
198
+bitu32 Unknown11    // start of "XELA" + 216 + Unknown11 = start of 
199
+layer 
200
+info
201
+bitu32 Unknown12    // start of "XELA" + 216 + Unknown12 = start of 
202
+vertices
203
+bitu32 Unknown13    // start of "XELA" + 216 + Unknown13 = start of 
204
+rect/tri
205
+bitu32 Unknown14    // same as Unknown13???
206
+bitu32 Unknown15    // start of vertices + Unknown15 = start of next 
207
+"XELA"
208
+}close 56 byte block
209
+
210
+bitu32 CDCDCDCD
211
+bitu32 CDCDCDCD
212
+bitu32 CDCDCDCD
213
+bitu32 CDCDCDCD
214
+
215
+// Lights //////////////////////////
216
+if lights then 85 bytes light data followed by CDCDCD for each light
217
+
218
+// Unknown /////////////////////////
219
+if NumUnknown_36_byte_struct then read them too
220
+
221
+// Sectors /////////////////////////
222
+Sector Data (sectors times 8 bytes) normal sector data structure
223
+
224
+// Portals /////////////////////////
225
+Int NumberDoors
226
+
227
+NumberDoors times 32 bytes (normal portal structure)
228
+
229
+Int CDCD
230
+
231
+// Static meshes //////////////////
232
+if StaticMeshes than numberofstatics times 20 bytes each (normal 
233
+structure)
234
+
235
+
236
+// Layers ////////////////////////
237
+Layer Data blocks. 56 bytes each.
238
+{
239
+   bitu32 NumberVertices
240
+   Int  Unknown16
241
+   Int  NumberRectangles
242
+   Int  NumberTriangles
243
+
244
+   unknown 46 bytes // was 48 in older docs
245
+
246
+}close Layer Data block
247
+
248
+following the Layer Data block are:
249
+  rectangles for Layer1 // see format under NOTES
250
+  triangles  for Layer1 // see format under NOTES
251
+  rectangles for Layer2
252
+  triangles  for Layer2
253
+
254
+  ...and so on untill all layers are done
255
+
256
+after the rectangle and triangle information are the room vertices
257
+which are described under NOTES
258
+
259
+
260
+}Close Rooms Loop
261
+
262
+
263
+

+ 7012
- 0
doc/TRosettaStone.html
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 82
- 0
doc/ankrace.notes 파일 보기

@@ -0,0 +1,82 @@
1
+Mesh list from ang_race.tr4  ( heads may be for lip syncing )
2
+
3
+I examined the meshes in my Freyja modeler and asmebled them
4
+to identify them.  -- Mongoose
5
+
6
+00 - lara small torso w/ pack
7
+..
8
+29 - "    "     "  "   ( error? )
9
+30 - lara hips w/ belt
10
+31 - lara thigh ( left? )
11
+32 - lara lower leg ( left? )
12
+33 - lara shoe ( left? )
13
+34 - lara thigh ( right? )
14
+35 - lara lower leg ( right? )
15
+36 - lara shoe ( right? )
16
+37 - lara torso w/o pack
17
+38 - lara upper arm ( right )
18
+39 - lara lower arm ( right )
19
+40 - lara hand ( right )
20
+41 - lara upper arm ( left )
21
+42 - lara lower arm ( left )
22
+43 - lara hand ( left )
23
+44 - lara head
24
+45 - lara 'plate of skin thingy'
25
+46 - lara part of pants ring ( left? )
26
+47 - lara knee ( left? )
27
+48 - lara small boot ring ( left? )
28
+49 - lara part of pants ring ( right? )
29
+50 - lara knee ( right? )
30
+51 - lara small boot ring ( right? )
31
+52 - lara midriff
32
+53 - lara shoulder ( left? )      -- was right
33
+54 - lara elbow ( left? )      -- was right
34
+55 - lara wrist ( left? )      -- was right
35
+56 - lara shoulder ( right? )
36
+57 - lara elbow ( right? )
37
+58 - lara wrist ( right? )
38
+59 - lara neck
39
+60 - lara torso ( seems to be sized for game model )
40
+61 - lara another small torso ( error? )
41
+..
42
+73 - " " " " ( error? )
43
+74 - lara head ( gnashing teeth )
44
+75 - lara another small torso ( error? )
45
+..
46
+88 - " " " " ( error? )
47
+89 - lara head ( puzzled look? )
48
+90 - lara another small torso ( error? )
49
+..
50
+103 - " " " " ( error? )
51
+104 - lara head ( happy look? )
52
+105 - lara another small torso ( error? )
53
+..
54
+118 - " " " " ( error? )
55
+119 - lara head ( 'sshha' look? )
56
+120 - lara another small torso ( error? )
57
+..
58
+133 - " " " " ( error? )
59
+134 - lara head ( mouth closed )
60
+135 - lara another small torso ( error? )
61
+..
62
+155 - " " " " ( error? )
63
+156 - von croy head ( mouth closed )
64
+157 - lara another small torso ( error? )
65
+..
66
+180 - " " " " ( error? )
67
+181 - von croy head ( mouth open )
68
+182 - lara another small torso ( error? )
69
+..
70
+184 - " " " " ( error? )
71
+185 - lara ponytail ( 1, Added to head )
72
+186 - lara ponytail ( 2 )
73
+187 - lara ponytail ( 3 )
74
+188 - lara ponytail ( 4 )
75
+189 - lara ponytail ( 5, ends with band )
76
+190 - lara ponytail ( 6, end of ponytail )
77
+191 - von croy hat brim?
78
+192 - von croy upper leg ( left? )
79
+193 - von croy lower leg ( left? )
80
+194 - von croy foot ( left? )
81
+
82
+Stopped here - goes to 526

+ 18
- 0
fix-gcc3.sh 파일 보기

@@ -0,0 +1,18 @@
1
+#!/bin/sh
2
+
3
+if [ -f src/endian.h ]
4
+then
5
+    echo GCC 3.x fix...
6
+    mv src/endian.h src/mendian.h
7
+
8
+    for i in `grep -l "endian.h" src/*.* src/*/*.*`; do mv $i $i.old && sed -e "s/endian.h/mendian.h/" $i.old > $i; done
9
+else
10
+    echo Removing GCC 3.x fix... 
11
+    mv src/mendian.h src/endian.h
12
+
13
+    for i in `grep -l "mendian.h" src/*.* src/*/*.*`; do mv $i $i.old && sed -e "s/mendian.h/endian.h/" $i.old > $i; done
14
+
15
+#    for i in `find . -name "*.old"`; do echo $i > sed.0 && mv $i `sed -e "s/.old//" sed.0`; done
16
+#
17
+#    rm -d sed.0
18
+fi

+ 211
- 0
msvc/OpenRaider/OpenRaider.dsp 파일 보기

@@ -0,0 +1,211 @@
1
+# Microsoft Developer Studio Project File - Name="OpenRaider" - Package Owner=<4>
2
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
3
+# ** DO NOT EDIT **
4
+
5
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
6
+
7
+CFG=OpenRaider - Win32 Debug
8
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9
+!MESSAGE use the Export Makefile command and run
10
+!MESSAGE 
11
+!MESSAGE NMAKE /f "OpenRaider.mak".
12
+!MESSAGE 
13
+!MESSAGE You can specify a configuration when running NMAKE
14
+!MESSAGE by defining the macro CFG on the command line. For example:
15
+!MESSAGE 
16
+!MESSAGE NMAKE /f "OpenRaider.mak" CFG="OpenRaider - Win32 Debug"
17
+!MESSAGE 
18
+!MESSAGE Possible choices for configuration are:
19
+!MESSAGE 
20
+!MESSAGE "OpenRaider - Win32 Release" (based on\
21
+ "Win32 (x86) Console Application")
22
+!MESSAGE "OpenRaider - Win32 Debug" (based on\
23
+ "Win32 (x86) Console Application")
24
+!MESSAGE 
25
+
26
+# Begin Project
27
+# PROP Scc_ProjName ""
28
+# PROP Scc_LocalPath ""
29
+CPP=cl.exe
30
+RSC=rc.exe
31
+
32
+!IF  "$(CFG)" == "OpenRaider - Win32 Release"
33
+
34
+# PROP BASE Use_MFC 0
35
+# PROP BASE Use_Debug_Libraries 0
36
+# PROP BASE Output_Dir "Release"
37
+# PROP BASE Intermediate_Dir "Release"
38
+# PROP BASE Target_Dir ""
39
+# PROP Use_MFC 0
40
+# PROP Use_Debug_Libraries 0
41
+# PROP Output_Dir "../../bin/release.win32"
42
+# PROP Intermediate_Dir "../../bin/release.win32"
43
+# PROP Ignore_Export_Lib 0
44
+# PROP Target_Dir ""
45
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
46
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
47
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
48
+# ADD RSC /l 0x409 /d "NDEBUG"
49
+BSC32=bscmake.exe
50
+# ADD BASE BSC32 /nologo
51
+# ADD BSC32 /nologo
52
+LINK32=link.exe
53
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
54
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
55
+
56
+!ELSEIF  "$(CFG)" == "OpenRaider - Win32 Debug"
57
+
58
+# PROP BASE Use_MFC 0
59
+# PROP BASE Use_Debug_Libraries 1
60
+# PROP BASE Output_Dir "Debug"
61
+# PROP BASE Intermediate_Dir "Debug"
62
+# PROP BASE Target_Dir ""
63
+# PROP Use_MFC 0
64
+# PROP Use_Debug_Libraries 1
65
+# PROP Output_Dir "../../bin/debug.win32"
66
+# PROP Intermediate_Dir "../../bin/debug.win32"
67
+# PROP Ignore_Export_Lib 0
68
+# PROP Target_Dir ""
69
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
70
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "DEBUG" /D "EXPERIMENTAL" /D "GLUT_INTERFACE" /YX /FD /c
71
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
72
+# ADD RSC /l 0x409 /d "_DEBUG"
73
+BSC32=bscmake.exe
74
+# ADD BASE BSC32 /nologo
75
+# ADD BSC32 /nologo
76
+LINK32=link.exe
77
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
78
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glut32.lib glu32.lib zlib.dll /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
79
+
80
+!ENDIF 
81
+
82
+# Begin Target
83
+
84
+# Name "OpenRaider - Win32 Release"
85
+# Name "OpenRaider - Win32 Debug"
86
+# Begin Source File
87
+
88
+SOURCE=..\..\src\Camera.cpp
89
+# End Source File
90
+# Begin Source File
91
+
92
+SOURCE=..\..\src\Camera.h
93
+# End Source File
94
+# Begin Source File
95
+
96
+SOURCE=..\..\src\Emitter.cpp
97
+# End Source File
98
+# Begin Source File
99
+
100
+SOURCE=..\..\src\Emitter.h
101
+# End Source File
102
+# Begin Source File
103
+
104
+SOURCE=..\..\src\gl_test.cpp
105
+# End Source File
106
+# Begin Source File
107
+
108
+SOURCE=..\..\src\gl_util.cpp
109
+# End Source File
110
+# Begin Source File
111
+
112
+SOURCE=..\..\src\gl_util.h
113
+# End Source File
114
+# Begin Source File
115
+
116
+SOURCE=..\..\src\GLString.cpp
117
+# End Source File
118
+# Begin Source File
119
+
120
+SOURCE=..\..\src\GLString.h
121
+# End Source File
122
+# Begin Source File
123
+
124
+SOURCE=..\..\src\List.h
125
+# End Source File
126
+# Begin Source File
127
+
128
+SOURCE=..\..\src\main.cpp
129
+# End Source File
130
+# Begin Source File
131
+
132
+SOURCE=..\..\src\main.h
133
+# End Source File
134
+# Begin Source File
135
+
136
+SOURCE=..\..\src\Map.h
137
+# End Source File
138
+# Begin Source File
139
+
140
+SOURCE=..\..\src\mtk3d.cpp
141
+# End Source File
142
+# Begin Source File
143
+
144
+SOURCE=..\..\src\mtk3d.h
145
+# End Source File
146
+# Begin Source File
147
+
148
+SOURCE=..\..\src\mtk_tga.cpp
149
+# End Source File
150
+# Begin Source File
151
+
152
+SOURCE=..\..\src\mtk_tga.h
153
+# End Source File
154
+# Begin Source File
155
+
156
+SOURCE=..\..\src\OpenRaider.cpp
157
+# End Source File
158
+# Begin Source File
159
+
160
+SOURCE=..\..\src\OpenRaider.h
161
+# End Source File
162
+# Begin Source File
163
+
164
+SOURCE=..\..\src\Particle.cpp
165
+# End Source File
166
+# Begin Source File
167
+
168
+SOURCE=..\..\src\Particle.h
169
+# End Source File
170
+# Begin Source File
171
+
172
+SOURCE=..\..\src\Render.cpp
173
+# End Source File
174
+# Begin Source File
175
+
176
+SOURCE=..\..\src\Render.h
177
+# End Source File
178
+# Begin Source File
179
+
180
+SOURCE=..\..\src\Resource.cpp
181
+# End Source File
182
+# Begin Source File
183
+
184
+SOURCE=..\..\src\Resource.h
185
+# End Source File
186
+# Begin Source File
187
+
188
+SOURCE=..\..\src\Sound.cpp
189
+# End Source File
190
+# Begin Source File
191
+
192
+SOURCE=..\..\src\Sound.h
193
+# End Source File
194
+# Begin Source File
195
+
196
+SOURCE=..\..\src\Texture.cpp
197
+# End Source File
198
+# Begin Source File
199
+
200
+SOURCE=..\..\src\Texture.h
201
+# End Source File
202
+# Begin Source File
203
+
204
+SOURCE=..\..\src\TombRaider.cpp
205
+# End Source File
206
+# Begin Source File
207
+
208
+SOURCE=..\..\src\TombRaider.h
209
+# End Source File
210
+# End Target
211
+# End Project

+ 29
- 0
msvc/OpenRaider/OpenRaider.dsw 파일 보기

@@ -0,0 +1,29 @@
1
+Microsoft Developer Studio Workspace File, Format Version 5.00
2
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
3
+
4
+###############################################################################
5
+
6
+Project: "OpenRaider"=".\OpenRaider.dsp" - Package Owner=<4>
7
+
8
+Package=<5>
9
+{{{
10
+}}}
11
+
12
+Package=<4>
13
+{{{
14
+}}}
15
+
16
+###############################################################################
17
+
18
+Global:
19
+
20
+Package=<5>
21
+{{{
22
+}}}
23
+
24
+Package=<3>
25
+{{{
26
+}}}
27
+
28
+###############################################################################
29
+

BIN
msvc/OpenRaider/OpenRaider.ncb 파일 보기


BIN
msvc/OpenRaider/OpenRaider.opt 파일 보기


+ 674
- 0
msvc/OpenRaider/OpenRaider.plg 파일 보기

@@ -0,0 +1,674 @@
1
+--------------------Configuration: OpenRaider - Win32 Debug--------------------
2
+Begining build with project "C:\projects\OpenRaider\OpenRaider-0.0.3\msvc\OpenRaider\OpenRaider.dsp", at root.
3
+Active configuration is Win32 (x86) Console Application (based on Win32 (x86) Console Application)
4
+
5
+Project's tools are:
6
+			"32-bit C/C++ Compiler for 80x86" with flags "/nologo /MLd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "DEBUG" /D "EXPERIMENTAL" /D "GLUT_INTERFACE" /Fp"../../bin/debug.win32/OpenRaider.pch" /YX /Fo"../../bin/debug.win32/" /Fd"../../bin/debug.win32/" /FD /c "
7
+			"Win32 Resource Compiler" with flags "/l 0x409 /d "_DEBUG" "
8
+			"Browser Database Maker" with flags "/nologo /o"../../bin/debug.win32/OpenRaider.bsc" "
9
+			"COFF Linker for 80x86" with flags "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glut32.lib glu32.lib zlib.dll /nologo /subsystem:console /incremental:yes /pdb:"../../bin/debug.win32/OpenRaider.pdb" /debug /machine:I386 /out:"../../bin/debug.win32/OpenRaider.exe" /pdbtype:sept "
10
+			"Custom Build" with flags ""
11
+			"<Component 0xa>" with flags ""
12
+
13
+Creating temp file "C:\TEMP\RSP26.tmp" with contents </nologo /MLd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "DEBUG" /D "EXPERIMENTAL" /D "GLUT_INTERFACE" /Fp"../../bin/debug.win32/OpenRaider.pch" /YX /Fo"../../bin/debug.win32/" /Fd"../../bin/debug.win32/" /FD /c 
14
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\Camera.cpp"
15
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\Emitter.cpp"
16
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_test.cpp"
17
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp"
18
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\GLString.cpp"
19
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\main.cpp"
20
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp"
21
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk_tga.cpp"
22
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\OpenRaider.cpp"
23
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\Particle.cpp"
24
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\Render.cpp"
25
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp"
26
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\Sound.cpp"
27
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\Texture.cpp"
28
+"C:\projects\OpenRaider\OpenRaider-0.0.3\src\TombRaider.cpp"
29
+>
30
+Creating command line "cl.exe @C:\TEMP\RSP26.tmp" 
31
+Creating temp file "C:\TEMP\RSP27.tmp" with contents <kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glut32.lib glu32.lib zlib.dll /nologo /subsystem:console /incremental:yes /pdb:"../../bin/debug.win32/OpenRaider.pdb" /debug /machine:I386 /out:"../../bin/debug.win32/OpenRaider.exe" /pdbtype:sept 
32
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\Camera.obj"
33
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\Emitter.obj"
34
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\gl_test.obj"
35
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\gl_util.obj"
36
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\GLString.obj"
37
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\main.obj"
38
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\mtk3d.obj"
39
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\mtk_tga.obj"
40
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\OpenRaider.obj"
41
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\Particle.obj"
42
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\Render.obj"
43
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\Resource.obj"
44
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\Sound.obj"
45
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\Texture.obj"
46
+"\projects\OpenRaider\OpenRaider-0.0.3\bin\debug.win32\TombRaider.obj">
47
+Creating command line "link.exe @C:\TEMP\RSP27.tmp" 
48
+Compiling...
49
+Camera.cpp
50
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2501: 'WINGDIAPI' : missing decl-specifiers
51
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
52
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2062: type 'void' unexpected
53
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2501: 'WINGDIAPI' : missing decl-specifiers
54
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2086: 'WINGDIAPI' : redefinition
55
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
56
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2062: type 'void' unexpected
57
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2501: 'WINGDIAPI' : missing decl-specifiers
58
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2086: 'WINGDIAPI' : redefinition
59
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2239: unexpected token 'identifier' following declaration of 'WINGDIAPI'
60
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2061: syntax error : identifier 'GLboolean'
61
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2501: 'WINGDIAPI' : missing decl-specifiers
62
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2086: 'WINGDIAPI' : redefinition
63
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
64
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2062: type 'void' unexpected
65
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2501: 'WINGDIAPI' : missing decl-specifiers
66
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2086: 'WINGDIAPI' : redefinition
67
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
68
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2062: type 'void' unexpected
69
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2501: 'WINGDIAPI' : missing decl-specifiers
70
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2086: 'WINGDIAPI' : redefinition
71
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
72
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2062: type 'void' unexpected
73
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2501: 'WINGDIAPI' : missing decl-specifiers
74
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2086: 'WINGDIAPI' : redefinition
75
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
76
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2062: type 'void' unexpected
77
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2501: 'WINGDIAPI' : missing decl-specifiers
78
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2086: 'WINGDIAPI' : redefinition
79
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
80
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2062: type 'void' unexpected
81
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2501: 'WINGDIAPI' : missing decl-specifiers
82
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2086: 'WINGDIAPI' : redefinition
83
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
84
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2062: type 'void' unexpected
85
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2501: 'WINGDIAPI' : missing decl-specifiers
86
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2086: 'WINGDIAPI' : redefinition
87
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
88
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2062: type 'void' unexpected
89
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2501: 'WINGDIAPI' : missing decl-specifiers
90
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2086: 'WINGDIAPI' : redefinition
91
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
92
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2062: type 'void' unexpected
93
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2501: 'WINGDIAPI' : missing decl-specifiers
94
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2086: 'WINGDIAPI' : redefinition
95
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
96
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2062: type 'void' unexpected
97
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2501: 'WINGDIAPI' : missing decl-specifiers
98
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2086: 'WINGDIAPI' : redefinition
99
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
100
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2062: type 'void' unexpected
101
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2501: 'WINGDIAPI' : missing decl-specifiers
102
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2086: 'WINGDIAPI' : redefinition
103
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
104
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2062: type 'void' unexpected
105
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2501: 'WINGDIAPI' : missing decl-specifiers
106
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2086: 'WINGDIAPI' : redefinition
107
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
108
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2062: type 'void' unexpected
109
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2501: 'WINGDIAPI' : missing decl-specifiers
110
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2086: 'WINGDIAPI' : redefinition
111
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
112
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2062: type 'void' unexpected
113
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2501: 'WINGDIAPI' : missing decl-specifiers
114
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2086: 'WINGDIAPI' : redefinition
115
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
116
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2062: type 'void' unexpected
117
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2501: 'WINGDIAPI' : missing decl-specifiers
118
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2086: 'WINGDIAPI' : redefinition
119
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
120
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2062: type 'void' unexpected
121
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2501: 'WINGDIAPI' : missing decl-specifiers
122
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2086: 'WINGDIAPI' : redefinition
123
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
124
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2062: type 'void' unexpected
125
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2501: 'WINGDIAPI' : missing decl-specifiers
126
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2086: 'WINGDIAPI' : redefinition
127
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
128
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2062: type 'void' unexpected
129
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2501: 'WINGDIAPI' : missing decl-specifiers
130
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2086: 'WINGDIAPI' : redefinition
131
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
132
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2062: type 'void' unexpected
133
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2501: 'WINGDIAPI' : missing decl-specifiers
134
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2086: 'WINGDIAPI' : redefinition
135
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
136
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2062: type 'void' unexpected
137
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2501: 'WINGDIAPI' : missing decl-specifiers
138
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2086: 'WINGDIAPI' : redefinition
139
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
140
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2062: type 'void' unexpected
141
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2501: 'WINGDIAPI' : missing decl-specifiers
142
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2086: 'WINGDIAPI' : redefinition
143
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
144
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2062: type 'void' unexpected
145
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2501: 'WINGDIAPI' : missing decl-specifiers
146
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2086: 'WINGDIAPI' : redefinition
147
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
148
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2062: type 'void' unexpected
149
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : error C2501: 'WINGDIAPI' : missing decl-specifiers
150
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : error C2086: 'WINGDIAPI' : redefinition
151
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : fatal error C1003: error count exceeds 100; stopping compilation
152
+Emitter.cpp
153
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2501: 'WINGDIAPI' : missing decl-specifiers
154
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
155
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2062: type 'void' unexpected
156
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2501: 'WINGDIAPI' : missing decl-specifiers
157
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2086: 'WINGDIAPI' : redefinition
158
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
159
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2062: type 'void' unexpected
160
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2501: 'WINGDIAPI' : missing decl-specifiers
161
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2086: 'WINGDIAPI' : redefinition
162
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2239: unexpected token 'identifier' following declaration of 'WINGDIAPI'
163
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2061: syntax error : identifier 'GLboolean'
164
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2501: 'WINGDIAPI' : missing decl-specifiers
165
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2086: 'WINGDIAPI' : redefinition
166
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
167
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2062: type 'void' unexpected
168
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2501: 'WINGDIAPI' : missing decl-specifiers
169
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2086: 'WINGDIAPI' : redefinition
170
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
171
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2062: type 'void' unexpected
172
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2501: 'WINGDIAPI' : missing decl-specifiers
173
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2086: 'WINGDIAPI' : redefinition
174
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
175
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2062: type 'void' unexpected
176
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2501: 'WINGDIAPI' : missing decl-specifiers
177
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2086: 'WINGDIAPI' : redefinition
178
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
179
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2062: type 'void' unexpected
180
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2501: 'WINGDIAPI' : missing decl-specifiers
181
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2086: 'WINGDIAPI' : redefinition
182
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
183
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2062: type 'void' unexpected
184
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2501: 'WINGDIAPI' : missing decl-specifiers
185
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2086: 'WINGDIAPI' : redefinition
186
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
187
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2062: type 'void' unexpected
188
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2501: 'WINGDIAPI' : missing decl-specifiers
189
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2086: 'WINGDIAPI' : redefinition
190
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
191
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2062: type 'void' unexpected
192
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2501: 'WINGDIAPI' : missing decl-specifiers
193
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2086: 'WINGDIAPI' : redefinition
194
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
195
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2062: type 'void' unexpected
196
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2501: 'WINGDIAPI' : missing decl-specifiers
197
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2086: 'WINGDIAPI' : redefinition
198
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
199
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2062: type 'void' unexpected
200
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2501: 'WINGDIAPI' : missing decl-specifiers
201
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2086: 'WINGDIAPI' : redefinition
202
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
203
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2062: type 'void' unexpected
204
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2501: 'WINGDIAPI' : missing decl-specifiers
205
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2086: 'WINGDIAPI' : redefinition
206
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
207
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2062: type 'void' unexpected
208
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2501: 'WINGDIAPI' : missing decl-specifiers
209
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2086: 'WINGDIAPI' : redefinition
210
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
211
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2062: type 'void' unexpected
212
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2501: 'WINGDIAPI' : missing decl-specifiers
213
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2086: 'WINGDIAPI' : redefinition
214
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
215
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2062: type 'void' unexpected
216
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2501: 'WINGDIAPI' : missing decl-specifiers
217
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2086: 'WINGDIAPI' : redefinition
218
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
219
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2062: type 'void' unexpected
220
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2501: 'WINGDIAPI' : missing decl-specifiers
221
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2086: 'WINGDIAPI' : redefinition
222
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
223
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2062: type 'void' unexpected
224
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2501: 'WINGDIAPI' : missing decl-specifiers
225
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2086: 'WINGDIAPI' : redefinition
226
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
227
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2062: type 'void' unexpected
228
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2501: 'WINGDIAPI' : missing decl-specifiers
229
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2086: 'WINGDIAPI' : redefinition
230
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
231
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2062: type 'void' unexpected
232
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2501: 'WINGDIAPI' : missing decl-specifiers
233
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2086: 'WINGDIAPI' : redefinition
234
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
235
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2062: type 'void' unexpected
236
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2501: 'WINGDIAPI' : missing decl-specifiers
237
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2086: 'WINGDIAPI' : redefinition
238
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
239
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2062: type 'void' unexpected
240
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2501: 'WINGDIAPI' : missing decl-specifiers
241
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2086: 'WINGDIAPI' : redefinition
242
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
243
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2062: type 'void' unexpected
244
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2501: 'WINGDIAPI' : missing decl-specifiers
245
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2086: 'WINGDIAPI' : redefinition
246
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
247
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2062: type 'void' unexpected
248
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2501: 'WINGDIAPI' : missing decl-specifiers
249
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2086: 'WINGDIAPI' : redefinition
250
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
251
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2062: type 'void' unexpected
252
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : error C2501: 'WINGDIAPI' : missing decl-specifiers
253
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : error C2086: 'WINGDIAPI' : redefinition
254
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : fatal error C1003: error count exceeds 100; stopping compilation
255
+gl_test.cpp
256
+gl_util.cpp
257
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(27) : error C2065: 'GLint' : undeclared identifier
258
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(27) : error C2146: syntax error : missing ')' before identifier 'x'
259
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(27) : error C2182: 'glPrint' : illegal use of type 'void'
260
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(27) : error C2371: 'glPrint' : redefinition; different basic types
261
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(27) : error C2059: syntax error : ')'
262
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(33) : error C2065: 'GL_TEXTURE_2D' : undeclared identifier
263
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(33) : error C2065: 'texture' : undeclared identifier
264
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(33) : error C2109: subscript requires array or pointer type
265
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(33) : error C2501: 'glBindTexture' : missing decl-specifiers
266
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(33) : error C2078: too many initializers
267
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(36) : error C2065: 'GL_DEPTH_TEST' : undeclared identifier
268
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(36) : error C2501: 'glDisable' : missing decl-specifiers
269
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(39) : error C2065: 'GL_PROJECTION' : undeclared identifier
270
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(39) : error C2501: 'glMatrixMode' : missing decl-specifiers
271
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(46) : error C2065: '_width' : undeclared identifier
272
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(46) : error C2065: '_height' : undeclared identifier
273
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(46) : error C2501: 'glOrtho' : missing decl-specifiers
274
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(46) : error C2078: too many initializers
275
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(49) : error C2065: 'GL_MODELVIEW' : undeclared identifier
276
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(49) : error C2501: 'glMatrixMode' : missing decl-specifiers
277
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(49) : error C2086: 'glMatrixMode' : redefinition
278
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(56) : error C2065: 'x' : undeclared identifier
279
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(56) : error C2065: 'y' : undeclared identifier
280
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(56) : error C2501: 'glTranslated' : missing decl-specifiers
281
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(56) : error C2078: too many initializers
282
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(59) : error C2065: 'base' : undeclared identifier
283
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(59) : error C2065: 'set' : undeclared identifier
284
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(59) : error C2501: 'glListBase' : missing decl-specifiers
285
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(62) : error C2065: 'strlen' : undeclared identifier
286
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(62) : error C2065: 'string' : undeclared identifier
287
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(62) : error C2065: 'GL_BYTE' : undeclared identifier
288
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(62) : error C2501: 'glCallLists' : missing decl-specifiers
289
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(62) : error C2078: too many initializers
290
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(65) : error C2501: 'glMatrixMode' : missing decl-specifiers
291
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(65) : error C2086: 'glMatrixMode' : redefinition
292
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(70) : error C2501: 'glMatrixMode' : missing decl-specifiers
293
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(70) : error C2086: 'glMatrixMode' : redefinition
294
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(75) : error C2501: 'glEnable' : missing decl-specifiers
295
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\gl_util.cpp(76) : error C2143: syntax error : missing ';' before '}'
296
+GLString.cpp
297
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2501: 'WINGDIAPI' : missing decl-specifiers
298
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
299
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2062: type 'void' unexpected
300
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2501: 'WINGDIAPI' : missing decl-specifiers
301
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2086: 'WINGDIAPI' : redefinition
302
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
303
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2062: type 'void' unexpected
304
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2501: 'WINGDIAPI' : missing decl-specifiers
305
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2086: 'WINGDIAPI' : redefinition
306
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2239: unexpected token 'identifier' following declaration of 'WINGDIAPI'
307
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2061: syntax error : identifier 'GLboolean'
308
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2501: 'WINGDIAPI' : missing decl-specifiers
309
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2086: 'WINGDIAPI' : redefinition
310
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
311
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2062: type 'void' unexpected
312
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2501: 'WINGDIAPI' : missing decl-specifiers
313
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2086: 'WINGDIAPI' : redefinition
314
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
315
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2062: type 'void' unexpected
316
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2501: 'WINGDIAPI' : missing decl-specifiers
317
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2086: 'WINGDIAPI' : redefinition
318
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
319
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2062: type 'void' unexpected
320
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2501: 'WINGDIAPI' : missing decl-specifiers
321
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2086: 'WINGDIAPI' : redefinition
322
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
323
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2062: type 'void' unexpected
324
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2501: 'WINGDIAPI' : missing decl-specifiers
325
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2086: 'WINGDIAPI' : redefinition
326
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
327
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2062: type 'void' unexpected
328
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2501: 'WINGDIAPI' : missing decl-specifiers
329
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2086: 'WINGDIAPI' : redefinition
330
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
331
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2062: type 'void' unexpected
332
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2501: 'WINGDIAPI' : missing decl-specifiers
333
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2086: 'WINGDIAPI' : redefinition
334
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
335
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2062: type 'void' unexpected
336
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2501: 'WINGDIAPI' : missing decl-specifiers
337
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2086: 'WINGDIAPI' : redefinition
338
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
339
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2062: type 'void' unexpected
340
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2501: 'WINGDIAPI' : missing decl-specifiers
341
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2086: 'WINGDIAPI' : redefinition
342
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
343
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2062: type 'void' unexpected
344
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2501: 'WINGDIAPI' : missing decl-specifiers
345
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2086: 'WINGDIAPI' : redefinition
346
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
347
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2062: type 'void' unexpected
348
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2501: 'WINGDIAPI' : missing decl-specifiers
349
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2086: 'WINGDIAPI' : redefinition
350
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
351
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2062: type 'void' unexpected
352
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2501: 'WINGDIAPI' : missing decl-specifiers
353
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2086: 'WINGDIAPI' : redefinition
354
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
355
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2062: type 'void' unexpected
356
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2501: 'WINGDIAPI' : missing decl-specifiers
357
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2086: 'WINGDIAPI' : redefinition
358
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
359
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2062: type 'void' unexpected
360
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2501: 'WINGDIAPI' : missing decl-specifiers
361
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2086: 'WINGDIAPI' : redefinition
362
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
363
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2062: type 'void' unexpected
364
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2501: 'WINGDIAPI' : missing decl-specifiers
365
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2086: 'WINGDIAPI' : redefinition
366
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
367
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2062: type 'void' unexpected
368
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2501: 'WINGDIAPI' : missing decl-specifiers
369
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2086: 'WINGDIAPI' : redefinition
370
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
371
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2062: type 'void' unexpected
372
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2501: 'WINGDIAPI' : missing decl-specifiers
373
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2086: 'WINGDIAPI' : redefinition
374
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
375
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2062: type 'void' unexpected
376
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2501: 'WINGDIAPI' : missing decl-specifiers
377
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2086: 'WINGDIAPI' : redefinition
378
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
379
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2062: type 'void' unexpected
380
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2501: 'WINGDIAPI' : missing decl-specifiers
381
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2086: 'WINGDIAPI' : redefinition
382
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
383
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2062: type 'void' unexpected
384
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2501: 'WINGDIAPI' : missing decl-specifiers
385
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2086: 'WINGDIAPI' : redefinition
386
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
387
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2062: type 'void' unexpected
388
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2501: 'WINGDIAPI' : missing decl-specifiers
389
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2086: 'WINGDIAPI' : redefinition
390
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
391
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2062: type 'void' unexpected
392
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2501: 'WINGDIAPI' : missing decl-specifiers
393
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2086: 'WINGDIAPI' : redefinition
394
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
395
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2062: type 'void' unexpected
396
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : error C2501: 'WINGDIAPI' : missing decl-specifiers
397
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : error C2086: 'WINGDIAPI' : redefinition
398
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : fatal error C1003: error count exceeds 100; stopping compilation
399
+main.cpp
400
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\main.cpp(35) : fatal error C1083: Cannot open include file: 'GL/glut.h': No such file or directory
401
+mtk3d.cpp
402
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(50) : warning C4244: 'return' : conversion from 'double' to 'float', possible loss of data
403
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(56) : warning C4244: 'return' : conversion from 'double' to 'float', possible loss of data
404
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(61) : warning C4244: 'return' : conversion from 'double' to 'float', possible loss of data
405
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(130) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
406
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(130) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
407
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(131) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
408
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(131) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
409
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(134) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
410
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(134) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
411
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(136) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
412
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(136) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
413
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(139) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
414
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(139) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
415
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(140) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
416
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(140) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
417
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(184) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
418
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(190) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
419
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk3d.cpp(196) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
420
+mtk_tga.cpp
421
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\mtk_tga.cpp(226) : error C2106: '=' : left operand must be l-value
422
+OpenRaider.cpp
423
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\OpenRaider.cpp(28) : fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
424
+Particle.cpp
425
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Particle.cpp(33) : warning C4305: 'argument' : truncation from 'const double' to 'float'
426
+Render.cpp
427
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2501: 'WINGDIAPI' : missing decl-specifiers
428
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
429
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2062: type 'void' unexpected
430
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2501: 'WINGDIAPI' : missing decl-specifiers
431
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2086: 'WINGDIAPI' : redefinition
432
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
433
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2062: type 'void' unexpected
434
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2501: 'WINGDIAPI' : missing decl-specifiers
435
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2086: 'WINGDIAPI' : redefinition
436
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2239: unexpected token 'identifier' following declaration of 'WINGDIAPI'
437
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2061: syntax error : identifier 'GLboolean'
438
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2501: 'WINGDIAPI' : missing decl-specifiers
439
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2086: 'WINGDIAPI' : redefinition
440
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
441
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2062: type 'void' unexpected
442
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2501: 'WINGDIAPI' : missing decl-specifiers
443
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2086: 'WINGDIAPI' : redefinition
444
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
445
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2062: type 'void' unexpected
446
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2501: 'WINGDIAPI' : missing decl-specifiers
447
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2086: 'WINGDIAPI' : redefinition
448
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
449
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2062: type 'void' unexpected
450
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2501: 'WINGDIAPI' : missing decl-specifiers
451
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2086: 'WINGDIAPI' : redefinition
452
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
453
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2062: type 'void' unexpected
454
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2501: 'WINGDIAPI' : missing decl-specifiers
455
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2086: 'WINGDIAPI' : redefinition
456
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
457
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2062: type 'void' unexpected
458
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2501: 'WINGDIAPI' : missing decl-specifiers
459
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2086: 'WINGDIAPI' : redefinition
460
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
461
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2062: type 'void' unexpected
462
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2501: 'WINGDIAPI' : missing decl-specifiers
463
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2086: 'WINGDIAPI' : redefinition
464
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
465
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2062: type 'void' unexpected
466
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2501: 'WINGDIAPI' : missing decl-specifiers
467
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2086: 'WINGDIAPI' : redefinition
468
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
469
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2062: type 'void' unexpected
470
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2501: 'WINGDIAPI' : missing decl-specifiers
471
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2086: 'WINGDIAPI' : redefinition
472
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
473
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2062: type 'void' unexpected
474
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2501: 'WINGDIAPI' : missing decl-specifiers
475
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2086: 'WINGDIAPI' : redefinition
476
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
477
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2062: type 'void' unexpected
478
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2501: 'WINGDIAPI' : missing decl-specifiers
479
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2086: 'WINGDIAPI' : redefinition
480
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
481
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2062: type 'void' unexpected
482
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2501: 'WINGDIAPI' : missing decl-specifiers
483
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2086: 'WINGDIAPI' : redefinition
484
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
485
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2062: type 'void' unexpected
486
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2501: 'WINGDIAPI' : missing decl-specifiers
487
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2086: 'WINGDIAPI' : redefinition
488
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
489
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2062: type 'void' unexpected
490
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2501: 'WINGDIAPI' : missing decl-specifiers
491
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2086: 'WINGDIAPI' : redefinition
492
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
493
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2062: type 'void' unexpected
494
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2501: 'WINGDIAPI' : missing decl-specifiers
495
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2086: 'WINGDIAPI' : redefinition
496
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
497
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2062: type 'void' unexpected
498
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2501: 'WINGDIAPI' : missing decl-specifiers
499
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2086: 'WINGDIAPI' : redefinition
500
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
501
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2062: type 'void' unexpected
502
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2501: 'WINGDIAPI' : missing decl-specifiers
503
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2086: 'WINGDIAPI' : redefinition
504
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
505
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2062: type 'void' unexpected
506
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2501: 'WINGDIAPI' : missing decl-specifiers
507
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2086: 'WINGDIAPI' : redefinition
508
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
509
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2062: type 'void' unexpected
510
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2501: 'WINGDIAPI' : missing decl-specifiers
511
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2086: 'WINGDIAPI' : redefinition
512
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
513
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2062: type 'void' unexpected
514
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2501: 'WINGDIAPI' : missing decl-specifiers
515
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2086: 'WINGDIAPI' : redefinition
516
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
517
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2062: type 'void' unexpected
518
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2501: 'WINGDIAPI' : missing decl-specifiers
519
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2086: 'WINGDIAPI' : redefinition
520
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
521
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2062: type 'void' unexpected
522
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2501: 'WINGDIAPI' : missing decl-specifiers
523
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2086: 'WINGDIAPI' : redefinition
524
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
525
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2062: type 'void' unexpected
526
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : error C2501: 'WINGDIAPI' : missing decl-specifiers
527
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : error C2086: 'WINGDIAPI' : redefinition
528
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : fatal error C1003: error count exceeds 100; stopping compilation
529
+Resource.cpp
530
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(44) : error C2065: 'strlen' : undeclared identifier
531
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(46) : error C2065: 'strncmp' : undeclared identifier
532
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(48) : error C2065: 'i' : undeclared identifier
533
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(48) : error C2065: 'j' : undeclared identifier
534
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(50) : error C2065: 'buf' : undeclared identifier
535
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(50) : error C2109: subscript requires array or pointer type
536
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(50) : error C2106: '=' : left operand must be l-value
537
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(51) : error C2109: subscript requires array or pointer type
538
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(51) : error C2106: '=' : left operand must be l-value
539
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(54) : error C2065: 'strcmp' : undeclared identifier
540
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(90) : error C2065: 'printf' : undeclared identifier
541
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(110) : error C2065: '_width' : undeclared identifier
542
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(110) : error C2065: 'atoi' : undeclared identifier
543
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(120) : error C2065: '_height' : undeclared identifier
544
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(131) : error C2065: '_fast_card' : undeclared identifier
545
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(148) : error C2065: '_no_sound' : undeclared identifier
546
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(176) : error C2065: 'strncpy' : undeclared identifier
547
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(180) : error C2065: '_map_list' : undeclared identifier
548
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(180) : error C2228: left of '.Add' must have class/struct/union type
549
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(192) : error C2065: '_debug_map' : undeclared identifier
550
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(205) : error C2065: '_debug_model' : undeclared identifier
551
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(218) : error C2065: '_dump_texture' : undeclared identifier
552
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(231) : error C2065: 'FILE' : undeclared identifier
553
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(231) : error C2065: 'f' : undeclared identifier
554
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(246) : error C2065: 'snprintf' : undeclared identifier
555
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Resource.cpp(247) : fatal error C1019: unexpected #else
556
+Sound.cpp
557
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\Sound.cpp(22) : fatal error C1083: Cannot open include file: 'AL/al.h': No such file or directory
558
+Texture.cpp
559
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2501: 'WINGDIAPI' : missing decl-specifiers
560
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
561
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1135) : error C2062: type 'void' unexpected
562
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2501: 'WINGDIAPI' : missing decl-specifiers
563
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2086: 'WINGDIAPI' : redefinition
564
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
565
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1136) : error C2062: type 'void' unexpected
566
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2501: 'WINGDIAPI' : missing decl-specifiers
567
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2086: 'WINGDIAPI' : redefinition
568
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2239: unexpected token 'identifier' following declaration of 'WINGDIAPI'
569
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1137) : error C2061: syntax error : identifier 'GLboolean'
570
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2501: 'WINGDIAPI' : missing decl-specifiers
571
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2086: 'WINGDIAPI' : redefinition
572
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
573
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1138) : error C2062: type 'void' unexpected
574
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2501: 'WINGDIAPI' : missing decl-specifiers
575
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2086: 'WINGDIAPI' : redefinition
576
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
577
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1139) : error C2062: type 'void' unexpected
578
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2501: 'WINGDIAPI' : missing decl-specifiers
579
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2086: 'WINGDIAPI' : redefinition
580
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
581
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1140) : error C2062: type 'void' unexpected
582
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2501: 'WINGDIAPI' : missing decl-specifiers
583
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2086: 'WINGDIAPI' : redefinition
584
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
585
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1141) : error C2062: type 'void' unexpected
586
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2501: 'WINGDIAPI' : missing decl-specifiers
587
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2086: 'WINGDIAPI' : redefinition
588
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
589
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1142) : error C2062: type 'void' unexpected
590
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2501: 'WINGDIAPI' : missing decl-specifiers
591
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2086: 'WINGDIAPI' : redefinition
592
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
593
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1143) : error C2062: type 'void' unexpected
594
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2501: 'WINGDIAPI' : missing decl-specifiers
595
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2086: 'WINGDIAPI' : redefinition
596
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
597
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1144) : error C2062: type 'void' unexpected
598
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2501: 'WINGDIAPI' : missing decl-specifiers
599
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2086: 'WINGDIAPI' : redefinition
600
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
601
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1145) : error C2062: type 'void' unexpected
602
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2501: 'WINGDIAPI' : missing decl-specifiers
603
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2086: 'WINGDIAPI' : redefinition
604
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
605
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1146) : error C2062: type 'void' unexpected
606
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2501: 'WINGDIAPI' : missing decl-specifiers
607
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2086: 'WINGDIAPI' : redefinition
608
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
609
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1147) : error C2062: type 'void' unexpected
610
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2501: 'WINGDIAPI' : missing decl-specifiers
611
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2086: 'WINGDIAPI' : redefinition
612
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
613
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1148) : error C2062: type 'void' unexpected
614
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2501: 'WINGDIAPI' : missing decl-specifiers
615
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2086: 'WINGDIAPI' : redefinition
616
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
617
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1149) : error C2062: type 'void' unexpected
618
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2501: 'WINGDIAPI' : missing decl-specifiers
619
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2086: 'WINGDIAPI' : redefinition
620
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
621
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1150) : error C2062: type 'void' unexpected
622
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2501: 'WINGDIAPI' : missing decl-specifiers
623
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2086: 'WINGDIAPI' : redefinition
624
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
625
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1151) : error C2062: type 'void' unexpected
626
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2501: 'WINGDIAPI' : missing decl-specifiers
627
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2086: 'WINGDIAPI' : redefinition
628
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
629
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1152) : error C2062: type 'void' unexpected
630
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2501: 'WINGDIAPI' : missing decl-specifiers
631
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2086: 'WINGDIAPI' : redefinition
632
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
633
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1153) : error C2062: type 'void' unexpected
634
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2501: 'WINGDIAPI' : missing decl-specifiers
635
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2086: 'WINGDIAPI' : redefinition
636
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
637
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1154) : error C2062: type 'void' unexpected
638
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2501: 'WINGDIAPI' : missing decl-specifiers
639
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2086: 'WINGDIAPI' : redefinition
640
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
641
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1155) : error C2062: type 'void' unexpected
642
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2501: 'WINGDIAPI' : missing decl-specifiers
643
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2086: 'WINGDIAPI' : redefinition
644
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
645
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1156) : error C2062: type 'void' unexpected
646
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2501: 'WINGDIAPI' : missing decl-specifiers
647
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2086: 'WINGDIAPI' : redefinition
648
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
649
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1157) : error C2062: type 'void' unexpected
650
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2501: 'WINGDIAPI' : missing decl-specifiers
651
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2086: 'WINGDIAPI' : redefinition
652
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
653
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1158) : error C2062: type 'void' unexpected
654
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2501: 'WINGDIAPI' : missing decl-specifiers
655
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2086: 'WINGDIAPI' : redefinition
656
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2239: unexpected token 'type' following declaration of 'WINGDIAPI'
657
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1159) : error C2062: type 'void' unexpected
658
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : error C2501: 'WINGDIAPI' : missing decl-specifiers
659
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : error C2086: 'WINGDIAPI' : redefinition
660
+C:\Program Files\DevStudio\VC\INCLUDE\GL/gl.h(1160) : fatal error C1003: error count exceeds 100; stopping compilation
661
+TombRaider.cpp
662
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\TombRaider.cpp(424) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
663
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\TombRaider.cpp(425) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
664
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\TombRaider.cpp(426) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
665
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\TombRaider.cpp(430) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
666
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\TombRaider.cpp(431) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
667
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\TombRaider.cpp(432) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
668
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\TombRaider.cpp(962) : error C2065: 'unknown_int' : undeclared identifier
669
+C:\projects\OpenRaider\OpenRaider-0.0.3\src\TombRaider.cpp(3602) : warning C4244: 'return' : conversion from 'double' to 'float', possible loss of data
670
+Error executing cl.exe.
671
+
672
+
673
+
674
+OpenRaider.exe - 580 error(s), 26 warning(s)

+ 13
- 0
setup.sh 파일 보기

@@ -0,0 +1,13 @@
1
+#!/bin/sh
2
+echo "Setting up OpenRaider for user $USER..."
3
+mkdir -p ~/.OpenRaider
4
+cp data/OpenRaider.init ~/.OpenRaider/
5
+cp data/custom.cfg ~/.OpenRaider/
6
+mkdir -p ~/.OpenRaider/paks
7
+mkdir -p ~/.OpenRaider/music
8
+mkdir -p ~/.OpenRaider/data
9
+mkdir -p ~/.OpenRaider/sshots
10
+cp data/*.tga ~/.OpenRaider/data
11
+cp data/*.wav ~/.OpenRaider/data
12
+cp data/*.ttf ~/.OpenRaider/data
13
+echo "DONE"

+ 398
- 0
src/Camera.cpp 파일 보기

@@ -0,0 +1,398 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Freyja
5
+ * Author  : Mongoose
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Camera
9
+ * License : No use w/o permission (C) 2001 Mongoose
10
+ * Comments: OpenGL camera class for Freyja
11
+ *
12
+ *           This file was generated using Mongoose's C++ 
13
+ *           template generator script.  <stu7440@westga.edu>
14
+ * 
15
+ *-- History ------------------------------------------------- 
16
+ *
17
+ * 2002.12.16:
18
+ * Mongoose - Removed perspective setting and OpenGL dependency
19
+ *            API changes to reflect new direction of this object:
20
+ *              Removing outdated algorithms and code 
21
+ *              And refactoring the class in general
22
+ *
23
+ * 2001.06.06:
24
+ * Mongoose - Moving GLU code into here to setup break up
25
+ *            into Camera base class, DynamicCamera,
26
+ *            and GLUCamera child classes
27
+ *
28
+ * 2001.06.04:
29
+ * Mongoose - Quaternion based compile option
30
+ *
31
+ * 2001.05.18:
32
+ * Mongoose - Created
33
+ =================================================================*/
34
+
35
+#include <math.h>
36
+#include <hel/math.h>
37
+#include "Camera.h"
38
+
39
+#ifdef DEBUG_MEMEORY
40
+#   include "memeory_test.h"
41
+#endif
42
+
43
+
44
+unsigned int Camera::mCounter = 0;
45
+
46
+////////////////////////////////////////////////////////////
47
+// Constructors
48
+////////////////////////////////////////////////////////////
49
+
50
+Camera::Camera()
51
+{
52
+	mId = ++mCounter;
53
+	mFlags = 0;
54
+	mViewDistance = 14.0;
55
+	mTranslateDelta = 256.0;
56
+	mRotateDelta = helDegToRad(15.0);
57
+ 	mRotateDelta2 = helDegToRad(5.0);
58
+	mFlags &= Camera_FlyMode;
59
+	reset();
60
+}
61
+
62
+
63
+Camera::~Camera()
64
+{
65
+}
66
+
67
+
68
+////////////////////////////////////////////////////////////
69
+// Public Accessors
70
+////////////////////////////////////////////////////////////
71
+
72
+unsigned int Camera::getId()
73
+{
74
+	return mId;
75
+}
76
+
77
+
78
+void Camera::getPosition(vec3_t pos)
79
+{
80
+	pos[0] = mPos[0];
81
+	pos[1] = mPos[1];
82
+	pos[2] = mPos[2];
83
+}
84
+
85
+
86
+void Camera::getUp(vec3_t up)
87
+{
88
+	up[0] = mUp[0];
89
+	up[1] = mUp[1];
90
+	up[2] = mUp[2];
91
+}
92
+
93
+
94
+void Camera::getTarget(vec3_t target)
95
+{
96
+	target[0] = mTarget[0];
97
+	target[1] = mTarget[1];
98
+	target[2] = mTarget[2];
99
+}
100
+
101
+
102
+float Camera::getYaw()
103
+{
104
+	return helRadToDeg(mTheta);
105
+}
106
+
107
+
108
+double Camera::getRadianYaw()
109
+{
110
+	return mTheta;
111
+}
112
+
113
+
114
+double Camera::getRadianPitch()
115
+{
116
+	return mTheta2;
117
+}
118
+
119
+
120
+////////////////////////////////////////////////////////////
121
+// Public Mutators
122
+////////////////////////////////////////////////////////////
123
+
124
+void Camera::rotate(float angle, float x, float y, float z)
125
+{
126
+	Quaternion t, n;
127
+	Matrix matrix;
128
+	double side[4] = { 1, 0,  0, 1 };
129
+	double up[4] =   { 0, 1,  0, 1 };
130
+	double look[4] = { 0, 0, -1, 1 };
131
+ 	unsigned int i;
132
+	matrix_t m;
133
+   
134
+
135
+	t.set(angle, x, y, z);
136
+	n = mQ * t;
137
+	n.normalize();
138
+
139
+	n.getMatrix(m);
140
+	matrix.setMatrix(m);
141
+	matrix.multiply4d(side, mSide);
142
+	matrix.multiply4d(look, mTarget);
143
+	matrix.multiply4d(up, mUp);
144
+
145
+	for (i = 0; i < 3; ++i)
146
+	{
147
+		mSide[i] += mPos[i];
148
+		mTarget[i] += mPos[i];
149
+		mUp[i] += mPos[i];
150
+	}
151
+    
152
+	mQ = n;
153
+}
154
+
155
+
156
+void Camera::translate(float x, float y, float z)
157
+{
158
+	int i;
159
+	double result[4];
160
+	double v[4];
161
+	matrix_t m;
162
+	Matrix matrix;
163
+
164
+
165
+	v[0] = x;
166
+	v[1] = y;
167
+	v[2] = -z;
168
+	v[3] = 1;
169
+
170
+	m[0] = mSide[0] - mPos[0];
171
+	m[1] = mUp[0] - mPos[0];
172
+	m[2] = mTarget[0] - mPos[0];
173
+	m[3] = 0;
174
+	m[4] = mSide[1] - mPos[1];
175
+	m[5] = mUp[1] - mPos[1];
176
+	m[6] = mTarget[1] - mPos[1];
177
+	m[7] = 0;
178
+	m[8] = mSide[2] - mPos[2];
179
+	m[9] = mUp[2] - mPos[2];
180
+	m[10] = mTarget[2] - mPos[2];
181
+	m[11] = 0;
182
+	m[12] = 0;
183
+	m[13] = 0;
184
+	m[14] = 0;
185
+	m[15] = 1;
186
+
187
+	matrix.setMatrix(m);
188
+	matrix.multiply4d(v, result);
189
+
190
+	for (i = 0; i < 3; ++i)
191
+	{
192
+		mSide[i] += result[i];
193
+		mUp[i] += result[i];
194
+		mTarget[i] += result[i];
195
+		mPos[i] += result[i];
196
+	}
197
+
198
+	mPos[0] = x;
199
+	mPos[1] = y;
200
+	mPos[2] = z;	
201
+}
202
+
203
+
204
+void Camera::reset()
205
+{
206
+	mTheta = 0.0;
207
+	mTheta2 = 0.0;
208
+
209
+	mPos[0] = 0.0;
210
+	mPos[1] = 0.0;
211
+	mPos[2] = 0.0;
212
+
213
+	mTarget[0] = 0.0;
214
+	mTarget[1] = 0.0;
215
+	mTarget[2] = mViewDistance;
216
+
217
+	mSide[0] = 1.0;
218
+	mSide[1] = 0.0;
219
+	mSide[2] = 0.0;
220
+
221
+	mUp[0] = 0.0;
222
+	mUp[1] = 1.0;
223
+	mUp[2] = 0.0;
224
+
225
+	mQ.setIdentity();
226
+	translate(0.0, 0.0, 0.0);
227
+}
228
+
229
+
230
+void Camera::setSensitivityY(float angle)
231
+{
232
+	mRotateDelta2 = helDegToRad(angle);
233
+}
234
+
235
+
236
+void Camera::setSensitivityX(float angle)
237
+{
238
+	mRotateDelta = helDegToRad(angle);
239
+}
240
+
241
+////////
242
+void Camera::command(enum camera_command cmd)
243
+{
244
+	switch (cmd)
245
+	{
246
+	case CAMERA_MOVE_FORWARD:
247
+		if (mFlags & Camera_FlyMode)
248
+		{
249
+			mPos[2] += (mTranslateDelta * cos(mTheta));
250
+		}
251
+		
252
+	  mPos[0] += (mTranslateDelta * sin(mTheta));
253
+	  mPos[1] += (mTranslateDelta * sin(mTheta2));
254
+	  break;
255
+  case CAMERA_MOVE_BACKWARD:
256
+	  if (mFlags & Camera_FlyMode)
257
+	  {
258
+		  mPos[2] -= (mTranslateDelta * cos(mTheta));
259
+	  }
260
+
261
+	  mPos[0] -= (mTranslateDelta * sin(mTheta));
262
+	  mPos[1] -= (mTranslateDelta * sin(mTheta2));
263
+	  break;
264
+  case CAMERA_MOVE_LEFT:
265
+#ifdef OBSOLETE
266
+	  //mPos[0] -= (mTranslateDelta * sin(mTheta2+MTK_PI_OVER_4));
267
+	  mPos[1] -= (mTranslateDelta * cos(mTheta));
268
+
269
+	  if (mFlags & Camera_FlyMode)
270
+	  {
271
+		  mPos[2] -= (mTranslateDelta * cos(mTheta2+MTK_PI_OVER_4));
272
+	  }
273
+#else
274
+	  mPos[0] -= (mTranslateDelta * sin(mTheta - 90.0f));
275
+	  mPos[2] -= (mTranslateDelta * cos(mTheta - 90.0f));
276
+#endif
277
+	  break;
278
+  case CAMERA_MOVE_RIGHT:
279
+#ifdef OBSOLETE  // I have no idea when it got out of hand
280
+	  //mPos[0] += (mTranslateDelta * sin(mTheta2+MTK_PI_OVER_4));
281
+	  mPos[1] += (mTranslateDelta * cos(mTheta));
282
+
283
+	  if (mFlags & Camera_FlyMode)
284
+	  {
285
+		  mPos[2] += (mTranslateDelta * cos(mTheta2+MTK_PI_OVER_4));
286
+	  }
287
+#else
288
+	  mPos[0] -= (mTranslateDelta * sin(mTheta + 90.0f));
289
+	  mPos[2] -= (mTranslateDelta * cos(mTheta + 90.0f));
290
+#endif
291
+	  break;
292
+ case CAMERA_ROTATE_UP:
293
+	 mTheta2 += mRotateDelta2;
294
+	 rotate(mTheta2, 1.0, 0.0, 0.0);
295
+	 break;
296
+ case CAMERA_ROTATE_DOWN:
297
+	 mTheta2 -= mRotateDelta2;
298
+	 rotate(mTheta2, 1.0, 0.0, 0.0);
299
+	 break;
300
+ case CAMERA_ROTATE_RIGHT:
301
+	 mTheta += mRotateDelta;
302
+	 rotate(mTheta, 0.0, 1.0, 0.0);
303
+	 break;
304
+  case CAMERA_ROTATE_LEFT:
305
+	  mTheta -= mRotateDelta;
306
+	  rotate(mTheta, 0.0, 1.0, 0.0);
307
+	  break;
308
+  case CAMERA_MOVE_UP:
309
+	  mPos[1] -= mTranslateDelta / 2.0;   
310
+	  mTarget[1] -= mTranslateDelta / 2.0;
311
+	  break;
312
+  case CAMERA_MOVE_DOWN:
313
+	  mPos[1] += mTranslateDelta / 2.0;
314
+	  mTarget[1] += mTranslateDelta / 2.0;
315
+	  break;
316
+  case CAMERA_SPEED_UP:
317
+    ++mTranslateDelta;
318
+    break;
319
+  case CAMERA_SPEED_DOWN:
320
+    if (--mTranslateDelta < 0.0)
321
+      mTranslateDelta = 1.0;
322
+  default:
323
+    ;
324
+  }
325
+}
326
+
327
+
328
+// FIXME: Mostly invalid for QUAT_CAM (can rotate on XYZ)
329
+bool Camera::isBehind(int x, int z)
330
+{
331
+  double bTheta, bCameraX, bCameraZ, Distance;
332
+
333
+
334
+  // Set up a "virtual camera" a huge distance behind us
335
+  bTheta = mTheta + HEL_PI;
336
+
337
+  if (bTheta > HEL_PI)
338
+    bTheta -= HEL_2_PI;
339
+
340
+   // 64k is a fair distance away...
341
+  bCameraX = (65536.0 * sin(bTheta)) + mPos[0];
342
+  bCameraZ = (65536.0 * cos(bTheta)) + mPos[2];
343
+
344
+  bCameraX -= x;
345
+  bCameraZ -= z;
346
+  Distance = sqrt((bCameraX * bCameraX) + (bCameraZ * bCameraZ));
347
+
348
+  return (Distance < 65536.0);
349
+}
350
+
351
+
352
+void Camera::setSpeed(float s)
353
+{
354
+	mTranslateDelta = s;
355
+}
356
+
357
+
358
+void Camera::update()
359
+{
360
+   mTarget[2] = (mViewDistance * cos(mTheta)) + mPos[2];
361
+   mTarget[0] = (mViewDistance * sin(mTheta)) + mPos[0];
362
+	mTarget[1] = (mViewDistance * sin(mTheta2)) + mPos[1]; // + height_offset;
363
+}
364
+
365
+
366
+void Camera::setPosition(vec3_t pos)
367
+{
368
+	mPos[0] = pos[0];
369
+	mPos[1] = pos[1];
370
+	mPos[2] = pos[2];
371
+}
372
+
373
+
374
+void Camera::setUp(vec3_t up)
375
+{
376
+	mUp[0] = up[0];
377
+	mUp[1] = up[1];
378
+	mUp[2] = up[2];
379
+}
380
+
381
+
382
+void Camera::setTarget(vec3_t target)
383
+{
384
+	mTarget[0] = target[0];
385
+	mTarget[1] = target[1];
386
+	mTarget[2] = target[2];
387
+}
388
+
389
+
390
+////////////////////////////////////////////////////////////
391
+// Private Accessors
392
+////////////////////////////////////////////////////////////
393
+
394
+
395
+////////////////////////////////////////////////////////////
396
+// Private Mutators
397
+////////////////////////////////////////////////////////////
398
+

+ 370
- 0
src/Camera.h 파일 보기

@@ -0,0 +1,370 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Hel
5
+ * Author  : Mongoose
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Camera
9
+ * License : No use w/o permission (C) 2001 Mongoose
10
+ * Comments: OpenGL camera class for Freyja
11
+ *
12
+ *           This file was generated using Mongoose's C++ 
13
+ *           template generator script.  <stu7440@westga.edu>
14
+ * 
15
+ *-- History ------------------------------------------------ 
16
+ *
17
+ * 2002.12.16:
18
+ * Mongoose - Removed perspective setting and OpenGL dependency
19
+ *            API changes to reflect new direction of this object:
20
+ *              Removing outdated algorithms and code 
21
+ *              And refactoring the class in general
22
+ *
23
+ * 2001.06.06:
24
+ * Mongoose - Moving GLU code into here to setup break up
25
+ *            into Camera base class, DynamicCamera,
26
+ *            and GLUCamera child classes
27
+ *
28
+ * 2001.06.04:
29
+ * Mongoose - Quaternion based compile option
30
+ *
31
+ * 2001.05.18:
32
+ * Mongoose - Created, based on my old GL camera code
33
+ *            that has been used in GooseEgg since alpha
34
+ *            and algorithms from Yuri Zhivago's trview
35
+ ================================================================*/
36
+
37
+
38
+#ifndef __HEL_MONGOOSE_CAMERA_H_
39
+#define __HEL_MONGOOSE_CAMERA_H_
40
+
41
+#include <hel/math.h>
42
+#include <hel/Matrix.h>
43
+#include <hel/Quaternion.h>
44
+
45
+enum camera_command                /* Interactive camera control */
46
+{
47
+  CAMERA_MOVE_FORWARD = 1,
48
+  CAMERA_MOVE_BACKWARD,
49
+  CAMERA_MOVE_UP,
50
+  CAMERA_MOVE_DOWN,
51
+  CAMERA_ROTATE_RIGHT,
52
+  CAMERA_ROTATE_LEFT,
53
+  CAMERA_SPEED_UP,
54
+  CAMERA_SPEED_DOWN,
55
+  CAMERA_ROTATE_UP,
56
+  CAMERA_ROTATE_DOWN,
57
+  CAMERA_MOVE_LEFT,
58
+  CAMERA_MOVE_RIGHT
59
+};
60
+
61
+enum CameraFlags
62
+{
63
+	Camera_FlyMode = 1
64
+};
65
+
66
+
67
+class Camera
68
+{
69
+ public:
70
+
71
+	////////////////////////////////////////////////////////////
72
+	// Constructors
73
+	////////////////////////////////////////////////////////////
74
+
75
+	Camera();
76
+	/*------------------------------------------------------
77
+	 * Pre  : 
78
+	 * Post : Constructs an object of Camera
79
+	 *
80
+	 *-- History ------------------------------------------
81
+	 *
82
+	 * 2001.05.18: 
83
+	 * Mongoose - Created
84
+	 ------------------------------------------------------*/
85
+
86
+	~Camera();
87
+	/*------------------------------------------------------
88
+	 * Pre  : Camera object is allocated
89
+	 * Post : Deconstructs an object of Camera
90
+	 *
91
+	 *-- History ------------------------------------------
92
+	 *
93
+	 * 2001.05.18: 
94
+	 * Mongoose - Created
95
+	 ------------------------------------------------------*/
96
+
97
+
98
+	////////////////////////////////////////////////////////////
99
+	// Public Accessors
100
+	////////////////////////////////////////////////////////////
101
+
102
+	unsigned int getId();
103
+	/*------------------------------------------------------
104
+	 * Pre  : 
105
+	 * Post : Returns this camera's id
106
+	 *
107
+	 *-- History ------------------------------------------
108
+	 *
109
+	 * 2001.05.18: 
110
+	 * Mongoose - Created
111
+	 ------------------------------------------------------*/
112
+
113
+	void getPosition(vec3_t pos);
114
+	/*------------------------------------------------------
115
+	 * Pre  : 
116
+	 * Post : Returns current position
117
+	 *
118
+	 *-- History ------------------------------------------
119
+	 *
120
+	 * 2002.06.16:
121
+	 * Mongoose - Created
122
+	 ------------------------------------------------------*/
123
+
124
+	void getUp(vec3_t up);
125
+	/*------------------------------------------------------
126
+	 * Pre  : 
127
+	 * Post : Returns up vector
128
+	 *
129
+	 *-- History ------------------------------------------
130
+	 *
131
+	 * 2001.05.18: 
132
+	 * Mongoose - Created
133
+	 ------------------------------------------------------*/
134
+
135
+	void getTarget(vec3_t target);
136
+	/*------------------------------------------------------
137
+	 * Pre  : 
138
+	 * Post : Returns target ( look at pos )
139
+	 *
140
+	 *-- History ------------------------------------------
141
+	 *
142
+	 * 2001.05.18: 
143
+	 * Mongoose - Created
144
+	 ------------------------------------------------------*/
145
+	
146
+	float getYaw();
147
+	/*------------------------------------------------------
148
+	 * Pre  : Get current yaw in degrees
149
+	 * Post : 
150
+	 *
151
+	 *-- History ------------------------------------------
152
+	 *
153
+	 * 2002.06.22:
154
+	 * Mongoose - Created
155
+	 ------------------------------------------------------*/
156
+
157
+	double getRadianYaw();
158
+	/*------------------------------------------------------
159
+	 * Pre  : 
160
+	 * Post : Returns theta angle/yaw of camera
161
+	 *
162
+	 *-- History ------------------------------------------
163
+	 *
164
+	 * 2001.05.26: 
165
+	 * Mongoose - Created
166
+	 ------------------------------------------------------*/
167
+	
168
+	float getPitch();
169
+	/*------------------------------------------------------
170
+	 * Pre  : Get current pitch in degrees
171
+	 * Post : 
172
+	 *
173
+	 *-- History ------------------------------------------
174
+	 *
175
+	 * 2002.06.22:
176
+	 * Mongoose - Created
177
+	 ------------------------------------------------------*/
178
+
179
+	double getRadianPitch();
180
+	/*------------------------------------------------------
181
+	 * Pre  : 
182
+	 * Post : Returns phi angle/pitch of camera
183
+	 *
184
+	 *-- History ------------------------------------------
185
+	 *
186
+	 * 2001.05.26: 
187
+	 * Mongoose - Created
188
+	 ------------------------------------------------------*/
189
+	
190
+	bool isBehind(int x, int z);
191
+	/*------------------------------------------------------
192
+	 * Pre  : 
193
+	 * Post : Returns true if (x, z) is behind camera eye
194
+	 *
195
+	 *-- History ------------------------------------------
196
+	 *
197
+	 * 2001.05.26: 
198
+	 * Mongoose - Created
199
+	 ------------------------------------------------------*/
200
+
201
+
202
+	////////////////////////////////////////////////////////////
203
+	// Public Mutators
204
+	////////////////////////////////////////////////////////////
205
+
206
+	void rotate(float angle, float x, float y, float z);
207
+	/*------------------------------------------------------
208
+	 * Pre  : x,y,z axis; angle in radians
209
+	 * Post : Rotates camera
210
+	 *
211
+	 *-- History ------------------------------------------
212
+	 *
213
+	 * 2001.06.04: 
214
+	 * Mongoose - Created
215
+	 ------------------------------------------------------*/
216
+
217
+	void translate(float x, float y, float z);
218
+	/*------------------------------------------------------
219
+	 * Pre  : 
220
+	 * Post : Camera position is set to x,y,z
221
+	 *
222
+	 *-- History ------------------------------------------
223
+	 *
224
+	 * 2001.05.18: 
225
+	 * Mongoose - Created
226
+	 ------------------------------------------------------*/
227
+
228
+	void reset();
229
+	/*------------------------------------------------------
230
+	 * Pre  : 
231
+	 * Post : Camera is set to inital state
232
+	 *
233
+	 *-- History ------------------------------------------
234
+	 *
235
+	 * 2001.05.18: 
236
+	 * Mongoose - Created
237
+	 ------------------------------------------------------*/
238
+
239
+	void setSensitivityX(float angle);
240
+	/*------------------------------------------------------
241
+	 * Pre  : angle is theta's rotation delta in degrees
242
+	 * Post : Sets rotation delta
243
+	 *
244
+	 *-- History ------------------------------------------
245
+	 *
246
+	 * 2001.06.04: 
247
+	 * Mongoose - Created
248
+	 ------------------------------------------------------*/
249
+
250
+	void setSensitivityY(float angle);
251
+	/*------------------------------------------------------
252
+	 * Pre  : angle is theta's rotation delta in degrees
253
+	 * Post : Sets rotation delta
254
+	 *
255
+	 *-- History ------------------------------------------
256
+	 *
257
+	 * 2001.06.04: 
258
+	 * Mongoose - Created
259
+	 ------------------------------------------------------*/
260
+
261
+	void command(enum camera_command cmd);
262
+	/*------------------------------------------------------
263
+	 * Pre  : Command is valid camera command
264
+	 * Post : Sends interactive command to camera
265
+	 *
266
+	 *-- History ------------------------------------------
267
+	 *
268
+	 * 2001.05.18: 
269
+	 * Mongoose - Created
270
+	 ------------------------------------------------------*/
271
+
272
+   void setSpeed(float s);
273
+   /*------------------------------------------------------
274
+    * Pre  : s is 256 or greater in general
275
+    * Post : Sets 'speed'
276
+    *
277
+    *-- History ------------------------------------------
278
+    *
279
+    * 2002.01.02: 
280
+    * Mongoose - Created
281
+    ------------------------------------------------------*/
282
+
283
+	void update();
284
+	/*------------------------------------------------------
285
+	 * Pre  : 
286
+	 * Post : Updates view target
287
+	 *
288
+	 *-- History ------------------------------------------
289
+	 *
290
+	 * 2001.05.18: 
291
+	 * Mongoose - Created
292
+	 ------------------------------------------------------*/
293
+
294
+	void setPosition(vec3_t pos);
295
+	/*------------------------------------------------------
296
+	 * Pre  : Set current position
297
+	 * Post : 
298
+	 *
299
+	 *-- History ------------------------------------------
300
+	 *
301
+	 * 2002.06.16:
302
+	 * Mongoose - Created
303
+	 ------------------------------------------------------*/
304
+
305
+	void setUp(vec3_t up);
306
+	/*------------------------------------------------------
307
+	 * Pre  : 
308
+	 * Post : Sets up vector
309
+	 *
310
+	 *-- History ------------------------------------------
311
+	 *
312
+	 * 2001.05.18: 
313
+	 * Mongoose - Created
314
+	 ------------------------------------------------------*/
315
+
316
+	void setTarget(vec3_t target);
317
+	/*------------------------------------------------------
318
+	 * Pre  : 
319
+	 * Post : Sets target ( look at pos )
320
+	 *
321
+	 *-- History ------------------------------------------
322
+	 *
323
+	 * 2001.05.18: 
324
+	 * Mongoose - Created
325
+	 ------------------------------------------------------*/
326
+
327
+
328
+ private:
329
+
330
+	////////////////////////////////////////////////////////////
331
+	// Private Accessors
332
+	////////////////////////////////////////////////////////////
333
+
334
+
335
+	////////////////////////////////////////////////////////////
336
+	// Private Mutators
337
+	////////////////////////////////////////////////////////////
338
+
339
+	unsigned int mId;           /* Unquie id */
340
+
341
+	Quaternion mQ;              /* Quaternion for rotation */
342
+
343
+	unsigned int mFlags;        /* For testing with flags  */
344
+		
345
+	double mPos[4];             /* Location in 3 space (aka eye) */
346
+	
347
+	double mTarget[4];          /* Postition we're looking at  */
348
+	
349
+	double mUp[4];              /* Up vector  */
350
+	
351
+	double mSide[4];            /* Side vector  */
352
+	
353
+	double mViewDistance;      /* Distance from target */
354
+	
355
+	double mTranslateDelta;    /* Step size to move */
356
+	
357
+	double mRotateDelta;       /* Radians to rotate  Y */
358
+	
359
+	double mTheta;              /* View angle  Y */
360
+
361
+	double mRotateDelta2;      /* Radians to rotate  Z */
362
+	
363
+	double mTheta2;             /* View angle  Z */
364
+	
365
+	bool mUpdate;               /* Check to see if view needs updating */
366
+
367
+	static unsigned int mCounter;   /* Id system use */
368
+};
369
+
370
+#endif

+ 346
- 0
src/Emitter.cpp 파일 보기

@@ -0,0 +1,346 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Freyja
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Emitter
9
+ * License : No use w/o permission (C)2001Mongoose
10
+ * Comments: Particle emitter for freyja
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2001.06.30:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#include <stdlib.h>
23
+#include <string.h>
24
+#include <stdio.h>
25
+#include <GL/gl.h>
26
+#include <GL/glu.h>
27
+#include "Emitter.h"
28
+
29
+#ifdef DEBUG_MEMEORY
30
+#   include "memeory_test.h"
31
+#endif
32
+
33
+vec_t Emitter::mFrustum[6][4];
34
+
35
+
36
+int compareParticleDist(const void *voidA, const void *voidB)
37
+{
38
+	Particle *a = (Particle *)voidA, *b = (Particle *)voidB;
39
+	float x, y, z, distA, distB;
40
+
41
+	if (!a || !b)
42
+		return -1; // error really
43
+
44
+	a->Pos(&x, &y, &z);
45
+	distA = (Emitter::mFrustum[5][0] * x + 
46
+				Emitter::mFrustum[5][1] * y + 
47
+				Emitter::mFrustum[5][2] * z + 
48
+				Emitter::mFrustum[5][3]);
49
+
50
+	b->Pos(&x, &y, &z);
51
+	distB = (Emitter::mFrustum[5][0] * x + 
52
+				Emitter::mFrustum[5][1] * y + 
53
+				Emitter::mFrustum[5][2] * z + 
54
+				Emitter::mFrustum[5][3]);
55
+
56
+	// reverse less/greater than
57
+	// less than
58
+	if (distA > distB)
59
+		return -1;
60
+
61
+	// greater than ( no need for equal )
62
+	return 1;
63
+}
64
+
65
+
66
+Emitter::Emitter(char *name, int n)
67
+{
68
+	_name = NULL;
69
+	_flags = 0;
70
+	_particle = NULL;
71
+	_count = 0;
72
+	_pos[0] = _pos[1] = _pos[2] = 0.0;
73
+	_mangle[0] = _mangle[1] = _mangle[2] = 0.0;
74
+
75
+	Name(name);
76
+	ParticleArray(n);
77
+}
78
+
79
+
80
+Emitter::~Emitter()
81
+{
82
+	if (_name)
83
+	{
84
+		delete [] _name;
85
+	}
86
+
87
+	if (_particle)
88
+	{
89
+		delete [] _particle;
90
+	}
91
+
92
+	_count = 0;
93
+}
94
+
95
+Particle *Emitter::Particles()
96
+{
97
+	return _particle;
98
+}
99
+
100
+
101
+int Emitter::Count()
102
+{
103
+	return _count;
104
+}
105
+
106
+
107
+void Emitter::Pos(float *x, float *y, float *z)
108
+{
109
+	*x = _pos[0];
110
+	*y = _pos[1];
111
+	*z = _pos[2];
112
+}
113
+
114
+
115
+void Emitter::Pos(float x, float y, float z)
116
+{
117
+	_pos[0] = x;
118
+	_pos[1] = y;
119
+	_pos[2] = z;
120
+}
121
+
122
+
123
+void Emitter::Orientation(float *x, float *y, float *z)
124
+{
125
+	*x = _mangle[0];
126
+	*y = _mangle[1];
127
+	*z = _mangle[2];
128
+}
129
+
130
+
131
+void Emitter::Orientation(float x, float y, float z)
132
+{
133
+	_mangle[0] = x;
134
+	_mangle[1] = y;
135
+	_mangle[2] = z;
136
+}
137
+
138
+
139
+unsigned int Emitter::Flags()
140
+{
141
+  return _flags;
142
+}
143
+
144
+
145
+void Emitter::Flags(unsigned int flag, bool op)
146
+{
147
+  _flags |= flag;
148
+
149
+  if (!op)
150
+    _flags ^= flag;
151
+}
152
+
153
+
154
+void Emitter::ParticleArray(int n)
155
+{
156
+	if (n)
157
+	{
158
+		if (_particle)
159
+		{
160
+			_count = 0;
161
+			delete [] _particle;
162
+		}
163
+
164
+		_count = n;
165
+		_particle = new Particle[_count];
166
+	}
167
+}
168
+
169
+
170
+void Emitter::Name(char *name)
171
+{
172
+	int l;
173
+
174
+
175
+	if (name && name[0])
176
+	{
177
+		if (_name)
178
+		{
179
+			delete [] _name;
180
+		}
181
+
182
+		l = strlen(name);
183
+		_name = new char[l+1];
184
+
185
+		// Mongoose 2002.01.09, Mongoose says 'Only you can prevent overflows'
186
+		strncpy(_name, name, l);
187
+		_name[l] = 0;
188
+	}
189
+}
190
+
191
+
192
+void Emitter::SetTextureId(int id)
193
+{
194
+	unsigned int i;
195
+
196
+	
197
+	for (i = 0; i < _count; i++)
198
+		_particle[i].TextureId(id);		
199
+}
200
+
201
+
202
+void Emitter::TextureId(unsigned int particle_start, 
203
+								unsigned int particle_end, int id)
204
+{
205
+	unsigned int i;
206
+
207
+
208
+	if ((particle_start >= 0 && particle_start < _count) &&
209
+		 (particle_end > 0 && particle_end <= _count) &&
210
+		 (particle_start < particle_end))
211
+	{
212
+		for (i = particle_start; i < particle_end; i++)
213
+			_particle[i].TextureId(id);		
214
+	}
215
+}
216
+
217
+
218
+void Emitter::Color(unsigned int particle_start, unsigned int particle_end, 
219
+						  float r, float g, float b)
220
+{
221
+	unsigned int i;
222
+
223
+
224
+	if ((particle_start >= 0 && particle_start < _count) &&
225
+		 (particle_end > 0 && particle_end <= _count) &&
226
+		 (particle_start < particle_end))
227
+	{
228
+		for (i = particle_start; i < particle_end; i++)
229
+			_particle[i].Color(r, g, b);		
230
+	}
231
+}
232
+
233
+
234
+void Emitter::Speed(unsigned int particle_start, unsigned int particle_end, 
235
+						  float x, float y, float z)
236
+{
237
+	unsigned int i;
238
+
239
+
240
+	if ((particle_start >= 0 && particle_start < _count) &&
241
+		 (particle_end > 0 && particle_end <= _count) &&
242
+		 (particle_start < particle_end))
243
+	{
244
+		for (i = particle_start; i < particle_end; i++)
245
+			_particle[i].Speed(x, y, z);		
246
+	}
247
+}
248
+
249
+
250
+void Emitter::Force(unsigned int particle_start, unsigned int particle_end, 
251
+						  float x, float y, float z)
252
+{
253
+	unsigned int i;
254
+
255
+
256
+	if ((particle_start >= 0 && particle_start < _count) &&
257
+		 (particle_end > 0 && particle_end <= _count) &&
258
+		 (particle_start < particle_end))
259
+	{
260
+		for (i = particle_start; i < particle_end; i++)
261
+			_particle[i].Force(x, y, z);		
262
+	}
263
+}
264
+
265
+
266
+void Emitter::Draw()
267
+{
268
+	unsigned int i, p;
269
+	float x, y, z;
270
+	float r, g, b;
271
+	float life;
272
+
273
+
274
+	if (!_count || !_particle)
275
+	{
276
+		printf("Emitter::Draw> No particles!\n");
277
+		return;
278
+	}
279
+
280
+	glPushMatrix();
281
+
282
+	//glRotatef(_mangle[0], 1.0, 0.0, 0.0);
283
+	//glRotatef(_mangle[1], 0.0, 1.0, 0.0);
284
+	//glRotatef(_mangle[2], 0.0, 0.0, 1.0);
285
+	//glTranslatef(_pos[0], _pos[1], _pos[2]);
286
+
287
+	if (_flags & fUseDepthSorting)
288
+	{
289
+		qsort(_particle, _count, sizeof(Particle), compareParticleDist);
290
+	}
291
+
292
+	for (i = 0; i < _count; i++)
293
+	{
294
+		if (_particle[i].isActive())
295
+		{
296
+			_particle[i].Pos(&x, &y, &z);
297
+
298
+			if (_flags & fUseFrustumCulling)
299
+			{
300
+				for (p = 0; p < 6; ++p)
301
+				{
302
+					if (mFrustum[p][0] * x + 
303
+						 mFrustum[p][1] * y + 
304
+						 mFrustum[p][2] * z + 
305
+						 mFrustum[p][3] < 0)
306
+					{
307
+						_particle[i].setActive(false);
308
+						break;
309
+					}
310
+				}
311
+
312
+				if (!_particle[i].isActive())
313
+					continue;
314
+			}
315
+
316
+			_particle[i].Color(&r, &g, &b);
317
+			life = _particle[i].Life();
318
+
319
+			// Mongoose 2002.01.01, Removed Texture agent dep
320
+			glBindTexture(GL_TEXTURE_2D, _particle[i].Texture());
321
+
322
+			// Alpha is determined by life, which is affected by blend amount
323
+			glColor4f(r, g, b, life);
324
+
325
+			// Render tristrip quad
326
+			glBegin(GL_TRIANGLE_STRIP);
327
+		      glTexCoord2d(1.0, 1.0);
328
+		      glVertex3f(x + 0.5, y + 0.5, z);
329
+
330
+		      glTexCoord2d(0.0, 1.0);
331
+		      glVertex3f(x - 0.5, y + 0.5, z);
332
+
333
+		      glTexCoord2d(1.0, 0.0);
334
+		      glVertex3f(x + 0.5, y - 0.5, z);
335
+
336
+		      glTexCoord2d(0.0, 0.0);
337
+		      glVertex3f(x - 0.5, y - 0.5, z);
338
+		    glEnd();
339
+
340
+			 // Update particle's attributes for it's life cycle
341
+			 _particle[i].Update();
342
+		}
343
+	}
344
+
345
+	glPopMatrix();
346
+}

+ 289
- 0
src/Emitter.h 파일 보기

@@ -0,0 +1,289 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Freyja
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Emitter
9
+ * License : No use w/o permission (C)2001Mongoose
10
+ * Comments: Particle emitter for freyja
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------ 
17
+ *
18
+ * 2001.08.13:
19
+ * Mongoose - Now using new Particle class!
20
+ *
21
+ * 2001.06.30:
22
+ * Mongoose - Created
23
+ ================================================================*/
24
+
25
+
26
+#ifndef __FREYJA_MONGOOSE_EMITTER_H_
27
+#define __FREYJA_MONGOOSE_EMITTER_H_
28
+
29
+#include "Particle.h"
30
+
31
+
32
+class Emitter
33
+{
34
+ public:
35
+
36
+	typedef enum 
37
+	{
38
+		fUseFrustumCulling = 1,
39
+		fUseDepthSorting = 2
40
+	} EmitterFlags;
41
+
42
+
43
+  Emitter(char *name, int n);
44
+  /*------------------------------------------------------
45
+   * Pre  : name is a valid C string
46
+	*        n is a number greater than 0
47
+	*
48
+   * Post : Constructs an object of Emitter
49
+   *
50
+   *-- History ------------------------------------------
51
+   *
52
+   * 2001.06.30: 
53
+   * Mongoose - Created
54
+   ------------------------------------------------------*/
55
+
56
+  ~Emitter();
57
+  /*------------------------------------------------------
58
+   * Pre  : Emitter object is allocated
59
+   * Post : Deconstructs an object of Emitter
60
+   *
61
+   *-- History ------------------------------------------
62
+   *
63
+   * 2001.06.30: 
64
+   * Mongoose - Created
65
+   ------------------------------------------------------*/
66
+
67
+   Particle *Particles();
68
+  /*------------------------------------------------------
69
+   * Pre  : 
70
+   * Post : Returns particle array
71
+   *
72
+   *-- History ------------------------------------------
73
+   *
74
+   * 2001.08.14: 
75
+   * Mongoose - Created
76
+   ------------------------------------------------------*/
77
+
78
+  int Count();
79
+  /*------------------------------------------------------
80
+   * Pre  : 
81
+   * Post : Returns number of particles emitted
82
+   *
83
+   *-- History ------------------------------------------
84
+   *
85
+   * 2001.08.14: 
86
+   * Mongoose - Created
87
+   ------------------------------------------------------*/
88
+
89
+  void Pos(float x, float y, float z);
90
+  /*------------------------------------------------------
91
+   * Pre  : x,y,z exist
92
+   * Post : Sets position of emitter in 3 space
93
+   *
94
+   *-- History ------------------------------------------
95
+   *
96
+   * 2001.08.13: 
97
+   * Mongoose - Created
98
+   ------------------------------------------------------*/
99
+
100
+  void Pos(float *x, float *y, float *z);
101
+  /*------------------------------------------------------
102
+   * Pre  : x,y,z exist
103
+   * Post : Returns position of emitter in 3 space
104
+   *
105
+   *-- History ------------------------------------------
106
+   *
107
+   * 2001.08.13: 
108
+   * Mongoose - Created
109
+   ------------------------------------------------------*/
110
+
111
+	void Orientation(float x, float y, float z);
112
+  /*------------------------------------------------------
113
+   * Pre  : x,y,z exist
114
+   * Post : Sets orientation of emitter in 3 space
115
+   *
116
+   *-- History ------------------------------------------
117
+   *
118
+   * 2001.08.13: 
119
+   * Mongoose - Created
120
+   ------------------------------------------------------*/
121
+
122
+	void Orientation(float *x, float *y, float *z);
123
+  /*------------------------------------------------------
124
+   * Pre  : x,y,z exist
125
+   * Post : Returns orientation of emitter in 3 space
126
+   *
127
+   *-- History ------------------------------------------
128
+   *
129
+   * 2001.08.13: 
130
+   * Mongoose - Created
131
+   ------------------------------------------------------*/
132
+
133
+  unsigned int Flags();
134
+  /*------------------------------------------------------
135
+   * Pre  : 
136
+   * Post : Returns emitter flags
137
+   *
138
+   *-- History ------------------------------------------
139
+   *
140
+   * 2001.08.14: 
141
+   * Mongoose - Created
142
+   ------------------------------------------------------*/
143
+
144
+
145
+  void Flags(unsigned int flag, bool op);
146
+  /*------------------------------------------------------
147
+   * Pre  : 
148
+   * Post : Set and Unset flag with op 
149
+	*
150
+	*          true - set
151
+	*          flase - unset
152
+   *
153
+   *-- History ------------------------------------------
154
+   *
155
+   * 2001.08.14: 
156
+   * Mongoose - Created
157
+   ------------------------------------------------------*/
158
+
159
+  void ParticleArray(int n);
160
+  /*------------------------------------------------------
161
+   * Pre  : n is a number greater than 0
162
+   * Post : Allocates the particle array and sets the count.
163
+	*        If the array has been allocated previously, then
164
+	*        the array is deallocated and a new one made.
165
+	*         
166
+   *
167
+   *-- History ------------------------------------------
168
+   *
169
+   * 2001.08.13: 
170
+   * Mongoose - Created
171
+   ------------------------------------------------------*/
172
+
173
+  void Draw();
174
+  /*------------------------------------------------------
175
+   * Pre  : 
176
+   * Post : Renders particles
177
+   *
178
+   *-- History ------------------------------------------
179
+   *
180
+   * 2001.06.30: 
181
+   * Mongoose - Created
182
+   ------------------------------------------------------*/
183
+
184
+  void Name(char *name);
185
+  /*------------------------------------------------------
186
+   * Pre  : name is a valid C string
187
+   * Post : Sets the emitters name
188
+   *
189
+   *-- History ------------------------------------------
190
+   *
191
+   * 2001.08.13: 
192
+   * Mongoose - Created
193
+   ------------------------------------------------------*/
194
+
195
+  void SetTextureId(int id);
196
+  /*------------------------------------------------------
197
+   * Pre  : 
198
+   * Post : Resets all particle texture ids
199
+   *
200
+   *-- History ------------------------------------------
201
+   *
202
+   * 2001.08.13: 
203
+   * Mongoose - Created
204
+   ------------------------------------------------------*/
205
+
206
+  void TextureId(unsigned int particle_start, unsigned int particle_end, 
207
+					  int id);
208
+  /*------------------------------------------------------
209
+   * Pre  : particle_start and particle_end are a valid 
210
+	*        range of particles in the array
211
+	*
212
+	*        id is a valid texture id
213
+	*
214
+   * Post : 
215
+   *
216
+   *-- History ------------------------------------------
217
+   *
218
+   * 2001.08.14: 
219
+   * Mongoose - Created
220
+   ------------------------------------------------------*/
221
+
222
+  void Color(unsigned int particle_start, unsigned int particle_end, 
223
+				 float r, float g, float b);
224
+  /*------------------------------------------------------
225
+   * Pre  : particle_start and particle_end are a valid 
226
+	*        range of particles in the array
227
+	*
228
+	*        r,g,b are colors 0.0 to 1.0
229
+	*
230
+   * Post : 
231
+   *
232
+   *-- History ------------------------------------------
233
+   *
234
+   * 2001.08.14: 
235
+   * Mongoose - Created
236
+   ------------------------------------------------------*/
237
+
238
+  void Speed(unsigned int particle_start, unsigned int particle_end, 
239
+				 float x, float y, float z);
240
+  /*------------------------------------------------------
241
+   * Pre  : particle_start and particle_end are a valid 
242
+	*        range of particles in the array
243
+	*
244
+	*        take note speed inits at 2000, lower is faster
245
+	*
246
+   * Post : 
247
+   *
248
+   *-- History ------------------------------------------
249
+   *
250
+   * 2001.08.14: 
251
+   * Mongoose - Created
252
+   ------------------------------------------------------*/
253
+
254
+  void Force(unsigned int particle_start, unsigned int particle_end, 
255
+				 float x, float y, float z);
256
+  /*------------------------------------------------------
257
+   * Pre  : particle_start and particle_end are a valid 
258
+	*        range of particles in the array
259
+	*
260
+	*        Force/Gravity acting on particles
261
+	*
262
+   * Post : 
263
+   *
264
+   *-- History ------------------------------------------
265
+   *
266
+   * 2001.08.14: 
267
+   * Mongoose - Created
268
+   ------------------------------------------------------*/
269
+
270
+
271
+	static vec_t mFrustum[6][4]; /* View Volume copy */
272
+
273
+
274
+ private:
275
+
276
+	char *_name;              /* Emitter name */
277
+
278
+	unsigned int _flags;      /* Emitter flags */
279
+
280
+	vec3_t _pos;              /* Position in 3 space */
281
+
282
+	vec3_t _mangle;           /* Oreintation in 3 space */
283
+
284
+	Particle *_particle;      /* Array of particles */
285
+
286
+	unsigned int _count;      /* Particle count */
287
+};
288
+
289
+#endif

+ 736
- 0
src/GLString.cpp 파일 보기

@@ -0,0 +1,736 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Mtk
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : GLString
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: Open GL rendering font/string class
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2002.01.01:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#include <string.h>
23
+#include <stdio.h>
24
+#include <stdlib.h>
25
+#include <stdarg.h>
26
+#include <GL/gl.h>
27
+
28
+#include "Texture.h"
29
+
30
+#include "GLString.h"
31
+
32
+#ifdef DEBUG_MEMEORY
33
+#   include "memeory_test.h"
34
+#endif
35
+
36
+
37
+
38
+GLString::GLString()
39
+{
40
+	_num_string_max = 0;
41
+	_num_font_max = 0;
42
+	_num_font = 0;
43
+	_num_string = 0;
44
+	_scale = 1.0;
45
+	_font_texture = NULL;
46
+	_font_base = NULL;
47
+	_string = NULL;
48
+}
49
+
50
+
51
+GLString::~GLString()
52
+{
53
+	unsigned int i;
54
+
55
+
56
+	for (i = 0; i < _num_font; ++i)
57
+	{
58
+		glDeleteLists(_font_base[i], 256);
59
+	}
60
+
61
+	if (_font_texture)
62
+	{
63
+		delete [] _font_texture;
64
+	}
65
+	
66
+	if (_font_base)
67
+	{
68
+		delete [] _font_base;
69
+	}
70
+
71
+	if (_string)
72
+	{
73
+
74
+		for (i = 0; i < _num_string; ++i)
75
+		{
76
+			if (_string[i].text)
77
+			{
78
+				delete [] _string[i].text;
79
+			}
80
+		}
81
+
82
+		delete [] _string;
83
+	}
84
+}
85
+
86
+
87
+void GLString::Init(unsigned int max_strings, unsigned int max_fonts, 
88
+						  int *tex_map)
89
+{
90
+	unsigned int i;
91
+
92
+
93
+	if (!max_strings || !max_fonts || !tex_map)
94
+	{
95
+		return;
96
+	}
97
+
98
+	_num_string_max = max_strings;
99
+	_num_font_max = max_fonts;
100
+
101
+	_font_texture = new int[max_fonts];
102
+	_font_base = new int[max_fonts];
103
+	_string = new gl_string_t[max_strings];
104
+
105
+	for (i = 0; i < max_fonts; ++i)
106
+	{
107
+		_font_texture[i] = tex_map[i];
108
+		
109
+		if (BuildFontList(i) < 0)
110
+		{
111
+			printf("GLString::Init> BuildFontList failed for %i\n", i);
112
+		}
113
+	}
114
+}
115
+
116
+
117
+void GLString::SetChar(unsigned int string, unsigned int pos, char c)
118
+{
119
+	gl_string_t *str = GetString(string);
120
+
121
+	
122
+	if (str && pos < str->len)
123
+	{
124
+		str->text[pos] = c;
125
+	}
126
+}
127
+
128
+
129
+unsigned int GLString::GetStringLen(unsigned int string)
130
+{
131
+	gl_string_t *str = GetString(string);
132
+
133
+	
134
+	if (str)
135
+	{
136
+		return str->len;
137
+	}
138
+
139
+	return 0;
140
+}
141
+
142
+
143
+char *GLString::GetBuffer(unsigned int string)
144
+{
145
+	gl_string_t *str = GetString(string);
146
+
147
+	
148
+	if (str)
149
+	{
150
+		return str->text;
151
+	}
152
+
153
+	return 0;
154
+}
155
+
156
+
157
+void GLString::setActive(unsigned int string, bool active)
158
+{
159
+	gl_string_t *str;
160
+
161
+
162
+	str = GetString(string);
163
+
164
+	if (str)
165
+	{
166
+		str->active = active;
167
+	}
168
+}
169
+
170
+
171
+void GLString::SetString(unsigned int string, char *s, ...)
172
+{
173
+	va_list args;
174
+	gl_string_t *str;
175
+	unsigned int len;
176
+
177
+
178
+	str = GetString(string);
179
+
180
+	if (s && s[0] && str)
181
+	{
182
+		str->active = true;
183
+
184
+		len = strlen(s);
185
+
186
+		if (len > str->len)
187
+		{
188
+			len = str->len - 1;
189
+		}
190
+
191
+		va_start(args, s);
192
+		vsnprintf(str->text, str->len-2, s, args);	
193
+		str->text[str->len-1] = 0;
194
+		va_end(args);
195
+	}
196
+}
197
+
198
+
199
+void GLString::Scale(float scale)
200
+{
201
+	_scale = scale;
202
+}
203
+
204
+
205
+int GLString::BuildFontList(int index)
206
+{
207
+	int i;
208
+	float cx;
209
+	float cy;
210
+	
211
+
212
+	if (_num_font >= _num_font_max || index < 0 || index >= (int)_num_font_max)
213
+	{
214
+		return -1;
215
+	}
216
+
217
+	_font_base[index] = glGenLists(256);
218
+	glBindTexture(GL_TEXTURE_2D, _font_texture[index]);
219
+	
220
+	// Mongoose 2002.01.01, Generate 256 lists per font
221
+	//   one per symbol
222
+	for (i = 0; i < 256; i++)
223
+	{
224
+		/* X Position Of Current Character */
225
+		cx = 1 - (float)(i % 16) / 16.0f;
226
+		/* Y Position Of Current Character */
227
+		cy = 1 - (float)(i / 16) / 16.0f;
228
+		
229
+		/* Start Building A List */
230
+		glNewList(_font_base[index] + (255 - i), GL_COMPILE);
231
+		/* Use A Quad For Each Character */
232
+		glBegin(GL_QUADS);
233
+		/* Texture Coord (Bottom Left) */
234
+		glTexCoord2f(cx - 0.0625, cy);
235
+		/* Vertex Coord (Bottom Left) */
236
+		glVertex2i(0, 0);
237
+		
238
+		/* Texture Coord (Bottom Right) */
239
+		glTexCoord2f(cx, cy);
240
+		/* Vertex Coord (Bottom Right) */
241
+		glVertex2i(16, 0);
242
+		
243
+		/* Texture Coord (Top Right) */
244
+		glTexCoord2f(cx, cy - 0.0625f);
245
+		 /* Vertex Coord (Top Right) */
246
+		glVertex2i(16, 16);
247
+		
248
+		/* Texture Coord (Top Left) */
249
+		glTexCoord2f(cx - 0.0625f, cy - 0.0625f);
250
+		/* Vertex Coord (Top Left) */
251
+		glVertex2i(0, 16);
252
+		glEnd();
253
+		
254
+		/* Move To The Left Of The Character */
255
+		glTranslated(10, 0, 0);
256
+		glEndList();
257
+	}
258
+
259
+	return 0;
260
+}
261
+
262
+
263
+int GLString::glPrintf(int x, int y, int font, char *string, ...)
264
+{
265
+	int sz = 60;
266
+	int n;
267
+	va_list args;
268
+
269
+	
270
+	// Mongoose 2002.01.01, Only allow valid strings
271
+	//   we must assume it's NULL terminated also if it passes...
272
+	if (!string || !string[0])
273
+	{
274
+		return -1;
275
+	}
276
+
277
+	if (_num_string > _num_string_max)
278
+	{
279
+		return -2;
280
+	}
281
+
282
+	if (font < 0 || font > (int)_num_font_max)
283
+	{
284
+		return -3;
285
+	}
286
+
287
+	// Mongoose 2002.01.01, Assume no longer than 'sz' wide lines
288
+	//   on first try
289
+	_string[_num_string].text = new char[sz];
290
+
291
+	// Mongoose 2002.01.03, Setup scale factor
292
+	_string[_num_string].scale = _scale;
293
+
294
+	//  Mongoose 2002.01.01, Setup position
295
+	_string[_num_string].x = x;
296
+	_string[_num_string].y = y;
297
+
298
+	//  Mongoose 2002.01.01, Setup font list base index to use
299
+	_string[_num_string].font = font;
300
+
301
+	va_start(args, string);
302
+
303
+	// Mongoose 2002.01.01, Get exact size needed if the first try fails
304
+	n = vsnprintf(_string[_num_string].text, sz, string, args);
305
+
306
+	// Mongoose 2002.01.01, Realloc correct amount if truncated
307
+	while (1)
308
+	{
309
+		if (n > -1 && n < sz)
310
+		{
311
+			break;
312
+		}
313
+
314
+		// Mongoose 2002.01.01, For glibc 2.1
315
+		if (n > -1)
316
+		{
317
+			sz = n + 1;
318
+			delete [] _string[_num_string].text;
319
+			_string[_num_string].text = new char[sz];
320
+			n = vsnprintf(_string[_num_string].text, sz, string, args);
321
+
322
+			break;
323
+		}
324
+		else // glibc 2.0
325
+		{
326
+			sz *= 2;
327
+			delete [] _string[_num_string].text;
328
+			_string[_num_string].text = new char[sz];
329
+			n = vsnprintf(_string[_num_string].text, sz, string, args);
330
+		}
331
+	}
332
+
333
+	va_end(args);
334
+
335
+
336
+	// Mongoose 2002.01.04, Remeber string size, for future rebuffering use
337
+	_string[_num_string].len = sz;
338
+
339
+	// Mongoose 2002.01.01, Incement string counter, since we just 
340
+	//   allocated a string
341
+	++_num_string;
342
+
343
+	return 0;
344
+}
345
+
346
+
347
+void GLString::Render(int width, int height)
348
+{
349
+	unsigned int i;
350
+
351
+#ifndef HAVE_SDL_TTF
352
+	// Mongoose 2001.12.31, Start the evil font rendering...
353
+	glLoadIdentity();
354
+	glDisable(GL_DEPTH_TEST);
355
+
356
+	// Mongoose 2001.12.31, New 'flat' projection
357
+	glMatrixMode(GL_PROJECTION);
358
+	glPushMatrix();
359
+	glLoadIdentity();
360
+	glOrtho(0, width, 0, height, -1, 1);
361
+
362
+	// Mongoose 2001.12.31, New rendering matrix
363
+	glMatrixMode(GL_MODELVIEW);
364
+	glPushMatrix();
365
+	glLoadIdentity();
366
+
367
+	// Mongoose 2001.12.31, Rasterize strings' text
368
+	for (i = 0; i < _num_string; ++i)
369
+	{
370
+		if (_string[i].active)
371
+		{
372
+			glPushMatrix();
373
+			glBindTexture(GL_TEXTURE_2D, _font_texture[_string[i].font]);
374
+			glTranslated(_string[i].x, _string[i].y, 0);
375
+			glScaled(_string[i].scale, _string[i].scale, _string[i].scale);
376
+			glListBase(_font_base[_string[i].font] - 32);
377
+			glCallLists(strlen(_string[i].text), GL_BYTE, _string[i].text);
378
+			glPopMatrix();
379
+		}
380
+	}
381
+
382
+
383
+	// Mongoose 2001.12.31, Restore scene projection
384
+	glMatrixMode(GL_PROJECTION);
385
+	glPopMatrix();
386
+	
387
+	// Mongoose 2001.12.31, Restore scene matrix
388
+	glMatrixMode(GL_MODELVIEW);
389
+	glPopMatrix();
390
+
391
+	glEnable(GL_DEPTH_TEST);
392
+#else
393
+	for (i = 0; i < _num_string; ++i)
394
+	{
395
+		if (_string[i].active)
396
+		{
397
+			glPrint2d(_string[i].x, _string[i].y, 
398
+						 _string[i].scale, 
399
+						 _string[i].text);
400
+		}
401
+	}
402
+#endif
403
+}
404
+
405
+
406
+gl_string_t *GLString::GetString(unsigned int id)
407
+{
408
+	if (id < _num_string)
409
+	{
410
+		return _string + id;
411
+	}
412
+
413
+	return NULL;
414
+}
415
+
416
+
417
+////////////////////////////////////////////////////////////
418
+// Test code
419
+////////////////////////////////////////////////////////////
420
+
421
+
422
+#ifdef __TEST__
423
+
424
+#include <GL/glu.h>
425
+
426
+#ifdef HAVE_MTK
427
+#   include "Texture.h"
428
+#   include "mtk_tga.h"
429
+
430
+Texture gTexture;
431
+#else
432
+#   error "Requires MTK: Texture and mtk_tga"
433
+#endif
434
+
435
+
436
+GLString *TEXT;
437
+
438
+void swap_buffers();
439
+
440
+
441
+void event_resize(int width, int height)
442
+{
443
+	GLfloat aspect;
444
+
445
+	glMatrixMode(GL_PROJECTION);
446
+	aspect = (GLfloat)width/(GLfloat)height;
447
+	
448
+	// Mongoose 2002.01.01, Setup view volume, with a nice FOV
449
+	gluPerspective(40.0, aspect, 1, 2000);
450
+
451
+	glMatrixMode(GL_MODELVIEW);
452
+}
453
+
454
+
455
+void event_display(int width, int height)
456
+{
457
+	static float x = 0.0, y = 0.0, z = -150.0, r = 0.0;
458
+
459
+
460
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
461
+	glLoadIdentity();
462
+
463
+	glTranslatef(0.0, 0.0, -20.0);
464
+	glRotatef((float)cos(r)*180.0, 0.0, 0.0, 1.0);
465
+	r += 0.01;
466
+
467
+	// Mongoose 2002.01.01, Render color quad
468
+	glDisable(GL_TEXTURE_2D);
469
+	glBegin(GL_TRIANGLE_STRIP);
470
+	glColor3f(1.0, 0.0, 0.0);
471
+	glVertex3f(x + 50, y + 50, z);
472
+	glColor3f(0.0, 1.0, 0.0);
473
+	glVertex3f(x - 50, y + 50, z);
474
+	glColor3f(0.0, 0.0, 1.0);
475
+	glVertex3f(x + 50, y - 50, z);
476
+	glColor3f(0.5, 0.5, 0.5);
477
+	glVertex3f(x - 50, y - 50, z);
478
+	glEnd();
479
+
480
+	// Mongoose 2002.01.01, Render text
481
+	glDisable(GL_CULL_FACE);
482
+	glEnable(GL_BLEND);
483
+	glEnable(GL_TEXTURE_2D);
484
+	glColor3f(0.1, 0.2, 1.0);
485
+	TEXT->Render(width, height);
486
+
487
+	glFlush();
488
+	swap_buffers();
489
+}
490
+
491
+
492
+#ifdef HAVE_SDL
493
+#include <SDL/SDL.h>
494
+
495
+
496
+SDL_Surface *SDL_WINDOW = NULL;
497
+
498
+
499
+void swap_buffers()
500
+{
501
+	SDL_GL_SwapBuffers();
502
+}
503
+
504
+
505
+void shutdown_gl()
506
+{
507
+	SDL_Quit();
508
+}
509
+
510
+
511
+void init_gl(unsigned int width, unsigned int height, 
512
+				 int argc, char *argv[])
513
+{
514
+	int i, j;
515
+	int id[4];
516
+	float s = 1.0;
517
+
518
+
519
+	// Setup GL
520
+	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
521
+	glShadeModel(GL_SMOOTH);
522
+	glEnable(GL_DEPTH_TEST);
523
+	glDepthFunc(GL_LESS);
524
+	glEnable(GL_BLEND);
525
+	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
526
+	
527
+	event_resize(width, height);
528
+
529
+	// Mongoose 2002.01.01, Texture setup
530
+	gTexture.reset();
531
+	gTexture.setFlag(Texture::fUseMipmaps);
532
+	gTexture.setMaxTextureCount(32);
533
+	
534
+	if (argc > 1)
535
+	{
536
+		for (i = 1, j = 0; i < argc; ++i, ++j)
537
+		{
538
+			if (j < 4)
539
+			{
540
+				id[j++] = gTexture.loadTGA(argv[i]);
541
+			}
542
+		}
543
+	}
544
+	else
545
+	{
546
+		id[0] = gTexture.loadTGA("data/font-0.tga");
547
+		id[1] = gTexture.loadTGA("data/font-1.tga");
548
+		id[2] = gTexture.loadTGA("data/font-2.tga");
549
+		id[3] = gTexture.loadTGA("data/font-3.tga");
550
+	}
551
+
552
+	printf("%i %i %i %i\n", id[0], id[1], id[2], id[3]);
553
+
554
+	TEXT->Init(4, 4, id);
555
+	i = TEXT->glPrintf((width/2)-12*5, height/2, 0, 
556
+							 "[font %i] GLString Test", id[0]);
557
+	if (i)
558
+	{
559
+		printf("TEXT->glPrintf> ERROR code %i ( 0 means no error )\n", i);
560
+	}
561
+
562
+	i = TEXT->glPrintf((width/2)-10*7, height/2+32, 1, 
563
+							 "[font %i] GLString Test", id[1]);
564
+
565
+	if (i)
566
+	{
567
+		printf("TEXT->glPrintf> ERROR code %i ( 0 means no error )\n", i);
568
+	}
569
+
570
+	s = 1.1;
571
+	TEXT->Scale(s);
572
+
573
+	i = TEXT->glPrintf((width/2)-10*7, height/2+64, 1, 
574
+							 "[font %i] Scaled by %.3f", id[1], s);
575
+
576
+	if (i)
577
+	{
578
+		printf("TEXT->glPrintf> ERROR code %i ( 0 means no error )\n", i);
579
+	}
580
+	i = TEXT->glPrintf((width/2)-10*7, height/2-32, 0, 
581
+							 "[font %i] Scaled by %.3f", id[0], s);
582
+
583
+	if (i)
584
+	{
585
+		printf("TEXT->glPrintf> ERROR code %i ( 0 means no error )\n", i);
586
+	}
587
+}
588
+
589
+
590
+int main_gl(int argc, char *argv[])
591
+{
592
+  SDL_Event event;
593
+  unsigned int mkeys, mod, key;
594
+  int flags;
595
+  unsigned int width = 640;
596
+  unsigned int height = 460;
597
+  bool fullscreen = false;
598
+  char *driver = NULL;
599
+
600
+
601
+  // Setup clean up on exit
602
+  atexit(shutdown_gl);
603
+
604
+  // Get user settings
605
+  //event_init(&width, &height, &fullscreen, &driver, argc, argv);
606
+
607
+  // Create GL context
608
+  SDL_Init(SDL_INIT_VIDEO);
609
+
610
+  if (!driver || !driver[0] || SDL_GL_LoadLibrary(driver) < 0)
611
+  {
612
+	  SDL_ClearError();
613
+
614
+	  // Fallback 1
615
+	  if (SDL_GL_LoadLibrary("libGL.so") < 0)
616
+	  {
617
+		  SDL_ClearError();
618
+    
619
+		  // Fallback 2
620
+		  if (SDL_GL_LoadLibrary("libGL.so.1") < 0)
621
+		  {
622
+			  fprintf(stderr, "main_gl> SDL_GL_LoadLibrary failed!\n");
623
+			  fprintf(stderr, "main_gl> Error is [%s].\n", SDL_GetError());
624
+			  exit(1);
625
+		  }
626
+	  }
627
+  }
628
+
629
+  flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER;
630
+
631
+  if (fullscreen)
632
+  {
633
+	  flags |= SDL_FULLSCREEN;
634
+	  SDL_ShowCursor(SDL_DISABLE);
635
+  }
636
+
637
+  SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
638
+  SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
639
+  SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
640
+  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
641
+  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
642
+  SDL_WINDOW = SDL_SetVideoMode(width, height, 16, flags);
643
+  SDL_WM_SetCaption("GLString Test", "GLString Test");
644
+  SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
645
+  
646
+  // Init rendering
647
+  init_gl(width, height, argc, argv);
648
+
649
+  for (;;)
650
+  {
651
+	  // Pause for 10-20 ms
652
+	  SDL_Delay(10);
653
+
654
+	  event_display(width, height);
655
+
656
+	  while (SDL_PollEvent(&event))
657
+	  {
658
+		  switch (event.type)
659
+		  {
660
+		  case SDL_QUIT:
661
+			  exit(0);
662
+			  break;
663
+		  case SDL_MOUSEMOTION:
664
+			  break;
665
+		  case SDL_MOUSEBUTTONDOWN:
666
+		  case SDL_MOUSEBUTTONUP:
667
+			  break;	
668
+		  case SDL_KEYDOWN:
669
+			  mkeys = (unsigned int)SDL_GetModState();
670
+			  mod = 0;
671
+
672
+			  if (mkeys & KMOD_LSHIFT)
673
+				  mod |= KMOD_LSHIFT;
674
+
675
+			  if (mkeys & KMOD_RSHIFT)
676
+				  mod |= KMOD_RSHIFT;
677
+
678
+			  if (mkeys & KMOD_LCTRL)
679
+				  mod |= KMOD_LCTRL;
680
+
681
+			  if (mkeys & KMOD_RCTRL)
682
+				  mod |= KMOD_RCTRL;
683
+
684
+			  if (mkeys & KMOD_LALT)
685
+				  mod |= KMOD_LALT;
686
+
687
+			  if (mkeys & KMOD_RALT)
688
+				  mod |= KMOD_RALT;
689
+
690
+			  key = event.key.keysym.sym;
691
+
692
+			  switch (key)
693
+			  {
694
+			  case 0x1B: // 27d, ESC
695
+				  exit(0);
696
+				  break;
697
+			  }
698
+			  break;
699
+		  case SDL_KEYUP:
700
+			  break;
701
+		  case SDL_VIDEORESIZE:			  
702
+			  event_resize(event.resize.w, event.resize.h);
703
+
704
+			  width = event.resize.w;
705
+			  height = event.resize.h;
706
+			  event_display(width, height);
707
+			  break;
708
+		  }
709
+	  }
710
+  }
711
+  
712
+  return 0;
713
+}
714
+#else
715
+#error "Requires SDL to create GL Context"
716
+#endif
717
+
718
+
719
+int GLString::_RegressionTest(int argc, char *argv[])
720
+{
721
+	TEXT = this;
722
+	main_gl(argc, argv);
723
+	return 0;
724
+}
725
+
726
+
727
+int main(int argc, char *argv[])
728
+{
729
+  GLString test;
730
+
731
+
732
+  printf("[GLString class test]\n");
733
+
734
+  return test._RegressionTest(argc, argv);
735
+}
736
+#endif

+ 244
- 0
src/GLString.h 파일 보기

@@ -0,0 +1,244 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Mtk
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : GLString
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: Open GL rendering font/string class
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------ 
17
+ *
18
+ * 2002.01.01:
19
+ * Mongoose - Created
20
+ ================================================================*/
21
+
22
+
23
+#ifndef __MTK_MONGOOSE_GLSTRING_H_
24
+#define __MTK_MONGOOSE_GLSTRING_H_
25
+
26
+typedef struct gl_string_s
27
+{
28
+	int x;
29
+	int y;
30
+	int font;
31
+	float scale;
32
+	char *text;
33
+	bool active;
34
+	unsigned short int len;
35
+
36
+} gl_string_t;
37
+
38
+
39
+class GLString
40
+{
41
+ public:
42
+
43
+	GLString();
44
+	/*------------------------------------------------------
45
+	 * Pre  : 
46
+	 * Post : Constructs an object of GLString
47
+	 *
48
+	 *-- History ------------------------------------------
49
+	 *
50
+	 * 2002.01.01: 
51
+	 * Mongoose - Created
52
+	 ------------------------------------------------------*/
53
+
54
+	~GLString();
55
+	/*------------------------------------------------------
56
+	 * Pre  : GLString object is allocated
57
+	 * Post : Deconstructs an object of GLString
58
+	 *
59
+	 *-- History ------------------------------------------
60
+	 *
61
+	 * 2002.01.01: 
62
+	 * Mongoose - Created
63
+	 ------------------------------------------------------*/
64
+
65
+   void Init(unsigned int max_strings, unsigned int max_fonts, int *tex_map);
66
+   /*------------------------------------------------------
67
+    * Pre  : Set max number of strings and font faces
68
+	 *
69
+	 *        Pass an int array as a map of font texture ids
70
+	 *        and it's size should be 'max_fonts' since
71
+	 *        you need a texture per font  =)
72
+	 *
73
+    * Post : 
74
+    *
75
+    *-- History ------------------------------------------
76
+    *
77
+    * 2002.01.01: 
78
+    * Mongoose - Created
79
+    ------------------------------------------------------*/
80
+
81
+	void SetChar(unsigned int string, unsigned int pos, char c);
82
+   /*------------------------------------------------------
83
+    * Pre  : String is valid gl_string id
84
+	 *        Pos is position in that gl_string to set
85
+	 *        to character C
86
+	 *
87
+    * Post : Sets a single byte in a string
88
+    *
89
+    *-- History ------------------------------------------
90
+    *
91
+    * 2002.03.30: 
92
+    * Mongoose - Created
93
+    ------------------------------------------------------*/
94
+
95
+	unsigned int GetStringLen(unsigned int string);
96
+   /*------------------------------------------------------
97
+    * Pre  : String is valid gl_string id
98
+	 *
99
+    * Post : Gets num bytes in string buffer
100
+    *
101
+    *-- History ------------------------------------------
102
+    *
103
+    * 2002.03.30: 
104
+    * Mongoose - Created
105
+    ------------------------------------------------------*/
106
+
107
+	char *GetBuffer(unsigned int string);
108
+   /*------------------------------------------------------
109
+    * Pre  : String is valid gl_string id
110
+	 *
111
+    * Post : Returns a pointer to string buffer
112
+    *
113
+    *-- History ------------------------------------------
114
+    *
115
+    * 2002.03.30: 
116
+    * Mongoose - Created
117
+    ------------------------------------------------------*/
118
+
119
+	void setActive(unsigned int string, bool active);
120
+
121
+	void SetString(unsigned int string, char *s, ...);
122
+   /*------------------------------------------------------
123
+    * Pre  : String is valid gl_string id
124
+	 *        Args form the string to fill String buffer
125
+	 *        Args are same as printf format
126
+	 *
127
+    * Post : Sets text in a string, which will be
128
+	 *        truncated as needed to fit
129
+    *
130
+    *-- History ------------------------------------------
131
+    *
132
+    * 2002.03.30: 
133
+    * Mongoose - Created
134
+    ------------------------------------------------------*/
135
+
136
+   void Scale(float scale);
137
+   /*------------------------------------------------------
138
+    * Pre  : scale is > 0.0
139
+    * Post : Sets default text scaling
140
+    *
141
+    *-- History ------------------------------------------
142
+    *
143
+    * 2002.01.03: 
144
+    * Mongoose - Created
145
+    ------------------------------------------------------*/
146
+
147
+   int BuildFontList(int index);
148
+   /*------------------------------------------------------
149
+    * Pre  : Index is valid index into the font base list
150
+    * Post : Adds a new font face to font list
151
+	 *
152
+	 *        Returns index of font on no error
153
+	 *        Returns -1 on full font list
154
+    *
155
+    *-- History ------------------------------------------
156
+    *
157
+    * 2002.01.01: 
158
+    * Mongoose - Created
159
+    ------------------------------------------------------*/
160
+
161
+   int glPrintf(int x, int y, int font, char *string, ...);
162
+   /*------------------------------------------------------
163
+    * Pre  : X, Y are valid screen coor
164
+	 *        Font is valid font index
165
+	 *        String is valid string with args
166
+	 *
167
+	 *        Returns  0 on no error
168
+	 *        Returns -1 on invalid string
169
+	 *        Returns -2 on full string list
170
+	 *        Returns -3 on full font list
171
+	 *
172
+    * Post : Generates a new string
173
+	 *        Renders string to gl target
174
+    *
175
+    *-- History ------------------------------------------
176
+    *
177
+    * 2001.12.31: 
178
+    * Mongoose - Created
179
+    ------------------------------------------------------*/
180
+
181
+   void Render(int width, int height);
182
+   /*------------------------------------------------------
183
+    * Pre  : Width and Height for the GL context
184
+	 *        Called after scene is rendered
185
+	 *        
186
+	 *        GL Culling disabled
187
+	 *
188
+    * Post : Renders strings over GL scene
189
+    *
190
+    *-- History ------------------------------------------
191
+    *
192
+    * 2002.01.01: 
193
+    * Mongoose - Created
194
+    ------------------------------------------------------*/
195
+
196
+   gl_string_t *GetString(unsigned int id);
197
+   /*------------------------------------------------------
198
+    * Pre  : Id is valid string id
199
+    * Post : Return string with id, or NULL if DNE
200
+    *
201
+    *-- History ------------------------------------------
202
+    *
203
+    * 2002.01.04: 
204
+    * Mongoose - Created
205
+    ------------------------------------------------------*/
206
+
207
+
208
+#ifdef __TEST__
209
+	int _RegressionTest(int argc, char *argv[]);
210
+	/*------------------------------------------------------
211
+	 * Pre  : argc and argv are valid
212
+	 * Post : Tests GLString
213
+	 *
214
+	 *        Returns 0 on sucess, or an error id
215
+	 *
216
+	 *-- History ------------------------------------------
217
+	 *
218
+	 * 2002.01.01: 
219
+	 * Mongoose - Created
220
+	 ------------------------------------------------------*/
221
+#endif
222
+
223
+ private:
224
+
225
+	unsigned int _num_string_max;	   /* Max number of strings buffered */
226
+
227
+	unsigned int _num_font_max;	   /* Max number of font faces */
228
+
229
+	unsigned int _num_font;	         /* Current number of font faces */
230
+
231
+	unsigned int _num_string;	      /* Current number of strings buffered */
232
+
233
+	int *_font_texture;	            /* Font texture mapping to actual
234
+												   texture index */
235
+
236
+	int *_font_base;	               /* Font GL list, base index list */
237
+
238
+	gl_string_t *_string;            /* Buffered strings and their 
239
+													properities */
240
+
241
+	float _scale;                    /* Default scale factor for new strings */
242
+};
243
+
244
+#endif

+ 180
- 0
src/GLUTSystem.cpp 파일 보기

@@ -0,0 +1,180 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : UnRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : GLUTSystem
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: 
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2002.08.09:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#include <stdlib.h>
23
+#include <stdio.h>
24
+#include <string.h>
25
+
26
+#include <GL/gl.h>
27
+#include <GL/glu.h>
28
+#include <GL/glut.h>
29
+
30
+#ifdef PS2_LINUX
31
+#   include "ps2.h"
32
+#endif
33
+
34
+#include "GLUTSystem.h"
35
+
36
+
37
+// Mongoose 2003.06.03, Updated to modern times since the wheel
38
+//          was invented, no longer propagate crap up to System
39
+GLUTSystem gGlutSystem;
40
+
41
+
42
+////////////////////////////////////////////////////////////
43
+// Constructors
44
+////////////////////////////////////////////////////////////
45
+
46
+GLUTSystem::GLUTSystem() : System()
47
+{
48
+}
49
+
50
+
51
+GLUTSystem::~GLUTSystem()
52
+{
53
+}
54
+
55
+
56
+////////////////////////////////////////////////////////////
57
+// Public Accessors
58
+////////////////////////////////////////////////////////////
59
+
60
+
61
+////////////////////////////////////////////////////////////
62
+// Public Mutators
63
+////////////////////////////////////////////////////////////
64
+
65
+void display(void)
66
+{
67
+	gGlutSystem.gameFrame();
68
+}
69
+
70
+
71
+void reshape(int w, int h)
72
+{
73
+	gGlutSystem.resizeGL(w, h);
74
+}
75
+
76
+
77
+void key(unsigned char k, int x, int y)
78
+{
79
+	gGlutSystem.handleKeyEvent(k, 0);
80
+}
81
+
82
+
83
+void special(int key, int x, int y)
84
+{
85
+	gGlutSystem.handleKeyEvent(key, 0);
86
+}
87
+
88
+
89
+void GLUTSystem::shutdown(int i)
90
+{
91
+	//#ifdef DEBUG_MEMEORY
92
+	//printf("[Mongoose MEMEORY_DEBUG]\nUnfreed memory table:\n");
93
+	//dump_memory_report();
94
+	//#endif
95
+	
96
+	printf("\n\n\tThanks for testing %s\n", VERSION);
97
+	printf("\tPlease file bug reports and submit video card performance\n\n");
98
+	printf("\tBuild date : %s @ %s\n", __DATE__, __TIME__);
99
+	printf("\tBuild host : %s\n", BUILD_HOST);
100
+	printf("\tEmail bugs : mongoose@users.sourceforge.net\n");
101
+	printf("\tWeb site   : http://openraider.sourceforge.net\n\n");
102
+
103
+	exit(0);
104
+}
105
+
106
+
107
+void GLUTSystem::initVideo(unsigned int width, unsigned int height, 
108
+								  bool fullscreen)
109
+{
110
+	glutInit(NULL, 0);
111
+	printf("@Created OpenGL Context...\n");
112
+	
113
+	m_width = width;
114
+	m_height = height;
115
+
116
+	if (fullscreen)
117
+	{
118
+	}
119
+
120
+   glutReshapeFunc(reshape);
121
+   glutDisplayFunc(display);
122
+   glutKeyboardFunc(key);
123
+   glutSpecialFunc(special);
124
+
125
+	// Start game renderer
126
+	initGL();
127
+
128
+	// Resize context
129
+	resizeGL(width, height);
130
+}
131
+
132
+
133
+void GLUTSystem::runGame()
134
+{
135
+	glutMainLoop();
136
+}
137
+
138
+
139
+void GLUTSystem::toggleFullscreen()
140
+{
141
+}
142
+
143
+
144
+void GLUTSystem::swapBuffersGL()
145
+{
146
+	glutSwapBuffers();
147
+}
148
+
149
+
150
+////////////////////////////////////////////////////////////
151
+// Private Accessors
152
+////////////////////////////////////////////////////////////
153
+
154
+
155
+////////////////////////////////////////////////////////////
156
+// Private Mutators
157
+////////////////////////////////////////////////////////////
158
+
159
+
160
+////////////////////////////////////////////////////////////
161
+// Unit Test code
162
+////////////////////////////////////////////////////////////
163
+
164
+#ifdef UNIT_TEST_GLUTSYSTEM
165
+int runGLUTSystemUnitTest(int argc, char *argv[])
166
+{
167
+	return 0;
168
+}
169
+
170
+
171
+int main(int argc, char *argv[])
172
+{
173
+	GLUTSystem test;
174
+
175
+
176
+	printf("[GLUTSystem class test]\n");
177
+
178
+	return runGLUTSystemUnitTest(argc, argv);
179
+}
180
+#endif

+ 100
- 0
src/GLUTSystem.h 파일 보기

@@ -0,0 +1,100 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : UnRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : GLUTSystem
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: 
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- Test Defines -----------------------------------------------
17
+ *           
18
+ * UNIT_TEST_GLUTSYSTEM - Builds GLUTSystem class as a console unit test 
19
+ *
20
+ *-- History ------------------------------------------------ 
21
+ *
22
+ * 2002.08.09:
23
+ * Mongoose - Created
24
+ ================================================================*/
25
+
26
+
27
+#ifndef GUARD__UNRAIDER_MONGOOSE_GLUTSYSTEM_H_
28
+#define GUARD__UNRAIDER_MONGOOSE_GLUTSYSTEM_H_
29
+
30
+#include "System.h"
31
+
32
+
33
+class GLUTSystem : public System
34
+{
35
+ public:
36
+
37
+	////////////////////////////////////////////////////////////
38
+	// Constructors
39
+	////////////////////////////////////////////////////////////
40
+
41
+	GLUTSystem();
42
+	/*------------------------------------------------------
43
+	 * Pre  : 
44
+	 * Post : Constructs an object of GLUTSystem
45
+	 *
46
+	 *-- History ------------------------------------------
47
+	 *
48
+	 * 2002.08.09: 
49
+	 * Mongoose - Created
50
+	 ------------------------------------------------------*/
51
+
52
+	~GLUTSystem();
53
+	/*------------------------------------------------------
54
+	 * Pre  : GLUTSystem object is allocated
55
+	 * Post : Deconstructs an object of GLUTSystem
56
+	 *
57
+	 *-- History ------------------------------------------
58
+	 *
59
+	 * 2002.08.09: 
60
+	 * Mongoose - Created
61
+	 ------------------------------------------------------*/
62
+
63
+
64
+	////////////////////////////////////////////////////////////
65
+	// Public Accessors
66
+	////////////////////////////////////////////////////////////
67
+
68
+
69
+
70
+	////////////////////////////////////////////////////////////
71
+	// Public Mutators
72
+	////////////////////////////////////////////////////////////
73
+
74
+	void shutdown(int i);
75
+
76
+	void initVideo(unsigned int width, unsigned int height, 
77
+						bool fullscreen);
78
+
79
+	void runGame();
80
+
81
+	void toggleFullscreen();
82
+
83
+	void swapBuffersGL();
84
+
85
+ private:
86
+
87
+	////////////////////////////////////////////////////////////
88
+	// Private Accessors
89
+	////////////////////////////////////////////////////////////
90
+
91
+
92
+	////////////////////////////////////////////////////////////
93
+	// Private Mutators
94
+	////////////////////////////////////////////////////////////
95
+
96
+
97
+	/* */
98
+};
99
+
100
+#endif

+ 52
- 0
src/Light.cpp 파일 보기

@@ -0,0 +1,52 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Freyja
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Light
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: This is the GL light class
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2002.01.27:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#include "Light.h"
23
+
24
+
25
+Light::Light()
26
+{
27
+}
28
+
29
+
30
+Light::~Light()
31
+{
32
+}
33
+
34
+
35
+////////////////////////////////////////////////////////////
36
+// Unit Test code
37
+////////////////////////////////////////////////////////////
38
+
39
+#ifdef LIGHT_UNIT_TEST
40
+int runLightUnitTest(int argc, char *argv[])
41
+{
42
+	return 0;
43
+}
44
+
45
+
46
+int main(int argc, char *argv[])
47
+{
48
+	printf("[Light class test]\n");
49
+
50
+	return runLightUnitTest(argc, argv);
51
+}
52
+#endif

+ 91
- 0
src/Light.h 파일 보기

@@ -0,0 +1,91 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Freyja
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Light
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: This is the GL light class
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------ 
17
+ *
18
+ * 2002.01.27:
19
+ * Mongoose - Created
20
+ ================================================================*/
21
+
22
+
23
+#ifndef __FREYJA_MONGOOSE_LIGHT_H_
24
+#define __FREYJA_MONGOOSE_LIGHT_H_
25
+
26
+#include <hel/math.h>
27
+
28
+
29
+class Light
30
+{
31
+ public:
32
+
33
+	typedef enum
34
+   {
35
+		typePoint = 1, 
36
+		typeSpot = 2, 
37
+		typeDirectional = 3
38
+	} FreyjaLightType;
39
+
40
+
41
+	Light();
42
+	/*------------------------------------------------------
43
+	 * Pre  : 
44
+	 * Post : Constructs an object of Light
45
+	 *
46
+	 *-- History ------------------------------------------
47
+	 *
48
+	 * 2002.01.27: 
49
+	 * Mongoose - Created
50
+	 ------------------------------------------------------*/
51
+
52
+	~Light();
53
+	/*------------------------------------------------------
54
+	 * Pre  : Light object is allocated
55
+	 * Post : Deconstructs an object of Light
56
+	 *
57
+	 *-- History ------------------------------------------
58
+	 *
59
+	 * 2002.01.27: 
60
+	 * Mongoose - Created
61
+	 ------------------------------------------------------*/
62
+
63
+
64
+	float mAmbient[4];          /* Ambient color */
65
+
66
+	float mDiffuse[4];          /* Diffuse color */
67
+
68
+	float mSpecular[4];         /* Specular color */
69
+
70
+	vec4_t mPos;                /* Light position in 3 space */
71
+
72
+	vec3_t mDir;                /* Light direction */
73
+
74
+	float mAtt;                 /* */
75
+
76
+	vec4_t mColor;              /* Color of light */
77
+
78
+	vec_t mCutoff;              /* Fade out distance */
79
+
80
+	FreyjaLightType mType;	    /* Type of light */
81
+
82
+ private:
83
+
84
+	unsigned int mFlags;        /* Flags for this light */
85
+
86
+	unsigned int mId;           /* Unique identifier of this light */
87
+
88
+	char *mName;                /* Light name */
89
+};
90
+
91
+#endif

+ 972
- 0
src/Md3.cpp 파일 보기

@@ -0,0 +1,972 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*==========================================================================
3
+ * 
4
+ * Project : GooseEgg
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Md3
9
+ * Comments: This is the MD3 model module.
10
+ *
11
+ *           See file COPYING for license details.
12
+ *
13
+ *           Quake (c) id Software 1995 - 2000
14
+ *
15
+ *           MD3 file format specs provided by Mental Vortex,
16
+ *           and that site says the specs may not be 100% correct
17
+ *           so - since this class is desgined using their specs...
18
+ *
19
+ *
20
+ *-- History ---------------------------------------------------------- 
21
+ *
22
+ * 2000-10-06:
23
+ * Mongoose - The new code for the new interface
24
+ *
25
+ * 2000-06-03:
26
+ * Mongoose - Those specs where FUBAR - but I figured out the ordering
27
+ * Mongoose - Created from MD3 specs provided by Mental Vortex
28
+ ==========================================================================*/
29
+
30
+#include <sys/types.h>
31
+#include <stdio.h>
32
+#include <string.h>
33
+#include <stdlib.h>
34
+#include <stdarg.h>
35
+#include <math.h>
36
+
37
+#ifdef USING_OPENGL
38
+#   include <GL/gl.h>
39
+#endif
40
+
41
+#include "endian.h"
42
+
43
+#include "Md3.h"
44
+
45
+
46
+
47
+Md3::Md3()
48
+{
49
+	mFlags = fDecodeNormals;
50
+
51
+	memset(m_filename, 0, 68);     
52
+ 
53
+	m_id = 0;
54
+	m_version = 0;           
55
+	m_num_bones = 0;   
56
+	m_num_tags = 0;          
57
+	m_num_meshes = 0;        
58
+	m_max_skins = 0;
59
+
60
+	m_header_length = 0;     
61
+	m_tag_start = 0;         
62
+	m_surfaces_start = 0;          
63
+	m_file_size = 0;        
64
+
65
+	m_debug = 1;
66
+
67
+	m_tags = NULL;     
68
+	m_bones = NULL;
69
+	m_meshes = NULL;
70
+	slaveTest = NULL;
71
+	texTest = NULL;
72
+}
73
+
74
+
75
+Md3::Md3(unsigned int num_meshes, unsigned int num_bones, unsigned int num_tags)
76
+{	
77
+	memset(m_filename, 0, 68);     
78
+ 
79
+	m_id = 0;
80
+	m_version = 0;
81
+	m_max_skins = 0;
82
+
83
+	m_header_length = 0;     
84
+	m_tag_start = 0;         
85
+	m_surfaces_start = 0;          
86
+	m_file_size = 0;        
87
+
88
+	m_debug = 1;
89
+
90
+	m_tags = NULL;     
91
+	m_bones = NULL;
92
+	m_meshes = NULL;
93
+	slaveTest = NULL;
94
+	texTest = NULL;
95
+
96
+	m_num_bones = num_bones;   
97
+	m_num_tags = num_tags;          
98
+	m_num_meshes = num_meshes;
99
+	createMeshes(num_meshes);
100
+	createTags(num_tags*num_bones);
101
+	createBones(num_bones);
102
+}
103
+
104
+
105
+Md3::~Md3()
106
+{
107
+	reset();
108
+}
109
+
110
+
111
+////////////////////////////////////////////////////////////
112
+// Public Accessors
113
+////////////////////////////////////////////////////////////
114
+
115
+unsigned int Md3::getNumMeshes()
116
+{
117
+	return m_num_meshes;
118
+}
119
+
120
+
121
+unsigned int Md3::getNumTags()
122
+{
123
+	return m_num_tags;
124
+}
125
+
126
+
127
+unsigned int Md3::getNumBones()
128
+{
129
+	return m_num_bones;
130
+}
131
+
132
+
133
+md3_mesh_t *Md3::getMeshes()
134
+{
135
+	return m_meshes;
136
+}
137
+
138
+
139
+md3_tag_t *Md3::getTags()
140
+{
141
+	return m_tags;
142
+}
143
+
144
+
145
+md3_bone_t *Md3::getBones()
146
+{
147
+	return m_bones;
148
+}
149
+
150
+
151
+////////////////////////////////////////////////////////////
152
+// Public Mutators
153
+////////////////////////////////////////////////////////////
154
+
155
+void Md3::toggleFlag(Md3Flag flag)
156
+{
157
+	mFlags ^= flag;
158
+}
159
+
160
+
161
+void Md3::reset()
162
+{
163
+	int i;
164
+
165
+	memset(m_filename, 0, 68);     
166
+
167
+	m_id = 0;
168
+	m_version = 0;           
169
+	m_num_bones = 0;   
170
+	m_num_tags = 0;          
171
+	m_num_meshes = 0;        
172
+	m_max_skins = 0;
173
+	m_header_length = 0;     
174
+	m_tag_start = 0;         
175
+	m_surfaces_start = 0;          
176
+	m_file_size = 0;  
177
+
178
+	if (m_meshes)
179
+	{
180
+		for (i = 0; i < m_num_meshes; ++i)
181
+		{
182
+			if (m_meshes[i].skin)
183
+			{
184
+				delete [] m_meshes[i].skin;
185
+			}
186
+
187
+			if (m_meshes[i].tris)
188
+			{
189
+				delete [] m_meshes[i].tris;
190
+			}
191
+
192
+			if (m_meshes[i].texel)
193
+			{
194
+				delete [] m_meshes[i].texel;
195
+			}
196
+
197
+			if (m_meshes[i].vertex)
198
+			{
199
+				delete [] m_meshes[i].vertex;
200
+			}
201
+		}
202
+
203
+		delete [] m_meshes;
204
+	}
205
+
206
+	if (m_tags)
207
+	{
208
+		delete [] m_tags;
209
+	}
210
+
211
+	if (m_bones)
212
+	{
213
+		delete [] m_bones;
214
+	}
215
+
216
+	if (slaveTest)
217
+	{
218
+		delete [] slaveTest;
219
+	}
220
+
221
+	if (texTest)
222
+	{
223
+		delete [] texTest;
224
+	}
225
+} 
226
+
227
+
228
+void Md3::setDebug(unsigned char level)
229
+{
230
+	m_debug = level;
231
+}
232
+
233
+
234
+// FIXME: Only partial endian support
235
+int Md3::load(char *filename)
236
+{
237
+	FILE *f;
238
+	int i, j, k, npherno_warn;
239
+	bool dump_skin;
240
+	int16_t ss;
241
+	int8_t sb;
242
+
243
+  
244
+	npherno_warn = 0;
245
+
246
+	f = fopen(filename, "rb");
247
+
248
+	if (!f)
249
+	{
250
+		perror("Md3::load> \n");
251
+		return -1;
252
+	}
253
+
254
+	// Start Header ////////////////
255
+
256
+	fread_int_small(&m_id, f);
257
+	printDebug("load", "id = 0x%x\n", m_id);
258
+  
259
+	if (m_id != MD3_IDALIASHEADER)
260
+	{
261
+		printError("load", "header not 0x%x\n", MD3_IDALIASHEADER);
262
+		return -2;
263
+	}
264
+  
265
+	fread_int_small(&m_version, f);
266
+	printDebug("load", "version = %i\n", m_version);
267
+
268
+	if (m_version != MD3_ALIAS_VERSION)
269
+	{
270
+		printError("load", "version not %i\n", MD3_ALIAS_VERSION);
271
+		return -3;
272
+	}
273
+  
274
+	fread(&m_filename, 68, 1, f);
275
+	printDebug("load", "filename = '%s'\n", m_filename);
276
+
277
+	fread_int_small(&m_num_bones, f);
278
+	printDebug("load", "num_bone_frames = %i\n", m_num_bones);
279
+
280
+	fread_int_small(&m_num_tags, f);
281
+	printDebug("load", "num_tags = %i\n", m_num_tags);
282
+
283
+	fread_int_small(&m_num_meshes, f);
284
+	printDebug("load", "num_meshes = %i\n", m_num_meshes);
285
+
286
+	fread_int_small(&m_max_skins, f);
287
+	printDebug("load", "max_skins = %i\n", m_max_skins);
288
+
289
+	fread_int_small(&m_header_length, f);
290
+	printDebug("load", "header_length = %i\n", m_header_length);
291
+
292
+	fread_int_small(&m_tag_start, f);
293
+	printDebug("load", "tag_start = %i\n", m_tag_start);
294
+
295
+	fread_int_small(&m_surfaces_start, f);
296
+	printDebug("load", "surfaces_start = %i\n", m_surfaces_start);
297
+
298
+	fread_int_small(&m_file_size, f);
299
+	printDebug("load", "file_size = %i\n", m_file_size);
300
+ 
301
+	// End Header //////////////////
302
+	printDebug("load", "Loading %i bones\n", m_num_bones);
303
+	createBones(m_num_bones);
304
+
305
+	for (i = 0; i < m_num_bones; ++i)
306
+	{
307
+		//fread(&m_bones[i].mins, 12, 1, f);
308
+		fread_float_small(&m_bones[i].mins[0], f);
309
+		fread_float_small(&m_bones[i].mins[1], f);
310
+		fread_float_small(&m_bones[i].mins[2], f);
311
+		//fread(&m_bones[i].maxs, 12, 1, f);
312
+		fread_float_small(&m_bones[i].maxs[0], f);
313
+		fread_float_small(&m_bones[i].maxs[1], f);
314
+		fread_float_small(&m_bones[i].maxs[2], f);
315
+		//fread(&m_bones[i].center, 12, 1, f);
316
+		fread_float_small(&m_bones[i].center[0], f);
317
+		fread_float_small(&m_bones[i].center[1], f);
318
+		fread_float_small(&m_bones[i].center[2], f);
319
+		//fread(&m_bones[i].scale, 4, 1, f);
320
+		fread_float_small(&m_bones[i].scale, f);
321
+		fread(&m_bones[i].creator, 16, 1, f);
322
+
323
+		if (!i && strncmp("NPherno->MD3", m_bones[i].creator, 16) == 0)
324
+		{
325
+			npherno_warn = 1;
326
+		}
327
+
328
+		printDebug("load", "bone[%i].mins = %f %f %f\n", i, 
329
+				 m_bones[i].mins[0], m_bones[i].mins[1], m_bones[i].mins[2]);
330
+		printDebug("load", "bone[%i].maxs = %f %f %f\n", i, 
331
+				 m_bones[i].maxs[0], m_bones[i].maxs[1], m_bones[i].maxs[2]);
332
+		printDebug("load", "bone[%i].center = %f %f %f\n", i, 
333
+				 m_bones[i].center[0], m_bones[i].center[1], m_bones[i].center[2]);
334
+		printDebug("load", "bone[%i].scale = %f\n", i, m_bones[i].scale);
335
+		printDebug("load", "bone[%i].creator = '%s'\n", i, m_bones[i].creator);
336
+	}
337
+
338
+
339
+	if (m_tag_start != ftell(f))
340
+	{
341
+		printWarning("load", "tag_start %i != file pos %lu\n", 
342
+						 m_tag_start,ftell(f));
343
+
344
+		fseek(f, m_tag_start, SEEK_SET);
345
+		printWarning("load", "File position set to %lu\n", ftell(f));
346
+	}
347
+
348
+	printDebug("load", "Loading %i tags\n", m_num_tags * m_num_bones);
349
+	createTags(m_num_tags * m_num_bones);
350
+
351
+	for (i = 0; i < m_num_tags * m_num_bones; ++i)
352
+	{
353
+		fread(&m_tags[i].name, 64, 1, f);
354
+		//fread(&m_tags[i].center, 12, 1, f);
355
+		fread_float_small(&m_tags[i].center[0], f);
356
+		fread_float_small(&m_tags[i].center[1], f);
357
+		fread_float_small(&m_tags[i].center[2], f);
358
+		fread(&m_tags[i].rotation, 36, 1, f);
359
+
360
+		printDebug("load", "tag[%i].name = '%s'\n", i, m_tags[i].name);
361
+	}
362
+
363
+	if (m_surfaces_start != ftell(f))
364
+	{
365
+		printWarning("load", "surfaces_start %i != file pos %lu\n", 
366
+						 m_surfaces_start, ftell(f));
367
+
368
+		fseek(f, m_surfaces_start, SEEK_SET);
369
+		printWarning("load", "File position set to %lu\n", ftell(f));
370
+	}
371
+ 
372
+	printDebug("load", "Loading %i meshes\n", m_num_meshes);
373
+	createMeshes(m_num_meshes);
374
+
375
+	for(i = 0; i < m_num_meshes; ++i)
376
+	{
377
+		// Start Mesh Header /////////////////
378
+
379
+		fread(&m_meshes[i].id, 4, 1, f);
380
+		fread(&m_meshes[i].name, 64, 1, f);
381
+		fread(&m_meshes[i].flags, 4, 1, f);
382
+		fread(&m_meshes[i].num_frames, 4, 1, f);
383
+    
384
+		fread(&m_meshes[i].num_shaders, 4, 1, f);
385
+		m_meshes[i].num_skins = m_meshes[i].num_shaders;
386
+    
387
+		fread(&m_meshes[i].num_vertices, 4, 1, f);
388
+		fread(&m_meshes[i].num_triangles, 4, 1, f);
389
+		fread(&m_meshes[i].tris_offset, 4, 1, f);
390
+		fread(&m_meshes[i].header_size, 4, 1, f);   // offset from start of surface
391
+		// to shaders
392
+		fread(&m_meshes[i].texel_offset, 4, 1, f);
393
+		fread(&m_meshes[i].vertex_offset, 4, 1, f); // offset to normals
394
+		// num_verts * num_frames
395
+		fread(&m_meshes[i].mesh_size, 4, 1, f);     // next surface
396
+
397
+		printDebug("load", "mesh[%i].id = '%c%c%c%c'\n", i, 
398
+				 m_meshes[i].id[0], m_meshes[i].id[1], m_meshes[i].id[2], m_meshes[i].id[3]);
399
+		printDebug("load", "mesh[%i].name = '%s'\n", i, 
400
+				 m_meshes[i].name);
401
+		printDebug("load", "mesh[%i].flags = %i\n", i, 
402
+				 m_meshes[i].flags);
403
+		printDebug("load", "mesh[%i].num_frames = %i\n", i, 
404
+				 m_meshes[i].num_frames);
405
+		printDebug("load", "mesh[%i].num_shaders = %i\n", i, 
406
+				 m_meshes[i].num_shaders);
407
+		printDebug("load", "mesh[%i].num_vertices = %i\n", i, 
408
+				 m_meshes[i].num_vertices);
409
+		printDebug("load", "mesh[%i].num_triangles = %i\n", i, 
410
+				 m_meshes[i].num_triangles);
411
+		printDebug("load", "mesh[%i].tris_offset = %i\n", i, 
412
+				 m_meshes[i].tris_offset+m_surfaces_start);
413
+		printDebug("load", "mesh[%i].shader_offset = %i\n", i, 
414
+				 m_meshes[i].header_size+m_surfaces_start);
415
+		printDebug("load", "mesh[%i].texel_offset = %i\n", i, 
416
+				 m_meshes[i].texel_offset+m_surfaces_start);
417
+		printDebug("load", "mesh[%i].vertex_offset = %i\n", i, 
418
+				 m_meshes[i].vertex_offset+m_surfaces_start);
419
+		printDebug("load", "mesh[%i].mesh_end = %i\n", i, 
420
+				 m_meshes[i].mesh_size+m_surfaces_start);
421
+
422
+		// This will kind of handle bad mesh reads here
423
+		if (*(int*)&m_meshes[i].id != MD3_IDALIASHEADER)
424
+		{
425
+			printWarning("load", "Bad/damaged mesh, handling...\n");
426
+			printWarning("load", "HANDLE: Keeping valid meshes... %i/%i total\n",
427
+							 i, m_num_meshes);
428
+
429
+			m_num_meshes = i; // don't use more than prev valid meshes
430
+			break;
431
+		}
432
+
433
+		// End Mesh Header ///////////////////
434
+
435
+		m_meshes[i].skin = NULL;
436
+		m_meshes[i].tris = NULL;
437
+		m_meshes[i].texel = NULL;
438
+		m_meshes[i].vertex = NULL;
439
+
440
+		// Start shaders /////////////////////
441
+		if (m_surfaces_start+m_meshes[i].header_size != ftell(f))
442
+		{
443
+			printWarning("load", "_mesh[%i] shader offset %i != file pos %lu\n",
444
+							 i, m_surfaces_start+m_meshes[i].header_size, ftell(f));
445
+      
446
+			fseek(f, m_surfaces_start+m_meshes[i].header_size, SEEK_SET);
447
+			printWarning("load", "HANDLE: File position set to %lu\n", ftell(f));
448
+		}
449
+
450
+		m_meshes[i].skin = new md3_skin_t[m_meshes[i].num_skins];
451
+
452
+		dump_skin = false;
453
+
454
+		for (j = 0; j < m_meshes[i].num_skins; ++j)
455
+		{
456
+			fread(&m_meshes[i].skin[j].name, 68, 1, f);
457
+
458
+			if (!m_meshes[i].skin[j].name[0])
459
+			{
460
+				m_meshes[i].skin[j].name[0] = 'm';
461
+
462
+				printWarning("load", "Error in skin name %i/%i.\n",
463
+								 j+1, m_meshes[i].num_skins);
464
+
465
+				dump_skin = true;
466
+			}
467
+
468
+#ifdef UNIT_TEST_MD3_LV2
469
+			dump_skin = true;
470
+#endif
471
+
472
+			if (dump_skin)
473
+			{
474
+				printDebug("load", "Dumping skin buffer:\n'");
475
+
476
+				for (k = 0; k < 68; ++k)
477
+				{
478
+					if (m_meshes[i].skin[j].name[k] > 32 && 
479
+						 m_meshes[i].skin[j].name[k] < 127)
480
+					{
481
+						printf("%c", m_meshes[i].skin[j].name[k]);
482
+					}
483
+					else
484
+					{
485
+						printf("%c", 183); // print a dot for invalid text
486
+					}
487
+				}
488
+
489
+				printf("'\n");
490
+			}
491
+
492
+			printDebug("load", "mesh[%i].skin[%i].name = '%s'\n", 
493
+					 i, j, m_meshes[i].skin[j].name);
494
+		}
495
+
496
+		// Start triangles ////////////////////////
497
+		if (m_surfaces_start+m_meshes[i].tris_offset != ftell(f))
498
+		{
499
+			printWarning("load", "mesh[%i] tris offset %i != file pos %lu\n", i, 
500
+							 m_surfaces_start+m_meshes[i].tris_offset, ftell(f));
501
+      
502
+			fseek(f, m_surfaces_start+m_meshes[i].tris_offset, SEEK_SET);
503
+			printWarning("load", "HANDLE: File position set to %lu\n", ftell(f));
504
+		}
505
+
506
+		m_meshes[i].tris = new md3_tri_index_t[m_meshes[i].num_triangles];
507
+
508
+		for (j = 0; j < m_meshes[i].num_triangles; ++j)
509
+		{
510
+			fread(&m_meshes[i].tris[j].triangle, 12, 1, f);
511
+		}
512
+
513
+		// Start texels /////////////////////
514
+		if (m_surfaces_start+m_meshes[i].texel_offset != ftell(f))
515
+		{
516
+			printWarning("load", "mesh[%i] texel offset %i != file pos %lu\n", i, 
517
+							 m_surfaces_start+m_meshes[i].texel_offset, ftell(f));
518
+      
519
+			fseek(f, m_surfaces_start+m_meshes[i].texel_offset, SEEK_SET);
520
+			printWarning("load", "HANDLE: File position set to %lu\n", ftell(f));
521
+		}
522
+
523
+		m_meshes[i].texel = new md3_texel_t[m_meshes[i].num_vertices];
524
+
525
+		for (j = 0; j < m_meshes[i].num_vertices; j++)
526
+		{
527
+			fread_float_small(&m_meshes[i].texel[j].st[0], f);
528
+			fread_float_small(&m_meshes[i].texel[j].st[1], f);
529
+		}
530
+
531
+		// Start vertices /////////////////////
532
+		if (m_surfaces_start+m_meshes[i].vertex_offset != ftell(f))
533
+		{
534
+			printWarning("load", "mesh[%i] vertex offset %i != file pos %lu\n", 
535
+							 i, m_surfaces_start+m_meshes[i].vertex_offset, ftell(f));
536
+      
537
+			fseek(f, m_surfaces_start+m_meshes[i].vertex_offset, SEEK_SET);
538
+			printWarning("load", "HANDLE: File position set to %lu\n", ftell(f));
539
+		}
540
+
541
+		// Should be num_vertices * num_frames??
542
+		m_meshes[i].vertex = 
543
+      new md3_vertex_t[m_meshes[i].num_vertices * m_meshes[i].num_frames];
544
+
545
+		for (j = 0; j < m_meshes[i].num_vertices * m_meshes[i].num_frames; ++j)
546
+		{
547
+			fread(&ss, 2, 1, f);
548
+			m_meshes[i].vertex[j].pos[0] = ss;
549
+			fread(&ss, 2, 1, f);
550
+			m_meshes[i].vertex[j].pos[1] = ss;
551
+			fread(&ss, 2, 1, f);
552
+			m_meshes[i].vertex[j].pos[2] = ss;
553
+
554
+			fread(&sb, 1, 1, f);
555
+			m_meshes[i].vertex[j].st[0] = sb;
556
+
557
+			fread(&sb, 1, 1, f);
558
+			m_meshes[i].vertex[j].st[1] = sb;
559
+
560
+			if (mFlags & fDecodeNormals)
561
+			{
562
+				unsigned short normal;
563
+				unsigned char lat, lng;
564
+
565
+
566
+				normal = (unsigned short)m_meshes[i].vertex[j].st;
567
+				lat = (unsigned char)((normal & 255) * (2 * M_PI) / 255.0);
568
+				lng = (unsigned char)(((normal >> 8) & 255) * (2 * M_PI) / 255.0);
569
+				
570
+				m_meshes[i].vertex[j].norm[0] = cos(lat) * sin(lng);
571
+				m_meshes[i].vertex[j].norm[1] = sin(lat) * sin(lng);
572
+				m_meshes[i].vertex[j].norm[2] = cos(lng);
573
+
574
+				printDebug("load", "%f %f %f\n", 
575
+							  m_meshes[i].vertex[j].norm[0],
576
+							  m_meshes[i].vertex[j].norm[1],
577
+							  m_meshes[i].vertex[j].norm[2]);
578
+			}
579
+		}
580
+
581
+		// Start next surface/mesh /////////////////////
582
+		if (m_surfaces_start+m_meshes[i].mesh_size != ftell(f))
583
+		{
584
+			printWarning("load", "_mesh[%i] next mesh offset %i != file pos %lu\n", 
585
+						  i, m_surfaces_start+m_meshes[i].mesh_size, ftell(f));
586
+      
587
+			fseek(f, m_surfaces_start+m_meshes[i].mesh_size, SEEK_SET);
588
+			printWarning("load", "HANDLE: File position set to %lu\n", ftell(f));
589
+		}
590
+
591
+		// Now acculate this mesh offset
592
+		m_surfaces_start = ftell(f);
593
+	}
594
+
595
+	fclose(f);
596
+
597
+	return 0;
598
+}
599
+
600
+
601
+int Md3::save(char *filename)
602
+{
603
+  FILE *f;
604
+  int i, ii, tmp, hms;
605
+  int32_t si;
606
+  
607
+
608
+  if ((!m_tags && m_num_tags) || (!m_bones && m_num_bones) || 
609
+		(!m_meshes && m_num_meshes))
610
+  {
611
+    printError("save", "invalid md3\n");
612
+    return -1;
613
+  }
614
+
615
+  f = fopen(filename, "wb");
616
+
617
+  if (!f)
618
+  {
619
+    perror("Md3::Save> \n");
620
+    return -1;
621
+  }
622
+
623
+  // Start Header ////////////////
624
+  si = m_id;
625
+  fwrite(&si, 4, 1, f);
626
+  printDebug("save", "id = 0x%x\n", m_id);
627
+  
628
+  m_version = MD3_ALIAS_VERSION;
629
+
630
+  fwrite(&m_version, 4, 1, f);
631
+  printDebug("save", "version = %i\n", m_version);
632
+
633
+  fwrite(&m_filename, sizeof(m_filename), 1, f);
634
+  printDebug("save", "filename = '%s'\n", m_filename);
635
+
636
+  fwrite(&m_num_bones, 4, 1, f);
637
+  printDebug("save", "num_bones = %i\n", m_num_bones);
638
+
639
+  fwrite(&m_num_tags, 4, 1, f);
640
+  printDebug("save", "num_tags = %i\n", m_num_tags);
641
+
642
+  fwrite(&m_num_meshes, 4, 1, f);
643
+  printDebug("save", "num_meshes = %i\n", m_num_meshes);
644
+
645
+  fwrite(&m_max_skins, 4, 1, f);
646
+  printDebug("save", "max_skins = %i\n", m_max_skins);
647
+
648
+  // Seek back and write in actual value later
649
+  // store file postion for now
650
+  m_header_length = ftell(f);
651
+  fwrite(&m_header_length, 4, 1, f);
652
+
653
+  // Seek back and write in actual value later
654
+  // store file postion for now
655
+  m_tag_start = ftell(f);
656
+  fwrite(&m_tag_start, 4, 1, f);
657
+
658
+  // Seek back and write in actual value later
659
+  // store file postion for now
660
+  m_surfaces_start = ftell(f);
661
+  fwrite(&m_surfaces_start, 4, 1, f);
662
+
663
+  // Seek back and write in actual value later
664
+  // store file postiion for now
665
+  m_file_size = ftell(f);
666
+  fwrite(&m_file_size, 4, 1, f);
667
+ 
668
+  // End Header //////////////////
669
+  tmp = m_header_length;
670
+  m_header_length = ftell(f);
671
+  fseek(f, tmp, SEEK_SET);
672
+  fwrite(&m_header_length, 4, 1, f);
673
+  printDebug("save", "header_length = %i\n", m_header_length);
674
+  fseek(f, m_header_length, SEEK_SET);
675
+
676
+  for (i = 0; i < m_num_bones; ++i)
677
+  {
678
+    fwrite(&m_bones[i].mins, sizeof(m_bones[i].mins), 1, f);
679
+    fwrite(&m_bones[i].maxs, sizeof(m_bones[i].maxs), 1, f);
680
+    fwrite(&m_bones[i].center, sizeof(m_bones[i].center), 1, f);
681
+    fwrite(&m_bones[i].scale, sizeof(float), 1, f);
682
+    fwrite(&m_bones[i].creator, 16, 1, f);
683
+
684
+    printDebug("save", "bone[%i].creator = '%s'\n", i, m_bones[i].creator);
685
+  }
686
+
687
+  printDebug("save", "Saving %i tags\n", m_num_tags * m_num_bones);
688
+
689
+  // Start Tags ////////////////
690
+  tmp = m_tag_start;
691
+  m_tag_start = ftell(f);
692
+  fseek(f, tmp, SEEK_SET);
693
+  fwrite(&m_tag_start, 4, 1, f);
694
+  printDebug("save", "tag_start = %i\n", m_tag_start);
695
+  fseek(f, m_tag_start, SEEK_SET);
696
+
697
+  for (i = 0; i < m_num_tags * m_num_bones; ++i)
698
+  {
699
+    fwrite(&m_tags[i].name, 64, 1, f);
700
+    fwrite(&m_tags[i].center, sizeof(m_tags[i].center), 1, f);
701
+    fwrite(&m_tags[i].rotation, sizeof(m_tags[i].rotation), 1, f);
702
+
703
+    printDebug("save", "tag[%i].name = '%s'\n", i, m_tags[i].name);
704
+  }
705
+
706
+  // Start Geometeric data ////////////////
707
+  tmp = m_surfaces_start;
708
+  m_surfaces_start = ftell(f);
709
+  fseek(f, tmp, SEEK_SET);
710
+  fwrite(&m_surfaces_start, 4, 1, f);
711
+  printDebug("save", "surfaces_start = %i\n", m_surfaces_start);
712
+  fseek(f, m_surfaces_start, SEEK_SET);
713
+
714
+  for (i = 0; i < m_num_meshes; i++)
715
+  {
716
+    // Start Mesh Header /////////////////
717
+    hms = ftell(f);
718
+
719
+    fwrite(&m_meshes[i].id, 4, 1, f);
720
+    fwrite(&m_meshes[i].name, 68, 1, f);
721
+    fwrite(&m_meshes[i].num_frames, 4, 1, f);
722
+    fwrite(&m_meshes[i].num_skins, 4, 1, f);
723
+    fwrite(&m_meshes[i].num_vertices, 4, 1, f);
724
+    fwrite(&m_meshes[i].num_triangles, 4, 1, f);
725
+
726
+    m_meshes[i].tris_offset = ftell(f);
727
+    fwrite(&m_meshes[i].tris_offset, 4, 1, f);
728
+
729
+    m_meshes[i].header_size = ftell(f);
730
+    fwrite(&m_meshes[i].header_size, 4, 1, f);
731
+
732
+    m_meshes[i].texel_offset = ftell(f);
733
+    fwrite(&m_meshes[i].texel_offset, 4, 1, f);
734
+
735
+    m_meshes[i].vertex_offset = ftell(f);
736
+    fwrite(&m_meshes[i].vertex_offset, 4, 1, f);
737
+
738
+    m_meshes[i].mesh_size = ftell(f);
739
+    fwrite(&m_meshes[i].mesh_size, 4, 1, f);
740
+
741
+    printDebug("save", "_mesh[%i].name = '%s'\n", i, m_meshes[i].name);
742
+
743
+    // End Mesh Header ///////////////////
744
+    tmp = ftell(f);
745
+    fseek(f, m_meshes[i].header_size, SEEK_SET);
746
+    m_meshes[i].header_size = tmp - hms;
747
+    fwrite(&m_meshes[i].header_size, 4, 1, f);
748
+    printDebug("save", "_mesh[%i].header_size = %i\n",i,m_meshes[i].header_size);
749
+    fseek(f, tmp, SEEK_SET);
750
+
751
+    for(ii = 0; ii < m_meshes[i].num_skins; ii++)
752
+    {
753
+      fwrite(&m_meshes[i].skin[ii].name, 68, 1, f);
754
+
755
+      if (!m_meshes[i].skin[ii].name[0])
756
+	m_meshes[i].skin[ii].name[0] = 'm';
757
+
758
+#ifdef TEST_MD3
759
+      printf("Viewing full skin buffer:\n'");
760
+		
761
+      for (int foo = 0; foo < 68; ++foo)
762
+	printf("%c", m_meshes[i].skin[ii].name[foo]);
763
+
764
+      printf("'\n");
765
+#endif
766
+
767
+      printDebug("save", "_mesh[%i].skin[%i].name = '%s'\n", 
768
+	     i, ii, m_meshes[i].skin[ii].name);
769
+    }
770
+
771
+    // Tris Start //////////////
772
+    tmp = ftell(f);
773
+    fseek(f, m_meshes[i].tris_offset, SEEK_SET);
774
+    m_meshes[i].tris_offset = tmp - hms;
775
+    fwrite(&m_meshes[i].tris_offset, 4, 1, f);
776
+    printDebug("save", "_mesh[%i].tris_offset = %i\n",i,m_meshes[i].tris_offset);
777
+    fseek(f, tmp, SEEK_SET);   
778
+
779
+    for(ii = 0; ii < m_meshes[i].num_triangles; ++ii)
780
+    {
781
+      fwrite(&m_meshes[i].tris[ii].triangle, 12, 1, f);
782
+    }
783
+
784
+    // Texel Start //////////////
785
+    tmp = ftell(f);
786
+    fseek(f, m_meshes[i].texel_offset, SEEK_SET);
787
+    m_meshes[i].texel_offset = tmp - hms;
788
+    fwrite(&m_meshes[i].texel_offset, 4, 1, f);
789
+    printDebug("save", "_mesh[%i].texel_offset = %i\n",
790
+	   i,m_meshes[i].texel_offset);
791
+    fseek(f, tmp, SEEK_SET);   
792
+
793
+    for(ii = 0; ii < m_meshes[i].num_vertices; ++ii)
794
+    {
795
+      fwrite(&m_meshes[i].texel[ii].st, sizeof(m_meshes[i].texel[ii].st), 1, f);
796
+    }
797
+
798
+    // Vertex Start //////////////
799
+    tmp = ftell(f);
800
+    fseek(f, m_meshes[i].vertex_offset, SEEK_SET);
801
+    m_meshes[i].vertex_offset = tmp - hms;
802
+    fwrite(&m_meshes[i].vertex_offset, 4, 1, f);
803
+    printDebug("save", "_mesh[%i]._vertexoffset = %i\n",
804
+	   i,m_meshes[i].vertex_offset);
805
+    fseek(f, tmp, SEEK_SET);  
806
+
807
+    // Should be num_vertices * num_frames??
808
+    for(ii = 0; ii < m_meshes[i].num_vertices * m_meshes[i].num_frames; ++ii)
809
+    {
810
+      fwrite(&m_meshes[i].vertex[ii].pos, sizeof(m_meshes[i].vertex[ii].pos), 1, f);
811
+      fwrite(&m_meshes[i].vertex[ii].st, sizeof(m_meshes[i].vertex[ii].st), 1, f);
812
+    }
813
+    // End Mesh  ///////////////////
814
+    tmp = ftell(f);
815
+    fseek(f, m_meshes[i].mesh_size, SEEK_SET);
816
+    m_meshes[i].mesh_size = tmp - hms;
817
+    fwrite(&m_meshes[i].mesh_size, 4, 1, f);
818
+    printDebug("save", "_mesh[%i].mesh_size = %i\n",i,m_meshes[i].mesh_size);
819
+    fseek(f, tmp, SEEK_SET);
820
+
821
+  }
822
+
823
+  // End File /////////////
824
+  tmp = m_file_size;
825
+  m_file_size = ftell(f);
826
+  fseek(f, tmp, SEEK_SET);
827
+  fwrite(&m_file_size, 4, 1, f);
828
+  printDebug("save", "file_size = %i\n", m_file_size);
829
+  fseek(f, m_file_size, SEEK_SET);
830
+
831
+  fclose(f);
832
+
833
+  return 0;
834
+}
835
+
836
+
837
+////////////////////////////////////////////////////////////
838
+// Private Mutators
839
+////////////////////////////////////////////////////////////
840
+
841
+void Md3::printDebug(char *method, char *s, ...)
842
+{
843
+	va_list args;
844
+
845
+
846
+	if (m_debug < 2)
847
+	{
848
+		return;
849
+	}
850
+
851
+	va_start(args, s);
852
+	fprintf(stdout, "Md3::%s> ", method);
853
+	vfprintf(stdout, s, args);
854
+	fprintf(stdout, "\n");
855
+	va_end(args);
856
+}
857
+
858
+
859
+void Md3::printError(char *method, char *s, ...)
860
+{
861
+	va_list args;
862
+
863
+
864
+	va_start(args, s);
865
+	fprintf(stderr, "Md3::%s> ERROR: ", method);
866
+	vfprintf(stderr, s, args);
867
+	fprintf(stderr, "\n");
868
+	va_end(args);
869
+}
870
+
871
+
872
+void Md3::printWarning(char *method, char *s, ...)
873
+{
874
+	va_list args;
875
+
876
+
877
+	if (m_debug < 1)
878
+	{
879
+		return;
880
+	}
881
+
882
+	va_start(args, s);
883
+	fprintf(stderr, "Md3::%s> WARNING: ", method);
884
+	vfprintf(stderr, s, args);
885
+	fprintf(stderr, "\n");
886
+	va_end(args);
887
+}
888
+
889
+
890
+void Md3::createMeshes(unsigned int num)
891
+{
892
+	m_meshes = new md3_mesh_t[num];
893
+
894
+	texTest = new int[num];
895
+	memset(texTest, 0, num*4);	
896
+}
897
+
898
+
899
+void Md3::createTags(unsigned int num)
900
+{
901
+	m_tags = new md3_tag_t[num];
902
+
903
+	slaveTest = new unsigned int[num];
904
+	memset(slaveTest, 0, num*4);
905
+}
906
+
907
+
908
+void Md3::createBones(unsigned int num)
909
+{
910
+	m_bones = new md3_bone_t[num];
911
+}
912
+
913
+
914
+
915
+////////////////////////////////////////////////////////////
916
+// Unit Test code
917
+////////////////////////////////////////////////////////////
918
+
919
+#ifdef UNIT_TEST_MD3
920
+int main(int argc, char *argv[])
921
+{
922
+	Md3 md3;
923
+
924
+
925
+	printf("[MD3 class test]\n");
926
+	
927
+	md3.setDebug(2);
928
+
929
+	if (argc > 2)
930
+	{
931
+		if (strcmp(argv[1], "load") == 0)
932
+		{
933
+			if (!md3.load(argv[2]))
934
+			{
935
+				printf("main: Load reports success.\n");
936
+			}
937
+		}
938
+		else if (strcmp(argv[1], "save") == 0)
939
+		{
940
+			// FIXME: Add code here to generate a small md3
941
+
942
+			if (!md3.save(argv[2]))
943
+			{
944
+				printf("main: Save reports success.\n");
945
+			}
946
+		}
947
+		else if (strcmp(argv[1], "test") == 0 && argc > 3)
948
+		{
949
+			if (!md3.load(argv[2]))
950
+			{
951
+				printf("main: Load reports success.\n");
952
+			}
953
+
954
+			if (!md3.save(argv[3]))
955
+			{
956
+				printf("main: Save reports success.\n");
957
+			}
958
+		}
959
+		else
960
+		{
961
+			printf("\n\n%s [save | load | test] filename.md3 [testout.md3]\n", 
962
+					 argv[0]);
963
+		}
964
+	}
965
+	else
966
+	{
967
+		printf("\n\n%s [save | load | test] filename.md3 [testout.md3]\n", 
968
+				 argv[0]);
969
+	}
970
+}
971
+#endif
972
+

+ 509
- 0
src/Md3.h 파일 보기

@@ -0,0 +1,509 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*==========================================================================
3
+ * 
4
+ * Project : Freyja
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://gooseegg.sourceforge.net
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Md3
9
+ * Comments: This is the MD3 model class.
10
+ *
11
+ *           See file COPYING for license details.
12
+ *
13
+ *           Quake (c) id Software 1995 - 2000
14
+ *
15
+ *           MD3 file format specs provided by Mental Vortex,
16
+ *           and that site says the specs may not be 100% correct
17
+ *           so - since this class is desgined using their specs...
18
+ *
19
+ *-- Test Defines -----------------------------------------------------
20
+ *           
21
+ * UNIT_TEST_MD3      - Builds Md3 class as a console unit test program 
22
+ * UNIT_TEST_MD3_LV2  - Does more debugging when used with unit test
23
+ *
24
+ *-- History ---------------------------------------------------------- 
25
+ *
26
+ * 2002.10.19:
27
+ * Mongoose - Interface update, Animation support starts
28
+ *
29
+ * 2000.10.07:
30
+ * Mongoose - Interface update
31
+ *
32
+ * 2000.06.03:
33
+ * Mongoose - Created, MD3 specs provided by Mental Vortex
34
+ ==========================================================================*/
35
+
36
+
37
+#ifndef __FREYJA_MONGOOSE_MD3_H
38
+#define __FREYJA_MONGOOSE_MD3_H
39
+
40
+
41
+#define MD3_IDALIASHEADER  0x33504449 // "IDP3"
42
+#define MD3_ALIAS_VERSION  15
43
+#define MD3_MAX_FRAMES     1024
44
+
45
+#ifndef vec3_t
46
+typedef float vec3_t[3];
47
+#endif
48
+
49
+#ifndef mat3_t
50
+typedef float mat3_t[3][3];
51
+#endif
52
+
53
+
54
+typedef struct md3_tag_s
55
+{
56
+  char name[64];    /* Name of 'tag' as it's usually 
57
+							  called in the md3 files try to 
58
+							  see it as a sub-mesh/seperate 
59
+							  mesh-part. 
60
+							  
61
+							  Sometimes this 64 string may 
62
+							  contain some garbage, but 
63
+							  i've been told this is because
64
+							  some tools leave garbage in
65
+							  those strings, but they ARE
66
+							  strings... */
67
+
68
+  vec3_t center;    /* Relative position of tag */
69
+ 
70
+  mat3_t rotation;  /* The direction the tag is facing 
71
+							  relative to the rest of the model */
72
+
73
+} md3_tag_t;
74
+
75
+
76
+typedef struct md3_boneframe_s
77
+{
78
+  float  mins[3];
79
+  float  maxs[3];
80
+  float  center[3];
81
+  float  scale;
82
+  char   creator[16]; 
83
+
84
+} md3_bone_t;
85
+
86
+
87
+typedef struct md3_skin_s
88
+{
89
+  char name[68];       /* Name of skin used by mesh
90
+								  65 chars, 
91
+								  32 bit aligned == 68 chars  */
92
+
93
+  int index;           /* For shader use (skin is a shader) */
94
+
95
+} md3_skin_t;
96
+
97
+
98
+typedef struct md3_tri_index_s
99
+{
100
+  int  triangle[3];    /* Vertex 1, 2, 3 of triangle */
101
+
102
+} md3_tri_index_t;
103
+
104
+
105
+typedef struct md3_texel_s
106
+{
107
+  float st[2];         /* Texel (s, t) */
108
+
109
+} md3_texel_t;
110
+
111
+
112
+typedef struct md3_vertex_s
113
+{
114
+  signed short pos[3];       /* Vertex X/Y/Z coordinate */
115
+
116
+  unsigned char st[2];       /* Enviromental mapping 
117
+										  texture coordinates 
118
+										  (Acutally encoded normal?) */
119
+	
120
+	float norm[3];            /* Decoded normal from above decoded */
121
+
122
+} md3_vertex_t;
123
+
124
+
125
+typedef struct md3_mesh_s
126
+{
127
+  // Start Mesh Header /////////////
128
+
129
+  char id[4];          /* Mesh alias id, must be IDP3  */
130
+
131
+  char name[68];       /* Name of mesh  
132
+								  65 chars,
133
+								  32 bit aligned == 68 chars */
134
+  int flags;
135
+
136
+
137
+  int  num_frames;     /* Number of VertexMorph frames 
138
+								  in mesh */
139
+
140
+  int num_shaders;     /* Number of shaders in mesh*/
141
+
142
+  int  num_skins;      /* Number of skins in mesh, 
143
+								  for backwards compatibility with
144
+								  incorrect/obsolete spec  */
145
+
146
+  int  num_vertices;   /* Number of vertices */
147
+ 
148
+  int  num_triangles;  /* Number of triangles */
149
+ 
150
+  int  tris_offset;    /* Starting position of 
151
+								  Triangle data, relative 
152
+								  to start of Mesh_Header  */
153
+
154
+  int  header_size;    /* Size of header  */
155
+  
156
+  int  texel_offset;   /* Starting position of 
157
+								  texvector data, relative 
158
+								  to start of Mesh_Header */
159
+ 
160
+  int  vertex_offset;  /* Starting position of 
161
+								  vertex data,relative 
162
+								  to start of Mesh_Header  */
163
+
164
+  int  mesh_size;      /* Size of mesh  */
165
+
166
+  // End Mesh Header ///////////////
167
+
168
+
169
+  md3_skin_t *skin;       /* Skins */
170
+
171
+  md3_tri_index_t *tris;  /* Triangles */
172
+
173
+  md3_texel_t *texel;     /* Texels */
174
+  
175
+  md3_vertex_t *vertex;   /* Vertices */
176
+
177
+} md3_mesh_t;
178
+
179
+
180
+class Md3
181
+{
182
+public:
183
+
184
+	enum Md3Flag
185
+	{
186
+		fDecodeNormals = 1
187
+	};
188
+
189
+	////////////////////////////////////////////////////////////
190
+	// Constructors
191
+	////////////////////////////////////////////////////////////
192
+
193
+	Md3();
194
+	/*------------------------------------------------------
195
+	 * Pre  : 
196
+	 * Post : Md3 object is constructed
197
+	 *
198
+	 *-- History ------------------------------------------
199
+	 *
200
+	 * 2000.06.03:
201
+	 * Mongoose - Created
202
+	 ------------------------------------------------------*/
203
+
204
+	Md3(unsigned int num_meshes, unsigned int num_bones, unsigned int num_tags);
205
+	/*------------------------------------------------------
206
+	 * Pre  : Md3 is being used for exporting, since
207
+	 *        this is the only way to allocate arrays
208
+	 *        from public access
209
+	 *
210
+	 * Post : Md3 object is constructed and ready to edit
211
+	 *
212
+	 *-- History ------------------------------------------
213
+	 *
214
+	 * 2002.06.19:
215
+	 * Mongoose - Created
216
+	 ------------------------------------------------------*/
217
+
218
+	~Md3();
219
+	/*------------------------------------------------------
220
+	 * Pre  : Md3 object is allocated
221
+	 * Post : Md3 object is deconstructed
222
+	 *
223
+	 *-- History ------------------------------------------
224
+	 *
225
+	 * 2000.06.03:
226
+	 * Mongoose - Created
227
+	 ------------------------------------------------------*/
228
+
229
+
230
+	////////////////////////////////////////////////////////////
231
+	// Public Accessors
232
+	////////////////////////////////////////////////////////////
233
+  
234
+	unsigned int getNumMeshes();
235
+	/*------------------------------------------------------
236
+	 * Pre  : 
237
+	 * Post : Mesh count is returned
238
+	 *
239
+	 *-- History ------------------------------------------
240
+	 *
241
+	 * 2002.06.19:
242
+	 * Mongoose - Created, Obsoletes:
243
+	 *            2000.06.03, int NumTags();
244
+	 ------------------------------------------------------*/
245
+
246
+	unsigned int getNumTags();
247
+	/*------------------------------------------------------
248
+	 * Pre  : 
249
+	 * Post : Tag count is returned
250
+	 *
251
+	 *-- History ------------------------------------------
252
+	 *
253
+	 * 2002.06.19:
254
+	 * Mongoose - Created, Obsoletes:
255
+	 *            2000.06.03, int NumTags();
256
+	 ------------------------------------------------------*/
257
+  
258
+	unsigned int getNumBones();
259
+	/*------------------------------------------------------
260
+	 * Pre  : 
261
+	 * Post : Bone count is returned
262
+	 *
263
+	 *-- History ------------------------------------------
264
+	 *
265
+	 * 2002.06.19:
266
+	 * Mongoose - Created, Obsoletes:
267
+	 *            2000.06.03, int NumTags();
268
+	 ------------------------------------------------------*/
269
+
270
+	md3_mesh_t *getMeshes();
271
+	/*------------------------------------------------------
272
+	 * Pre  : 
273
+	 * Post : Mesh list is returned
274
+	 *
275
+	 *-- History ------------------------------------------
276
+	 *
277
+	 * 2002.06.19:
278
+	 * Mongoose - Created, Obsoletes:
279
+	 *            2000.06.03, md3_mesh_t *Mesh();
280
+	 ------------------------------------------------------*/
281
+  
282
+	md3_tag_t *getTags();
283
+	/*------------------------------------------------------
284
+	 * Pre  : 
285
+	 * Post : Tag list is returned
286
+	 *
287
+	 *-- History ------------------------------------------
288
+	 *
289
+	 * 2002.06.19:
290
+	 * Mongoose - Created, Obsoletes:
291
+	 *            2000.06.03, md3_tag_t *Tag();
292
+	 ------------------------------------------------------*/
293
+  
294
+	md3_bone_t *getBones();
295
+	/*------------------------------------------------------
296
+	 * Pre  : 
297
+	 * Post : Bone list is returned
298
+	 *
299
+	 *-- History ------------------------------------------
300
+	 *
301
+	 * 2002.06.19:
302
+	 * Mongoose - Created, Obsoletes:
303
+	 *            2000.06.03, md3_boneframe_t *Bone();
304
+	 ------------------------------------------------------*/
305
+
306
+
307
+	////////////////////////////////////////////////////////////
308
+	// Public Mutators
309
+	////////////////////////////////////////////////////////////
310
+  
311
+	void toggleFlag(Md3Flag flag);
312
+	/*------------------------------------------------------
313
+	 * Pre  : 
314
+	 * Post : Toggles a flag
315
+	 *
316
+	 *-- History ------------------------------------------
317
+	 *
318
+	 * 2003.01.01:
319
+	 * Mongoose - Created
320
+	 ------------------------------------------------------*/
321
+
322
+	void reset();
323
+	/*------------------------------------------------------
324
+	 * Pre  : 
325
+	 * Post : Resets all model data
326
+	 *
327
+	 *-- History ------------------------------------------
328
+	 *
329
+	 * 2002.06.22:
330
+	 * Mongoose - Created
331
+	 ------------------------------------------------------*/
332
+
333
+	void setDebug(unsigned char level);
334
+	/*------------------------------------------------------
335
+	 * Pre  : 
336
+	 * Post : level 0 = errors, 1 = warnings, 2 = debug1
337
+	 *
338
+	 *-- History ------------------------------------------
339
+	 *
340
+	 * 2002.06.19:
341
+	 * Mongoose - Created
342
+	 ------------------------------------------------------*/
343
+
344
+	int load(char *filename);
345
+	/*------------------------------------------------------
346
+	 * Pre  : 
347
+	 * Post : Error code is returned, 0 no error
348
+	 *        Md3 filename is read into memory
349
+	 *
350
+	 *-- History ------------------------------------------
351
+	 *
352
+	 * 2000.06.03:
353
+	 * Mongoose - Created
354
+	 ------------------------------------------------------*/
355
+
356
+	int save(char *filename);
357
+	/*------------------------------------------------------
358
+	 * Pre  : 
359
+	 * Post : Error code is returned, 0 no error
360
+	 *        Md3 saved as filename
361
+	 *
362
+	 *-- History ------------------------------------------
363
+	 *
364
+	 * 2000.10.06:
365
+	 * Mongoose - Created
366
+	 ------------------------------------------------------*/
367
+
368
+	// Testing members
369
+	unsigned int *slaveTest;
370
+	unsigned int idTest;
371
+	int *texTest;
372
+
373
+	// For animation rendering
374
+	unsigned int numAnimations;
375
+	unsigned int currentAnimation;
376
+	unsigned int currentFrame;
377
+	unsigned int nextFrame;
378
+	float time;
379
+	float lastTime;
380
+ 
381
+private:
382
+
383
+	////////////////////////////////////////////////////////////
384
+	// Private Accessors
385
+	////////////////////////////////////////////////////////////
386
+
387
+
388
+	////////////////////////////////////////////////////////////
389
+	// Private Mutators
390
+	////////////////////////////////////////////////////////////
391
+
392
+	void printError(char *method, char *s, ...);
393
+	/*------------------------------------------------------
394
+	 * Pre  : 
395
+	 * Post : Dumps error to stderr
396
+	 *
397
+	 *-- History ------------------------------------------
398
+	 *
399
+	 * 2002.06.19:
400
+	 * Mongoose - Created
401
+	 ------------------------------------------------------*/
402
+
403
+	void printWarning(char *method, char *s, ...);
404
+	/*------------------------------------------------------
405
+	 * Pre  : 
406
+	 * Post : Dumps warning to stderr
407
+	 *
408
+	 *-- History ------------------------------------------
409
+	 *
410
+	 * 2002.06.19:
411
+	 * Mongoose - Created
412
+	 ------------------------------------------------------*/
413
+
414
+	void printDebug(char *method, char *s, ...);
415
+	/*------------------------------------------------------
416
+	 * Pre  : Debugging is on
417
+	 * Post : Dumps debug info
418
+	 *
419
+	 *-- History ------------------------------------------
420
+	 *
421
+	 * 2002.06.19:
422
+	 * Mongoose - Created
423
+	 ------------------------------------------------------*/
424
+
425
+	void createMeshes(unsigned int num);
426
+	/*------------------------------------------------------
427
+	 * Pre  : Model hasn't been init yet
428
+	 * Post : Allocates num of meshes for model 
429
+	 *
430
+	 *-- History ------------------------------------------
431
+	 *
432
+	 * 2002.06.19:
433
+	 * Mongoose - Created, Obsoletes:
434
+	 *            2000.10.24, void NumMeshes(int);
435
+	 *            2000.10.24, void Mesh(md3_mesh_t *);
436
+	 ------------------------------------------------------*/
437
+
438
+	void createTags(unsigned int num);
439
+	/*------------------------------------------------------
440
+	 * Pre  : Model hasn't been init yet
441
+	 * Post : Allocates num of tags for model 
442
+	 *
443
+	 *-- History ------------------------------------------
444
+	 *
445
+	 * 2002.06.19:
446
+	 * Mongoose - Created, Obsoletes:
447
+	 *            2000.10.24, void NumTags(int);
448
+	 *            2000.10.24, void Tag(md3_tag_t *);
449
+	 ------------------------------------------------------*/
450
+
451
+	void createBones(unsigned int num);
452
+	/*------------------------------------------------------
453
+	 * Pre  : Model hasn't been init yet
454
+	 * Post : Allocates num of bones for model 
455
+	 *
456
+	 *-- History ------------------------------------------
457
+	 *
458
+	 * 2002.06.19:
459
+	 * Mongoose - Created, Obsoletes:
460
+	 *            2000.10.24, void NumBones(int);
461
+	 *            2000.10.24, void Bone(md3_bone_t *);
462
+	 ------------------------------------------------------*/
463
+
464
+
465
+	unsigned int mFlags;
466
+
467
+
468
+  // Start Header //////////////////////////////////////////////
469
+
470
+	int m_id;                 /* Alias id always "IDP3" */
471
+
472
+	int m_version;            /* Version number, always 15 */
473
+
474
+	char m_filename[68];      /* Sometimes left blank... 
475
+										  65 chars, 32bit aligned == 
476
+										  68 chars */
477
+ 
478
+	int m_num_bones;          /* Number of Bone */
479
+
480
+	int m_num_tags;           /* Number of 'tags' per Bone */
481
+
482
+	int m_num_meshes;         /* Number of meshes/skins */ 
483
+
484
+	int m_max_skins;          /* Maximum number of unique skins
485
+										  used in md3 file */ 
486
+
487
+	int m_header_length;      /* Always equal to the length of 
488
+										  this header */ 
489
+
490
+	int m_tag_start;          /* Starting position of 
491
+										  tag-structures */ 
492
+
493
+	int m_surfaces_start;     /* Starting position of 
494
+										  geometeric data (mesh structures) */
495
+
496
+	int m_file_size;          /* Size of file */
497
+
498
+	// End Header ////////////////////////////////////////////////
499
+
500
+
501
+	unsigned char m_debug;    /* Set level of debug info to stdout */
502
+
503
+	md3_tag_t *m_tags;        /* Tags */
504
+
505
+	md3_bone_t *m_bones;      /* Bones */
506
+
507
+	md3_mesh_t *m_meshes;     /* Meshes */
508
+};
509
+#endif

+ 2302
- 0
src/Md3AnimModel.cpp
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 466
- 0
src/Md3AnimModel.h 파일 보기

@@ -0,0 +1,466 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Freyja
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Md3AnimModel
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: Md3 animation model class
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ *
16
+ *
17
+ *-- Test Defines -----------------------------------------------
18
+ *           
19
+ * UNIT_TEST_MD3 - Builds Md3 class as a console unit test 
20
+ *
21
+ *-- History ----------------------------------------------------
22
+ *
23
+ * 2002.06.19:
24
+ * Mongoose - Created
25
+ ================================================================*/
26
+
27
+
28
+#ifndef __FREYJA_MONGOOSE_MD3ANIMMODEL_H_
29
+#define __FREYJA_MONGOOSE_MD3ANIMMODEL_H_
30
+
31
+#include "Md3.h"
32
+
33
+
34
+typedef enum
35
+{
36
+	MD3_LOD_HIGH = 0,
37
+	MD3_LOD_MED  = 1,
38
+	MD3_LOD_LOW  = 2,
39
+
40
+} md3_lod_t;
41
+
42
+typedef enum
43
+{
44
+	MD3_SEX_MALE = 0,
45
+	MD3_SEX_FEMALE  = 1,
46
+	MD3_SEX_NEUTER  = 2,
47
+
48
+} md3_sex_t;
49
+
50
+typedef enum 
51
+{
52
+	UNSUPPORTED = -1,
53
+	BOTH_DEATH1 = 0,		// The first twirling death animation
54
+	BOTH_DEAD1,				// The end of the first twirling death animation
55
+	BOTH_DEATH2,			// The second twirling death animation
56
+	BOTH_DEAD2,				// The end of the second twirling death animation
57
+	BOTH_DEATH3,			// The back flip death animation
58
+	BOTH_DEAD3,				// The end of the back flip death animation
59
+	TORSO_GESTURE,			// The torso's gesturing animation	
60
+	TORSO_ATTACK,			// The torso's attack1 animation
61
+	TORSO_ATTACK2,			// The torso's attack2 animation
62
+	TORSO_DROP,				// The torso's weapon drop animation
63
+	TORSO_RAISE,			// The torso's weapon pickup animation
64
+	TORSO_STAND,			// The torso's idle stand animation
65
+	TORSO_STAND2,			// The torso's idle stand2 animation
66
+	LEGS_WALKCR,			// The legs's crouching walk animation
67
+	LEGS_WALK,				// The legs's walk animation
68
+	LEGS_RUN,				// The legs's run animation
69
+	LEGS_BACK,				// The legs's running backwards animation
70
+	LEGS_SWIM,				// The legs's swimming animation
71
+	LEGS_JUMP,				// The legs's jumping animation
72
+	LEGS_LAND,				// The legs's landing animation
73
+	LEGS_JUMPB,				// The legs's jumping back animation
74
+	LEGS_LANDB,				// The legs's landing back animation
75
+	LEGS_IDLE,				// The legs's idle stand animation
76
+	LEGS_IDLECR,			// The legs's idle crouching animation
77
+	LEGS_TURN				// The legs's turn animation
78
+	//	MD3_ANIM_SIZE
79
+
80
+} md3_animation_id_t;
81
+
82
+typedef struct md3_texture_s
83
+{
84
+	char *name;
85
+	unsigned int name_len;
86
+	int gl_texture_id;
87
+
88
+} md3_texture_t;
89
+
90
+typedef struct md3_animation_s
91
+{
92
+	md3_animation_id_t id;
93
+
94
+	unsigned int first_frame;
95
+	unsigned int end_frame;
96
+	unsigned int num_frames;
97
+	unsigned int looping_frames;
98
+	unsigned int frames_per_second;
99
+
100
+} md3_animation_t;
101
+
102
+
103
+class Md3AnimModel
104
+{
105
+ public:
106
+
107
+	enum Md3AnimModelFlags
108
+	{
109
+		fDisableTagInterpolate  = 1,
110
+		fAnimate                = 2,
111
+		fRenderBones            = 4,
112
+		fDrawWeapon             = 8,
113
+		fDisableMeshInterpolate = 16,
114
+		fRenderingWarnings      = 32,
115
+		fUseNormals             = 64
116
+	};
117
+
118
+
119
+	////////////////////////////////////////////////////////////
120
+	// Constructors
121
+	////////////////////////////////////////////////////////////
122
+
123
+	Md3AnimModel();
124
+	/*------------------------------------------------------
125
+	 * Pre  : 
126
+	 * Post : Md3AnimModel object is deconstructed
127
+	 *
128
+	 *-- History ------------------------------------------
129
+	 *
130
+	 * 2002.06.19:
131
+	 * Mongoose - Created
132
+	 ------------------------------------------------------*/
133
+
134
+	~Md3AnimModel();
135
+	/*------------------------------------------------------
136
+	 * Pre  : Md3AnimModel object is allocated
137
+	 * Post : Md3AnimModel object is deconstructed
138
+	 *
139
+	 *-- History ------------------------------------------
140
+	 *
141
+	 * 2002.06.19:
142
+	 * Mongoose - Created
143
+	 ------------------------------------------------------*/
144
+
145
+
146
+	////////////////////////////////////////////////////////////
147
+	// Public Accessors
148
+	////////////////////////////////////////////////////////////
149
+
150
+	unsigned int getFlags();
151
+	/*------------------------------------------------------
152
+	 * Pre  : 
153
+	 * Post : Gets option flags
154
+	 *
155
+	 *-- History ------------------------------------------
156
+	 *
157
+	 * 2002.12.29:
158
+	 * Mongoose - Created
159
+	 ------------------------------------------------------*/
160
+
161
+	md3_animation_id_t getAnimUpper();
162
+	/*------------------------------------------------------
163
+	 * Pre  : 
164
+	 * Post : Get animation for upper model
165
+	 *
166
+	 *-- History ------------------------------------------
167
+	 *
168
+	 * 2002.06.22:
169
+	 * Mongoose - Created
170
+	 ------------------------------------------------------*/
171
+
172
+	md3_animation_id_t getAnimLower();
173
+	/*------------------------------------------------------
174
+	 * Pre  : 
175
+	 * Post : Get animation for lower model
176
+	 *
177
+	 *-- History ------------------------------------------
178
+	 *
179
+	 * 2002.06.22:
180
+	 * Mongoose - Created
181
+	 ------------------------------------------------------*/
182
+
183
+
184
+	////////////////////////////////////////////////////////////
185
+	// Public Mutators
186
+	////////////////////////////////////////////////////////////
187
+
188
+	void setFlag(Md3AnimModelFlags flag);
189
+	/*------------------------------------------------------
190
+	 * Pre  : 
191
+	 * Post : Sets option flag
192
+	 *
193
+	 *-- History ------------------------------------------
194
+	 *
195
+	 * 2002.12.29:
196
+	 * Mongoose - Created
197
+	 ------------------------------------------------------*/
198
+
199
+	void toggleFlag(Md3AnimModelFlags flag);
200
+	/*------------------------------------------------------
201
+	 * Pre  : 
202
+	 * Post : Clear/Set option flag
203
+	 *
204
+	 *-- History ------------------------------------------
205
+	 *
206
+	 * 2002.12.29:
207
+	 * Mongoose - Created
208
+	 ------------------------------------------------------*/
209
+
210
+	void setAnimUpper(md3_animation_id_t anim);
211
+	/*------------------------------------------------------
212
+	 * Pre  : 
213
+	 * Post : Animation is set for upper model
214
+	 *
215
+	 *-- History ------------------------------------------
216
+	 *
217
+	 * 2002.06.22:
218
+	 * Mongoose - Created
219
+	 ------------------------------------------------------*/
220
+
221
+	void setAnimLower(md3_animation_id_t anim);
222
+	/*------------------------------------------------------
223
+	 * Pre  : 
224
+	 * Post : Animation is set for lower model
225
+	 *
226
+	 *-- History ------------------------------------------
227
+	 *
228
+	 * 2002.06.22:
229
+	 * Mongoose - Created
230
+	 ------------------------------------------------------*/
231
+
232
+	void setDebug(unsigned char level);
233
+	/*------------------------------------------------------
234
+	 * Pre  : 
235
+	 * Post : level 0 = errors, 1 = warnings, 2 = debug1
236
+	 *
237
+	 *-- History ------------------------------------------
238
+	 *
239
+	 * 2002.06.19:
240
+	 * Mongoose - Created
241
+	 ------------------------------------------------------*/
242
+
243
+	int load(char *modelPath, char *skin, md3_lod_t modelLoD);
244
+	/*------------------------------------------------------
245
+	 * Pre  : modelPath - Path to directory containg data files
246
+	 *
247
+	 *           eg '/usr/local/games/quake3/qbase3/players/slash'
248
+	 *
249
+	 *        skin - name of skin base to use
250
+	 *
251
+	 *           eg 'default' or 'red' or 'blue' etc
252
+	 *
253
+	 *        modelLoD - Level of detail to use, 
254
+	 *
255
+	 * Post : Error code is returned, 0 no error
256
+	 *        Md3s are read into memory
257
+	 *
258
+	 *-- History ------------------------------------------
259
+	 *
260
+	 *
261
+	 * 2002.12.29: 
262
+	 * Mongoose - Progressively loads lower LoDs if it can't
263
+	 *            find passed LoD 
264
+	 *
265
+	 * 2002.06.19:
266
+	 * Mongoose - Created
267
+	 ------------------------------------------------------*/
268
+
269
+	int loadAnimations(char *modelPath);
270
+	/*------------------------------------------------------
271
+	 * Pre  : 
272
+	 * Post : Loads animations for composite model
273
+	 *
274
+	 *-- History ------------------------------------------
275
+	 *
276
+	 * 2002.06.19:
277
+	 * Mongoose - Created
278
+	 ------------------------------------------------------*/
279
+
280
+	int loadWeapon(char *modelPath, char *name);
281
+	/*------------------------------------------------------
282
+	 * Pre  : 
283
+	 * Post : Loads a weapon model
284
+	 *
285
+	 *-- History ------------------------------------------
286
+	 *
287
+	 * 2002.06.19:
288
+	 * Mongoose - Created
289
+	 ------------------------------------------------------*/
290
+
291
+	void render();
292
+	/*------------------------------------------------------
293
+	 * Pre  : Build with USING_OPENGL
294
+	 * Post : Renders entire composite model
295
+	 *
296
+	 *-- History ------------------------------------------
297
+	 *
298
+	 * 2002.06.19:
299
+	 * Mongoose - Created
300
+	 ------------------------------------------------------*/
301
+
302
+	void renderTag(unsigned int id);
303
+	/*------------------------------------------------------
304
+	 * Pre  : Build with USING_OPENGL
305
+	 * Post : Renders tag and it's slaves
306
+	 *
307
+	 *-- History ------------------------------------------
308
+	 *
309
+	 * 2002.06.19:
310
+	 * Mongoose - Created
311
+	 ------------------------------------------------------*/
312
+
313
+	void renderModel(Md3 &model);
314
+	/*------------------------------------------------------
315
+	 * Pre  : Build with USING_OPENGL
316
+	 * Post : Renders single Md3 model
317
+	 *
318
+	 *-- History ------------------------------------------
319
+	 *
320
+	 * 2002.06.19:
321
+	 * Mongoose - Created
322
+	 ------------------------------------------------------*/
323
+
324
+
325
+	unsigned int texNumTest;        /* Number of texTests */
326
+
327
+	md3_texture_t texTest[32];      /* Texture loader/id trans test */
328
+
329
+
330
+private:
331
+
332
+	////////////////////////////////////////////////////////////
333
+	// Private Accessors
334
+	////////////////////////////////////////////////////////////
335
+
336
+
337
+	////////////////////////////////////////////////////////////
338
+	// Private Mutators
339
+	////////////////////////////////////////////////////////////
340
+
341
+	void setCurrentTime(Md3 &model);
342
+	/*------------------------------------------------------
343
+	 * Pre  : 
344
+	 * Post : time is set for model animation
345
+	 *
346
+	 *-- History ------------------------------------------
347
+	 *
348
+	 * 2002.06.23:
349
+	 * Mongoose - Created
350
+	 ------------------------------------------------------*/
351
+
352
+	void updateModel(Md3 &model);
353
+	/*------------------------------------------------------
354
+	 * Pre  : 
355
+	 * Post : Sets up md3 for next render pass
356
+	 *
357
+	 *-- History ------------------------------------------
358
+	 *
359
+	 * 2002.06.23:
360
+	 * Mongoose - Created, obsoletes old anim arrays
361
+	 ------------------------------------------------------*/
362
+
363
+	void initMd3(Md3 &model, unsigned int id);
364
+	/*------------------------------------------------------
365
+	 * Pre  : 
366
+	 * Post : Sets up md3 init animation values
367
+	 *
368
+	 *-- History ------------------------------------------
369
+	 *
370
+	 * 2002.06.23:
371
+	 * Mongoose - Created, obsoletes old anim arrays
372
+	 ------------------------------------------------------*/
373
+
374
+	int addAnim(char *modelPath, md3_animation_id_t id, 
375
+					unsigned int firstFrame, unsigned int numFrames, 
376
+					unsigned int loopingFrames, unsigned int framesPerSecond);
377
+	/*------------------------------------------------------
378
+	 * Pre  : 
379
+	 * Post : Sets up animation array
380
+	 *
381
+	 *-- History ------------------------------------------
382
+	 *
383
+	 * 2002.06.22:
384
+	 * Mongoose - Created, forked off load()
385
+	 ------------------------------------------------------*/
386
+
387
+	int loadMd3(Md3 &model, char *base, char *modelPath, char *skin, 
388
+					md3_lod_t modelLoD);
389
+	/*------------------------------------------------------
390
+	 * Pre  : 
391
+	 * Post : Loads model and if given skin
392
+	 *
393
+	 *-- History ------------------------------------------
394
+	 *
395
+	 * 2002.06.22:
396
+	 * Mongoose - Created, forked off load()
397
+	 ------------------------------------------------------*/
398
+
399
+	int loadSkin(Md3 &model, char *filename);
400
+	/*------------------------------------------------------
401
+	 * Pre  : 
402
+	 * Post : Loads skin for model
403
+	 *
404
+	 *-- History ------------------------------------------
405
+	 *
406
+	 * 2002.06.19:
407
+	 * Mongoose - Created
408
+	 ------------------------------------------------------*/
409
+
410
+	int loadShader(Md3 &model, char *filename);
411
+	/*------------------------------------------------------
412
+	 * Pre  : 
413
+	 * Post : Loads shader for model
414
+	 *
415
+	 *-- History ------------------------------------------
416
+	 *
417
+	 * 2002.06.19:
418
+	 * Mongoose - Created
419
+	 ------------------------------------------------------*/
420
+
421
+	void connectModels(char *tagName, Md3 &modelA, Md3 &modelB);
422
+	/*------------------------------------------------------
423
+	 * Pre  : 
424
+	 * Post : Connects models as A slave to B master
425
+	 *
426
+	 *-- History ------------------------------------------
427
+	 *
428
+	 * 2002.06.19:
429
+	 * Mongoose - Created
430
+	 ------------------------------------------------------*/
431
+
432
+	int cacheTexture(char *texture);
433
+	/*------------------------------------------------------
434
+	 * Pre  : 
435
+	 * Post : Sets up texture filename caching
436
+	 *
437
+	 *-- History ------------------------------------------
438
+	 *
439
+	 * 2002.06.19:
440
+	 * Mongoose - Created
441
+	 ------------------------------------------------------*/
442
+
443
+	unsigned int mFlags;       /* Model options */
444
+
445
+	Md3 m_head;                /* Head model */
446
+
447
+	Md3 m_upper;               /* Upper body model */
448
+
449
+	Md3 m_lower;               /* Lower body model */
450
+
451
+	Md3 m_weapon;              /* Weapon model */
452
+
453
+	unsigned int m_animCount;  /* Number of animations loaded */
454
+
455
+	unsigned char m_debug;     /* Set level of debug info to stdout */
456
+
457
+	md3_sex_t m_sex;           /* Sex of model */
458
+
459
+	md3_animation_t m_anim[32];        /* This models animation list */
460
+
461
+	md3_animation_id_t m_upperAnim;    /* Current upper model animation */
462
+
463
+	md3_animation_id_t m_lowerAnim;    /* Current lower model animation */
464
+};
465
+
466
+#endif

+ 852
- 0
src/MtkImage.cpp 파일 보기

@@ -0,0 +1,852 @@
1
+/*================================================================
2
+ * 
3
+ * Project : Freyja
4
+ * Author  : Mongoose
5
+ * Website : http://www.westga.edu/~stu7440/
6
+ * Email   : stu7440@westga.edu
7
+ * Object  : MtkImage
8
+ * License : GPL See file COPYING, also (C) 2000 Mongoose
9
+ * Comments: This is the new mtkImage class for mtk
10
+ *
11
+ *
12
+ *           This file was generated using Mongoose's C++ 
13
+ *           template generator script.  <stu7440@westga.edu>
14
+ * 
15
+ *-- History ------------------------------------------------- 
16
+ *
17
+ * 2000-10-05:
18
+ * Mongoose - Created
19
+ =================================================================*/
20
+
21
+#include "MtkImage.h"
22
+
23
+#ifdef DEBUG_MEMEORY
24
+#   include "memeory_test.h"
25
+#endif
26
+
27
+
28
+#include <dlfcn.h>
29
+static const char *mtk_image_module_names[] = {
30
+  "pcx",
31
+  "ppm",
32
+  "tga",
33
+  "jpeg",
34
+  "png"
35
+};
36
+
37
+#define MTK_IMAGE_MODULE_NAME_COUNT (sizeof(mtk_image_module_names) / sizeof(mtk_image_module_names[0]))
38
+
39
+
40
+#include <stdio.h>
41
+#include <stdlib.h>
42
+#include <math.h>
43
+
44
+int mtkExtCheck(char *filename, char *ext)
45
+{
46
+  unsigned int len_f, len_e;
47
+ 
48
+ 
49
+  len_f = strlen(filename) - 1;
50
+  len_e = strlen(ext) - 1;
51
+
52
+  while (len_f+1 && len_e+1)
53
+  {
54
+    //printf("extcheck: %c %c\n", filename[len_f], ext[len_e]);
55
+
56
+    if (filename[len_f] == ext[len_e])
57
+    {
58
+      if (ext[len_e] == '.')
59
+      {
60
+	//printf("extcheck: match\n");
61
+	return 0;
62
+      }
63
+    }
64
+    else if (filename[len_f] < ext[len_e])
65
+      return -1;
66
+    else if (filename[len_f] > ext[len_e])
67
+      return 1;
68
+
69
+    len_f--;
70
+    len_e--;
71
+  }
72
+
73
+  return 1;
74
+}
75
+
76
+//////////////////////////////////////////////
77
+
78
+MtkImage::MtkImage()
79
+{
80
+  _image = NULL;
81
+  _palette = NULL;
82
+  _width = 0;             
83
+  _height = 0;            
84
+  _original_width = 0;    
85
+  _original_height = 0;   
86
+  _color_mode = COLORMODE_RGB;
87
+  _image_bpp = 0;
88
+  _palette_bpp = 0;
89
+}
90
+
91
+
92
+MtkImage::~MtkImage()
93
+{
94
+  Clear();
95
+}
96
+
97
+
98
+void MtkImage::Clear()
99
+{
100
+   if (_image)
101
+      delete [] _image;
102
+
103
+   if (_palette)
104
+      delete [] _palette;
105
+
106
+   _width = 0;
107
+   _height = 0;  
108
+   _original_width = 0;
109
+   _original_height = 0;
110
+   _palette_bpp = 0;
111
+}
112
+
113
+
114
+int MtkImage::Width()
115
+{
116
+  return _width;
117
+}
118
+
119
+
120
+int MtkImage::Height()
121
+{
122
+  return _height;
123
+}
124
+
125
+
126
+int MtkImage::OriginalWidth()
127
+{
128
+  return _original_width;
129
+}
130
+
131
+
132
+int MtkImage::OriginalHeight()
133
+{
134
+  return _original_height;
135
+}
136
+
137
+
138
+void MtkImage::Mode(mtk_colormode mode)
139
+{
140
+  fprintf(stderr, "MtkImage::Mode> ERROR not implemented, %s:%i\n",
141
+	  __FILE__, __LINE__);
142
+}
143
+
144
+
145
+//FIXME: Add support for 32bit!
146
+int MtkImage::PaletteLoad(unsigned char *buffer, int bpp)
147
+{
148
+  if (buffer && buffer != _palette && 
149
+      (bpp == 8 || bpp == 16 || bpp == 24))
150
+  {
151
+    if (_palette)
152
+      delete [] _palette;
153
+
154
+    _palette_bpp = bpp;
155
+
156
+    _palette = new unsigned char[768];
157
+    memcpy(_palette, buffer, 768);
158
+      
159
+    return 0;
160
+  }
161
+
162
+  printf("MtkImage::LoadPaletteBuffer()> Assertion Error bpp not {8,16,24}\n");
163
+  return -1;
164
+}
165
+
166
+
167
+int MtkImage::LoadIndexed(unsigned char *image, int width, int height)
168
+{
169
+  int i, size, index;
170
+
171
+
172
+  if (!image || !_palette || !width || !height || image == _image)
173
+  {
174
+    printf("MtkImage::LoadIndexedBuffer> Assertion failed\n");
175
+    return -1;
176
+  }
177
+
178
+  if (_image)
179
+    delete [] _image;
180
+
181
+  size = width * height;
182
+
183
+  _width = _original_width = width;
184
+  _height = _original_height = height;
185
+  _image = new unsigned char[size * 3];
186
+
187
+  _color_mode = COLORMODE_RGB;
188
+
189
+  for (i = 0; i < size; i++)
190
+  {
191
+    index = image[i];
192
+
193
+    if (index * 3 + 2 > 768)
194
+      printf("Index outside of palette!\n");
195
+    else
196
+    {
197
+      _image[i*3] = _palette[index*3];
198
+      _image[i*3+1] = _palette[index*3+1];
199
+      _image[i*3+2] = _palette[index*3+2];
200
+    }
201
+  }
202
+
203
+  return 0;
204
+}
205
+
206
+void MtkImage::PaletteBrighten(float p)
207
+{
208
+  int i;
209
+
210
+
211
+  if (p <= 0.0 || p > 0.999)
212
+  {
213
+    printf("MtkImage::BrightenPalette> %f isn't a postive percentage\n", p);
214
+    return;
215
+  }
216
+
217
+  if (_palette)
218
+  {
219
+    for (i = 0; i < 255; i++)
220
+    {
221
+      _palette[i*3] += (unsigned char)(_palette[i*3] * p);
222
+      _palette[i*3+1] += (unsigned char)(_palette[i*3+1] * p);
223
+      _palette[i*3+2] += (unsigned char)(_palette[i*3+2] * p);
224
+    }    
225
+  }
226
+}
227
+
228
+
229
+void MtkImage::Image(unsigned char **buffer)
230
+{
231
+  *buffer = NULL;
232
+
233
+  if (!_image)
234
+  {
235
+    printf("Image::ImageBuffer> No image allocated\n");
236
+    return;
237
+  }
238
+
239
+  switch (_color_mode)
240
+  {
241
+  case COLORMODE_RGB:
242
+    *buffer = new unsigned char[_width*_height*3];
243
+    memcpy(*buffer, _image, _width*_height*3);
244
+    break;
245
+  case COLORMODE_RGBA:
246
+    *buffer = new unsigned char[_width*_height*4];
247
+    memcpy(*buffer, _image, _width*_height*4);
248
+    break;
249
+  case COLORMODE_INDEXED:
250
+    break;
251
+  }
252
+}
253
+
254
+
255
+void MtkImage::Palette(unsigned char **buffer)
256
+{
257
+  *buffer = NULL;
258
+
259
+  if (!_palette)
260
+  {
261
+    printf("Image::PaletteBuffer> No palette allocated\n");
262
+    return;
263
+  }
264
+
265
+  *buffer = new unsigned char[768];
266
+  memcpy(*buffer, _palette, 768);
267
+}
268
+
269
+
270
+void MtkImage::IndexedImage(unsigned char **buffer)
271
+{
272
+  int size = _width * _height;
273
+  float rgb[3];
274
+  int i;
275
+
276
+
277
+  *buffer = NULL;
278
+
279
+  if (!_image || !_palette)
280
+  {
281
+    printf("MtkImage::IndexedImage> No image or palette allocated\n");
282
+    return;
283
+  }
284
+
285
+  *buffer = new unsigned char[size];
286
+
287
+  for (i = 0; i < size; i++)
288
+  {
289
+    rgb[0] = _image[i*3]/255.0;
290
+    rgb[1] = _image[i*3+1]/255.0;
291
+    rgb[2] = _image[i*3+2]/255.0;
292
+
293
+    (*buffer)[i] = PaletteMatchColor(rgb);
294
+  }
295
+}
296
+
297
+void MtkImage::FlipVertical()
298
+{
299
+  int i, j;
300
+  unsigned char *swap_row = NULL;
301
+
302
+
303
+  if (!_image)
304
+    return;
305
+
306
+  switch(_color_mode)
307
+  {
308
+  case COLORMODE_INDEXED:
309
+    // We don't store images as indexed, they're computed
310
+    break;
311
+  case COLORMODE_RGB:
312
+    swap_row = new unsigned char[_width*3];
313
+
314
+    for (i = 0, j = _height-1; i < _height/2; i++, j--)
315
+    {
316
+      memcpy(swap_row, &_image[i*_width*3], _width*3);
317
+      memcpy(&_image[i*_width*3], &_image[j*_width*3], _width*3);
318
+      memcpy(&_image[j*_width*3], swap_row, _width*3);
319
+    }
320
+
321
+    delete [] swap_row;
322
+    break;
323
+  case COLORMODE_RGBA:
324
+    swap_row = new unsigned char[_width*4];
325
+
326
+    for (i = 0, j = _height-1; i < _height/2; i++, j--)
327
+    {
328
+      memcpy(swap_row, &_image[i*_width*4], _width*4);
329
+      memcpy(&_image[i*_width*4], &_image[j*_width*4], _width*4);
330
+      memcpy(&_image[j*_width*4], swap_row, _width*4);
331
+    }
332
+
333
+    delete [] swap_row;
334
+    break;
335
+  }
336
+}
337
+
338
+// FIXME: static only for now
339
+int MtkImage::Load(char *filename)
340
+{
341
+  int (*load)(char *filename, unsigned char **image, 
342
+	      unsigned int *width, unsigned int *height, char *type);
343
+  int (*check)(char *filename);
344
+  void *handle;
345
+  char *error;
346
+  FILE *f;
347
+  unsigned int i;
348
+  char module_filename[128];
349
+  char module_check[128];
350
+  char module_load[128];
351
+  char *name;
352
+  unsigned char *image;
353
+  unsigned int w, h;
354
+  bool loaded = false;
355
+  char type;
356
+
357
+
358
+  f = fopen(filename, "rb");
359
+
360
+  if (!f)
361
+  {
362
+    perror("MtkImage::Load> File open failed.\n");
363
+    return -1;
364
+  }
365
+
366
+  printf("[MtkImage module loader invoked]\n");
367
+
368
+  for (i = 0; i < MTK_IMAGE_MODULE_NAME_COUNT && !loaded; i++)
369
+  {
370
+    name = (char *)mtk_image_module_names[i];
371
+
372
+    snprintf(module_filename, 128, "libmtk_loader-%s.so", name);
373
+    snprintf(module_load, 128, "mtk_image__%s_load", name);
374
+    snprintf(module_check, 128, "mtk_image__%s_check", name);
375
+
376
+    if (!(handle = dlopen (module_filename, RTLD_NOW))) //RTLD_LAZY)))
377
+    {
378
+      fprintf(stderr, "\tERROR: Couldn't find module '%s'.\n", module_filename);
379
+      return -1;
380
+    }
381
+    else
382
+    {
383
+      printf("\tModule '%s' opened.\n", module_filename);
384
+    
385
+      check = (int (*)(char *filename))dlsym(handle, module_check);
386
+      
387
+      load = (int (*)(char * filename, unsigned char **image, 
388
+		      unsigned int *w, unsigned int *h, 
389
+		      char *type))dlsym(handle, module_load);
390
+
391
+      if ((error = dlerror()) != NULL)  
392
+      {
393
+	fprintf (stderr, "\tERROR: %s\n", error);
394
+	return -5;
395
+      }
396
+
397
+      loaded = (loaded || (!(*check)(filename) && 
398
+			   !(*load)(filename, &image, &w, &h, &type)));
399
+
400
+      if ((error = dlerror()) != NULL) 
401
+	return -10;
402
+     
403
+      dlclose(handle);
404
+    }
405
+  }
406
+
407
+
408
+  if (loaded)
409
+  {
410
+    Clear();
411
+
412
+    _image = image;
413
+    _original_width = _width = w;
414
+    _original_height = _height = h;
415
+
416
+    switch (type)
417
+    {
418
+    case 4:
419
+    case 2:
420
+      _color_mode = COLORMODE_RGBA;
421
+      break;
422
+    default:
423
+      _color_mode = COLORMODE_RGB;
424
+    }
425
+    return 0;
426
+  }
427
+  else
428
+    return -2;
429
+}
430
+
431
+int MtkImage::Save(char *filename, char *format)
432
+{
433
+  extern int mtk_image__tga_save(FILE *f, unsigned char *image,
434
+				 unsigned int width, unsigned int height, 
435
+				 char bpp);
436
+  FILE *f;
437
+  int ret;
438
+  
439
+
440
+  f = fopen(filename, "wb");
441
+
442
+
443
+  ret = mtk_image__tga_save(f, _image, _width, _height, _color_mode+1);
444
+
445
+  if (f)
446
+    fclose(f);
447
+
448
+  return ret;
449
+}
450
+
451
+
452
+int MtkImage::Load(unsigned char *image, unsigned int w, unsigned int h,
453
+	 mtk_colormode mode)
454
+{
455
+  switch (mode)
456
+  {
457
+  case COLORMODE_INDEXED:
458
+    return LoadIndexed(image, w, h);
459
+    break;
460
+  case COLORMODE_RGB:
461
+    if (!image || !w || !h || image == _image)
462
+      return -1;  
463
+
464
+    _width = _original_width = w;
465
+    _height = _original_height = h;
466
+
467
+    if (_image)
468
+      delete [] _image;
469
+
470
+    _color_mode = COLORMODE_RGB;
471
+
472
+    _image = new unsigned char[w * h * 3];
473
+    memcpy(_image, image, w * h * 3);
474
+
475
+    return 0;
476
+    break;
477
+  case COLORMODE_RGBA:
478
+    if (!image || !w || !h || image == _image)
479
+      return -1;  
480
+
481
+    _width = _original_width = w;
482
+    _height = _original_height = h;
483
+
484
+    if (_image)
485
+      delete [] _image;
486
+
487
+    _color_mode = COLORMODE_RGBA;
488
+
489
+    _image = new unsigned char[w * h * 4];
490
+    memcpy(_image, image, w * h * 4);
491
+
492
+    return 0;
493
+    break;
494
+  }
495
+
496
+  return -1;
497
+}
498
+
499
+
500
+// Palette ////////////////////////////////////////////
501
+
502
+// Search palette for matching ( or closest ) rgb color
503
+// Colors *must be 0.0 to 1.0 form!
504
+//
505
+// Note if you have a small palette this may 'wash' to black
506
+// quickly after running through a few times ( 0.0 is default )
507
+int MtkImage::PaletteMatchColor(float rgb[3])
508
+{
509
+  float color[3];
510
+  float best_weight, current_weight;
511
+  int i, best;
512
+
513
+
514
+  if (!_palette)
515
+  {
516
+    printf("MtkImage::MatchColor> ERROR no palette loaded\n");
517
+    return -1;
518
+  }
519
+
520
+  best_weight = current_weight = 0.0;
521
+  
522
+  for (best = 0, i = 0; i < 256; i++)
523
+  {
524
+    // Convert from 0-255 to 0.0-1.0 color scale
525
+    PaletteColor(i, color);
526
+    //color[0] = _palette[i*3]/255.0;
527
+    //color[1] = _palette[i*3+1]/255.0;
528
+    //color[2] = _palette[i*3+2]/255.0;
529
+
530
+    // FIXME: Should be 0.0 (far off) to 1.0 (exact match)
531
+    current_weight = 1.0 - ((fabs(rgb[0] - color[0]) + 
532
+			     fabs(rgb[1] - color[1]) + 
533
+			     fabs(rgb[2] - color[2])) / 3.0);
534
+
535
+    if (current_weight > best_weight)
536
+    {
537
+      best_weight = current_weight;
538
+      best = i;
539
+
540
+      if (best_weight == 1.0)
541
+	i = 1024; // break;
542
+    }
543
+  }
544
+
545
+  return best;
546
+}
547
+
548
+void MtkImage::PaletteColor(int i, float rgb[3])
549
+{
550
+  if (i > 0 && i < 256 && rgb && _palette)
551
+  {
552
+    rgb[0] = (float)_palette[i*3]/255.0;
553
+    rgb[1] = (float)_palette[i*3+1]/255.0;
554
+    rgb[2] = (float)_palette[i*3+2]/255.0;
555
+  }
556
+}	
557
+
558
+
559
+int MtkImage::PaletteLoadLMP(char *filename)
560
+{
561
+  FILE *f;
562
+	
563
+
564
+  f = fopen(filename, "rb");
565
+
566
+  if (f)
567
+  {
568
+    if (!_palette)
569
+      _palette = new unsigned char[768];
570
+
571
+    fread(_palette, 1, 768, f);
572
+    fclose(f);
573
+    return 0;
574
+  }
575
+
576
+  return -1;
577
+}
578
+
579
+int MtkImage::PaletteLoad(char *filename)
580
+{
581
+  FILE *f;
582
+  int i;
583
+  unsigned int rgb[3];
584
+
585
+
586
+  if (!filename)
587
+    return -1;
588
+
589
+  f = fopen(filename, "r");
590
+
591
+  if (f)
592
+  {
593
+    if (_palette)
594
+      delete [] _palette;
595
+
596
+    _palette = new unsigned char[768];
597
+
598
+    for (i = 0; i < 768; i+=3)
599
+    {
600
+      fscanf(f, "%u %u %u\n", 
601
+	     &rgb[0],
602
+	     &rgb[1],
603
+	     &rgb[2]);
604
+
605
+      _palette[i]   = rgb[0];
606
+      _palette[i+1] = rgb[1];
607
+      _palette[i+2] = rgb[2];
608
+    }
609
+    
610
+    fclose(f);
611
+    return 0;
612
+  }
613
+
614
+  return 1;
615
+}
616
+
617
+int MtkImage::PaletteSave(char *filename)
618
+{
619
+  FILE *f;
620
+  int i;
621
+
622
+
623
+  if (!_palette || !filename)
624
+    return -1;
625
+
626
+  f = fopen(filename, "w");
627
+
628
+  if (f)
629
+  {
630
+    for (i = 0; i < 768; i+=3)
631
+    {
632
+      fprintf(f, "%i %i %i\n", 
633
+	      (int)_palette[i], 
634
+	      (int)_palette[i+1], 
635
+	      (int)_palette[i+2]);
636
+    }
637
+    
638
+    fclose(f);
639
+    return 0;
640
+  }
641
+
642
+  return 1;
643
+}
644
+
645
+mtk_colormode MtkImage::Mode()
646
+{
647
+  return _color_mode;
648
+}
649
+
650
+
651
+/* This code based off on gluScaleImage()  */
652
+void MtkImage::Scale()
653
+{
654
+   int i, j, k;
655
+   float* tempin;
656
+   float* tempout;
657
+   float sx, sy;
658
+   int components = 3;
659
+   unsigned char *image;
660
+
661
+
662
+   if (!_image || !_width || !_height)
663
+     return;
664
+
665
+   _height = NextPower(_height);
666
+   _width = NextPower(_width);
667
+
668
+   if (_height > 256) 
669
+     _height = 256;
670
+    
671
+   if (_width > 256) 
672
+     _width = 256;
673
+    
674
+
675
+   // Check to see if scaling is needed
676
+   if (_height == _original_height && _width == _original_width) 
677
+     return;
678
+
679
+   image = new unsigned char[_height * _width * 3];
680
+
681
+   tempin = new float[_original_width * _original_height * 
682
+		      components * sizeof(float)];
683
+   tempout = new float[_width * _height * components * sizeof(float)];
684
+
685
+   if (!tempout || !tempin)
686
+   {
687
+     if (tempout)
688
+       delete [] tempout;
689
+
690
+     if (tempin)
691
+       delete [] tempin;
692
+
693
+     printf("Oh shit out of memory!\n");
694
+     return;
695
+   }
696
+
697
+   // Copy user data to float format.
698
+   for (i = 0; i < _original_height * _original_width * components; i++) 
699
+   {
700
+     tempin[i] = (float)_image[i];
701
+   }
702
+
703
+   // Determine which filter to use by checking ratios.
704
+   if (_width > 1) 
705
+   {
706
+     sx = (float)(_original_width - 1) / (float)(_width - 1);
707
+   } 
708
+   else 
709
+   {
710
+     sx = (float)(_original_width - 1);
711
+   }
712
+
713
+   if (_height > 1)
714
+   {
715
+     sy = (float)(_original_height - 1) / (float) (_height - 1);
716
+   } 
717
+   else 
718
+   {
719
+     sy = (float)(_original_height - 1);
720
+   }
721
+
722
+   if (sx < 1.0 && sy < 1.0) 
723
+   {
724
+     /* Magnify both width and height:  use weighted sample of 4 pixels */
725
+     int i0, i1, j0, j1;
726
+     float alpha, beta;
727
+     float* src00;
728
+     float* src01;
729
+     float* src10;
730
+     float* src11;
731
+     float s1, s2;
732
+     float* dst;
733
+
734
+     for(i = 0; i < _height; i++) 
735
+     {
736
+       i0 = (int)(i * sy);
737
+       i1 = i0 + 1;
738
+
739
+       if (i1 >= _original_height) 
740
+       {
741
+	 i1 = _original_height - 1;
742
+       }
743
+
744
+       alpha = i * sy - i0;
745
+
746
+       for (j = 0; j < _width; j++) 
747
+       {
748
+	 j0 = (int) (j * sx);
749
+	 j1 = j0 + 1;
750
+
751
+	 if (j1 >= _original_width) 
752
+	 {
753
+	   j1 = _original_width - 1;
754
+	 }
755
+
756
+	 beta = j * sx - j0;
757
+
758
+	 /* Compute weighted average of pixels in rect (i0,j0)-(i1,j1) */
759
+	 src00 = tempin + (i0 * _original_width + j0) * components;
760
+	 src01 = tempin + (i0 * _original_width + j1) * components;
761
+	 src10 = tempin + (i1 * _original_width + j0) * components;
762
+	 src11 = tempin + (i1 * _original_width + j1) * components;
763
+
764
+	 dst = tempout + (i * _width + j) * components;
765
+
766
+	 for (k = 0; k < components; k++) 
767
+	 {
768
+	   s1 = *src00++ * (1.0 - beta) + *src01++ * beta;
769
+	   s2 = *src10++ * (1.0 - beta) + *src11++ * beta;
770
+	   *dst++ = s1 * (1.0 - alpha) + s2 * alpha;
771
+	 } 
772
+       }
773
+     }     
774
+   }
775
+   else 
776
+   {
777
+     /* Shrink width and/or height:  use an unweighted box filter */
778
+     int i0, i1;
779
+     int j0, j1;
780
+     int ii, jj;
781
+     float sum;
782
+     float* dst;
783
+
784
+     for (i = 0; i < _height; i++) 
785
+     {
786
+       i0 = (int) (i * sy);
787
+       i1 = i0 + 1;
788
+
789
+       if (i1 >= _original_height) 
790
+       {
791
+	 i1 = _original_height - 1;
792
+       }
793
+
794
+       for (j = 0; j < _width; j++) 
795
+       {
796
+	 j0 = (int) (j * sx);
797
+	 j1 = j0 + 1;
798
+
799
+	 if (j1 >= _original_width) 
800
+	 {
801
+	   j1 = _original_width - 1;
802
+	 }
803
+
804
+	 dst = tempout + (i * _width + j) * components;
805
+
806
+	 /* Compute average of pixels in the rectangle (i0,j0)-(i1,j1) */
807
+	 for (k = 0; k < components; k++) 
808
+	 {
809
+	   sum = 0.0;
810
+
811
+	   for (ii = i0; ii <= i1; ii++) 
812
+	   {
813
+	     for (jj = j0; jj <= j1; jj++) 
814
+	     {
815
+	       sum += *(tempin + (ii * _original_width + jj) 
816
+			* components + k);
817
+	     }
818
+	   }
819
+
820
+	   sum /= ( j1 - j0 + 1 ) * ( i1 - i0 + 1 );
821
+	   *dst++ = sum;
822
+	 }
823
+       } 
824
+     }
825
+   }
826
+
827
+   // Copy to our results.
828
+   for( i = 0; i < _height * _width * components; i++ ) 
829
+   {
830
+     image[i] = (unsigned char) tempout[i];
831
+   }
832
+
833
+   // Delete our temp buffers.
834
+   delete[] tempin;
835
+   delete[] tempout;
836
+   delete[] _image;
837
+
838
+   _image = image;
839
+}
840
+
841
+int MtkImage::NextPower(int seed)
842
+{
843
+  int i;
844
+
845
+  for(i = 1; i < seed; i *= 2) 
846
+    ;
847
+
848
+  return i;
849
+}
850
+
851
+
852
+

+ 243
- 0
src/MtkImage.h 파일 보기

@@ -0,0 +1,243 @@
1
+/*================================================================
2
+ * 
3
+ * Project : Freyja
4
+ * Author  : Mongoose
5
+ * Website : http://www.westga.edu/~stu7440/
6
+ * Email   : stu7440@westga.edu
7
+ * Object  : MtkImage
8
+ * License : GPL See file COPYING, also (C) 2000 Mongoose
9
+ * Comments: This is the mtkImage agent/class for mtk
10
+ *
11
+ *
12
+ *           This file was generated using Mongoose's C++ 
13
+ *           template generator script.  <stu7440@westga.edu>
14
+ * 
15
+ *-- History ------------------------------------------------ 
16
+ *
17
+ * 2000-10-05:
18
+ * Mongoose - Created
19
+ ================================================================*/
20
+
21
+
22
+#ifndef __MTK_MONGOOSE_MTKIMAGE_H_
23
+#define __MTK_MONGOOSE_MTKIMAGE_H_
24
+
25
+#include <stdio.h>
26
+
27
+typedef enum mtk_colormode
28
+{
29
+  COLORMODE_INDEXED = 1, 
30
+  COLORMODE_RGB     = 2, 
31
+  COLORMODE_RGBA    = 3
32
+};
33
+
34
+int mtkExtCheck(char *filename, char *ext);
35
+
36
+class MtkImage
37
+{
38
+ public:
39
+
40
+  MtkImage();
41
+  /*--------------------------------------------
42
+   * Created  : 2000-10-05 by Mongoose
43
+   * Modified : 
44
+   *
45
+   * Pre  : None
46
+   * Post : MtkImage agent is constructed
47
+   --------------------------------------------*/
48
+
49
+  ~MtkImage();
50
+  /*--------------------------------------------
51
+   * Created  : 2000-10-05 by Mongoose
52
+   * Modified : 
53
+   *
54
+   * Pre  : MtkImage agent is allocated
55
+   * Post : MtkImage agent is deconstructed
56
+   --------------------------------------------*/
57
+
58
+   void Clear();
59
+  /*--------------------------------------------
60
+   * Created  : 2000-10-05 by Mongoose
61
+   * Modified : 
62
+   *
63
+   * Pre  : None
64
+   * Post : MtkImage agent's data is reset to 
65
+   *        initial state
66
+   --------------------------------------------*/
67
+
68
+   int Width();
69
+  /*--------------------------------------------
70
+   * Created  : 2000-10-05 by Mongoose
71
+   * Modified : 
72
+   *
73
+   * Pre  : None
74
+   * Post : Returns image width
75
+   --------------------------------------------*/
76
+
77
+   int Height();
78
+  /*--------------------------------------------
79
+   * Created  : 2000-10-05 by Mongoose
80
+   * Modified : 
81
+   *
82
+   * Pre  : None
83
+   * Post : Returns image height
84
+   --------------------------------------------*/
85
+
86
+   int OriginalWidth();
87
+  /*--------------------------------------------
88
+   * Created  : 2000-10-05 by Mongoose
89
+   * Modified : 
90
+   *
91
+   * Pre  : None
92
+   * Post : Returns image width before transforms
93
+   --------------------------------------------*/
94
+
95
+   int OriginalHeight();
96
+  /*--------------------------------------------
97
+   * Created  : 2000-10-05 by Mongoose
98
+   * Modified : 
99
+   *
100
+   * Pre  : None
101
+   * Post : Returns image height before transforms
102
+   --------------------------------------------*/
103
+
104
+   void Mode(mtk_colormode mode);
105
+  /*--------------------------------------------
106
+   * Created  : 2000-10-05 by Mongoose
107
+   * Modified : 
108
+   *
109
+   * Pre  : mode is an mtk_colormode
110
+   * 
111
+   *        NOTE: You can't set to an indexed mode
112
+   *        since they are computed per palette
113
+   * 
114
+   * Post : Converts image into a new color mode
115
+   *        if not in that mode already
116
+   --------------------------------------------*/
117
+
118
+   void Image(unsigned char **image);
119
+  /*--------------------------------------------
120
+   * Created  : 2000-10-05 by Mongoose
121
+   * Modified : 
122
+   *
123
+   * Pre  : image must be an unallocated pointer
124
+   *
125
+   * Post : Returns a copy of the image buffer
126
+   *        in mode, or NULL if unable
127
+   --------------------------------------------*/
128
+
129
+   void IndexedImage(unsigned char **image);
130
+  /*--------------------------------------------
131
+   * Created  : 2000-10-05 by Mongoose
132
+   * Modified : 
133
+   *
134
+   * Pre  : image must be an unallocated pointer
135
+   *        A palette must have been loaded
136
+   *
137
+   * Post : Returns a copy of a computed
138
+   *        indexed image
139
+   --------------------------------------------*/
140
+
141
+   int Load(unsigned char *image, unsigned int width, unsigned int height, 
142
+	    mtk_colormode mode);
143
+  /*--------------------------------------------
144
+   * Created  : 2000-10-05 by Mongoose
145
+   * Modified : 
146
+   *
147
+   * Pre  : image must be valid
148
+   *        width and height must be valid
149
+   *        mode must be valid
150
+   *
151
+   *        1. Palettes must be loaded to make
152
+   *           a computed INDEXED mode image
153
+   *
154
+   * Post : Loads image of type mode
155
+   --------------------------------------------*/
156
+
157
+   void Palette(unsigned char **buffer);
158
+  /*--------------------------------------------
159
+   * Created  : 2000-10-05 by Mongoose
160
+   * Modified : 
161
+   *
162
+   * Pre  : buffer must be an unallocated pointer
163
+   * Post : Returns a copy of the palette buffer
164
+   --------------------------------------------*/
165
+
166
+   int PaletteMatchColor(float rgb[3]);
167
+  /*--------------------------------------------
168
+   * Created  : 2000-10-05 by Mongoose
169
+   * Modified : 
170
+   *
171
+   * Pre  : rgb is a color as defined as an
172
+   *        array of Red Green and Blue with
173
+   *        colors ranged 0.0 to 1.0
174
+   *
175
+   * Post : Returns closest matched color index
176
+   *        it can find in a loaded palette
177
+   *
178
+   *        NOTE: tends to lean to darker shades
179
+   --------------------------------------------*/
180
+
181
+   //////////////////////////////////////////////
182
+   int Load(char *filename);
183
+   int Save(char *filename, char *format);
184
+
185
+   int PaletteLoad(unsigned char *filename, int bpp);
186
+   int PaletteSave(char *filename);
187
+   int PaletteLoad(char *filename);
188
+   int PaletteLoadLMP(char *filename);
189
+   //////////////////////////////////////////////
190
+
191
+   void Scale();
192
+   void PaletteBrighten(float p);
193
+   void PaletteGamma(float b);
194
+   void PaletteColor(int i, float rgb[3]);
195
+   void FlipVertical();
196
+   mtk_colormode Mode();
197
+
198
+ private:
199
+
200
+   int LoadIndexed(unsigned char *image, int width, int height);
201
+  /*--------------------------------------------
202
+   * Created  : 2000-10-05 by Mongoose
203
+   * Modified : 
204
+   *
205
+   * Pre  : image must be valid indexed image
206
+   *        width must be valid
207
+   *        height must be valid
208
+   *        pallette must have been previously
209
+   *        loaded
210
+   *
211
+   * Post : Loads indexed image using previously
212
+   *        loaded pallette
213
+   --------------------------------------------*/
214
+
215
+   int NextPower(int seed);
216
+  /*--------------------------------------------
217
+   * Created  : 2000-10-05 by Mongoose
218
+   * Modified : 
219
+   *
220
+   * Pre  : seed is valid ( last power )
221
+   * Post : Returns next power of 2
222
+   --------------------------------------------*/
223
+
224
+   unsigned char *_image;                 /* Image buffer */
225
+
226
+   unsigned char *_palette;               /* Image palette */
227
+
228
+   int _width;                            /* Width of image */
229
+
230
+   int _height;                           /* Height of image */
231
+
232
+   int _original_width;                   /* Width before transforms */
233
+
234
+   int _original_height;                  /* Height before transforms */
235
+
236
+   enum mtk_colormode _color_mode;        /* Color mode of image */
237
+
238
+   int _image_bpp;                        /* Color depth of image */ 
239
+
240
+   int _palette_bpp;                      /* Color depth of palette */
241
+};
242
+
243
+#endif

+ 791
- 0
src/Network.cpp 파일 보기

@@ -0,0 +1,791 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : UnRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Network
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: 
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2002.06.21:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#include "Network.h"
23
+
24
+#include <unistd.h>
25
+#include <signal.h>
26
+#include <string.h>
27
+#include <time.h>
28
+#include <sys/time.h>
29
+#include <errno.h>
30
+#include <strings.h>
31
+#include <stdio.h>
32
+#include <sys/types.h>
33
+#include <sys/socket.h>
34
+#include <netinet/in.h>
35
+#include <netdb.h>
36
+#include <arpa/inet.h>
37
+#include <stdlib.h>
38
+
39
+//#define LOCAL_BCAST
40
+#define NETWORK_RELIABLE
41
+#define MAX_CLIENTS 32
42
+
43
+typedef struct client_s
44
+{
45
+	unsigned int uid;
46
+	char active;
47
+	unsigned int seq;
48
+	unsigned int frameExpected;
49
+
50
+} client_t;
51
+
52
+
53
+#ifdef USING_PTHREADS
54
+#   include <pthread.h>
55
+pthread_t gPThreadId[3];
56
+#endif
57
+
58
+unsigned int gUID;
59
+client_t gClients[MAX_CLIENTS];
60
+unsigned int gNumClients = 0;
61
+network_frame_t gPiggyBack;
62
+
63
+
64
+////////////////////////////////////////////////////////////
65
+// Constructors
66
+////////////////////////////////////////////////////////////
67
+
68
+Network *Network::mInstance = 0x0;
69
+
70
+
71
+Network *Network::Instance()
72
+{
73
+	if (mInstance == 0x0) 
74
+	{
75
+		mInstance = new Network();
76
+	}
77
+	
78
+	return mInstance;
79
+}
80
+
81
+
82
+void killNetworkSingleton()
83
+{
84
+	printf("Shutting down Network...\n");
85
+	
86
+	// Requires public deconstructor
87
+	delete Network::Instance();
88
+}
89
+
90
+
91
+Network::Network()
92
+{
93
+	strncpy(mRemoteHost, "localhost", REMOTE_HOST_STR_SZ);
94
+	memset(mBindHost, 0, BIND_HOST_STR_SZ);
95
+	setPort(8080);
96
+
97
+	mPiggyBack = true;
98
+	mNetworkReliable = true;
99
+	mSpawnedClient = false;
100
+	mSpawnedServer = false;
101
+	mKillClient = false;
102
+	mKillServer = false;
103
+	mDebug = false;
104
+
105
+	gUID = getUID();
106
+
107
+	printf("UID %u\n", gUID);
108
+
109
+	for (gNumClients = MAX_CLIENTS; gNumClients > 0;)
110
+	{
111
+		--gNumClients;
112
+
113
+		gClients[gNumClients].active = 0;
114
+		gClients[gNumClients].uid = 0;
115
+		gClients[gNumClients].seq = 0;
116
+	}
117
+}
118
+
119
+
120
+Network::~Network()
121
+{
122
+	killServerThread();
123
+	killClientThread();
124
+}
125
+
126
+
127
+////////////////////////////////////////////////////////////
128
+// Public Accessors
129
+////////////////////////////////////////////////////////////
130
+
131
+network_frame_t &Network::getPiggyBack()
132
+{
133
+	return gPiggyBack;
134
+}
135
+
136
+
137
+unsigned int Network::getUID()
138
+{
139
+	struct timeval tv;
140
+	struct timezone tz;
141
+
142
+
143
+	gettimeofday(&tv, &tz);
144
+
145
+	srand(tv.tv_usec);
146
+
147
+	return ((unsigned int)(tv.tv_sec * getRandom(2.0, 3.3) -
148
+								  tv.tv_sec * getRandom(1.0, 2.0)) + 
149
+			  (unsigned int)(tv.tv_usec * getRandom(2.0, 3.3) -
150
+								  tv.tv_usec * getRandom(1.0, 2.0)) +
151
+			  (unsigned int)getRandom(666.0, 5000.0));
152
+}
153
+
154
+
155
+float Network::getRandom(float from, float to)
156
+{
157
+	return from + (to*rand()/(RAND_MAX+1.0));
158
+}
159
+
160
+
161
+int Network::getPort()
162
+{
163
+	return mPort;
164
+}
165
+
166
+
167
+////////////////////////////////////////////////////////////
168
+// Public Mutators
169
+////////////////////////////////////////////////////////////
170
+
171
+void *client_thread(void *v)
172
+{
173
+	Network &network = *Network::Instance();
174
+	network.runClient();
175
+
176
+	return NULL;
177
+}
178
+
179
+
180
+void *server_thread(void *v)
181
+{
182
+	Network &network = *Network::Instance();
183
+	network.runServer();
184
+
185
+	return NULL;
186
+}
187
+
188
+
189
+void Network::setBindHost(char *s)
190
+{
191
+	if (!s && !s[0])
192
+		return;
193
+
194
+	strncpy(mBindHost, s, BIND_HOST_STR_SZ);
195
+}
196
+
197
+
198
+void Network::setRemoteHost(char *s)
199
+{
200
+	if (!s && !s[0])
201
+		return;
202
+
203
+	strncpy(mRemoteHost, s, REMOTE_HOST_STR_SZ);
204
+}
205
+
206
+
207
+void Network::setDebug(bool toggle)
208
+{
209
+	mDebug = toggle;
210
+}
211
+
212
+
213
+void Network::setPort(unsigned int port)
214
+{
215
+	mPort = port;
216
+}
217
+
218
+
219
+void Network::killServerThread()
220
+{
221
+	mKillServer = true;
222
+
223
+	// Remember for mutex
224
+	//	while (mKillServer)
225
+	//	{
226
+	//	}
227
+
228
+	mSpawnedServer = false;
229
+}
230
+
231
+
232
+void Network::killClientThread()
233
+{
234
+	mKillClient = true;
235
+
236
+	// Remember for mutex
237
+	//	while (mKillClient)
238
+	//	{
239
+	//	}
240
+
241
+	mSpawnedClient = false;
242
+}
243
+
244
+
245
+void Network::spawnServerThread()
246
+{
247
+	// For now don't handle shutting down server to start client and vv
248
+	if (!mSpawnedServer && !mSpawnedClient)
249
+	{
250
+#ifdef USING_PTHREADS
251
+		pthread_create(gPThreadId + 0, 0, server_thread, NULL);
252
+#else
253
+		printf("Network::spawnServerThread> Build doesn't support threads\n");
254
+#endif
255
+
256
+		mSpawnedServer = true;
257
+	}
258
+}
259
+
260
+
261
+void Network::spawnClientThread()
262
+{
263
+	// For now don't handle shutting down server to start client and vv
264
+	if (!mSpawnedServer && !mSpawnedClient)
265
+	{
266
+#ifdef USING_PTHREADS
267
+		pthread_create(gPThreadId + 1, 0, client_thread, NULL);
268
+#else
269
+		printf("Network::spawnClientThread> Build doesn't support threads\n");
270
+#endif
271
+
272
+		mSpawnedClient = true;
273
+	}
274
+}
275
+
276
+
277
+////////////////////////////////////////////////////////////
278
+// Protected Mutators
279
+////////////////////////////////////////////////////////////
280
+
281
+int Network::runServer()
282
+{
283
+	unsigned int fsize;
284
+ 	int socket_fd, cc, cip;
285
+	struct sockaddr_in s_in, from;
286
+	char hostid[64];
287
+	network_frame_t f;
288
+	unsigned int i;	
289
+	unsigned int packetsRecieved = 0;
290
+
291
+
292
+	socket_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
293
+
294
+	if (socket_fd < 0)
295
+	{
296
+		perror("recv_udp:socket");
297
+		return -1;
298
+	}
299
+
300
+	if (mBindHost[0])
301
+	{
302
+		strncpy(hostid, mBindHost, 64);
303
+	}
304
+	else
305
+	{
306
+		if (gethostname(hostid, 64) < 0)
307
+		{
308
+			perror("Server: recv_udp:gethostname");
309
+			return -1;
310
+		}
311
+
312
+		printf("Server: gethostname returned '%s'\n", hostid); 
313
+		fflush(stdout);
314
+	}
315
+
316
+	// Setup for port binding
317
+	memset(&s_in, 0, sizeof(s_in));
318
+	s_in.sin_family = AF_INET;
319
+#ifdef LOCAL_BCAST
320
+	struct hostent *hostptr;
321
+
322
+	if ((hostptr = gethostbyname(hostid)) == NULL)
323
+	{
324
+		fprintf(stderr, "Server: recv_udp, Invalid host name '%s'\n", hostid);
325
+		return -1;
326
+	}
327
+
328
+	memcpy((void *)(&s_in.sin_addr), hostptr->h_addr, hostptr->h_length);
329
+#else
330
+	s_in.sin_addr.s_addr = htonl(INADDR_ANY);
331
+#endif
332
+	int port = getPort();
333
+	s_in.sin_port = htons(port); // htons new
334
+
335
+	fflush(stdout);
336
+
337
+	// Bind
338
+	while (bind(socket_fd, (struct sockaddr *)&s_in, sizeof(s_in)) < 0)
339
+	{
340
+		if (s_in.sin_port++ > (port + 10))
341
+		{
342
+			perror("Server: recv_udp:bind exhausted");
343
+			return -1;
344
+		}
345
+	}
346
+
347
+	cip = ntohl(s_in.sin_addr.s_addr);
348
+
349
+	printf("Server: Started on ( %i.%i.%i.%i:%i )\n", 
350
+			 cip >> 24, cip << 8 >> 24, 
351
+			 cip << 16 >> 24, cip << 24 >> 24, s_in.sin_port);
352
+
353
+	for (; !mKillClient;)
354
+	{
355
+		fsize = sizeof(from);
356
+
357
+		// 1. Wait for event
358
+		// 2. Get inbound frame
359
+		cc = recvfrom(socket_fd, &f, sizeof(network_frame_t), 0, 
360
+						  (struct sockaddr *)&from, &fsize);
361
+
362
+		if (cc < 0)
363
+		{
364
+			perror("Server: recv_udp:recvfrom");
365
+			continue;
366
+		}
367
+
368
+		++packetsRecieved;
369
+
370
+		if (mDebug)
371
+		{
372
+			printf("=====================================================\n");
373
+			printf("Packet %i\n", packetsRecieved);
374
+			printf("Server: Recieved packet from %u\n",
375
+					 f.uid);
376
+		}
377
+
378
+		// A. Look and see if this client has connected before
379
+		for (i = 0; i < gNumClients; ++i)
380
+		{
381
+			if (gClients[i].uid == f.uid)
382
+			{
383
+				break;
384
+			}
385
+		}
386
+
387
+		// B. Collect client data if it's a new connection
388
+		if (!gClients[i].active)
389
+		{
390
+			for (i = 0; i < gNumClients+1; ++i)
391
+			{
392
+				if ((i + 1) < MAX_CLIENTS && !gClients[i].active)
393
+				{
394
+					gClients[i].uid = f.uid;
395
+					gClients[i].active = 1;
396
+					gClients[i].frameExpected = 0;
397
+					++gNumClients;
398
+
399
+					printf("Server: %u made connection, as client %i\n", 
400
+							 gClients[i].uid, i);
401
+					break;
402
+				}
403
+			}
404
+
405
+			if (i == MAX_CLIENTS || !gClients[i].active)
406
+			{
407
+				if (mDebug)
408
+				{
409
+					printf("Server: Handshake packet from %u failed?\n",
410
+							 f.uid);
411
+				}
412
+				continue;
413
+			}
414
+		}
415
+
416
+		cip = ntohl(from.sin_addr.s_addr);
417
+
418
+		if (mDebug)
419
+		{
420
+			printf("Server: Client (Famliy %d, Address %i.%i.%i.%i:%d)\n", 
421
+					 ntohs(from.sin_family), cip >> 24, cip << 8 >> 24, 
422
+					 cip << 16 >> 24, cip << 24 >> 24, 
423
+					 ntohs(from.sin_port));
424
+
425
+			printf("Server: Datalink layer recieved: packet seq %i\n", 
426
+					 f.seq);
427
+		}
428
+
429
+		if (mNetworkReliable)
430
+		{
431
+			if (f.seq == gClients[i].seq)
432
+			{
433
+				if (mDebug)
434
+				{
435
+					printf("SERVER> Msg from %u\n", f.uid);
436
+				}
437
+
438
+				to_network_layer(f.data);
439
+				gClients[i].seq = f.seq;
440
+			}
441
+			else
442
+			{
443
+				continue;
444
+			}
445
+		}
446
+
447
+		// FIXME: Combine with above, duh
448
+		// 3. Send to network layer
449
+		if (gClients[i].frameExpected == f.header)
450
+		{
451
+			f.data.cid = i;
452
+
453
+			to_network_layer(f.data);
454
+			gClients[i].frameExpected = !gClients[i].frameExpected;
455
+		}
456
+		
457
+		fflush(stdout);
458
+		
459
+#ifdef UNIT_TEST_NETWORK
460
+		if ((rand() % 10 == 0))
461
+		{
462
+			printf("Server: Simulating a lost ack %i\n", f.seq);
463
+			continue;
464
+		}
465
+#endif
466
+		
467
+		// 4. Send ACK, w/ piggyback if requested
468
+		if (mPiggyBack)
469
+		{
470
+			gPiggyBack.header = 0;
471
+			gPiggyBack.seq = f.seq;
472
+			gPiggyBack.uid = gUID;
473
+
474
+			if (mDebug)
475
+			{
476
+				printf("SERVER> Sending data by piggyback\n");
477
+			}
478
+
479
+			cc = sendto(socket_fd, &gPiggyBack, sizeof(gPiggyBack), 0, 
480
+							(struct sockaddr *)&from, sizeof(from));
481
+		}
482
+		else
483
+		{
484
+			f.header = 0;
485
+			f.seq = 0;
486
+			f.uid = gUID;
487
+
488
+			cc = sendto(socket_fd, &f, sizeof(f), 0, 
489
+							(struct sockaddr *)&from, sizeof(from));
490
+		}
491
+		
492
+		if (cc < 0)
493
+		{
494
+			perror("Server: send_udp:sendto");
495
+		}
496
+		else
497
+		{
498
+			if (mDebug)
499
+			{
500
+				printf("Server: Ack sent to %u\n", gClients[i].uid);
501
+			}
502
+		}
503
+	}
504
+
505
+	mKillClient = false;
506
+
507
+	return 0;
508
+}
509
+
510
+
511
+void Network::runClient()
512
+{
513
+	unsigned int fsize, last_frame_sent = 0;
514
+	int socket_fd, cc, done;
515
+	struct sockaddr_in dest;
516
+	struct hostent *hostptr;
517
+	network_frame_t f;
518
+	struct timeval timeout;
519
+	fd_set  readfds;
520
+	unsigned int packetsSent = 0;
521
+	unsigned int seq = 0;
522
+	char timedOut = 1;  
523
+
524
+	if (!mRemoteHost || !mRemoteHost[0])
525
+	{
526
+		return;
527
+	}
528
+
529
+	memset((char*) &timeout, 0, sizeof(timeout)); 
530
+	timeout.tv_sec = 5; 
531
+
532
+	socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
533
+
534
+	if (socket_fd == -1)
535
+	{
536
+		perror("Client: send_udp: socket");
537
+		exit(0);
538
+	}
539
+    
540
+	if ((hostptr = gethostbyname(mRemoteHost)) == NULL)
541
+	{
542
+		fprintf(stderr, "Client: send_udp: invalid host name, %s\n", 
543
+				  mRemoteHost);
544
+		exit(0);
545
+	}
546
+
547
+	// Setup connection
548
+	bzero((char*) &dest, sizeof(dest));
549
+	dest.sin_family = AF_INET;
550
+	int port = getPort();
551
+	dest.sin_port = htons(port);
552
+#ifdef LOCAL_BCAST
553
+	memcpy(hostptr->h_addr, (char *) &dest.sin_addr, hostptr->h_length);
554
+#else
555
+	if (inet_pton(AF_INET, mRemoteHost, &dest.sin_addr) < 0)
556
+	{
557
+		perror("inet_pton");
558
+		return;
559
+	}
560
+#endif
561
+
562
+
563
+	// init	
564
+	f.data.send = 0;
565
+	f.seq = 0;
566
+
567
+	for (; !mKillServer;)
568
+	{
569
+		++packetsSent;
570
+
571
+		if (mDebug)
572
+		{
573
+			printf("=====================================================\n");
574
+			printf("Packet %i\n", packetsSent);
575
+		}
576
+
577
+		// 1. Get packet to send over wire
578
+		if (mNetworkReliable && timedOut && f.seq != seq)
579
+		{
580
+			if (mDebug)
581
+			{
582
+				printf("Client: Resending packet\n");
583
+			}
584
+		}
585
+		else
586
+		{
587
+			from_network_layer(&f.data, &last_frame_sent);
588
+
589
+			if (!f.data.send)
590
+			{
591
+				usleep(20);
592
+				continue;
593
+			}
594
+		}
595
+
596
+		// 2. Copy to frame
597
+		f.seq = 0;//seq;  // 0 forces all packets to check out
598
+		f.uid = gUID;
599
+
600
+		// 3. Send over the wire
601
+		done = 0;
602
+		timedOut = 0;
603
+
604
+		while (!done)
605
+		{
606
+			if (mDebug)
607
+			{
608
+				printf("Client: Sending packet %i\n", f.seq);
609
+			}
610
+
611
+			cc = sendto(socket_fd, &f, sizeof(f), 0, 
612
+							(struct sockaddr *)&dest, sizeof(dest));
613
+
614
+			if (cc < 0)
615
+			{
616
+				perror("Client: send_udp:sendto");
617
+
618
+				if (errno == EMSGSIZE)
619
+				{
620
+					printf("Client: packet was too large\n");
621
+				}
622
+			}
623
+			else
624
+			{
625
+				f.data.send = 0;
626
+			}
627
+
628
+			// Comment out this to enable more reliable service
629
+			done = 1;
630
+		}
631
+
632
+		// 4. Wait for +ack or resend
633
+		FD_ZERO(&readfds);
634
+ 
635
+		// Setup socket to listen on here
636
+		FD_SET(socket_fd, &readfds);
637
+
638
+		// Set timeout in milliseconds
639
+		timeout.tv_usec = 850; 
640
+
641
+		cc = select(socket_fd + 1, &readfds, NULL, NULL, &timeout);
642
+
643
+		if ((cc < 0) && (errno != EINTR)) 
644
+		{
645
+			// there was an local error with select
646
+		}
647
+
648
+		if (cc == 0)
649
+		{
650
+			if (mDebug)
651
+			{
652
+				printf("Client: Timeout detected on packet %i\n", f.seq);
653
+			}
654
+			timedOut = 1;
655
+			continue;
656
+		}
657
+
658
+		// Clear header for recv use
659
+		f.header = 0;
660
+
661
+		fsize = sizeof(dest);
662
+		cc = recvfrom(socket_fd, &f, sizeof(f), 0, 
663
+						  (struct sockaddr *)&dest, &fsize); 
664
+
665
+		if (cc < 0)
666
+		{
667
+			perror("Client: recv_udp:recvfrom");
668
+		}
669
+		else
670
+		{
671
+			if (mDebug)
672
+			{
673
+				printf("Client: Datalink layer recieved: packet seq %i\n", f.seq);
674
+				printf("CLIENT> Msg from %u\n", f.uid);
675
+			}
676
+
677
+			to_network_layer(f.data);
678
+		}
679
+
680
+		if (seq == f.seq)
681
+		{
682
+			if (mDebug)
683
+			{
684
+				printf("Client: Recieved ack %i\n", f.seq);
685
+			}
686
+
687
+			++seq;
688
+		}
689
+	}
690
+
691
+	mKillServer = false;
692
+}
693
+
694
+
695
+////////////////////////////////////////////////////////////
696
+// Private Accessors
697
+////////////////////////////////////////////////////////////
698
+
699
+
700
+////////////////////////////////////////////////////////////
701
+// Private Mutators
702
+////////////////////////////////////////////////////////////
703
+
704
+
705
+
706
+////////////////////////////////////////////////////////////
707
+// Unit Test code
708
+////////////////////////////////////////////////////////////
709
+
710
+#ifdef UNIT_TEST_NETWORK
711
+void from_network_layer(network_packet_t *p, unsigned int *last_id)
712
+{
713
+	static unsigned int i = 0;
714
+
715
+
716
+	if (!p)
717
+	{
718
+		return;
719
+	}
720
+
721
+	*last_id = i++;
722
+
723
+	sleep(1);
724
+
725
+	p->send = 1;
726
+	p->pos[0] = i*3;
727
+	p->pos[1] = i*3+1;
728
+	p->pos[2] = i*3+2;
729
+
730
+	printf("<S>ending { %f %f %f }\n", p->pos[0], p->pos[1], p->pos[2]);
731
+}
732
+
733
+
734
+void to_network_layer(network_packet_t p)
735
+{
736
+	printf("<R>ecieved { %f %f %f }\n", p.pos[0], p.pos[1], p.pos[2]);
737
+
738
+	gPiggyBack.data.pos[0] = gPiggyBack.seq*4;
739
+	gPiggyBack.data.pos[1] = gPiggyBack.seq*4+1;
740
+	gPiggyBack.data.pos[2] = gPiggyBack.seq*4+2;
741
+	gPiggyBack.data.send = 1;
742
+	gPiggyBack.data.yaw = 90.0f;
743
+}
744
+
745
+
746
+int main(int argc, char *argv[])
747
+{
748
+	printf("\n\n[Network class test]\n");
749
+	Network &test = *Network::Instance();
750
+
751
+
752
+	if (argc > 3)
753
+	{
754
+		if (argv[1][1] == 'v')
755
+		{
756
+			test.setDebug(true);
757
+		}
758
+
759
+		switch (argv[1][0])
760
+		{
761
+		case 'c':
762
+			test.setRemoteHost(argv[2]);
763
+			test.setPort(atoi(argv[3]));
764
+			test.runClient();
765
+			break;
766
+		case 's':
767
+			test.setBindHost(argv[2]);
768
+			test.setPort(atoi(argv[3]));
769
+			test.runServer();
770
+			break;
771
+		default:
772
+			printf("Error in command line, run %s for help\n", argv[0]);
773
+		}
774
+	}
775
+	else if (argc > 2)
776
+	{
777
+		test.setPort(atoi(argv[2]));
778
+		test.runServer();
779
+	}
780
+	else
781
+	{
782
+		printf("Server: %s s [bind_host_name] port\n", argv[0]);
783
+		printf("Client: %s c remote_host_name remote_host_port\n", argv[0]);
784
+		printf("Append 'v' behind c/s option for verbose. eg cv\n");
785
+	}
786
+
787
+	killNetworkSingleton();
788
+
789
+	return 0;
790
+}
791
+#endif

+ 329
- 0
src/Network.h 파일 보기

@@ -0,0 +1,329 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : UnRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Network
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: 
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------ 
17
+ *
18
+ * 2002.06.21:
19
+ * Mongoose - Created
20
+ ================================================================*/
21
+
22
+
23
+#ifndef __UNRAIDER_MONGOOSE_NETWORK_H_
24
+#define __UNRAIDER_MONGOOSE_NETWORK_H_
25
+
26
+/*----------------------------------------------
27
+ * The packet holds the data for the network
28
+ *  layer.  This is encapsulated in the frame.
29
+ *
30
+ * data  - a short (32 char) string
31
+ ---------------------------------------------*/
32
+typedef struct network_packet_s
33
+{
34
+	char send;
35
+	unsigned int port;
36
+	unsigned int cid;
37
+	char  data[32];
38
+	float pos[3];
39
+	float pitch;
40
+	float yaw;
41
+	int aframe;
42
+	int bframe;
43
+	int view_model;
44
+
45
+	char gurantee; // TCP like
46
+
47
+} network_packet_t;
48
+
49
+
50
+/*----------------------------------------------
51
+ * The frame holds the data for the datalink
52
+ *  layer.  This goes over the line.
53
+ *
54
+ * header - The header flags
55
+ * seq    - The sequence number
56
+ * data   - The packet for the NL
57
+ ---------------------------------------------*/
58
+typedef struct network_frame_s
59
+{
60
+	unsigned int header;
61
+	unsigned int seq;
62
+	unsigned int uid;
63
+
64
+	network_packet_t data;
65
+
66
+} network_frame_t;
67
+
68
+
69
+void from_network_layer(network_packet_t *p, unsigned int *last_id);
70
+void to_network_layer(network_packet_t p);
71
+
72
+
73
+void killNetworkSingleton();
74
+
75
+#define REMOTE_HOST_STR_SZ 64
76
+#define BIND_HOST_STR_SZ 64
77
+
78
+
79
+class Network
80
+{
81
+ public:
82
+
83
+	////////////////////////////////////////////////////////////
84
+	// Constructors ( Singleton )
85
+	////////////////////////////////////////////////////////////
86
+
87
+	static Network *Instance();
88
+	/*------------------------------------------------------
89
+	 * Pre  : 
90
+	 * Post : Constructs the object of Network or
91
+	 *        returns pointer to it if previously allocated
92
+	 *
93
+	 *-- History ------------------------------------------
94
+	 *
95
+	 * 2001.08.24: 
96
+	 * Mongoose - Created
97
+	 ------------------------------------------------------*/
98
+
99
+	~Network();
100
+	/*------------------------------------------------------
101
+	 * Pre  : Network object is allocated
102
+	 * Post : Deconstructs an object of Network
103
+	 *
104
+	 *-- History ------------------------------------------
105
+	 *
106
+	 * 2002.06.21: 
107
+	 * Mongoose - Created
108
+	 ------------------------------------------------------*/
109
+
110
+	////////////////////////////////////////////////////////////
111
+	// Public Accessors
112
+	////////////////////////////////////////////////////////////
113
+	
114
+	network_frame_t &getPiggyBack();
115
+	/*------------------------------------------------------
116
+	 * Pre  : 
117
+	 * Post : 
118
+	 *
119
+	 *-- History ------------------------------------------
120
+	 *
121
+	 * 2002.09.03:
122
+	 * Mongoose - Created
123
+	 ------------------------------------------------------*/
124
+
125
+	unsigned int getUID();
126
+	/*------------------------------------------------------
127
+	 * Pre  : 
128
+	 * Post : 
129
+	 *
130
+	 *-- History ------------------------------------------
131
+	 *
132
+	 * 2002.09.03:
133
+	 * Mongoose - Created
134
+	 ------------------------------------------------------*/
135
+
136
+	float getRandom(float from, float to);
137
+	/*------------------------------------------------------
138
+	 * Pre  : 
139
+	 * Post : 
140
+	 *
141
+	 *-- History ------------------------------------------
142
+	 *
143
+	 * 2002.09.03:
144
+	 * Mongoose - Created
145
+	 ------------------------------------------------------*/
146
+
147
+	int getPort();
148
+	/*------------------------------------------------------
149
+	 * Pre  : 
150
+	 * Post : 
151
+	 *
152
+	 *-- History ------------------------------------------
153
+	 *
154
+	 * 2002.09.03:
155
+	 * Mongoose - Created
156
+	 ------------------------------------------------------*/
157
+
158
+	////////////////////////////////////////////////////////////
159
+	// Public Mutators
160
+	////////////////////////////////////////////////////////////
161
+
162
+	void setDebug(bool toggle);
163
+	/*------------------------------------------------------
164
+	 * Pre  : 
165
+	 * Post : 
166
+	 *
167
+	 *-- History ------------------------------------------
168
+	 *
169
+	 * 2002.12.15:
170
+	 * Mongoose - Created
171
+	 ------------------------------------------------------*/
172
+
173
+	void setPort(unsigned int port);
174
+	/*------------------------------------------------------
175
+	 * Pre  : 
176
+	 * Post : 
177
+	 *
178
+	 *-- History ------------------------------------------
179
+	 *
180
+	 * 2002.09.03:
181
+	 * Mongoose - Created
182
+	 ------------------------------------------------------*/
183
+
184
+	void setBindHost(char *s);
185
+	/*------------------------------------------------------
186
+	 * Pre  : 
187
+	 * Post : 
188
+	 *
189
+	 *-- History ------------------------------------------
190
+	 *
191
+	 * 2002.09.10:
192
+	 * Mongoose - Created
193
+	 ------------------------------------------------------*/
194
+
195
+	void setRemoteHost(char *s);
196
+	/*------------------------------------------------------
197
+	 * Pre  : 
198
+	 * Post : 
199
+	 *
200
+	 *-- History ------------------------------------------
201
+	 *
202
+	 * 2002.09.03:
203
+	 * Mongoose - Created
204
+	 ------------------------------------------------------*/
205
+
206
+	void killServerThread();
207
+	/*------------------------------------------------------
208
+	 * Pre  : 
209
+	 * Post : 
210
+	 *
211
+	 *-- History ------------------------------------------
212
+	 *
213
+	 * 2002.09.03:
214
+	 * Mongoose - Created
215
+	 ------------------------------------------------------*/
216
+
217
+	void killClientThread();
218
+	/*------------------------------------------------------
219
+	 * Pre  : 
220
+	 * Post : 
221
+	 *
222
+	 *-- History ------------------------------------------
223
+	 *
224
+	 * 2002.09.03:
225
+	 * Mongoose - Created
226
+	 ------------------------------------------------------*/
227
+
228
+	void spawnServerThread();
229
+	/*------------------------------------------------------
230
+	 * Pre  : 
231
+	 * Post : 
232
+	 *
233
+	 *-- History ------------------------------------------
234
+	 *
235
+	 * 2002.09.03:
236
+	 * Mongoose - Created
237
+	 ------------------------------------------------------*/
238
+
239
+	void spawnClientThread();
240
+	/*------------------------------------------------------
241
+	 * Pre  : 
242
+	 * Post : 
243
+	 *
244
+	 *-- History ------------------------------------------
245
+	 *
246
+	 * 2002.09.03:
247
+	 * Mongoose - Created
248
+	 ------------------------------------------------------*/
249
+
250
+	int runServer();
251
+	/*------------------------------------------------------
252
+	 * Pre  : 
253
+	 * Post : 
254
+	 *
255
+	 *-- History ------------------------------------------
256
+	 *
257
+	 * 2002.09.03:
258
+	 * Mongoose - Created
259
+	 ------------------------------------------------------*/
260
+
261
+	void runClient();
262
+	/*------------------------------------------------------
263
+	 * Pre  : 
264
+	 * Post : 
265
+	 *
266
+	 *-- History ------------------------------------------
267
+	 *
268
+	 * 2002.09.03:
269
+	 * Mongoose - Created
270
+	 ------------------------------------------------------*/
271
+
272
+ protected:
273
+
274
+	////////////////////////////////////////////////////////////
275
+	// Constructors ( Singleton )
276
+	////////////////////////////////////////////////////////////
277
+
278
+	Network();
279
+	/*------------------------------------------------------
280
+	 * Pre  : 
281
+	 * Post : Constructs an object of Network
282
+	 *
283
+	 *-- History ------------------------------------------
284
+	 *
285
+	 * 2002.06.21: 
286
+	 * Mongoose - Created
287
+	 ------------------------------------------------------*/
288
+
289
+
290
+	////////////////////////////////////////////////////////////
291
+	// Protected Mutators
292
+	////////////////////////////////////////////////////////////
293
+
294
+ private:
295
+
296
+	////////////////////////////////////////////////////////////
297
+	// Private Accessors
298
+	////////////////////////////////////////////////////////////
299
+
300
+
301
+	////////////////////////////////////////////////////////////
302
+	// Private Mutators
303
+	////////////////////////////////////////////////////////////
304
+
305
+
306
+	static Network *mInstance;      /* Singleton use */
307
+
308
+	bool mSpawnedClient;
309
+
310
+	bool mSpawnedServer;
311
+
312
+	int mPort;
313
+
314
+	char mRemoteHost[REMOTE_HOST_STR_SZ];
315
+
316
+	char mBindHost[BIND_HOST_STR_SZ];
317
+
318
+	bool mPiggyBack;
319
+
320
+	bool mNetworkReliable;
321
+
322
+	bool mKillClient;
323
+
324
+	bool mKillServer;
325
+
326
+	bool mDebug;
327
+};
328
+
329
+#endif

+ 652
- 0
src/OpenGLMesh.cpp 파일 보기

@@ -0,0 +1,652 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : OpenRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : OpenGLMesh
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: 
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2002.08.23:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#include <GL/gl.h>
23
+#include "OpenGLMesh.h"
24
+
25
+
26
+////////////////////////////////////////////////////////////
27
+// Constructors
28
+////////////////////////////////////////////////////////////
29
+
30
+OpenGLMesh::OpenGLMesh()
31
+{
32
+	mNumVertices = 0;
33
+	mVertices = 0x0;
34
+
35
+	mNumNormals = 0;
36
+	mNormals = 0x0;
37
+
38
+	mNumColors = 0;
39
+	mColors = 0x0;
40
+
41
+	mNumTris = 0;
42
+	mTris = 0x0;
43
+
44
+	mNumQuads = 0;
45
+	mQuads = 0x0;
46
+
47
+	mVertexArray = 0x0;
48
+	mNormalArray = 0x0;
49
+	mColorArray = 0x0;
50
+
51
+	mTriangleCount = 0;
52
+	mTriangleTextures = 0x0;
53
+	mTriangleIndices = 0x0;
54
+	mTriangleFlags = 0x0;
55
+	mTriangleTexCoordArray = 0x0;
56
+
57
+	mFlags = 0;
58
+	mMode = OpenGLMeshModeTexture;
59
+}
60
+
61
+
62
+OpenGLMesh::~OpenGLMesh()
63
+{
64
+	unsigned int i;
65
+
66
+
67
+	if (mVertices)
68
+	{
69
+		delete [] mVertices;
70
+	}
71
+	
72
+	if (mNormals)
73
+	{
74
+		delete [] mNormals;
75
+	}
76
+	
77
+	if (mColors)
78
+	{
79
+		delete [] mColors;
80
+	}
81
+
82
+	if (mTris)
83
+	{
84
+		for (i = 0; i < mNumTris; ++i)
85
+		{
86
+			if (mTris[i].triangles)
87
+				delete [] mTris[i].triangles;
88
+
89
+			if (mTris[i].alpha_triangles)
90
+				delete [] mTris[i].alpha_triangles;
91
+
92
+			if (mTris[i].texcoors)
93
+				delete [] mTris[i].texcoors;
94
+
95
+			if (mTris[i].texcoors2)
96
+				delete [] mTris[i].texcoors2;
97
+		}
98
+
99
+		delete [] mTris;
100
+	}
101
+	
102
+	if (mQuads)
103
+	{	
104
+		for (i = 0; i < mNumQuads; ++i)
105
+		{
106
+			if (mQuads[i].quads)
107
+				delete [] mQuads[i].quads;
108
+
109
+			if (mQuads[i].alpha_quads)
110
+				delete [] mQuads[i].alpha_quads;
111
+
112
+			if (mQuads[i].texcoors)
113
+				delete [] mQuads[i].texcoors;
114
+
115
+			if (mQuads[i].texcoors2)
116
+				delete [] mQuads[i].texcoors2;
117
+		}
118
+
119
+		delete [] mQuads;
120
+	}
121
+
122
+	if (mVertexArray)
123
+	{
124
+		delete [] mVertexArray;
125
+	}
126
+
127
+	if (mNormalArray)
128
+	{
129
+		delete [] mNormalArray;
130
+	}
131
+
132
+	if (mColorArray)
133
+	{
134
+		delete [] mColorArray;
135
+	}
136
+
137
+	if (mTriangleTextures)
138
+	{
139
+		delete [] mTriangleTextures;
140
+	}
141
+
142
+	if (mTriangleIndices)
143
+	{
144
+		delete [] mTriangleIndices;
145
+	}
146
+
147
+	if (mTriangleFlags)
148
+	{
149
+		delete [] mTriangleFlags;
150
+	}
151
+
152
+	if (mTriangleTexCoordArray)
153
+	{
154
+		delete [] mTriangleTexCoordArray;
155
+	}
156
+}
157
+
158
+
159
+////////////////////////////////////////////////////////////
160
+// Public Accessors
161
+////////////////////////////////////////////////////////////
162
+
163
+void OpenGLMesh::drawAlpha()
164
+{
165
+	unsigned int i, j, k, index;
166
+
167
+
168
+	// Render quadralaterals
169
+	for (mQuads ? i = 0 : i = mNumQuads; i < mNumQuads; ++i)
170
+	{
171
+		switch (mMode)
172
+		{
173
+		case OpenGLMeshModeWireframe:
174
+			glColor3f(0.0, 0.0, 1.0);
175
+		case OpenGLMeshModeSolid:
176
+			// Bind WHITE texture for solid colors
177
+			glBindTexture(GL_TEXTURE_2D, 0);
178
+			break;
179
+		default:
180
+			// Bind texture id for textures
181
+			glBindTexture(GL_TEXTURE_2D, mQuads[i].texture+1);
182
+		}
183
+
184
+		glBegin(GL_QUADS);
185
+
186
+		for (j = 0; j < mQuads[i].num_alpha_quads; ++j) 
187
+		{
188
+			for (k = 0; k < 4; ++k)
189
+			{							
190
+				index = mQuads[i].alpha_quads[j*4+k];
191
+				
192
+				glTexCoord2fv(mQuads[i].texcoors2[j*4+k]);
193
+				glColor4fv(mColors[index]);
194
+				glVertex3fv(mVertices[index]);
195
+			}
196
+		}
197
+
198
+		glEnd();
199
+	}
200
+
201
+	// Render triangles
202
+	for (mTris ? i = 0 : i = mNumTris; i < mNumTris; ++i)
203
+	{
204
+		switch (mMode)
205
+		{
206
+		case OpenGLMeshModeWireframe:
207
+			glColor3f(0.0, 1.0, 0.0);
208
+		case OpenGLMeshModeSolid:
209
+			// Bind WHITE texture for solid colors
210
+			glBindTexture(GL_TEXTURE_2D, 0);
211
+			break;
212
+		default:
213
+			// Bind texture id for textures
214
+			glBindTexture(GL_TEXTURE_2D, mTris[i].texture+1);
215
+		}
216
+
217
+		glBegin(GL_TRIANGLES);
218
+
219
+		for (j = 0; j < mTris[i].num_alpha_triangles; ++j) 
220
+		{
221
+			for (k = 0; k < 3; ++k)
222
+			{
223
+				index = mTris[i].alpha_triangles[j*3+k];
224
+				
225
+				glTexCoord2fv(mTris[i].texcoors2[j*3+k]);
226
+				glColor4fv(mColors[index]);
227
+				glVertex3fv(mVertices[index]);
228
+			}
229
+		}
230
+
231
+		glEnd();
232
+	}
233
+}
234
+
235
+
236
+void OpenGLMesh::drawSolid()
237
+{
238
+	unsigned int i, j, k, index;
239
+
240
+
241
+	if (mFlags & fOpenGLMesh_UseVertexArray)
242
+	{
243
+		//glEnableClientState(GL_VERTEX_ARRAY);
244
+		//glVertexPointer(3, GL_FLOAT, 0, mVertexArray);
245
+
246
+		glPointSize(2.0f);
247
+		glColor3f(1.0f, 1.0f, 1.0f);
248
+		glBegin(GL_TRIANGLES);
249
+
250
+		for (i = 0; i < mTriangleCount*3; ++i)
251
+		{
252
+			//glArrayElement(mTriangleIndices[i]);
253
+			glVertex3fv(mVertexArray+mTriangleIndices[i]);
254
+		}
255
+
256
+		glEnd();
257
+
258
+		glPointSize(1.0f);
259
+
260
+		return; // FIXME
261
+
262
+		for (j = 0; j < mQuads[i].num_quads; ++j) 
263
+		{
264
+			for (k = 0; k < 4; ++k)
265
+			{							
266
+				index = mQuads[i].quads[j*4+k];
267
+				
268
+				glTexCoord2fv(mQuads[i].texcoors[j*4+k]);
269
+				glArrayElement(mQuads[i].quads[j*4+k]);
270
+			}
271
+		}
272
+
273
+		return;
274
+	}
275
+
276
+	// Render quadralaterals
277
+	for (mQuads ? i = 0 : i = mNumQuads; i < mNumQuads; ++i)
278
+	{
279
+		switch (mMode)
280
+		{
281
+		case OpenGLMeshModeSolid:
282
+			glColor3f(0.0, 0.0, 0.0);
283
+			break;
284
+		case OpenGLMeshModeWireframe:
285
+			// Bind WHITE texture for solid colors
286
+			glBindTexture(GL_TEXTURE_2D, 0);
287
+			break;
288
+#ifdef MULTITEXTURE
289
+		case OpenGLMeshModeMultiTexture:
290
+			glActiveTextureARB(GL_TEXTURE0_ARB);
291
+			glEnable(GL_TEXTURE_2D);
292
+			glBindTexture(GL_TEXTURE_2D, mQuads[i].texture+1);
293
+
294
+			glActiveTextureARB(GL_TEXTURE1_ARB);
295
+			glEnable(GL_TEXTURE_2D);
296
+			glBindTexture(GL_TEXTURE_2D, mQuads[i].bumpmap+1);
297
+			break;
298
+#endif
299
+		default:
300
+			// Bind texture id for textures
301
+			glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
302
+			glBindTexture(GL_TEXTURE_2D, mQuads[i].texture+1);
303
+		}
304
+
305
+		glBegin(GL_QUADS);
306
+
307
+		for (j = 0; j < mQuads[i].num_quads; ++j) 
308
+		{
309
+			for (k = 0; k < 4; ++k)
310
+			{							
311
+				index = mQuads[i].quads[j*4+k];
312
+					
313
+				glColor4fv(mColors[index]);
314
+
315
+#ifdef MULTITEXTURE
316
+				if (mMode == OpenGLMeshModeMultiTexture)
317
+				{
318
+					glMultiTexCoord2fvARB(GL_TEXTURE0_ARB, 
319
+												 mQuads[i].texcoors[j*4+k]);
320
+					glMultiTexCoord2fvARB(GL_TEXTURE1_ARB, 
321
+												 mQuads[i].texcoors[j*4+k]);
322
+				}
323
+				else
324
+#endif
325
+					glTexCoord2fv(mQuads[i].texcoors[j*4+k]);
326
+
327
+				glVertex3fv(mVertices[index]);
328
+			}
329
+		}
330
+
331
+		glEnd();
332
+	}
333
+
334
+	// Render triangles
335
+	for (mTris ? i = 0 : i = mNumTris; i < mNumTris; ++i)
336
+	{
337
+		switch (mMode)
338
+		{
339
+		case OpenGLMeshModeSolid:
340
+			glColor3f(1.0, 0.0, 0.0);
341
+			break;
342
+		case OpenGLMeshModeWireframe:
343
+			// Bind WHITE texture for solid colors
344
+			glBindTexture(GL_TEXTURE_2D, 0);
345
+			break;
346
+#ifdef MULTITEXTURE
347
+		case OpenGLMeshModeMultiTexture:
348
+			glActiveTextureARB(GL_TEXTURE0_ARB);
349
+			glEnable(GL_TEXTURE_2D);
350
+			glBindTexture(GL_TEXTURE_2D, mTris[i].texture+1);
351
+
352
+			glActiveTextureARB(GL_TEXTURE1_ARB);
353
+			glEnable(GL_TEXTURE_2D);
354
+			glBindTexture(GL_TEXTURE_2D, mTris[i].bumpmap+1);
355
+			break;
356
+#endif
357
+		default:
358
+			// Bind texture id for textures
359
+			glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
360
+			glBindTexture(GL_TEXTURE_2D, mTris[i].texture+1);
361
+		}
362
+
363
+		glBegin(GL_TRIANGLES);
364
+
365
+		for (j = 0; j < mTris[i].num_triangles; ++j) 
366
+		{
367
+			for (k = 0; k < 3; ++k)
368
+			{
369
+				index = mTris[i].triangles[j*3+k];
370
+
371
+#ifdef MULTITEXTURE
372
+				if (mMode == OpenGLMeshModeMultiTexture)
373
+				{
374
+					glMultiTexCoord2fvARB(GL_TEXTURE0_ARB, 
375
+												 mTris[i].texcoors[j*3+k]);
376
+					glMultiTexCoord2fvARB(GL_TEXTURE1_ARB, 
377
+												 mTris[i].texcoors[j*3+k]);
378
+				}
379
+				else
380
+#endif
381
+					glTexCoord2fv(mTris[i].texcoors[j*3+k]);
382
+
383
+				glColor4fv(mColors[index]);
384
+				glVertex3fv(mVertices[index]);
385
+			}
386
+		}
387
+
388
+		glEnd();
389
+	}
390
+
391
+#ifdef MULTITEXTURE
392
+	if (mMode == OpenGLMeshModeMultiTexture)
393
+	{
394
+		glDisable(GL_TEXTURE_2D);
395
+		glActiveTextureARB(GL_TEXTURE0_ARB);
396
+	}
397
+#endif
398
+}
399
+
400
+
401
+////////////////////////////////////////////////////////////
402
+// Public Mutators
403
+////////////////////////////////////////////////////////////
404
+
405
+void OpenGLMesh::allocateColors(unsigned int n)
406
+{
407
+	if (mColors)
408
+	{
409
+		mNumColors = 0;
410
+		delete [] mColors;
411
+	}
412
+
413
+	if (!n)
414
+	{
415
+		return;
416
+	}
417
+
418
+	mNumColors = n;
419
+	mColors = new vec4_t[mNumColors];
420
+}
421
+
422
+
423
+void OpenGLMesh::allocateNormals(unsigned int n)
424
+{
425
+	if (mNormals)
426
+	{
427
+		mNumNormals = 0;
428
+		delete [] mNormals;
429
+	}
430
+
431
+	if (!n)
432
+	{
433
+		return;
434
+	}
435
+
436
+	mNumNormals = n;
437
+	mNormals = new vec3_t[mNumNormals];
438
+}
439
+
440
+
441
+void OpenGLMesh::allocateRectangles(unsigned int n)
442
+{
443
+	if (mQuads)
444
+	{
445
+		mNumQuads = 0;
446
+		delete [] mQuads;
447
+	}
448
+
449
+	if (!n)
450
+	{
451
+		return;
452
+	}
453
+
454
+	mNumQuads = n;
455
+	mQuads = new rect_t[mNumQuads];
456
+}
457
+
458
+
459
+void OpenGLMesh::allocateTriangles(unsigned int n)
460
+{
461
+	if (mTris)
462
+	{
463
+		mNumTris = 0;
464
+		delete [] mTris;
465
+	}
466
+
467
+	if (!n)
468
+	{
469
+		return;
470
+	}
471
+
472
+	mNumTris = n;
473
+	mTris = new tris_t[mNumTris];
474
+}
475
+
476
+
477
+void OpenGLMesh::allocateVertices(unsigned int n)
478
+{
479
+	if (mVertices)
480
+	{
481
+		mNumVertices = 0;
482
+		delete [] mVertices;
483
+	}
484
+
485
+	if (!n)
486
+	{
487
+		return;
488
+	}
489
+
490
+	mNumVertices = n;
491
+	mVertices = new vec3_t[mNumVertices];
492
+}
493
+
494
+
495
+void OpenGLMesh::bufferColorArray(unsigned int colorCount, vec_t *colors,
496
+											 unsigned int colorWidth)
497
+{
498
+	if (mColors)
499
+	{
500
+		mNumColors = 0;
501
+		delete [] mColors;
502
+	}
503
+	
504
+	if (!colorCount)
505
+	{
506
+		return;
507
+	}
508
+	
509
+		//mColorWidth = colorWidth;  // for now assume 4 always
510
+	mNumColors = colorCount;
511
+	mColorArray = colors; 
512
+}
513
+
514
+
515
+void OpenGLMesh::bufferNormalArray(unsigned int normalCount, vec_t *normals)
516
+{
517
+	if (mNormals)
518
+	{
519
+		mNumNormals = 0;
520
+		delete [] mNormals;
521
+	}
522
+	
523
+	if (!normalCount)
524
+	{
525
+		return;
526
+	}
527
+	
528
+	mNumNormals = normalCount;
529
+	mNormalArray = normals;
530
+}
531
+
532
+
533
+void OpenGLMesh::bufferTriangles(unsigned int count, 
534
+											unsigned int *indices, vec_t *texCoords, 
535
+											int *textures, unsigned int *flags)
536
+{
537
+	
538
+	mTriangleCount = count;
539
+	mTriangleTextures = textures;
540
+	mTriangleIndices = indices;
541
+	mTriangleFlags = flags;
542
+	mTriangleTexCoordArray = texCoords;
543
+
544
+	// FIXME: sortTrianglesByTexture();
545
+}
546
+
547
+
548
+void OpenGLMesh::bufferVertexArray(unsigned int vertexCount, vec_t *vertices)
549
+{
550
+	if (mVertices)
551
+	{
552
+		mNumVertices = 0;
553
+		delete [] mVertices;
554
+	}
555
+	
556
+	if (!vertexCount)
557
+	{
558
+		return;
559
+	}
560
+	
561
+	mNumVertices = vertexCount;
562
+	mVertexArray = vertices; 
563
+	mFlags |= fOpenGLMesh_UseVertexArray;
564
+}
565
+
566
+
567
+void OpenGLMesh::setColor(unsigned int index, 
568
+								  float r, float g, float b, float a)
569
+{
570
+	if (index > mNumColors)
571
+	{
572
+		return;
573
+	}
574
+	
575
+	mColors[index][0] = r;
576
+	mColors[index][1] = g;
577
+	mColors[index][2] = b;
578
+		mColors[index][3] = a;
579
+}
580
+
581
+
582
+void OpenGLMesh::setColor(unsigned int index, float rgba[4])
583
+{
584
+	if (index > mNumColors)
585
+	{
586
+		return;
587
+	}
588
+	
589
+	mColors[index][0] = rgba[0];
590
+	mColors[index][1] = rgba[1];
591
+	mColors[index][2] = rgba[2];
592
+	mColors[index][3] = rgba[3];
593
+}
594
+
595
+
596
+void OpenGLMesh::setNormal(unsigned int index, float i, float j, float k)
597
+{
598
+	if (index > mNumNormals)
599
+	{
600
+		return;
601
+	}
602
+	
603
+	mNormals[index][0] = i;
604
+	mNormals[index][1] = j;
605
+	mNormals[index][2] = k;
606
+}
607
+
608
+
609
+void OpenGLMesh::setVertex(unsigned int index, float x, float y, float z)
610
+{
611
+	if (index > mNumVertices)
612
+	{
613
+		return;
614
+	}
615
+	
616
+	mVertices[index][0] = x;
617
+	mVertices[index][1] = y;
618
+	mVertices[index][2] = z;
619
+}
620
+
621
+
622
+////////////////////////////////////////////////////////////
623
+// Private Accessors
624
+////////////////////////////////////////////////////////////
625
+
626
+
627
+////////////////////////////////////////////////////////////
628
+// Private Mutators
629
+////////////////////////////////////////////////////////////
630
+
631
+
632
+////////////////////////////////////////////////////////////
633
+// Unit Test code
634
+////////////////////////////////////////////////////////////
635
+
636
+#ifdef UNIT_TEST_OPENGLMESH
637
+int runOpenGLMeshUnitTest(int argc, char *argv[])
638
+{
639
+	return 0;
640
+}
641
+
642
+
643
+int main(int argc, char *argv[])
644
+{
645
+	OpenGLMesh test;
646
+
647
+
648
+	printf("[OpenGLMesh class test]\n");
649
+
650
+	return runOpenGLMeshUnitTest(argc, argv);
651
+}
652
+#endif

+ 420
- 0
src/OpenGLMesh.h 파일 보기

@@ -0,0 +1,420 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : OpenRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : OpenGLMesh
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: 
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- Test Defines -----------------------------------------------
17
+ *           
18
+ * UNIT_TEST_OPENGLMESH - Builds OpenGLMesh class as a console unit test 
19
+ *
20
+ *-- History ------------------------------------------------ 
21
+ *
22
+ * 2002.08.23:
23
+ * Mongoose - Created
24
+ ================================================================*/
25
+
26
+
27
+#ifndef GUARD__OPENRAIDER_MONGOOSE_OPENGLMESH_H_
28
+#define GUARD__OPENRAIDER_MONGOOSE_OPENGLMESH_H_
29
+
30
+#include <hel/math.h>
31
+
32
+// TODO: Unify the parallel systems here, arrays and the allocate/set
33
+
34
+
35
+typedef enum
36
+{
37
+	OpenGLMeshModeSolid          = 0,
38
+	OpenGLMeshModeWireframe      = 1,
39
+	OpenGLMeshModeTexture        = 2,	
40
+	OpenGLMeshModeMultiTexture   = 3
41
+
42
+} OpenGLMeshMode;
43
+
44
+enum OpenGLMeshFlags
45
+{
46
+	fOpenGLMesh_Transparent      = 1,
47
+	fOpenGLMesh_BumpMap          = 2,
48
+	fOpenGLMesh_UseVertexArray   = 4
49
+};
50
+
51
+
52
+typedef struct tris_s
53
+{
54
+	int texture;
55
+#ifdef MULTITEXTURE
56
+	int bumpmap;
57
+#endif
58
+
59
+	unsigned int cnum_triangles;
60
+	unsigned int cnum_alpha_triangles;
61
+
62
+	unsigned int num_texcoors;
63
+	vec2_t *texcoors; 
64
+
65
+	unsigned int num_texcoors2;
66
+	vec2_t *texcoors2; 
67
+
68
+	// Arrays of triangle indices sorted by texture
69
+	unsigned int num_triangles;
70
+	unsigned int *triangles; // ABCABCABC...
71
+
72
+	// Arrays of alpha triangle indices sorted by texture
73
+	unsigned int num_alpha_triangles;
74
+	unsigned int *alpha_triangles; // ABCABCABC... 
75
+
76
+} tris_t;
77
+
78
+
79
+typedef struct rect_s
80
+{
81
+	int texture;
82
+#ifdef MULTITEXTURE
83
+	int bumpmap;
84
+#endif
85
+
86
+	unsigned int cnum_quads;
87
+	unsigned int cnum_alpha_quads;
88
+
89
+	unsigned int num_texcoors;
90
+	vec2_t *texcoors; 
91
+
92
+	unsigned int num_texcoors2;
93
+	vec2_t *texcoors2; 
94
+
95
+	// Arrays of rectangle indices sorted by texture
96
+	unsigned int num_quads;
97
+	unsigned int *quads; // ABCDABCDABCD...
98
+
99
+	// Arrays of alpha rectangle indices sorted by texture
100
+	unsigned int num_alpha_quads;
101
+	unsigned int *alpha_quads; // ABCDABCDABCD...
102
+
103
+} rect_t;
104
+
105
+
106
+class OpenGLMesh
107
+{
108
+ public:
109
+
110
+	////////////////////////////////////////////////////////////
111
+	// Constructors
112
+	////////////////////////////////////////////////////////////
113
+
114
+	OpenGLMesh();
115
+	/*------------------------------------------------------
116
+	 * Pre  : 
117
+	 * Post : Constructs an object of OpenGLMesh
118
+	 *
119
+	 *-- History ------------------------------------------
120
+	 *
121
+	 * 2002.08.23: 
122
+	 * Mongoose - Created
123
+	 ------------------------------------------------------*/
124
+
125
+	~OpenGLMesh();
126
+	/*------------------------------------------------------
127
+	 * Pre  : OpenGLMesh object is allocated
128
+	 * Post : Deconstructs an object of OpenGLMesh
129
+	 *
130
+	 *-- History ------------------------------------------
131
+	 *
132
+	 * 2002.08.23: 
133
+	 * Mongoose - Created
134
+	 ------------------------------------------------------*/
135
+
136
+
137
+	////////////////////////////////////////////////////////////
138
+	// Public Accessors
139
+	////////////////////////////////////////////////////////////
140
+
141
+	void drawAlpha();
142
+	/*------------------------------------------------------
143
+	 * Pre  : 
144
+	 * Post : Render alpha polygons
145
+	 *
146
+	 *-- History ------------------------------------------
147
+	 *
148
+	 * 2002.08.23:
149
+	 * Mongoose - Created
150
+	 ------------------------------------------------------*/
151
+
152
+	void drawSolid();
153
+	/*------------------------------------------------------
154
+	 * Pre  : 
155
+	 * Post : Render solid polygons
156
+	 *
157
+	 *-- History ------------------------------------------
158
+	 *
159
+	 * 2002.08.23:
160
+	 * Mongoose - Created
161
+	 ------------------------------------------------------*/
162
+
163
+
164
+	////////////////////////////////////////////////////////////
165
+	// Public Mutators
166
+	////////////////////////////////////////////////////////////
167
+
168
+	void allocateColors(unsigned int n);
169
+	/*------------------------------------------------------
170
+	 * Pre  : 
171
+	 * Post : 
172
+	 *
173
+	 *-- History ------------------------------------------
174
+	 *
175
+	 * 2002.08.23:
176
+	 * Mongoose - Created
177
+	 ------------------------------------------------------*/
178
+
179
+	void allocateNormals(unsigned int n);
180
+	/*------------------------------------------------------
181
+	 * Pre  : 
182
+	 * Post : 
183
+	 *
184
+	 *-- History ------------------------------------------
185
+	 *
186
+	 * 2002.08.23:
187
+	 * Mongoose - Created
188
+	 ------------------------------------------------------*/
189
+
190
+	void allocateRectangles(unsigned int n);
191
+	/*------------------------------------------------------
192
+	 * Pre  : 
193
+	 * Post : 
194
+	 *
195
+	 *-- History ------------------------------------------
196
+	 *
197
+	 * 2002.08.23:
198
+	 * Mongoose - Created
199
+	 ------------------------------------------------------*/
200
+
201
+	void allocateTriangles(unsigned int n);
202
+	/*------------------------------------------------------
203
+	 * Pre  : 
204
+	 * Post : 
205
+	 *
206
+	 *-- History ------------------------------------------
207
+	 *
208
+	 * 2002.08.23:
209
+	 * Mongoose - Created
210
+	 ------------------------------------------------------*/
211
+
212
+	void allocateVertices(unsigned int n);
213
+	/*------------------------------------------------------
214
+	 * Pre  : 
215
+	 * Post : 
216
+	 *
217
+	 *-- History ------------------------------------------
218
+	 *
219
+	 * 2002.08.23:
220
+	 * Mongoose - Created
221
+	 ------------------------------------------------------*/
222
+
223
+	void bufferColorArray(unsigned int colorCount, vec_t *colors,
224
+								 unsigned int colorWidth);
225
+	/*------------------------------------------------------
226
+	 * Pre  : 
227
+	 * Post : 
228
+	 *
229
+	 *-- History ------------------------------------------
230
+	 *
231
+	 * 2003.05.20:
232
+	 * Mongoose - Created
233
+	 ------------------------------------------------------*/
234
+
235
+	void bufferNormalArray(unsigned int normalCount, vec_t *normals);
236
+	/*------------------------------------------------------
237
+	 * Pre  : 
238
+	 * Post : 
239
+	 *
240
+	 *-- History ------------------------------------------
241
+	 *
242
+	 * 2003.05.20:
243
+	 * Mongoose - Created
244
+	 ------------------------------------------------------*/
245
+
246
+	void bufferTriangles(unsigned int count, 
247
+								unsigned int *indices, vec_t *texCoords, 
248
+								int *textures, unsigned int *flags);
249
+	/*------------------------------------------------------
250
+	 * Pre  : 
251
+	 * Post : 
252
+	 *
253
+	 *-- History ------------------------------------------
254
+	 *
255
+	 * 2003.05.26:
256
+	 * Mongoose - Created
257
+	 ------------------------------------------------------*/
258
+
259
+	void bufferVertexArray(unsigned int vertexCount, vec_t *vertices);
260
+	/*------------------------------------------------------
261
+	 * Pre  : 
262
+	 * Post : 
263
+	 *
264
+	 *-- History ------------------------------------------
265
+	 *
266
+	 * 2003.05.20:
267
+	 * Mongoose - Created
268
+	 ------------------------------------------------------*/
269
+
270
+	void setColor(unsigned int index, float r, float g, float b, float a);
271
+	/*------------------------------------------------------
272
+	 * Pre  : 
273
+	 * Post : 
274
+	 *
275
+	 *-- History ------------------------------------------
276
+	 *
277
+	 * 2002.08.23:
278
+	 * Mongoose - Created
279
+	 ------------------------------------------------------*/
280
+
281
+	void setColor(unsigned int index, float rgba[4]);
282
+	/*------------------------------------------------------
283
+	 * Pre  : 
284
+	 * Post : 
285
+	 *
286
+	 *-- History ------------------------------------------
287
+	 *
288
+	 * 2002.08.23:
289
+	 * Mongoose - Created
290
+	 ------------------------------------------------------*/
291
+
292
+	void setNormal(unsigned int index, float i, float j, float k);
293
+	/*------------------------------------------------------
294
+	 * Pre  : 
295
+	 * Post : 
296
+	 *
297
+	 *-- History ------------------------------------------
298
+	 *
299
+	 * 2002.08.23:
300
+	 * Mongoose - Created
301
+	 ------------------------------------------------------*/
302
+
303
+	void setVertex(unsigned int index, float x, float y, float z);
304
+	/*------------------------------------------------------
305
+	 * Pre  : 
306
+	 * Post : 
307
+	 *
308
+	 *-- History ------------------------------------------
309
+	 *
310
+	 * 2002.08.23:
311
+	 * Mongoose - Created
312
+	 ------------------------------------------------------*/
313
+
314
+#ifdef NOT_IMPLEMENTED
315
+	void sortFacesByTexture();
316
+	/*------------------------------------------------------
317
+	 * Pre  : 
318
+	 * Post : 
319
+	 *
320
+	 *-- History ------------------------------------------
321
+	 *
322
+	 * 2003.05.26:
323
+	 * Mongoose - Created
324
+	 ------------------------------------------------------*/
325
+
326
+	void addFace(int textureIndex, int textureIndexB, unsigned int flags,
327
+					 unsigned int vertexIndexCount, vec_t *vertexIndices);
328
+	/*------------------------------------------------------
329
+	 * Pre  : 
330
+	 * Post : 
331
+	 *
332
+	 *-- History ------------------------------------------
333
+	 *
334
+	 * 2003.05.26:
335
+	 * Mongoose - Created
336
+	 ------------------------------------------------------*/
337
+
338
+	void addTexTiledFace(int textureIndex, int textureIndexB, 
339
+								unsigned int flags, unsigned int indexCount, 
340
+								vec_t *vertexIndices, vec_t *texcoords);
341
+	/*------------------------------------------------------
342
+	 * Pre  : 
343
+	 * Post : 
344
+	 *
345
+	 *-- History ------------------------------------------
346
+	 *
347
+	 * 2003.05.26:
348
+	 * Mongoose - Created
349
+	 ------------------------------------------------------*/
350
+
351
+	void bufferTexcoords(unsigned int texcoordCount, vec_t *texcoords);
352
+	/*------------------------------------------------------
353
+	 * Pre  : 
354
+	 * Post : 
355
+	 *
356
+	 *-- History ------------------------------------------
357
+	 *
358
+	 * 2003.05.26:
359
+	 * Mongoose - Created
360
+	 ------------------------------------------------------*/
361
+
362
+	void duplicateArraysForTexTiledTexcoords();
363
+	/*------------------------------------------------------
364
+	 * Pre  : 
365
+	 * Post : 
366
+	 *
367
+	 *-- History ------------------------------------------
368
+	 *
369
+	 * 2003.05.26:
370
+	 * Mongoose - Created
371
+	 ------------------------------------------------------*/
372
+#endif
373
+
374
+
375
+	unsigned int mFlags;
376
+
377
+	OpenGLMeshMode mMode;
378
+
379
+	unsigned int mNumVertices;
380
+	vec3_t *mVertices;  // <XYZ>
381
+
382
+	unsigned int mNumNormals;
383
+	vec3_t *mNormals;   // <IJK>
384
+
385
+	unsigned int mNumColors;
386
+	vec4_t *mColors;    // <RGBA>
387
+
388
+	unsigned int mNumTris;
389
+	tris_t *mTris;
390
+
391
+	unsigned int mNumQuads;
392
+	rect_t *mQuads;
393
+
394
+	
395
+	unsigned int mTriangleCount;
396
+	int *mTriangleTextures;
397
+	unsigned int *mTriangleIndices;
398
+	unsigned int *mTriangleFlags;
399
+	vec_t *mTriangleTexCoordArray;
400
+
401
+	vec_t *mVertexArray;
402
+	vec_t *mNormalArray;
403
+	vec_t *mColorArray;
404
+
405
+ private:
406
+
407
+	////////////////////////////////////////////////////////////
408
+	// Private Accessors
409
+	////////////////////////////////////////////////////////////
410
+
411
+
412
+	////////////////////////////////////////////////////////////
413
+	// Private Mutators
414
+	////////////////////////////////////////////////////////////
415
+
416
+
417
+	/* */
418
+};
419
+
420
+#endif

+ 3593
- 0
src/OpenRaider.cpp
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 473
- 0
src/OpenRaider.h 파일 보기

@@ -0,0 +1,473 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : OpenRaider
5
+ * Author  : Mongoose
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : OpenRaider
9
+ * License : No use w/o permission (C) 2001 Mongoose
10
+ * Comments: This is the main class for OpenRaider
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------ 
17
+ *
18
+ * 2002.08.24:
19
+ * Mongoose - Finally made into Singleton
20
+ *
21
+ * 2001.05.21:
22
+ * Mongoose - Created
23
+ ================================================================*/
24
+
25
+
26
+#ifndef GUARD__OPENRAIDER_MONGOOSE_OPENRAIDER_H_
27
+#define GUARD__OPENRAIDER_MONGOOSE_OPENRAIDER_H_
28
+
29
+
30
+#include <mstl/List.h>
31
+#include <mstl/Map.h>
32
+#include <mstl/Vector.h>
33
+#include "TombRaider.h"
34
+#include "Camera.h"
35
+#include "Render.h"
36
+#include "Sound.h"
37
+#include "SDLSystem.h"
38
+#include "Network.h"
39
+#include "World.h"
40
+
41
+
42
+typedef enum
43
+{
44
+	OpenRaiderKey_console = 1, // Reserved 0 event for console in System
45
+	OpenRaiderKey_attack,
46
+	OpenRaiderKey_forward,
47
+	OpenRaiderKey_left,
48
+	OpenRaiderKey_right,
49
+	OpenRaiderKey_backward,
50
+	OpenRaiderKey_jump,
51
+	OpenRaiderKey_tiltUp,
52
+	OpenRaiderKey_tiltDown,
53
+	OpenRaiderKey_panLeft,
54
+	OpenRaiderKey_panRight,
55
+	OpenRaiderKey_crouch
56
+
57
+} OpenRaider_KeyEvent;
58
+
59
+
60
+typedef enum
61
+{
62
+	OpenRaider_ShowFPS      =   1,
63
+	OpenRaider_DebugMap     =   2,
64
+	OpenRaider_DebugModel   =   4,
65
+	OpenRaider_EnableSound  =   8,
66
+	OpenRaider_DumpTexture  =  16,
67
+	OpenRaider_FullScreen   =  32,
68
+	OpenRaider_Loading      =  64,
69
+	OpenRaider_GameRunning  = 128,
70
+
71
+} OpenRaiderFlags;
72
+
73
+typedef enum
74
+{
75
+	OpenRaiderSound_Ambient = 1
76
+
77
+} OpenRaider_SoundEventType;
78
+
79
+
80
+class OpenRaider : public SDLSystem
81
+{
82
+ public:
83
+
84
+	////////////////////////////////////////////////////////////
85
+	// Constructors ( Singleton )
86
+	////////////////////////////////////////////////////////////
87
+
88
+	static OpenRaider *Instance();
89
+	/*------------------------------------------------------
90
+	 * Pre  : 
91
+	 * Post : Constructs the object of OpenRaider or
92
+	 *        returns pointer to it if previously allocated
93
+	 *
94
+	 *-- History ------------------------------------------
95
+	 *
96
+	 * 2001.08.24: 
97
+	 * Mongoose - Created
98
+	 ------------------------------------------------------*/
99
+
100
+	~OpenRaider();
101
+	/*------------------------------------------------------
102
+	 * Pre  : OpenRaider object is allocated
103
+	 * Post : Deconstructs an object of OpenRaider
104
+	 *
105
+	 *-- History ------------------------------------------
106
+	 *
107
+	 * 2001.05.21: 
108
+	 * Mongoose - Created
109
+	 ------------------------------------------------------*/
110
+
111
+
112
+	////////////////////////////////////////////////////////////
113
+	// Public Accessors
114
+	////////////////////////////////////////////////////////////
115
+
116
+
117
+	////////////////////////////////////////////////////////////
118
+	// Public Mutators
119
+	////////////////////////////////////////////////////////////
120
+
121
+	void start();
122
+	/*------------------------------------------------------
123
+	 * Pre  : 
124
+	 * Post : Init the Game
125
+	 *
126
+	 *-- History ------------------------------------------
127
+	 *
128
+	 * 2001.05.21: 
129
+	 * Mongoose - Created
130
+	 ------------------------------------------------------*/
131
+
132
+	void handleMouseMotionEvent(float x, float y);
133
+	/*------------------------------------------------------
134
+	 * Pre  : 
135
+	 * Post : Mouse motion input used
136
+	 *
137
+	 *-- History ------------------------------------------
138
+	 *
139
+	 * 2001.06.04: 
140
+	 * Mongoose - Created
141
+	 ------------------------------------------------------*/
142
+
143
+	void handleBoundKeyPressEvent(unsigned int key);
144
+	/*------------------------------------------------------
145
+	 * Pre  : <Key> is a valid keyboard code
146
+	 *
147
+	 * Post : Recieves <Event> bound to <Cmd> from <Key> press 
148
+	 *
149
+	 *-- History ------------------------------------------
150
+	 *
151
+	 * 2003.06.03:
152
+	 * Mongoose - Created
153
+	 ------------------------------------------------------*/
154
+
155
+	void handleBoundKeyReleaseEvent(unsigned int key);
156
+	/*------------------------------------------------------
157
+	 * Pre  : <Key> is a valid keyboard code
158
+	 *
159
+	 * Post : Recieves <Event> bound to <Cmd> from <Key> release
160
+	 *
161
+	 *-- History ------------------------------------------
162
+	 *
163
+	 * 2003.06.03:
164
+	 * Mongoose - Created
165
+	 ------------------------------------------------------*/
166
+
167
+	 void handleCommand(char *command, unsigned int mode);
168
+	/*------------------------------------------------------
169
+	 * Pre  : <Command> is valid keyword optionally followed 
170
+	 *        by ' ' (space) seperated and argument(s)
171
+	 *
172
+	 *        <Mode> is the current type or resource mode
173
+	 *
174
+	 * Post : Executes valid command based on keyword
175
+	 *
176
+	 *-- History ------------------------------------------
177
+	 *
178
+	 * 2002.03.23:
179
+	 * Mongoose - Created
180
+	 ------------------------------------------------------*/
181
+
182
+	 void handleConsoleKeyPressEvent(unsigned int key, unsigned int mod);
183
+	/*------------------------------------------------------
184
+	 * Pre  : <Key> is a valid keyboard code
185
+	 *
186
+	 * Post : Recieves <Key> code from text input in console mode
187
+	 *
188
+	 *-- History ------------------------------------------
189
+	 *
190
+	 * 2003.06.03:
191
+	 * Mongoose - Created
192
+	 ------------------------------------------------------*/
193
+
194
+	void handleKeyPressEvent(unsigned int key, unsigned int mod);
195
+	void handleKeyReleaseEvent(unsigned int key, unsigned int mod);
196
+	/*------------------------------------------------------
197
+	 * Pre  : key and mod are valid key command
198
+	 * Post : executes command acc with key, if any
199
+	 *
200
+	 *-- History ------------------------------------------
201
+	 *
202
+	 * 2001.05.27: 
203
+	 * Mongoose - Created
204
+	 ------------------------------------------------------*/
205
+
206
+	void initGL();
207
+	/*------------------------------------------------------
208
+	 * Pre  : 
209
+	 * Post : 
210
+	 *
211
+	 *-- History ------------------------------------------
212
+	 *
213
+	 * 2002.08.13:
214
+	 * Mongoose - Created
215
+	 ------------------------------------------------------*/
216
+
217
+	void gameFrame();
218
+	/*------------------------------------------------------
219
+	 * Pre  : 
220
+	 * Post : One game physics/time frame passes
221
+	 *        Also renders one frame per call
222
+	 *
223
+	 *-- History ------------------------------------------
224
+	 *
225
+	 * 2001.05.21: 
226
+	 * Mongoose - Created
227
+	 ------------------------------------------------------*/
228
+
229
+	void print(bool dump_stdout, char *format, ...);
230
+	/*------------------------------------------------------
231
+	 * Pre  : Use like printf
232
+	 *
233
+	 * Post : Outputs message in game console
234
+	 *
235
+	 *        If dump_stdout is true, print to stdout also
236
+	 *
237
+	 *-- History ------------------------------------------
238
+	 *
239
+	 * 2002.08.13:
240
+	 * Mongoose - Created
241
+	 ------------------------------------------------------*/
242
+
243
+
244
+ protected:
245
+
246
+	////////////////////////////////////////////////////////////
247
+	// Constructors ( Singleton )
248
+	////////////////////////////////////////////////////////////
249
+
250
+	OpenRaider();
251
+	/*------------------------------------------------------
252
+	 * Pre  : 
253
+	 * Post : Constructs an object of OpenRaider
254
+	 *
255
+	 *-- History ------------------------------------------
256
+	 *
257
+	 * 2001.05.21: 
258
+	 * Mongoose - Created
259
+	 ------------------------------------------------------*/
260
+
261
+
262
+ private:
263
+
264
+	////////////////////////////////////////////////////////////
265
+	// Private Accessors
266
+	////////////////////////////////////////////////////////////
267
+
268
+
269
+	////////////////////////////////////////////////////////////
270
+	// Private Mutators
271
+	////////////////////////////////////////////////////////////
272
+
273
+	void consoleCommand(char *cmd);
274
+	/*------------------------------------------------------
275
+	 * Pre  : 
276
+	 * Post : 
277
+	 *
278
+	 *-- History ------------------------------------------
279
+	 *
280
+	 * ????.??.??: 
281
+	 * Mongoose - Created
282
+	 ------------------------------------------------------*/
283
+
284
+	void soundEvent(int type, int id, vec3_t pos, vec3_t angles);
285
+	/*------------------------------------------------------
286
+	 * Pre  : 
287
+	 * Post : 
288
+	 *
289
+	 *-- History ------------------------------------------
290
+	 *
291
+	 * 2002.06.16: 
292
+	 * Mongoose - Created
293
+	 ------------------------------------------------------*/
294
+
295
+//	void entityEvent(entity_t &e, RaiderEvent event);
296
+	/*------------------------------------------------------
297
+	 * Pre  : 
298
+	 * Post : 
299
+	 *
300
+	 *-- History ------------------------------------------
301
+	 *
302
+	 * 2002.06.16: 
303
+	 * Mongoose - Created
304
+	 ------------------------------------------------------*/
305
+
306
+	void processPakSounds();
307
+	/*------------------------------------------------------
308
+	 * Pre  : 
309
+	 * Post : 
310
+	 *
311
+	 *-- History ------------------------------------------
312
+	 *
313
+	 * 2001.06.04: 
314
+	 * Mongoose - Created
315
+	 ------------------------------------------------------*/
316
+
317
+	void initSound();
318
+	/*------------------------------------------------------
319
+	 * Pre  : Sound system has been init
320
+	 * Post : Loads and positions level sounds and music
321
+	 *
322
+	 *-- History ------------------------------------------
323
+	 *
324
+	 * 2001.06.04: 
325
+	 * Mongoose - Created
326
+	 ------------------------------------------------------*/
327
+
328
+	void initTextures();
329
+	/*------------------------------------------------------
330
+	 * Pre  : 
331
+	 * Post : Generates all textures or mipmaps
332
+	 *        needed for fonts, splash, ext particles
333
+	 *
334
+	 *-- History ------------------------------------------
335
+	 *
336
+	 * 2001.05.28: 
337
+	 * Mongoose - Created
338
+	 ------------------------------------------------------*/
339
+
340
+	void processTextures();
341
+	/*------------------------------------------------------
342
+	 * Pre  : 
343
+	 * Post : Generates tombraider textures or mipmaps
344
+	 *        needed for sprites, rooms, and models
345
+	 *
346
+	 *-- History ------------------------------------------
347
+	 *
348
+	 * 2001.05.28: 
349
+	 * Mongoose - Created
350
+	 ------------------------------------------------------*/
351
+
352
+	void processSprites();
353
+	/*------------------------------------------------------
354
+	 * Pre  : 
355
+	 * Post : Generates render sprite sequences
356
+	 *
357
+	 *-- History ------------------------------------------
358
+	 *
359
+	 * 2001.06.06:
360
+	 * Mongoose - All new functionality
361
+	 *
362
+	 * 2001.05.28: 
363
+	 * Mongoose - Created
364
+	 ------------------------------------------------------*/
365
+	
366
+	void processMoveables();
367
+	/*------------------------------------------------------
368
+	 * Pre  : 
369
+	 * Post : 
370
+	 *
371
+	 *-- History ------------------------------------------
372
+	 *
373
+	 * 2001.06.08: 
374
+	 * Mongoose - Created
375
+	 ------------------------------------------------------*/
376
+	
377
+	void processMoveable(int index, int i, int *ent, List <skeletal_model_t *> &cache2, List <unsigned int> &cache, int object_id);
378
+	/*------------------------------------------------------
379
+	 * Pre  : 
380
+	 * Post : 
381
+	 *
382
+	 *-- History ------------------------------------------
383
+	 *
384
+	 * 2002.04.06: 
385
+	 * Mongoose - Created
386
+	 ------------------------------------------------------*/
387
+
388
+	void processModel(int index);
389
+	/*------------------------------------------------------
390
+	 * Pre  : valid model index
391
+	 * Post : Generates render mesh and any textures
392
+	 *        needed for model[index]
393
+	 *
394
+	 *-- History ------------------------------------------
395
+	 *
396
+	 * 2001.05.26: 
397
+	 * Mongoose - Created
398
+	 ------------------------------------------------------*/
399
+
400
+	void processRoom(int index);
401
+	/*------------------------------------------------------
402
+	 * Pre  : valid room index
403
+	 * Post : Generates render mesh and any textures
404
+	 *        needed for room[index]
405
+	 *
406
+	 *-- History ------------------------------------------
407
+	 *
408
+	 * 2001.05.21: 
409
+	 * Mongoose - Created
410
+	 ------------------------------------------------------*/
411
+	
412
+	void loadLevel(char *filename);
413
+	/*------------------------------------------------------
414
+	 * Pre  : 
415
+	 * Post : Loads validated level pak from diskfile 
416
+	 *        using maplist
417
+	 *
418
+	 *-- History ------------------------------------------
419
+	 *
420
+	 * 2001.05.21: 
421
+	 * Mongoose - Created
422
+	 ------------------------------------------------------*/
423
+
424
+
425
+	static OpenRaider *mInstance; /* Singleton use */
426
+
427
+	TombRaider m_tombraider;      /* Tombraider data support */
428
+
429
+	Sound mSound;                 /* 3d Audio support */
430
+
431
+	Render m_render;              /* Rendering support */
432
+
433
+	Camera m_camera;              /* Client camera support */
434
+
435
+	GLString *mText;              /* Hook to textbox like output */
436
+
437
+	int mNoClipping;              /* 0 - Clipping, 1 - No Clipping,
438
+											   2 - No Clipping w/o gravity */
439
+
440
+	// RC vars //////////////////
441
+
442
+	unsigned int mMode[8];			/* Translate System's mode ids to OR's */
443
+
444
+	unsigned int m_flags;			/* Set options by flags */
445
+
446
+	int m_testSFX;						/* Used for mixed channel sound tests */
447
+
448
+	float m_mouseX, m_mouseY;		/* XY axis rotation deltas */
449
+
450
+	unsigned int m_texOffset;		/* Offset of TombRaider textures in list */
451
+
452
+	unsigned int mLevelTextureOffset;
453
+
454
+	// Game vars //////////////
455
+
456
+	Vector <char *> mMusicList;  /* List of game level music */ 
457
+
458
+	Vector <char *> mMapList;    /* List of game maps */ 
459
+	
460
+	char m_mapName[32];          /* Current map filename */
461
+
462
+	char *m_pakDir;              /* Current pak directory */
463
+
464
+	char *m_audioDir;            /* Current audio directory */
465
+
466
+	char *m_homeDir;             /* Current home directory */
467
+
468
+	Vector<entity_t *> mClients; /* Player entity/clients */
469
+
470
+	unsigned int mMaxClients;    /* Max number of clients */
471
+};
472
+
473
+#endif

+ 2589
- 0
src/PSKModel.cpp
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 589
- 0
src/PSKModel.h 파일 보기

@@ -0,0 +1,589 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Freyja
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : PSKModel
9
+ * License : No use w/o permission (C) 2003 Mongoose
10
+ * Comments: Unreal Tournament skeletal model
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- Test Defines -----------------------------------------------
17
+ *           
18
+ * UNIT_TEST_PSKMODEL - Builds PSKModel class as a console unit test 
19
+ *
20
+ *-- History ------------------------------------------------ 
21
+ *
22
+ * 2003.07.12:
23
+ * Mongoose - UT Package prototype code moved into 'UTPackage'
24
+ *            API changes to structs to clearify meaning
25
+ *
26
+ * 2003.06.12:
27
+ * Mongoose - PSA keyframes fixed, special thanks to:
28
+ *            Steven Fuller and Forest Hale for help picking
29
+ *            apart those tough little 8 bytes   =)
30
+ *
31
+ * 2003.06.11:
32
+ * Mongoose - Broke up rendering and model loading into seperate
33
+ *            classes ( Closely coupled )
34
+ *
35
+ *            PSA experimental loader
36
+ *
37
+ * 2003.06.10:
38
+ * Mongoose - Skeletal format fixed, should load perfectly
39
+ *
40
+ * 2003.01.20:
41
+ * Mongoose - Fixed triangle rendering thanks to debugging by
42
+ *            Steven Fuller, who found the tris -> UV -> vert 
43
+ *            connection
44
+ *
45
+ *            Finished up basic rendering, lots of 
46
+ *            small fixes/features
47
+ *
48
+ * 2003.01.06:
49
+ * Mongoose - Created
50
+ ================================================================*/
51
+
52
+
53
+#ifndef GUARD__FREYJA_MONGOOSE_PSKMODEL_H_
54
+#define GUARD__FREYJA_MONGOOSE_PSKMODEL_H_
55
+
56
+
57
+typedef struct /* 13 bytes */
58
+{
59
+	unsigned short x, y, z;
60
+	unsigned char material;
61
+	unsigned int flags;
62
+	unsigned short unknown;
63
+
64
+} psk_face_t;
65
+
66
+
67
+typedef struct /* 16 bytes */
68
+{
69
+	unsigned short vertex;
70
+	unsigned short unknown1;
71
+	float uv[2];
72
+	unsigned int unknown2;
73
+
74
+} psk_vtxw_t;
75
+
76
+
77
+typedef struct  /* 88 bytes */
78
+{
79
+	char name[64];
80
+
81
+	unsigned int unknown1;
82
+	unsigned int unknown2;
83
+	unsigned int unknown3;
84
+	unsigned int unknown4;
85
+	unsigned int unknown5;
86
+	unsigned int unknown6;
87
+
88
+} psk_material_t;
89
+
90
+typedef struct /* 120 bytes */
91
+{
92
+	char name[64];
93
+	unsigned int flags;         /* Option flags? */
94
+	unsigned int numChildren;
95
+	unsigned int parentIndex;
96
+	float restDir[4];           /* Quaternion x,y,z,w */
97
+	float restLoc[3];
98
+	int unknown[4];             /* Scale? */
99
+
100
+} psk_bone_t;
101
+
102
+
103
+typedef struct  /* 12 bytes */
104
+{
105
+	float weight;
106
+	unsigned int vertexIndex;
107
+	unsigned int boneIndex;
108
+
109
+} psk_weight_t;
110
+
111
+
112
+typedef struct /* 168 bytes */
113
+{
114
+	char name[64];
115
+	char name2[64];
116
+	unsigned int numBones;
117
+	unsigned int rootId; // ?
118
+	unsigned int key[2];
119
+	float keyf;
120
+	float time[2];
121
+	float unknown[3];
122
+
123
+} psa_anim_info_t;
124
+
125
+
126
+typedef struct /* 32 bytes */
127
+{
128
+	float trans[3];	// xyz
129
+	float dir[4];		// xyzw
130
+	float scale;		// ?
131
+
132
+} psa_key_frame_t;
133
+
134
+
135
+class PSKModel
136
+{
137
+ public:
138
+
139
+	enum PSKModelFlag
140
+	{
141
+		fDebugWeightLoad		= 1,
142
+		fDebugPointLoad		= 2,
143
+		fDebugFaceLoad			= 4,
144
+		fDebugUVLoad			= 8,
145
+		fDebugMattLoad			= 16,
146
+		fDebugBoneLoad			= 32
147
+	};
148
+
149
+
150
+	////////////////////////////////////////////////////////////
151
+	// Constructors
152
+	////////////////////////////////////////////////////////////
153
+
154
+	PSKModel();
155
+	/*------------------------------------------------------
156
+	 * Pre  : 
157
+	 * Post : Constructs an object of PSKModel
158
+	 *
159
+	 *-- History ------------------------------------------
160
+	 *
161
+	 * 2003.01.06: 
162
+	 * Mongoose - Created
163
+	 ------------------------------------------------------*/
164
+
165
+	~PSKModel();
166
+	/*------------------------------------------------------
167
+	 * Pre  : PSKModel object is allocated
168
+	 * Post : Deconstructs an object of PSKModel
169
+	 *
170
+	 *-- History ------------------------------------------
171
+	 *
172
+	 * 2003.01.06: 
173
+	 * Mongoose - Created
174
+	 ------------------------------------------------------*/
175
+
176
+
177
+	////////////////////////////////////////////////////////////
178
+	// Public Accessors
179
+	////////////////////////////////////////////////////////////
180
+
181
+	void printSkeletion(bool printNames);
182
+	/*------------------------------------------------------
183
+	 * Pre  : <PrintNames> if true use names instead of Ids
184
+	 *
185
+	 * Post : Prints skeletion bone trace one bone per line
186
+	 *
187
+	 *-- History ------------------------------------------
188
+	 *
189
+	 * 2003.06.10:
190
+	 * Mongoose - Created
191
+	 ------------------------------------------------------*/
192
+
193
+
194
+	////////////////////////////////////////////////////////////
195
+	// Public Mutators
196
+	////////////////////////////////////////////////////////////
197
+
198
+	int load(char *filename);
199
+	/*------------------------------------------------------
200
+	 * Pre  : 
201
+	 * Post : Loads PSK model from disk
202
+	 *
203
+	 *-- History ------------------------------------------
204
+	 *
205
+	 * 2003.01.06:
206
+	 * Mongoose - Created
207
+	 ------------------------------------------------------*/
208
+
209
+	unsigned int mFlags;
210
+
211
+	unsigned int mNumFrames;
212
+
213
+	unsigned int mNumVertices;
214
+
215
+	unsigned int mNumFaces;
216
+
217
+	unsigned int mNumVTXWs;
218
+
219
+	unsigned int mNumMaterials;
220
+
221
+	unsigned int mNumBones;
222
+
223
+	unsigned int mNumWeights;
224
+
225
+	float *mVertices;							/* Vertices of the model */
226
+
227
+	psk_vtxw_t *mVTXWs;						/* UV Wedges */
228
+
229
+	psk_face_t *mFaces;						/* The triangle mesh */
230
+
231
+	psk_material_t *mMaterials;			/* Materials/textures */
232
+
233
+	psk_bone_t *mBones;						/* The bones of the model */
234
+
235
+	psk_weight_t *mWeights;					/* The weights of the bones */
236
+
237
+
238
+ private:
239
+
240
+	////////////////////////////////////////////////////////////
241
+	// Private Accessors
242
+	////////////////////////////////////////////////////////////
243
+
244
+
245
+	////////////////////////////////////////////////////////////
246
+	// Private Mutators
247
+	////////////////////////////////////////////////////////////
248
+};
249
+
250
+
251
+//////////////////////////////////////////////////////////////////////
252
+// PSAAnimation Class
253
+//////////////////////////////////////////////////////////////////////
254
+
255
+class PSAAnimation
256
+{
257
+public:
258
+
259
+	enum PSKModelRendererFlag
260
+	{
261
+		fReserved1			= 1,
262
+		fReserved2			= 2,
263
+		fDebugBones			= 4,
264
+		fDebugAnimInfos	= 8,
265
+		fDebugKeyFrames	= 16
266
+	};
267
+
268
+	////////////////////////////////////////////////////////////
269
+	// Constructors
270
+	////////////////////////////////////////////////////////////
271
+
272
+	PSAAnimation();
273
+	/*------------------------------------------------------
274
+	 * Pre  : 
275
+	 * Post : Constructs an object of PSAAnimation
276
+	 *
277
+	 *-- History ------------------------------------------
278
+	 *
279
+	 * 2003.06.11: 
280
+	 * Mongoose - Created
281
+	 ------------------------------------------------------*/
282
+
283
+	~PSAAnimation();
284
+	/*------------------------------------------------------
285
+	 * Pre  : PSAAnimation object is allocated
286
+	 * Post : Deconstructs an object of PSAAnimation
287
+	 *
288
+	 *-- History ------------------------------------------
289
+	 *
290
+	 * 2003.06.11: 
291
+	 * Mongoose - Created
292
+	 ------------------------------------------------------*/
293
+
294
+
295
+	////////////////////////////////////////////////////////////
296
+	// Public Accessors
297
+	////////////////////////////////////////////////////////////
298
+
299
+	int load(char *filename);
300
+	/*------------------------------------------------------
301
+	 * Pre  : 
302
+	 * Post : Loads PSA animation from disk
303
+	 *
304
+	 *        Returns < 0 on error
305
+	 *
306
+	 *-- History ------------------------------------------
307
+	 *
308
+	 * 2003.01.06:
309
+	 * Mongoose - Created
310
+	 ------------------------------------------------------*/
311
+
312
+
313
+	////////////////////////////////////////////////////////////
314
+	// Public Mutators
315
+	////////////////////////////////////////////////////////////
316
+
317
+	unsigned int mFlags;
318
+
319
+	unsigned int mNumFrames;
320
+
321
+	unsigned int mNumBones;
322
+
323
+	unsigned int mNumAnimInfos;
324
+
325
+	unsigned int mNumKeyFrames;
326
+
327
+	psk_bone_t *mBones;
328
+
329
+	psa_anim_info_t *mAnimInfos;
330
+
331
+	psa_key_frame_t *mKeyFrames;
332
+
333
+
334
+private:
335
+
336
+	////////////////////////////////////////////////////////////
337
+	// Private Accessors
338
+	////////////////////////////////////////////////////////////
339
+
340
+
341
+	////////////////////////////////////////////////////////////
342
+	// Private Mutators
343
+	////////////////////////////////////////////////////////////
344
+
345
+};
346
+
347
+
348
+//////////////////////////////////////////////////////////////////////
349
+// PSKModelRenderer Class
350
+//////////////////////////////////////////////////////////////////////
351
+
352
+class PSKModelRenderer
353
+{
354
+ public:
355
+
356
+	enum PSKModelRendererFlag
357
+	{
358
+		fRenderFaces		= 1,
359
+		fRenderTexture		= 2,
360
+		fRenderPoints		= 4,
361
+		fRenderBones 		= 8,
362
+		fConvertEuler 		= 16,
363
+		fDebugFaceRender 	= 32
364
+	};
365
+
366
+
367
+	////////////////////////////////////////////////////////////
368
+	// Constructors
369
+	////////////////////////////////////////////////////////////
370
+
371
+	PSKModelRenderer();
372
+	/*------------------------------------------------------
373
+	 * Pre  : 
374
+	 * Post : Constructs an object of PSKModelRenderer
375
+	 *
376
+	 *-- History ------------------------------------------
377
+	 *
378
+	 * 2003.01.06: 
379
+	 * Mongoose - Created
380
+	 ------------------------------------------------------*/
381
+
382
+	~PSKModelRenderer();
383
+	/*------------------------------------------------------
384
+	 * Pre  : PSKModelRenderer object is allocated
385
+	 * Post : Deconstructs an object of PSKModelRenderer
386
+	 *
387
+	 *-- History ------------------------------------------
388
+	 *
389
+	 * 2003.01.06: 
390
+	 * Mongoose - Created
391
+	 ------------------------------------------------------*/
392
+
393
+
394
+	////////////////////////////////////////////////////////////
395
+	// Public Accessors
396
+	////////////////////////////////////////////////////////////
397
+
398
+	void render();
399
+	/*------------------------------------------------------
400
+	 * Pre  : 
401
+	 * Post : Renders PSK model in OpenGL
402
+	 *
403
+	 *-- History ------------------------------------------
404
+	 *
405
+	 * 2003.01.06:
406
+	 * Mongoose - Created
407
+	 ------------------------------------------------------*/
408
+
409
+	void renderBone(unsigned int id);
410
+	/*------------------------------------------------------
411
+	 * Pre  : 
412
+	 * Post : Renders PSK model's bone in OpenGL, 
413
+	 *        ( Recursive calling )
414
+	 *
415
+	 *-- History ------------------------------------------
416
+	 *
417
+	 * 2003.01.06:
418
+	 * Mongoose - Created, from nonpublic render()
419
+	 ------------------------------------------------------*/
420
+
421
+
422
+	////////////////////////////////////////////////////////////
423
+	// Public Mutators
424
+	////////////////////////////////////////////////////////////
425
+
426
+	void convertBoneAngles();
427
+	/*------------------------------------------------------
428
+	 * Pre  : 
429
+	 * Post : Converts bone angles for rendering use
430
+	 *
431
+	 *-- History ------------------------------------------
432
+	 *
433
+	 * 2003.06.10:
434
+	 * Mongoose - Created
435
+	 ------------------------------------------------------*/
436
+
437
+	void convertBoneAnglesPSA(unsigned int frame);
438
+	/*------------------------------------------------------
439
+	 * Pre  : 
440
+	 * Post : Converts PSA bone angles for rendering use
441
+	 *
442
+	 *-- History ------------------------------------------
443
+	 *
444
+	 * 2003.06.10:
445
+	 * Mongoose - Created
446
+	 ------------------------------------------------------*/
447
+
448
+	void copyVertices();
449
+	/*------------------------------------------------------
450
+	 * Pre  : 
451
+	 * Post : Resets vertices to match PSKModel's default
452
+	 *
453
+	 *-- History ------------------------------------------
454
+	 *
455
+	 * 2003.06.10:
456
+	 * Mongoose - Created
457
+	 ------------------------------------------------------*/
458
+
459
+	void setAnimation(PSAAnimation *anim);
460
+	/*------------------------------------------------------
461
+	 * Pre  : 
462
+	 * Post : Sets PSA animation to render, and sets up cache
463
+	 *
464
+	 *-- History ------------------------------------------
465
+	 *
466
+	 * 2003.06.11:
467
+	 * Mongoose - Created
468
+	 ------------------------------------------------------*/
469
+
470
+	void setModel(PSKModel *model);
471
+	/*------------------------------------------------------
472
+	 * Pre  : 
473
+	 * Post : Sets PSK model to render, and sets up cache
474
+	 *
475
+	 *-- History ------------------------------------------
476
+	 *
477
+	 * 2003.06.10:
478
+	 * Mongoose - Created
479
+	 ------------------------------------------------------*/
480
+
481
+	void setupRestMatrices(unsigned int id);
482
+	/*------------------------------------------------------
483
+	 * Pre  : <Id> the bone to setup matching invert matrix 
484
+	 *
485
+	 * Post : Generates inverted matrices to render deformed
486
+	 *        mesh by recursive call from root bone
487
+	 *
488
+	 *        OpenGL accelerated where avalibable
489
+	 *
490
+	 *-- History ------------------------------------------
491
+	 *
492
+	 * 2003.07.07:
493
+	 * Mongoose - Created, was boneTransforms
494
+	 ------------------------------------------------------*/
495
+
496
+	void setupWorldMatrices(unsigned int id);
497
+	/*------------------------------------------------------
498
+	 * Pre  : <Id> the bone to setup matching transform matrix 
499
+	 *
500
+	 * Post : Generates transform matrices to render deformed
501
+	 *        mesh by recursive call from root bone
502
+	 *
503
+	 *-- History ------------------------------------------
504
+	 *
505
+	 * 2003.06.10:
506
+	 * Mongoose - Created, was boneTransforms
507
+	 ------------------------------------------------------*/
508
+
509
+	void transformVertices();
510
+	/*------------------------------------------------------
511
+	 * Pre  : 
512
+	 * Post : Transforms vertices to deformed mesh for 
513
+	 *        current bone frame
514
+	 *
515
+	 *-- History ------------------------------------------
516
+	 *
517
+	 * 2003.06.10:
518
+	 * Mongoose - Created
519
+	 ------------------------------------------------------*/
520
+
521
+	unsigned int mFlags;
522
+
523
+	int mTextures[8];							/* Texture Ids of loaded materials */
524
+
525
+	unsigned int mAnimationFrame;			/* Used to keep up with animation 
526
+														frame externally, 
527
+													
528
+														And updated	internally
529
+
530
+														Should be moved to 
531
+														private+acessor method
532
+													*/
533
+
534
+ private:
535
+
536
+	////////////////////////////////////////////////////////////
537
+	// Private Accessors
538
+	////////////////////////////////////////////////////////////
539
+
540
+
541
+	////////////////////////////////////////////////////////////
542
+	// Private Mutators
543
+	////////////////////////////////////////////////////////////
544
+
545
+	float *mBoneRotationCache;				/* Cache of the computed axis angles */
546
+
547
+	float *mVertexTransformCache;			/* Cache of vertex transforms */
548
+
549
+	float **mInvertedMatrices;          /* Cache of computed inverted 
550
+														bone transform matrices for the
551
+														vertices at rest position */
552
+
553
+	float **mWorldMatrices;
554
+
555
+	unsigned int mNumMatrices;
556
+
557
+
558
+	/* Simulate inheritence here, cheesy waste */
559
+
560
+	unsigned int mNumFrames;
561
+
562
+	unsigned int mNumVertices;
563
+
564
+	unsigned int mNumFaces;
565
+
566
+	unsigned int mNumVTXWs;
567
+
568
+	unsigned int mNumMaterials;
569
+
570
+	unsigned int mNumBones;
571
+
572
+	unsigned int mNumWeights;
573
+
574
+	PSKModel *mModel;							/* Current PSK model to render */
575
+
576
+	PSAAnimation *mAnimation;				/* Current PSA anim to render */
577
+
578
+	psk_vtxw_t *mVTXWs;						/* UV Wedges */
579
+
580
+	psk_face_t *mFaces;						/* The triangle mesh */
581
+
582
+	psk_material_t *mMaterials;			/* Materials/textures */
583
+
584
+	psk_bone_t *mBones;						/* The bones of the model */
585
+
586
+	psk_weight_t *mWeights;					/* The weights of the bones */
587
+};
588
+
589
+#endif

+ 177
- 0
src/Particle.cpp 파일 보기

@@ -0,0 +1,177 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Freyja
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Particle
9
+ * License : No use w/o permission (C)2001Mongoose
10
+ * Comments: Partcle system's atomic base
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2001.08.13:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#include <stdlib.h>
23
+#include <stdio.h>
24
+#include "Particle.h"
25
+
26
+#ifdef DEBUG_MEMEORY
27
+#   include "memeory_test.h"
28
+#endif
29
+
30
+
31
+
32
+Particle::Particle()
33
+{
34
+	setActive(true);
35
+	TextureId(0);
36
+	Speed(2000.0, 2000.0, 2000.0);
37
+	Color(1.0, 1.0, 1.0);
38
+	Force(0.0, 0.8, 0.0);
39
+
40
+	Reset();
41
+}
42
+
43
+
44
+Particle::~Particle()
45
+{
46
+}
47
+
48
+
49
+void Particle::TextureId(int id)
50
+{
51
+	_texture = id;
52
+}
53
+
54
+
55
+void Particle::setActive(bool active)
56
+{
57
+	_active = active;
58
+}
59
+
60
+
61
+void Particle::Speed(float x, float y, float z)
62
+{
63
+	_speed[0] = x;
64
+	_speed[1] = y;
65
+	_speed[2] = z;
66
+}
67
+
68
+
69
+void Particle::Color(float r, float g, float b)
70
+{
71
+	_color[0] = r;
72
+	_color[1] = g;
73
+	_color[2] = b;
74
+}
75
+
76
+
77
+void Particle::Force(float x, float y, float z)
78
+{
79
+	_force[0] = x;
80
+	_force[1] = y;
81
+	_force[2] = z;
82
+}
83
+
84
+
85
+void Particle::Reset()
86
+{
87
+	// Mongoose 2002.01.01, Ah, how old is that code?
88
+#ifdef OBSOLOETE
89
+	_active = true;
90
+	_life = 1.0;
91
+	_blend = (float)(rand() % 100) / 1000.0 + 0.003;
92
+
93
+	_pos[0] = _pos[1] = _pos[2] = 0.0;
94
+	
95
+	_dir[0] = (float)((rand() % 50) - 26.0) * 10.0;
96
+	_dir[1] = (float)((rand() % 50) - 25.0) * 10.0;
97
+	_dir[2] = _dir[1];
98
+	
99
+	_force[0] = 0.0;
100
+	_force[1] = -0.8;
101
+	_force[2] = 0.0;
102
+#else
103
+	// FIXME: _blend prob should have nonstatic range
104
+	_blend = (float)(0.003 + (0.1 * rand() / (RAND_MAX + 1.0))); // high order
105
+	//_blend = (float)(rand() % 100) / 1000.0 + 0.003; 
106
+
107
+	// FIXME: Reset these using some nonstatic functions and values later
108
+	_life = 1.0;
109
+
110
+	_pos[0] = _pos[1] = _pos[2] = 0.0;
111
+
112
+	_dir[0] = (float)(-26.0 + (50.0 * rand() / (RAND_MAX + 1.0))); // high order
113
+	_dir[0] *= 10.0;
114
+	//_dir[0] = (float)((rand() % 50) - 26.0) * 10.0;
115
+	_dir[1] = (float)(-25.0 + (50.0 * rand() / (RAND_MAX + 1.0))); // high order
116
+	_dir[1] *= 10.0;
117
+	//_dir[1] = (float)((rand() % 50) - 25.0) * 10.0;
118
+	_dir[2] = _dir[1];
119
+#endif
120
+}
121
+
122
+
123
+void Particle::Pos(float *x, float *y, float *z)
124
+{
125
+	*x = _pos[0];
126
+	*y = _pos[1];
127
+	*z = _pos[2];
128
+}
129
+
130
+
131
+void Particle::Color(float *r, float *g, float *b)
132
+{
133
+	*r = _color[0];
134
+	*g = _color[1];
135
+	*b = _color[2];
136
+}
137
+
138
+
139
+float Particle::Life()
140
+{
141
+	return _life;
142
+}
143
+
144
+
145
+void Particle::Update()
146
+{
147
+	// Adjust particle position
148
+	_pos[0] += _dir[0] / _speed[0];
149
+	_pos[1] += _dir[1] / _speed[1];
150
+	_pos[2] += _dir[2] / _speed[2];
151
+	
152
+	// Adjust particle direction
153
+	_dir[0] += _force[0];
154
+	_dir[1] += _force[1];
155
+	_dir[2] += _force[2];
156
+
157
+	// Adjust particle blending/life
158
+	_life -= _blend;
159
+	
160
+	// Reset 'dead' OR fully blended particles
161
+	if (_life < 0.0)
162
+	{
163
+		Reset();
164
+	}
165
+}
166
+
167
+
168
+int Particle::Texture()
169
+{
170
+	return _texture;
171
+}
172
+
173
+
174
+bool Particle::isActive()
175
+{ 
176
+	return _active;
177
+}

+ 210
- 0
src/Particle.h 파일 보기

@@ -0,0 +1,210 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Freyja
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Particle
9
+ * License : No use w/o permission (C)2001Mongoose
10
+ * Comments: Partcle system's atomic base
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------ 
17
+ *
18
+ * 2001.08.13:
19
+ * Mongoose - Created
20
+ ================================================================*/
21
+
22
+
23
+#ifndef __FREYJA_MONGOOSE_PARTICLE_H_
24
+#define __FREYJA_MONGOOSE_PARTICLE_H_
25
+
26
+#include <hel/math.h>
27
+
28
+class Particle
29
+{
30
+ public:
31
+
32
+  Particle();
33
+  /*------------------------------------------------------
34
+   * Pre  : 
35
+   * Post : Constructs an object of Particle
36
+   *
37
+   *-- History ------------------------------------------
38
+   *
39
+   * 2001.08.13: 
40
+   * Mongoose - Created
41
+   ------------------------------------------------------*/
42
+
43
+  ~Particle();
44
+  /*------------------------------------------------------
45
+   * Pre  : Particle object is allocated
46
+   * Post : Deconstructs an object of Particle
47
+   *
48
+   *-- History ------------------------------------------
49
+   *
50
+   * 2001.08.13: 
51
+   * Mongoose - Created
52
+   ------------------------------------------------------*/
53
+
54
+	void setActive(bool active);
55
+  /*------------------------------------------------------
56
+   * Pre  : 
57
+   * Post : Toggles active state of particle
58
+   *
59
+   *-- History ------------------------------------------
60
+   *
61
+   * 2001.08.13: 
62
+   * Mongoose - Created
63
+   ------------------------------------------------------*/
64
+
65
+  void Force(float x, float y, float z);
66
+  /*------------------------------------------------------
67
+   * Pre  : 
68
+   * Post : Sets gravity/force acting on particle
69
+   *
70
+   *-- History ------------------------------------------
71
+   *
72
+   * 2001.08.13: 
73
+   * Mongoose - Created
74
+   ------------------------------------------------------*/
75
+
76
+  void Reset();
77
+  /*------------------------------------------------------
78
+   * Pre  : 
79
+   * Post : Resets particle to defaults
80
+   *
81
+   *-- History ------------------------------------------
82
+   *
83
+   * 2001.08.13: 
84
+   * Mongoose - Created
85
+   ------------------------------------------------------*/
86
+
87
+  void Speed(float x, float y, float z);
88
+  /*------------------------------------------------------
89
+   * Pre  : note speed inits at 2000, lower is faster
90
+   * Post : Sets particle speed
91
+   *
92
+   *-- History ------------------------------------------
93
+   *
94
+   * 2001.08.14: 
95
+   * Mongoose - Created
96
+   ------------------------------------------------------*/
97
+
98
+  void Color(float r, float g, float b);
99
+  /*------------------------------------------------------
100
+   * Pre  : r,g,b are colors 0.0 to 1.0
101
+   * Post : Sets new particle coloring
102
+	*
103
+	* NOTE : White {1.0, 1.0, 1.0} is the init color
104
+   *
105
+   *-- History ------------------------------------------
106
+   *
107
+   * 2001.08.14: 
108
+   * Mongoose - Created
109
+   ------------------------------------------------------*/
110
+
111
+  void Pos(float *x, float *y, float *z);
112
+  /*------------------------------------------------------
113
+   * Pre  : x,y,z exist
114
+   * Post : Returns position of particle in 3 space
115
+   *
116
+   *-- History ------------------------------------------
117
+   *
118
+   * 2001.08.13: 
119
+   * Mongoose - Created
120
+   ------------------------------------------------------*/
121
+
122
+  void Color(float *r, float *g, float *b);
123
+  /*------------------------------------------------------
124
+   * Pre  : r,g,b exist
125
+   * Post : Returns current color of particle
126
+   *
127
+   *-- History ------------------------------------------
128
+   *
129
+   * 2001.08.13: 
130
+   * Mongoose - Created
131
+   ------------------------------------------------------*/
132
+
133
+  float Life();
134
+  /*------------------------------------------------------
135
+   * Pre  : 
136
+   * Post : Returns current life ( blend ) of particle
137
+   *
138
+   *-- History ------------------------------------------
139
+   *
140
+   * 2001.08.13: 
141
+   * Mongoose - Created
142
+   ------------------------------------------------------*/
143
+
144
+  void Update();
145
+  /*------------------------------------------------------
146
+   * Pre  : 
147
+   * Post : Ajusts for particle life cycle
148
+   *
149
+   *-- History ------------------------------------------
150
+   *
151
+   * 2001.08.13: 
152
+   * Mongoose - Created
153
+   ------------------------------------------------------*/
154
+
155
+  int Texture();
156
+  /*------------------------------------------------------
157
+   * Pre  : 
158
+   * Post : Returens texture binding for this particle
159
+   *
160
+   *-- History ------------------------------------------
161
+   *
162
+   * 2001.08.13: 
163
+   * Mongoose - Created
164
+   ------------------------------------------------------*/
165
+
166
+  bool isActive();
167
+  /*------------------------------------------------------
168
+   * Pre  : 
169
+   * Post : Returns active value
170
+   *
171
+   *-- History ------------------------------------------
172
+   *
173
+   * 2001.08.13: 
174
+   * Mongoose - Created
175
+   ------------------------------------------------------*/
176
+
177
+  void TextureId(int t);
178
+  /*------------------------------------------------------
179
+   * Pre  : 
180
+   * Post : 
181
+   *
182
+   *-- History ------------------------------------------
183
+   *
184
+   * 2001.08.13: 
185
+   * Mongoose - Created
186
+   ------------------------------------------------------*/
187
+
188
+
189
+ private:
190
+
191
+	bool _active;           /* Is this particle in use? */
192
+	
193
+	float _life;            /* Life of particle  */
194
+	
195
+	float _blend;           /* Blend amount or fade */
196
+
197
+	int _texture;           /* Texture polygon to use */
198
+
199
+	vec3_t _pos;            /* Current position in 3 space */
200
+
201
+	vec3_t _color;          /* Current color */
202
+
203
+	vec3_t _dir;            /* Current direction */
204
+
205
+	vec3_t _force;          /* Current force or 'gravity' */
206
+
207
+	vec3_t _speed;          /* Speed of particle movement */
208
+};
209
+
210
+#endif

+ 2298
- 0
src/Render.cpp
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 599
- 0
src/Render.h 파일 보기

@@ -0,0 +1,599 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Render
5
+ * Author  : Mongoose
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Render
9
+ * License : No use w/o permission (C) 2001 Mongoose
10
+ * Comments: This is the renderer class for OpenRaider
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------ 
17
+ *
18
+ * 2001.05.21:
19
+ * Mongoose - Created
20
+ ================================================================*/
21
+
22
+
23
+#ifndef GUARD__RENDER_MONGOOSE_RENDER_H_
24
+#define GUARD__RENDER_MONGOOSE_RENDER_H_
25
+
26
+#include <mstl/List.h>
27
+#include <mstl/Vector.h>
28
+#include <hel/Matrix.h>
29
+#include <hel/ViewVolume.h>
30
+#include "Light.h"
31
+#include "World.h"
32
+#include "SkeletalModel.h"
33
+#include "OpenGLMesh.h"
34
+#include "Texture.h"
35
+#include "Camera.h"
36
+#include "GLString.h"
37
+
38
+#ifdef USING_EMITTER
39
+#   include "Emitter.h"
40
+#endif
41
+
42
+
43
+class RenderRoom
44
+{
45
+public:
46
+	RenderRoom()
47
+	{
48
+		room = 0x0;
49
+	}
50
+
51
+	~RenderRoom()
52
+	{
53
+		// FIXME: hangs when erasing - might be shared pointers somewhere
54
+		//lights.erase();
55
+	}
56
+
57
+	void computeCenter()
58
+	{
59
+		if (room)
60
+		{
61
+			helMidpoint3v(room->bbox_min, room->bbox_max, center);
62
+		}
63
+	}
64
+
65
+	vec_t dist;              /* Distance to near plane, move to room?  */
66
+
67
+	vec3_t center;           /* Center of bbox, move to room? */
68
+
69
+	room_mesh_t *room;       /* Physical room stored in World,
70
+										 Very dangerous as allocated and used */
71
+
72
+	Vector<Light *> lights;  /* List of lights in this room */
73
+
74
+	OpenGLMesh mesh;         /* OpenGL mesh that represents this room */
75
+};
76
+
77
+
78
+class Render
79
+{
80
+ public:
81
+
82
+	typedef enum
83
+   {
84
+		modeDisabled    = 0,
85
+		modeLoadScreen  = 1,
86
+		modeVertexLight = 2,
87
+		modeSolid       = 3,
88
+		modeWireframe   = 4,
89
+		modeTexture     = 5
90
+	} RenderMode;
91
+
92
+	typedef enum
93
+   {
94
+		fParticles		= 1,
95
+		fPortals			= 2,
96
+		fRoomAlpha		= 4,
97
+		fViewModel    = 8,
98
+		fSprites      = 16,
99
+		fRoomModels   = 32,
100
+		fEntityModels = 64,
101
+		fFog          = 128,
102
+		fUsePortals   = 256,
103
+		fFastCard     = 1024,
104
+		fGL_Lights    = 2048,
105
+		fOneRoom      = 4096,
106
+		fRenderPonytail = 8192,
107
+		fMultiTexture = 16384,
108
+		fUpdateRoomListPerFrame = 32768,
109
+		fAnimateAllModels = 65536,
110
+		fAllRooms      =  131072
111
+	} RenderFlags;
112
+
113
+	typedef enum
114
+	{
115
+		roomMesh = 1,
116
+		skeletalMesh = 2
117
+
118
+	} RenderMeshType;
119
+
120
+	////////////////////////////////////////////////////////////
121
+	// Constructors
122
+	////////////////////////////////////////////////////////////
123
+	
124
+	Render();
125
+	/*------------------------------------------------------
126
+	 * Pre  : 
127
+	 * Post : Constructs an object of Render
128
+	 *
129
+	 *-- History ------------------------------------------
130
+	 *
131
+	 * 2001.05.21: 
132
+	 * Mongoose - Created
133
+	 ------------------------------------------------------*/
134
+	
135
+	~Render();
136
+	/*------------------------------------------------------
137
+	 * Pre  : Render object is allocated
138
+	 * Post : Deconstructs an object of Render
139
+	 *
140
+	 *-- History ------------------------------------------
141
+	 *
142
+	 * 2001.05.21: 
143
+	 * Mongoose - Created
144
+	 ------------------------------------------------------*/
145
+	
146
+
147
+	////////////////////////////////////////////////////////////
148
+	// Public Accessors
149
+	////////////////////////////////////////////////////////////
150
+
151
+	void screenShot(char *filenameBase);
152
+	/*------------------------------------------------------
153
+	 * Pre  : 
154
+	 * Post : Makes a screenshot, writes to disk as file
155
+	 *
156
+	 *-- History ------------------------------------------
157
+	 *
158
+	 * 2002.12.20: 
159
+	 * Mongoose - Created, factored out of OpenRaider class
160
+	 ------------------------------------------------------*/
161
+
162
+	int getMode();
163
+	/*------------------------------------------------------
164
+	 * Pre  : 
165
+	 * Post : Gets current rendering mode
166
+	 *
167
+	 *-- History ------------------------------------------
168
+	 *
169
+	 * 2001.05.21: 
170
+	 * Mongoose - Created
171
+	 ------------------------------------------------------*/
172
+
173
+
174
+	////////////////////////////////////////////////////////////
175
+	// Public Mutators
176
+	////////////////////////////////////////////////////////////
177
+
178
+	void addRoom(RenderRoom *rRoom);
179
+	/*------------------------------------------------------
180
+	 * Pre  : 
181
+	 * Post : 
182
+	 *
183
+	 *-- History ------------------------------------------
184
+	 *
185
+	 * 2002.12.21:
186
+	 * Mongoose - Created, factored out of World
187
+	 ------------------------------------------------------*/
188
+
189
+	void Init(int width, int height, bool fastCard);
190
+	/*------------------------------------------------------
191
+	 * Pre  : 
192
+	 * Post : Starts and sets up OpenGL target
193
+	 *
194
+	 *-- History ------------------------------------------
195
+	 *
196
+	 * 2001.05.21: 
197
+	 * Mongoose - Created
198
+	 ------------------------------------------------------*/
199
+
200
+	void loadTexture(unsigned char *image, 
201
+						  unsigned int width, unsigned int height,
202
+						  unsigned int id);
203
+	/*------------------------------------------------------
204
+	 * Pre  : 
205
+	 * Post : Loads textures in a certian id slot
206
+	 *
207
+	 *-- History ------------------------------------------
208
+	 *
209
+	 * 2002.12.20: 
210
+	 * Mongoose - Created, factored out of OpenRaider class
211
+	 ------------------------------------------------------*/
212
+
213
+	void initTextures(char *textureDir, unsigned int *numLoaded, 
214
+							unsigned int *nextId);
215
+	/*------------------------------------------------------
216
+	 * Pre  : textureDir is valid and exists with textures
217
+	 * Post : Sets up textures for OpenRaider
218
+	 *        Returns number of loaded textures and 
219
+	 *
220
+	 *        numLoaded will update number of
221
+	 *        external textures loaded
222
+	 *
223
+	 *        nextId will update next level texture id
224
+	 *
225
+	 *-- History ------------------------------------------
226
+	 *
227
+	 * 2002.12.20: 
228
+	 * Mongoose - Created, factored out of OpenRaider class
229
+	 ------------------------------------------------------*/
230
+
231
+	void loadMd3(char *model, char *skin);
232
+	/*------------------------------------------------------
233
+	 * Pre  : model is dir that holds an Md3 model data group
234
+	 *        skin is a skin in that dir
235
+	 *
236
+	 * Post : Loads an Md3 model with animation for a nice
237
+	 *        xmas easter egg that might show up in CVS later
238
+	 *
239
+	 *-- History ------------------------------------------
240
+	 *
241
+	 * 2002.12.25: 
242
+	 * Mongoose - Created, factored out of UnRaider class
243
+	 ------------------------------------------------------*/
244
+
245
+	void initEmitter(char *name, unsigned int size, 
246
+						  unsigned int snowTex1, unsigned int snowTex2);
247
+	/*------------------------------------------------------
248
+	 * Pre  : Textures are init and these args are valid
249
+	 * Post : Emitter is set up for rendering with 2 textures
250
+	 *        in a overhead rain or snow like pattern
251
+	 *
252
+	 *-- History ------------------------------------------
253
+	 *
254
+	 * 2002.12.20:
255
+	 * Mongoose - Created
256
+	 ------------------------------------------------------*/
257
+
258
+	void ClearWorld();
259
+  /*------------------------------------------------------
260
+   * Pre  : 
261
+   * Post : Removes current world/entity/etc geometery
262
+   *
263
+   *-- History ------------------------------------------
264
+   *
265
+   * 2001.05.21: 
266
+   * Mongoose - Created
267
+   ------------------------------------------------------*/
268
+
269
+	void toggleFlag(unsigned int flag);
270
+	void clearFlags(unsigned int flags);
271
+	void setFlags(unsigned int flags);
272
+  /*------------------------------------------------------
273
+   * Pre  : (Un)Sets bitflags for various control use
274
+   * Post : Changes state of renderer in some way
275
+   *
276
+   *-- History ------------------------------------------
277
+   *
278
+   * 2002.03.21: 
279
+   * Mongoose - Created
280
+   ------------------------------------------------------*/
281
+
282
+	void setMode(int n);
283
+  /*------------------------------------------------------
284
+   * Pre  : 
285
+   * Post : 
286
+   *
287
+   *-- History ------------------------------------------
288
+   *
289
+   * 2001.05.21: 
290
+   * Mongoose - Created
291
+   ------------------------------------------------------*/
292
+
293
+	void Update(int width, int height);
294
+  /*------------------------------------------------------
295
+   * Pre  : 
296
+   * Post : 
297
+   *
298
+   *-- History ------------------------------------------
299
+   *
300
+   * 2001.05.21: 
301
+   * Mongoose - Created
302
+   ------------------------------------------------------*/
303
+
304
+	void Display();
305
+  /*------------------------------------------------------
306
+   * Pre  : 
307
+   * Post : Renders a single game frame
308
+   *
309
+   *-- History ------------------------------------------
310
+   *
311
+   * 2001.05.21: 
312
+   * Mongoose - Created
313
+   ------------------------------------------------------*/
314
+	
315
+	void setSkyMesh(int index, bool rot);
316
+  /*------------------------------------------------------
317
+   * Pre  : 
318
+   * Post : 
319
+   *
320
+   *-- History ------------------------------------------
321
+   *
322
+   * 2001.05.21: 
323
+   * Mongoose - Created
324
+   ------------------------------------------------------*/
325
+	
326
+	void ViewModel(entity_t *ent, int index);
327
+  /*------------------------------------------------------
328
+   * Pre  : 
329
+   * Post : 
330
+   *
331
+   *-- History ------------------------------------------
332
+   *
333
+   * 2001.05.21: 
334
+   * Mongoose - Created
335
+   ------------------------------------------------------*/
336
+	
337
+	void RegisterCamera(Camera *camera);
338
+  /*------------------------------------------------------
339
+   * Pre  : 
340
+   * Post : 
341
+   *
342
+   *-- History ------------------------------------------
343
+   *
344
+   * 2001.05.21: 
345
+   * Mongoose - Created
346
+   ------------------------------------------------------*/
347
+
348
+   GLString *GetString();
349
+   /*------------------------------------------------------
350
+    * Pre  : 
351
+    * Post : Returns GL text output agent
352
+    *
353
+    *-- History ------------------------------------------
354
+    *
355
+    * 2002.01.04: 
356
+    * Mongoose - Created
357
+    ------------------------------------------------------*/
358
+
359
+	// FIXME: Should be private
360
+   void drawLoadScreen();
361
+   /*------------------------------------------------------
362
+    * Pre  : Texture is init
363
+    * Post : Renders load screen
364
+    *
365
+    *-- History ------------------------------------------
366
+    *
367
+    * 2002.01.01: 
368
+    * Mongoose - Created
369
+    ------------------------------------------------------*/
370
+
371
+	void addSkeletalModel(SkeletalModel *mdl);
372
+   /*------------------------------------------------------
373
+    * Pre  :
374
+    * Post :
375
+    *
376
+    *-- History ------------------------------------------
377
+    *
378
+    * 2002.01.01: 
379
+    * Mongoose - Created
380
+    ------------------------------------------------------*/
381
+
382
+
383
+private:
384
+
385
+	////////////////////////////////////////////////////////////
386
+	// Private Accessors
387
+	////////////////////////////////////////////////////////////
388
+
389
+	bool isVisible(float bboxMin[3], float bboxMax[3]);
390
+	/*------------------------------------------------------
391
+	 * Pre  : Abstract bounding box must be valid
392
+	 * Post : If object's bounding box is in viewing volume
393
+	 *        return true, else false
394
+	 *
395
+	 *-- History ------------------------------------------
396
+	 *
397
+	 * 2002.12.16:
398
+	 * Mongoose - Moved to Render class
399
+	 *
400
+	 * 2001.06.06: 
401
+	 * Mongoose - Created
402
+	 ------------------------------------------------------*/
403
+
404
+	bool isVisible(float x, float y, float z);
405
+	/*------------------------------------------------------
406
+	 * Pre  : 
407
+	 * Post : Is point in view volume?
408
+	 *
409
+	 *-- History ------------------------------------------
410
+	 *
411
+	 * 2002.12.16:
412
+	 * Mongoose - Created
413
+	 ------------------------------------------------------*/
414
+
415
+	bool isVisible(float x, float y, float z, float radius);
416
+	/*------------------------------------------------------
417
+	 * Pre  : 
418
+	 * Post : Is sphere in view volume?
419
+	 *
420
+	 *-- History ------------------------------------------
421
+	 *
422
+	 * 2002.12.16:
423
+	 * Mongoose - Created
424
+	 ------------------------------------------------------*/
425
+
426
+
427
+	////////////////////////////////////////////////////////////
428
+	// Private Mutators
429
+	////////////////////////////////////////////////////////////
430
+
431
+	void newRoomRenderList(int index);
432
+   /*------------------------------------------------------
433
+    * Pre  : room index is valid
434
+    * Post : Build a visible room list starting at index
435
+    *
436
+    *-- History ------------------------------------------
437
+    *
438
+    * 2002.01.01: 
439
+    * Mongoose - Created
440
+    ------------------------------------------------------*/
441
+
442
+	void buildRoomRenderList(RenderRoom *room);
443
+   /*------------------------------------------------------
444
+    * Pre  : room is valid
445
+    * Post : Build a visible room list starting from room
446
+	 *        and only consider it's linked rooms and their
447
+	 *        linked rooms
448
+    *
449
+    *-- History ------------------------------------------
450
+    *
451
+    * 2002.01.01: 
452
+    * Mongoose - Created
453
+    ------------------------------------------------------*/
454
+
455
+	void drawObjects();
456
+   /*------------------------------------------------------
457
+    * Pre  : Texture is init
458
+    * Post : Renders visible world objects
459
+    *
460
+    *-- History ------------------------------------------
461
+    *
462
+    * 2002.01.01: 
463
+    * Mongoose - Created
464
+    ------------------------------------------------------*/
465
+
466
+	void drawSkyMesh(float scale);
467
+   /*------------------------------------------------------
468
+    * Pre  : Texture is init
469
+	 *        scale is correct for map size
470
+    * Post : Renders Sky domes/boxes/etc by scaling factor
471
+    *
472
+    *-- History ------------------------------------------
473
+    *
474
+    * 2002.01.01: 
475
+    * Mongoose - Created
476
+    ------------------------------------------------------*/
477
+
478
+	void drawModel(SkeletalModel *model);
479
+   /*------------------------------------------------------
480
+    * Pre  : Texture is init
481
+    * Post : Renders a skeletal model
482
+    *
483
+    *-- History ------------------------------------------
484
+    *
485
+    * 2002.01.01: 
486
+    * Mongoose - Created
487
+    ------------------------------------------------------*/
488
+
489
+	void drawRoom(RenderRoom *rRoom, bool draw_alpha);
490
+   /*------------------------------------------------------
491
+    * Pre  : Texture is init
492
+	 *        Draw all rooms with alpha false, then
493
+	 *        draw with alpha true
494
+	 *
495
+    * Post : Renders a room in 2 seperate passes to
496
+	 *        handle alpha, currently doesn't sort alpha
497
+	 *        but looks pretty good
498
+    *
499
+    *-- History ------------------------------------------
500
+    *
501
+    * 2002.01.01: 
502
+    * Mongoose - Created
503
+    ------------------------------------------------------*/
504
+	
505
+	void drawRoomModel(static_model_t *mesh);
506
+   /*------------------------------------------------------
507
+    * Pre  : Texture is init
508
+    * Post : Renders static room model
509
+    *
510
+    *-- History ------------------------------------------
511
+    *
512
+    * 2002.01.01: 
513
+    * Mongoose - Created
514
+    ------------------------------------------------------*/
515
+	
516
+	void drawModelMesh(model_mesh_t *r_mesh, RenderMeshType type);
517
+   /*------------------------------------------------------
518
+    * Pre  : Texture is init, type is object containing mesh
519
+    * Post : Renders a mesh
520
+    *
521
+    *-- History ------------------------------------------
522
+    *
523
+    * 2002.01.01: 
524
+    * Mongoose - Created
525
+    ------------------------------------------------------*/
526
+	
527
+	void drawSprite(sprite_t *sprite);
528
+   /*------------------------------------------------------
529
+    * Pre  : Texture is init
530
+    * Post : Renders a sprite
531
+    *
532
+    *-- History ------------------------------------------
533
+    *
534
+    * 2002.01.01: 
535
+    * Mongoose - Created
536
+    ------------------------------------------------------*/
537
+
538
+	void updateViewVolume();
539
+	/*------------------------------------------------------
540
+	 * Pre  : Call once per render frame
541
+	 * Post : Updated view volume
542
+	 *
543
+	 *-- History ------------------------------------------
544
+	 *
545
+	 * 2002.12.16:
546
+	 * Mongoose - Created
547
+	 ------------------------------------------------------*/
548
+
549
+	void tmpRenderModelMesh(model_mesh_t *r_mesh, texture_tri_t *ttri);
550
+	/*------------------------------------------------------
551
+	 * Pre  : 
552
+	 * Post : Let them eat cake...
553
+	 *
554
+	 *-- History ------------------------------------------
555
+	 *
556
+	 * 2003.05.19:
557
+	 * Mongoose - Created
558
+	 ------------------------------------------------------*/
559
+
560
+
561
+
562
+#ifdef USING_EMITTER
563
+	Emitter *mEmitter;      /* Particle emitter test */
564
+#endif
565
+
566
+	Texture mTexture;       /* Texture subsystem */
567
+
568
+	Camera *mCamera;        /* Camera subsystem */
569
+
570
+	GLString mString;       /* GL Text subsystem */
571
+
572
+	Vector<RenderRoom *> mRoomRenderList;
573
+
574
+	Vector<RenderRoom *> mRooms;
575
+
576
+	Vector<SkeletalModel *> mModels;
577
+
578
+	unsigned int mFlags;    /* Rendering flags */
579
+
580
+	unsigned int mWidth;    /* Viewport width */
581
+
582
+	unsigned int mHeight;   /* Viewport height */
583
+
584
+	unsigned int mMode;     /* Rendering mode */
585
+
586
+	unsigned int *mNumTexturesLoaded;
587
+
588
+	unsigned int *mNextTextureId;
589
+
590
+	float mSplash;
591
+
592
+	int mLock;
593
+
594
+	int mSkyMesh;           /* Skymesh model id */
595
+
596
+	bool mSkyMeshRotation;  /* Should Skymesh be rotated? */
597
+};
598
+
599
+#endif

+ 591
- 0
src/SDLSystem.cpp 파일 보기

@@ -0,0 +1,591 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : OpenRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : SDL
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: 
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2003.06.30, 
19
+ * Mongoose - SDL_TTF support moved to Texture class
20
+ *
21
+ * 2003.06.03:
22
+ * Mongoose - SDL_TTF support based on Sam Lantinga's public domain
23
+ *            SDL_TTF demo functions and algorithms 
24
+ *
25
+ * 2002.06.06:
26
+ * Mongoose - Created
27
+ =================================================================*/
28
+
29
+
30
+#include <stdlib.h>
31
+#include <stdio.h>
32
+#include <string.h>
33
+
34
+#ifdef MEMEORY_TEST
35
+#   include "memeory_test.h"
36
+#endif
37
+
38
+#ifdef HAVE_OPENGL
39
+#   include <GL/gl.h>
40
+#   include <GL/glu.h>
41
+#else
42
+#   error "SDLSystem requires -DHAVE_OPENGL"
43
+#endif
44
+
45
+#ifdef PS2_LINUX
46
+#   include "ps2.h"
47
+#endif
48
+
49
+#include "SDLSystem.h"
50
+
51
+
52
+unsigned int *gWidth = 0x0;
53
+unsigned int *gHeight = 0x0;
54
+
55
+/* 500, 50 */
56
+void glDrawGrid(float size, float step)
57
+{
58
+	float x, y;
59
+
60
+
61
+	// Draw grid
62
+	glPushMatrix();
63
+	glScalef(2.0f, 2.0f, 2.0f);
64
+	glColor3f(0.4f, 0.4f, 0.6f);
65
+
66
+	for (x = -size; x < size; x += step)
67
+	{
68
+		glBegin(GL_LINE_LOOP);
69
+		for (y = -size; y < size; y += step)
70
+		{
71
+			glVertex3f(x + step, 0.0f, y);	
72
+			glVertex3f(x, 0.0f, y);	
73
+			glVertex3f(x, 0.0f, y + step);
74
+			glVertex3f(x + step, 0.0f, y + step);
75
+		}
76
+		glEnd();
77
+	}
78
+
79
+	glPopMatrix();
80
+}
81
+
82
+void glDrawAxis(float length, float arrowLenght)
83
+{
84
+	/* Draw axis list to show bone orientation */
85
+	glBegin(GL_LINES);
86
+
87
+	/* X axis */
88
+	glColor3f(1.0f, 0.0f, 0.0f);
89
+	glVertex3f(-8.0f, 0.0f, 0.0f);
90
+	glVertex3f(8.0f, 0.0f, 0.0f);
91
+
92
+	/* X direction */
93
+	glVertex3f(8.0f, 0.0f, 0.0f);
94
+	glVertex3f(7.0f, 1.0f, 0.0f);
95
+	glVertex3f(8.0f, 0.0f, 0.0f);
96
+	glVertex3f(7.0f, -1.0f, 0.0f);
97
+
98
+	/* Y axis */
99
+	glColor3f(0.0f, 1.0f, 0.0f);
100
+	glVertex3f(0.0f, -8.0f, 0.0f);
101
+	glVertex3f(0.0f, 8.0f, 0.0f);
102
+
103
+	/* Y direction */
104
+	glVertex3f(0.0f, 8.0f, 0.0f);
105
+	glVertex3f(0.0f, 7.0f, 1.0f);
106
+	glVertex3f(0.0f, 8.0f, 0.0f);
107
+	glVertex3f(0.0f, 7.0f, -1.0f);
108
+
109
+	/* Z axis */
110
+	glColor3f(0.0f, 0.0f, 1.0f);
111
+	glVertex3f(0.0f, 0.0f, -8.0f);
112
+	glVertex3f(0.0f, 0.0f, 8.0f);
113
+
114
+	/* Z direction */
115
+	glVertex3f(0.0f, 0.0f, 8.0f);
116
+	glVertex3f(0.0f, 1.0f, 7.0f);
117
+	glVertex3f(0.0f, 0.0f, 8.0f);
118
+	glVertex3f(0.0f, -1.0f, 7.0f);
119
+
120
+	glEnd();
121
+}
122
+
123
+
124
+////////////////////////////////////////////////////////////
125
+// Constructors
126
+////////////////////////////////////////////////////////////
127
+
128
+SDLSystem::SDLSystem() : System()
129
+{
130
+	mWindow = 0x0;
131
+	gWidth = &m_width;
132
+	gHeight = &m_height;
133
+}
134
+
135
+
136
+SDLSystem::~SDLSystem()
137
+{
138
+}
139
+
140
+
141
+////////////////////////////////////////////////////////////
142
+// Public Accessors
143
+////////////////////////////////////////////////////////////
144
+
145
+unsigned int SDLSystem::getTicks()
146
+{
147
+	return SDL_GetTicks();
148
+}
149
+
150
+
151
+////////////////////////////////////////////////////////////
152
+// Public Mutators
153
+////////////////////////////////////////////////////////////
154
+
155
+#ifdef FIXME
156
+void SDLSystem::bindKeyCommand(char *cmd, int key, int event)
157
+{
158
+	if (key > 255)
159
+	{
160
+		printf("Currently key event mapping only handles ASCII characters\n");
161
+		return;
162
+	}
163
+
164
+	printf("Bound command '%s' -> event %i (0x%x key)\n", cmd, event, key);
165
+	
166
+	keyEvents[key] = event;
167
+}
168
+#endif
169
+
170
+
171
+
172
+void SDLSystem::glPrintf2d(float x, float y, char *string)
173
+{
174
+#ifdef HAVE_SDL_TTF
175
+#   ifdef FIXME
176
+	// FIXME: Filler
177
+	glBindTexture(GL_TEXTURE_2D, texture);
178
+	glBegin(GL_TRIANGLE_STRIP);
179
+	glTexCoord2f(texMinX, texMinY); glVertex2i(x,   y  );
180
+	glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y  );
181
+	glTexCoord2f(texMinX, texMaxY); glVertex2i(x,   y+h);
182
+	glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h);
183
+	glEnd();
184
+#   endif
185
+#endif
186
+}
187
+
188
+
189
+void SDLSystem::glPrintf3d(float x, float y, float z, char *string)
190
+{
191
+#ifdef HAVE_SDL_TTF_FIXME
192
+	// FIXME: Filler
193
+	// FIXME: Billboarding here requires a yaw jackass   =)
194
+	glBindTexture(GL_TEXTURE_2D, texture);
195
+	glBegin(GL_TRIANGLE_STRIP);
196
+	glTexCoord2f(texMinX, texMinY); glVertex2i(x,   y  );
197
+	glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y  );
198
+	glTexCoord2f(texMinX, texMaxY); glVertex2i(x,   y+h);
199
+	glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h);
200
+	glEnd();
201
+#endif
202
+}
203
+
204
+
205
+void SDLSystem::setGrabMouse(bool on)
206
+{
207
+	on ? SDL_WM_GrabInput(SDL_GRAB_ON) : SDL_WM_GrabInput(SDL_GRAB_OFF);
208
+}
209
+
210
+
211
+void SDLSystem::initVideo(unsigned int width, unsigned int height, 
212
+								  bool fullscreen)
213
+{
214
+	int flags; //, x, y;
215
+
216
+
217
+	// Create GL context
218
+	SDL_Init(SDL_INIT_VIDEO);
219
+	printf("@Created OpenGL Context...\n");
220
+	atexit(SDL_Quit);
221
+
222
+	m_width = width;
223
+	m_height = height;
224
+
225
+	if (!m_driver || !m_driver[0] || SDL_GL_LoadLibrary(m_driver) < 0)
226
+	{
227
+		SDL_ClearError();
228
+		
229
+		// Fallback 1
230
+		if (SDL_GL_LoadLibrary("libGL.so") < 0)
231
+		{
232
+			SDL_ClearError();
233
+    
234
+			// Fallback 2
235
+			if (SDL_GL_LoadLibrary("libGL.so.1") < 0)
236
+			{
237
+				fprintf(stderr, "initVideo> SDL_GL_LoadLibrary failed!\n");
238
+				fprintf(stderr, "initVideo> Error is [%s].\n", SDL_GetError());
239
+				shutdown(1);
240
+			}
241
+		}
242
+	}
243
+
244
+	flags = 0;
245
+
246
+	flags |= SDL_OPENGL;
247
+
248
+	if (fullscreen)
249
+	{
250
+		flags |= SDL_FULLSCREEN;
251
+		SDL_ShowCursor(SDL_DISABLE);
252
+	}
253
+
254
+	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
255
+	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
256
+	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
257
+	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
258
+	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
259
+	mWindow = SDL_SetVideoMode(width, height, 16, flags);
260
+	SDL_WM_SetCaption(VERSION, VERSION);
261
+	//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
262
+	SDL_EnableKeyRepeat(100, SDL_DEFAULT_REPEAT_INTERVAL);
263
+
264
+#ifdef UNICODE_SUPPORT
265
+	//@JML get Unicode value of key for international keyboard
266
+	SDL_EnableUNICODE(1);
267
+#endif
268
+
269
+	// Start game renderer
270
+	initGL();
271
+	
272
+	// Resize context
273
+	resizeGL(width, height);
274
+}
275
+
276
+
277
+void SDLSystem::resize(unsigned int width, unsigned int height)
278
+{
279
+	GLfloat aspect;
280
+
281
+	
282
+	m_width = width;
283
+	m_height = height;
284
+
285
+	aspect = (GLfloat)width/(GLfloat)height;
286
+
287
+	glViewport(0, 0, width, height); 
288
+
289
+	glMatrixMode(GL_PROJECTION);
290
+	glLoadIdentity();
291
+	gluPerspective(m_fovY, aspect, m_clipNear, m_clipFar);
292
+
293
+	glMatrixMode(GL_MODELVIEW);
294
+	glLoadIdentity();
295
+
296
+	// Resize window
297
+	mWindow = SDL_SetVideoMode(width, height, 16, SDL_OPENGL);
298
+
299
+	// Resize context
300
+	resizeGL(width, height);
301
+}
302
+
303
+
304
+void SDLSystem::runGame()
305
+{
306
+	SDL_Event event;
307
+	unsigned int mkeys, mod, key;
308
+	int btn;
309
+	bool specialKey;
310
+
311
+
312
+	for (;;)
313
+	{
314
+		// Pause for 10-20 ms
315
+		SDL_Delay(10);
316
+
317
+		while (SDL_PollEvent(&event))
318
+		{
319
+			switch (event.type)
320
+			{
321
+			case SDL_QUIT:
322
+				shutdown(0);
323
+				break;
324
+			case SDL_MOUSEMOTION:
325
+				// Wrap motion
326
+				handleMouseMotionEvent(event.motion.xrel*2, event.motion.yrel*2);
327
+				break;
328
+			case SDL_MOUSEBUTTONDOWN:
329
+			case SDL_MOUSEBUTTONUP:
330
+				//handleMouseEvent(event.button.button, event.button.state,
331
+				//			          event.button.x, event.button.y);
332
+
333
+				switch (event.button.button)
334
+				{
335
+				case SDL_BUTTON_LEFT:
336
+					btn = SYS_MOUSE_LEFT;
337
+					break; 
338
+				case SDL_BUTTON_RIGHT:
339
+					btn = SYS_MOUSE_RIGHT;
340
+					break; 
341
+				case SDL_BUTTON_MIDDLE:
342
+					btn = SYS_MOUSE_MIDDLE;
343
+					break;
344
+				}
345
+
346
+				if (event.button.state == SDL_PRESSED)
347
+				{
348
+					handleKeyPressEvent(btn, 0); // FIXME: mod not used
349
+				}
350
+				else
351
+				{
352
+					handleKeyReleaseEvent(btn, 0); // FIXME: mod not used
353
+				}
354
+				break;
355
+			case SDL_KEYUP:	
356
+			case SDL_KEYDOWN:
357
+				//SDL_GetMouseState(&x, &y); // Get cursor pos
358
+
359
+				mkeys = (unsigned int)SDL_GetModState();
360
+				mod = 0;
361
+
362
+				if (mkeys & KMOD_LSHIFT)
363
+					mod |= SYS_MOD_KEY_LSHIFT;
364
+
365
+				if (mkeys & KMOD_RSHIFT)
366
+					mod |= SYS_MOD_KEY_RSHIFT;
367
+
368
+				if (mkeys & KMOD_LCTRL)
369
+					mod |= SYS_MOD_KEY_LCTRL;
370
+
371
+				if (mkeys & KMOD_RCTRL)
372
+					mod |= SYS_MOD_KEY_RCTRL;
373
+
374
+				if (mkeys & KMOD_LALT)
375
+					mod |= SYS_MOD_KEY_LALT;
376
+
377
+				if (mkeys & KMOD_RALT)
378
+					mod |= SYS_MOD_KEY_RALT;
379
+
380
+				key = event.key.keysym.sym;
381
+				specialKey = false;
382
+
383
+				switch (key)
384
+				{
385
+				case SDLK_F1:
386
+					key = SYS_KEY_F1;
387
+					specialKey = true;
388
+					break;
389
+				case SDLK_F2:
390
+					key = SYS_KEY_F2;
391
+					specialKey = true;
392
+					break;
393
+				case SDLK_F3:
394
+					key = SYS_KEY_F3;
395
+					specialKey = true;
396
+					break;
397
+				case SDLK_F4:
398
+					key = SYS_KEY_F4;
399
+					specialKey = true;
400
+					break;
401
+				case SDLK_F5:
402
+					key = SYS_KEY_F5;
403
+					specialKey = true;
404
+					break;
405
+				case SDLK_F6:
406
+					key = SYS_KEY_F6;
407
+					specialKey = true;
408
+					break;
409
+				case SDLK_F7:
410
+					key = SYS_KEY_F7;
411
+					specialKey = true;
412
+					break;
413
+				case SDLK_F8:
414
+					key = SYS_KEY_F8;
415
+					specialKey = true;
416
+					break;
417
+				case SDLK_F9:
418
+					key = SYS_KEY_F9;
419
+					specialKey = true;
420
+					break;
421
+				case SDLK_F10:
422
+					key = SYS_KEY_F10;
423
+					specialKey = true;
424
+					break;
425
+				case SDLK_F11:
426
+					key = SYS_KEY_F11;
427
+					specialKey = true;
428
+					break;
429
+				case SDLK_F12:
430
+					key = SYS_KEY_F12;
431
+					specialKey = true;
432
+					break;
433
+				case SDLK_UP:
434
+					key = SYS_KEY_UP;
435
+					specialKey = true;
436
+					break;
437
+				case SDLK_DOWN:
438
+					key = SYS_KEY_DOWN;
439
+					specialKey = true;
440
+					break;
441
+				case SDLK_RIGHT:
442
+					key = SYS_KEY_RIGHT;
443
+					specialKey = true;
444
+					break;
445
+				case SDLK_LEFT:
446
+					key = SYS_KEY_LEFT;
447
+					specialKey = true;
448
+					break;
449
+				case SDLK_PAGEDOWN:
450
+					key = SYS_KEY_PAGEDOWN;
451
+					specialKey = true;
452
+					break;
453
+				case SDLK_PAGEUP:
454
+					key = SYS_KEY_PAGEUP;
455
+					specialKey = true;
456
+					break;
457
+				}
458
+
459
+#ifdef UNICODE_SUPPORT
460
+				// JML: if a std key was pressed get it ascii code
461
+				if (!specialKey && key != 0)
462
+				{
463
+					if ((event.key.keysym.unicode & 0xFF80) == 0)
464
+					{
465
+						key= (unsigned int)(event.key.keysym.unicode & 0x7F);
466
+					}
467
+					else 
468
+					{
469
+						key = 0;
470
+					}
471
+				}
472
+#else
473
+				// FIXME: Avoid passing modifers as a key, since the 
474
+				// consoles using this expect text characters, add unicode
475
+				// support later when they're able to handle it
476
+				if (key > 255 && key < 1000)
477
+				{
478
+					key = 0;
479
+				}
480
+#endif
481
+				
482
+				if (key == mConsoleKey)
483
+				{
484
+					if (event.type == SDL_KEYDOWN)
485
+					{
486
+						mConsoleMode = !mConsoleMode;
487
+						// Tmp hack
488
+						handleConsoleKeyPressEvent(mConsoleKey, 0);
489
+					}
490
+				}
491
+				else if (mConsoleMode) // Console keying ( text input )
492
+				{
493
+					switch (event.type)
494
+					{
495
+					case SDL_KEYDOWN:
496
+						handleConsoleKeyPressEvent(key, mod);
497
+						break;
498
+					default:
499
+						;
500
+					}
501
+				}
502
+				else if (mKeyEvents[key] != 0)// Bound key
503
+				{
504
+					//if (key < 255 && mKeyEvents[key] != 0)
505
+					key = mKeyEvents[key];
506
+
507
+					switch (event.type)
508
+					{
509
+					case SDL_KEYDOWN:
510
+						handleBoundKeyPressEvent(key);
511
+						break;
512
+					default:
513
+						handleBoundKeyReleaseEvent(key);
514
+					}
515
+				}
516
+				else // 'Classic' key event handlers
517
+				{
518
+					switch (event.type)
519
+					{
520
+					case SDL_KEYDOWN:
521
+						handleKeyPressEvent(key, mod);
522
+						break;
523
+					default:
524
+						handleKeyReleaseEvent(key, mod);
525
+					}
526
+				}
527
+				break;
528
+			case SDL_VIDEORESIZE:			  
529
+				resizeGL(event.resize.w, event.resize.h);
530
+				gameFrame();
531
+				break;
532
+			}
533
+		}
534
+
535
+		// Game frame
536
+		gameFrame();
537
+	}
538
+}
539
+
540
+
541
+void SDLSystem::shutdown(int i)
542
+{
543
+	//SDL_QuitSubSystem(SDL_OPENGL);
544
+	//SDL_Quit(); // Moved to atexit() call
545
+
546
+	//#ifdef DEBUG_MEMEORY
547
+	//printf("[Mongoose MEMEORY_DEBUG]\nUnfreed memory table:\n");
548
+	//dump_memory_report();
549
+	//#endif
550
+
551
+	exit(0);
552
+}
553
+
554
+
555
+void SDLSystem::toggleFullscreen()
556
+{
557
+	if (mWindow)
558
+	{		
559
+		SDL_ShowCursor(SDL_DISABLE);
560
+		SDL_WM_ToggleFullScreen(mWindow);
561
+	}
562
+}
563
+
564
+
565
+void SDLSystem::swapBuffersGL()
566
+{
567
+	SDL_GL_SwapBuffers();
568
+}
569
+
570
+
571
+////////////////////////////////////////////////////////////
572
+// Unit Test code
573
+////////////////////////////////////////////////////////////
574
+
575
+#ifdef __UNIT_TEST__
576
+int SDL::unitTest(int argc, char *argv[])
577
+{
578
+	return 0;
579
+}
580
+
581
+
582
+int main(int argc, char *argv[])
583
+{
584
+	SDL test;
585
+
586
+
587
+	printf("[SDL class test]\n");
588
+
589
+	return test._UnitTest(argc, argv);
590
+}
591
+#endif

+ 237
- 0
src/SDLSystem.h 파일 보기

@@ -0,0 +1,237 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : OpenRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : SDLSystem
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: 
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------ 
17
+ *
18
+ * 2002.06.06:
19
+ * Mongoose - Created
20
+ ================================================================*/
21
+
22
+
23
+#ifndef GUARD__UNRAIDER_MONGOOSE_SDLSYSTEM_H_
24
+#define GUARD__UNRAIDER_MONGOOSE_SDLSYSTEM_H_
25
+
26
+#ifdef SDL_INTERFACE
27
+#   include <SDL/SDL.h>
28
+#else
29
+#   error "SDLSystem requires -DSDL_INTERFACE"
30
+#endif
31
+
32
+#include "System.h"
33
+
34
+class SDLSystem : public System
35
+{
36
+ public:
37
+
38
+	////////////////////////////////////////////////////////////
39
+	// Constructors
40
+	////////////////////////////////////////////////////////////
41
+
42
+	SDLSystem();
43
+	/*------------------------------------------------------
44
+	 * Pre  : 
45
+	 * Post : Constructs an object of SDLSystem
46
+	 *
47
+	 *-- History ------------------------------------------
48
+	 *
49
+	 * 2002.06.06: 
50
+	 * Mongoose - Created
51
+	 ------------------------------------------------------*/
52
+
53
+	virtual ~SDLSystem();
54
+	/*------------------------------------------------------
55
+	 * Pre  : SDL object is allocated
56
+	 * Post : Deconstructs an object of SDLSystem
57
+	 *
58
+	 *-- History ------------------------------------------
59
+	 *
60
+	 * 2002.06.06: 
61
+	 * Mongoose - Created
62
+	 ------------------------------------------------------*/
63
+
64
+
65
+	////////////////////////////////////////////////////////////
66
+	// Public Accessors
67
+	////////////////////////////////////////////////////////////
68
+
69
+	virtual unsigned int getTicks();
70
+	/*------------------------------------------------------
71
+	 * Pre  : 
72
+	 * Post : Returns number of milliseconds since start of
73
+	 *        program
74
+	 *
75
+	 *-- History ------------------------------------------
76
+	 *
77
+	 * 2002.06.06: 
78
+	 * Mongoose - Created
79
+	 ------------------------------------------------------*/
80
+
81
+
82
+	////////////////////////////////////////////////////////////
83
+	// Public Mutators
84
+	////////////////////////////////////////////////////////////
85
+
86
+	//FIXME: void bindKeyCommand(char *cmd, int key, int event);
87
+	/*------------------------------------------------------
88
+	 * Pre  : <Cmd> is a valid command string
89
+	 *        <Key> is a valid keyboard code
90
+	 *        <Event> is a valid game event Id
91
+	 *
92
+	 * Post : Sets <Event> binding <Cmd> to <Key> press 
93
+	 *
94
+	 *-- History ------------------------------------------
95
+	 *
96
+	 * 2003.06.03:
97
+	 * Mongoose - Created
98
+	 ------------------------------------------------------*/
99
+
100
+   void glPrintf2d(float x, float y, char *string);
101
+   /*------------------------------------------------------
102
+    * Pre  : <X>, and <Y> are valid world coordinates
103
+	 *        <String> is a valid string
104
+	 *     
105
+	 *        Requires glEnterMode2d() call before entry
106
+	 *
107
+	 *        System::bufferString(..) can cache printf()
108
+	 *        style calls for use with this method
109
+	 *
110
+    * Post : Renders string in OpenGL ( 2d projection )
111
+	 *
112
+	 *        Call glExitMode2d() after finishing calls
113
+	 *        to this method and other 2d rendering
114
+    *
115
+    *-- History ------------------------------------------
116
+    *
117
+	 * 2003.06.03:
118
+	 * Mongoose - Ported to SDL_TTF
119
+	 *
120
+    * 2001.12.31: 
121
+    * Mongoose - Created
122
+    ------------------------------------------------------*/
123
+
124
+   void glPrintf3d(float x, float y, float z, char *string);
125
+   /*------------------------------------------------------
126
+    * Pre  : <X>, <Y>, and <Z> are valid world coordinates
127
+	 *        <String> is a valid string
128
+	 *
129
+	 *        System::bufferString(..) can cache printf()
130
+	 *        style calls for use with this method
131
+	 *
132
+    * Post : Renders string in OpenGL ( 3d projection )
133
+    *
134
+    *-- History ------------------------------------------
135
+    *
136
+	 * 2003.06.03:
137
+	 * Mongoose - Ported to SDL_TTF
138
+	 *
139
+    * 2001.12.31: 
140
+    * Mongoose - Created
141
+    ------------------------------------------------------*/
142
+
143
+	void initVideo(unsigned int width, unsigned int height, 
144
+						bool fullscreen);
145
+	/*------------------------------------------------------
146
+	 * Pre  : Video mode request <Width> x <Height>
147
+	 *        <Fullscreen> enables fullscreen rendering
148
+	 *
149
+	 * Post : Start up video subsystem
150
+	 *
151
+	 *-- History ------------------------------------------
152
+	 *
153
+	 * 2002.06.06: 
154
+	 * Mongoose - Created
155
+	 ------------------------------------------------------*/
156
+
157
+	void resize(unsigned int width, unsigned int height);
158
+	/*------------------------------------------------------
159
+	 * Pre  : 
160
+	 * Post : Resizes game window
161
+	 *
162
+	 *-- History ------------------------------------------
163
+	 *
164
+	 * 2002.06.06: 
165
+	 * Mongoose - Created, from old SDLUnitTest code
166
+	 ------------------------------------------------------*/
167
+
168
+	void runGame();
169
+	/*------------------------------------------------------
170
+	 * Pre  : 
171
+	 * Post : Start game loop
172
+	 *
173
+	 *-- History ------------------------------------------
174
+	 *
175
+	 * 2002.06.06: 
176
+	 * Mongoose - Created
177
+	 ------------------------------------------------------*/
178
+
179
+	void setGrabMouse(bool on);
180
+	/*------------------------------------------------------
181
+	 * Pre  : 
182
+	 * Post : 
183
+	 *
184
+	 *-- History ------------------------------------------
185
+	 *
186
+	 * 2003.01.05:
187
+	 * Mongoose - Created
188
+	 ------------------------------------------------------*/
189
+
190
+	void shutdown(int i);
191
+	/*------------------------------------------------------
192
+	 * Pre  : 
193
+	 * Post : Shutsdown the game subsystems, exits game loop
194
+	 *
195
+	 *-- History ------------------------------------------
196
+	 *
197
+	 * 2002.06.06: 
198
+	 * Mongoose - Created
199
+	 ------------------------------------------------------*/
200
+
201
+	void swapBuffersGL();
202
+	/*------------------------------------------------------
203
+	 * Pre  : 
204
+	 * Post : Swaps OpenGL buufers ( call at end of frame )
205
+	 *
206
+	 *-- History ------------------------------------------
207
+	 *
208
+	 * 2002.06.06: 
209
+	 * Mongoose - Created
210
+	 ------------------------------------------------------*/
211
+
212
+	void toggleFullscreen();
213
+	/*------------------------------------------------------
214
+	 * Pre  : 
215
+	 * Post : Toggle fullscreen windowing mode
216
+	 *
217
+	 *-- History ------------------------------------------
218
+	 *
219
+	 * 2002.06.06: 
220
+	 * Mongoose - Created
221
+	 ------------------------------------------------------*/
222
+
223
+
224
+ private:
225
+
226
+	////////////////////////////////////////////////////////////
227
+	// Private Accessors
228
+	////////////////////////////////////////////////////////////
229
+
230
+
231
+	////////////////////////////////////////////////////////////
232
+	// Private Mutators
233
+	////////////////////////////////////////////////////////////
234
+	
235
+	SDL_Surface *mWindow;	/* This is the pointer to the SDL surface */
236
+};
237
+#endif

+ 597
- 0
src/SDLUnitTest.cpp 파일 보기

@@ -0,0 +1,597 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+#ifdef SDL_UNIT_TEST
3
+#include <stdio.h>
4
+#include <string.h>
5
+#include <stdlib.h>
6
+
7
+#ifdef USING_OPENGL
8
+
9
+#   include <GL/gl.h>
10
+#   include <GL/glu.h>
11
+#   include <SDL/SDL.h>
12
+#   include <Texture.h>
13
+
14
+// Implement these functions in your Unit Test
15
+void renderScene(float time, float lastTime);
16
+void handleKey(int key);
17
+void handleArgKey(char key);
18
+void initScene(int argc, char *argv[]);
19
+
20
+// Call this function to start SDL Unit Test
21
+int runSDLUnitTest(int argc, char *argv[]);
22
+
23
+//////////////////////////////////////////////////////////////////
24
+Texture gTexture;
25
+
26
+char gTitle[128];
27
+float gYaw = 0.0f;
28
+bool gYawOn = true;
29
+float gPitch = -20.0f;
30
+float gScale = 1.0f;
31
+float gLightPos[] = { 0.0, 512.0, 1024.0, 0.0 };
32
+unsigned int gWidth = 640, gHeight = 460;
33
+
34
+
35
+void event_resize(unsigned int width, unsigned int height);
36
+
37
+void handle_key(int key)
38
+{
39
+	static bool wireframe = false;
40
+	static bool alphaBlend = false;
41
+	static bool lighting = false;
42
+
43
+	switch (key)
44
+	{
45
+	case SDLK_F5:
46
+		wireframe = !wireframe;
47
+
48
+		if (wireframe)
49
+		{
50
+			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 
51
+		}
52
+		else
53
+		{
54
+			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
55
+		}
56
+
57
+		printf("%sabled wireframe rendering\n", wireframe ? "En" : "Dis");
58
+		break;
59
+	case SDLK_F6:
60
+		alphaBlend = !alphaBlend;
61
+
62
+		if (alphaBlend)
63
+		{
64
+			glEnable(GL_BLEND);
65
+			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
66
+			glAlphaFunc(GL_GREATER, 0);
67
+		}
68
+		else
69
+		{
70
+			glDisable(GL_BLEND);
71
+		}
72
+
73
+		printf("%sabled alpha blending\n", alphaBlend  ? "En" : "Dis");
74
+		break;
75
+	case SDLK_F7:
76
+		lighting = !lighting;
77
+
78
+		if (lighting)
79
+		{
80
+			static bool firsttime = true;
81
+
82
+
83
+			glEnable(GL_LIGHTING);
84
+
85
+			if (firsttime)
86
+			{
87
+				float specular[] = { 0.6, 0.6, 0.6, 1.0 };
88
+				float ambient[] = { 0.64, 0.64, 0.64, 1.0 };
89
+				float shine[] = { 50.0 };
90
+
91
+
92
+				// Caustic fx possible with mod amb?
93
+				glMaterialfv(GL_FRONT, GL_SPECULAR,  specular);
94
+				glMaterialfv(GL_FRONT, GL_AMBIENT,   ambient);
95
+				//glMaterialfv(GL_FRONT, GL_DIFFUSE,   ambient);
96
+				glMaterialfv(GL_FRONT, GL_SHININESS, shine);
97
+				glLightfv(GL_LIGHT0,   GL_POSITION,  gLightPos);
98
+				glEnable(GL_LIGHT0);
99
+
100
+				glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0);
101
+
102
+				//glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0);
103
+				//glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, WHITE);
104
+				//glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, WHITE);
105
+				//glLightModelfv(GL_LIGHT_MODEL_AMBIENT, DIM_WHITE);
106
+				//glLightf(GL_LIGHT0,  GL_SPOT_CUTOFF,    cutoff);
107
+				//glLightfv(GL_LIGHT0, GL_POSITION,       pos);
108
+				//glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, dir);
109
+				//glLightfv(GL_LIGHT0, GL_DIFFUSE,        color);
110
+
111
+				firsttime = false;
112
+			}
113
+		}
114
+		else
115
+		{
116
+			glDisable(GL_LIGHTING);
117
+		}
118
+		break;
119
+	case SDLK_F8:
120
+		gYawOn = !gYawOn;
121
+		break;
122
+	case SDLK_F9:
123
+		gTexture.glScreenShot("screenshot", gWidth, gHeight);
124
+		break;
125
+	case SDLK_F10:
126
+		event_resize(640, 460);
127
+		break;
128
+	case SDLK_F11:
129
+		event_resize(800, 600);
130
+		break;
131
+	case SDLK_F12:
132
+		event_resize(1024, 768);
133
+		break;
134
+	case SDLK_RIGHT:
135
+		++gYaw;
136
+		break;
137
+	case SDLK_LEFT:
138
+		--gYaw;
139
+		break;
140
+	case SDLK_UP:
141
+		++gPitch;
142
+		break;
143
+	case SDLK_DOWN:
144
+		--gPitch;
145
+		break;
146
+	case '-':
147
+		if (gScale *= 0.75f > 0.000001)
148
+			gScale *= 0.75f;
149
+		break;
150
+	case '=':
151
+		gScale *= 1.25f;
152
+		break;
153
+	case 'i':
154
+		gLightPos[1] += 16.0f;
155
+		glLightfv(GL_LIGHT0,   GL_POSITION,  gLightPos);
156
+		break;
157
+	case 'k':
158
+		gLightPos[1] -= 16.0f;
159
+		glLightfv(GL_LIGHT0,   GL_POSITION,  gLightPos);
160
+		break;
161
+	case 'j':
162
+		gLightPos[2] -= 16.0f;
163
+		glLightfv(GL_LIGHT0,   GL_POSITION,  gLightPos);
164
+		break;
165
+	case 'l':
166
+		gLightPos[2] += 16.0f;
167
+		glLightfv(GL_LIGHT0,   GL_POSITION,  gLightPos);
168
+		break;
169
+	case 'h':
170
+		printf("[SDLUnitTest.test]\n");
171
+		printf("----------------------------------\n");
172
+		printf("ESC        - Exit\n");
173
+		printf("F5         - Toggle wireframe rendering\n");
174
+		printf("F6         - Toggle alpha blending\n");
175
+		printf("F8         - Toggle scene rotation\n");
176
+		printf("F7         - Toggle lighting\n");
177
+		printf("F9         - Take screenshot\n");
178
+		printf("F11        - Set window to 640x460\n");
179
+		printf("F11        - Set window to 800x600\n");
180
+		printf("F12        - Set window to 1024x768\n");
181
+		printf("ALT+ENTER  - Toogle fullscreen\n");
182
+		printf("UP/DOWN    - Adjust scene pitch\n");
183
+		printf("RIGHT/LEFT - Adjust scene yaw\n");
184
+		printf("-/=        - Adjust model scaling\n");
185
+		printf("----------------------------------\n");
186
+		printf("i,k,j,l - Move light\n");
187
+		printf("h          - Help\n");
188
+	default:
189
+		handleKey(key);
190
+	}
191
+}
192
+
193
+
194
+///////////////////////////////////////////////////
195
+
196
+SDL_Surface *gSDLWindow = NULL;
197
+
198
+
199
+void updateWindowTitle(char *newTitle)
200
+{
201
+	static char title[64];
202
+
203
+	memcpy(title, newTitle, 64);
204
+	title[63] = 0;
205
+
206
+	SDL_WM_SetCaption(title, "PSKModel.test");
207
+}
208
+
209
+
210
+unsigned int getTicks()
211
+{
212
+	return SDL_GetTicks();
213
+}
214
+
215
+
216
+void swap_buffers()
217
+{
218
+	SDL_GL_SwapBuffers();
219
+}
220
+
221
+
222
+void event_resize(unsigned int width, unsigned int height)
223
+{
224
+	GLfloat aspect;
225
+
226
+	
227
+	gWidth = width;
228
+	gHeight = height;
229
+
230
+	aspect = (GLfloat)width/(GLfloat)height;
231
+
232
+	glViewport(0, 0, width, height); 
233
+
234
+	glMatrixMode(GL_PROJECTION);
235
+	glLoadIdentity();
236
+	gluPerspective(45.0f, aspect, 8.0f, 4600.0f);
237
+
238
+	glMatrixMode(GL_MODELVIEW);
239
+	glLoadIdentity();
240
+
241
+	// Resize window
242
+	gSDLWindow = SDL_SetVideoMode(width, height, 16, SDL_OPENGL);
243
+}
244
+
245
+
246
+#ifdef FIXME
247
+void draw_axis(float length, float arrowLenght)
248
+{
249
+	/* Draw axis list to show bone orientation */
250
+	glBegin(GL_LINES);
251
+
252
+	/* X axis */
253
+	glColor3f(1.0f, 0.0f, 0.0f);
254
+	glVertex3f(-8.0f, 0.0f, 0.0f);
255
+	glVertex3f(8.0f, 0.0f, 0.0f);
256
+
257
+	/* X direction */
258
+	glVertex3f(8.0f, 0.0f, 0.0f);
259
+	glVertex3f(7.0f, 1.0f, 0.0f);
260
+	glVertex3f(8.0f, 0.0f, 0.0f);
261
+	glVertex3f(7.0f, -1.0f, 0.0f);
262
+
263
+	/* Y axis */
264
+	glColor3f(0.0f, 1.0f, 0.0f);
265
+	glVertex3f(0.0f, -8.0f, 0.0f);
266
+	glVertex3f(0.0f, 8.0f, 0.0f);
267
+
268
+	/* Y direction */
269
+	glVertex3f(0.0f, 8.0f, 0.0f);
270
+	glVertex3f(0.0f, 7.0f, 1.0f);
271
+	glVertex3f(0.0f, 8.0f, 0.0f);
272
+	glVertex3f(0.0f, 7.0f, -1.0f);
273
+
274
+	/* Z axis */
275
+	glColor3f(0.0f, 0.0f, 1.0f);
276
+	glVertex3f(0.0f, 0.0f, -8.0f);
277
+	glVertex3f(0.0f, 0.0f, 8.0f);
278
+
279
+	/* Z direction */
280
+	glVertex3f(0.0f, 0.0f, 8.0f);
281
+	glVertex3f(0.0f, 1.0f, 7.0f);
282
+	glVertex3f(0.0f, 0.0f, 8.0f);
283
+	glVertex3f(0.0f, -1.0f, 7.0f);
284
+
285
+	glEnd();
286
+}
287
+#endif
288
+
289
+
290
+void renderUnitTestScene() 
291
+{
292
+
293
+	static float lastTime = 0.0f;
294
+	const float size = 500.0f, step = 50.0f;
295
+	float x, y, time;
296
+
297
+
298
+	gluLookAt(0.0, 0.0, -256.0, 
299
+				 0.0, 8.0, 0.0, 
300
+				 0.0, 1.0, 0.0);
301
+
302
+	glDisable(GL_TEXTURE_2D);
303
+
304
+	time = getTicks() * 0.1f;
305
+
306
+	if (time - lastTime > 5.0f)
307
+	{
308
+		lastTime = time;
309
+
310
+		if (gYawOn)
311
+			++gYaw;
312
+	}
313
+
314
+#ifdef DRAW_ACTUAL_ORIGIN_AXIS_WITH_ROTATION
315
+	glPushMatrix();
316
+	glRotatef(yaw, 0, 1, 0);
317
+	glBegin(GL_LINES);
318
+	glColor3f(1.0f, 0.0f, 0.0f);
319
+	glVertex3f(0.0f, 0.0f, 0.0f);
320
+	glVertex3f(10.0f, 0.0f, 0.0f);
321
+	glColor3f(0.0f, 1.0f, 0.0f);
322
+	glVertex3f(0.0f, 0.0f, 0.0f);
323
+	glVertex3f(0.0f, 10.0f, 0.0f);
324
+	glColor3f(0.0f, 0.0f, 1.0f);
325
+	glVertex3f(0.0f, 0.0f, 0.0f);
326
+	glVertex3f(0.0f, 0.0f, 10.0f);
327
+	glEnd();
328
+	glPopMatrix();
329
+#endif
330
+
331
+	// Draw light symbol
332
+	glPushMatrix();
333
+	glTranslatef(gLightPos[0], gLightPos[1], gLightPos[2]);
334
+	
335
+	glBegin(GL_LINES);
336
+	glColor3f(1.0f, 1.0f, 1.0f);
337
+	glVertex3f(0.0f, 0.0f, 0.0f);
338
+	glVertex3f(10.0f, 0.0f, 0.0f);
339
+	glVertex3f(0.0f, 0.0f, 0.0f);
340
+	glVertex3f(0.0f, 10.0f, 0.0f);
341
+	glVertex3f(0.0f, 0.0f, 0.0f);
342
+	glVertex3f(0.0f, 0.0f, 10.0f);
343
+	glEnd();
344
+	glPopMatrix();
345
+
346
+	glTranslatef(0.0f, -128.0f, 512.0f);
347
+	glRotatef(gPitch, 1, 0, 0);
348
+	glRotatef(gYaw,   0, 1, 0);
349
+
350
+	// Draw transformed origin axis
351
+	glBegin(GL_LINES);
352
+	glColor3f(1.0f, 0.0f, 0.0f);
353
+	glVertex3f(-30.0f, 0.0f, 0.0f);
354
+	glVertex3f(30.0f, 0.0f, 0.0f);
355
+	glColor3f(0.0f, 1.0f, 0.0f);
356
+	glVertex3f(0.0f, -30.0f, 0.0f);
357
+	glVertex3f(0.0f, 30.0f, 0.0f);
358
+	glColor3f(0.0f, 0.0f, 1.0f);
359
+	glVertex3f(0.0f, 0.0f, -30.0f);
360
+	glVertex3f(0.0f, 0.0f, 30.0f);
361
+	glEnd();
362
+
363
+	// Draw grid
364
+	glPushMatrix();
365
+	glScalef(2.0f, 2.0f, 2.0f);
366
+	glColor3f(0.4f, 0.4f, 0.6f);
367
+
368
+	for (x = -size; x < size; x += step)
369
+	{
370
+		glBegin(GL_LINE_LOOP);
371
+		for (y = -size; y < size; y += step)
372
+		{
373
+			glVertex3f(x + step, 0.0f, y);	
374
+			glVertex3f(x, 0.0f, y);	
375
+			glVertex3f(x, 0.0f, y + step);
376
+			glVertex3f(x + step, 0.0f, y + step);
377
+		}
378
+		glEnd();
379
+	}
380
+
381
+	glPopMatrix();
382
+
383
+	
384
+	glEnable(GL_TEXTURE_2D);
385
+	glColor3f(1.0f, 1.0f, 1.0f);
386
+	glPushMatrix();
387
+	glTranslatef(0.0f, 8.0f, 0.0f);
388
+	glScalef(gScale, gScale, gScale);
389
+
390
+	renderScene(time, lastTime);
391
+
392
+	glPopMatrix();
393
+}
394
+
395
+
396
+void event_display(int width, int height)
397
+{
398
+	glClearColor(0.3, 0.3, 0.5, 1.0);
399
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
400
+	glLoadIdentity();
401
+
402
+	renderUnitTestScene();
403
+
404
+	glFlush();
405
+	swap_buffers();
406
+}
407
+
408
+
409
+void shutdown_gl()
410
+{
411
+	SDL_Quit();
412
+}
413
+
414
+
415
+void init_gl(unsigned int width, unsigned int height)
416
+{
417
+	// Print driver support information
418
+	printf("\n\n\t## GL Driver Info ##\n");
419
+	printf("\tVendor     : %s\n", glGetString(GL_VENDOR));
420
+	printf("\tRenderer   : %s\n", glGetString(GL_RENDERER));
421
+	printf("\tVersion    : %s\n", glGetString(GL_VERSION));
422
+	printf("\tExtensions : %s\n\n\n", (char*)glGetString(GL_EXTENSIONS));
423
+
424
+	// Setup GL
425
+	glClearColor(0.3, 0.3, 0.5, 1.0);
426
+	event_resize(width, height);
427
+
428
+	// Texture setup
429
+	//gTexture.reset();
430
+	//gTexture.setMaxTextureCount(64);
431
+}
432
+
433
+
434
+int main_gl(int argc, char *argv[])
435
+{
436
+  SDL_Event event;
437
+  unsigned int mkeys, mod, key, flags;
438
+  unsigned int width = gWidth;
439
+  unsigned int height = gHeight;
440
+  bool fullscreen = false;
441
+  char *driver = 0x0;
442
+
443
+
444
+  // Setup clean up on exit
445
+  atexit(shutdown_gl);
446
+
447
+  // NOTE: Removed fullscreen/driver option parser args
448
+
449
+  // Create GL context
450
+  SDL_Init(SDL_INIT_VIDEO);
451
+  printf("\n@Created OpenGL Context...\n");
452
+
453
+  if (!driver || !driver[0] || SDL_GL_LoadLibrary(driver) < 0)
454
+  {
455
+	  SDL_ClearError();
456
+
457
+	  // Fallback 1
458
+	  if (SDL_GL_LoadLibrary("libGL.so") < 0)
459
+	  {
460
+		  SDL_ClearError();
461
+    
462
+		  // Fallback 2
463
+		  if (SDL_GL_LoadLibrary("libGL.so.1") < 0)
464
+		  {
465
+			  fprintf(stderr, "main_gl> SDL_GL_LoadLibrary failed!\n");
466
+			  fprintf(stderr, "main_gl> Error is [%s].\n", SDL_GetError());
467
+			  exit(1);
468
+		  }
469
+	  }
470
+  }
471
+
472
+  flags = SDL_OPENGL;
473
+
474
+  if (fullscreen)
475
+  {
476
+	  flags |= SDL_FULLSCREEN;
477
+	  SDL_ShowCursor(SDL_DISABLE);
478
+  }
479
+
480
+  SDL_GL_SetAttribute(SDL_GL_RED_SIZE,     5);
481
+  SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,   5);
482
+  SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,    5);
483
+  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,  16);
484
+  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
485
+  gSDLWindow = SDL_SetVideoMode(width, height, 16, flags);
486
+  SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
487
+  
488
+  // Init rendering
489
+  init_gl(width, height);
490
+  initScene(argc, argv);
491
+
492
+  printf("\n@Starting event loop...\n");
493
+  updateWindowTitle(argv[0]);
494
+
495
+  for (;;)
496
+  {
497
+	  while (SDL_PollEvent(&event))
498
+	  {
499
+		  switch (event.type)
500
+		  {
501
+		  case SDL_QUIT:
502
+			  exit(0);
503
+			  break;
504
+		  case SDL_MOUSEMOTION:
505
+			  break;
506
+		  case SDL_MOUSEBUTTONDOWN:
507
+		  case SDL_MOUSEBUTTONUP:
508
+			  break;	
509
+		  case SDL_KEYDOWN:
510
+			  mkeys = (unsigned int)SDL_GetModState();
511
+			  mod = 0;
512
+
513
+			  if (mkeys & KMOD_LSHIFT)
514
+				  mod |= KMOD_LSHIFT;
515
+
516
+			  if (mkeys & KMOD_RSHIFT)
517
+				  mod |= KMOD_RSHIFT;
518
+
519
+			  if (mkeys & KMOD_LCTRL)
520
+				  mod |= KMOD_LCTRL;
521
+
522
+			  if (mkeys & KMOD_RCTRL)
523
+				  mod |= KMOD_RCTRL;
524
+
525
+			  if (mkeys & KMOD_LALT)
526
+				  mod |= KMOD_LALT;
527
+
528
+			  if (mkeys & KMOD_RALT)
529
+				  mod |= KMOD_RALT;
530
+
531
+			  key = event.key.keysym.sym;
532
+
533
+			  switch (key)
534
+			  {
535
+			  case SDLK_ESCAPE: // 0x1B, 27d, ESC
536
+				  exit(0);
537
+				  break;
538
+			  case SDLK_RETURN:
539
+				  if (mod & KMOD_LALT)
540
+				  {
541
+					  SDL_ShowCursor(SDL_DISABLE);
542
+					  SDL_WM_ToggleFullScreen(gSDLWindow);
543
+				  }
544
+			  }
545
+			  
546
+			  handle_key(key);
547
+			  break;
548
+		  case SDL_KEYUP:
549
+			  break;
550
+		  case SDL_VIDEORESIZE:			  
551
+			  event_resize(event.resize.w, event.resize.h);
552
+
553
+			  width = event.resize.w;
554
+			  height = event.resize.h;
555
+			  event_display(width, height);
556
+			  break;
557
+		  }
558
+	  }
559
+
560
+	  event_display(width, height);
561
+  }
562
+  
563
+  return 0;
564
+}
565
+#endif
566
+
567
+
568
+int runSDLUnitTest(int argc, char *argv[])
569
+{
570
+	handle_key('h');
571
+
572
+	if (argc > 1)
573
+	{
574
+		for (int i = 0; argv[1][i] != 0; ++i)
575
+		{
576
+			switch (argv[1][i])
577
+			{
578
+			default:
579
+			  handleArgKey(argv[1][i]);
580
+			}
581
+		}
582
+	}
583
+	else
584
+	{
585
+		printf("'%s h' for help\n", argv[0]);
586
+	}
587
+
588
+	
589
+#ifdef USING_OPENGL
590
+	main_gl(argc, argv);
591
+#else
592
+	printf("Build not OpenGL enabled\n");
593
+#endif
594
+
595
+	return 0;
596
+}
597
+#endif

+ 194
- 0
src/SkeletalModel.cpp 파일 보기

@@ -0,0 +1,194 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : OpenRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : SkeletalModel
9
+ * License : No use w/o permission (C) 2003 Mongoose
10
+ * Comments: This is the factored out skeletal model class
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2003.05.19:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#include "SkeletalModel.h"
23
+
24
+
25
+////////////////////////////////////////////////////////////
26
+// Constructors
27
+////////////////////////////////////////////////////////////
28
+
29
+SkeletalModel::SkeletalModel()
30
+{
31
+	model = 0x0;
32
+	flags = 0;
33
+	mBoneFrame = 0;  
34
+	mAnimationFrame = 0;
35
+	mIdleAnimation = 0;
36
+}
37
+
38
+
39
+SkeletalModel::~SkeletalModel()
40
+{
41
+	if (model)
42
+	{
43
+		for (model->animation.start();
44
+			  model->animation.forward();
45
+			  model->animation.next())
46
+		{
47
+			animation_frame_t *af = model->animation.current();
48
+			
49
+			if (!af)
50
+				continue;
51
+			
52
+			for (af->frame.start(); af->frame.forward(); af->frame.next())
53
+			{
54
+				bone_frame_t *bf = af->frame.current();
55
+				
56
+				if (!bf)
57
+					continue;
58
+
59
+				bf->tag.erase();
60
+				
61
+				//for (bf->tag.start(); bf->tag.forward(); bf->tag.next())
62
+				//{
63
+				//	if (bf->tag.current())
64
+				//		delete bf->tag.current();
65
+				//}
66
+				
67
+				delete bf;
68
+			}
69
+			
70
+			af->frame.clear();
71
+			
72
+			delete af;
73
+		}
74
+		
75
+		model->animation.clear();
76
+		
77
+		delete model;
78
+	}
79
+}
80
+
81
+
82
+////////////////////////////////////////////////////////////
83
+// Public Accessors
84
+////////////////////////////////////////////////////////////
85
+
86
+int SkeletalModel::getAnimation() 
87
+{
88
+	return mAnimationFrame; 
89
+}
90
+
91
+
92
+int SkeletalModel::getFrame() 
93
+{ 
94
+	return mBoneFrame; 
95
+}
96
+
97
+
98
+int SkeletalModel::getIdleAnimation() 
99
+{ 
100
+	return mIdleAnimation; 
101
+}
102
+
103
+
104
+////////////////////////////////////////////////////////////
105
+// Public Mutators
106
+////////////////////////////////////////////////////////////
107
+
108
+void SkeletalModel::setModel(skeletal_model_t *mdl)
109
+{
110
+	if (mdl)
111
+		model = mdl;
112
+}
113
+
114
+
115
+void SkeletalModel::setAnimation(int index)
116
+{
117
+	if (!model) // index > (int)model->animation.size())
118
+		return;
119
+	
120
+	animation_frame_t *a = model->animation[index];
121
+	
122
+	if (a)
123
+	{
124
+		mAnimationFrame = index;
125
+		mBoneFrame = 0;
126
+		rate = a->rate;
127
+	}
128
+}
129
+
130
+
131
+void SkeletalModel::setFrame(int index)
132
+{
133
+	if (!model)
134
+		return;
135
+
136
+	animation_frame_t *a = model->animation[mAnimationFrame];
137
+	
138
+	if (a) // index > (int)a->frame.size())
139
+	{
140
+		bone_frame_t *b = a->frame[index];
141
+		
142
+		if (b)
143
+		{
144
+			mBoneFrame = index;
145
+		}
146
+	}
147
+}
148
+
149
+
150
+void SkeletalModel::setIdleAnimation(int index)
151
+{
152
+	if (!model)
153
+		return;
154
+	
155
+	animation_frame_t *a = model->animation[index];
156
+	
157
+	if (a)
158
+	{
159
+		mIdleAnimation = index;
160
+	}
161
+}
162
+
163
+
164
+////////////////////////////////////////////////////////////
165
+// Private Accessors
166
+////////////////////////////////////////////////////////////
167
+
168
+
169
+////////////////////////////////////////////////////////////
170
+// Private Mutators
171
+////////////////////////////////////////////////////////////
172
+
173
+
174
+////////////////////////////////////////////////////////////
175
+// Unit Test code
176
+////////////////////////////////////////////////////////////
177
+
178
+#ifdef UNIT_TEST_SKELETALMODEL
179
+int runSkeletalModelUnitTest(int argc, char *argv[])
180
+{
181
+	SkeletalModel test;
182
+
183
+	return 0;
184
+}
185
+
186
+
187
+int main(int argc, char *argv[])
188
+{
189
+	printf("[SkeletalModel class test]\n");
190
+	runSkeletalModelUnitTest(argc, argv);
191
+
192
+	return 0;
193
+}
194
+#endif

+ 166
- 0
src/SkeletalModel.h 파일 보기

@@ -0,0 +1,166 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : OpenRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : SkeletalModel
9
+ * License : No use w/o permission (C) 2003 Mongoose
10
+ * Comments: This is the factored out skeletal model class
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- Test Defines -----------------------------------------------
17
+ *           
18
+ * UNIT_TEST_SKELETALMODEL - Builds SkeletalModel class as a console unit test 
19
+ *
20
+ *-- History ------------------------------------------------ 
21
+ *
22
+ * 2003.05.19:
23
+ * Mongoose - Created
24
+ ================================================================*/
25
+
26
+// TODO 
27
+// Start cutting off old hacks by simple force use of method interface
28
+// Also move the publicly exposed attributes out  =)
29
+// Better animation system in general - this is memory wasteful
30
+
31
+#ifndef GUARD__OPENRAIDER_MONGOOSE_SKELETALMODEL_H_
32
+#define GUARD__OPENRAIDER_MONGOOSE_SKELETALMODEL_H_
33
+
34
+#include <mstl/Vector.h>
35
+#include <hel/math.h>
36
+
37
+
38
+typedef struct bone_tag_s
39
+{
40
+	int mesh;
41
+	vec3_t off;
42
+	vec3_t rot;
43
+	char flag;
44
+
45
+} bone_tag_t;
46
+
47
+
48
+typedef struct bone_frame_s
49
+{
50
+	Vector<bone_tag_t *> tag;
51
+	vec3_t pos;
52
+	float yaw;
53
+
54
+} bone_frame_t;
55
+
56
+
57
+typedef struct animation_frame_s
58
+{
59
+	int id;
60
+	char rate;
61
+	Vector<bone_frame_t *> frame;
62
+
63
+} animation_frame_t;
64
+
65
+
66
+typedef struct skeletal_model_s
67
+{
68
+	int id;
69
+	bool tr4Overlay;
70
+	bool pigtails;
71
+	int ponytailId;
72
+	vec3_t ponytail;
73
+	int ponytailMeshId;
74
+	unsigned int ponytailNumMeshes;
75
+	float ponytailAngle;
76
+	float ponyOff;
77
+	float ponyOff2;
78
+	Vector<animation_frame_t *> animation;
79
+
80
+} skeletal_model_t;
81
+
82
+
83
+class SkeletalModel
84
+{
85
+ public:
86
+
87
+	////////////////////////////////////////////////////////////
88
+	// Constructors
89
+	////////////////////////////////////////////////////////////
90
+
91
+	SkeletalModel();
92
+	/*------------------------------------------------------
93
+	 * Pre  : 
94
+	 * Post : Constructs an object of SkeletalModel
95
+	 *
96
+	 *-- History ------------------------------------------
97
+	 *
98
+	 * 2003.05.19: 
99
+	 * Mongoose - Created
100
+	 ------------------------------------------------------*/
101
+
102
+	~SkeletalModel();
103
+	/*------------------------------------------------------
104
+	 * Pre  : SkeletalModel object is allocated
105
+	 * Post : Deconstructs an object of SkeletalModel
106
+	 *
107
+	 *-- History ------------------------------------------
108
+	 *
109
+	 * 2003.05.19: 
110
+	 * Mongoose - Created
111
+	 ------------------------------------------------------*/
112
+
113
+
114
+	////////////////////////////////////////////////////////////
115
+	// Public Accessors
116
+	////////////////////////////////////////////////////////////
117
+
118
+	int getAnimation();
119
+
120
+	int getFrame() ;
121
+
122
+	int getIdleAnimation();
123
+
124
+
125
+	////////////////////////////////////////////////////////////
126
+	// Public Mutators
127
+	////////////////////////////////////////////////////////////
128
+
129
+	void setModel(skeletal_model_t *mdl);
130
+
131
+	void setAnimation(int index);
132
+
133
+	void setFrame(int index);
134
+
135
+	void setIdleAnimation(int index);
136
+
137
+
138
+	enum SkeletalModelFlag { fReserved = 1 };
139
+
140
+	unsigned int flags;
141
+
142
+	skeletal_model_t *model;   /* World render model */
143
+
144
+	float time;                /* Interpolation use */
145
+	float lastTime;
146
+
147
+	float rate; // temp cache this here for old animation system use
148
+
149
+private:
150
+
151
+	////////////////////////////////////////////////////////////
152
+	// Private Accessors
153
+	////////////////////////////////////////////////////////////
154
+
155
+
156
+	////////////////////////////////////////////////////////////
157
+	// Private Mutators
158
+	////////////////////////////////////////////////////////////
159
+
160
+
161
+	int mBoneFrame;             /* Bone frame */
162
+	int mAnimationFrame;        /* Animation frame */
163
+	int mIdleAnimation;         /* Idle animation */
164
+};
165
+
166
+#endif

+ 336
- 0
src/Sound.cpp 파일 보기

@@ -0,0 +1,336 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : OpenRaider
5
+ * Author  : Mongoose
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Sound
9
+ * License : No use w/o permission (C) 2001 Mongoose
10
+ * Comments: This is the audio manager for OpenRaider
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2001.05.23:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#ifdef HAVE_OPENAL
23
+#   include <AL/al.h>
24
+#   include <AL/alc.h>
25
+#   include <AL/alut.h>
26
+#   include <AL/alext.h>
27
+#endif
28
+
29
+#include <time.h>
30
+#include <stdio.h>
31
+#include <stdlib.h>
32
+#include <sys/time.h>
33
+#include <sys/types.h>
34
+#include <sys/stat.h>
35
+#include <fcntl.h>
36
+#include <unistd.h>
37
+#include "Sound.h"
38
+
39
+#ifdef DEBUG_MEMEORY
40
+#   include "memeory_test.h"
41
+#endif
42
+
43
+
44
+
45
+Sound::Sound()
46
+{
47
+	mSource[0] = 0;
48
+	mBuffer[0] = 0;
49
+	mNextBuffer = 0;
50
+	mNextSource = 0;
51
+	mInit = false;
52
+}
53
+
54
+
55
+Sound::~Sound()
56
+{
57
+	if (mInit)
58
+	{
59
+#ifdef HAVE_OPENAL
60
+		alutExit();
61
+#endif
62
+	}
63
+}
64
+
65
+
66
+int Sound::init()
67
+{
68
+	int fd;	
69
+
70
+	fd = open("/dev/dsp", O_RDWR);
71
+
72
+	if (fd < 0)
73
+	{
74
+		perror("Sound::Init> Could not open /dev/dsp : ");
75
+		return -1;
76
+	}
77
+
78
+	close(fd);
79
+
80
+#ifdef HAVE_OPENAL
81
+	alutInit(NULL, 0);
82
+
83
+	mInit = true;
84
+	printf("@Created OpenAL Context...\n");
85
+#else
86
+	printf("*Couldn't create sound Context...\n");
87
+#endif
88
+
89
+	return 0;
90
+}
91
+
92
+
93
+void Sound::listenAt(float pos[3], float angle[3])
94
+{
95
+	if (!mInit)
96
+		return;
97
+
98
+#ifdef HAVE_OPENAL
99
+	alListenerfv(AL_POSITION, pos);
100
+	alListenerfv(AL_ORIENTATION, angle);	
101
+#endif
102
+}
103
+
104
+
105
+void Sound::sourceAt(int source, float pos[3])
106
+{
107
+	if (!mInit || source < 0)
108
+		return;
109
+
110
+#ifdef HAVE_OPENAL
111
+	alSourcefv(mSource[source-1], AL_POSITION, pos);
112
+#endif
113
+}
114
+
115
+
116
+// Mongoose 2002.01.04, FIXME seperate sourcing and buffering
117
+int Sound::add(char *filename, int *source, unsigned int flags)
118
+{
119
+#ifdef HAVE_OPENAL
120
+   ALsizei size, freq, bits;
121
+   ALenum format;
122
+   ALvoid *data;
123
+   ALboolean err;
124
+#endif
125
+
126
+
127
+	if (!mInit || !filename || !source)
128
+	{
129
+		printf("Sound::Add> ERROR pre condition assertion failed\n");
130
+		return -1000;
131
+	}
132
+
133
+	*source = -1;
134
+
135
+#ifdef HAVE_OPENAL
136
+   alGetError();
137
+
138
+	alGenBuffers(1, &mBuffer[mNextBuffer]);
139
+
140
+	if (alGetError() != AL_NO_ERROR)	
141
+   {
142
+		fprintf(stderr, "Sound::Init> alGenBuffers call failed\n");
143
+		return -1;
144
+	}
145
+
146
+   alGetError();
147
+
148
+   alGenSources(1, &mSource[mNextSource]);
149
+
150
+	if (alGetError() != AL_NO_ERROR)
151
+   {
152
+		fprintf(stderr, "Sound::Init> alGenSources call failed\n");
153
+		return -2;
154
+	}
155
+   
156
+   err = alutLoadWAV(filename, &data, &format, &size, &bits, &freq);
157
+
158
+   if (err == AL_FALSE) 
159
+	{
160
+	   fprintf(stderr, "Could not load %s\n", filename);
161
+	   return -3;
162
+   }
163
+
164
+   alBufferData(mBuffer[mNextBuffer], format, data, size, freq);
165
+
166
+   alSourcei(mSource[mNextSource], AL_BUFFER, mBuffer[mNextBuffer]);
167
+
168
+	if (flags & SoundFlagsLoop)
169
+	{
170
+		alSourcei(mSource[mNextSource], AL_LOOPING, 1);
171
+	}
172
+
173
+   ++mNextBuffer;
174
+   ++mNextSource;
175
+
176
+	*source = mNextBuffer;
177
+
178
+   return 0;
179
+#else
180
+	return -1;
181
+#endif
182
+}
183
+
184
+
185
+int Sound::add(unsigned char *wav, int *source, unsigned int flags)
186
+{
187
+#ifdef HAVE_OPENAL
188
+   ALsizei size, freq;
189
+   ALvoid *data;
190
+#endif
191
+
192
+	if (!mInit || !wav || !source)
193
+	{
194
+		printf("Sound::Add> ERROR pre condition assertion failed\n");
195
+		return -1000;
196
+	}
197
+
198
+	*source = -1;
199
+
200
+#ifdef HAVE_OPENAL
201
+	data = wav;
202
+
203
+   alGetError();
204
+
205
+	alGenBuffers(1, &mBuffer[mNextBuffer]);
206
+
207
+	if (alGetError() != AL_NO_ERROR)	
208
+   {
209
+		fprintf(stderr, "Sound::Init> alGenBuffers call failed\n");
210
+		return -1;
211
+	}
212
+
213
+   alGetError();
214
+
215
+   alGenSources(1, &mSource[mNextSource]);
216
+
217
+	if (alGetError() != AL_NO_ERROR)
218
+   {
219
+		fprintf(stderr, "Sound::Init> alGenSources call failed\n");
220
+		return -2;
221
+	}
222
+   
223
+	// AL_FORMAT_WAVE_EXT
224
+   alBufferData(mBuffer[mNextBuffer], AL_FORMAT_WAVE_EXT, data, size, freq);
225
+
226
+   alSourcei(mSource[mNextSource], AL_BUFFER, mBuffer[mNextBuffer]);
227
+
228
+	if (flags & SoundFlagsLoop)
229
+	{
230
+		alSourcei(mSource[mNextSource], AL_LOOPING, 1);
231
+	}
232
+
233
+   ++mNextBuffer;
234
+   ++mNextSource;
235
+
236
+	*source = mNextBuffer;
237
+
238
+   return 0;
239
+#else
240
+	return -1;
241
+#endif
242
+}
243
+
244
+
245
+void Sound::play(int source)
246
+{
247
+	if (!mInit)
248
+	{
249
+		printf("Sound::Play> ERROR: Sound not initialized\n");
250
+		return;
251
+	}
252
+
253
+	if (source < 0)
254
+	{
255
+		printf("Sound::Play> ERROR: Source Id invalid\n");
256
+		return;
257
+	}
258
+
259
+#ifdef HAVE_OPENAL
260
+	alSourcePlay(mSource[source-1]);
261
+#endif
262
+}
263
+
264
+
265
+void Sound::stop(int source)
266
+{
267
+	if (!mInit || source < 0)
268
+	{
269
+		printf("Sound::Stop> ERROR pre condition assertion failed\n");
270
+		return;
271
+	}
272
+
273
+#ifdef HAVE_OPENAL
274
+	alSourceStop(mSource[source-1]);
275
+#endif
276
+}
277
+
278
+
279
+///////////////////////////////////////////////////////
280
+
281
+
282
+#ifdef UNIT_TEST_SOUND
283
+int main(int argc, char* argv[]) 
284
+{
285
+	Sound snd;
286
+	FILE *f;
287
+	unsigned int l;
288
+	unsigned char *buf;
289
+   int id, ret;
290
+
291
+
292
+	if (argc > 1)
293
+	{
294
+		snd.init();
295
+		printf("Loading %s\n", argv[1]);
296
+		ret = snd.add(argv[1], &id, SoundFlagsNone);
297
+		printf("Load returned %i\n", ret);
298
+		printf("Playing %u::%s\n", id, argv[1]);
299
+		snd.play(id);
300
+
301
+		printf("Waiting...\n");
302
+		sleep(5);
303
+
304
+		f = fopen(argv[1], "rb");
305
+
306
+		if (f)
307
+		{
308
+			fseek(f, 0, SEEK_END);
309
+			l = ftell(f);
310
+			fseek(f, 0, SEEK_SET);
311
+
312
+			buf = new unsigned char[l];
313
+			fread(buf, l, 1, f);
314
+
315
+			fclose(f);
316
+			
317
+			printf("Loading buffer of %s\n", argv[1]);
318
+			ret = snd.add(buf, &id, SoundFlagsNone);
319
+			printf("Load returned %i\n", ret);
320
+			printf("Playing buffer of %u::%s\n", id, argv[1]);
321
+			snd.play(id);
322
+
323
+			delete [] buf;
324
+			printf("Waiting...\n");
325
+			sleep(5);
326
+		}
327
+	}
328
+	else
329
+	{
330
+		printf("%s filename.wav\n", argv[0]);
331
+	}
332
+
333
+	return 0;
334
+}
335
+#endif
336
+

+ 181
- 0
src/Sound.h 파일 보기

@@ -0,0 +1,181 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : OpenRaider
5
+ * Author  : Mongoose
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Sound
9
+ * License : No use w/o permission (C) 2001 Mongoose
10
+ * Comments: This is the audio manager for OpenRaider
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ *
16
+ *-- Test Defines -----------------------------------------------
17
+ *           
18
+ * UNIT_TEST_SOUND - Builds Sound class as a console unit test 
19
+ *
20
+ *-- History ---------------------------------------------------- 
21
+ *
22
+ * 2002.09.13:
23
+ * Mongoose - API follows new code style guidelines
24
+ *
25
+ * 2002.01.03:
26
+ * Mongoose - Flags use added
27
+ *
28
+ * 2001.05.23:
29
+ * Mongoose - Created
30
+ ================================================================*/
31
+
32
+#ifndef __OPENRAIDER_MONGOOSE_SOUND_H_
33
+#define __OPENRAIDER_MONGOOSE_SOUND_H_
34
+
35
+typedef enum
36
+{
37
+	SoundFlagsNone = 0,            /* No FX */
38
+	SoundFlagsLoop = 1             /* Enable looping during playback */
39
+
40
+} SoundFlags;
41
+
42
+
43
+class Sound
44
+{
45
+ public:
46
+
47
+  Sound();
48
+  /*------------------------------------------------------
49
+   * Pre  : 
50
+   * Post : Constructs an object of Sound
51
+   *
52
+   *-- History ------------------------------------------
53
+   *
54
+   * 2001.05.23: 
55
+   * Mongoose - Created
56
+   ------------------------------------------------------*/
57
+
58
+  ~Sound();
59
+  /*------------------------------------------------------
60
+   * Pre  : Sound object is allocated
61
+   * Post : Deconstructs an object of Sound
62
+   *
63
+   *-- History ------------------------------------------
64
+   *
65
+   * 2001.05.23: 
66
+   * Mongoose - Created
67
+   ------------------------------------------------------*/
68
+
69
+  int init();
70
+  /*------------------------------------------------------
71
+   * Pre  : 
72
+   * Post : Initializes sound system
73
+	*
74
+	*        No error returns 0 all others returns < 0
75
+	*        error flags
76
+   *
77
+   *-- History ------------------------------------------
78
+   *
79
+   * 2001.05.23: 
80
+   * Mongoose - Created
81
+   ------------------------------------------------------*/
82
+
83
+  void listenAt(float pos[3], float angle[3]);
84
+  /*------------------------------------------------------
85
+   * Pre  : pos and angles are valid for listener
86
+   * Post : Moves listener and repositions them
87
+   *
88
+   *-- History ------------------------------------------
89
+   *
90
+   * 2001.05.23: 
91
+   * Mongoose - Created
92
+   ------------------------------------------------------*/
93
+
94
+  void sourceAt(int source, float pos[3]);
95
+  /*------------------------------------------------------
96
+   * Pre  : source and pos are valid for source
97
+   * Post : Moves sound source to position
98
+   *
99
+   *-- History ------------------------------------------
100
+   *
101
+   * 2001.05.23: 
102
+   * Mongoose - Created
103
+   ------------------------------------------------------*/
104
+
105
+  int add(char *filename, int *source, unsigned int flags);
106
+  /*------------------------------------------------------
107
+   * Pre  : filename and source aren't NULL
108
+	*        flags (un)set options
109
+	*
110
+   * Post : Loads wav file from disk
111
+	*
112
+	*        Source returns it's sound source id, 
113
+	*        source id is set -1 for error
114
+	*
115
+	*        Returns either 0 for no error or < 0 error 
116
+	*        flag
117
+   *
118
+   *-- History ------------------------------------------
119
+   *
120
+   * 2001.05.23: 
121
+   * Mongoose - Created
122
+   ------------------------------------------------------*/
123
+
124
+  // FIXME: Not implemented yet
125
+  int add(unsigned char *wav, int *source, unsigned int flags);
126
+  /*------------------------------------------------------
127
+   * Pre  : wav and source aren't NULL
128
+	*        wav is a valid waveform buffer
129
+	*
130
+	*        flags (un)set options
131
+	*
132
+   * Post : Loads wav file from buffer
133
+	*
134
+	*        Source returns it's sound source id, 
135
+	*        source id is set -1 for error
136
+	*
137
+	*        Returns either 0 for no error or < 0 error 
138
+	*        flag
139
+   *
140
+   *-- History ------------------------------------------
141
+   *
142
+   * 2001.05.23: 
143
+   * Mongoose - Created
144
+   ------------------------------------------------------*/
145
+
146
+  void play(int source);
147
+  /*------------------------------------------------------
148
+   * Pre  : 
149
+   * Post : Play sound source
150
+   *
151
+   *-- History ------------------------------------------
152
+   *
153
+   * 2001.05.23: 
154
+   * Mongoose - Created
155
+   ------------------------------------------------------*/
156
+
157
+  void stop(int source);
158
+  /*------------------------------------------------------
159
+   * Pre  : 
160
+   * Post : Stop playing sound source
161
+   *
162
+   *-- History ------------------------------------------
163
+   *
164
+   * 2001.05.23: 
165
+   * Mongoose - Created
166
+   ------------------------------------------------------*/
167
+
168
+ private:
169
+
170
+  bool mInit;                    /* Guard to ensure ausio system is active */
171
+
172
+  unsigned int mBuffer[256];     /* Audio buffer id list */
173
+
174
+  unsigned int mSource[256];     /* Audio source id list */
175
+
176
+  unsigned int mNextBuffer;      /* Audio buffer id cursor */
177
+
178
+  unsigned int mNextSource;      /* Audio source id cursor */
179
+};
180
+
181
+#endif

+ 785
- 0
src/System.cpp 파일 보기

@@ -0,0 +1,785 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : UnRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : System
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: 
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2002.08.09:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#include <stdlib.h>
23
+#include <stdio.h>
24
+#include <sys/stat.h>
25
+#include <sys/types.h>
26
+#include <string.h>
27
+#include <stdarg.h>
28
+
29
+#ifdef USING_OPENGL
30
+#   include <GL/gl.h>
31
+#   include <GL/glu.h>
32
+#endif
33
+
34
+#ifdef HAVE_LIBFERIT
35
+#   include <ferit/Url.h>
36
+#   include <ferit/TcpProtocol.h>
37
+#   include <ferit/Http.h>
38
+#   include <ferit/Ftp.h>
39
+#endif
40
+
41
+#ifdef linux
42
+#   include <time.h>
43
+#   include <sys/time.h>
44
+#endif
45
+
46
+#ifdef MEMEORY_TEST
47
+#   include "memeory_test.h"
48
+#endif
49
+
50
+#ifdef PS2_LINUX
51
+#   include "ps2linux.h"
52
+#endif
53
+
54
+#include "System.h"
55
+
56
+
57
+////////////////////////////////////////////////////////////
58
+// Constructors
59
+////////////////////////////////////////////////////////////
60
+
61
+System::System()
62
+{
63
+	m_width = 800;
64
+	m_height = 600;
65
+	m_fastCard = true;
66
+
67
+	m_driver = 0x0;
68
+
69
+	m_clipFar  = 4000.0f;
70
+	m_clipNear = 4.0f;
71
+	m_fovY     = 45.0f;
72
+
73
+	mConsoleMode = false;
74
+
75
+	printf("[System.Core]\n");
76
+
77
+	// Hack for bad Map class, as well as reserved commands
78
+	addCommandMode("[System.Console]"); 
79
+	mConsoleKey = '`';
80
+	bindKeyCommand("+console", mConsoleKey, 0);
81
+
82
+#ifdef WIN32
83
+	setDriverGL("libGL32.dll");
84
+#else
85
+	setDriverGL("/usr/lib/libGL.so.1");
86
+#endif
87
+}
88
+
89
+
90
+System::~System()
91
+{
92
+}
93
+
94
+
95
+////////////////////////////////////////////////////////////
96
+// Public Accessors
97
+////////////////////////////////////////////////////////////
98
+
99
+char *System::bufferString(char *string, ...)
100
+{
101
+	int sz = 60;
102
+	int n;
103
+	char *text;
104
+	va_list args;
105
+
106
+	
107
+	// Mongoose 2002.01.01, Only allow valid strings
108
+	//   we must assume it's NULL terminated also if it passes...
109
+	if (!string || !string[0])
110
+	{
111
+		return NULL;
112
+	}
113
+
114
+	text = new char[sz];
115
+
116
+	va_start(args, string);
117
+
118
+	// Mongoose 2002.01.01, Get exact size needed if the first try fails
119
+	n = vsnprintf(text, sz, string, args);
120
+
121
+	// Mongoose 2002.01.01, Realloc correct amount if truncated
122
+	while (1)
123
+	{
124
+		if (n > -1 && n < sz)
125
+		{
126
+			break;
127
+		}
128
+
129
+		// Mongoose 2002.01.01, For glibc 2.1
130
+		if (n > -1)
131
+		{
132
+			sz = n + 1;
133
+			delete [] text;
134
+			text = new char[sz];
135
+			n = vsnprintf(text, sz, string, args);
136
+			break;
137
+		}
138
+		else // glibc 2.0
139
+		{
140
+			sz *= 2;
141
+			delete [] text;
142
+			text = new char[sz];
143
+			n = vsnprintf(text, sz, string, args);
144
+		}
145
+	}
146
+
147
+	va_end(args);
148
+
149
+	return text;
150
+}
151
+
152
+
153
+char *System::fullPath(char *path, char end)
154
+{
155
+	unsigned int i, lenPath, lenEnv, len;
156
+	char *env, *dir;
157
+
158
+
159
+	if (!path || !path[0])
160
+		return 0;
161
+
162
+	if (path[0] == '~')
163
+	{
164
+#ifdef unix
165
+		env = getenv("HOME");
166
+
167
+		if (!env || !env[0])
168
+		{
169
+			return 0;
170
+		}
171
+
172
+		lenEnv = strlen(env);
173
+		lenPath = strlen(path);
174
+		len = lenEnv + lenPath;
175
+
176
+		dir = new char[len+1];
177
+
178
+		// Mongoose 2002.08.17, Copy ENV,  strip '~', append rest of path
179
+		for (i = 0; i < len; ++i)
180
+		{
181
+			if (i < lenEnv)
182
+			{
183
+				dir[i] = env[i];
184
+			}
185
+			else
186
+			{
187
+				dir[i] = path[1+(i-lenEnv)];
188
+			}
189
+		}
190
+#endif
191
+	}
192
+	else
193
+	{
194
+		lenPath = strlen(path);
195
+		dir = new char[lenPath+1];
196
+		strncpy(dir, path, lenPath);
197
+
198
+		i = lenPath;
199
+	}
200
+	
201
+	// Make sure ends in "end" char
202
+	if (end && dir[i-1] != end)
203
+	{
204
+		dir[i++] = end;
205
+	}
206
+		
207
+	dir[i] = 0;
208
+
209
+	return dir;
210
+}
211
+
212
+
213
+char *System::getFileFromFullPath(char *filename)
214
+{
215
+	int i, j, len;
216
+	char *str;
217
+
218
+
219
+	len = strlen(filename);
220
+	
221
+	for (i = len, j = 0; i > 0; --i, ++j)
222
+	{
223
+		if (filename[i] == '/' || filename[i] == '\\')
224
+			break;
225
+	}
226
+	
227
+	j--;
228
+	
229
+	str = new char[len - j + 1];
230
+	
231
+	for (i = 0; i < len - j; ++i)
232
+	{
233
+		str[i] = filename[i + len - j];
234
+	}
235
+
236
+	str[i] = 0;
237
+
238
+	return str;
239
+}
240
+
241
+
242
+unsigned int System::getTicks()
243
+{
244
+	return system_timer(1);
245
+}
246
+
247
+
248
+int System::createDir(char *path)
249
+{
250
+#ifdef WIN32
251
+	return _mkdir(path);
252
+#else
253
+	return mkdir(path, S_IRWXU | S_IRWXG);
254
+#endif
255
+}
256
+
257
+
258
+int System::downloadToBuffer(char *urlString, 
259
+									  unsigned char **buffer, unsigned int *size)
260
+{
261
+#ifdef HAVE_LIBFERIT
262
+	printf("ERROR: This build is libferit enabled, but func not implemented\n");
263
+	return -1;
264
+#else
265
+	printf("ERROR: This build not libferit enabled, unable to download\n");
266
+	return -1000;
267
+#endif
268
+}
269
+
270
+
271
+int System::downloadToFile(char *urlString, char *filename)
272
+{
273
+#ifdef HAVE_LIBFERIT
274
+	int err = 0;
275
+	unsigned int timeout = 10;
276
+	Url *url = 0x0;
277
+	TcpProtocol *client = 0x0;
278
+
279
+
280
+	if (!urlString || !urlString[0])
281
+		return -1;
282
+
283
+	url = new Url("");
284
+	url->UrlToSession(urlString);
285
+	url->Options(OPT_RESUME | OPT_QUIET);
286
+	url->Outfile(url->Filename());
287
+
288
+	switch (url->Protocol())
289
+	{
290
+	case FTP_SESSION:
291
+		client = new Ftp(timeout);
292
+		break;
293
+	case HTTP_SESSION:
294
+		client = new Http(timeout);
295
+		break;
296
+	default:
297
+		printf("Sorry the protocol used in the URL isn't unsupported.\n");
298
+	
299
+		if (client)
300
+		{
301
+			delete client;
302
+		}
303
+		
304
+		return -2;
305
+	}
306
+
307
+	if (client)
308
+	{
309
+		err = client->Download(url, NULL);
310
+		delete client;
311
+	}
312
+
313
+	if (url)
314
+		delete url;
315
+	
316
+	return err;
317
+#else
318
+	printf("ERROR: This build not libferit enabled, unable to download\n");
319
+	return -1000;
320
+#endif
321
+}
322
+
323
+
324
+////////////////////////////////////////////////////////////
325
+// Public Mutators
326
+////////////////////////////////////////////////////////////
327
+
328
+unsigned int System::addCommandMode(char *command)
329
+{
330
+	if (command && command[0] == '[')
331
+	{
332
+		mCmdModes.pushBack(command);
333
+		return (mCmdModes.size() - 1);
334
+	}
335
+	else
336
+	{
337
+		return 0;
338
+	}
339
+}
340
+
341
+// FIXME: Modifer support later
342
+void System::bindKeyCommand(char *cmd, unsigned int key, int event)
343
+{
344
+	printf("Bound command '%s' -> event %i (0x%x key)\n", cmd, event, key);	
345
+	mKeyEvents.Add(key, event);
346
+}
347
+
348
+
349
+void System::command(char *cmd)
350
+{
351
+	bool modeFound = false;
352
+
353
+
354
+	if (!cmd || !cmd[0]) // Null command string
355
+		return;
356
+
357
+	if (cmd[0] == '[') // Set a mode, eg "[Engine.OpenGL.Driver]"
358
+	{
359
+		for (mCmdModes.start(); mCmdModes.forward(); mCmdModes.next())
360
+		{
361
+			if (strcmp(cmd, mCmdModes.current()) == 0)
362
+			{
363
+				mCommandMode = mCmdModes.getCurrentIndex();
364
+				modeFound = true;
365
+			}
366
+		}
367
+
368
+		if (!modeFound)
369
+		{
370
+			//	mCommandMode = 0;
371
+			printf("Command> Unknown mode '%s'\n", cmd);
372
+		}
373
+	}
374
+	else // Execute a command in current mode, eg "stat fps"
375
+	{
376
+		handleCommand(cmd, mCommandMode);
377
+	}
378
+}
379
+
380
+
381
+int System::loadResourceFile(char *filename)
382
+{
383
+	char buffer[256];
384
+	bool line_comment = false;
385
+	FILE *f;
386
+	char c;
387
+	int i, j;
388
+
389
+
390
+	f = fopen(filename, "r");
391
+
392
+	if (!f)
393
+	{
394
+		perror(filename);
395
+		return -1;
396
+	}
397
+
398
+	printf("Resource system \n");
399
+
400
+	i = 0;
401
+	buffer[0] = 0;
402
+	
403
+	// Strip out whitespace and comments
404
+	while (fscanf(f, "%c", &c) != EOF)
405
+	{
406
+		if (line_comment && c != '\n')
407
+			continue;
408
+		
409
+		if (i > 254)
410
+		{
411
+			printf("loadResourceFile> Overflow handled\n");
412
+			i = 254;
413
+		}
414
+		
415
+		switch (c)
416
+		{
417
+		case '\v':
418
+		case '\t':
419
+			break;
420
+		case '#':
421
+			buffer[i++] = 0;
422
+			line_comment = true;
423
+			break;
424
+		case '\n':
425
+			if (line_comment)
426
+			{
427
+				line_comment = false;
428
+			}
429
+			
430
+			if (buffer[0] == 0)
431
+			{
432
+				i = 0;
433
+				continue;
434
+			}
435
+			
436
+			buffer[i] = 0;
437
+			//printf("'%s'\n", buffer);
438
+
439
+			// 'Preprocessor' commands
440
+			if (buffer[0] == '@')
441
+			{
442
+				if (strncmp(buffer, "@include ", 9) == 0)
443
+				{
444
+					for (j = 9; j < i; ++j)
445
+					{
446
+						buffer[j-9] = buffer[j];
447
+						buffer[j-8] = 0;
448
+					}
449
+					
450
+					printf("Importing '%s'\n", buffer);
451
+					
452
+					loadResourceFile(fullPath(buffer, '/'));
453
+				}
454
+			}
455
+			else
456
+			{
457
+				command(buffer);
458
+			}
459
+
460
+			i = 0;
461
+			buffer[0] = 0;
462
+			break;
463
+		default:
464
+			buffer[i++] = c;
465
+		}
466
+	}
467
+	
468
+	fclose(f);
469
+
470
+	return 0;
471
+}
472
+
473
+
474
+void System::setDriverGL(const char *driver)
475
+{
476
+	unsigned int len;
477
+
478
+
479
+	if (m_driver)
480
+	{
481
+		delete [] m_driver;
482
+	}
483
+
484
+	if (driver && driver[0])
485
+	{
486
+		len = strlen(driver);
487
+		m_driver = new char[len+1];
488
+		strncpy(m_driver, driver, len);
489
+		m_driver[len] = 0;
490
+	}
491
+}
492
+
493
+
494
+void System::setFastCardPerformance(bool is_fast)
495
+{
496
+	m_fastCard = is_fast;
497
+}
498
+
499
+
500
+void System::resetTicks()
501
+{
502
+	system_timer(0);
503
+}
504
+
505
+
506
+void System::initGL()
507
+{
508
+	char *s;
509
+
510
+
511
+	// Print driver support information
512
+	printf("\n\n\t## GL Driver Info ##\n");
513
+	printf("\tVendor     : %s\n", glGetString(GL_VENDOR));
514
+	printf("\tRenderer   : %s\n", glGetString(GL_RENDERER));
515
+	printf("\tVersion    : %s\n", glGetString(GL_VERSION));
516
+	printf("\tExtensions : %s\n\n\n", (char*)glGetString(GL_EXTENSIONS));
517
+
518
+	// Testing for goodies
519
+	// Mongoose 2001.12.31, Fixed string use to check for bad strings
520
+	s = (char*)glGetString(GL_EXTENSIONS);
521
+
522
+	if (s && s[0])
523
+	{
524
+		printf("\tGL_ARB_multitexture       \t\t");
525
+
526
+		if (strstr(s, "GL_ARB_multitexture"))
527
+		{
528
+			printf("YES\n");
529
+		}
530
+		else
531
+		{
532
+			printf("NO\n");
533
+		}
534
+
535
+		//glActiveTextureARB
536
+		//glMultiTexCoord2fARB
537
+		//glFogCoordfEXT
538
+
539
+		printf("\tGL_EXT_texture_env_combine\t\t");
540
+
541
+		if (strstr(s, "GL_EXT_texture_env_combine"))
542
+		{
543
+			printf("YES\n");
544
+		}
545
+		else
546
+		{
547
+			printf("NO\n");
548
+		}
549
+	}
550
+
551
+	// Set up Z buffer
552
+	glEnable(GL_DEPTH_TEST);
553
+	glDepthFunc(GL_LESS);
554
+
555
+	// Set up culling
556
+	glEnable(GL_CULL_FACE);
557
+	//glFrontFace(GL_CW);
558
+	glFrontFace(GL_CCW);
559
+	//glCullFace(GL_FRONT);
560
+
561
+	// Set background to black
562
+	glClearColor(0.0, 0.0, 0.0, 1.0);
563
+
564
+	// Disable lighting 
565
+	glDisable(GL_LIGHTING);
566
+
567
+	// Set up alpha blending
568
+	if (m_fastCard) 
569
+	{
570
+		glEnable(GL_BLEND);
571
+		glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
572
+
573
+		//glEnable(GL_ALPHA_TEST); // Disable per pixel alpha blending
574
+		glAlphaFunc(GL_GREATER, 0);
575
+	}
576
+	else
577
+	{
578
+		glDisable(GL_BLEND);
579
+		glDisable(GL_ALPHA_TEST);
580
+	}
581
+
582
+	glPointSize(5.0);
583
+
584
+	// Setup shading
585
+	glShadeModel(GL_SMOOTH);
586
+
587
+	if (m_fastCard) 
588
+	{
589
+		glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
590
+		glHint(GL_FOG_HINT, GL_NICEST);
591
+		glDisable(GL_COLOR_MATERIAL);
592
+		glEnable(GL_DITHER);
593
+		
594
+		// AA polygon edges
595
+		//glEnable(GL_POLYGON_SMOOTH);
596
+		//glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
597
+
598
+		glEnable(GL_POINT_SMOOTH);
599
+	}
600
+	else
601
+	{
602
+		glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
603
+		glHint(GL_FOG_HINT, GL_FASTEST);
604
+		glDisable(GL_COLOR_MATERIAL);
605
+		glDisable(GL_DITHER);
606
+		glDisable(GL_POLYGON_SMOOTH);
607
+		glDisable(GL_POINT_SMOOTH);
608
+		glDisable(GL_FOG);
609
+	}
610
+
611
+	glDisable(GL_LINE_SMOOTH);
612
+	glDisable(GL_AUTO_NORMAL);
613
+	glDisable(GL_LOGIC_OP);
614
+	glDisable(GL_TEXTURE_1D);
615
+	glDisable(GL_STENCIL_TEST);
616
+
617
+
618
+	glDisable(GL_NORMALIZE);
619
+
620
+	glEnableClientState(GL_VERTEX_ARRAY);
621
+	glDisableClientState(GL_EDGE_FLAG_ARRAY);
622
+	glDisableClientState(GL_COLOR_ARRAY);
623
+	glDisableClientState(GL_NORMAL_ARRAY);
624
+
625
+	glPolygonMode(GL_FRONT, GL_FILL);
626
+
627
+	glMatrixMode(GL_MODELVIEW);
628
+}
629
+
630
+
631
+void System::resizeGL(unsigned int w, unsigned int h)
632
+{
633
+	if (!w || !h)
634
+	{
635
+		printf("resizeGL> ERROR assertions 'w > 0', 'h > 0' failed\n");
636
+		return;
637
+	}
638
+
639
+	glViewport(0, 0, w, h);
640
+	glMatrixMode(GL_PROJECTION); 
641
+	glLoadIdentity(); 
642
+
643
+	// Adjust clipping
644
+	gluPerspective(m_fovY, ((GLdouble)w)/((GLdouble)h), m_clipNear, m_clipFar);
645
+	glMatrixMode(GL_MODELVIEW);
646
+}
647
+
648
+////////////////////////////////////////////////////////////
649
+// Private Accessors
650
+////////////////////////////////////////////////////////////
651
+
652
+
653
+////////////////////////////////////////////////////////////
654
+// Private Mutators
655
+////////////////////////////////////////////////////////////
656
+
657
+
658
+
659
+////////////////////////////////////////////////////////////
660
+// Gobal helper functions
661
+////////////////////////////////////////////////////////////
662
+
663
+// Mongoose 2002.03.23, Checks command to see if it's same 
664
+//   as symbol, then returns the arg list in command buffer
665
+bool rc_command(char *symbol, char *command)
666
+{
667
+	int i, j, lens, lenc;
668
+
669
+
670
+	if (!symbol || !symbol[0] || !command || !command[0])
671
+	{
672
+		return false;
673
+	}
674
+
675
+	lens = strlen(symbol);
676
+
677
+	if (strncmp(command, symbol, lens) == 0)
678
+	{
679
+		lenc = strlen(command);
680
+
681
+		// lens+1 skips '=' or ' '
682
+		for (i = 0, j = lens+1; j < lenc; ++i, ++j)
683
+		{
684
+			command[i] = command[j];
685
+			command[i+1] = 0;
686
+		}
687
+
688
+		return true;
689
+	}
690
+		
691
+	return false;
692
+}
693
+
694
+
695
+int rc_get_bool(char *buffer, bool *val)
696
+{
697
+	if (!buffer || !buffer[0])
698
+	{
699
+		return -1;
700
+	}
701
+	
702
+	if (strncmp(buffer, "true", 4) == 0)
703
+		*val = true;
704
+	else if (strncmp(buffer, "false", 5) == 0)
705
+		*val = false;
706
+	else
707
+		return -2;
708
+
709
+	return 0;
710
+}
711
+
712
+
713
+unsigned int system_timer(int state)
714
+{
715
+	static struct timeval start;
716
+	static struct timeval stop;
717
+	static struct timeval total;
718
+	static struct timezone tz;
719
+
720
+
721
+	switch (state)
722
+	{
723
+	case 0:
724
+		gettimeofday(&start, &tz);
725
+		total.tv_sec = 0;
726
+		total.tv_usec = 0;
727
+		break;
728
+	case 1:
729
+		gettimeofday(&stop, &tz);
730
+		
731
+		if (start.tv_usec > stop.tv_usec) 
732
+		{ 
733
+#ifdef OBSOLETE
734
+			stop.tv_usec = (1000000 + stop.tv_usec); 
735
+#else
736
+			stop.tv_usec = (1000 + stop.tv_usec); 
737
+#endif
738
+			stop.tv_sec--; 
739
+		} 
740
+
741
+		stop.tv_usec -= start.tv_usec; 
742
+		stop.tv_sec -= start.tv_sec;
743
+
744
+#ifdef OBSOLETE
745
+		total.tv_sec += stop.tv_sec;
746
+		total.tv_usec += stop.tv_usec;
747
+
748
+		while (total.tv_usec > 1000000) 
749
+		{
750
+			total.tv_usec -= 1000000;
751
+			total.tv_sec++; 
752
+		} 
753
+
754
+		return total.tv_sec * 1000000 + total.tv_usec;
755
+#else
756
+		return (stop.tv_sec-start.tv_sec)*1000+(stop.tv_usec-start.tv_usec)/1000;
757
+#endif
758
+		break;
759
+	}
760
+
761
+	return 0;
762
+}
763
+
764
+
765
+////////////////////////////////////////////////////////////
766
+// Unit Test code
767
+////////////////////////////////////////////////////////////
768
+
769
+#ifdef UNIT_TEST_SYSTEM
770
+int runSystemUnitTest(int argc, char *argv[])
771
+{
772
+	return 0;
773
+}
774
+
775
+
776
+int main(int argc, char *argv[])
777
+{
778
+	System test;
779
+
780
+
781
+	printf("[System class test]\n");
782
+
783
+	return runSystemUnitTest(argc, argv);
784
+}
785
+#endif

+ 553
- 0
src/System.h 파일 보기

@@ -0,0 +1,553 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : UnRaider, OpenRaider, RaiderUnification 2003
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : System
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: 
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- Test Defines -----------------------------------------------
17
+ *
18
+ * UNIT_TEST_SYSTEM - Builds System class as a console unit test 
19
+ *
20
+ *-- History ------------------------------------------------ 
21
+ *
22
+ * 2002.08.09:
23
+ * Mongoose - Created
24
+ ================================================================*/
25
+
26
+
27
+#ifndef GUARD__UNRAIDER_MONGOOSE_SYSTEM_H_
28
+#define GUARD__UNRAIDER_MONGOOSE_SYSTEM_H_
29
+
30
+#include <mstl/Map.h>
31
+#include <mstl/Vector.h>
32
+
33
+// TODO: Replace with unicode compatible key codes
34
+#define SYS_MOUSE_LEFT    6000
35
+#define SYS_MOUSE_RIGHT   6001
36
+#define SYS_MOUSE_MIDDLE  6002
37
+#define SYS_KEY_ESC       27
38
+#define SYS_KEY_ENTER     13
39
+#define SYS_KEY_UP        5000
40
+#define SYS_KEY_DOWN      5001
41
+#define SYS_KEY_RIGHT     5002
42
+#define SYS_KEY_LEFT      5003
43
+#define SYS_KEY_PAGEDOWN  5004
44
+#define SYS_KEY_PAGEUP    5005
45
+#define SYS_KEY_F1        1000
46
+#define SYS_KEY_F2        1001
47
+#define SYS_KEY_F3        1002
48
+#define SYS_KEY_F4        1003
49
+#define SYS_KEY_F5        1004
50
+#define SYS_KEY_F6        1005
51
+#define SYS_KEY_F7        1006
52
+#define SYS_KEY_F8        1007
53
+#define SYS_KEY_F9        1008
54
+#define SYS_KEY_F10       1009
55
+#define SYS_KEY_F11       1010
56
+#define SYS_KEY_F12       1011
57
+
58
+typedef enum 
59
+{
60
+  SYS_MOD_KEY_LSHIFT = 1,
61
+  SYS_MOD_KEY_RSHIFT = 2,
62
+  SYS_MOD_KEY_LCTRL  = 4, 
63
+  SYS_MOD_KEY_RCTRL  = 8, 
64
+  SYS_MOD_KEY_LALT   = 16,
65
+  SYS_MOD_KEY_RALT   = 32
66
+
67
+} sdl_sys_mod_key_t;
68
+
69
+
70
+class System
71
+{
72
+public:
73
+
74
+	////////////////////////////////////////////////////////////
75
+	// Constructors
76
+	////////////////////////////////////////////////////////////
77
+
78
+	System();
79
+	/*------------------------------------------------------
80
+	 * Pre  : 
81
+	 * Post : Constructs an object of System
82
+	 *
83
+	 *-- History ------------------------------------------
84
+	 *
85
+	 * 2002.08.09: 
86
+	 * Mongoose - Created
87
+	 ------------------------------------------------------*/
88
+
89
+	virtual ~System();
90
+	/*------------------------------------------------------
91
+	 * Pre  : System object is allocated
92
+	 * Post : Deconstructs an object of System
93
+	 *
94
+	 *-- History ------------------------------------------
95
+	 *
96
+	 * 2002.08.09: 
97
+	 * Mongoose - Created
98
+	 ------------------------------------------------------*/
99
+
100
+
101
+	////////////////////////////////////////////////////////////
102
+	// Public Accessors
103
+	////////////////////////////////////////////////////////////
104
+
105
+   static char *bufferString(char *string, ...);
106
+   /*------------------------------------------------------
107
+    * Pre  : <String> is a valid string with valid args
108
+	 *
109
+    * Post : Generates a buufered string for the printf
110
+	 *        call
111
+    *
112
+    *-- History ------------------------------------------
113
+    *
114
+	 * 2003.06.03:
115
+	 * Mongoose - Made into a printf string caching system
116
+	 *
117
+    * 2001.12.31: 
118
+    * Mongoose - Created, was GLString::glPrintf
119
+    ------------------------------------------------------*/
120
+
121
+	static char *fullPath(char *path, char end);
122
+	/*------------------------------------------------------
123
+	 * Pre  : 
124
+	 * Post : Returns allocated string of path, with
125
+	 *        expansion of unix home enviroment char and
126
+	 *        makes sure string ends in "end" char
127
+	 *
128
+	 *        end = 0 appends no addional char
129
+	 *
130
+	 *-- History ------------------------------------------
131
+	 *
132
+	 * 2002.08.17: 
133
+	 * Mongoose - Created
134
+	 ------------------------------------------------------*/
135
+
136
+	static char *getFileFromFullPath(char *filename);
137
+	/*------------------------------------------------------
138
+	 * Pre  : 
139
+	 * Post : 
140
+	 *
141
+	 *-- History ------------------------------------------
142
+	 *
143
+	 * 2003.07.05:
144
+	 * Mongoose - Created
145
+	 ------------------------------------------------------*/
146
+
147
+	virtual unsigned int getTicks();
148
+	/*------------------------------------------------------
149
+	 * Pre  : 
150
+	 * Post : Returns number of milliseconds since start of
151
+	 *        program
152
+	 *
153
+	 *-- History ------------------------------------------
154
+	 *
155
+	 * 2002.06.06: 
156
+	 * Mongoose - Created
157
+	 ------------------------------------------------------*/
158
+
159
+	static int downloadToBuffer(char *urlString, 
160
+										 unsigned char **buffer, unsigned int *size);
161
+	/*------------------------------------------------------
162
+	 * Pre  : 
163
+	 * Post : Downloads something into passed buffer,
164
+	 *        Returns < 0 on error, 0 on sucess
165
+	 *
166
+	 *-- History ------------------------------------------
167
+	 *
168
+	 * 2003.07.12:
169
+	 * Mongoose - Created
170
+	 ------------------------------------------------------*/
171
+
172
+	static int downloadToFile(char *urlString, char *filename);
173
+	/*------------------------------------------------------
174
+	 * Pre  : 
175
+	 * Post : Downloads something into a disk file,
176
+	 *        Returns < 0 on error, 0 on sucess
177
+	 *
178
+	 *-- History ------------------------------------------
179
+	 *
180
+	 * 2003.07.12:
181
+	 * Mongoose - Created
182
+	 ------------------------------------------------------*/
183
+
184
+	static int createDir(char *path);
185
+	/*------------------------------------------------------
186
+	 * Pre  : Creates directory
187
+	 * Post : Returns -1 on error
188
+	 *
189
+	 *-- History ------------------------------------------
190
+	 *
191
+	 * 2003.07.12:
192
+	 * Mongoose - Created
193
+	 ------------------------------------------------------*/
194
+
195
+
196
+	////////////////////////////////////////////////////////////
197
+	// Public Mutators
198
+	////////////////////////////////////////////////////////////
199
+
200
+	virtual unsigned int addCommandMode(char *command);
201
+	/*------------------------------------------------------
202
+	 * Pre  : <Command> is valid command mode for the
203
+	 *        resource file, eg "[Engine.OpenGL.Driver]"
204
+	 *
205
+	 * Post : Returns Id given to mode
206
+	 *
207
+	 *-- History ------------------------------------------
208
+	 *
209
+	 * 2002.03.23:
210
+	 * Mongoose - Created
211
+	 ------------------------------------------------------*/
212
+
213
+	virtual void bindKeyCommand(char *cmd, unsigned int key, int event);
214
+	/*------------------------------------------------------
215
+	 * Pre  : <Cmd> is a valid command string
216
+	 *        <Key> is a valid keyboard code
217
+	 *        <Event> is a valid game event Id
218
+	 *
219
+	 * Post : Sets <Event> binding <Cmd> to <Key> press 
220
+	 *
221
+	 *-- History ------------------------------------------
222
+	 *
223
+	 * 2003.06.03:
224
+	 * Mongoose - Created
225
+	 ------------------------------------------------------*/
226
+
227
+	virtual void command(char *cmd);
228
+	/*------------------------------------------------------
229
+	 * Pre  : cmd is a valid command string
230
+	 * Post : cmd sets it's var
231
+	 *
232
+	 *-- History ------------------------------------------
233
+	 *
234
+	 * 2001.05.27: 
235
+	 * Mongoose - Created
236
+	 ------------------------------------------------------*/
237
+
238
+	virtual void gameFrame() = 0;
239
+	/*------------------------------------------------------
240
+	 * Pre  : 
241
+	 * Post : 
242
+	 *
243
+	 *-- History ------------------------------------------
244
+	 *
245
+	 * 2002.08.09?: 
246
+	 * Mongoose - Created
247
+	 ------------------------------------------------------*/
248
+
249
+	virtual void handleMouseMotionEvent(float x, float y) = 0;
250
+	/*------------------------------------------------------
251
+	 * Pre  : 
252
+	 * Post : 
253
+	 *
254
+	 *-- History ------------------------------------------
255
+	 *
256
+	 * 2002.08.09?: 
257
+	 * Mongoose - Created
258
+	 ------------------------------------------------------*/
259
+
260
+	virtual void handleBoundKeyPressEvent(unsigned int key) = 0;
261
+	/*------------------------------------------------------
262
+	 * Pre  : <Key> is a valid keyboard code
263
+	 *
264
+	 * Post : Recieves <Event> bound to <Cmd> from <Key> press 
265
+	 *
266
+	 *-- History ------------------------------------------
267
+	 *
268
+	 * 2003.06.03:
269
+	 * Mongoose - Created
270
+	 ------------------------------------------------------*/
271
+
272
+	virtual void handleBoundKeyReleaseEvent(unsigned int key) = 0;
273
+	/*------------------------------------------------------
274
+	 * Pre  : <Key> is a valid keyboard code
275
+	 *
276
+	 * Post : Recieves <Event> bound to <Cmd> from <Key> release
277
+	 *
278
+	 *-- History ------------------------------------------
279
+	 *
280
+	 * 2003.06.03:
281
+	 * Mongoose - Created
282
+	 ------------------------------------------------------*/
283
+
284
+	virtual void handleCommand(char *command, unsigned int mode) = 0;
285
+	/*------------------------------------------------------
286
+	 * Pre  : <Command> is valid keyword optionally followed 
287
+	 *        by ' ' (space) seperated and argument(s)
288
+	 *
289
+	 *        <Mode> is the current type or resource mode
290
+	 *
291
+	 * Post : Executes valid command based on keyword
292
+	 *
293
+	 *-- History ------------------------------------------
294
+	 *
295
+	 * 2002.03.23:
296
+	 * Mongoose - Created
297
+	 ------------------------------------------------------*/
298
+
299
+	virtual void handleConsoleKeyPressEvent(unsigned int key, 
300
+														 unsigned int mod) = 0;
301
+	/*------------------------------------------------------
302
+	 * Pre  : <Key> is a valid keyboard code
303
+	 *
304
+	 * Post : Recieves <Key> code from text input in console mode
305
+	 *
306
+	 *-- History ------------------------------------------
307
+	 *
308
+	 * 2003.06.03:
309
+	 * Mongoose - Created
310
+	 ------------------------------------------------------*/
311
+
312
+	virtual void handleKeyPressEvent(unsigned int key, unsigned int mod) = 0;
313
+	/*------------------------------------------------------
314
+	 * Pre  : 
315
+	 * Post : 
316
+	 *
317
+	 *-- History ------------------------------------------
318
+	 *
319
+	 * 2002.08.09?: 
320
+	 * Mongoose - Created
321
+	 ------------------------------------------------------*/
322
+
323
+	virtual void handleKeyReleaseEvent(unsigned int key, unsigned int mod) = 0;
324
+	/*------------------------------------------------------
325
+	 * Pre  : 
326
+	 * Post : 
327
+	 *
328
+	 *-- History ------------------------------------------
329
+	 *
330
+	 * 2002.08.09?: 
331
+	 * Mongoose - Created
332
+	 ------------------------------------------------------*/
333
+
334
+	virtual void initGL();
335
+	/*------------------------------------------------------
336
+	 * Pre  : 
337
+	 * Post : 
338
+	 *
339
+	 *-- History ------------------------------------------
340
+	 *
341
+	 * 2002.08.09?: 
342
+	 * Mongoose - Created
343
+	 ------------------------------------------------------*/
344
+
345
+	virtual void initVideo(unsigned int width, unsigned int height, 
346
+								  bool fullscreen) = 0;
347
+	/*------------------------------------------------------
348
+	 * Pre  : 
349
+	 * Post : 
350
+	 *
351
+	 *-- History ------------------------------------------
352
+	 *
353
+	 * 2002.08.09?: 
354
+	 * Mongoose - Created
355
+	 ------------------------------------------------------*/
356
+
357
+	virtual int loadResourceFile(char *filename);
358
+	/*------------------------------------------------------
359
+	 * Pre  : 
360
+	 * Post : Init the resource vars
361
+	 *
362
+	 *        Returns less than zero value on error
363
+	 *
364
+	 *-- History ------------------------------------------
365
+	 *
366
+	 * 2001.05.27: 
367
+	 * Mongoose - Created
368
+	 ------------------------------------------------------*/
369
+
370
+	static void resetTicks();
371
+	/*------------------------------------------------------
372
+	 * Pre  : 
373
+	 * Post : 
374
+	 *
375
+	 *-- History ------------------------------------------
376
+	 *
377
+	 * 2002.08.09?: 
378
+	 * Mongoose - Created
379
+	 ------------------------------------------------------*/
380
+
381
+	virtual void resizeGL(unsigned int width, unsigned int height);
382
+	/*------------------------------------------------------
383
+	 * Pre  : 
384
+	 * Post : 
385
+	 *
386
+	 *-- History ------------------------------------------
387
+	 *
388
+	 * 2002.08.09?: 
389
+	 * Mongoose - Created
390
+	 ------------------------------------------------------*/
391
+
392
+	virtual void runGame() = 0;
393
+	/*------------------------------------------------------
394
+	 * Pre  : 
395
+	 * Post : 
396
+	 *
397
+	 *-- History ------------------------------------------
398
+	 *
399
+	 * 2002.08.09?: 
400
+	 * Mongoose - Created
401
+	 ------------------------------------------------------*/
402
+
403
+	void setConsoleMode(bool on);
404
+	/*------------------------------------------------------
405
+	 * Pre  : 
406
+	 * Post : Turns console key events on/off,
407
+	 *        mostly for allowing text entry vs key 
408
+	 *        impluse commands
409
+	 *
410
+	 *-- History ------------------------------------------
411
+	 *
412
+	 * 2003.06.03:
413
+	 * Mongoose - Created
414
+	 ------------------------------------------------------*/
415
+
416
+	void setDriverGL(const char *driver);
417
+	/*------------------------------------------------------
418
+	 * Pre  : 
419
+	 * Post : 
420
+	 *
421
+	 *-- History ------------------------------------------
422
+	 *
423
+	 * 2002.08.09?: 
424
+	 * Mongoose - Created
425
+	 ------------------------------------------------------*/
426
+
427
+	void setFastCardPerformance(bool isFast);
428
+	/*------------------------------------------------------
429
+	 * Pre  : 
430
+	 * Post : 
431
+	 *
432
+	 *-- History ------------------------------------------
433
+	 *
434
+	 * 2002.08.09?: 
435
+	 * Mongoose - Created
436
+	 ------------------------------------------------------*/
437
+
438
+	virtual void shutdown(int code) = 0;
439
+	/*------------------------------------------------------
440
+	 * Pre  : 
441
+	 * Post : 
442
+	 *
443
+	 *-- History ------------------------------------------
444
+	 *
445
+	 * 2002.08.09?: 
446
+	 * Mongoose - Created
447
+	 ------------------------------------------------------*/
448
+
449
+	virtual void swapBuffersGL() = 0;
450
+	/*------------------------------------------------------
451
+	 * Pre  : 
452
+	 * Post : 
453
+	 *
454
+	 *-- History ------------------------------------------
455
+	 *
456
+	 * 2002.08.09?: 
457
+	 * Mongoose - Created
458
+	 ------------------------------------------------------*/
459
+
460
+	virtual void toggleFullscreen() = 0;
461
+	/*------------------------------------------------------
462
+	 * Pre  : 
463
+	 * Post : 
464
+	 *
465
+	 *-- History ------------------------------------------
466
+	 *
467
+	 * 2002.08.09?: 
468
+	 * Mongoose - Created
469
+	 ------------------------------------------------------*/
470
+
471
+ protected:
472
+
473
+	unsigned int m_width;      /* Width of the viewport */
474
+
475
+	unsigned int m_height;     /* Height of the viewport */
476
+
477
+	bool m_fastCard;           /* Assume expensive calls are fine if true */
478
+
479
+	char *m_driver;            /* String for dynamic use of GL library */
480
+
481
+	float m_clipNear;          /* Clip near distance */
482
+
483
+	float m_clipFar;           /* Clip far distance */
484
+
485
+	float m_fovY;              /* Field of vision */
486
+
487
+	Map<unsigned int, int> mKeyEvents;	/* Single key press event mappings */
488
+
489
+	bool mConsoleMode;         /* Using text (console) event handler? */
490
+
491
+	Vector<char *> mCmdModes;	/* Dynamic resource command collection */
492
+
493
+	unsigned int mCommandMode;	/* Current resource command mode */
494
+
495
+	unsigned int mConsoleKey;	/* Console toggle event now handled lower */
496
+
497
+ private:
498
+
499
+	////////////////////////////////////////////////////////////
500
+	// Private Accessors
501
+	////////////////////////////////////////////////////////////
502
+
503
+
504
+	////////////////////////////////////////////////////////////
505
+	// Private Mutators
506
+	////////////////////////////////////////////////////////////
507
+};
508
+
509
+
510
+// Could make these static methods later, depends on API evolution
511
+
512
+	bool rc_command(char *symbol, char *command);
513
+	/*------------------------------------------------------
514
+	 * Pre  : 
515
+	 * Post : Returns true if <Command> matches <Symbol>
516
+	 *        command string
517
+	 *
518
+	 *        Returns the rest of the argument list back in
519
+	 *        <Command> buffer, if any
520
+	 *
521
+	 *-- History ------------------------------------------
522
+	 *
523
+	 * 2002.03.23: 
524
+	 * Mongoose - Created
525
+	 ------------------------------------------------------*/
526
+
527
+	int rc_get_bool(char *buffer, bool *val);
528
+	/*------------------------------------------------------
529
+	 * Pre  : Buffer is "true" or "false"
530
+	 *
531
+	 * Post : Returns 0 if <Buffer> is "true" or "false" 
532
+	 *        and sets <Val> accordingly
533
+	 *
534
+	 *        Returns -1 for null string
535
+	 *        Returns -2 if string isn't "true" or "false"
536
+	 *
537
+	 *-- History ------------------------------------------
538
+	 *
539
+	 * 2002.03.23: 
540
+	 * Mongoose - Created
541
+	 ------------------------------------------------------*/
542
+
543
+	unsigned int system_timer(int state);
544
+	/*------------------------------------------------------
545
+	 * Pre  : 0 - reset, 1 - get number of ticks
546
+	 * Post : Sets timer state and returns number of ticks
547
+	 *
548
+	 *-- History ------------------------------------------
549
+	 *
550
+	 * 2002.06.06: 
551
+	 * Mongoose - Created
552
+	 ------------------------------------------------------*/
553
+#endif

+ 1320
- 0
src/Texture.cpp
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 510
- 0
src/Texture.h 파일 보기

@@ -0,0 +1,510 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*==========================================================================
3
+ * 
4
+ * Project : MTK, Freyja, OpenRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : MtkTexture
9
+ * Comments: This is the Texture registery
10
+ *
11
+ *           See file COPYING for license details.
12
+ *
13
+ * 
14
+ *-- History ---------------------------------------------------------- 
15
+ *
16
+ * 2003.06.30, 
17
+ * Mongoose - API update, SDL_TTF support moved here, misc features
18
+ *            SDL_TTF support based on Sam Lantinga's public domain
19
+ *            SDL_TTF demo functions and algorithms 
20
+ *
21
+ * 2001.05.29:
22
+ * Mongoose - Removed legacy code and done clean up
23
+ *
24
+ * 2001.02.19:
25
+ * Mongoose - Moved from GooseEgg to mtk
26
+ *
27
+ * 2000.04.29:
28
+ * Mongoose - Created from old PPM/PCX codebases I have done before
29
+ ==========================================================================*/
30
+
31
+
32
+#ifndef __MTK_MONGOOSE_MTKTEXTURE_H
33
+#define __MTK_MONGOOSE_MTKTEXTURE_H
34
+
35
+#include <stdio.h>
36
+
37
+typedef struct
38
+{
39
+	int x, y, w, h;
40
+	int minx; int maxx; int miny; int maxy; int advance;
41
+
42
+} ttf_glyph_t; 
43
+
44
+typedef struct
45
+{
46
+	unsigned int utf8Offset;
47
+	unsigned int count;   
48
+
49
+/* [utf8Offset -> utf8Offset+count], 
50
+	 matches indexing into glyphs[0 -> count] for texcoords, etc
51
+	----------------------------------------
52
+	41     -> 126     ASCII English w/ special chars,
53
+	0x303f -> 0x3093  Japanese hiragana kana,
54
+	0x301a -> 0x30f6  Japanese katakana kana */
55
+
56
+	unsigned int width;     /* Width and height of RGBA texture */
57
+	unsigned char *texture; /* RGBA texture data */
58
+
59
+	ttf_glyph_t *glyphs;    /* For typesetting and rendering use */
60
+	int fontHeight;
61
+	int fontAscent;
62
+	int fontDescent;
63
+	int fontSpacing;
64
+
65
+} ttf_texture_t; 
66
+
67
+
68
+typedef struct
69
+{
70
+	unsigned int utf8Offset;
71
+	unsigned int count;
72
+	int textureId;
73
+	int drawListBase;
74
+
75
+} gl_font_t;
76
+
77
+
78
+
79
+class Texture
80
+{
81
+ public:
82
+
83
+	enum ColorMode
84
+	{
85
+		GREYSCALE = 1,
86
+		RGB,
87
+		RGBA,
88
+		ARGB
89
+	};
90
+
91
+	enum TextureFlag
92
+	{
93
+		fUseMipmaps			= 1,
94
+		fUseMultiTexture	= 2,
95
+		fUseSDL_TTF			= 4
96
+	};
97
+
98
+
99
+	////////////////////////////////////////////////////////////
100
+	// Constructors
101
+	////////////////////////////////////////////////////////////
102
+
103
+   Texture();
104
+	/*------------------------------------------------------
105
+	 * Pre  : 
106
+	 * Post : Constructs an object of Texture
107
+	 *
108
+	 *-- History ------------------------------------------
109
+	 *
110
+	 * 2001.05.29:
111
+	 * Mongoose - Big code clean up, documentation
112
+	 *
113
+	 * 2000.10.05: 
114
+	 * Mongoose - Created
115
+	 ------------------------------------------------------*/
116
+
117
+   ~Texture();
118
+	/*------------------------------------------------------
119
+	 * Pre  : This object exists
120
+	 * Post : Deconstructs an object of Texture
121
+	 *
122
+	 *-- History ------------------------------------------
123
+	 *
124
+	 * 2001.05.29:
125
+	 * Mongoose - Big code clean up, documentation
126
+	 *
127
+	 * 2000.10.05: 
128
+	 * Mongoose - Created
129
+	 ------------------------------------------------------*/
130
+
131
+
132
+	////////////////////////////////////////////////////////////
133
+	// Public Accessors
134
+	////////////////////////////////////////////////////////////
135
+
136
+	static unsigned char *generateColorTexture(unsigned char rgba[4],
137
+															 unsigned int width, 
138
+															 unsigned int height);
139
+	/*------------------------------------------------------
140
+	 * Pre  : <Rgba> is 32bpp RGBA color
141
+	 *        <Width> and <Height> are powers of two, pref
142
+	 *        the same number
143
+	 * Post : 
144
+	 *
145
+	 *-- History ------------------------------------------
146
+	 *
147
+	 * 2003.06.30:
148
+	 * Mongoose - Created
149
+	 ------------------------------------------------------*/
150
+
151
+	gl_font_t *generateFont(ttf_texture_t *texture);
152
+	/*------------------------------------------------------
153
+	 * Pre  : 
154
+	 * Post : 
155
+	 *
156
+	 *-- History ------------------------------------------
157
+	 *
158
+	 * 2003.06.30:
159
+	 * Mongoose - Created
160
+	 ------------------------------------------------------*/
161
+
162
+	ttf_texture_t *generateFontTexture(char *filename, int pointSize, 
163
+												  unsigned int textureWidth,
164
+												  unsigned char color[3],
165
+												  unsigned int utf8Offset,
166
+												  unsigned int count,
167
+												  char verbose);
168
+	/*------------------------------------------------------
169
+	 * Pre  : <Filename> of TTF font
170
+	 *        <PointSize> to generate
171
+	 *        <TextureWidth> is width of texture, height will match it
172
+	 *        <Color> is RGB 24bit color
173
+	 *        <Utf8Offset> is offset into font's encoding chart
174
+	 *        <Count> is number of glyphs to read from offset start
175
+	 *        <Verbose> dumps debug info to stdout 
176
+	 *
177
+	 * Post : Generates a font texture with typeset info from TTF
178
+	 *
179
+	 *        DOES NOT load the texture itself, call loadFont()
180
+	 *        on returned ttf_texture_t
181
+	 *
182
+	 *
183
+	 *-- History ------------------------------------------
184
+	 *
185
+	 * 2003.06.03:
186
+	 * Mongoose - Created
187
+	 ------------------------------------------------------*/
188
+
189
+   int getTextureCount();
190
+	/*------------------------------------------------------
191
+	 * Pre  : 
192
+	 * Post : Returns number of textures in use, or -1 for
193
+	 *        error ( Not initalized )
194
+	 *
195
+	 *-- History ------------------------------------------
196
+	 *
197
+	 * 2001.05.29:
198
+	 * Mongoose - Big code clean up, documentation
199
+	 *
200
+	 * 2000.10.05: 
201
+	 * Mongoose - Created
202
+	 ------------------------------------------------------*/
203
+
204
+	void glScreenShot(char *base, unsigned int width, unsigned int height);
205
+	/*------------------------------------------------------
206
+	 * Pre  : <Base> is base filename, 
207
+	 *        <Width> and <Height> are viewport dim
208
+	 *
209
+	 * Post : Dumps a screenshot to disk, 
210
+	 *        avoids overwriting files with same base name
211
+	 *
212
+	 *-- History ------------------------------------------
213
+	 *
214
+	 * 2002.06.16:
215
+	 * Mongoose - Created
216
+	 ------------------------------------------------------*/
217
+
218
+
219
+	////////////////////////////////////////////////////////////
220
+	// Public Mutators
221
+	////////////////////////////////////////////////////////////
222
+
223
+	void bindMultiTexture(int texture0, int texture1);
224
+	/*------------------------------------------------------
225
+	 * Pre  : 
226
+	 * Post : Sets up multitexture rendering with passed texture ids
227
+	 *
228
+	 *-- History ------------------------------------------
229
+	 *
230
+	 * 2002.12.24:
231
+	 * Mongoose - Created
232
+	 ------------------------------------------------------*/
233
+
234
+   void bindTextureId(unsigned int n);
235
+	/*------------------------------------------------------
236
+	 * Pre  : n is valid texture index
237
+	 * Post : Binds the texture for use in GL
238
+	 *
239
+	 *-- History ------------------------------------------
240
+	 *
241
+	 * 2001.05.29:
242
+	 * Mongoose - Big code clean up, documentation
243
+	 *
244
+	 * 2000.10.05: 
245
+	 * Mongoose - Created
246
+	 ------------------------------------------------------*/
247
+
248
+	void clearFlag(TextureFlag flag);
249
+	/*------------------------------------------------------
250
+	 * Pre  : 
251
+	 * Post : CLears a option flag
252
+	 *
253
+	 *-- History ------------------------------------------
254
+	 *
255
+	 * 2003.01.05:
256
+	 * Mongoose - Created
257
+	 ------------------------------------------------------*/
258
+
259
+	void disableMultiTexture();
260
+	/*------------------------------------------------------
261
+	 * Pre  : 
262
+	 * Post : 
263
+	 *
264
+	 *-- History ------------------------------------------
265
+	 *
266
+	 * 2002.12.24:
267
+	 * Mongoose - Created
268
+	 ------------------------------------------------------*/
269
+
270
+	void initSDL_TTF();
271
+	/*------------------------------------------------------
272
+	 * Pre  : 
273
+	 * Post : Loads SDL_TTF if avalible
274
+	 *
275
+	 *-- History ------------------------------------------
276
+	 *
277
+	 * 2003.06.03:
278
+	 * Mongoose - Created
279
+	 ------------------------------------------------------*/
280
+
281
+   int loadBuffer(unsigned char *image, 
282
+						unsigned int width, unsigned int height, 
283
+						ColorMode mode, unsigned int bpp);
284
+	/*------------------------------------------------------
285
+	 * Pre  : image must be a valid pixmap that agrees
286
+	 *        with mode, width, and height
287
+	 *
288
+	 * Post : Returns texture id or < 0 error flag
289
+	 *
290
+	 *-- History ------------------------------------------
291
+	 *
292
+	 * 2001.05.29:
293
+	 * Mongoose - Big code clean up, documentation
294
+	 *
295
+	 * 2000.10.05: 
296
+	 * Mongoose - Created
297
+	 ------------------------------------------------------*/
298
+
299
+   int loadBufferSlot(unsigned char *image, 
300
+							 unsigned int width, unsigned int height, 
301
+							 ColorMode mode, unsigned int bpp,
302
+							 unsigned int slot);
303
+	/*------------------------------------------------------
304
+	 * Pre  : image must be a valid pixmap that agrees
305
+	 *        with mode, width, and height, slot ( ID )
306
+	 *
307
+	 * Post : Returns texture id or < 0 error flag
308
+	 *
309
+	 *-- History ------------------------------------------
310
+	 *
311
+	 * 2002.09.05: 
312
+	 * Mongoose - Created
313
+	 ------------------------------------------------------*/
314
+
315
+	int loadColorTexture(unsigned char rgba[4],
316
+								unsigned int width, unsigned int height);
317
+	/*------------------------------------------------------
318
+	 * Pre  : 
319
+	 * Post : Generates and loads a solid color texture,
320
+	 *        returns texture Id or -1 if failed
321
+	 *
322
+	 *-- History ------------------------------------------
323
+	 *
324
+	 * 2003.06.30:
325
+	 * Mongoose - Created
326
+	 ------------------------------------------------------*/
327
+
328
+	int loadFontTTF(char *filename, 
329
+						 unsigned int utf8Offset, unsigned int count);
330
+	/*------------------------------------------------------
331
+	 * Pre  : <Filename> of TTF font
332
+	 *        <Utf8Offset> is offset into UNICODE table
333
+	 *        <Count> is number of glyphs to load
334
+	 *
335
+	 * Post : Loads a TTF, 
336
+	 *        Generates: texture image, glyph list, and drawlist
337
+	 *
338
+	 *        Returns font id if sucessful, or < 0 if error
339
+	 *
340
+	 *-- History ------------------------------------------
341
+	 *
342
+	 * 2003.07.05:
343
+	 * Mongoose - Created
344
+	 ------------------------------------------------------*/
345
+
346
+	int loadPNG(char *filename);
347
+	/*------------------------------------------------------
348
+	 * Pre  : Texture is init and filename/file is valid
349
+	 * Post : Loads PNG as texture and returns ID or -1 error
350
+	 *
351
+	 *-- History ------------------------------------------
352
+	 *
353
+	 * 2002.06.16:
354
+	 * Mongoose - Created, from Freyja
355
+	 ------------------------------------------------------*/
356
+
357
+	int loadTGA(char *filename);
358
+	/*------------------------------------------------------
359
+	 * Pre  : Texture is init and filename/file is valid
360
+	 * Post : Loads TGA as texture and returns ID or -1 error
361
+	 *
362
+	 *-- History ------------------------------------------
363
+	 *
364
+	 * 2002.06.16:
365
+	 * Mongoose - Created
366
+	 ------------------------------------------------------*/
367
+
368
+   void reset();
369
+	/*------------------------------------------------------
370
+	 * Pre  : 
371
+	 * Post : Resets all texture data
372
+	 *
373
+	 *-- History ------------------------------------------
374
+	 *
375
+	 * 2001.05.29:
376
+	 * Mongoose - Big code clean up, documentation
377
+	 *
378
+	 * 2000.10.05: 
379
+	 * Mongoose - Created
380
+	 ------------------------------------------------------*/
381
+
382
+	void setFlag(TextureFlag flag);
383
+	/*------------------------------------------------------
384
+	 * Pre  : 
385
+	 * Post : Sets a option flag
386
+	 *
387
+	 *-- History ------------------------------------------
388
+	 *
389
+	 * 2003.01.05:
390
+	 * Mongoose - Created
391
+	 ------------------------------------------------------*/
392
+
393
+	void setMaxTextureCount(unsigned int n);
394
+	/*------------------------------------------------------
395
+	 * Pre  : n is max number of textures you wish to allow
396
+	 * Post : Sets up GL texturing, and must be called 
397
+	 *        as the first setup step
398
+	 *
399
+	 *-- History ------------------------------------------
400
+	 *
401
+	 * 2001.05.29:
402
+	 * Mongoose - Big code clean up, documentation
403
+	 *
404
+	 * 2000.10.05: 
405
+	 * Mongoose - Created
406
+	 ------------------------------------------------------*/
407
+
408
+	void useMultiTexture(float u, float v);
409
+	/*------------------------------------------------------
410
+	 * Pre  : 
411
+	 * Post : 
412
+	 *
413
+	 *-- History ------------------------------------------
414
+	 *
415
+	 * 2002.12.24:
416
+	 * Mongoose - Created
417
+	 ------------------------------------------------------*/
418
+
419
+	void useMultiTexture(float aU, float aV, float bU, float bV);
420
+	/*------------------------------------------------------
421
+	 * Pre  : 
422
+	 * Post : 
423
+	 *
424
+	 *-- History ------------------------------------------
425
+	 *
426
+	 * 2002.12.24:
427
+	 * Mongoose - Created
428
+	 ------------------------------------------------------*/
429
+
430
+
431
+ private:
432
+
433
+	////////////////////////////////////////////////////////////
434
+	// Private Accessors
435
+	////////////////////////////////////////////////////////////
436
+
437
+	int nextPower(int seed);
438
+	/*------------------------------------------------------
439
+	 * Pre  : 
440
+	 * Post : 
441
+	 *
442
+	 *-- History ------------------------------------------
443
+	 *
444
+	 * 2002.06.16:
445
+	 * Mongoose - Created
446
+	 ------------------------------------------------------*/
447
+
448
+	unsigned char *scaleBuffer(unsigned char *image, int width, int height,	
449
+										int components);
450
+	/*------------------------------------------------------
451
+	 * Pre  : 
452
+	 * Post : 
453
+	 *
454
+	 *-- History ------------------------------------------
455
+	 *
456
+	 * 2002.06.16:
457
+	 * Mongoose - Created
458
+	 ------------------------------------------------------*/
459
+
460
+
461
+	////////////////////////////////////////////////////////////
462
+	// Private Mutators
463
+	////////////////////////////////////////////////////////////
464
+
465
+   unsigned int *mTextureIds;		/* GL texture list */
466
+
467
+   unsigned int mTextureCount;	/* Texture counter */
468
+	
469
+   unsigned int mTextureLimit;	/* The texture limit */
470
+
471
+	unsigned int mFlags;				/* Class options */
472
+
473
+   int mTextureId;					/* Currently bound texture id */
474
+
475
+	int mTextureId2;					/* Multitexture Texture Id */
476
+};
477
+
478
+
479
+/* Experimental testing */
480
+void bufferedPrintf(char *string, unsigned int len, char *s, ...);
481
+
482
+void glPrint3d(float x, float y, float z, 
483
+					float pitch, float yaw, float roll, 
484
+					float scale,
485
+					char *string);
486
+
487
+void glPrint2d(float x, float y, float scale, char *string);
488
+
489
+	void glEnterMode2d(unsigned int width, unsigned int height);
490
+	/*------------------------------------------------------
491
+	 * Pre  : 
492
+	 * Post : OpenGL ortho projection
493
+	 *
494
+	 *-- History ------------------------------------------
495
+	 *
496
+	 * 2003.06.03:
497
+	 * Mongoose - Created
498
+	 ------------------------------------------------------*/
499
+
500
+	void glExitMode2d();
501
+	/*------------------------------------------------------
502
+	 * Pre  : 
503
+	 * Post : OpenGL model matrix projection
504
+	 *
505
+	 *-- History ------------------------------------------
506
+	 *
507
+	 * 2003.06.03:
508
+	 * Mongoose - Created
509
+	 ------------------------------------------------------*/
510
+#endif

+ 6839
- 0
src/TombRaider.cpp
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 2770
- 0
src/TombRaider.h
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 548
- 0
src/TombRaider1.h 파일 보기

@@ -0,0 +1,548 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : OpenRaider
5
+ * Author  : Mongoose
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : OpenRaider
9
+ * License : GPL, See file COPYING for details
10
+ * Comments: Loads TR 1 states and etc
11
+ *
12
+ *           This file was generated using Mongoose's C++ 
13
+ *           template generator script.  <stu7440@westga.edu>
14
+ * 
15
+ *-- History ------------------------------------------------ 
16
+ *
17
+ * Mongoose - Created, based on:
18
+ *                TR Rosetta Stone ( TombRaider pak format specs )
19
+ ================================================================*/
20
+
21
+#ifndef __OPENRAIDER_MONGOOSE_TOMBRAIDER1_H_
22
+#define __OPENRAIDER_MONGOOSE_TOMBRAIDER1_H_
23
+
24
+
25
+class TombRaider1
26
+{
27
+public:
28
+
29
+	TombRaider1();
30
+
31
+	~TombRaider1();
32
+
33
+	enum Items 
34
+   {
35
+		Lara = 0,
36
+		PistolAnimation  = 1,
37
+		ShotgunAnimation = 2,
38
+		MagnumAnimation = 3,
39
+		LaraAlternate = 4, // Lara's home appearance, wounded, or turned to gold
40
+		UziAnimation = 5,
41
+		LaraMutant = 6,
42
+		Wolf = 7,
43
+		Bear = 8,
44
+		Bat = 9
45
+	};
46
+
47
+	enum WolfStates
48
+	{
49
+		WolfState_Walking   = 1,
50
+		WolfState_Running   = 2,
51
+		WolfState_Jumping   = 3,
52
+		WolfState_Stalking  = 5,
53
+		WolfState_JumpingAttack   = 6,
54
+		WolfState_Attacking = 7,
55
+		WolfState_Lying     = 8,  // down
56
+		WolfState_Getting   = 9,  // ready to strike
57
+		WolfState_RunningJump   = 10,
58
+		WolfState_Dying     = 11,
59
+		WolfState_Biting    = 12
60
+	};
61
+};
62
+
63
+#ifdef FIXME_DONT_COMPILE
64
+//  Bear = 8,
65
+//         Walking = 0, on all fours
66
+//         Getting = 1, back to all fours
67
+//         Walking = 2, on hind legs
68
+//         Running = 3, on all fours
69
+//         Rearing = 4, up on hind legs
70
+//         Growling = 5,?
71
+//         Running = 6, and attacking
72
+//         Standing = 7, on hind legs
73
+//         Biting = 8,
74
+//         Dying = 9,
75
+//  Bat = 9,
76
+//         Starting = 1, to fly
77
+//         Flying = 2, straight
78
+//         Biting = 3,
79
+//         Circling = 4,
80
+//         Dying = 5,
81
+// Crocodile = 10, (on land)
82
+//         Stationary = 1,
83
+//         Walking = 2,
84
+//         Walking = 3,
85
+//         Turning = 4,
86
+//         Biting = 5,
87
+//         Dying = 7,
88
+// Crocodile = 11, (in water)
89
+//         Swimming = 1,
90
+//         Biting = 2,
91
+//         Dying = 3,
92
+// Lion = 12, (male)
93
+//         Standing = 1,
94
+//         Walking = 2,
95
+//         Leaping = 3,
96
+//         Leaping = 4, and biting
97
+//         Dying = 5,
98
+//         Biting = 6,
99
+//         Biting = 7,
100
+// Lion = 13, (female)
101
+//         Standing = 1,
102
+//         Walking = 2,
103
+//         Leaping = 3,
104
+//         Leaping = 4, and biting
105
+//         Dying = 5,
106
+//         Biting = 6,
107
+//         Biting = 7,
108
+// Panther = 14,
109
+//         Standing = 1,
110
+//         Walking = 2,
111
+//         Leaping = 3,
112
+//         Leaping = 4, and biting
113
+//         Dying = 5,
114
+//         Biting = 6,
115
+//         Biting = 7,
116
+// Gorilla = 15,
117
+//         Standing = 1, on all fours
118
+//         Running = 3, on all fours
119
+//        Walking = 4, on legs (attacking?)
120
+//         Dying = 5,
121
+//         Thumping = 6, chest
122
+//         Waving = 7, arms
123
+//         Turning = 8, leftward?
124
+//         Turning = 9, rightward?
125
+//        Jumping = 10, up and waving arms
126
+//        Climbing = 11,
127
+// Giant = 16, Rat (on land)
128
+//         Standing = 1,
129
+//         Jumping = 2, and Biting
130
+//         Running = 3,
131
+//         Biting = 4,
132
+//         Dying = 5,
133
+//         Rearing = 6, up
134
+// Giant = 17, Rat (in water)
135
+//         Swimming = 1,
136
+//         Biting = 2,
137
+//         Dying = 3,
138
+// Tyrannosaur = 18,
139
+//        Standing = 1,
140
+//         Walking = 2,
141
+//         Running = 3,
142
+//         Dying = 5,
143
+//         Bellowing = 6,
144
+//         Biting = 7,
145
+//         Shaking = 8, Head and Spitting Out
146
+// Raptor = 19,
147
+//         Dying = 0,
148
+//         Standing = 1,
149
+//         Walking = 2,
150
+//         Running = 3,
151
+//         Jumping = 4, and Biting?
152
+//         Bellowing = 6,
153
+//         Running = 7, and bellowing
154
+//         Biting = 8,
155
+// Winged = 20, mummy (unused) / Winged mutant
156
+//         Crouching = 1,
157
+//         Walking = 2,
158
+//         Running = 3,
159
+//         Biting = 4,?
160
+//         Looking = 6,
161
+//         Jumping = 7,?
162
+//         Clawing = 8,?
163
+//         Aiming = 9, right-hand gun
164
+//        Aiming = 10, and firing left-hand gun
165
+//        Firing = 11, right-hand gun
166
+//        Standing = 12,
167
+//        Flying = 13,
168
+// Lara = 21,'s hips
169
+//         [Only one state]
170
+// Lara = 22,'s hips
171
+//         [Only one state]
172
+// Centaur = 23, mutant
173
+//         Standing = 1,
174
+//         Firing = 2,
175
+//         Galloping = 3,
176
+//         Aiming = 4,
177
+//         Dying = 5,
178
+//         Rearing = 6, up
179
+// Mummy = 24,
180
+//         Standing = 1,
181
+//         Falling = 2, forward
182
+// Larson = 27,
183
+//         Walking = 0,
184
+//         Standing = 1, holding gun
185
+//         Walking = 2,
186
+//         Running = 3,
187
+//         Aiming = 4, gun
188
+//         Injured = 5, by gunshot / Dying
189
+//         Standing = 6,
190
+//         Firing = 7, gun
191
+// Pierre = 28,
192
+//         Standing = 1,
193
+//         Walking = 2,
194
+//         Running = 3,
195
+//         Aiming = 4, guns
196
+//         Dying = 5,
197
+//         Putting = 6, guns away
198
+//         Firing = 7, guns
199
+// Skateboard = 29,
200
+//         Being = 0, turned around
201
+//         Stationary = 1,
202
+//         Stationary = 2,
203
+//         Stationary = 3,
204
+//         Stationary = 4,
205
+// Skateboard = 30, kid
206
+//         Turning = 0, and Aiming?
207
+//         Firing = 1,
208
+//         Skating = 2,
209
+//         Aiming = 3,
210
+//         Firing = 4,
211
+//         Dying = 5,
212
+// Cowboy = 31,
213
+//         Aiming = 1,
214
+//         Walking = 2,
215
+//         Running = 3,
216
+//         Aiming = 4,
217
+//         Dying = 5,
218
+//         Firing = 6,
219
+//  32: "Mr. T"
220
+//         Dying = 0,
221
+//         Standing = 1,
222
+//         Walking = 2,
223
+//         Running = 3,
224
+//         Aiming = 4,
225
+//         Firing = 6,
226
+// Winged = 33, Natla (actually, Natla with a winged mutant)
227
+//         Standing = 1,
228
+//         Flying = 2,
229
+//         Running = 3,
230
+//         Aiming = 4, and firing
231
+//          5: "Dying" the first time
232
+//         Spinning = 7, around in air
233
+//         Standing = 8,
234
+//         Dying = 9, for real
235
+// Giant = 34, mutant
236
+//         Dying = 0,
237
+//         Sitting = 1, on floor
238
+//         Pulling = 2, self forward
239
+//         Slapping = 4, with right hand
240
+//         Slapping = 5, with both hands
241
+//         Making = 6, big wave with right hand
242
+//         Dropping = 8, to floor after hatching
243
+//         Raising = 9, arms
244
+//         Shaking = 11, victim with right hand
245
+// Collapsible = 35, floor
246
+//         Stationary = 0,
247
+//         Shaking = 1,
248
+//         Falling = 2,
249
+//         Settling = 3, down
250
+// Swinging = 36, blade
251
+//         Stationary = 0,
252
+//         Swinging = 2,
253
+// Spikes = 37,
254
+//         [Only one state]
255
+// Boulder = 38,
256
+//         Stationary = 0,
257
+//         Rolling = 1,
258
+// Dart = 39,
259
+//         [Only one state]
260
+// Wall = 40,-mounted dartgun
261
+//         Idle = 0,?
262
+//         Firing = 1,?
263
+// Door = 41, (opens upward)
264
+//         Upward = 0,
265
+//         On = 1, side
266
+// Slamming = 42, doors
267
+//         Open = 0,
268
+//         Closed = 1,
269
+// Sword = 43, of Damocles
270
+//         [Only one state]
271
+// Thor = 44,'s hammer's handle
272
+//         Stationary = 0, in "up" position
273
+//         Moving = 1, down a little and returning
274
+//         Moving = 2, down all the way
275
+//         Stopped = 3, at "down" position
276
+// Thor = 45,'s hammer's block
277
+//         Stationary = 0,
278
+//         Moving = 1, down a little and returning
279
+//         Moving = 2, down all the way
280
+// Hanging = 46, ball? / Some kind of box?
281
+//         [Only one state]
282
+// Metal = 47, rod? / Powered mining cart
283
+//         Stationary = 0,
284
+//         Moving = 1,
285
+// Movable = 48, cubical block (pushable)
286
+//         Stationary = 0,
287
+//         Being = 1, pulled?
288
+//         Being = 2, pushed?
289
+// Movable = 49, cubical block (pushable)
290
+//         Stationary = 0,
291
+//         Being = 1, pulled?
292
+//         Being = 2, pushed?
293
+// Movable = 50, cubical block (pushable)
294
+//         Stationary = 0,
295
+//         Being = 1, pulled?
296
+//         Being = 2, pushed?
297
+// Movable = 51, cubical block (pushable)
298
+//         Stationary = 0,
299
+//         Being = 1, pulled?
300
+//         Being = 2, pushed?
301
+// Movable = 52, tall block
302
+//         Stationary = 0,
303
+//         Moving = 1, forward?
304
+//         Moving = 2, backward?
305
+// Pieces = 53, of something?
306
+//         Stationary = 0,
307
+//         Falling = 1,
308
+//         Settling = 2, down
309
+// Sword = 54, of Damocles
310
+//         [Only one state]
311
+// Above = 55,-water switch
312
+//         Off = 0,
313
+//         On = 1,
314
+//          [states may be reversed]
315
+// Underwater = 56, switch
316
+//         Off = 0,
317
+//         On = 1,
318
+//          [states may be reversed]
319
+// Door = 57,
320
+//         Closed = 0,
321
+//         Open = 1,
322
+// Door = 58,
323
+//         Closed = 0,
324
+//         Open = 1,
325
+// Door = 59,
326
+//         Closed = 0,
327
+//         Open = 1,
328
+// Door = 60,
329
+//         Closed = 0,
330
+//         Open = 1,
331
+// Door = 61,
332
+//         Closed = 0,
333
+//         Open = 1,
334
+// Door = 62,
335
+//         Closed = 0,
336
+//         Open = 1,
337
+// Door = 63,
338
+//         Closed = 0,
339
+//         Open = 1,
340
+// Door = 64,
341
+//         Closed = 0,
342
+//         Open = 1,
343
+// Trapdoor = 65, (opens downward)
344
+//         Closed = 0,
345
+//         Open = 1,
346
+// Trapdoor = 66, (opens downward)
347
+//         Closed = 0,
348
+//         Open = 1,
349
+// Bridge = 68, (flat)
350
+//         [Only one state]
351
+// Bridge = 69, (slope = 1)
352
+//         [Only one state]
353
+// Bridge = 70, (slope = 2)
354
+//         [Only one state]
355
+// Passport = 71, (opening up)
356
+//         [Only one state]
357
+// Compass = 72,
358
+//         [Only one state]
359
+// Cogs = 74, (animated)
360
+//         Stationary = 0,
361
+//         Turning = 1,
362
+// Cogs = 75, (animated)
363
+//         Stationary = 0,
364
+//         Turning = 1,
365
+// Cogs = 76, (animated)
366
+//         Stationary = 0,
367
+//         Turning = 1,
368
+// Lara = 77, in CS / Scion holder in CS
369
+// Larson = 78, in CS / Natla in CS / Scion holder in CS
370
+// Larson = 79,'s gun in CS / Scion in CS / Natla in CS
371
+// Scion = 80, in CS
372
+// Passport = 81, (closed)
373
+//         [Only one state]
374
+// N = 82,-thingy (Playstation memory card?)
375
+//         [Only one state]
376
+// Save = 83, crystal
377
+//         [Only one state]
378
+//  84: * Pistols
379
+//  85: * Shotgun
380
+//  86: * Magnums
381
+//  87: * Uzis
382
+//  88: * Pistol ammo(?)
383
+//  89: * Shotgun ammo
384
+//  90: * Magnum ammo
385
+//  91: * Uzi ammo
386
+//  93: * Small medipack
387
+//  94: * Large medipack
388
+// Sunglasses = 95,
389
+//         [Only one state]
390
+// Cassette = 96, player and headphones
391
+//         [Only one state]
392
+// Direction = 97, keys
393
+//         [Only one state]
394
+// Pistol = 99,
395
+//         [Only one state]
396
+// 100: Shotgun
397
+//         [Only one state]
398
+// 101: Magnum
399
+//         [Only one state]
400
+// 102: Uzi
401
+//         [Only one state]
402
+// 103: Pistol ammo(?)
403
+//         [Only one state]
404
+// 104: Shotgun ammo
405
+//         [Only one state]
406
+// 105: Magnum ammo
407
+//         [Only one state]
408
+// 106: Uzi ammo
409
+//         [Only one state]
410
+// 108: Small medipack
411
+//         [Only one state]
412
+// 109: Large medipack
413
+//         [Only one state]
414
+// 110: * Puzzle 1
415
+// 111: * Puzzle 2
416
+// 112: * Puzzle 3
417
+// 113: * Puzzle 4
418
+// 114: Puzzle 1
419
+//         [Only one state]
420
+// 115: Puzzle 2
421
+//         [Only one state]
422
+// 116: Puzzle 3
423
+//         [Only one state]
424
+// 117: Puzzle 4
425
+//         [Only one state]
426
+// 118: Slot 1 empty
427
+//         [Only one state]
428
+// 119: Slot 2 empty
429
+//         [Only one state]
430
+// 120: Slot 3 empty
431
+//         [Only one state]
432
+// 121: Slot 4 empty
433
+//         [Only one state]
434
+// 122: Slot 1 full
435
+//         [Only one state]
436
+// 123: Slot 2 full
437
+//         [Only one state]
438
+// 124: Slot 3 full
439
+//         [Only one state]
440
+// 125: Slot 4 full
441
+//         [Only one state]
442
+// 126: * Pickup 1
443
+// 127: Pickup 1
444
+//         [Only one state]
445
+// 128: Lara's hips
446
+//         [Only one state]
447
+// 129: * Key 1
448
+// 130: * Key 2
449
+// 131: * Key 3
450
+// 132: * Key 4
451
+// 133: Key 1
452
+//         [Only one state]
453
+// 134: Key 2
454
+//         [Only one state]
455
+// 135: Key 3
456
+//         [Only one state]
457
+// 136: Key 4
458
+//         [Only one state]
459
+// 137: Lock 1
460
+//         [Only one state]
461
+// 138: Lock 2
462
+//         [Only one state]
463
+// 139: Lock 3
464
+//         [Only one state]
465
+// 140: Lock 4
466
+//         [Only one state]
467
+// 143: * Scion Piece
468
+// 146: Complete Scion
469
+//         [Only one state]
470
+// 147: Scion Holder
471
+//         [Only one state]
472
+// 150: Scion Piece
473
+//         [Only one state]
474
+// 151: * Flare(?) / Explosion
475
+// 153: * Splash
476
+// 155: * Bubbles
477
+// 156: * Bubbles
478
+// 158: * Blood splatter
479
+// 160: * Flying disk
480
+// 161: Centaur statue
481
+//         [Only one state]
482
+// 162: Shack suspended from wire rope
483
+//         Starting = 0, position
484
+//         Dropping = 1, after first fuse
485
+//         Dropping = 2, after second fuse
486
+//         Dropping = 3, after third fuse (to ground)
487
+//         On = 4, the ground
488
+// 163: Mutant egg and holder (normal size)
489
+//         Starting = 0, to hatch
490
+//         Hatching = 1, (is the fragmenting hardcoded?)
491
+// 164: * Bullet hit
492
+// 165: * Sparkle
493
+// 166: Gunflare
494
+//         [Only one state]
495
+// 169: Lara's hips
496
+//         [Only one state]
497
+// 170: Lara's hips
498
+//         [Only one state]
499
+// 172: Mutant bullet
500
+//         [Only one state]
501
+// 173: Mutant grenade
502
+//         [Only one state]
503
+// 176: * Splatter
504
+// 177: Lara's hips
505
+//         [Only one state]
506
+// 178: * Fire
507
+// 179: Lara's hips
508
+//         [Only one state]
509
+// 180: Flowing Atlantean lava
510
+//         [Only one state]
511
+// 181: Mutant egg and holder (big)
512
+//         Starting = 0, to hatch
513
+//         Hatching = 1, (is the fragmenting hardcoded?)
514
+// 182: Motorboat
515
+//         Stationary = 1, (initial)
516
+//         Moving = 2,
517
+//         Stationary = 3, (final)
518
+// 183: Lara's hips
519
+//         [Only one state]
520
+// 189: Shrinking wedge?
521
+//         [Only one state]
522
+// 190: * Standard symbols
523
+// 191: * Plant 1
524
+// 192: * Plant 2
525
+// 193: * Plant 3
526
+// 194: * Plant 4
527
+// 195: * Plant 5
528
+// 200: * Bag 1
529
+// 204: * Bag 2
530
+// 207: Gunflare
531
+//         [Only one state]
532
+// 212: * Rock 1
533
+// 213: * Rock 2
534
+// 214: * Rock 3
535
+// 215: * Bag 3
536
+// 216: * Pottery 1
537
+// 217: * Pottery 2
538
+// 231: * Painted pot
539
+// 233: * Inca mummy
540
+// 236: * Pottery 3
541
+// 237: * Pottery 4
542
+// 238: * Pottery 5
543
+// 239: * Pottery 6
544
+
545
+#endif
546
+
547
+
548
+#endif

+ 486
- 0
src/TombRaider5.h 파일 보기

@@ -0,0 +1,486 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : OpenRaider
5
+ * Author  : Mongoose
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : 
9
+ * License : GPL, also (C) 2002 Mongoose
10
+ * Comments: 
11
+ *
12
+ *-- History ------------------------------------------------ 
13
+ *
14
+ * 2002.04.04:
15
+ * Mongoose - Created, based on work by ? ( one of the TRE guys )
16
+ ================================================================*/
17
+
18
+typedef enum
19
+{
20
+		TR4_OBJ_LARA = 0,
21
+		TR4_OBJ_PISTOLS_ANIM = 1,
22
+		TR4_OBJ_UZI_ANIM = 2,
23
+		TR4_OBJ_SHOTGUN_ANIM = 3,
24
+		TR4_OBJ_CROSSBOW_ANIM = 4,
25
+		TR4_OBJ_GRENADE_GUN_ANIM = 5,
26
+		TR4_OBJ_SIXSHOOTER_ANIM = 6,
27
+		TR4_OBJ_FLARE_ANIM = 7,
28
+		TR4_OBJ_LARA_SKIN = 8,
29
+		TR4_OBJ_LARA_SKIN_JOINTS = 9,
30
+		TR4_OBJ_LARA_SCREAM = 10,
31
+		TR4_OBJ_LARA_CROSSBOW_LASER = 11,
32
+		TR4_OBJ_LARA_REVOLVER_LASER = 12,
33
+		TR4_OBJ_LARA_HOLSTERS = 13,
34
+		TR4_OBJ_LARA_HOLSTERS_PISTOLS = 14,
35
+		TR4_OBJ_LARA_HOLSTERS_UZIS = 15,
36
+		TR4_OBJ_LARA_HOLSTERS_SIXSHOOTER = 16,
37
+		TR4_OBJ_LARA_SPEECH_HEAD1 = 17,
38
+		TR4_OBJ_LARA_SPEECH_HEAD2 = 18,
39
+		TR4_OBJ_LARA_SPEECH_HEAD3 = 19,
40
+		TR4_OBJ_LARA_SPEECH_HEAD4 = 20,
41
+		TR4_OBJ_ACTOR1_SPEECH_HEAD1 = 21,
42
+		TR4_OBJ_ACTOR1_SPEECH_HEAD2 = 22,
43
+		TR4_OBJ_ACTOR2_SPEECH_HEAD1 = 23,
44
+		TR4_OBJ_ACTOR2_SPEECH_HEAD2 = 24,
45
+		TR4_OBJ_LARA_WATER_MESH = 25,
46
+		TR4_OBJ_LARA_PETROL_MESH = 26,
47
+		TR4_OBJ_LARA_DIRT_MESH = 27,
48
+		TR4_OBJ_CROWBAR_ANIM = 28,
49
+		TR4_OBJ_TORCH_ANIM = 29,
50
+		TR4_OBJ_HAIR = 30,
51
+		TR4_OBJ_MOTORBIKE = 31,
52
+		TR4_OBJ_JEEP = 32,
53
+		TR4_OBJ_VEHICLE_EXTRA = 33,
54
+		TR4_OBJ_ENEMY_JEEP = 34,
55
+		TR4_OBJ_SKELETON = 35,
56
+		TR4_OBJ_SKELETON_MIP = 36,
57
+		TR4_OBJ_GUIDE = 37,
58
+		TR4_OBJ_GUIDE_MIP = 38,
59
+		TR4_OBJ_VON_CROY = 39,
60
+		TR4_OBJ_VON_CROY_MIP = 40,
61
+		TR4_OBJ_BADDY_1 = 41,
62
+		TR4_OBJ_BADDY_1_MIP = 42,
63
+		TR4_OBJ_BADDY_2 = 43,
64
+		TR4_OBJ_BADDY_2_MIP = 44,
65
+		TR4_OBJ_SETHA = 45,
66
+		TR4_OBJ_SETHA_MIP = 46,
67
+		TR4_OBJ_MUMMY = 47,
68
+		TR4_OBJ_MUMMY_MIP = 48,
69
+		TR4_OBJ_SPHINX = 49,
70
+		TR4_OBJ_SPHINX_MIP = 50,
71
+		TR4_OBJ_CROCODILE = 51,
72
+		TR4_OBJ_CROCODILE_MIP = 52,
73
+		TR4_OBJ_HORSEMAN = 53,
74
+		TR4_OBJ_HORSEMAN_MIP = 54,
75
+		TR4_OBJ_SCORPION = 55,
76
+		TR4_OBJ_SCORPION_MIP = 56,
77
+		TR4_OBJ_JEAN_YVES = 57,
78
+		TR4_OBJ_JEAN_YVES_MIP = 58,
79
+		TR4_OBJ_TROOPS = 59,
80
+		TR4_OBJ_TROOPS_MIP = 60,
81
+		TR4_OBJ_KNIGHTS_TEMPLAR = 61,
82
+		TR4_OBJ_KNIGHTS_TEMPLAR_MIP = 62,
83
+		TR4_OBJ_MUTANT = 63,
84
+		TR4_OBJ_MUTANT_MIP = 64,
85
+		TR4_OBJ_HORSE = 65,
86
+		TR4_OBJ_HORSE_MIP = 66,
87
+		TR4_OBJ_BABOON_NORMAL = 67,
88
+		TR4_OBJ_BABOON_NORMAL_MIP = 68,
89
+		TR4_OBJ_BABOON_INV = 69,
90
+		TR4_OBJ_BABOON_INV_MIP = 70,
91
+		TR4_OBJ_BABOON_SILENT = 71,
92
+		TR4_OBJ_BABOON_SILENT_MIP = 72,
93
+		TR4_OBJ_WILD_BOAR = 73,
94
+		TR4_OBJ_WILD_BOAR_MIP = 74,
95
+		TR4_OBJ_HARPY = 75,
96
+		TR4_OBJ_HARPY_MIP = 76,
97
+		TR4_OBJ_DEMIGOD1 = 77,
98
+		TR4_OBJ_DEMIGOD1_MIP = 78,
99
+		TR4_OBJ_DEMIGOD2 = 79,
100
+		TR4_OBJ_DEMIGOD2_MIP = 80,
101
+		TR4_OBJ_DEMIGOD3 = 81,
102
+		TR4_OBJ_DEMIGOD3_MIP = 82,
103
+		TR4_OBJ_LITTLE_BEETLE = 83,
104
+		TR4_OBJ_BIG_BEETLE = 84,
105
+		TR4_OBJ_BIG_BEETLE_MIP = 85,
106
+		TR4_OBJ_WRAITH1 = 86,
107
+		TR4_OBJ_WRAITH2 = 87,
108
+		TR4_OBJ_WRAITH3 = 88,
109
+		TR4_OBJ_WRAITH4 = 89,
110
+		TR4_OBJ_BAT = 90,
111
+		TR4_OBJ_DOG = 91,
112
+		TR4_OBJ_DOG_MIP = 92,
113
+		TR4_OBJ_HAMMERHEAD = 93,
114
+		TR4_OBJ_HAMMERHEAD_MIP = 94,
115
+		TR4_OBJ_SAS = 95,
116
+		TR4_OBJ_SAS_MIP = 96,
117
+		TR4_OBJ_SAS_DYING = 97,
118
+		TR4_OBJ_SAS_DYING_MIP = 98,
119
+		TR4_OBJ_SAS_CAPTAIN = 99,
120
+		TR4_OBJ_SAS_CAPTAIN_MIP = 100,
121
+		TR4_OBJ_SAS_DRAG_BLOKE = 101,
122
+		TR4_OBJ_AHMET = 102,
123
+		TR4_OBJ_AHMET_MIP = 103,
124
+		TR4_OBJ_LARA_DOUBLE = 104,
125
+		TR4_OBJ_LARA_DOUBLE_MIP = 105,
126
+		TR4_OBJ_SMALL_SCORPION = 106,
127
+		TR4_OBJ_FISH = 107,
128
+		TR4_OBJ_GAME_PIECE1 = 108,
129
+		TR4_OBJ_GAME_PIECE2 = 109,
130
+		TR4_OBJ_GAME_PIECE3 = 110,
131
+		TR4_OBJ_ENEMY_PIECE = 111,
132
+		TR4_OBJ_WHEEL_OF_FORTUNE = 112,
133
+		TR4_OBJ_SCALES = 113,
134
+		TR4_OBJ_DARTS = 114,
135
+		TR4_OBJ_DART_EMITTER = 115,
136
+		TR4_OBJ_HOMING_DART_EMITTER = 116,
137
+		TR4_OBJ_FALLING_CEILING = 117,
138
+		TR4_OBJ_FALLING_BLOCK = 118,
139
+		TR4_OBJ_FALLING_BLOCK2 = 119,
140
+		TR4_OBJ_SMASHABLE_BIKE_WALL = 120,
141
+		TR4_OBJ_SMASHABLE_BIKE_FLOOR = 121,
142
+		TR4_OBJ_TRAPDOOR1 = 122,
143
+		TR4_OBJ_TRAPDOOR2 = 123,
144
+		TR4_OBJ_TRAPDOOR3 = 124,
145
+		TR4_OBJ_FLOOR_TRAPDOOR1 = 125,
146
+		TR4_OBJ_FLOOR_TRAPDOOR2 = 126,
147
+		TR4_OBJ_CEILING_TRAPDOOR1 = 127,
148
+		TR4_OBJ_CEILING_TRAPDOOR2 = 128,
149
+		TR4_OBJ_SCALING_TRAPDOOR = 129,
150
+		TR4_OBJ_ROLLINGBALL = 130,
151
+		TR4_OBJ_SPIKEY_FLOOR = 131,
152
+		TR4_OBJ_TEETH_SPIKES = 132,
153
+		TR4_OBJ_JOBY_SPIKES = 133,
154
+		TR4_OBJ_SLICER_DICER = 134,
155
+		TR4_OBJ_CHAIN = 135,
156
+		TR4_OBJ_PLOUGH = 136,
157
+		TR4_OBJ_STARGATE = 137,
158
+		TR4_OBJ_HAMMER = 138,
159
+		TR4_OBJ_BURNING_FLOOR = 139,
160
+		TR4_OBJ_COG = 140,
161
+		TR4_OBJ_SPIKEBALL = 141,
162
+		TR4_OBJ_FLAME = 142,
163
+		TR4_OBJ_FLAME_EMITTER = 143,
164
+		TR4_OBJ_FLAME_EMITTER2 = 144,
165
+		TR4_OBJ_FLAME_EMITTER3 = 145,
166
+		TR4_OBJ_ROPE = 146,
167
+		TR4_OBJ_FIREROPE = 147,
168
+		TR4_OBJ_POLEROPE = 148,
169
+		TR4_OBJ_ONEBLOCK_PLATFORM = 149,
170
+		TR4_OBJ_TWOBLOCK_PLATFORM = 150,
171
+		TR4_OBJ_RAISING_BLOCK1 = 151,
172
+		TR4_OBJ_RAISING_BLOCK2 = 152,
173
+		TR4_OBJ_EXPANDING_PLATFORM = 153,
174
+		TR4_OBJ_SQUISHY_BLOCK1 = 154,
175
+		TR4_OBJ_SQUISHY_BLOCK2 = 155,
176
+		TR4_OBJ_PUSHABLE_OBJECT1 = 156,
177
+		TR4_OBJ_PUSHABLE_OBJECT2 = 157,
178
+		TR4_OBJ_PUSHABLE_OBJECT3 = 158,
179
+		TR4_OBJ_PUSHABLE_OBJECT4 = 159,
180
+		TR4_OBJ_PUSHABLE_OBJECT5 = 160,
181
+		TR4_OBJ_TRIPWIRE = 161,
182
+		TR4_OBJ_SENTRY_GUN = 162,
183
+		TR4_OBJ_MINE = 163,
184
+		TR4_OBJ_MAPPER = 164,
185
+		TR4_OBJ_OBELISK = 165,
186
+		TR4_OBJ_FLOOR_4BLADE = 166,
187
+		TR4_OBJ_ROOF_4BLADE = 167,
188
+		TR4_OBJ_BIRD_BLADE = 168,
189
+		TR4_OBJ_CATWALK_BLADE = 169,
190
+		TR4_OBJ_MOVING_BLADE = 170,
191
+		TR4_OBJ_PLINTH_BLADE = 171,
192
+		TR4_OBJ_SETH_BLADE = 172,
193
+		TR4_OBJ_LIGHTNING_CONDUCTOR = 173,
194
+		TR4_OBJ_ELEMENT_PUZZLE = 174,
195
+		TR4_OBJ_PUZZLE_ITEM1 = 175,
196
+		TR4_OBJ_PUZZLE_ITEM2 = 176,
197
+		TR4_OBJ_PUZZLE_ITEM3 = 177,
198
+		TR4_OBJ_PUZZLE_ITEM4 = 178,
199
+		TR4_OBJ_PUZZLE_ITEM5 = 179,
200
+		TR4_OBJ_PUZZLE_ITEM6 = 180,
201
+		TR4_OBJ_PUZZLE_ITEM7 = 181,
202
+		TR4_OBJ_PUZZLE_ITEM8 = 182,
203
+		TR4_OBJ_PUZZLE_ITEM9 = 183,
204
+		TR4_OBJ_PUZZLE_ITEM10 = 184,
205
+		TR4_OBJ_PUZZLE_ITEM11 = 185,
206
+		TR4_OBJ_PUZZLE_ITEM12 = 186,
207
+		TR4_OBJ_PUZZLE_ITEM1_COMBO1 = 187,
208
+		TR4_OBJ_PUZZLE_ITEM1_COMBO2 = 188,
209
+		TR4_OBJ_PUZZLE_ITEM2_COMBO1 = 189,
210
+		TR4_OBJ_PUZZLE_ITEM2_COMBO2 = 190,
211
+		TR4_OBJ_PUZZLE_ITEM3_COMBO1 = 191,
212
+		TR4_OBJ_PUZZLE_ITEM3_COMBO2 = 192,
213
+		TR4_OBJ_PUZZLE_ITEM4_COMBO1 = 193,
214
+		TR4_OBJ_PUZZLE_ITEM4_COMBO2 = 194,
215
+		TR4_OBJ_PUZZLE_ITEM5_COMBO1 = 195,
216
+		TR4_OBJ_PUZZLE_ITEM5_COMBO2 = 196,
217
+		TR4_OBJ_PUZZLE_ITEM6_COMBO1 = 197,
218
+		TR4_OBJ_PUZZLE_ITEM6_COMBO2 = 198,
219
+		TR4_OBJ_PUZZLE_ITEM7_COMBO1 = 199,
220
+		TR4_OBJ_PUZZLE_ITEM7_COMBO2 = 200,
221
+		TR4_OBJ_PUZZLE_ITEM8_COMBO1 = 201,
222
+		TR4_OBJ_PUZZLE_ITEM8_COMBO2 = 202,
223
+		TR4_OBJ_KEY_ITEM1 = 203,
224
+		TR4_OBJ_KEY_ITEM2 = 204,
225
+		TR4_OBJ_KEY_ITEM3 = 205,
226
+		TR4_OBJ_KEY_ITEM4 = 206,
227
+		TR4_OBJ_KEY_ITEM5 = 207,
228
+		TR4_OBJ_KEY_ITEM6 = 208,
229
+		TR4_OBJ_KEY_ITEM7 = 209,
230
+		TR4_OBJ_KEY_ITEM8 = 210,
231
+		TR4_OBJ_KEY_ITEM9 = 211,
232
+		TR4_OBJ_KEY_ITEM10 = 212,
233
+		TR4_OBJ_KEY_ITEM11 = 213,
234
+		TR4_OBJ_KEY_ITEM12 = 214,
235
+		TR4_OBJ_KEY_ITEM1_COMBO1 = 215,
236
+		TR4_OBJ_KEY_ITEM1_COMBO2 = 216,
237
+		TR4_OBJ_KEY_ITEM2_COMBO1 = 217,
238
+		TR4_OBJ_KEY_ITEM2_COMBO2 = 218,
239
+		TR4_OBJ_KEY_ITEM3_COMBO1 = 219,
240
+		TR4_OBJ_KEY_ITEM3_COMBO2 = 220,
241
+		TR4_OBJ_KEY_ITEM4_COMBO1 = 221,
242
+		TR4_OBJ_KEY_ITEM4_COMBO2 = 222,
243
+		TR4_OBJ_KEY_ITEM5_COMBO1 = 223,
244
+		TR4_OBJ_KEY_ITEM5_COMBO2 = 224,
245
+		TR4_OBJ_KEY_ITEM6_COMBO1 = 225,
246
+		TR4_OBJ_KEY_ITEM6_COMBO2 = 226,
247
+		TR4_OBJ_KEY_ITEM7_COMBO1 = 227,
248
+		TR4_OBJ_KEY_ITEM7_COMBO2 = 228,
249
+		TR4_OBJ_KEY_ITEM8_COMBO1 = 229,
250
+		TR4_OBJ_KEY_ITEM8_COMBO2 = 230,
251
+		TR4_OBJ_PICKUP_ITEM1 = 231,
252
+		TR4_OBJ_PICKUP_ITEM2 = 232,
253
+		TR4_OBJ_PICKUP_ITEM3 = 233,
254
+		TR4_OBJ_PICKUP_ITEM4 = 234,
255
+		TR4_OBJ_PICKUP_ITEM1_COMBO1 = 235,
256
+		TR4_OBJ_PICKUP_ITEM1_COMBO2 = 236,
257
+		TR4_OBJ_PICKUP_ITEM2_COMBO1 = 237,
258
+		TR4_OBJ_PICKUP_ITEM2_COMBO2 = 238,
259
+		TR4_OBJ_PICKUP_ITEM3_COMBO1 = 239,
260
+		TR4_OBJ_PICKUP_ITEM3_COMBO2 = 240,
261
+		TR4_OBJ_PICKUP_ITEM4_COMBO1 = 241,
262
+		TR4_OBJ_PICKUP_ITEM4_COMBO2 = 242,
263
+		TR4_OBJ_EXAMINE1 = 243,
264
+		TR4_OBJ_EXAMINE2 = 244,
265
+		TR4_OBJ_EXAMINE3 = 245,
266
+		TR4_OBJ_CROWBAR_ITEM = 246,
267
+		TR4_OBJ_BURNING_TORCH_ITEM = 247,
268
+		TR4_OBJ_CLOCKWORK_BEETLE = 248,
269
+		TR4_OBJ_CLOCKWORK_BEETLE_COMBO1 = 249,
270
+		TR4_OBJ_CLOCKWORK_BEETLE_COMBO2 = 250,
271
+		TR4_OBJ_MINE_DETECTOR = 251,
272
+		TR4_OBJ_QUEST_ITEM1 = 252,
273
+		TR4_OBJ_QUEST_ITEM2 = 253,
274
+		TR4_OBJ_QUEST_ITEM3 = 254,
275
+		TR4_OBJ_QUEST_ITEM4 = 255,
276
+		TR4_OBJ_QUEST_ITEM5 = 256,
277
+		TR4_OBJ_QUEST_ITEM6 = 257,
278
+		TR4_OBJ_MAP = 258,
279
+		TR4_OBJ_SECRET_MAP = 259,
280
+		TR4_OBJ_PUZZLE_HOLE1 = 260,
281
+		TR4_OBJ_PUZZLE_HOLE2 = 261,
282
+		TR4_OBJ_PUZZLE_HOLE3 = 262,
283
+		TR4_OBJ_PUZZLE_HOLE4 = 263,
284
+		TR4_OBJ_PUZZLE_HOLE5 = 264,
285
+		TR4_OBJ_PUZZLE_HOLE6 = 265,
286
+		TR4_OBJ_PUZZLE_HOLE7 = 266,
287
+		TR4_OBJ_PUZZLE_HOLE8 = 267,
288
+		TR4_OBJ_PUZZLE_HOLE9 = 268,
289
+		TR4_OBJ_PUZZLE_HOLE10 = 269,
290
+		TR4_OBJ_PUZZLE_HOLE11 = 270,
291
+		TR4_OBJ_PUZZLE_HOLE12 = 271,
292
+		TR4_OBJ_PUZZLE_DONE1 = 272,
293
+		TR4_OBJ_PUZZLE_DONE2 = 273,
294
+		TR4_OBJ_PUZZLE_DONE3 = 274,
295
+		TR4_OBJ_PUZZLE_DONE4 = 275,
296
+		TR4_OBJ_PUZZLE_DONE5 = 276,
297
+		TR4_OBJ_PUZZLE_DONE6 = 277,
298
+		TR4_OBJ_PUZZLE_DONE7 = 278,
299
+		TR4_OBJ_PUZZLE_DONE8 = 279,
300
+		TR4_OBJ_PUZZLE_DONE9 = 280,
301
+		TR4_OBJ_PUZZLE_DONE10 = 281,
302
+		TR4_OBJ_PUZZLE_DONE11 = 282,
303
+		TR4_OBJ_PUZZLE_DONE12 = 283,
304
+		TR4_OBJ_KEY_HOLE1 = 284,
305
+		TR4_OBJ_KEY_HOLE2 = 285,
306
+		TR4_OBJ_KEY_HOLE3 = 286,
307
+		TR4_OBJ_KEY_HOLE4 = 287,
308
+		TR4_OBJ_KEY_HOLE5 = 288,
309
+		TR4_OBJ_KEY_HOLE6 = 289,
310
+		TR4_OBJ_KEY_HOLE7 = 290,
311
+		TR4_OBJ_KEY_HOLE8 = 291,
312
+		TR4_OBJ_KEY_HOLE9 = 292,
313
+		TR4_OBJ_KEY_HOLE10 = 293,
314
+		TR4_OBJ_KEY_HOLE11 = 294,
315
+		TR4_OBJ_KEY_HOLE12 = 295,
316
+		TR4_OBJ_WATERSKIN1_EMPTY = 296,
317
+		TR4_OBJ_WATERSKIN1_1 = 297,
318
+		TR4_OBJ_WATERSKIN1_2 = 298,
319
+		TR4_OBJ_WATERSKIN1_3 = 299,
320
+		TR4_OBJ_WATERSKIN2_EMPTY = 300,
321
+		TR4_OBJ_WATERSKIN2_1 = 301,
322
+		TR4_OBJ_WATERSKIN2_2 = 302,
323
+		TR4_OBJ_WATERSKIN2_3 = 303,
324
+		TR4_OBJ_WATERSKIN2_4 = 304,
325
+		TR4_OBJ_WATERSKIN2_5 = 305,
326
+		TR4_OBJ_SWITCH_TYPE1 = 306,
327
+		TR4_OBJ_SWITCH_TYPE2 = 307,
328
+		TR4_OBJ_SWITCH_TYPE3 = 308,
329
+		TR4_OBJ_SWITCH_TYPE4 = 309,
330
+		TR4_OBJ_SWITCH_TYPE5 = 310,
331
+		TR4_OBJ_SWITCH_TYPE6 = 311,
332
+		TR4_OBJ_SWITCH_TYPE7 = 312,
333
+		TR4_OBJ_SWITCH_TYPE8 = 313,
334
+		TR4_OBJ_UNDERWATER_SWITCH1 = 314,
335
+		TR4_OBJ_UNDERWATER_SWITCH2 = 315,
336
+		TR4_OBJ_TURN_SWITCH = 316,
337
+		TR4_OBJ_COG_SWITCH = 317,
338
+		TR4_OBJ_LEVER_SWITCH = 318,
339
+		TR4_OBJ_JUMP_SWITCH = 319,
340
+		TR4_OBJ_CROWBAR_SWITCH = 320,
341
+		TR4_OBJ_PULLEY = 321,
342
+		TR4_OBJ_DOOR_TYPE1 = 322,
343
+		TR4_OBJ_DOOR_TYPE2 = 323,
344
+		TR4_OBJ_DOOR_TYPE3 = 324,
345
+		TR4_OBJ_DOOR_TYPE4 = 325,
346
+		TR4_OBJ_DOOR_TYPE5 = 326,
347
+		TR4_OBJ_DOOR_TYPE6 = 327,
348
+		TR4_OBJ_DOOR_TYPE7 = 328,
349
+		TR4_OBJ_DOOR_TYPE8 = 329,
350
+		TR4_OBJ_PUSHPULL_DOOR1 = 330,
351
+		TR4_OBJ_PUSHPULL_DOOR2 = 331,
352
+		TR4_OBJ_KICK_DOOR1 = 332,
353
+		TR4_OBJ_KICK_DOOR2 = 333,
354
+		TR4_OBJ_UNDERWATER_DOOR = 334,
355
+		TR4_OBJ_DOUBLE_DOORS = 335,
356
+		TR4_OBJ_BRIDGE_FLAT = 336,
357
+		TR4_OBJ_BRIDGE_TILT1 = 337,
358
+		TR4_OBJ_BRIDGE_TILT2 = 338,
359
+		TR4_OBJ_SARCOPHAGUS = 339,
360
+		TR4_OBJ_SEQUENCE_DOOR1 = 340,
361
+		TR4_OBJ_SEQUENCE_SWITCH1 = 341,
362
+		TR4_OBJ_SEQUENCE_SWITCH2 = 342,
363
+		TR4_OBJ_SEQUENCE_SWITCH3 = 343,
364
+		TR4_OBJ_SARCOPHAGUS_CUT = 344,
365
+		TR4_OBJ_HORUS_STATUE = 345,
366
+		TR4_OBJ_GOD_HEAD = 346,
367
+		TR4_OBJ_SETH_DOOR = 347,
368
+		TR4_OBJ_STATUE_PLINTH = 348,
369
+		TR4_OBJ_PISTOLS_ITEM = 349,
370
+		TR4_OBJ_PISTOLS_AMMO_ITEM = 350,
371
+		TR4_OBJ_UZI_ITEM = 351,
372
+		TR4_OBJ_UZI_AMMO_ITEM = 352,
373
+		TR4_OBJ_SHOTGUN_ITEM = 353,
374
+		TR4_OBJ_SHOTGUN_AMMO1_ITEM = 354,
375
+		TR4_OBJ_SHOTGUN_AMMO2_ITEM = 355,
376
+		TR4_OBJ_CROSSBOW_ITEM = 356,
377
+		TR4_OBJ_CROSSBOW_AMMO1_ITEM = 357,
378
+		TR4_OBJ_CROSSBOW_AMMO2_ITEM = 358,
379
+		TR4_OBJ_CROSSBOW_AMMO3_ITEM = 359,
380
+		TR4_OBJ_CROSSBOW_BOLT = 360,
381
+		TR4_OBJ_GRENADE_GUN_ITEM = 361,
382
+		TR4_OBJ_GRENADE_GUN_AMMO1_ITEM = 362,
383
+		TR4_OBJ_GRENADE_GUN_AMMO2_ITEM = 363,
384
+		TR4_OBJ_GRENADE_GUN_AMMO3_ITEM = 364,
385
+		TR4_OBJ_GRENADE = 365,
386
+		TR4_OBJ_SIXSHOOTER_ITEM = 366,
387
+		TR4_OBJ_SIXSHOOTER_AMMO_ITEM = 367,
388
+		TR4_OBJ_BIGMEDI_ITEM = 368,
389
+		TR4_OBJ_SMALLMEDI_ITEM = 369,
390
+		TR4_OBJ_LASERSIGHT_ITEM = 370,
391
+		TR4_OBJ_BINOCULARS_ITEM = 371,
392
+		TR4_OBJ_FLARE_ITEM = 372,
393
+		TR4_OBJ_FLARE_INV_ITEM = 373,
394
+		TR4_OBJ_DIARY_ITEM = 374,
395
+		TR4_OBJ_COMPASS_ITEM = 375,
396
+		TR4_OBJ_MEMCARD_LOAD_INV_ITEM = 376,
397
+		TR4_OBJ_MEMCARD_SAVE_INV_ITEM = 377,
398
+		TR4_OBJ_PC_LOAD_INV_ITEM = 378,
399
+		TR4_OBJ_PC_SAVE_INV_ITEM = 379,
400
+		TR4_OBJ_SMOKE_EMITTER_WHITE = 380,
401
+		TR4_OBJ_SMOKE_EMITTER_BLACK = 381,
402
+		TR4_OBJ_STEAM_EMITTER = 382,
403
+		TR4_OBJ_EARTHQUAKE = 383,
404
+		TR4_OBJ_BUBBLES = 384,
405
+		TR4_OBJ_WATERFALLMIST = 385,
406
+		TR4_OBJ_GUNSHELL = 386,
407
+		TR4_OBJ_SHOTGUNSHELL = 387,
408
+		TR4_OBJ_GUN_FLASH = 388,
409
+		TR4_OBJ_BUTTERFLY = 389,
410
+		TR4_OBJ_SPRINKLER = 390,
411
+		TR4_OBJ_RED_LIGHT = 391,
412
+		TR4_OBJ_GREEN_LIGHT = 392,
413
+		TR4_OBJ_BLUE_LIGHT = 393,
414
+		TR4_OBJ_AMBER_LIGHT = 394,
415
+		TR4_OBJ_WHITE_LIGHT = 395,
416
+		TR4_OBJ_BLINKING_LIGHT = 396,
417
+		TR4_OBJ_LENS_FLARE = 397,
418
+		TR4_OBJ_AI_GUARD = 398,
419
+		TR4_OBJ_AI_AMBUSH = 399,
420
+		TR4_OBJ_AI_PATROL1 = 400,
421
+		TR4_OBJ_AI_MODIFY = 401,
422
+		TR4_OBJ_AI_FOLLOW = 402,
423
+		TR4_OBJ_AI_PATROL2 = 403,
424
+		TR4_OBJ_AI_X1 = 404,
425
+		TR4_OBJ_AI_X2 = 405,
426
+		TR4_OBJ_LARA_START_POS = 406,
427
+		TR4_OBJ_KILL_ALL_TRIGGERS = 407,
428
+		TR4_OBJ_TRIGGER_TRIGGERER = 408,
429
+		TR4_OBJ_SMASH_OBJECT1 = 409,
430
+		TR4_OBJ_SMASH_OBJECT2 = 410,
431
+		TR4_OBJ_SMASH_OBJECT3 = 411,
432
+		TR4_OBJ_SMASH_OBJECT4 = 412,
433
+		TR4_OBJ_SMASH_OBJECT5 = 413,
434
+		TR4_OBJ_SMASH_OBJECT6 = 414,
435
+		TR4_OBJ_SMASH_OBJECT7 = 415,
436
+		TR4_OBJ_SMASH_OBJECT8 = 416,
437
+		TR4_OBJ_MESHSWAP1 = 417,
438
+		TR4_OBJ_MESHSWAP2 = 418,
439
+		TR4_OBJ_MESHSWAP3 = 419,
440
+		TR4_OBJ_DEATH_SLIDE = 420,
441
+		TR4_OBJ_BODY_PART = 421,
442
+		TR4_OBJ_CAMERA_TARGET = 422,
443
+		TR4_OBJ_WATERFALL1 = 423,
444
+		TR4_OBJ_WATERFALL2 = 424,
445
+		TR4_OBJ_WATERFALL3 = 425,
446
+		TR4_OBJ_PLANET_EFFECT = 426,
447
+		TR4_OBJ_ANIMATING1 = 427,
448
+		TR4_OBJ_ANIMATING1_MIP = 428,
449
+		TR4_OBJ_ANIMATING2 = 429,
450
+		TR4_OBJ_ANIMATING2_MIP = 430,
451
+		TR4_OBJ_ANIMATING3 = 431,
452
+		TR4_OBJ_ANIMATING3_MIP = 432,
453
+		TR4_OBJ_ANIMATING4 = 433,
454
+		TR4_OBJ_ANIMATING4_MIP = 434,
455
+		TR4_OBJ_ANIMATING5 = 435,
456
+		TR4_OBJ_ANIMATING5_MIP = 436,
457
+		TR4_OBJ_ANIMATING6 = 437,
458
+		TR4_OBJ_ANIMATING6_MIP = 438,
459
+		TR4_OBJ_ANIMATING7 = 439,
460
+		TR4_OBJ_ANIMATING7_MIP = 440,
461
+		TR4_OBJ_ANIMATING8 = 441,
462
+		TR4_OBJ_ANIMATING8_MIP = 442,
463
+		TR4_OBJ_ANIMATING9 = 443,
464
+		TR4_OBJ_ANIMATING9_MIP = 444,
465
+		TR4_OBJ_ANIMATING10 = 445,
466
+		TR4_OBJ_ANIMATING10_MIP = 446,
467
+		TR4_OBJ_ANIMATING11 = 447,
468
+		TR4_OBJ_ANIMATING11_MIP = 448,
469
+		TR4_OBJ_ANIMATING12 = 449,
470
+		TR4_OBJ_ANIMATING12_MIP = 450,
471
+		TR4_OBJ_ANIMATING13 = 451,
472
+		TR4_OBJ_ANIMATING13_MIP = 452,
473
+		TR4_OBJ_ANIMATING14 = 453,
474
+		TR4_OBJ_ANIMATING14_MIP = 454,
475
+		TR4_OBJ_ANIMATING15 = 455,
476
+		TR4_OBJ_ANIMATING15_MIP = 456,
477
+		TR4_OBJ_ANIMATING16 = 457,
478
+		TR4_OBJ_ANIMATING16_MIP = 458,
479
+		TR4_OBJ_HORIZON = 459,
480
+		TR4_OBJ_SKY_GRAPHICS = 460,				   // Sprite (in SWD file)
481
+		TR4_OBJ_BINOCULAR_GRAPHICS = 461,
482
+		TR4_OBJ_TARGET_GRAPHICS = 462,
483
+		TR4_OBJ_DEFAULT_SPRITES = 463,				// Sprite (in SWD file)
484
+		TR4_OBJ_MISC_SPRITES = 464
485
+
486
+} tr4_objects_t;

+ 1253
- 0
src/UTPackage.cpp
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 222
- 0
src/UTPackage.h 파일 보기

@@ -0,0 +1,222 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : OpenRaider, PSKModel viewer, libhel_modelloader
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : UTPackage
9
+ * License : No use w/o permission (C) 2003 Mongoose
10
+ * Comments: This class handles UT packages
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- Test Defines -----------------------------------------------
17
+ *           
18
+ * UNIT_TEST_UTPACKAGE - Builds UTPackage class as a console unit test 
19
+ *
20
+ *-- History ------------------------------------------------ 
21
+ *
22
+ * 2003.07.11:
23
+ * Mongoose - Created, form old PSKModel prototype
24
+ ================================================================*/
25
+
26
+
27
+#ifndef GUARD__OPENRAIDER_MONGOOSE_UTPACKAGE_H_
28
+#define GUARD__OPENRAIDER_MONGOOSE_UTPACKAGE_H_
29
+
30
+typedef struct {
31
+
32
+	unsigned int exportCount;
33
+	unsigned int nameCount;
34
+
35
+} utx_generation_t;
36
+
37
+typedef struct {
38
+
39
+	char *objName;;
40
+	unsigned int objFlags;
41
+
42
+} utx_name_table_t;
43
+
44
+typedef struct {
45
+
46
+	int objClass;
47
+	int objSuper;
48
+	unsigned int package;
49
+	int objName;
50
+	unsigned int objFlags;
51
+	int serialSize;
52
+	int serialOffset;
53
+
54
+} utx_export_table_t;
55
+
56
+typedef struct {
57
+
58
+	int objClass;
59
+	int objSuper;
60
+	unsigned int package;
61
+	int objName;
62
+
63
+} utx_import_table_t;
64
+
65
+typedef struct {
66
+
67
+	unsigned int signature;
68
+	unsigned short version;
69
+	unsigned short version2; // aka mod
70
+	unsigned int flags;
71
+	unsigned int nameCount;
72
+	unsigned int nameOffset;
73
+	unsigned int exportCount;
74
+	unsigned int exportOffset;
75
+	unsigned int importCount;
76
+	unsigned int importOffset;
77
+
78
+	unsigned int heritageCount; // if version < 68
79
+	unsigned int heritageOffset; // if version < 68
80
+
81
+	unsigned int guid[4]; // else if version > 67
82
+	unsigned int generationCount; // else if version > 67
83
+	utx_generation_t *generations; // else if version > 67
84
+
85
+	utx_name_table_t *nameTable;
86
+	utx_export_table_t *exportTable;
87
+	utx_import_table_t *importTable;
88
+	unsigned int *heritageTable; // 16byte IDs stored as 4 u32s
89
+
90
+} utx_header_t;
91
+
92
+
93
+/* Index parser algorithm and defines from 'Unreal file reader' source */
94
+#define INDEX_SIGN_BIT  0x80        // Sign bit on first byte
95
+#define INDEX_CONT1_BIT 0x40        // Continuation bit on first byte
96
+#define INDEX_BYT1_MASK 0x3f        // Data mast on first byte
97
+#define INDEX_CONT_BIT  0x80        // Continuation bit on other bytes
98
+#define INDEX_BYTE_MASK 0x7f        // Data mask on other bytes
99
+
100
+#define UNP_ByteProperty        1
101
+#define UNP_IntProperty         2
102
+#define UNP_BoolProperty        3
103
+#define UNP_FloatProperty       4
104
+#define UNP_ObjectProperty      5
105
+#define UNP_NameProperty        6
106
+#define UNP_StringProperty      7
107
+#define UNP_ClassProperty       8
108
+#define UNP_ArrayProperty       9
109
+#define UNP_StructProperty      10
110
+#define UNP_VectorProperty      11
111
+#define UNP_RotatorProperty     12
112
+#define UNP_StrProperty         13
113
+#define UNP_MapProperty         14
114
+#define UNP_FixedArrayProperty  15
115
+
116
+#define PROPERTY_TYPE_MASK  0x0f
117
+#define PROPERTY_SIZE_MASK  0x70
118
+#define PROPERTY_ARRAY_MASK 0x80
119
+
120
+//////////////////////////////////////////////////////////////////////
121
+// UTPackageProperty Class
122
+//////////////////////////////////////////////////////////////////////
123
+
124
+class UTPackageProperty
125
+{
126
+public:
127
+
128
+	UTPackageProperty();
129
+
130
+	~UTPackageProperty();
131
+
132
+	void clear();
133
+
134
+	int load(utx_header_t *header, FILE *f);
135
+	
136
+
137
+	int index;
138
+
139
+	unsigned int nameIndex;
140
+	
141
+	unsigned int size;
142
+
143
+	unsigned int type;
144
+
145
+	unsigned int flags;
146
+
147
+	unsigned char *data;
148
+};
149
+
150
+
151
+//////////////////////////////////////////////////////////////////////
152
+// UTPackage Class
153
+//////////////////////////////////////////////////////////////////////
154
+
155
+class UTPackage
156
+{
157
+ public:
158
+
159
+	enum
160
+	{
161
+		UT_NULL,
162
+		UT_IMPORT,
163
+		UT_EXPORT
164
+		
165
+	} UT_INDEX;
166
+
167
+
168
+	////////////////////////////////////////////////////////////
169
+	// Constructors
170
+	////////////////////////////////////////////////////////////
171
+
172
+	UTPackage();
173
+	/*------------------------------------------------------
174
+	 * Pre  : 
175
+	 * Post : Constructs an object of UTPackage
176
+	 *
177
+	 *-- History ------------------------------------------
178
+	 *
179
+	 * 2003.07.11: 
180
+	 * Mongoose - Created
181
+	 ------------------------------------------------------*/
182
+
183
+	~UTPackage();
184
+	/*------------------------------------------------------
185
+	 * Pre  : UTPackage object is allocated
186
+	 * Post : Deconstructs an object of UTPackage
187
+	 *
188
+	 *-- History ------------------------------------------
189
+	 *
190
+	 * 2003.07.11: 
191
+	 * Mongoose - Created
192
+	 ------------------------------------------------------*/
193
+
194
+
195
+	////////////////////////////////////////////////////////////
196
+	// Public Accessors
197
+	////////////////////////////////////////////////////////////
198
+
199
+
200
+
201
+	////////////////////////////////////////////////////////////
202
+	// Public Mutators
203
+	////////////////////////////////////////////////////////////
204
+
205
+
206
+ private:
207
+
208
+	////////////////////////////////////////////////////////////
209
+	// Private Accessors
210
+	////////////////////////////////////////////////////////////
211
+
212
+
213
+	////////////////////////////////////////////////////////////
214
+	// Private Mutators
215
+	////////////////////////////////////////////////////////////
216
+
217
+
218
+	/* */
219
+};
220
+
221
+int load_utx(char *filename, bool hexDump, bool diskDump);
222
+#endif

+ 795
- 0
src/World.cpp 파일 보기

@@ -0,0 +1,795 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : OpenRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : World
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: The game world ( model )
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2002.12.16:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#ifdef DEBUG_MEMEORY
23
+#   include "memeory_test.h"
24
+#endif
25
+
26
+#include <math.h>
27
+#include "World.h"
28
+
29
+
30
+////////////////////////////////////////////////////////////
31
+// Constructors
32
+////////////////////////////////////////////////////////////
33
+
34
+World::World()
35
+{
36
+	mClearLock = false;
37
+	mFlags = 0;
38
+	mEntities.setError(0x0);
39
+	mRooms.setError(0x0);
40
+	mMeshes.setError(0x0);
41
+	mSprites.setError(0x0);
42
+	mModels.setError(0x0);
43
+}
44
+
45
+
46
+World::~World()
47
+{
48
+	destroy();
49
+}
50
+
51
+
52
+////////////////////////////////////////////////////////////
53
+// Public Accessors
54
+////////////////////////////////////////////////////////////
55
+
56
+int World::getRoomByLocation(int index, float x, float y, float z)
57
+{
58
+	room_mesh_t *room = mRooms[index];
59
+
60
+	if (room)
61
+	{
62
+		if (x > room->bbox_min[0] && x < room->bbox_max[0] &&
63
+			 z > room->bbox_min[2] && z < room->bbox_max[2])
64
+		{
65
+			if (y > room->bbox_min[1] && y < room->bbox_max[1])
66
+				return index;
67
+		}
68
+	}
69
+	
70
+	return getRoomByLocation(x, y, z);
71
+}
72
+
73
+
74
+int World::getRoomByLocation(float x, float y, float z)
75
+{
76
+	room_mesh_t *room;
77
+	int hop = -1;
78
+
79
+
80
+	for (mRooms.start(); mRooms.forward(); mRooms.next())
81
+	{
82
+		room = mRooms.current();
83
+	
84
+		if (!room)
85
+			continue;
86
+
87
+		if (x > room->bbox_min[0] && x < room->bbox_max[0] &&
88
+			 z > room->bbox_min[2] && z < room->bbox_max[2])
89
+		{			
90
+			// This room contains current position
91
+			if (y > room->bbox_min[1] && y < room->bbox_max[1])
92
+				return mRooms.getCurrentIndex();
93
+			
94
+			// This room is above or below current position
95
+			hop = mRooms.getCurrentIndex();
96
+		}
97
+  }
98
+
99
+	// Room is -1?  Must be in void, try to hop to room with same X,Z
100
+	if (mFlags & fEnableHopping)
101
+		return hop;
102
+
103
+	return -1;
104
+}
105
+
106
+
107
+int World::getAdjoiningRoom(int index, 
108
+									 float x, float y, float z,
109
+									 float x2, float y2, float z2)
110
+{
111
+	room_mesh_t *room = mRooms[index];
112
+	portal_t * portal;
113
+	vec3_t intersect, p1, p2;
114
+
115
+
116
+	p1[0] = x;	p1[1] = y;	p1[2] = z;
117
+	p2[0] = x2;	p2[1] = y2;	p2[2] = z2;
118
+
119
+	if (room)
120
+	{
121
+		for (room->portals.start(); room->portals.forward(); 
122
+			  room->portals.next())
123
+		{
124
+			portal = room->portals.current();
125
+			
126
+			if (!portal)
127
+				continue;
128
+			
129
+			if (helIntersectionLineAndPolygon(intersect, p1, p2, 4,
130
+														 portal->vertices))
131
+			{
132
+				return portal->adjoining_room;
133
+			}
134
+		}
135
+	}
136
+
137
+	return -1;
138
+}
139
+
140
+
141
+int World::getSector(int room, float x, float z, float *floor, float *ceiling)
142
+{
143
+	room_mesh_t *r;
144
+	sector_t * s;
145
+	int sector;
146
+
147
+
148
+	r = mRooms[room];
149
+	
150
+	if (!r)
151
+		return -1;
152
+
153
+	sector = (((((int)x - (int)r->pos[0]) / 1024) * r->numZSectors) + 
154
+				 (((int)z - (int)r->pos[2]) / 1024));
155
+
156
+	if (sector > -1)
157
+	{
158
+		s = r->sectors[sector];
159
+
160
+		if (!s)
161
+			return -1;
162
+
163
+		*floor = s->floor;
164
+		*ceiling = s->ceiling;
165
+	}
166
+
167
+	return sector;
168
+}
169
+
170
+
171
+int World::getSector(int room, float x, float z)
172
+{	
173
+	int sector;
174
+	room_mesh_t *r;
175
+
176
+
177
+	r = mRooms[room];
178
+
179
+	if (!r)
180
+	{
181
+		return -1;
182
+	}
183
+
184
+	sector = (((((int)x - (int)r->pos[0]) / 1024) * r->numZSectors) + 
185
+				 (((int)z - (int)r->pos[2]) / 1024));
186
+
187
+	if (sector < 0)
188
+	{
189
+		return -1;
190
+	}
191
+
192
+	return sector;
193
+}
194
+
195
+
196
+unsigned int World::getRoomInfo(int room)
197
+{
198
+	room_mesh_t *r;
199
+
200
+
201
+	r = mRooms[room];
202
+
203
+	if (!r)
204
+	{
205
+		return 0;
206
+	}
207
+
208
+	return r->flags;
209
+}
210
+
211
+
212
+bool World::isWall(int room, int sector)
213
+{
214
+	room_mesh_t *r;
215
+	sector_t *sect;
216
+
217
+
218
+	r = mRooms[room];
219
+
220
+	if (!r)
221
+	{
222
+		return true;
223
+	}
224
+
225
+	sect = r->sectors[sector];
226
+
227
+	if (!sect)
228
+	{
229
+		return true;
230
+	}
231
+
232
+	return (sector > 0 && sect->wall);
233
+}
234
+
235
+
236
+bool World::getHeightAtPosition(int index, float x, float *y, float z)
237
+{
238
+	room_mesh_t *room = mRooms[index];
239
+
240
+#ifdef OBSOLETE_USING_BOXES
241
+	unsigned int i;
242
+	float zmax, xmax, zmin, xmin;
243
+
244
+
245
+	if (!room)
246
+	{
247
+		return false;
248
+	}
249
+
250
+	// Mongoose 2002.08.14, It's 0302 - give me a fucking break -- 
251
+	//   this works albeit poorly  =)
252
+	for (i = 0; (int)i < room->num_boxes; ++i)
253
+	{
254
+		xmax = room->boxes[i].c.pos[0];
255
+		xmin = room->boxes[i].a.pos[0];
256
+		zmax = room->boxes[i].c.pos[2];
257
+		zmin = room->boxes[i].a.pos[2];
258
+
259
+		if (x < xmax && x > xmin && z < zmax && z > zmin)
260
+		{
261
+			//printf("%f %f %f %f\n", xmax, xmin, zmax, zmin);
262
+
263
+			*y =  room->boxes[i].a.pos[1]; // hhmm...room->pos[1] +
264
+			return true;
265
+		}
266
+	}
267
+
268
+	return false;
269
+#else
270
+	int sector;
271
+	sector_t *sect;
272
+
273
+
274
+	if (!room)
275
+	{
276
+		return false;
277
+	}
278
+
279
+	// Mongoose 2002.08.14, Remember sector_z is width of sector array
280
+	sector = getSector(index, x, z);
281
+
282
+	sect = room->sectors[sector];
283
+
284
+	if (!sect)
285
+	{
286
+		return true;
287
+	}
288
+
289
+	*y = sect->floor;
290
+
291
+	return true;
292
+#endif
293
+}
294
+
295
+
296
+// Temp methods for rendering use until more refactoring is done
297
+#ifdef BAD_BLOOD
298
+model_mesh_t *World::getMesh(int index)
299
+{
300
+	return mMeshes[index];
301
+}
302
+
303
+skeletal_model_t *World::getModel(int index)
304
+{
305
+	return mModels[index];
306
+}
307
+
308
+room_mesh_t *World::getRoom(int index)
309
+{
310
+	return mRooms[index];
311
+}
312
+
313
+Vector<entity_t *> *World::getEntities()
314
+{
315
+	return &mEntities;
316
+}
317
+
318
+Vector<sprite_seq_t *> *World::getSprites()
319
+{
320
+	return &mSprites;
321
+}
322
+
323
+Vector<room_mesh_t *> *World::getRooms()
324
+{
325
+	return &mRooms;
326
+}
327
+#endif
328
+
329
+
330
+////////////////////////////////////////////////////////////
331
+// Public Mutators
332
+////////////////////////////////////////////////////////////
333
+
334
+void World::setFlag(WorldFlag flag)
335
+{
336
+	mFlags |= flag;
337
+}
338
+
339
+
340
+
341
+void World::clearFlag(WorldFlag flag)
342
+{
343
+	mFlags |= flag;
344
+	mFlags ^= flag;
345
+}
346
+
347
+
348
+void World::destroy()
349
+{
350
+	// Add some locking to check use state first
351
+	if (!mClearLock)
352
+	{
353
+		clear();
354
+	}
355
+}
356
+
357
+
358
+void World::addRoom(room_mesh_t *room)
359
+{
360
+	mClearLock = false;
361
+	mRooms.pushBack(room);
362
+}
363
+
364
+
365
+void World::addMesh(model_mesh_t *mesh)
366
+{
367
+	if (mesh)
368
+	{
369
+		mClearLock = false;
370
+		mMeshes.pushBack(mesh);
371
+	}
372
+}
373
+
374
+
375
+void World::addEntity(entity_t *e)
376
+{
377
+	if (e)
378
+	{
379
+		mClearLock = false;
380
+		e->master = 0x0;
381
+		e->moveType = worldMoveType_walk; // Walk
382
+		e->room = getRoomByLocation(e->pos[0], e->pos[1], e->pos[2]);
383
+		mEntities.pushBack(e);
384
+	}
385
+}
386
+
387
+
388
+int World::addModel(skeletal_model_t *model)
389
+{
390
+	if (model)
391
+	{
392
+		mClearLock = false;
393
+		mModels.pushBack(model);
394
+		return mModels.end();
395
+	}
396
+
397
+	return -1;
398
+}
399
+
400
+
401
+void World::addSprite(sprite_seq_t *sprite)
402
+{
403
+	if (sprite)
404
+	{
405
+		mClearLock = false;
406
+		mSprites.pushBack(sprite);
407
+	}
408
+}
409
+
410
+
411
+void World::moveEntity(entity_t *e, char movement)
412
+{
413
+	const float moved = 180.0f;
414
+	const float testd = 220.0f;
415
+	const float camHeight = 8.0f;
416
+	float x, y, z, pitch, h, floor, ceiling;
417
+	int room, sector;
418
+	bool wall;
419
+	unsigned int roomFlags;
420
+
421
+
422
+	if (!e)
423
+	{
424
+		return;
425
+	}
426
+
427
+	switch (e->moveType)
428
+	{
429
+	case worldMoveType_walkNoSwim:
430
+	case worldMoveType_walk:
431
+		pitch = 0.0f;  // in the future pitch could control jump up blocks here
432
+		break;
433
+	default:
434
+		pitch = e->angles[2];
435
+	}
436
+
437
+	switch (movement)
438
+	{
439
+	case 'f':
440
+		x = e->pos[0] + (testd * sin(e->angles[1]));
441
+		y = e->pos[1] + (testd * sin(pitch));
442
+		z = e->pos[2] + (testd * cos(e->angles[1]));
443
+		break;
444
+	case 'b':
445
+		x = e->pos[0] - (testd * sin(e->angles[1]));
446
+		y = e->pos[1] - (testd * sin(pitch));
447
+		z = e->pos[2] - (testd * cos(e->angles[1]));
448
+		break;
449
+	case 'l':
450
+		x = e->pos[0] - (testd * sin(e->angles[1] + 90.0));
451
+		y = e->pos[1];
452
+		z = e->pos[2] - (testd * cos(e->angles[1] + 90.0));
453
+		break;
454
+	case 'r':
455
+		x = e->pos[0] + (testd * sin(e->angles[1] + 90.0));
456
+		y = e->pos[1];
457
+		z = e->pos[2] + (testd * cos(e->angles[1] + 90.0));
458
+		break;
459
+	default:
460
+		return;
461
+	}
462
+
463
+	//room = getRoomByLocation(x, y, z);
464
+	room = getRoomByLocation(e->room, x, y, z);
465
+
466
+	if (room == -1) // Will we hit a portal?
467
+	{
468
+#define ADJ_ROOM_CHECK
469
+#ifdef ADJ_ROOM_CHECK
470
+		room = getAdjoiningRoom(e->room,  
471
+										e->pos[0],  e->pos[1], e->pos[2],
472
+										x, y, z);
473
+#else
474
+		if (!mFlags & fEnableHopping)
475
+		{
476
+			mFlags |= fEnableHopping;
477
+			room = getRoomByLocation(e->room, x, y, z);
478
+			printf("Hopped\n");
479
+			mFlags ^= fEnableHopping;
480
+		}
481
+
482
+		//room = getRoomByLocation(x, y, z);
483
+#endif
484
+
485
+		if (room > -1)
486
+		{
487
+			printf("Crossing from room %i to %i\n", e->room, room);
488
+		}
489
+	}
490
+
491
+	roomFlags = getRoomInfo(room);
492
+	sector = getSector(room, x, z, &floor, &ceiling);
493
+	wall = isWall(room, sector);
494
+	
495
+	// If you're underwater you may want to swim  =)
496
+	// ...if you're worldMoveType_walkNoSwim, you better hope it's shallow
497
+	if (roomFlags & roomFlag_underWater && e->moveType == worldMoveType_walk)
498
+	{
499
+		e->moveType = worldMoveType_swim;
500
+	}
501
+
502
+	// Don't swim on land
503
+	if (!(roomFlags & roomFlag_underWater) && e->moveType == worldMoveType_swim)
504
+	{
505
+		e->moveType = worldMoveType_walk;
506
+	}	
507
+
508
+	// Mongoose 2002.09.02, Add check for room -> room transition 
509
+	//   ( Only allow by movement between rooms by using portals )
510
+	if ((e->moveType == worldMoveType_noClipping ||
511
+		  e->moveType == worldMoveType_fly ||
512
+		  e->moveType == worldMoveType_swim) ||
513
+		 room > -1 && !wall)
514
+	{
515
+		e->room = room;
516
+
517
+		switch (movement)
518
+		{
519
+		case 'f':
520
+			x = e->pos[0] + (moved * sin(e->angles[1]));
521
+			y = e->pos[1] + (moved * sin(pitch));
522
+			z = e->pos[2] + (moved * cos(e->angles[1]));
523
+			break;
524
+		case 'b':
525
+			x = e->pos[0] - (moved * sin(e->angles[1]));
526
+			y = e->pos[1] - (moved * sin(pitch));
527
+			z = e->pos[2] - (moved * cos(e->angles[1]));
528
+			break;
529
+		case 'l':
530
+			x = e->pos[0] - (moved * sin(e->angles[1] + 90.0));
531
+			z = e->pos[2] - (moved * cos(e->angles[1] + 90.0));
532
+			break;
533
+		case 'r':
534
+			x = e->pos[0] + (moved * sin(e->angles[1] + 90.0));
535
+			z = e->pos[2] + (moved * cos(e->angles[1] + 90.0));
536
+			break;
537
+		}
538
+
539
+		// FIXME: Test for vector (move vector) / plane (portal) collision here
540
+		//        to see if we need to switch rooms... man...
541
+
542
+		h = y;
543
+		getHeightAtPosition(room, x, &h, z);
544
+
545
+		switch (e->moveType)
546
+		{
547
+		case worldMoveType_fly:
548
+		case worldMoveType_swim:
549
+#ifdef DIVE_GAP
550
+			// Clips to top of water, waiting for DIVE event
551
+			if (h < floor)
552
+				e->pos[1] = floor;
553
+			else if (h > ceiling)
554
+				e->pos[1] = ceiling;
555
+			else
556
+				e->pos[1] = y;
557
+#endif
558
+
559
+			// Don't fall out of world, avoid a movement that does
560
+			if (h > y - camHeight)
561
+			{
562
+				e->pos[0] = x;
563
+				e->pos[1] = y;
564
+				e->pos[2] = z;
565
+			}
566
+			break;
567
+		case worldMoveType_walk:
568
+		case worldMoveType_walkNoSwim:
569
+			y = e->pos[1];  // Override vector movement walking ( er, not pretty )
570
+
571
+			// Now fake gravity
572
+			// Mongoose 2002.08.14, Remember TR is upside down ( you fall 'up' )
573
+
574
+			//ddist = h - e->pos[1];
575
+
576
+			// This is to force false gravity, by making camera stay on ground
577
+			e->pos[1] = h; //roomFloor->bbox_min[1];
578
+
579
+			// Check for camera below terrian and correct 
580
+			if (e->pos[1] < h - camHeight)
581
+			{
582
+				e->pos[1] = h - camHeight;
583
+			}
584
+
585
+			e->pos[0] = x;
586
+			e->pos[2] = z;
587
+			break;
588
+		case worldMoveType_noClipping:
589
+			e->pos[0] = x;
590
+			e->pos[1] = y;
591
+			e->pos[2] = z;
592
+		}
593
+
594
+#ifdef OBSOLETE
595
+		m_text->SetString(1,"Room %2i  Sector %2i %sPos %.0f %.0f %.0f Yaw %.0f",
596
+								room, sector,
597
+								wall ? " Wall " : " ",
598
+								e->pos[0], e->pos[1], e->pos[2], e->angles[1]);
599
+#endif
600
+	}
601
+	else
602
+	{
603
+		e->moving = false;
604
+		return;
605
+	}
606
+
607
+	e->room = room;
608
+	e->moving = true;
609
+}
610
+
611
+
612
+////////////////////////////////////////////////////////////
613
+// Private Accessors
614
+////////////////////////////////////////////////////////////
615
+
616
+
617
+////////////////////////////////////////////////////////////
618
+// Private Mutators
619
+////////////////////////////////////////////////////////////
620
+
621
+void World::clear()
622
+{
623
+	room_mesh_t *room;
624
+	model_mesh_t *mesh;
625
+	sprite_seq_t *sprite;
626
+	skeletal_model_t *model;
627
+	bone_frame_t *boneframe;
628
+	bone_tag_t *tag;
629
+	animation_frame_t *animation;
630
+	List<skeletal_model_t *> cache;
631
+
632
+
633
+	mClearLock = true;
634
+
635
+	mEntities.erase();
636
+
637
+	for (mRooms.start(); mRooms.forward(); mRooms.next())
638
+	{
639
+		room = mRooms.current();
640
+	
641
+		if (room)
642
+		{
643
+			room->portals.erase();
644
+			room->models.erase();
645
+			room->sprites.erase();
646
+			room->sectors.erase();
647
+			room->boxes.erase();
648
+		}
649
+	}
650
+
651
+	mRooms.erase();
652
+
653
+	for (mMeshes.start(); mMeshes.forward(); mMeshes.next())
654
+	{
655
+		mesh = mMeshes.current();
656
+
657
+		if (!mesh)
658
+			continue;
659
+
660
+		for (mesh->texturedTriangles.start(); 
661
+			  mesh->texturedTriangles.forward();
662
+			  mesh->texturedTriangles.next())
663
+		{
664
+			if (mesh->texturedTriangles.current())
665
+				delete mesh->texturedTriangles.current();
666
+		}
667
+
668
+		for (mesh->coloredTriangles.start(); mesh->coloredTriangles.forward();
669
+			  mesh->coloredTriangles.next())
670
+		{
671
+			if (mesh->coloredTriangles.current())
672
+				delete mesh->coloredTriangles.current();
673
+		}
674
+
675
+		for (mesh->texturedRectangles.start(); 
676
+			  mesh->texturedRectangles.forward();
677
+			  mesh->texturedRectangles.next())
678
+		{
679
+			if (mesh->texturedRectangles.current())
680
+				delete mesh->texturedRectangles.current();
681
+		}
682
+
683
+		for (mesh->coloredRectangles.start(); mesh->coloredRectangles.forward();
684
+			  mesh->coloredRectangles.next())
685
+		{
686
+			if (mesh->coloredRectangles.current())
687
+				delete mesh->coloredRectangles.current();
688
+		}
689
+
690
+		if (mesh->vertices)
691
+			delete [] mesh->vertices;
692
+
693
+		if (mesh->colors)
694
+			delete [] mesh->colors;
695
+
696
+		if (mesh->normals)
697
+			delete [] mesh->normals;
698
+
699
+		delete mesh;
700
+	}
701
+
702
+	mMeshes.clear();
703
+
704
+	for (mSprites.start(); mSprites.forward(); mSprites.next())
705
+	{
706
+		sprite = mSprites.current();
707
+	
708
+		if (!sprite)
709
+			continue;
710
+
711
+		if (sprite->sprite)
712
+			delete [] sprite->sprite;
713
+
714
+		delete sprite;
715
+	}
716
+
717
+	mSprites.clear();
718
+
719
+	for (mModels.start(); mModels.forward(); mModels.next())
720
+	{
721
+		model = mModels.current();
722
+	
723
+		if (!model)
724
+			continue;
725
+
726
+		// No smart pointers, so skip if deleted once  =)
727
+		if (!cache.SearchKey(model) == UINT_MAX)
728
+		{
729
+			cache.Add(model);
730
+		}
731
+		else
732
+		{
733
+			continue;
734
+		}
735
+
736
+		for (model->animation.start(); model->animation.forward(); 
737
+			  model->animation.next())
738
+		{
739
+			animation  = model->animation.current();
740
+
741
+			if (!animation)
742
+				continue;
743
+
744
+			for (animation->frame.start(); animation->frame.forward(); 
745
+				  animation->frame.next())
746
+			{
747
+				boneframe = animation->frame.current();
748
+
749
+				if (!boneframe)
750
+					continue;
751
+
752
+				for (boneframe->tag.start(); boneframe->tag.forward(); 
753
+					  boneframe->tag.next())
754
+				{
755
+					tag = boneframe->tag.current();
756
+					
757
+					if (!tag)
758
+						continue;
759
+
760
+					delete tag;
761
+				}		
762
+
763
+				delete boneframe;
764
+			}
765
+			
766
+			delete animation;
767
+		}
768
+
769
+		delete model;
770
+	}
771
+
772
+	mModels.clear();
773
+}
774
+
775
+
776
+////////////////////////////////////////////////////////////
777
+// Unit Test code
778
+////////////////////////////////////////////////////////////
779
+
780
+#ifdef UNIT_TEST_WORLD
781
+int runWorldUnitTest(int argc, char *argv[])
782
+{
783
+	return 0;
784
+}
785
+
786
+
787
+int main(int argc, char *argv[])
788
+{
789
+	printf("[World class test]\n");
790
+
791
+	runWorldUnitTest(argc, argv);
792
+
793
+	return 0;
794
+}
795
+#endif

+ 583
- 0
src/World.h 파일 보기

@@ -0,0 +1,583 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : OpenRaider
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : World
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: The game world ( model )
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- Test Defines -----------------------------------------------
17
+ *           
18
+ * UNIT_TEST_WORLD - Builds World class as a console unit test 
19
+ *
20
+ *-- History ------------------------------------------------ 
21
+ *
22
+ * 2002.12.16:
23
+ * Mongoose - Created
24
+ ================================================================*/
25
+
26
+
27
+#ifndef GUARD__OPENRAIDER_MONGOOSE_WORLD_H_
28
+#define GUARD__OPENRAIDER_MONGOOSE_WORLD_H_
29
+
30
+#define BAD_BLOOD  // For temp rendering use
31
+
32
+#ifdef BAD_BLOOD
33
+#   include "SkeletalModel.h"
34
+#endif
35
+
36
+#include <mstl/List.h>
37
+#include <mstl/Vector.h>
38
+#include <hel/math.h>
39
+#include <hel/Mass.h>
40
+
41
+
42
+// Mirrors TombRaider class' room flags really
43
+typedef enum
44
+{
45
+	roomFlag_underWater    = 0x0001
46
+
47
+} room_flags_t;
48
+
49
+typedef enum
50
+{
51
+	worldMoveType_walkNoSwim   = -1,
52
+	worldMoveType_walk         = 0,
53
+	worldMoveType_noClipping   = 1,
54
+	worldMoveType_fly          = 2,
55
+	worldMoveType_swim         = 3
56
+
57
+} worldMoveType;
58
+
59
+
60
+typedef struct vertex_s
61
+{
62
+	vec3_t pos;
63
+
64
+} vertex_t;
65
+
66
+
67
+typedef struct uv_s
68
+{
69
+	vec2_t uv;
70
+
71
+} uv_t;
72
+
73
+typedef struct texel_s
74
+{
75
+	vec2_t st;
76
+
77
+} texel_t;
78
+
79
+
80
+typedef struct color_s
81
+{
82
+	vec4_t rgba;
83
+
84
+} color_t;
85
+
86
+
87
+typedef struct sprite_s
88
+{
89
+	int num_verts; // 4 == Quad, 3 == Triangle, renderered as triangles 
90
+	vertex_t vertex[4];
91
+	texel_t texel[4];
92
+	float pos[3];
93
+	float radius; // yeah, I know
94
+	int texture;	
95
+
96
+} sprite_t;
97
+
98
+
99
+typedef struct sprite_seq_s
100
+{
101
+	int num_sprites;
102
+	sprite_t *sprite;
103
+
104
+} sprite_seq_t;
105
+
106
+
107
+// FIXME: For now shaders are textures on tex objects
108
+//        and materials on color objects.  If -1
109
+//        then it doesn't have that information yet.
110
+
111
+typedef struct texture_tri_s
112
+{
113
+	int index[3];
114
+	vec_t st[6];
115
+	int texture;
116
+	unsigned short transparency;
117
+
118
+} texture_tri_t;
119
+
120
+
121
+typedef struct model_mesh_s
122
+{
123
+	Vector<texture_tri_t *> texturedTriangles;
124
+	Vector<texture_tri_t *> coloredTriangles;
125
+	Vector<texture_tri_t *> texturedRectangles;
126
+	Vector<texture_tri_t *> coloredRectangles;
127
+
128
+	vec3_t center;
129
+	float radius;
130
+
131
+	unsigned int vertexCount;
132
+	vec_t *vertices;
133
+
134
+	unsigned int colorCount;
135
+	vec_t *colors;
136
+
137
+	unsigned int normalCount;
138
+	vec_t *normals;
139
+
140
+} model_mesh_t;
141
+
142
+
143
+////////////////////////////////////////////////////////////////
144
+
145
+
146
+typedef struct entity_s
147
+{
148
+	int id;                    // Unique identifier
149
+	float pos[3];              // World position
150
+	float angles[3];           // Eular angles (pitch, yaw, roll)
151
+	int type;                  // {(0x00, item), (0x01, ai), (0x02, player)}
152
+	int room;                  // Current room entity is in
153
+	worldMoveType moveType;    // Type of motion/clipping
154
+	bool moving;               // In motion?
155
+	struct entity_s *master;   // Part of entity chain?
156
+
157
+	int state;      // State of the Player, AI, or object
158
+	int objectId;              // What kind of entity?
159
+
160
+	int modelId;               // Animation model
161
+	void *tmpHook;
162
+	bool animate;
163
+
164
+	Mass mass;
165
+	/*
166
+	  float time, lastTime;
167
+	  int state, lastState;
168
+	  int event, lastEvent;
169
+	  int goal;
170
+	 */
171
+
172
+} entity_t;
173
+
174
+
175
+typedef struct static_model_s
176
+{
177
+	int index;     // model_mesh index
178
+	float yaw;     // angle of rotation on Y
179
+	float pos[3];  // position
180
+	
181
+	//vec3_t bboxMax;
182
+	//vec3_t bboxMin;
183
+
184
+} static_model_t;
185
+
186
+
187
+
188
+typedef struct portal_s
189
+{
190
+	float vertices[4][3];
191
+	float normal[3];
192
+	int adjoining_room;
193
+
194
+} portal_t;
195
+
196
+
197
+typedef struct box_s
198
+{
199
+	vertex_t a;
200
+	vertex_t b;
201
+	vertex_t c;
202
+	vertex_t d;
203
+
204
+} box_t;
205
+
206
+typedef struct sector_s
207
+{
208
+	vec_t floor;
209
+	vec_t ceiling;
210
+
211
+	bool wall;
212
+
213
+} sector_t;
214
+
215
+// FIXME: No room mesh list or sprites and etc
216
+typedef struct room_mesh_s
217
+{
218
+	Vector<int> adjacentRooms;
219
+	Vector<portal_t *> portals;
220
+	Vector<static_model_t *> models;
221
+	Vector<sprite_t *> sprites;
222
+	Vector<box_t *> boxes;
223
+	Vector<sector_t *> sectors;
224
+
225
+	int id;
226
+	unsigned int flags;
227
+	unsigned int numXSectors;
228
+	unsigned int numZSectors;
229
+	float pos[3];
230
+	vec3_t bbox_min;
231
+	vec3_t bbox_max;
232
+
233
+} room_mesh_t;
234
+
235
+
236
+// Workout generic entity and a client class from these entities
237
+typedef struct world_entity_s 
238
+{
239
+	vec3_t pos;
240
+	vec3_t lastPos;
241
+	vec3_t angle;
242
+	vec_t ttl;
243
+
244
+	int type;
245
+	int state;
246
+
247
+	//struct world_entity_s *master;
248
+
249
+} world_entity_t;
250
+
251
+
252
+typedef struct actor_entity_s 
253
+{
254
+	vec3_t pos;
255
+	vec3_t lastPos;
256
+	vec3_t angle;
257
+	char clipping;
258
+	float time, eventTime, eventTimer;
259
+	int state, nextState;
260
+	float health;
261
+
262
+	// Client
263
+	unsigned int uid;
264
+	char name[32];
265
+	int actor, enemy;
266
+
267
+	// Render
268
+	unsigned int model;
269
+	unsigned int skin;
270
+	unsigned int animFrame;
271
+
272
+} actor_entity_t;
273
+
274
+enum OpenRaiderEvent
275
+{
276
+	eNone            = 0,
277
+	eWeaponDischarge,
278
+	eDying,
279
+	eDead,
280
+	eWounded,
281
+	eRunForward,
282
+	eRunBackward,
283
+	eJump,
284
+	eCrouchWalk,
285
+	eIdle,
286
+	eTaunt,
287
+	eTurn,
288
+	eRespawn,
289
+	eLand
290
+};
291
+
292
+
293
+class World
294
+{
295
+ public:
296
+
297
+	enum WorldFlag
298
+	{
299
+		fEnableHopping = 1
300
+	};
301
+
302
+	////////////////////////////////////////////////////////////
303
+	// Constructors
304
+	////////////////////////////////////////////////////////////
305
+
306
+	World();
307
+	/*------------------------------------------------------
308
+	 * Pre  : 
309
+	 * Post : Constructs an object of World
310
+	 *
311
+	 *-- History ------------------------------------------
312
+	 *
313
+	 * 2002.12.16: 
314
+	 * Mongoose - Created
315
+	 ------------------------------------------------------*/
316
+
317
+	~World();
318
+	/*------------------------------------------------------
319
+	 * Pre  : World object is allocated
320
+	 * Post : Deconstructs an object of World
321
+	 *
322
+	 *-- History ------------------------------------------
323
+	 *
324
+	 * 2002.12.16: 
325
+	 * Mongoose - Created
326
+	 ------------------------------------------------------*/
327
+
328
+
329
+	////////////////////////////////////////////////////////////
330
+	// Public Accessors
331
+	////////////////////////////////////////////////////////////
332
+
333
+	int getRoomByLocation(int index, float x, float y, float z);
334
+	/*------------------------------------------------------
335
+	 * Pre  : index - Guessed room index
336
+	 * Post : Returns correct room index or -1 for unknown
337
+	 *
338
+	 *        NOTE: If it fails to be in a room it gives
339
+	 *        closest overlapping room
340
+	 *
341
+	 *-- History ------------------------------------------
342
+	 *
343
+	 * 2002.12.20:
344
+	 * Mongoose - Created, factored out of Render class 
345
+	 ------------------------------------------------------*/
346
+
347
+	int getRoomByLocation(float x, float y, float z);
348
+	/*------------------------------------------------------
349
+	 * Pre  : 
350
+	 * Post : Returns correct room index or -1 for unknown
351
+	 *
352
+	 *        NOTE: If it fails to be in a room it gives 
353
+	 *        closest overlapping room
354
+	 *
355
+	 *-- History ------------------------------------------
356
+	 *
357
+	 * 2002.12.20:
358
+	 * Mongoose - Created, factored out of Render class 
359
+	 ------------------------------------------------------*/
360
+
361
+	int getAdjoiningRoom(int index, 
362
+								float x, float y, float z,
363
+								float x2, float y2, float z2);
364
+	/*------------------------------------------------------
365
+	 * Pre  : 
366
+	 * Post : Looks for portal crossings from xyz to xyz2 segment
367
+	 *        from room[index] returns index of adjoined room or -1
368
+	 *
369
+	 *-- History ------------------------------------------
370
+	 *
371
+	 * 2003.05.29:
372
+	 * Mongoose - Created
373
+	 ------------------------------------------------------*/
374
+
375
+	int getSector(int room, float x, float z);
376
+	int getSector(int room, float x, float z, float *floor, float *ceiling);
377
+	/*------------------------------------------------------
378
+	 * Pre  : room - valid room index
379
+	 * Post : Gets the sector index of the position in room
380
+	 *
381
+	 *-- History ------------------------------------------
382
+	 *
383
+	 * 2002.12.20:
384
+	 * Mongoose - Created, factored out of Render class 
385
+	 ------------------------------------------------------*/
386
+
387
+	unsigned int getRoomInfo(int room);
388
+	/*------------------------------------------------------
389
+	 * Pre  : 
390
+	 * Post : 
391
+	 *
392
+	 *-- History ------------------------------------------
393
+	 *
394
+	 * 2003.05.28:
395
+	 * Mongoose - Created
396
+	 ------------------------------------------------------*/
397
+
398
+	bool isWall(int room, int sector);
399
+	/*------------------------------------------------------
400
+	 * Pre  : room - valid room index
401
+	 *        sector - valid sector index
402
+	 * Post : Returns true if this sector is a wall
403
+	 *
404
+	 *-- History ------------------------------------------
405
+	 *
406
+	 * 2002.12.20:
407
+	 * Mongoose - Created, factored out of Render class 
408
+	 ------------------------------------------------------*/
409
+
410
+	bool getHeightAtPosition(int index, float x, float *y, float z);
411
+	/*------------------------------------------------------
412
+	 * Pre  : index - valid room index
413
+	 * Post : Returns true if position is in a room
414
+	 *        and sets y to the world height in that room
415
+	 *
416
+	 *-- History ------------------------------------------
417
+	 *
418
+	 * 2002.12.20:
419
+	 * Mongoose - Created, factored out of Render class 
420
+	 ------------------------------------------------------*/
421
+
422
+	// Temp methods for rendering use until more refactoring is done
423
+#ifdef BAD_BLOOD
424
+	model_mesh_t *getMesh(int index);
425
+	skeletal_model_t *getModel(int index);
426
+	room_mesh_t *getRoom(int index);
427
+	Vector<entity_t *> *getEntities();
428
+	Vector<sprite_seq_t *> *getSprites();
429
+	Vector<room_mesh_t *> *getRooms();
430
+#endif
431
+
432
+	////////////////////////////////////////////////////////////
433
+	// Public Mutators
434
+	////////////////////////////////////////////////////////////
435
+	
436
+	void setFlag(WorldFlag flag);
437
+	/*------------------------------------------------------
438
+	 * Pre  : 
439
+	 * Post : Sets option flag
440
+	 *
441
+	 *-- History ------------------------------------------
442
+	 *
443
+	 * 2002.12.20:
444
+	 * Mongoose - Created, factored out of Render class 
445
+	 ------------------------------------------------------*/
446
+
447
+	void clearFlag(WorldFlag flag);
448
+	/*------------------------------------------------------
449
+	 * Pre  : 
450
+	 * Post : Clears option flag
451
+	 *
452
+	 *-- History ------------------------------------------
453
+	 *
454
+	 * 2002.12.20:
455
+	 * Mongoose - Created, factored out of Render class 
456
+	 ------------------------------------------------------*/
457
+
458
+	void destroy();
459
+	/*------------------------------------------------------
460
+	 * Pre  : 
461
+	 * Post : Clears all data in world, in future will check
462
+	 *        if data is in use before clearing
463
+	 *
464
+	 *-- History ------------------------------------------
465
+	 *
466
+	 * 2002.12.20:
467
+	 * Mongoose - Created
468
+	 ------------------------------------------------------*/
469
+
470
+	void addRoom(room_mesh_t *room);
471
+	/*------------------------------------------------------
472
+	 * Pre  : 
473
+	 * Post : Adds object to world
474
+	 *
475
+	 *-- History ------------------------------------------
476
+	 *
477
+	 * 2002.12.20:
478
+	 * Mongoose - Created, factored out of Render class 
479
+	 ------------------------------------------------------*/
480
+	
481
+	void addMesh(model_mesh_t *model);
482
+	/*------------------------------------------------------
483
+	 * Pre  : 
484
+	 * Post : Adds object to world
485
+	 *
486
+	 *-- History ------------------------------------------
487
+	 *
488
+	 * 2002.12.20:
489
+	 * Mongoose - Created, factored out of Render class 
490
+	 ------------------------------------------------------*/
491
+
492
+	void addEntity(entity_t *e);
493
+	/*------------------------------------------------------
494
+	 * Pre  : 
495
+	 * Post : Adds object to world
496
+	 *
497
+	 *-- History ------------------------------------------
498
+	 *
499
+	 * 2002.12.20:
500
+	 * Mongoose - Created, factored out of Render class 
501
+	 ------------------------------------------------------*/
502
+
503
+	int addModel(skeletal_model_t *model);
504
+	/*------------------------------------------------------
505
+	 * Pre  : 
506
+	 * Post : Adds object to world, returns next model Id
507
+	 *        or -1 if failed to add model to world
508
+	 *
509
+	 *-- History ------------------------------------------
510
+	 *
511
+	 * 2002.12.20:
512
+	 * Mongoose - Created, factored out of Render class 
513
+	 ------------------------------------------------------*/
514
+
515
+	void addSprite(sprite_seq_t *sprite);
516
+	/*------------------------------------------------------
517
+	 * Pre  : 
518
+	 * Post : Adds object to world
519
+	 *
520
+	 *-- History ------------------------------------------
521
+	 *
522
+	 * 2002.12.20:
523
+	 * Mongoose - Created, factored out of Render class 
524
+	 ------------------------------------------------------*/
525
+
526
+	void moveEntity(entity_t *e, char movement);
527
+	/*------------------------------------------------------
528
+	 * Pre  : movement - 'f' orward
529
+	 *                   'b' ackward
530
+	 *                   'l' eft
531
+	 *                   'r' ight
532
+	 *
533
+	 * Post : Move entity e in a given direction, unless
534
+	 *        a collision ocurrs
535
+	 *
536
+	 *-- History ------------------------------------------
537
+	 *
538
+	 * 2002.12.20:
539
+	 * Mongoose - Moved to WOrld class
540
+	 *
541
+	 * 2002.09.02:
542
+	 * Mongoose - Created
543
+	 ------------------------------------------------------*/
544
+
545
+
546
+ private:
547
+
548
+	////////////////////////////////////////////////////////////
549
+	// Private Accessors
550
+	////////////////////////////////////////////////////////////
551
+
552
+
553
+	////////////////////////////////////////////////////////////
554
+	// Private Mutators
555
+	////////////////////////////////////////////////////////////
556
+
557
+	void clear();
558
+	/*------------------------------------------------------
559
+	 * Pre  : 
560
+	 * Post : Clears all data in world
561
+	 *
562
+	 *-- History ------------------------------------------
563
+	 *
564
+	 * 2002.12.20:
565
+	 * Mongoose - Created
566
+	 ------------------------------------------------------*/
567
+
568
+	bool mClearLock;
569
+
570
+	unsigned int mFlags;                   /* World flags */
571
+
572
+	Vector<entity_t *> mEntities;	         /* World entities */
573
+
574
+	Vector<room_mesh_t *> mRooms;	         /* Map data and meshes */
575
+
576
+	Vector<model_mesh_t *> mMeshes;	      /* Unanimated meshes */
577
+
578
+	Vector<sprite_seq_t *> mSprites;	      /* Sprites */
579
+
580
+	Vector<skeletal_model_t *> mModels; 	/* Skeletal animation models */
581
+};
582
+
583
+#endif

+ 137
- 0
src/endian.cpp 파일 보기

@@ -0,0 +1,137 @@
1
+/*==========================================================================
2
+ * 
3
+ * Project : MDDC 
4
+ * Author  : Terry 'Mongoose' Hendrix II
5
+ * Website : http://www.westga.edu/~stu7440
6
+ * Email   : stu7440@westga.edu
7
+ * Object  : 
8
+ * Comments: This is the endian utils.
9
+ *
10
+ *           See file COPYING for license details.
11
+ *
12
+ *           Based on type converting code by: 
13
+ *           Michael Vance <mkv102@psu.edu> 
14
+ * 
15
+ *-- History ---------------------------------------------------------- 
16
+ *
17
+ * 2000-03-17:
18
+ * Mongoose: Created, I combined some endian checking with fread wrapper 
19
+ ==========================================================================*/
20
+
21
+#include "endian.h"
22
+
23
+
24
+int fread_u_int_small(unsigned int *ptr, FILE *stream)
25
+{  
26
+#ifdef BIG_ENDIAN
27
+   unsigned char b1, b2, b3, b4;
28
+   unsigned int l;
29
+#endif
30
+ 
31
+   if (fread(ptr, 4, 1, stream) != 1)
32
+   {
33
+      printf("FreadSmallInt> Failed fread.\n");
34
+      return false;
35
+   }
36
+
37
+#ifdef BIG_ENDIAN
38
+   l = *ptr; 
39
+
40
+   b1 = l & 255;
41
+   b2 = ( l >> 8 ) & 255;
42
+   b3 = ( l >> 16 ) & 255;
43
+   b4 = ( l >> 24 ) & 255;
44
+  *ptr = ( (int) b1 << 24 ) + ( (int) b2 << 16 ) + ( (int) b3 << 8 ) + b4;
45
+#endif
46
+
47
+   return true;
48
+}
49
+
50
+
51
+int fread_int_small(int *ptr, FILE *stream)
52
+{  
53
+#ifdef BIG_ENDIAN
54
+   unsigned char b1, b2, b3, b4;
55
+   int l;
56
+#endif
57
+ 
58
+   if (fread(ptr, 4, 1, stream) != 1)
59
+   {
60
+      printf("FreadSmallInt> Failed fread.\n");
61
+      return false;
62
+   }
63
+
64
+#ifdef BIG_ENDIAN
65
+   l = *ptr; 
66
+
67
+   b1 = l & 255;
68
+   b2 = ( l >> 8 ) & 255;
69
+   b3 = ( l >> 16 ) & 255;
70
+   b4 = ( l >> 24 ) & 255;
71
+  *ptr = ( (int) b1 << 24 ) + ( (int) b2 << 16 ) + ( (int) b3 << 8 ) + b4;
72
+#endif
73
+
74
+   return true;
75
+}
76
+
77
+int fread_float_small(float *ptr, FILE *stream)
78
+{  
79
+#ifdef BIG_ENDIAN
80
+   union
81
+   {
82
+      unsigned char b[4];
83
+      float f; 
84
+   } in, out;
85
+	
86
+   float l;
87
+#endif
88
+ 
89
+   if (fread(ptr, 4, 1, stream) != 1)
90
+   {
91
+      printf("FreadSmallFloat> Failed fread.\n");
92
+      return false;
93
+   }
94
+
95
+#ifdef BIG_ENDIAN
96
+   l = *ptr; 
97
+
98
+   in.f = l;
99
+   out.b[0] = in.b[3];
100
+   out.b[1] = in.b[2];
101
+   out.b[2] = in.b[1];
102
+   out.b[3] = in.b[0];
103
+	
104
+   *ptr = out.f;
105
+#endif
106
+
107
+   return true;
108
+}
109
+
110
+
111
+#ifdef NEW_API_PLANS
112
+
113
+/* FIXME: Add Big Endian support later */
114
+void fread_u8int_small(unsigned char *u, FILE *f)
115
+{
116
+	u_int8_t n;
117
+
118
+	fread(&n, 1, 1, f);
119
+	*u = n;
120
+}
121
+
122
+void fread_u16int_small(unsigned short *u, FILE *f)
123
+{
124
+	u_int16_t n;
125
+
126
+	fread(&n, 2, 1, f);
127
+	*u = n;
128
+}
129
+
130
+void fread_u32int_small(unsigned int *u, FILE *f)
131
+{
132
+	u_int32_t n;
133
+
134
+	fread(&n, 4, 1, f);
135
+	*u = n;
136
+}
137
+#endif

+ 34
- 0
src/endian.h 파일 보기

@@ -0,0 +1,34 @@
1
+/*==========================================================================
2
+ * 
3
+ * Project : MDDC 
4
+ * Author  : Terry 'Mongoose' Hendrix II
5
+ * Website : http://www.westga.edu/~stu7440
6
+ * Email   : stu7440@westga.edu
7
+ * Object  : 
8
+ * Comments: This is the endian utils.
9
+ *
10
+ *           See file COPYING for license details.
11
+ *
12
+ *           Based on type converting code by: 
13
+ *           Michael Vance <mkv102@psu.edu> 
14
+ * 
15
+ *-- History ---------------------------------------------------------- 
16
+ *
17
+ * See the source file's header.
18
+ ==========================================================================*/
19
+
20
+#ifndef __MONGOOSE_ENDIAN_H
21
+#define __MONGOOSE_ENDIAN_H
22
+
23
+#include <stdio.h>
24
+
25
+
26
+// Disable name mangling
27
+extern "C"
28
+{
29
+  int fread_float_small(float *ptr, FILE *stream);
30
+  int fread_int_small(int *ptr, FILE *stream);
31
+  int fread_u_int_small(unsigned int *ptr, FILE *stream);
32
+}
33
+
34
+#endif

+ 81
- 0
src/hel/BoundingVolume.cpp 파일 보기

@@ -0,0 +1,81 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : libHel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : BoundingVolume
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: Bounding volume class for world/vis 
11
+ *           culling/clipping/collision stuff
12
+ *
13
+ *
14
+ *           This file was generated using Mongoose's C++ 
15
+ *           template generator script.  <stu7440@westga.edu>
16
+ * 
17
+ *-- History ------------------------------------------------- 
18
+ *
19
+ * 2002.11.27:
20
+ * Mongoose - Created
21
+ =================================================================*/
22
+
23
+#include "BoundingVolume.h"
24
+
25
+
26
+////////////////////////////////////////////////////////////
27
+// Constructors
28
+////////////////////////////////////////////////////////////
29
+
30
+BoundingVolume::BoundingVolume()
31
+{
32
+}
33
+
34
+
35
+BoundingVolume::~BoundingVolume()
36
+{
37
+}
38
+
39
+
40
+////////////////////////////////////////////////////////////
41
+// Public Accessors
42
+////////////////////////////////////////////////////////////
43
+
44
+
45
+////////////////////////////////////////////////////////////
46
+// Public Mutators
47
+////////////////////////////////////////////////////////////
48
+
49
+
50
+////////////////////////////////////////////////////////////
51
+// Private Accessors
52
+////////////////////////////////////////////////////////////
53
+
54
+
55
+////////////////////////////////////////////////////////////
56
+// Private Mutators
57
+////////////////////////////////////////////////////////////
58
+
59
+
60
+////////////////////////////////////////////////////////////
61
+// Unit Test code
62
+////////////////////////////////////////////////////////////
63
+
64
+#ifdef UNIT_TEST_BOUNDINGVOLUME
65
+int runBoundingVolumeUnitTest()
66
+{
67
+	BoundingVolume vol;
68
+
69
+	return 0;
70
+}
71
+
72
+
73
+int main(int argc, char *argv[])
74
+{
75
+	printf("[BoundingVolume class test]\n");
76
+
77
+	runBoundingVolumeUnitTest();
78
+
79
+	return 0;
80
+}
81
+#endif

+ 112
- 0
src/hel/BoundingVolume.h 파일 보기

@@ -0,0 +1,112 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : libHel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : BoundingVolume
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: Bounding volume class for world/vis 
11
+ *           culling/clipping/collision stuff
12
+ *
13
+ *
14
+ *           This file was generated using Mongoose's C++ 
15
+ *           template generator script.  <stu7440@westga.edu>
16
+ * 
17
+ *-- Test Defines -----------------------------------------------
18
+ *           
19
+ * UNIT_TEST_BOUNDINGVOLUME - Builds BoundingVolume class unit test 
20
+ *
21
+ *-- History ------------------------------------------------ 
22
+ *
23
+ * 2002.11.27:
24
+ * Mongoose - Created
25
+ ================================================================*/
26
+
27
+
28
+#ifndef GUARD__LIBHEL_MONGOOSE_BOUNDINGVOLUME_H_
29
+#define GUARD__LIBHEL_MONGOOSE_BOUNDINGVOLUME_H_
30
+
31
+#include <hel/math.h>
32
+
33
+
34
+class BoundingSphere
35
+{
36
+public:
37
+	vec3_t mCenter;            /* Center of bounding sphere */
38
+
39
+	vec_t mRadius;             /* Raduis of bounding sphere */	
40
+};
41
+
42
+
43
+class BoundingBox
44
+{
45
+public:
46
+	vec3_t mMin;           /* Bounding box MIN point */
47
+
48
+	vec3_t mMax;           /* Bounding box MAX point */
49
+};
50
+
51
+
52
+class BoundingVolume
53
+{
54
+ public:
55
+
56
+	////////////////////////////////////////////////////////////
57
+	// Constructors
58
+	////////////////////////////////////////////////////////////
59
+
60
+	BoundingVolume();
61
+	/*------------------------------------------------------
62
+	 * Pre  : 
63
+	 * Post : Constructs an object of BoundingVolume
64
+	 *
65
+	 *-- History ------------------------------------------
66
+	 *
67
+	 * 2002.11.27: 
68
+	 * Mongoose - Created
69
+	 ------------------------------------------------------*/
70
+
71
+	~BoundingVolume();
72
+	/*------------------------------------------------------
73
+	 * Pre  : BoundingVolume object is allocated
74
+	 * Post : Deconstructs an object of BoundingVolume
75
+	 *
76
+	 *-- History ------------------------------------------
77
+	 *
78
+	 * 2002.11.27: 
79
+	 * Mongoose - Created
80
+	 ------------------------------------------------------*/
81
+
82
+
83
+	////////////////////////////////////////////////////////////
84
+	// Public Accessors
85
+	////////////////////////////////////////////////////////////
86
+
87
+
88
+	////////////////////////////////////////////////////////////
89
+	// Public Mutators
90
+	////////////////////////////////////////////////////////////
91
+
92
+
93
+	BoundingSphere mSphere;    /* Bounding sphere of this volume */
94
+
95
+	BoundingBox mBox;;         /* Bounding box of this volume */
96
+
97
+ private:
98
+
99
+	////////////////////////////////////////////////////////////
100
+	// Private Accessors
101
+	////////////////////////////////////////////////////////////
102
+
103
+
104
+	////////////////////////////////////////////////////////////
105
+	// Private Mutators
106
+	////////////////////////////////////////////////////////////
107
+
108
+
109
+	/* */
110
+};
111
+
112
+#endif

+ 79
- 0
src/hel/Entity.cpp 파일 보기

@@ -0,0 +1,79 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : libHel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Entity
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: This is the base thing class
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2002.11.09:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#include "Entity.h"
23
+
24
+
25
+////////////////////////////////////////////////////////////
26
+// Constructors
27
+////////////////////////////////////////////////////////////
28
+
29
+Entity::Entity()
30
+{
31
+}
32
+
33
+
34
+Entity::~Entity()
35
+{
36
+}
37
+
38
+
39
+////////////////////////////////////////////////////////////
40
+// Public Accessors
41
+////////////////////////////////////////////////////////////
42
+
43
+
44
+////////////////////////////////////////////////////////////
45
+// Public Mutators
46
+////////////////////////////////////////////////////////////
47
+
48
+
49
+////////////////////////////////////////////////////////////
50
+// Private Accessors
51
+////////////////////////////////////////////////////////////
52
+
53
+
54
+////////////////////////////////////////////////////////////
55
+// Private Mutators
56
+////////////////////////////////////////////////////////////
57
+
58
+
59
+////////////////////////////////////////////////////////////
60
+// Unit Test code
61
+////////////////////////////////////////////////////////////
62
+
63
+#ifdef UNIT_TEST_ENTITY
64
+int runEntityUnitTest(int argc, char *argv[])
65
+{
66
+	return 0;
67
+}
68
+
69
+
70
+int main(int argc, char *argv[])
71
+{
72
+	Entity test;
73
+
74
+
75
+	printf("[Entity class test]\n");
76
+
77
+	return runEntityUnitTest(argc, argv);
78
+}
79
+#endif

+ 113
- 0
src/hel/Entity.h 파일 보기

@@ -0,0 +1,113 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Hel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Entity
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: This is the base thing class
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- Test Defines -----------------------------------------------
17
+ *           
18
+ * UNIT_TEST_ENTITY - Builds Entity class as a console unit test 
19
+ *
20
+ *-- History ------------------------------------------------ 
21
+ *
22
+ * 2002.11.09:
23
+ * Mongoose - Created
24
+ ================================================================*/
25
+
26
+
27
+#ifndef GUARD__HEL_MONGOOSE_ENTITY_H_
28
+#define GUARD__HEL_MONGOOSE_ENTITY_H_
29
+
30
+#include <hel/math.h>
31
+#include <hel/BoundingVolume.h>
32
+#include <hel/Quaternion.h>
33
+#include <hel/Vector3d.h>
34
+#include <hel/Mass.h>
35
+
36
+
37
+typedef enum
38
+{
39
+	EntityFlag_Visible    = 1,
40
+	EntityFlag_Collision  = 2,
41
+	EntityFlag_Particle   = 4,
42
+	EntityFlag_World      = 8
43
+
44
+} EntityFlag;
45
+
46
+
47
+class Entity
48
+{
49
+ public:
50
+
51
+	////////////////////////////////////////////////////////////
52
+	// Constructors
53
+	////////////////////////////////////////////////////////////
54
+
55
+	Entity();
56
+	/*------------------------------------------------------
57
+	 * Pre  : 
58
+	 * Post : Constructs an object of Entity
59
+	 *
60
+	 *-- History ------------------------------------------
61
+	 *
62
+	 * 2002.11.09: 
63
+	 * Mongoose - Created
64
+	 ------------------------------------------------------*/
65
+
66
+	~Entity();
67
+	/*------------------------------------------------------
68
+	 * Pre  : Entity object is allocated
69
+	 * Post : Deconstructs an object of Entity
70
+	 *
71
+	 *-- History ------------------------------------------
72
+	 *
73
+	 * 2002.11.09: 
74
+	 * Mongoose - Created
75
+	 ------------------------------------------------------*/
76
+
77
+
78
+	////////////////////////////////////////////////////////////
79
+	// Public Accessors
80
+	////////////////////////////////////////////////////////////
81
+
82
+
83
+
84
+	////////////////////////////////////////////////////////////
85
+	// Public Mutators
86
+	////////////////////////////////////////////////////////////
87
+
88
+
89
+	unsigned int mId;          /* Unique identifier */
90
+
91
+	Vector3d mPos;             /* World position */
92
+
93
+	Quaternion mOrientation;	/* Orientation (Pitch, Yaw, Roll) */
94
+
95
+	BoundingVolume mVolume;		/* Bounding volume of entity */
96
+
97
+	Mass mMass;						/* Mass of this entity */
98
+
99
+	EntityFlag mFlag;	 			/* Flags of this entity */
100
+
101
+ private:
102
+
103
+	////////////////////////////////////////////////////////////
104
+	// Private Accessors
105
+	////////////////////////////////////////////////////////////
106
+
107
+
108
+	////////////////////////////////////////////////////////////
109
+	// Private Mutators
110
+	////////////////////////////////////////////////////////////
111
+};
112
+
113
+#endif

+ 117
- 0
src/hel/Mass.cpp 파일 보기

@@ -0,0 +1,117 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Hel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Mass
9
+ * License : No use w/o permission (C) 2003 Mongoose
10
+ * Comments: This is the class that has the mass - oh yass
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2003.06.02:
19
+ * Mongoose - Created, based on algorithms from Erkin Tunca
20
+ =================================================================*/
21
+
22
+#include "Mass.h"
23
+
24
+
25
+////////////////////////////////////////////////////////////
26
+// Constructors
27
+////////////////////////////////////////////////////////////
28
+
29
+Mass::Mass()
30
+{
31
+	mMass = 0.0;
32
+}
33
+
34
+
35
+Mass::Mass(vec_t mass)
36
+{
37
+	mMass = mass;
38
+}
39
+
40
+
41
+Mass::Mass(vec_t mass, const Vector3d &position, const Vector3d &velocity)
42
+{
43
+	mMass = mass;
44
+	mPos = position;
45
+	mVelocity = velocity;
46
+}
47
+
48
+
49
+Mass::~Mass()
50
+{
51
+}
52
+
53
+
54
+////////////////////////////////////////////////////////////
55
+// Public Accessors
56
+////////////////////////////////////////////////////////////
57
+
58
+
59
+////////////////////////////////////////////////////////////
60
+// Public Mutators
61
+////////////////////////////////////////////////////////////
62
+
63
+void Mass::applyForce(Vector3d force)
64
+{
65
+	mForce += force;
66
+}
67
+
68
+
69
+void Mass::rest()
70
+{
71
+	mForce = Vector3d(0, 0, 0);
72
+}
73
+
74
+
75
+void Mass::simulate(vec_t timeDelta)
76
+{
77
+	// The Euler Method, hhmmm... for now
78
+
79
+	// Update velocity
80
+	mVelocity += (mForce / mMass) * timeDelta;
81
+
82
+	// Update position, position = velocity * time delta
83
+	mPos += mVelocity * timeDelta;
84
+}
85
+
86
+
87
+////////////////////////////////////////////////////////////
88
+// Private Accessors
89
+////////////////////////////////////////////////////////////
90
+
91
+
92
+////////////////////////////////////////////////////////////
93
+// Private Mutators
94
+////////////////////////////////////////////////////////////
95
+
96
+
97
+////////////////////////////////////////////////////////////
98
+// Unit Test code
99
+////////////////////////////////////////////////////////////
100
+
101
+#ifdef UNIT_TEST_MASS
102
+int runMassUnitTest(int argc, char *argv[])
103
+{
104
+	Mass test;
105
+
106
+	return 0;
107
+}
108
+
109
+
110
+int main(int argc, char *argv[])
111
+{
112
+	printf("[Mass class test]\n");
113
+	runMassUnitTest(argc, argv);
114
+
115
+	return 0;
116
+}
117
+#endif

+ 151
- 0
src/hel/Mass.h 파일 보기

@@ -0,0 +1,151 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Hel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Mass
9
+ * License : No use w/o permission (C) 2003 Mongoose
10
+ * Comments: This is the class that has the mass - oh yass
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- Test Defines -----------------------------------------------
17
+ *           
18
+ * UNIT_TEST_MASS - Builds Mass class as a console unit test 
19
+ *
20
+ *-- History ------------------------------------------------ 
21
+ *
22
+ * 2003.06.02:
23
+ * Mongoose - Created, based on algorithms from Erkin Tunca
24
+ ================================================================*/
25
+
26
+
27
+#ifndef GUARD__HEL_MONGOOSE_MASS_H_
28
+#define GUARD__HEL_MONGOOSE_MASS_H_
29
+
30
+#include <hel/math.h>
31
+#include <hel/Vector3d.h>
32
+
33
+class Mass
34
+{
35
+ public:
36
+
37
+	////////////////////////////////////////////////////////////
38
+	// Constructors
39
+	////////////////////////////////////////////////////////////
40
+
41
+	Mass();
42
+	/*------------------------------------------------------
43
+	 * Pre  : 
44
+	 * Post : Constructs an object of Mass
45
+	 *
46
+	 *-- History ------------------------------------------
47
+	 *
48
+	 * 2003.06.02: 
49
+	 * Mongoose - Created
50
+	 ------------------------------------------------------*/
51
+
52
+	Mass(vec_t mass);
53
+	/*------------------------------------------------------
54
+	 * Pre  : 
55
+	 * Post : Constructs an object of Mass
56
+	 *
57
+	 *-- History ------------------------------------------
58
+	 *
59
+	 * 2003.06.02: 
60
+	 * Mongoose - Created
61
+	 ------------------------------------------------------*/
62
+
63
+	Mass(vec_t mass, const Vector3d &position, const Vector3d &velocity);
64
+	/*------------------------------------------------------
65
+	 * Pre  : 
66
+	 * Post : Constructs an object of Mass
67
+	 *
68
+	 *-- History ------------------------------------------
69
+	 *
70
+	 * 2003.06.02: 
71
+	 * Mongoose - Created
72
+	 ------------------------------------------------------*/
73
+
74
+	virtual ~Mass();
75
+	/*------------------------------------------------------
76
+	 * Pre  : Mass object is allocated
77
+	 * Post : Deconstructs an object of Mass
78
+	 *
79
+	 *-- History ------------------------------------------
80
+	 *
81
+	 * 2003.06.02: 
82
+	 * Mongoose - Created
83
+	 ------------------------------------------------------*/
84
+
85
+
86
+	////////////////////////////////////////////////////////////
87
+	// Public Accessors
88
+	////////////////////////////////////////////////////////////
89
+
90
+
91
+
92
+	////////////////////////////////////////////////////////////
93
+	// Public Mutators
94
+	////////////////////////////////////////////////////////////
95
+
96
+	virtual void applyForce(Vector3d force);
97
+	/*------------------------------------------------------
98
+	 * Pre  : 
99
+	 * Post : External force acts on... the mass
100
+	 *
101
+	 *-- History ------------------------------------------
102
+	 *
103
+	 * 2003.06.02:
104
+	 * Mongoose - Created
105
+	 ------------------------------------------------------*/
106
+
107
+	virtual void rest();
108
+	/*------------------------------------------------------
109
+	 * Pre  : 
110
+	 * Post : Reset forces acting on this mass
111
+	 *
112
+	 *-- History ------------------------------------------
113
+	 *
114
+	 * 2003.06.02:
115
+	 * Mongoose - Created
116
+	 ------------------------------------------------------*/
117
+
118
+	virtual void simulate(vec_t timeDelta);
119
+	/*------------------------------------------------------
120
+	 * Pre  : Given change in time
121
+	 * Post : Adjust velocity and position with respect to dt
122
+	 *
123
+	 *-- History ------------------------------------------
124
+	 *
125
+	 * 2003.06.02:
126
+	 * Mongoose - Created
127
+	 ------------------------------------------------------*/
128
+
129
+	vec_t mMass;          /* The value of the mass */
130
+
131
+	Vector3d mPos;        /* Location in 3 space of... the mass */
132
+
133
+	Vector3d mVelocity;   /* Velocity of... the mass */
134
+
135
+	Vector3d mForce;      /* Force acting on the mass */
136
+
137
+
138
+ private:
139
+
140
+	////////////////////////////////////////////////////////////
141
+	// Private Accessors
142
+	////////////////////////////////////////////////////////////
143
+
144
+
145
+	////////////////////////////////////////////////////////////
146
+	// Private Mutators
147
+	////////////////////////////////////////////////////////////
148
+
149
+};
150
+
151
+#endif

+ 726
- 0
src/hel/Matrix.cpp 파일 보기

@@ -0,0 +1,726 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Freyja
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Matrix
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: 3d Matrix class
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2002.05.11:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#include <stdio.h>
23
+#include <math.h>
24
+#include "Matrix.h"
25
+
26
+
27
+////////////////////////////////////////////////////////////
28
+// Constructors
29
+////////////////////////////////////////////////////////////
30
+
31
+Matrix::Matrix()
32
+{
33
+	setIdentity();
34
+}
35
+
36
+
37
+Matrix::Matrix(matrix_t m)
38
+{
39
+	setMatrix(m);
40
+}
41
+
42
+
43
+Matrix::Matrix(Quaternion &q)
44
+{
45
+	matrix_t m;
46
+
47
+
48
+	q.getMatrix(m);
49
+	setMatrix(m);
50
+}
51
+
52
+
53
+Matrix::~Matrix()
54
+{
55
+}
56
+
57
+
58
+////////////////////////////////////////////////////////////
59
+// Public Accessors
60
+////////////////////////////////////////////////////////////
61
+
62
+
63
+bool Matrix::getInvert(matrix_t out)
64
+{
65
+	matrix_t m;
66
+
67
+#ifdef COLUMN_ORDER
68
+	getMatrix(m);
69
+#else
70
+	getTransposeMatrix(m);
71
+#endif
72
+
73
+	/* Mongoose: This code was from a Jeff Lander tutorial which was based
74
+		on MESA GL's InvertMatrix */
75
+
76
+	/* NB. OpenGL Matrices are COLUMN major. */
77
+#define SWAP_ROWS(a, b) { float *_tmp = a; (a)=(b); (b)=_tmp; }
78
+#define MAT(m,r,c) (m)[(c)*4+(r)]
79
+	
80
+	float wtmp[4][8];
81
+	float m0, m1, m2, m3, s;
82
+	float *r0, *r1, *r2, *r3;
83
+	
84
+	r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3];
85
+	
86
+	r0[0] = MAT(m,0,0), r0[1] = MAT(m,0,1),
87
+	r0[2] = MAT(m,0,2), r0[3] = MAT(m,0,3),
88
+	r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0,
89
+	
90
+	r1[0] = MAT(m,1,0), r1[1] = MAT(m,1,1),
91
+	r1[2] = MAT(m,1,2), r1[3] = MAT(m,1,3),
92
+	r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0,
93
+	
94
+	r2[0] = MAT(m,2,0), r2[1] = MAT(m,2,1),
95
+	r2[2] = MAT(m,2,2), r2[3] = MAT(m,2,3),
96
+	r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0,
97
+	
98
+	r3[0] = MAT(m,3,0), r3[1] = MAT(m,3,1),
99
+	r3[2] = MAT(m,3,2), r3[3] = MAT(m,3,3),
100
+	r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
101
+
102
+	/* choose pivot - or die */
103
+	if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2);
104
+	if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1);
105
+	if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0);
106
+	if (0.0 == r0[0])  return false;
107
+	
108
+	/* eliminate first variable     */
109
+	m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0];
110
+	s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s;
111
+	s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s;
112
+	s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s;
113
+	s = r0[4];
114
+	if (s != 0.0) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; }
115
+	s = r0[5];
116
+	if (s != 0.0) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; }
117
+	s = r0[6];
118
+	if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; }
119
+	s = r0[7];
120
+	if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
121
+	
122
+	/* choose pivot - or die */
123
+	if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2);
124
+	if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1);
125
+	if (0.0 == r1[1])  return false;
126
+	
127
+	/* eliminate second variable */
128
+	m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1];
129
+	r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2];
130
+	r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3];
131
+	s = r1[4]; if (0.0 != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; }
132
+	s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; }
133
+	s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; }
134
+	s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
135
+	
136
+	/* choose pivot - or die */
137
+	if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2);
138
+	if (0.0 == r2[2])  return false;
139
+	
140
+	/* eliminate third variable */
141
+	m3 = r3[2]/r2[2];
142
+	r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4],
143
+	r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6],
144
+	r3[7] -= m3 * r2[7];
145
+	
146
+	/* last check */
147
+	if (0.0 == r3[3]) return false;
148
+	
149
+	s = 1.0/r3[3];              /* now back substitute row 3 */
150
+	r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s;
151
+	
152
+	m2 = r2[3];                 /* now back substitute row 2 */
153
+	s  = 1.0/r2[2];
154
+	r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2),
155
+	r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2);
156
+	m1 = r1[3];
157
+	r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1,
158
+	r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1;
159
+	m0 = r0[3];
160
+	r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0,
161
+	r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0;
162
+	
163
+	m1 = r1[2];                 /* now back substitute row 1 */
164
+	s  = 1.0/r1[1];
165
+	r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1),
166
+	r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1);
167
+	m0 = r0[2];
168
+	r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0,
169
+	r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0;
170
+	
171
+	m0 = r0[1];                 /* now back substitute row 0 */
172
+	s  = 1.0/r0[0];
173
+	r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0),
174
+	r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0);
175
+	
176
+	MAT(out,0,0) = r0[4]; 
177
+	MAT(out,0,1) = r0[5], MAT(out,0,2) = r0[6]; 
178
+	MAT(out,0,3) = r0[7], MAT(out,1,0) = r1[4];
179
+	MAT(out,1,1) = r1[5], MAT(out,1,2) = r1[6];
180
+	MAT(out,1,3) = r1[7], MAT(out,2,0) = r2[4];
181
+	MAT(out,2,1) = r2[5], MAT(out,2,2) = r2[6];
182
+	MAT(out,2,3) = r2[7], MAT(out,3,0) = r3[4];
183
+	MAT(out,3,1) = r3[5], MAT(out,3,2) = r3[6];
184
+	MAT(out,3,3) = r3[7]; 
185
+	
186
+	return true;
187
+#undef MAT
188
+#undef SWAP_ROWS
189
+}
190
+
191
+
192
+void Matrix::getMatrix(matrix_t mat)
193
+{
194
+	copy(mMatrix, mat);
195
+}
196
+
197
+
198
+void Matrix::getTransposeMatrix(matrix_t m)
199
+{
200
+	m[ 0]= mMatrix[0]; m[ 1]= mMatrix[4]; m[ 2]= mMatrix[ 8]; m[ 3]=mMatrix[12];
201
+	m[ 4]= mMatrix[1]; m[ 5]= mMatrix[5]; m[ 6]= mMatrix[ 9]; m[ 7]=mMatrix[13];
202
+	m[ 8]= mMatrix[2]; m[ 9]= mMatrix[6]; m[10]= mMatrix[10]; m[11]=mMatrix[14];
203
+	m[12]= mMatrix[3]; m[13]= mMatrix[7]; m[14]= mMatrix[11]; m[15]=mMatrix[15];
204
+}
205
+
206
+
207
+Matrix Matrix::multiply(const Matrix &a, const Matrix &b)
208
+{
209
+	Matrix c;
210
+
211
+
212
+	multiply(a.mMatrix, b.mMatrix, c.mMatrix);
213
+
214
+	return c;
215
+}
216
+
217
+
218
+Matrix Matrix::operator *(const Matrix &a)
219
+{
220
+	return multiply(a, *this);
221
+}
222
+
223
+
224
+Vector3d Matrix::operator *(Vector3d v)
225
+{
226
+	vec_t x = v.mVec[0], y = v.mVec[1], z = v.mVec[2];
227
+
228
+
229
+#ifdef COLUMN_ORDER
230
+	// Column order
231
+	return Vector3d(mMatrix[0]*x + mMatrix[4]*y + mMatrix[ 8]*z + mMatrix[12],
232
+						 mMatrix[1]*x + mMatrix[5]*y + mMatrix[ 9]*z + mMatrix[13],
233
+						 mMatrix[2]*x + mMatrix[6]*y + mMatrix[10]*z + mMatrix[14]);
234
+#else
235
+	// Row order
236
+	return Vector3d(mMatrix[0]*x + mMatrix[1]*y + mMatrix[ 2]*z + mMatrix[ 3],
237
+						 mMatrix[4]*x + mMatrix[5]*y + mMatrix[ 6]*z + mMatrix[ 7],
238
+						 mMatrix[8]*x + mMatrix[9]*y + mMatrix[10]*z + mMatrix[11]);
239
+#endif
240
+}
241
+
242
+
243
+void Matrix::multiply3v(vec3_t v, vec3_t result)
244
+{
245
+	vec_t x = v[0], y = v[1], z = v[2];
246
+
247
+
248
+   result[0] = mMatrix[0]*x + mMatrix[1]*y + mMatrix[ 2]*z + mMatrix[ 3];
249
+	result[1] = mMatrix[4]*x + mMatrix[5]*y + mMatrix[ 6]*z + mMatrix[ 7];
250
+	result[2] = mMatrix[8]*x + mMatrix[9]*y + mMatrix[10]*z + mMatrix[11];
251
+}
252
+
253
+
254
+void Matrix::multiply4d(double *v, double *result)
255
+{
256
+	double x = v[0], y = v[1], z = v[2], w = v[3];
257
+
258
+
259
+   result[0] = mMatrix[ 0]*x + mMatrix[ 1]*y + mMatrix[ 2]*z + mMatrix[ 3]*w;
260
+	result[1] = mMatrix[ 4]*x + mMatrix[ 5]*y + mMatrix[ 6]*z + mMatrix[ 7]*w;
261
+	result[2] = mMatrix[ 8]*x + mMatrix[ 9]*y + mMatrix[10]*z + mMatrix[11]*w;
262
+	result[3] = mMatrix[12]*x + mMatrix[13]*y + mMatrix[14]*z + mMatrix[15]*w;
263
+}
264
+
265
+
266
+void Matrix::multiply4v(vec4_t v, vec4_t result)
267
+{
268
+	vec_t x = v[0], y = v[1], z = v[2], w = v[3];
269
+
270
+	
271
+   result[0] = mMatrix[ 0]*x + mMatrix[ 1]*y + mMatrix[ 2]*z + mMatrix[ 3]*w;
272
+	result[1] = mMatrix[ 4]*x + mMatrix[ 5]*y + mMatrix[ 6]*z + mMatrix[ 7]*w;
273
+	result[2] = mMatrix[ 8]*x + mMatrix[ 9]*y + mMatrix[10]*z + mMatrix[11]*w;
274
+	result[3] = mMatrix[12]*x + mMatrix[13]*y + mMatrix[14]*z + mMatrix[15]*w;
275
+}
276
+
277
+
278
+void Matrix::print()
279
+{
280
+#ifdef COLUMN_ORDER
281
+	printf("{\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n}\n",
282
+			 mMatrix[0], mMatrix[4], mMatrix[ 8], mMatrix[12],
283
+			 mMatrix[1], mMatrix[5], mMatrix[ 9], mMatrix[13],
284
+			 mMatrix[2], mMatrix[6], mMatrix[10], mMatrix[14],
285
+			 mMatrix[3], mMatrix[7], mMatrix[11], mMatrix[15]);
286
+#else
287
+	printf("{\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n}\n",
288
+			 mMatrix[ 0], mMatrix[ 1], mMatrix[ 2], mMatrix[ 3],
289
+			 mMatrix[ 4], mMatrix[ 5], mMatrix[ 6], mMatrix[ 7],
290
+			 mMatrix[ 8], mMatrix[ 9], mMatrix[10], mMatrix[11],
291
+			 mMatrix[12], mMatrix[13], mMatrix[14], mMatrix[15]);
292
+#endif
293
+}
294
+
295
+
296
+bool Matrix::isIdentity()
297
+{
298
+	// Hhhmm... floating point using direct comparisions
299
+	if (mMatrix[ 0] == 1 && mMatrix[ 1] == 0 && mMatrix[ 2] == 0 && 
300
+		 mMatrix[ 3] == 0 &&	mMatrix[ 4] == 0 && mMatrix[ 5] == 1 && 
301
+		 mMatrix[ 6] == 0 && mMatrix[ 7] == 0 && mMatrix[ 8] == 0 && 
302
+		 mMatrix[ 9] == 0 && mMatrix[10] == 1 && mMatrix[11] == 0 &&
303
+		 mMatrix[12] == 0 && mMatrix[13] == 0 && mMatrix[14] == 0 && 
304
+		 mMatrix[15] == 1)
305
+		return true;
306
+
307
+	return false;
308
+}
309
+
310
+
311
+////////////////////////////////////////////////////////////
312
+// Public Mutators
313
+////////////////////////////////////////////////////////////
314
+
315
+void Matrix::setMatrix(matrix_t mat)
316
+{
317
+	copy(mat, mMatrix);
318
+}
319
+
320
+
321
+void Matrix::setIdentity()
322
+{
323
+	mMatrix[ 0] = 1; mMatrix[ 1] = 0; mMatrix[ 2] = 0; mMatrix[ 3] = 0;
324
+	mMatrix[ 4] = 0; mMatrix[ 5] = 1; mMatrix[ 6] = 0; mMatrix[ 7] = 0;
325
+	mMatrix[ 8] = 0; mMatrix[ 9] = 0; mMatrix[10] = 1; mMatrix[11] = 0;
326
+	mMatrix[12] = 0; mMatrix[13] = 0; mMatrix[14] = 0; mMatrix[15] = 1;
327
+}
328
+
329
+
330
+void Matrix::scale(const vec_t *xyz)
331
+{
332
+	scale(xyz[0], xyz[1], xyz[2]);
333
+}
334
+
335
+
336
+void Matrix::scale(vec_t sx, vec_t sy, vec_t sz)
337
+{
338
+   matrix_t smatrix;
339
+	matrix_t tmp;
340
+
341
+
342
+   smatrix[ 0] = sx;smatrix[ 1] = 0; smatrix[ 2] = 0; smatrix[ 3] = 0;
343
+   smatrix[ 4] = 0; smatrix[ 5] = sy;smatrix[ 6] = 0; smatrix[ 7] = 0;
344
+   smatrix[ 8] = 0; smatrix[ 9] = 0; smatrix[10] = sz;smatrix[11] = 0;
345
+   smatrix[12] = 0; smatrix[13] = 0; smatrix[14] = 0; smatrix[15] = 1;
346
+
347
+	copy(mMatrix, tmp);
348
+	multiply(tmp, smatrix, mMatrix);
349
+}
350
+
351
+
352
+void Matrix::rotate(const vec_t *xyz)
353
+{
354
+	rotate(xyz[0], xyz[1], xyz[2]);
355
+}
356
+
357
+
358
+void Matrix::rotate(vec_t ax, vec_t ay, vec_t az)
359
+{
360
+   matrix_t xmat, ymat, zmat, tmp, tmp2;
361
+
362
+
363
+   xmat[ 0]=1;        xmat[ 1]=0;        xmat[ 2]=0;        xmat[ 3]=0;
364
+   xmat[ 4]=0;        xmat[ 5]=cos(ax);  xmat[ 6]=sin(ax);  xmat[ 7]=0;
365
+   xmat[ 8]=0;        xmat[ 9]=-sin(ax); xmat[10]=cos(ax);  xmat[11]=0;
366
+   xmat[12]=0;        xmat[13]=0;        xmat[14]=0;        xmat[15]=1;
367
+
368
+   ymat[ 0]=cos(ay);  ymat[ 1]=0;        ymat[ 2]=-sin(ay); ymat[ 3]=0;
369
+   ymat[ 4]=0;        ymat[ 5]=1;        ymat[ 6]=0;        ymat[ 7]=0;
370
+   ymat[ 8]=sin(ay);  ymat[ 9]=0;        ymat[10]=cos(ay);  ymat[11]=0;
371
+   ymat[12]=0;        ymat[13]=0;        ymat[14]=0;        ymat[15]=1;
372
+
373
+   zmat[ 0]=cos(az);  zmat[ 1]=sin(az);  zmat[ 2]=0;        zmat[ 3]=0;
374
+   zmat[ 4]=-sin(az); zmat[ 5]=cos(az);  zmat[ 6]=0;        zmat[ 7]=0;
375
+   zmat[ 8]=0;        zmat[ 9]=0;        zmat[10]=1;        zmat[11]=0;
376
+   zmat[12]=0;        zmat[13]=0;        zmat[14]=0;        zmat[15]=1;
377
+
378
+   multiply(mMatrix, ymat, tmp);
379
+   multiply(tmp, xmat, tmp2);
380
+   multiply(tmp2, zmat, mMatrix);
381
+}
382
+
383
+
384
+void Matrix::translate(const vec_t *xyz)
385
+{
386
+	translate(xyz[0], xyz[1], xyz[2]);
387
+}
388
+
389
+
390
+void Matrix::translate(vec_t tx, vec_t ty, vec_t tz)
391
+{
392
+   matrix_t tmat, tmp;
393
+
394
+
395
+   tmat[ 0]=1;  tmat[ 1]=0;  tmat[ 2]=0;  tmat[ 3]=0;
396
+   tmat[ 4]=0;  tmat[ 5]=1;  tmat[ 6]=0;  tmat[ 7]=0;
397
+   tmat[ 8]=0;  tmat[ 9]=0;  tmat[10]=1;  tmat[11]=0;
398
+   tmat[12]=tx; tmat[13]=ty; tmat[14]=tz; tmat[15]=1;
399
+
400
+	copy(mMatrix, tmp);
401
+	multiply(tmp, tmat, mMatrix);
402
+}
403
+
404
+
405
+////////////////////////////////////////////////////////////
406
+// Private Accessors
407
+////////////////////////////////////////////////////////////
408
+
409
+
410
+////////////////////////////////////////////////////////////
411
+// Private Mutators
412
+////////////////////////////////////////////////////////////
413
+
414
+void Matrix::copy(matrix_t source, matrix_t dest)
415
+{
416
+#ifdef FASTER_MATRIX
417
+	memcpy(dest, source, sizeof(matrix_t));
418
+#else
419
+	dest[ 0] = source[ 0];
420
+	dest[ 1] = source[ 1];
421
+	dest[ 2] = source[ 2];
422
+	dest[ 3] = source[ 3];
423
+
424
+	dest[ 4] = source[ 4];
425
+	dest[ 5] = source[ 5];
426
+	dest[ 6] = source[ 6];
427
+	dest[ 7] = source[ 7];
428
+
429
+	dest[ 8] = source[8];
430
+	dest[ 9] = source[9];
431
+	dest[10] = source[10];
432
+	dest[11] = source[11];
433
+
434
+	dest[12] = source[12];
435
+	dest[13] = source[13];
436
+	dest[14] = source[14];
437
+	dest[15] = source[15];
438
+#endif
439
+}
440
+
441
+
442
+void Matrix::multiply(const matrix_t a, const matrix_t b, matrix_t result)
443
+{
444
+	/* Generated code for matrix mult */
445
+#ifdef COLUMN_ORDER
446
+	/* Column order */
447
+	result[ 0] = a[ 0] * b[ 0] + a[ 4] * b[ 1] + a[ 8] * b[ 2] + a[12] * b[ 3];
448
+	result[ 1] = a[ 0] * b[ 4] + a[ 4] * b[ 5] + a[ 8] * b[ 6] + a[12] * b[ 7];
449
+	result[ 2] = a[ 0] * b[ 8] + a[ 4] * b[ 9] + a[ 8] * b[10] + a[12] * b[11];
450
+	result[ 3] = a[ 0] * b[12] + a[ 4] * b[13] + a[ 8] * b[14] + a[12] * b[15];
451
+	
452
+	result[ 4] = a[ 1] * b[ 0] + a[ 5] * b[ 1] + a[ 9] * b[ 2] + a[13] * b[ 3];
453
+	result[ 5] = a[ 1] * b[ 4] + a[ 5] * b[ 5] + a[ 9] * b[ 6] + a[13] * b[ 7];
454
+	result[ 6] = a[ 1] * b[ 8] + a[ 5] * b[ 9] + a[ 9] * b[10] + a[13] * b[11];
455
+	result[ 7] = a[ 1] * b[12] + a[ 5] * b[13] + a[ 9] * b[14] + a[13] * b[15];
456
+	
457
+	result[ 8] = a[ 2] * b[ 0] + a[ 6] * b[ 1] + a[10] * b[ 2] + a[14] * b[ 3];
458
+	result[ 9] = a[ 2] * b[ 4] + a[ 6] * b[ 5] + a[10] * b[ 6] + a[14] * b[ 7];
459
+	result[10] = a[ 2] * b[ 8] + a[ 6] * b[ 9] + a[10] * b[10] + a[14] * b[11];
460
+	result[11] = a[ 2] * b[12] + a[ 6] * b[13] + a[10] * b[14] + a[14] * b[15];
461
+	
462
+	result[12] = a[ 3] * b[ 0] + a[ 7] * b[ 1] + a[11] * b[ 2] + a[15] * b[ 3];
463
+	result[13] = a[ 3] * b[ 4] + a[ 7] * b[ 5] + a[11] * b[ 6] + a[15] * b[ 7];
464
+	result[14] = a[ 3] * b[ 8] + a[ 7] * b[ 9] + a[11] * b[10] + a[15] * b[11];
465
+	result[15] = a[ 3] * b[12] + a[ 7] * b[13] + a[11] * b[14] + a[15] * b[15];
466
+#else
467
+	/* Row order */
468
+	result[ 0] = a[ 0] * b[ 0] + a[ 1] * b[ 4] + a[ 2] * b[ 8] + a[ 3] * b[12];
469
+	result[ 1] = a[ 0] * b[ 1] + a[ 1] * b[ 5] + a[ 2] * b[ 9] + a[ 3] * b[13];
470
+	result[ 2] = a[ 0] * b[ 2] + a[ 1] * b[ 6] + a[ 2] * b[10] + a[ 3] * b[14];
471
+	result[ 3] = a[ 0] * b[ 3] + a[ 1] * b[ 7] + a[ 2] * b[11] + a[ 3] * b[15];
472
+	
473
+	result[ 4] = a[ 4] * b[ 0] + a[ 5] * b[ 4] + a[ 6] * b[ 8] + a[ 7] * b[12];
474
+	result[ 5] = a[ 4] * b[ 1] + a[ 5] * b[ 5] + a[ 6] * b[ 9] + a[ 7] * b[13];
475
+	result[ 6] = a[ 4] * b[ 2] + a[ 5] * b[ 6] + a[ 6] * b[10] + a[ 7] * b[14];
476
+	result[ 7] = a[ 4] * b[ 3] + a[ 5] * b[ 7] + a[ 6] * b[11] + a[ 7] * b[15];
477
+	
478
+	result[ 8] = a[ 8] * b[ 0] + a[ 9] * b[ 4] + a[10] * b[ 8] + a[11] * b[12];
479
+	result[ 9] = a[ 8] * b[ 1] + a[ 9] * b[ 5] + a[10] * b[ 9] + a[11] * b[13];
480
+	result[10] = a[ 8] * b[ 2] + a[ 9] * b[ 6] + a[10] * b[10] + a[11] * b[14];
481
+	result[11] = a[ 8] * b[ 3] + a[ 9] * b[ 7] + a[10] * b[11] + a[11] * b[15];
482
+	
483
+	result[12] = a[12] * b[ 0] + a[13] * b[ 4] + a[14] * b[ 8] + a[15] * b[12];
484
+	result[13] = a[12] * b[ 1] + a[13] * b[ 5] + a[14] * b[ 9] + a[15] * b[13];
485
+	result[14] = a[12] * b[ 2] + a[13] * b[ 6] + a[14] * b[10] + a[15] * b[14];
486
+	result[15] = a[12] * b[ 3] + a[13] * b[ 7] + a[14] * b[11] + a[15] * b[15];
487
+#endif
488
+}
489
+
490
+
491
+////////////////////////////////////////////////////////////
492
+// Unit Test 
493
+////////////////////////////////////////////////////////////
494
+
495
+#ifdef MATRIX_UNIT_TEST
496
+/* <Order> is (r)ow or (c)ol */
497
+void generateMatrixSourceTest(char order)
498
+{
499
+	int i, j, k;
500
+
501
+	
502
+	if (order == 'r')
503
+	{
504
+		printf("/* Row order */\n");
505
+	}
506
+	else
507
+	{
508
+		printf("/* Column order */\n");
509
+	}
510
+	
511
+	for (i = 0; i < 4; ++i)
512
+	{
513
+		for (j = 0; j < 4; ++j)
514
+		{
515
+			if (order == 'r')
516
+			{
517
+				printf("result[%2i] = ", j+i*4);
518
+			}
519
+			else
520
+			{
521
+				printf("result[%2i] = ", j+i*4);
522
+			}
523
+			
524
+			for (k = 0; k < 4; ++k)
525
+			{
526
+				if (order == 'r')
527
+				{
528
+					printf("a[%2i] * b[%2i]%s",
529
+							  k+i*4, j+k*4, (k == 3) ? ";\n" : " + "); 
530
+				}
531
+				else
532
+				{
533
+					printf("a[%2i] * b[%2i]%s", 
534
+							 i+k*4, k+j*4, (k == 3) ? ";\n" : " + ");
535
+				}
536
+
537
+				//sum+=(elements[i+k*4]*m.elements[k+j*4]);
538
+			}
539
+
540
+			//result.elements[i+j*4]=sum;
541
+		}
542
+
543
+		printf("\n");
544
+	}
545
+
546
+	printf("\n");
547
+
548
+	printf("/* Transpose */\n");
549
+	for(i = 0; i < 4; ++i)
550
+	{
551
+		for (j = 0; j < 4; ++j)
552
+		{
553
+			printf("a[%2i] = b[%2i]%s",
554
+					 j+i*4, i+j*4, (j == 3) ? ";\n" : "; ");
555
+		}
556
+	}
557
+}
558
+
559
+
560
+int runMatrixUnitTest()
561
+{
562
+	unsigned int i, errs;
563
+	Matrix a, b, c;
564
+	matrix_t m;
565
+
566
+
567
+	// Test 3 cases of identity use
568
+	for (errs = 0, i = 0; i < 3; ++i)
569
+	{
570
+		// Fill A matrix with garbage
571
+		m[ 0] = m[ 1] = m[ 2] = m[ 3] = 45.0f;
572
+		m[ 4] = m[ 5] = m[ 6] = m[ 7] = 90.0f;
573
+		m[ 8] = m[ 9] = m[10] = m[11] = 180.0f;
574
+		m[12] = m[13] = m[14] = m[15] = 270.0f;
575
+		a.setMatrix(m);
576
+
577
+		switch (i)
578
+		{
579
+		case 0:
580
+			printf("Set to Identity");
581
+			a.setIdentity();
582
+			break;
583
+		case 1:
584
+			printf("Identity * Identity");
585
+			c.setIdentity();
586
+			b.setIdentity();
587
+			a = c * b; 
588
+			break;
589
+		case 2:
590
+			printf("Identity *= Identity");
591
+			a.setIdentity();
592
+			b.setIdentity();
593
+			a = a * b;
594
+			break;
595
+		}
596
+
597
+		if (a.isIdentity())
598
+		{
599
+			printf(" \t[ Passed ]\n");
600
+		}
601
+		else
602
+		{
603
+			++errs;
604
+			printf(" \t[ Failed ]\a\n"); // beep
605
+			a.print();
606
+		}
607
+
608
+		printf("\n");
609
+	}
610
+
611
+	/* 2003.06.18, Mongoose - These tests are weak and 
612
+		only spot check some of the matrix */
613
+
614
+
615
+	/* Cheap translation test */
616
+	a.setIdentity();
617
+	printf("I -> Translate (10, 20, 30)\n");
618
+	a.translate(10, 20, 30);
619
+
620
+#ifdef COLUMN_ORDER
621
+	unsigned char i0  = 0, i1  = 4, i2  =  8, i3  = 12;
622
+	unsigned char i4  = 1, i5  = 5, i6  =  9, i7  = 13; 
623
+	unsigned char i8  = 2, i9  = 6, i10 = 10, i11 = 14;
624
+	unsigned char i12 = 3, i13 = 7, i14 = 11, i15 = 15;
625
+#else
626
+	unsigned char i0  =  0, i1  =  1, i2  =  2, i3  =  3;
627
+	unsigned char i4  =  4, i5  =  5, i6  =  6, i7  =  7;
628
+	unsigned char i8  =  8, i9  =  9, i10 = 10, i11 = 11;
629
+	unsigned char i12 = 12, i13 = 13, i14 = 14, i15 = 15;
630
+#endif
631
+
632
+	if (a.mMatrix[i12] != 10 || 
633
+		 a.mMatrix[i13] != 20 || 
634
+		 a.mMatrix[i14] != 30)
635
+	{
636
+			++errs;
637
+			printf(" \t[ Failed ]\a\n"); // beep
638
+			a.print();		
639
+	}
640
+
641
+	/* Cheap X rotation test */
642
+	a.setIdentity();
643
+	printf("I -> Rotate (90 degrees, 0, 0)\n");
644
+	a.rotate(90*0.01745329251994329f, 0, 0);
645
+
646
+	if (a.mMatrix[i0] != 1 || a.mMatrix[i15] != 1 || 
647
+		 a.mMatrix[i9] != -1 || a.mMatrix[i6] != 1)
648
+	{
649
+			++errs;
650
+			printf(" \t[ Failed ]\a\n"); // beep
651
+			a.print();		
652
+	}
653
+
654
+	/* Cheap Y rotation test */
655
+	a.setIdentity();
656
+	printf("I -> Rotate (0, 90 degrees, 0)\n");
657
+	a.rotate(0, 90*0.01745329251994329f, 0);
658
+
659
+	if (a.mMatrix[i8] != 1 || a.mMatrix[i2] != -1 ||
660
+		 a.mMatrix[i15] != 1)
661
+	{
662
+			++errs;
663
+			printf(" \t[ Failed ]\a\n"); // beep
664
+			a.print();		
665
+	}
666
+
667
+	/* Cheap Z rotation test */
668
+	a.setIdentity();
669
+	printf("I -> Rotate (0, 0, 90 degrees)\n");
670
+	a.rotate(0, 0, 90*0.01745329251994329f);
671
+
672
+	if (a.mMatrix[i4] != -1 || a.mMatrix[i15] != 1 || 
673
+		 a.mMatrix[i1] != 1 || a.mMatrix[i10] != 1)
674
+	{
675
+			++errs;
676
+			printf(" \t[ Failed ]\a\n"); // beep
677
+			a.print();		
678
+	}
679
+
680
+	printf("\n%i errors\n", errs);
681
+	printf("\n");
682
+
683
+	printf("Prescision test...\n");
684
+	printf("I ->\n");
685
+	a.setIdentity();
686
+	printf(" -> Rotate (0, 0, 90 degrees)\n");
687
+	a.rotate(0, 0, 90*0.01745329251994329f);
688
+	printf(" -> Translate (10, 20, 30)\n");
689
+	a.translate(10, 20, 30);
690
+	printf(" -> scale (10, 10, 10)\n");
691
+	a.scale(10, 10, 10);
692
+	a.print();
693
+
694
+	printf("\n");
695
+
696
+	printf(" -> scale (0.1, 0.1, 0.1)\n");
697
+	a.scale(0.1, 0.1, 0.1);
698
+	printf(" -> Translate (-10, -20, -30)\n");
699
+	a.translate(-10, -20, -30);
700
+	printf(" -> Rotate (0, 0, -90 degrees)\n");
701
+	a.rotate(0, 0, -90*0.01745329251994329f);
702
+	a.print();	
703
+
704
+	printf("\n%i errors\n", errs);
705
+
706
+	return errs;
707
+}
708
+
709
+
710
+int main(int argc, char *argv[])
711
+{
712
+	if (argc > 2)
713
+	{
714
+		if (strcmp(argv[1], "-src") == 0)
715
+		{
716
+			generateMatrixSourceTest(argv[2][0]);
717
+			return 0;
718
+		}
719
+	}
720
+
721
+	printf("[Matrix class test]\n");
722
+	runMatrixUnitTest();
723
+
724
+	return 0;
725
+}
726
+#endif

+ 381
- 0
src/hel/Matrix.h 파일 보기

@@ -0,0 +1,381 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Freyja
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Matrix
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: 3d Matrix in class form
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------ 
17
+ *
18
+ * 2003.06.17:
19
+ * Mongoose - Now in column order to match OpenGL user needs,
20
+ *            use transpose() to get row order back  =)
21
+ *
22
+ * 2002.05.11:
23
+ * Mongoose - Created, based on my mtk3d matrix
24
+ ================================================================*/
25
+
26
+
27
+#ifndef GUARD__FREYJA_MONGOOSE_MATRIX_H_
28
+#define GUARD__FREYJA_MONGOOSE_MATRIX_H_
29
+
30
+
31
+#include <hel/math.h>
32
+#include <hel/Quaternion.h>
33
+#include <hel/Vector3d.h>
34
+
35
+	///////////////////////////////////////////////
36
+	// Multidim map for row order encoding       //
37
+	///////////////////////////////////////////////
38
+	// 0,0 - 0;   0,1 - 1;   0,2 - 2;   0,3 - 3  //
39
+	// 1,0 - 4;   1,1 - 5;   1,2 - 6;   1,3 - 7  //
40
+	// 2,0 - 8;   2,1 - 9;   2,2 - 10;  2,3 - 11 //
41
+	// 3,0 - 12;  3,1 - 13;  3,2 - 14;  3,3 - 15 //
42
+	///////////////////////////////////////////////
43
+
44
+	///////////////////////////////////////////////
45
+	// Multidim map for column order encoding    //
46
+	///////////////////////////////////////////////
47
+	// 0,0 - 0;   0,1 - 4;   0,2 - 8;   0,3 - 12 //
48
+	// 1,0 - 1;   1,1 - 5;   1,2 - 9;   1,3 - 13 //
49
+	// 2,0 - 2;   2,1 - 6;   2,2 - 10;  2,3 - 14 //
50
+	// 3,0 - 3;   3,1 - 7;   3,2 - 11;  3,3 - 15 //
51
+	///////////////////////////////////////////////
52
+
53
+
54
+class Matrix
55
+{
56
+ public:
57
+
58
+	////////////////////////////////////////////////////////////
59
+	// Constructors
60
+	////////////////////////////////////////////////////////////
61
+
62
+	Matrix();
63
+	/*------------------------------------------------------
64
+	 * Pre  : 
65
+	 * Post : Constructs an object of Matrix
66
+	 *
67
+	 *-- History ------------------------------------------
68
+	 *
69
+	 * 2002.05.11: 
70
+	 * Mongoose - Created
71
+	 ------------------------------------------------------*/
72
+
73
+	Matrix(matrix_t mat);
74
+	/*------------------------------------------------------
75
+	 * Pre  : 
76
+	 * Post : Constructs an object of Matrix
77
+	 *
78
+	 *-- History ------------------------------------------
79
+	 *
80
+	 * 2002.05.11: 
81
+	 * Mongoose - Created
82
+	 ------------------------------------------------------*/
83
+
84
+	Matrix(Quaternion &q);
85
+	/*------------------------------------------------------
86
+	 * Pre  : 
87
+	 * Post : Converts and asigns Q to a Matrix
88
+	 *        returns quaternion as Matrix
89
+	 *
90
+	 *-- History ------------------------------------------
91
+	 *
92
+	 * 2002.05.08:
93
+	 * Mongoose - Created
94
+	 ------------------------------------------------------*/
95
+
96
+	~Matrix();
97
+	/*------------------------------------------------------
98
+	 * Pre  : Matrix object is allocated
99
+	 * Post : Deconstructs an object of Matrix
100
+	 *
101
+	 *-- History ------------------------------------------
102
+	 *
103
+	 * 2002.05.11: 
104
+	 * Mongoose - Created
105
+	 ------------------------------------------------------*/
106
+
107
+	////////////////////////////////////////////////////////////
108
+	// Public Accessors
109
+	////////////////////////////////////////////////////////////
110
+
111
+	void getMatrix(matrix_t mat);
112
+	/*------------------------------------------------------
113
+	 * Pre  : 
114
+	 * Post : Returns this matrix copy
115
+	 *
116
+	 *-- History ------------------------------------------
117
+	 *
118
+	 * 2002.05.08:
119
+	 * Mongoose - Created
120
+	 ------------------------------------------------------*/
121
+
122
+	void getTransposeMatrix(matrix_t mat);
123
+	/*------------------------------------------------------
124
+	 * Pre  : 
125
+	 * Post : Returns this matrix transposed
126
+	 *
127
+	 *-- History ------------------------------------------
128
+	 *
129
+	 * 2002.05.08:
130
+	 * Mongoose - Created
131
+	 ------------------------------------------------------*/
132
+
133
+	bool getInvert(matrix_t mat);
134
+	/*------------------------------------------------------
135
+	 * Pre  : 
136
+	 * Post : Returns this matrix inverted
137
+	 *
138
+	 *-- History ------------------------------------------
139
+	 *
140
+	 * 2002.05.08:
141
+	 * Mongoose - Created
142
+	 ------------------------------------------------------*/
143
+
144
+	Matrix multiply(const Matrix &a, const Matrix &b);
145
+	/*------------------------------------------------------
146
+	 * Pre  : Multiplies 2 matrices
147
+	 * Post : Returns resultant matrix
148
+	 *
149
+	 *-- History ------------------------------------------
150
+	 *
151
+	 * 2002.05.08:
152
+	 * Mongoose - Created
153
+	 ------------------------------------------------------*/
154
+
155
+	void multiply4d(double *v, double *result);
156
+	/*------------------------------------------------------
157
+	 * Pre  : Multiplies <V> vector (double[4]) and <This> matrix
158
+	 *
159
+	 * Post : Returns <Result> vector, 
160
+	 *        <V> and <Result> maybe be the same vector
161
+	 *
162
+	 *-- History ------------------------------------------
163
+	 *
164
+	 * 2002.05.08:
165
+	 * Mongoose - Created
166
+	 ------------------------------------------------------*/
167
+
168
+	void multiply4v(vec4_t v, vec4_t result);
169
+	/*------------------------------------------------------
170
+	 * Pre  : Multiplies <V> vector and <This> matrix
171
+	 *
172
+	 * Post : Returns <Result> vector, 
173
+	 *        <V> and <Result> maybe be the same vector
174
+	 *
175
+	 *-- History ------------------------------------------
176
+	 *
177
+	 * 2002.05.08:
178
+	 * Mongoose - Created
179
+	 ------------------------------------------------------*/
180
+
181
+	void multiply3v(vec3_t v, vec3_t result);
182
+	/*------------------------------------------------------
183
+	 * Pre  : Multiplies <V> vector and <This> matrix
184
+	 *
185
+	 * Post : Returns <Result> vector, 
186
+	 *        <V> and <Result> maybe be the same vector
187
+	 *
188
+	 *-- History ------------------------------------------
189
+	 *
190
+	 * 2002.05.08:
191
+	 * Mongoose - Created
192
+	 ------------------------------------------------------*/
193
+
194
+	void print();
195
+	/*------------------------------------------------------
196
+	 * Pre  : 
197
+	 * Post : Prints matrix values to stdout
198
+	 *
199
+	 *-- History ------------------------------------------
200
+	 *
201
+	 * 2002.05.08:
202
+	 * Mongoose - Created
203
+	 ------------------------------------------------------*/
204
+
205
+	bool isIdentity();
206
+	/*------------------------------------------------------
207
+	 * Pre  : 
208
+	 * Post : Is this matrix the identity matrix?
209
+	 *
210
+	 *-- History ------------------------------------------
211
+	 *
212
+	 * 2002.05.08:
213
+	 * Mongoose - Created
214
+	 ------------------------------------------------------*/
215
+
216
+	Matrix operator *(const Matrix &a);
217
+	/*------------------------------------------------------
218
+	 * Pre  : Multiplies A and this matrices
219
+	 * Post : Returns resultant matrix
220
+	 *
221
+	 *-- History ------------------------------------------
222
+	 *
223
+	 * 2002.05.08:
224
+	 * Mongoose - Created
225
+	 ------------------------------------------------------*/
226
+
227
+	Vector3d operator *(Vector3d v);
228
+	/*------------------------------------------------------
229
+	 * Pre  : <V> is vector to multiply by this matrix
230
+	 * Post : Returns resultant vector ( mult )
231
+	 *
232
+	 *-- History ------------------------------------------
233
+	 *
234
+	 * 2002.05.08:
235
+	 * Mongoose - Created
236
+	 ------------------------------------------------------*/
237
+
238
+
239
+	////////////////////////////////////////////////////////////
240
+	// Public Mutators
241
+	////////////////////////////////////////////////////////////
242
+
243
+	void setIdentity();
244
+	/*------------------------------------------------------
245
+	 * Pre  : 
246
+	 * Post : Sets to identity matrix
247
+	 *
248
+	 *-- History ------------------------------------------
249
+	 *
250
+	 * 2002.05.08:
251
+	 * Mongoose - Created
252
+	 ------------------------------------------------------*/
253
+
254
+	void setMatrix(matrix_t mat);
255
+	/*------------------------------------------------------
256
+	 * Pre  : 
257
+	 * Post : Set the matrix ( dangerous, scary boo )
258
+	 *
259
+	 *-- History ------------------------------------------
260
+	 *
261
+	 * 2002.05.08:
262
+	 * Mongoose - Created
263
+	 ------------------------------------------------------*/
264
+
265
+	void rotate(vec_t x, vec_t y, vec_t z);
266
+	/*------------------------------------------------------
267
+	 * Pre  : Radian input
268
+	 * Post : Rotates object in 3 space
269
+	 *
270
+	 *-- History ------------------------------------------
271
+	 *
272
+	 * 2002.05.08:
273
+	 * Mongoose - Created
274
+	 ------------------------------------------------------*/
275
+
276
+	void rotate(const vec_t *xyz);
277
+	/*------------------------------------------------------
278
+	 * Pre  : Rotates object in 3 space, Radian input
279
+	 * Post : Returns true on sucess
280
+	 *
281
+	 *-- History ------------------------------------------
282
+	 *
283
+	 * 2002.05.08:
284
+	 * Mongoose - Created
285
+	 ------------------------------------------------------*/
286
+
287
+	void scale(vec_t x, vec_t y, vec_t z);
288
+	/*------------------------------------------------------
289
+	 * Pre  : 
290
+	 * Post : Scales object in 3 space
291
+	 *
292
+	 *-- History ------------------------------------------
293
+	 *
294
+	 * 2002.05.08:
295
+	 * Mongoose - Created
296
+	 ------------------------------------------------------*/
297
+
298
+	void scale(const vec_t *xyz);
299
+	/*------------------------------------------------------
300
+	 * Pre  : 
301
+	 * Post : Scales object in 3 space
302
+	 *
303
+	 *-- History ------------------------------------------
304
+	 *
305
+	 * 2002.05.08:
306
+	 * Mongoose - Created
307
+	 ------------------------------------------------------*/
308
+
309
+	void translate(vec_t x, vec_t y, vec_t z);
310
+	/*------------------------------------------------------
311
+	 * Pre  : 
312
+	 * Post : Translates ( moves ) object in 3 space
313
+	 *
314
+	 *-- History ------------------------------------------
315
+	 *
316
+	 * 2002.05.08:
317
+	 * Mongoose - Created
318
+	 ------------------------------------------------------*/
319
+
320
+	void translate(const vec_t *xyz);
321
+	/*------------------------------------------------------
322
+	 * Pre  : 
323
+	 * Post : Translates ( moves ) object in 3 space
324
+	 *
325
+	 *-- History ------------------------------------------
326
+	 *
327
+	 * 2002.05.08:
328
+	 * Mongoose - Created
329
+	 ------------------------------------------------------*/
330
+
331
+	void transpose();
332
+	/*------------------------------------------------------
333
+	 * Pre  : 
334
+	 * Post : Transpose this matrix
335
+	 *
336
+	 *-- History ------------------------------------------
337
+	 *
338
+	 * 2002.05.08:
339
+	 * Mongoose - Created
340
+	 ------------------------------------------------------*/
341
+
342
+	matrix_t mMatrix;      /* Data model, moved public for faster
343
+									  external renderer feedback use */
344
+
345
+ private:
346
+
347
+	////////////////////////////////////////////////////////////
348
+	// Private Accessors
349
+	////////////////////////////////////////////////////////////
350
+
351
+
352
+	////////////////////////////////////////////////////////////
353
+	// Private Mutators
354
+	////////////////////////////////////////////////////////////
355
+
356
+	void copy(matrix_t source, matrix_t dest);
357
+	/*------------------------------------------------------
358
+	 * Pre  : 
359
+	 * Post : Copys value of source to dest
360
+	 *
361
+	 *-- History ------------------------------------------
362
+	 *
363
+	 * 2002.05.08:
364
+	 * Mongoose - Created
365
+	 ------------------------------------------------------*/
366
+
367
+	void multiply(const matrix_t a, const matrix_t b, matrix_t result);
368
+	/*------------------------------------------------------
369
+	 * Pre  : Multiplies matrices a and b
370
+	 *        Neither a or b is also the result
371
+	 *
372
+	 * Post : Sets resultant matrix value ( result )
373
+	 *
374
+	 *-- History ------------------------------------------
375
+	 *
376
+	 * 2002.05.08:
377
+	 * Mongoose - Created
378
+	 ------------------------------------------------------*/
379
+};
380
+
381
+#endif

+ 121
- 0
src/hel/ParticleMass.h 파일 보기

@@ -0,0 +1,121 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Hel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Particle
9
+ * License : No use w/o permission (C) 2001-2003 Mongoose
10
+ * Comments: Partcle system's atomic base
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------ 
17
+ *
18
+ * 2003.06.02: 
19
+ * Mongoose - Now using Hel mass system
20
+ *
21
+ * 2001.08.13:
22
+ * Mongoose - Created
23
+ ================================================================*/
24
+
25
+
26
+#ifndef __HEL_MONGOOSE_PARTICLEMASS_H_
27
+#define __HEL_MONGOOSE_PARTICLEMASS_H_
28
+
29
+#include <hel/Mass.h>
30
+
31
+
32
+class ParticleMass
33
+{
34
+public:
35
+
36
+	////////////////////////////////////////////////////////////
37
+	// Constructors
38
+	////////////////////////////////////////////////////////////
39
+
40
+	ParticleMass();
41
+	/*------------------------------------------------------
42
+	 * Pre  : 
43
+	 * Post : Constructs an object of Particle
44
+	 *
45
+	 *-- History ------------------------------------------
46
+	 *
47
+	 * 2001.08.13: 
48
+	 * Mongoose - Created
49
+	 ------------------------------------------------------*/
50
+
51
+	~ParticleMass();
52
+	/*------------------------------------------------------
53
+	 * Pre  : Particle object is allocated
54
+	 * Post : Deconstructs an object of Particle
55
+	 *
56
+	 *-- History ------------------------------------------
57
+	 *
58
+	 * 2001.08.13: 
59
+	 * Mongoose - Created
60
+	 ------------------------------------------------------*/
61
+
62
+	void simulate(vec_t timeDelta)
63
+	{
64
+	/*------------------------------------------------------
65
+	 * Pre  : 
66
+	 * Post : Ajusts for particle life cycle
67
+	 *
68
+	 *-- History ------------------------------------------
69
+	 *
70
+	 * 2001.08.13: 
71
+	 * Mongoose - Created
72
+	 ------------------------------------------------------*/
73
+
74
+		mLife -= mBlend * timeDelta;
75
+		
76
+		// Reset 'dead' OR fully blended particles
77
+		if (mLife < 0.0)
78
+		{
79
+			mLife = 1.0;
80
+		}
81
+
82
+		mMass->simulate(timeDelta);
83
+	}
84
+
85
+
86
+	////////////////////////////////////////////////////////////
87
+	// Public Accessors
88
+	////////////////////////////////////////////////////////////
89
+
90
+
91
+
92
+	////////////////////////////////////////////////////////////
93
+	// Public Mutators
94
+	////////////////////////////////////////////////////////////
95
+
96
+	Mass *mMass;				/* Particle mass */
97
+
98
+	bool mActive;           /* Is this particle in use? */
99
+	
100
+	int mTextureId;         /* Texture Id to use on polygon */	
101
+	
102
+	vec_t mLife;            /* Life of particle  */
103
+	
104
+	vec_t mBlend;           /* Blend amount or fade per sec */
105
+
106
+	vec3_t mColor;          /* Current color */
107
+
108
+private:
109
+
110
+	////////////////////////////////////////////////////////////
111
+	// Private Accessors
112
+	////////////////////////////////////////////////////////////
113
+
114
+
115
+	////////////////////////////////////////////////////////////
116
+	// Private Mutators
117
+	////////////////////////////////////////////////////////////
118
+
119
+};
120
+
121
+#endif

+ 425
- 0
src/hel/Quaternion.cpp 파일 보기

@@ -0,0 +1,425 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Hel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Quaternion
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: Quaternion now in C++ class form fresh from the grove
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2002.12.16:
19
+ * Mongoose - Created, based on mtk3d ( freyja )
20
+ =================================================================*/
21
+
22
+#include <math.h>
23
+#include "Quaternion.h"
24
+
25
+
26
+////////////////////////////////////////////////////////////
27
+// Constructors
28
+////////////////////////////////////////////////////////////
29
+
30
+Quaternion::Quaternion()
31
+{
32
+	mW = 0;
33
+	mX = 0;
34
+	mY = 0;
35
+	mZ = 0;
36
+}
37
+
38
+
39
+Quaternion::Quaternion(vec_t w, vec_t x, vec_t y, vec_t z)
40
+{
41
+	mW = w;
42
+	mX = x;
43
+	mY = y;
44
+	mZ = z;
45
+}
46
+
47
+
48
+Quaternion::Quaternion(vec4_t v)
49
+{
50
+	mW = v[0];
51
+	mX = v[1];
52
+	mY = v[2];
53
+	mZ = v[3];
54
+}
55
+
56
+
57
+Quaternion::~Quaternion()
58
+{
59
+}
60
+
61
+
62
+////////////////////////////////////////////////////////////
63
+// Public Accessors
64
+////////////////////////////////////////////////////////////
65
+
66
+void Quaternion::getMatrix(matrix_t m)
67
+{
68
+	m[ 0] = 1.0f - 2.0f * (mY*mY + mZ*mZ);
69
+	m[ 1] = 2.0f * (mX*mY - mW*mZ);
70
+	m[ 2] = 2.0f * (mX*mZ + mW*mY);
71
+	m[ 3] = 0.0f;
72
+	
73
+	m[ 4] = 2.0f * (mX*mY + mW*mZ);
74
+	m[ 5] = 1.0f - 2.0f * (mX*mX + mZ*mZ);
75
+	m[ 6] = 2.0f * (mY*mZ - mW*mX);
76
+	m[ 7] = 0.0f;
77
+	
78
+	m[ 8] = 2.0f * (mX*mZ - mW*mY);
79
+	m[ 9] = 2.0f * (mY*mZ + mW*mX);
80
+	m[10] = 1.0 - 2.0f * (mX*mX + mY*mY);
81
+	m[11] = 0.0f;
82
+	
83
+	m[12] = 0.0f;
84
+	m[13] = 0.0f;
85
+	m[14] = 0.0f;
86
+	m[15] = 1.0f;
87
+}
88
+
89
+
90
+Quaternion Quaternion::operator =(const Quaternion &q)
91
+{
92
+	mW	= q.mW;
93
+	mX = q.mX;
94
+	mY = q.mY;
95
+	mZ = q.mZ;
96
+  
97
+  return (*this);
98
+}
99
+
100
+
101
+Quaternion Quaternion::operator *(const Quaternion &q)
102
+{
103
+	return multiply(*this, q);
104
+}
105
+
106
+
107
+Quaternion Quaternion::operator /(const Quaternion &q)
108
+{
109
+	return divide(*this, q);
110
+}
111
+
112
+
113
+Quaternion Quaternion::operator +(const Quaternion &q)
114
+{
115
+	return add(*this, q);
116
+}
117
+
118
+
119
+Quaternion Quaternion::operator -(const Quaternion &q)
120
+{
121
+	return subtract(*this, q);
122
+}
123
+
124
+
125
+bool Quaternion::operator ==(const Quaternion &q)
126
+{
127
+	return (mX == q.mX && mY == q.mY && mZ == q.mZ && mW == q.mW);
128
+}
129
+
130
+
131
+Quaternion Quaternion::conjugate()
132
+{
133
+	return Quaternion(mW, -mX, -mY, -mZ);
134
+}
135
+
136
+
137
+Quaternion Quaternion::scale(vec_t s)
138
+{
139
+   return Quaternion(mW * s, mX * s, mY * s, mZ * s);
140
+}
141
+
142
+
143
+Quaternion Quaternion::inverse()
144
+{
145
+	return conjugate().scale(1/magnitude());
146
+}
147
+
148
+
149
+vec_t Quaternion::dot(Quaternion a, Quaternion b)
150
+{
151
+	return ((a.mW * b.mW) + (a.mX * b.mX) + (a.mY * b.mY) + (a.mZ * b.mZ));
152
+}
153
+
154
+
155
+vec_t Quaternion::magnitude()
156
+{
157
+	return sqrt(dot(*this, *this));
158
+}
159
+
160
+
161
+////////////////////////////////////////////////////////////
162
+// Public Mutators
163
+////////////////////////////////////////////////////////////
164
+
165
+void Quaternion::setIdentity()
166
+{
167
+	mW = 1.0;
168
+	mX = 0.0;
169
+	mY = 0.0;
170
+	mZ = 0.0;
171
+}
172
+
173
+
174
+void Quaternion::set(vec_t angle, vec_t x, vec_t y, vec_t z)
175
+{
176
+	vec_t temp, dist;
177
+
178
+	
179
+	// Normalize
180
+	temp = x*x + y*y + z*z;
181
+	
182
+	dist = (float)(1.0 / sqrt(temp));
183
+	
184
+	x *= dist;
185
+	y *= dist;
186
+	z *= dist;
187
+	
188
+	mX = x;
189
+	mY = y;
190
+	mZ = z;
191
+	
192
+	mW = (float)cos(angle / 2.0f);	
193
+}
194
+
195
+
196
+void Quaternion::normalize()
197
+{
198
+	vec_t dist, square;
199
+
200
+
201
+	square = mX * mX + mY * mY + mZ * mZ + mW * mW;
202
+	
203
+	if (square > 0.0)
204
+	{
205
+		dist = (float)(1.0 / sqrt(square));
206
+	}
207
+	else 
208
+	{
209
+		dist = 1;
210
+	}
211
+
212
+	mX *= dist;
213
+	mY *= dist;
214
+	mZ *= dist;
215
+	mW *= dist; 
216
+}
217
+
218
+
219
+void Quaternion::copy(Quaternion q)
220
+{
221
+	mW = q.mW;
222
+	mX = q.mX;
223
+	mY = q.mY;
224
+	mZ = q.mZ;
225
+}
226
+
227
+
228
+Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time)
229
+{
230
+	/*******************************************************************
231
+	 * Spherical Linear Interpolation algorthim
232
+	 *-----------------------------------------------------------------
233
+	 *
234
+	 * Interpolate between A and B rotations ( Find qI )
235
+	 *
236
+	 * qI = (((qB . qA)^ -1)^ Time) qA
237
+	 *
238
+	 * http://www.magic-software.com/Documentation/quat.pdf
239
+	 *
240
+	 * Thanks to digiben for algorithms and basis of the notes in 
241
+	 * this func
242
+	 *
243
+	 *******************************************************************/
244
+
245
+	vec_t result, scaleA, scaleB, theta, sinTheta;
246
+	Quaternion i;
247
+
248
+
249
+	// Don't bother if it's the same rotation, it's the same as the result
250
+	if (a == b) 
251
+	{
252
+		return a;
253
+	}
254
+
255
+	// A . B 
256
+	result = dot(a, b);
257
+  
258
+	// If the dot product is less than 0, the angle is greater than 90 degrees
259
+	if (result < 0.0f)
260
+	{
261
+		// Negate quaternion B and the result of the dot product
262
+		b = Quaternion(-b.mW, -b.mX, -b.mY, -b.mZ);
263
+		result = -result;
264
+	}
265
+
266
+	// Set the first and second scale for the interpolation
267
+	scaleA = 1 - time;
268
+	scaleB = time;
269
+
270
+	// Next, we want to actually calculate the spherical interpolation.  Since this
271
+	// calculation is quite computationally expensive, we want to only perform it
272
+	// if the angle between the 2 quaternions is large enough to warrant it.  If the
273
+	// angle is fairly small, we can actually just do a simpler linear interpolation
274
+	// of the 2 quaternions, and skip all the complex math.  We create a "delta" value
275
+	// of 0.1 to say that if the cosine of the angle (result of the dot product) between
276
+	// the 2 quaternions is smaller than 0.1, then we do NOT want to perform the full on 
277
+	// interpolation using.  This is because you won't really notice the difference.
278
+	
279
+	// Check if the angle between the 2 quaternions was big enough 
280
+	// to warrant such calculations
281
+	if (1 - result > 0.1f)
282
+	{
283
+		// Get the angle between the 2 quaternions, and then
284
+		// store the sin() of that angle
285
+		theta = (float)acos(result);
286
+		sinTheta = (float)sin(theta);
287
+
288
+		// Calculate the scale for qA and qB, according to
289
+		// the angle and it's sine value
290
+		scaleA = (float)sin((1 - time) * theta) / sinTheta;
291
+		scaleB = (float)sin((time * theta)) / sinTheta;
292
+	}	
293
+
294
+	// Calculate the x, y, z and w values for the quaternion by using a special
295
+	// form of linear interpolation for quaternions.
296
+	return (a.scale(scaleA) + b.scale(scaleB));
297
+}
298
+
299
+
300
+void Quaternion::setByMatrix(matrix_t matrix)
301
+{   
302
+	float diagonal = matrix[0] + matrix[5] + matrix[10] + 1.0f;
303
+	float scale = 0.0f;
304
+	float w = 0.0f, x = 0.0f, y = 0.0f, z = 0.0f;
305
+	
306
+	
307
+	if (diagonal > 0.00000001)
308
+	{
309
+		// Calculate the scale of the diagonal
310
+		scale = (float)(sqrt(diagonal) * 2);
311
+		
312
+		w = 0.25f * scale;
313
+		x = (matrix[9] - matrix[6]) / scale;
314
+		y = (matrix[2] - matrix[8]) / scale;
315
+		z = (matrix[4] - matrix[1]) / scale;
316
+	}
317
+	else 
318
+	{
319
+		 // If the first element of the diagonal is the greatest value
320
+		if (matrix[0] > matrix[5] && matrix[0] > matrix[10])
321
+		{   
322
+			 // Find the scale according to the first element, and double it
323
+			scale = (float)sqrt(1.0f + matrix[0] - matrix[5] - matrix[10])*2.0f;
324
+			
325
+			// Calculate the quaternion
326
+			w = (matrix[9] - matrix[6]) / scale; 
327
+			x = 0.25f * scale;
328
+			y = (matrix[4] + matrix[1]) / scale;
329
+			z = (matrix[2] + matrix[8]) / scale;
330
+		} 
331
+		// The second element of the diagonal is the greatest value
332
+		else if (matrix[5] > matrix[10]) 
333
+		{
334
+			// Find the scale according to the second element, and double it
335
+			scale = (float)sqrt(1.0f + matrix[5] - matrix[0] - matrix[10])*2.0f;
336
+			
337
+			// Calculate the quaternion 
338
+			w = (matrix[2] - matrix[8]) / scale;
339
+			x = (matrix[4] + matrix[1]) / scale;
340
+			y = 0.25f * scale;
341
+			z = (matrix[9] + matrix[6]) / scale;
342
+		} 
343
+		// The third element of the diagonal is the greatest value
344
+		else 
345
+		{   
346
+			// Find the scale according to the third element, and double it
347
+			scale = (float)sqrt(1.0f + matrix[10] - matrix[0] - matrix[5])*2.0f;
348
+			
349
+			// Calculate the quaternion
350
+			w = (matrix[4] - matrix[1]) / scale;
351
+			x = (matrix[2] + matrix[8]) / scale;
352
+			y = (matrix[9] + matrix[6]) / scale;
353
+			z = 0.25f * scale;
354
+		}
355
+	}
356
+
357
+	mW = w;
358
+	mX = x;
359
+	mY = y;
360
+	mZ = z;
361
+}
362
+
363
+
364
+////////////////////////////////////////////////////////////
365
+// Private Accessors
366
+////////////////////////////////////////////////////////////
367
+
368
+Quaternion Quaternion::multiply(Quaternion a, Quaternion b)
369
+{
370
+	return Quaternion(a.mW * b.mW - a.mX * b.mX - a.mY * b.mY - a.mZ * b.mZ,
371
+							a.mW * b.mX + a.mX * b.mW + a.mY * b.mZ - a.mZ * b.mY,
372
+							a.mW * b.mY + a.mY * b.mW + a.mZ * b.mX - a.mX * b.mZ,
373
+							a.mW * b.mZ + a.mZ * b.mW + a.mX * b.mY - a.mY * b.mX);
374
+}
375
+
376
+
377
+Quaternion Quaternion::divide(Quaternion a, Quaternion b)
378
+{
379
+	return (a * (b.inverse()));
380
+}
381
+
382
+
383
+Quaternion Quaternion::add(Quaternion a, Quaternion b)
384
+{
385
+	return Quaternion(a.mW + b.mW,
386
+							a.mX + b.mX,
387
+							a.mY + b.mY,
388
+							a.mZ + b.mZ);
389
+}
390
+
391
+
392
+Quaternion Quaternion::subtract(Quaternion a, Quaternion b)
393
+{
394
+	return Quaternion(a.mW - b.mW,
395
+							a.mX - b.mX,
396
+							a.mY - b.mY,
397
+							a.mZ - b.mZ);
398
+}
399
+
400
+
401
+////////////////////////////////////////////////////////////
402
+// Private Mutators
403
+////////////////////////////////////////////////////////////
404
+
405
+
406
+////////////////////////////////////////////////////////////
407
+// Unit Test code
408
+////////////////////////////////////////////////////////////
409
+
410
+#ifdef UNIT_TEST_QUATERNION
411
+int runQuaternionUnitTest(int argc, char *argv[])
412
+{
413
+	return 0;
414
+}
415
+
416
+
417
+int main(int argc, char *argv[])
418
+{
419
+	printf("[Quaternion class test]\n");
420
+
421
+	runQuaternionUnitTest(argc, argv);
422
+
423
+	return 0;
424
+}
425
+#endif

+ 366
- 0
src/hel/Quaternion.h 파일 보기

@@ -0,0 +1,366 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Hel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Quaternion
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: Quaternion now in C++ class form fresh from the grove
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- Test Defines -----------------------------------------------
17
+ *           
18
+ * UNIT_TEST_QUATERNION - Builds Quaternion class as a console unit test 
19
+ *
20
+ *-- History ------------------------------------------------ 
21
+ *
22
+ * 2002.12.16:
23
+ * Mongoose - Created, based on mtk3d ( freyja )
24
+ ================================================================*/
25
+
26
+
27
+#ifndef GUARD__HEL_MONGOOSE_QUATERNION_H_
28
+#define GUARD__HEL_MONGOOSE_QUATERNION_H_
29
+
30
+#include <hel/math.h>
31
+//#include <hel/Matrix.h>
32
+
33
+class Quaternion
34
+{
35
+ public:
36
+
37
+	////////////////////////////////////////////////////////////
38
+	// Constructors
39
+	////////////////////////////////////////////////////////////
40
+
41
+	Quaternion();
42
+	/*------------------------------------------------------
43
+	 * Pre  : 
44
+	 * Post : Constructs an object of Quaternion
45
+	 *
46
+	 *-- History ------------------------------------------
47
+	 *
48
+	 * 2002.12.16: 
49
+	 * Mongoose - Created
50
+	 ------------------------------------------------------*/
51
+
52
+	Quaternion(vec_t w, vec_t x, vec_t y, vec_t z);
53
+	/*------------------------------------------------------
54
+	 * Pre  : 
55
+	 * Post : Constructs an object of Quaternion
56
+	 *
57
+	 *-- History ------------------------------------------
58
+	 *
59
+	 * 2002.12.16: 
60
+	 * Mongoose - Created
61
+	 ------------------------------------------------------*/
62
+
63
+	Quaternion(vec4_t v);
64
+	/*------------------------------------------------------
65
+	 * Pre  : v { w, x, y, z }
66
+	 * Post : Constructs an object of Quaternion
67
+	 *
68
+	 *-- History ------------------------------------------
69
+	 *
70
+	 * 2002.12.16: 
71
+	 * Mongoose - Created
72
+	 ------------------------------------------------------*/
73
+
74
+	~Quaternion();
75
+	/*------------------------------------------------------
76
+	 * Pre  : Quaternion object is allocated
77
+	 * Post : Deconstructs an object of Quaternion
78
+	 *
79
+	 *-- History ------------------------------------------
80
+	 *
81
+	 * 2002.12.16: 
82
+	 * Mongoose - Created
83
+	 ------------------------------------------------------*/
84
+
85
+
86
+	////////////////////////////////////////////////////////////
87
+	// Public Accessors
88
+	////////////////////////////////////////////////////////////
89
+
90
+	void getMatrix(matrix_t m);
91
+	/*------------------------------------------------------
92
+	 * Pre  : Matrix is valid
93
+	 * Post : Returns col order matrix equiv of this quaternion
94
+	 *
95
+	 *-- History ------------------------------------------
96
+	 *
97
+	 * 2002.05.08:
98
+	 * Mongoose - Created
99
+	 ------------------------------------------------------*/
100
+
101
+	Quaternion operator =(const Quaternion &q);
102
+	/*------------------------------------------------------
103
+	 * Pre  : 
104
+	 * Post : Asigns Q to this quaternion
105
+	 *        returns (this) resultant quaternion
106
+	 *
107
+	 *-- History ------------------------------------------
108
+	 *
109
+	 * 2002.05.08:
110
+	 * Mongoose - Created
111
+	 ------------------------------------------------------*/
112
+
113
+	Quaternion operator *(const Quaternion &q);
114
+	/*------------------------------------------------------
115
+	 * Pre  : 
116
+	 * Post : Multiplies Q and this quaternion
117
+	 *        returns resultant quaternion
118
+	 *        ( Use normalize() call for unit quaternion )
119
+	 *
120
+	 *-- History ------------------------------------------
121
+	 *
122
+	 * 2002.05.08:
123
+	 * Mongoose - Created
124
+	 ------------------------------------------------------*/
125
+
126
+	Quaternion operator /(const Quaternion &q);
127
+	/*------------------------------------------------------
128
+	 * Pre  : 
129
+	 * Post : Dividess Q from this quaternion
130
+	 *        returns quotient quaternion
131
+	 *
132
+	 *-- History ------------------------------------------
133
+	 *
134
+	 * 2002.05.08:
135
+	 * Mongoose - Created
136
+	 ------------------------------------------------------*/
137
+
138
+	Quaternion operator +(const Quaternion &q);
139
+	/*------------------------------------------------------
140
+	 * Pre  : 
141
+	 * Post : Adds Q and this quaternion
142
+	 *        returns resultant quaternion
143
+	 *
144
+	 *-- History ------------------------------------------
145
+	 *
146
+	 * 2002.05.08:
147
+	 * Mongoose - Created
148
+	 ------------------------------------------------------*/
149
+
150
+	Quaternion operator -(const Quaternion &q);
151
+	/*------------------------------------------------------
152
+	 * Pre  : 
153
+	 * Post : Subtracts Q from this quaternion
154
+	 *        returns resultant quaternion
155
+	 *
156
+	 *-- History ------------------------------------------
157
+	 *
158
+	 * 2002.05.08:
159
+	 * Mongoose - Created
160
+	 ------------------------------------------------------*/
161
+
162
+	bool operator ==(const Quaternion &q);
163
+	/*------------------------------------------------------
164
+	 * Pre  : 
165
+	 * Post : Compares Q to this quaternion
166
+	 *        returns boolean true if equal, otherwise false
167
+	 *
168
+	 *-- History ------------------------------------------
169
+	 *
170
+	 * 2002.05.08:
171
+	 * Mongoose - Created
172
+	 ------------------------------------------------------*/
173
+
174
+	Quaternion conjugate();
175
+	/*------------------------------------------------------
176
+	 * Pre  : 
177
+	 * Post : Returns conjugate of this quaternion
178
+	 *
179
+	 *-- History ------------------------------------------
180
+	 *
181
+	 * 2002.05.08:
182
+	 * Mongoose - Created
183
+	 ------------------------------------------------------*/
184
+
185
+	Quaternion scale(vec_t s);
186
+	/*------------------------------------------------------
187
+	 * Pre  : 
188
+	 * Post : Returns scaled result of this quaternion
189
+	 *
190
+	 *-- History ------------------------------------------
191
+	 *
192
+	 * 2002.05.08:
193
+	 * Mongoose - Created
194
+	 ------------------------------------------------------*/
195
+
196
+	Quaternion inverse();
197
+	/*------------------------------------------------------
198
+	 * Pre  : 
199
+	 * Post : Returns inverse of this quaternion
200
+	 *
201
+	 *-- History ------------------------------------------
202
+	 *
203
+	 * 2002.05.08:
204
+	 * Mongoose - Created
205
+	 ------------------------------------------------------*/
206
+
207
+	static vec_t dot(Quaternion a, Quaternion b);
208
+	/*------------------------------------------------------
209
+	 * Pre  : 
210
+	 * Post : Returns dot product of A and B quaternions
211
+	 *
212
+	 *-- History ------------------------------------------
213
+	 *
214
+	 * 2002.05.08:
215
+	 * Mongoose - Created
216
+	 ------------------------------------------------------*/
217
+
218
+	vec_t magnitude();
219
+	/*------------------------------------------------------
220
+	 * Pre  : 
221
+	 * Post : Returns magnitude this quaternion
222
+	 *
223
+	 *-- History ------------------------------------------
224
+	 *
225
+	 * 2002.05.08:
226
+	 * Mongoose - Created
227
+	 ------------------------------------------------------*/
228
+
229
+	static Quaternion slerp(Quaternion a, Quaternion b, vec_t time);
230
+	/*------------------------------------------------------
231
+	 * Pre  : 
232
+	 * Post : Interpolates between A and B rotations and
233
+	 *        returns resultant quaternion using
234
+	 *        spherical linear interpolation:
235
+	 *
236
+	 *        I = (((B . A)^ -1)^ Time) A
237
+	 *
238
+	 *-- History ------------------------------------------
239
+	 *
240
+	 * 2002.05.08:
241
+	 * Mongoose - Created
242
+	 ------------------------------------------------------*/
243
+
244
+
245
+	////////////////////////////////////////////////////////////
246
+	// Public Mutators
247
+	////////////////////////////////////////////////////////////
248
+
249
+	void setIdentity();
250
+	/*------------------------------------------------------
251
+	 * Pre  : 
252
+	 * Post : Sets this quaternion to identity
253
+	 *
254
+	 *-- History ------------------------------------------
255
+	 *
256
+	 * 2002.05.08:
257
+	 * Mongoose - Created
258
+	 ------------------------------------------------------*/
259
+
260
+	void set(vec_t angle, vec_t x, vec_t y, vec_t z);
261
+	/*------------------------------------------------------
262
+	 * Pre  : 
263
+	 * Post : Sets this quaternion
264
+	 *
265
+	 *-- History ------------------------------------------
266
+	 *
267
+	 * 2002.05.08:
268
+	 * Mongoose - Created
269
+	 ------------------------------------------------------*/
270
+
271
+	void normalize();
272
+	/*------------------------------------------------------
273
+	 * Pre  : 
274
+	 * Post : Normalize this quaternion
275
+	 *
276
+	 *-- History ------------------------------------------
277
+	 *
278
+	 * 2002.05.08:
279
+	 * Mongoose - Created
280
+	 ------------------------------------------------------*/
281
+
282
+	void copy(Quaternion q);
283
+	/*------------------------------------------------------
284
+	 * Pre  : 
285
+	 * Post : Set this quaternion using q
286
+	 *
287
+	 *-- History ------------------------------------------
288
+	 *
289
+	 * 2002.05.08:
290
+	 * Mongoose - Created
291
+	 ------------------------------------------------------*/
292
+
293
+	void setByMatrix(matrix_t m);
294
+	/*------------------------------------------------------
295
+	 * Pre  : Matrix is valid column order
296
+	 * Post : Sets matrix equiv of this quaternion
297
+	 *
298
+	 *-- History ------------------------------------------
299
+	 *
300
+	 * 2002.05.08:
301
+	 * Mongoose - Created
302
+	 ------------------------------------------------------*/
303
+
304
+
305
+ private:
306
+
307
+	////////////////////////////////////////////////////////////
308
+	// Private Accessors
309
+	////////////////////////////////////////////////////////////
310
+
311
+	Quaternion multiply(Quaternion a, Quaternion b);
312
+	/*------------------------------------------------------
313
+	 * Pre  : 
314
+	 * Post : Multiplies A and B quaternions
315
+	 *        returns resultant quaternion
316
+	 *
317
+	 *-- History ------------------------------------------
318
+	 *
319
+	 * 2002.05.08:
320
+	 * Mongoose - Created
321
+	 ------------------------------------------------------*/
322
+
323
+	Quaternion divide(Quaternion a, Quaternion b);
324
+	/*------------------------------------------------------
325
+	 * Pre  : 
326
+	 * Post : Divides B from A quaternion
327
+	 *        returns quotient quaternion
328
+	 *
329
+	 *-- History ------------------------------------------
330
+	 *
331
+	 * 2002.05.08:
332
+	 * Mongoose - Created
333
+	 ------------------------------------------------------*/
334
+
335
+	Quaternion add(Quaternion a, Quaternion b);
336
+	/*------------------------------------------------------
337
+	 * Pre  : 
338
+	 * Post : Adds A and B quaternions
339
+	 *        returns resultant quaternion
340
+	 *
341
+	 *-- History ------------------------------------------
342
+	 *
343
+	 * 2002.05.08:
344
+	 * Mongoose - Created
345
+	 ------------------------------------------------------*/
346
+
347
+	Quaternion subtract(Quaternion a, Quaternion b);
348
+	/*------------------------------------------------------
349
+	 * Pre  : 
350
+	 * Post : Subtracts B from A quaternion
351
+	 *        returns resultant quaternion
352
+	 *
353
+	 *-- History ------------------------------------------
354
+	 *
355
+	 * 2002.05.08:
356
+	 * Mongoose - Created
357
+	 ------------------------------------------------------*/
358
+
359
+	////////////////////////////////////////////////////////////
360
+	// Private Mutators
361
+	////////////////////////////////////////////////////////////
362
+
363
+	vec_t mW, mX, mY, mZ;          /* Quaternion */
364
+};
365
+
366
+#endif

+ 452
- 0
src/hel/Simulation.cpp 파일 보기

@@ -0,0 +1,452 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Hel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Simulation
9
+ * License : No use w/o permission (C) 2003 Mongoose
10
+ * Comments: This class simulates mass physics
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2003.06.02:
19
+ * Mongoose - Created, based on algorithms from Erkin Tunca
20
+ =================================================================*/
21
+
22
+#include "Simulation.h"
23
+
24
+
25
+////////////////////////////////////////////////////////////
26
+// Constructors
27
+////////////////////////////////////////////////////////////
28
+
29
+Simulation::Simulation()
30
+{
31
+	mMassCount = 0;
32
+}
33
+
34
+
35
+Simulation::~Simulation()
36
+{
37
+	clear();
38
+}
39
+
40
+
41
+////////////////////////////////////////////////////////////
42
+// Public Accessors
43
+////////////////////////////////////////////////////////////
44
+
45
+Mass *Simulation::getMass(unsigned int i)
46
+{
47
+	return mMasses[i];
48
+}
49
+
50
+
51
+////////////////////////////////////////////////////////////
52
+// Public Mutators
53
+////////////////////////////////////////////////////////////
54
+
55
+void Simulation::attachCollisionObject(CollisionObject *obj)
56
+{
57
+	mObjects.pushBack(obj);
58
+}
59
+
60
+
61
+void Simulation::clear()
62
+{
63
+	mMasses.erase();
64
+}
65
+
66
+
67
+bool Simulation::collisionDetected(Mass *mass)
68
+{
69
+	bool detected = false;
70
+
71
+	for (mObjects.start(); mObjects.forward(); mObjects.next())
72
+	{
73
+		if ((mObjects.current())->intersectPoint(mass->mPos))
74
+		{
75
+			detected = true; 
76
+			resolveCollision(mass, mObjects.current());
77
+		}
78
+	}
79
+
80
+	return detected;
81
+}
82
+
83
+
84
+void Simulation::generateMasses(unsigned int count, vec_t mass)
85
+{
86
+	generateMasses(count, mass, Vector3d(0, 0, 0), Vector3d(0, 0, 0));
87
+}
88
+
89
+
90
+void Simulation::generateMasses(unsigned int count, vec_t mass,
91
+										  const Vector3d &position, 
92
+										  const Vector3d &velocity)
93
+{
94
+	unsigned int i;
95
+
96
+
97
+	mMassCount = count;
98
+	//mMasses.reserve(mMasses.size() + count);
99
+
100
+	for (i = 0; i < count; ++i)
101
+	{
102
+		mMasses.pushBack(new Mass(mass, position, velocity));
103
+	}
104
+}
105
+
106
+
107
+void Simulation::init()
108
+{
109
+	Mass *m;
110
+
111
+	for (mMasses.start(); mMasses.forward(); mMasses.next())
112
+	{
113
+		m = mMasses.current();
114
+
115
+		if (!m)
116
+			continue;
117
+
118
+		m->rest();
119
+	}
120
+}
121
+
122
+
123
+void Simulation::resolveCollision(Mass *mass, CollisionObject *obj)
124
+{
125
+	mass->mPos = obj->mIntersection;
126
+}
127
+
128
+
129
+void Simulation::run(vec_t timeDelta)
130
+{
131
+	// Reset forces
132
+	init();
133
+
134
+	// Apply external forces
135
+	solve();
136
+
137
+	// Update change in time
138
+	simulate(timeDelta);
139
+}
140
+
141
+
142
+void Simulation::simulate(vec_t timeDelta)
143
+{
144
+	Mass *m;
145
+
146
+	for (mMasses.start(); mMasses.forward(); mMasses.next())
147
+	{
148
+		m = mMasses.current();
149
+
150
+		if (!m)
151
+			continue;
152
+
153
+		m->simulate(timeDelta);
154
+	}
155
+}
156
+
157
+
158
+void Simulation::solve()
159
+{
160
+}
161
+
162
+
163
+////////////////////////////////////////////////////////////
164
+// Private Accessors
165
+////////////////////////////////////////////////////////////
166
+
167
+
168
+////////////////////////////////////////////////////////////
169
+// Private Mutators
170
+////////////////////////////////////////////////////////////
171
+
172
+
173
+////////////////////////////////////////////////////////////
174
+// Unit Test code
175
+////////////////////////////////////////////////////////////
176
+
177
+#ifdef UNIT_TEST_SIMULATION
178
+
179
+#define SDL_UNIT_TEST
180
+#include "SDLUnitTest.cpp"
181
+
182
+Simulation *gEmitter;
183
+GravitySimulation gGravityEmitter;
184
+SpringSimulation gSpringEmitter;
185
+SpringSimulation gSpringEmitter2;
186
+bool gOn = false;
187
+float gSpeed = 0.1f;
188
+
189
+
190
+// Draw particles
191
+#define ENABLE_TEX_PARTICLES
192
+void renderScene(float time, float lastTime)
193
+{
194
+	Mass *m;
195
+	Vector3d last;
196
+	vec_t x, y, z;
197
+
198
+	glBindTexture(GL_TEXTURE_2D, 1);
199
+
200
+	if (gOn)
201
+		gEmitter->run((time - lastTime) * 0.1 * gSpeed); // slow it down
202
+
203
+#ifdef ENABLE_TEX_PARTICLES
204
+	// Alpha is determined by life, which is affected by blend amount
205
+	//glColor4f(mColor, g, b, life);
206
+
207
+	// Render tristrip quad
208
+	for (gEmitter->mMasses.start(); gEmitter->mMasses.forward(); 
209
+		  gEmitter->mMasses.next())
210
+	{
211
+		m = gEmitter->mMasses.current();
212
+
213
+		if (!m)
214
+			continue;
215
+
216
+		if (gEmitter == &gSpringEmitter)
217
+		{
218
+			if (gEmitter->mMasses.getCurrentIndex() == 0)
219
+			{
220
+				glDisable(GL_TEXTURE_2D);
221
+
222
+				glColor4f(0.0, 1.0, 0.0, 1.0);
223
+				glBegin(GL_POINTS);
224
+				glVertex3fv(gSpringEmitter.connectionPos.mVec);
225
+				glEnd();
226
+			}
227
+
228
+			glColor4f(gEmitter->mMasses.getCurrentIndex()*0.33, 0.0, 1.0, 1.0);
229
+			glBegin(GL_POINTS);
230
+			glVertex3fv(m->mPos.mVec);
231
+			glEnd();
232
+			glBegin(GL_LINES);
233
+			glVertex3fv(m->mPos.mVec);
234
+			glVertex3fv(gSpringEmitter.connectionPos.mVec);
235
+			glEnd();
236
+		}
237
+		else
238
+		{
239
+			x = m->mPos.mVec[0];
240
+			y = m->mPos.mVec[1];
241
+			z = m->mPos.mVec[2];
242
+
243
+			glBegin(GL_TRIANGLE_STRIP);
244
+			
245
+			glTexCoord2d(1.0, 1.0);
246
+			glVertex3f(x + 25, y + 25, z);
247
+			
248
+			glTexCoord2d(0.0, 1.0);
249
+			glVertex3f(x - 25, y + 25, z);
250
+			
251
+			glTexCoord2d(1.0, 0.0);
252
+			glVertex3f(x + 25, y - 25, z);
253
+			
254
+			glTexCoord2d(0.0, 0.0);
255
+			glVertex3f(x - 25, y - 25, z);
256
+			
257
+			glEnd();
258
+		}
259
+	}
260
+
261
+#else
262
+	glBegin(GL_POINTS);
263
+
264
+	for (gEmitter.mMasses.start(); gEmitter.mMasses.forward(); 
265
+		  gEmitter.mMasses.next())
266
+	{
267
+		m = gEmitter.mMasses.current();
268
+
269
+		if (!m)
270
+			continue;
271
+
272
+		glColor4f(0.0, 1.0, 1.0, 1.0);
273
+		glVertex3fv(m->mPos.mVec);
274
+	}
275
+
276
+	glEnd();
277
+#endif
278
+}
279
+
280
+
281
+void handleKey(int key)
282
+{
283
+	Mass *m;
284
+
285
+	switch (key)
286
+	{
287
+	case ' ':
288
+		m = gGravityEmitter.getMass(0);
289
+
290
+		if (m)
291
+		{
292
+			m->mVelocity = Vector3d(0.0f, 120.0f, 0.0f);
293
+		}
294
+		break;
295
+	case 'r':
296
+		gGravityEmitter.clear();
297
+
298
+		gGravityEmitter.generateMasses(1, 1.0f, 
299
+												 Vector3d(0.0f, 0.0f, 0.0f),
300
+												 Vector3d(0.0f, 96.0f, -64.0f));
301
+		gGravityEmitter.generateMasses(1, 1.0f, 
302
+												 Vector3d(-128.0f, 0.0f, 0.0f),
303
+												 Vector3d(32.0f, 96.0f, 0.0f));
304
+		gGravityEmitter.generateMasses(1, 1.0f,
305
+												 Vector3d(128.0f, 0.0f, 0.0f),
306
+												 Vector3d(-32.0f, 96.0f, 0.0f));
307
+		break;
308
+	case 't':
309
+		if (gEmitter == &gGravityEmitter)
310
+		{
311
+			gEmitter = &gSpringEmitter;
312
+		}
313
+		else
314
+		{
315
+			gEmitter = &gGravityEmitter;
316
+		}
317
+		break;
318
+	case 'f':
319
+		gGravityEmitter.gravitation *= 10.0;
320
+		printf("G is now %f\n", gGravityEmitter.gravitation.mVec[1]);
321
+		break;
322
+	case 'g':
323
+		if (fabs(gGravityEmitter.gravitation.mVec[1] * 0.1) > 0.0000001)
324
+			gGravityEmitter.gravitation *= 0.1;
325
+
326
+		printf("G is now %f\n", gGravityEmitter.gravitation.mVec[1]);
327
+		break;
328
+	case 's':
329
+		gOn = !gOn;
330
+		break;
331
+	case '[':
332
+		gSpringEmitter.springConstant += 0.5f;
333
+		printf("Spring constant = %f\n", gSpringEmitter.springConstant);
334
+		break;
335
+	case ']':
336
+		if (gSpringEmitter.springConstant - 0.5 > 0.0f)
337
+			gSpringEmitter.springConstant -= 0.5f;
338
+		printf("Spring constant = %f\n", gSpringEmitter.springConstant);
339
+		break;
340
+	case '.':
341
+		gSpeed *= 10.0;
342
+		printf("Time is at %f speed\n", gSpeed);
343
+		break;
344
+	case ',':
345
+		if (gSpeed * 0.1 > 0.0000001)
346
+			gSpeed *= 0.1;
347
+		printf("Time is at %f speed\n", gSpeed);
348
+		break;
349
+	case 'h':
350
+		printf("\n");
351
+		printf("----------------------------------\n");
352
+		printf("t -       Toggle emitter\n");
353
+		printf("r -       Reset gravity emitter test\n");
354
+		printf("[ ] -     Adjust spring stiffness\n");
355
+		printf(", . -     Adjust time delta\n");
356
+		printf("g -       Scale gravity down\n");
357
+		printf("f -       Scale gravity up\n");
358
+		printf("s -       Start/stop simulation\n");
359
+		break;
360
+	}
361
+}
362
+
363
+
364
+void handleArgKey(char key)
365
+{
366
+	switch (key)
367
+	{
368
+	default:
369
+		;
370
+	}
371
+}
372
+
373
+
374
+void initScene(int argc, char *argv[])
375
+{
376
+	//glEnable(GL_CULL_FACE);
377
+	//glCullFace(GL_FRONT);    // Q3A uses front face culling
378
+	glEnable(GL_TEXTURE_2D);
379
+	glEnable(GL_DEPTH_TEST);
380
+	glDepthFunc(GL_LESS);
381
+	glShadeModel(GL_SMOOTH);
382
+	glDisable(GL_LIGHTING);
383
+
384
+	glPointSize(5.0f);
385
+	gYawOn = false;
386
+	gScale = 0.3f;
387
+
388
+	// Texture setup
389
+	gTexture.reset();
390
+	gTexture.setFlag(Texture::fUseMipmaps);
391
+	gTexture.setMaxTextureCount(64);
392
+	printf("Loading textures: ");
393
+	gTexture.loadTGA("data/snow.tga");
394
+	gTexture.loadTGA("data/snow2.tga");
395
+	printf(" done\n\n");
396
+}
397
+
398
+
399
+int runSimulationUnitTest(int argc, char *argv[])
400
+{
401
+	gEmitter = &gGravityEmitter;
402
+
403
+	// Masses created above the origin, traveling down on Y axis
404
+	// as if it where in a vacuum pulled by gravity
405
+	gGravityEmitter.generateMasses(1, 1.0f, 
406
+											 Vector3d(0.0f, 0.0f, 0.0f),
407
+											 Vector3d(0.0f, 96.0f, 0.0f));
408
+	gGravityEmitter.generateMasses(1, 1.0f, 
409
+											 Vector3d(-64.0f, 1424.0f, 0.0f),
410
+											 Vector3d(-9.8f, 0.0f, 0.0f));
411
+	gGravityEmitter.generateMasses(1, 1.0f,
412
+											 Vector3d(64.0f, 1424.0f, 0.0f),
413
+											 Vector3d(9.8f, 0.0f, 0.0f));
414
+
415
+	//InternalBBoxCollisionObject *obj = 
416
+	//new InternalBBoxCollisionObject(-9999, 0, -9999, 
417
+	//										 9999, 9999, 9999);
418
+
419
+	HeightCollisionObject *obj = new HeightCollisionObject(0, 9999);
420
+
421
+	/* Don't fall out ot the box world  =) */
422
+	gGravityEmitter.attachCollisionObject(obj);
423
+	gSpringEmitter.attachCollisionObject(obj);
424
+
425
+	// Spring
426
+	gSpringEmitter.connectionPos = Vector3d(0.0f, 200.0f, 0.0f);
427
+	gSpringEmitter.springConstant = 0.3f;
428
+	gSpringEmitter.generateMasses(1, 0.5f, 
429
+											Vector3d(0.0f, -512.0f, 0.0f),
430
+											Vector3d(3.0f, 0.0f, 0.0f));
431
+	gSpringEmitter.generateMasses(1, 0.5f, 
432
+											Vector3d(-512.0f, -128.0f, 0.0f),
433
+											Vector3d(0.0f, 3.0f, 0.0f));
434
+	gSpringEmitter.generateMasses(1, 0.5f, 
435
+											Vector3d(512.0f, -128.0f, 0.0f),
436
+											Vector3d(0.0f, 0.0f, 0.3f));
437
+
438
+	updateWindowTitle("[Simulation particle class test]");
439
+	runSDLUnitTest(argc, argv);
440
+
441
+	return 0;
442
+}
443
+
444
+
445
+int main(int argc, char *argv[])
446
+{
447
+	printf("[Simulation class test]\n");
448
+	runSimulationUnitTest(argc, argv);
449
+
450
+	return 0;
451
+}
452
+#endif

+ 308
- 0
src/hel/Simulation.h 파일 보기

@@ -0,0 +1,308 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Hel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Simulation
9
+ * License : No use w/o permission (C) 2003 Mongoose
10
+ * Comments: This class simulates mass physics
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- Test Defines -----------------------------------------------
17
+ *           
18
+ * UNIT_TEST_SIMULATION - Builds Simulation class as a console unit test 
19
+ *
20
+ *-- History ------------------------------------------------ 
21
+ *
22
+ * 2003.06.08:
23
+ * Mongoose - Generic collision and basic resolution w/o generic
24
+ *            Hel Resolvers
25
+ *
26
+ * 2003.06.02:
27
+ * Mongoose - Created, based on algorithms from Erkin Tunca
28
+ ================================================================*/
29
+
30
+
31
+#ifndef GUARD__HEL_MONGOOSE_SIMULATION_H_
32
+#define GUARD__HEL_MONGOOSE_SIMULATION_H_
33
+
34
+#include <mstl/Vector.h>
35
+#include <hel/CollisionObject.h>
36
+#include <hel/Mass.h>
37
+#include <hel/math.h>
38
+
39
+
40
+class Simulation
41
+{
42
+ public:
43
+
44
+	////////////////////////////////////////////////////////////
45
+	// Constructors
46
+	////////////////////////////////////////////////////////////
47
+
48
+	Simulation();
49
+	/*------------------------------------------------------
50
+	 * Pre  : 
51
+	 * Post : Constructs an object of Simulation
52
+	 *
53
+	 *-- History ------------------------------------------
54
+	 *
55
+	 * 2003.06.02: 
56
+	 * Mongoose - Created
57
+	 ------------------------------------------------------*/
58
+
59
+	virtual ~Simulation();
60
+	/*------------------------------------------------------
61
+	 * Pre  : Simulation object is allocated
62
+	 * Post : Deconstructs an object of Simulation
63
+	 *
64
+	 *-- History ------------------------------------------
65
+	 *
66
+	 * 2003.06.02: 
67
+	 * Mongoose - Created
68
+	 ------------------------------------------------------*/
69
+
70
+
71
+	////////////////////////////////////////////////////////////
72
+	// Public Accessors
73
+	////////////////////////////////////////////////////////////
74
+
75
+	Mass *getMass(unsigned int i);
76
+	/*------------------------------------------------------
77
+	 * Pre  : 
78
+	 * Post : Get <i>th Mass element of this simulation
79
+	 *
80
+	 *-- History ------------------------------------------
81
+	 *
82
+	 * 2003.06.02:
83
+	 * Mongoose - Created
84
+	 ------------------------------------------------------*/
85
+
86
+
87
+	////////////////////////////////////////////////////////////
88
+	// Public Mutators
89
+	////////////////////////////////////////////////////////////
90
+
91
+	virtual void attachCollisionObject(CollisionObject *obj);
92
+	/*------------------------------------------------------
93
+	 * Pre  : 
94
+	 * Post : Adds <Obj> to the collision list for this simulation
95
+	 *
96
+	 * TODO : Allow multiple types of collision to be excluded?
97
+	 *
98
+	 *-- History ------------------------------------------
99
+	 *
100
+	 * 2003.06.08:
101
+	 * Mongoose - Created
102
+	 ------------------------------------------------------*/
103
+
104
+	virtual void clear();
105
+	/*------------------------------------------------------
106
+	 * Pre  : 
107
+	 * Post : Removes all masses from this simulation
108
+	 *
109
+	 *-- History ------------------------------------------
110
+	 *
111
+	 * 2003.06.02:
112
+	 * Mongoose - Created
113
+	 ------------------------------------------------------*/
114
+
115
+	virtual bool collisionDetected(Mass *mass);
116
+	/*------------------------------------------------------
117
+	 * Pre  : 
118
+	 * Post : Returns true if <Mass> collided with object
119
+	 *
120
+	 *-- History ------------------------------------------
121
+	 *
122
+	 * 2003.06.08:
123
+	 * Mongoose - Created
124
+	 ------------------------------------------------------*/
125
+
126
+	virtual void generateMasses(unsigned int count, vec_t mass);
127
+	/*------------------------------------------------------
128
+	 * Pre  : 
129
+	 * Post : <Count> number of masses with <mass> value are added
130
+	 *
131
+	 *-- History ------------------------------------------
132
+	 *
133
+	 * 2003.06.02:
134
+	 * Mongoose - Created
135
+	 ------------------------------------------------------*/
136
+
137
+	virtual void generateMasses(unsigned int count, vec_t mass,
138
+										 const Vector3d &position, 
139
+										 const Vector3d &velocity);
140
+	/*------------------------------------------------------
141
+	 * Pre  : 
142
+	 * Post : <Count> number of masses with 
143
+	 *        <mass>, <position>, and <velocity> are added
144
+	 *
145
+	 *-- History ------------------------------------------
146
+	 *
147
+	 * 2003.06.02:
148
+	 * Mongoose - Created
149
+	 ------------------------------------------------------*/
150
+
151
+	virtual void init();
152
+	/*------------------------------------------------------
153
+	 * Pre  : 
154
+	 * Post : Reset forces acting on masses
155
+	 *
156
+	 *-- History ------------------------------------------
157
+	 *
158
+	 * 2003.06.02:
159
+	 * Mongoose - Created
160
+	 ------------------------------------------------------*/
161
+
162
+	virtual void resolveCollision(Mass *mass, CollisionObject *obj);
163
+	/*------------------------------------------------------
164
+	 * Pre  : 
165
+	 * Post : Resolves a collision of <Obj> and <Mass>
166
+	 *
167
+	 *        The default resolution here is to set mass pos
168
+	 *        to intersection point with the object, there
169
+	 *        is no affect on velocity
170
+	 *
171
+	 *-- History ------------------------------------------
172
+	 *
173
+	 * 2003.06.08:
174
+	 * Mongoose - Created
175
+	 ------------------------------------------------------*/
176
+
177
+	virtual void run(vec_t timeDelta);
178
+	/*------------------------------------------------------
179
+	 * Pre  : 
180
+	 * Post : Does full init, solve, simulate cycle
181
+	 *
182
+	 *-- History ------------------------------------------
183
+	 *
184
+	 * 2003.06.02:
185
+	 * Mongoose - Created
186
+	 ------------------------------------------------------*/
187
+
188
+	virtual void simulate(vec_t timeDelta);
189
+	/*------------------------------------------------------
190
+	 * Pre  : 
191
+	 * Post : Update change in time for each mass
192
+	 *
193
+	 *-- History ------------------------------------------
194
+	 *
195
+	 * 2003.06.02:
196
+	 * Mongoose - Created
197
+	 ------------------------------------------------------*/
198
+
199
+	virtual void solve ();
200
+	/*------------------------------------------------------
201
+	 * Pre  :
202
+	 * Post : Have forces act on masses  
203
+	 *
204
+	 *-- History ------------------------------------------
205
+	 *
206
+	 * 2003.06.02:
207
+	 * Mongoose - Created
208
+	 ------------------------------------------------------*/
209
+
210
+	Vector<Mass *> mMasses;			/* It's a collection of masses, silly */
211
+
212
+	Vector<CollisionObject *> mObjects;	/* Object(s) to test collision with */
213
+
214
+	unsigned int mMassCount;		/* Cache of number of masses in collection  */
215
+
216
+
217
+ private:
218
+
219
+	////////////////////////////////////////////////////////////
220
+	// Private Accessors
221
+	////////////////////////////////////////////////////////////
222
+
223
+
224
+	////////////////////////////////////////////////////////////
225
+	// Private Mutators
226
+	////////////////////////////////////////////////////////////
227
+};
228
+
229
+
230
+class GravitySimulation : public Simulation
231
+{
232
+public:
233
+
234
+	GravitySimulation() : Simulation()      
235
+	{
236
+		gravitation = Vector3d(0.0f, -9.81f, 0.0f);
237
+	}
238
+
239
+
240
+	virtual void solve()                                                    
241
+	{
242
+		Mass *m;
243
+
244
+		// Apply gravitational force to each mass
245
+		for (mMasses.start(); mMasses.forward(); mMasses.next())
246
+		{
247
+			m = mMasses.current();
248
+
249
+			// Gravitational force, Force = (Mass)(Gravity)
250
+			m->applyForce(gravitation * m->mMass);
251
+			
252
+			if (collisionDetected(m))
253
+			{
254
+				m->mVelocity = Vector3d(0, 0, 0);
255
+			}
256
+		}
257
+	}
258
+
259
+
260
+	Vector3d gravitation;     /* Gravitational acceleration */
261
+};
262
+
263
+
264
+class SpringSimulation : public Simulation
265
+{
266
+public:
267
+
268
+	SpringSimulation() : Simulation()
269
+	{
270
+	}
271
+
272
+	
273
+	virtual void generateMasses(unsigned int count, vec_t mass,
274
+										 const Vector3d &position, 
275
+										 const Vector3d &velocity)
276
+	{
277
+		Simulation::generateMasses(count, mass, 
278
+											connectionPos + position, velocity);
279
+	}
280
+
281
+
282
+	virtual void solve()
283
+	{
284
+		Mass *m;
285
+
286
+		// Apply spring force to each mass
287
+		for (mMasses.start(); mMasses.forward(); mMasses.next())
288
+		{
289
+			m = mMasses.current();
290
+
291
+			// Vector from mass to spring connection
292
+			Vector3d springVector = m->mPos - connectionPos;
293
+			
294
+			// Apply spring force, spring force formulation
295
+			m->applyForce(-springVector * springConstant);
296
+
297
+			if (collisionDetected(m))
298
+			{
299
+				//m->mVelocity = Vector3d(0, 0, 0);
300
+			}
301
+		}
302
+	}
303
+
304
+	vec_t springConstant;     /* Stiffness, higher values more spring force */
305
+
306
+	Vector3d connectionPos;   /* Location where mass is connected to spring */
307
+};
308
+#endif

+ 235
- 0
src/hel/Vector3d.cpp 파일 보기

@@ -0,0 +1,235 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Hel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Vector3d
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: Math vector
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- History ------------------------------------------------- 
17
+ *
18
+ * 2002.12.24:
19
+ * Mongoose - Created
20
+ =================================================================*/
21
+
22
+#include <math.h>
23
+#include "Vector3d.h"
24
+
25
+
26
+////////////////////////////////////////////////////////////
27
+// Constructors
28
+////////////////////////////////////////////////////////////
29
+
30
+Vector3d::Vector3d()
31
+{
32
+	mVec[0] = mVec[1] = mVec[2] = 0.0f;
33
+}
34
+
35
+
36
+Vector3d::Vector3d(vec3_t v)
37
+{
38
+	mVec[0] = v[0];
39
+	mVec[1] = v[1];
40
+	mVec[2] = v[2];
41
+}
42
+
43
+
44
+Vector3d::Vector3d(vec_t x, vec_t y, vec_t z)
45
+{
46
+	mVec[0] = x;
47
+	mVec[1] = y;
48
+	mVec[2] = z;
49
+}
50
+
51
+
52
+Vector3d::~Vector3d()
53
+{
54
+}
55
+
56
+
57
+////////////////////////////////////////////////////////////
58
+// Public Accessors
59
+////////////////////////////////////////////////////////////
60
+
61
+vec_t Vector3d::dot(const Vector3d &u, const Vector3d &v)
62
+{
63
+	return (u.mVec[0]*v.mVec[0] + u.mVec[1]*v.mVec[1] + u.mVec[2]*v.mVec[2]);
64
+}
65
+
66
+
67
+Vector3d Vector3d::cross(const Vector3d &u, const Vector3d &v)
68
+{
69
+	return Vector3d(u.mVec[1] * v.mVec[2] - u.mVec[2] * v.mVec[1],
70
+						 u.mVec[2] * v.mVec[0] - u.mVec[0] * v.mVec[2],
71
+						 u.mVec[0] * v.mVec[1] - u.mVec[1] * v.mVec[0]);
72
+}
73
+
74
+
75
+vec_t Vector3d::magnitude()
76
+{
77
+	return sqrt(mVec[0]*mVec[0] + mVec[1]*mVec[1] + mVec[2]*mVec[2]);
78
+}
79
+
80
+
81
+Vector3d Vector3d::unit()
82
+{
83
+	vec_t norm = magnitude();
84
+	
85
+	return Vector3d(mVec[0] / norm,
86
+						 mVec[1] / norm,
87
+						 mVec[2] / norm);
88
+}
89
+
90
+
91
+Vector3d Vector3d::zeroVector()
92
+{
93
+	return Vector3d(0, 0, 0);
94
+}
95
+
96
+
97
+Vector3d Vector3d::operator +(const Vector3d &v)
98
+{
99
+	return Vector3d(mVec[0] + v.mVec[0],
100
+						 mVec[1] + v.mVec[1],
101
+						 mVec[2] + v.mVec[2]);
102
+}
103
+
104
+
105
+Vector3d Vector3d::operator -(const Vector3d &v)
106
+{
107
+	return Vector3d(mVec[0] - v.mVec[0],
108
+						 mVec[1] - v.mVec[1],
109
+						 mVec[2] - v.mVec[2]);	
110
+}
111
+
112
+
113
+Vector3d Vector3d::operator -()
114
+{
115
+	return Vector3d(-mVec[0],
116
+						 -mVec[1],
117
+						 -mVec[2]);	
118
+}
119
+
120
+
121
+Vector3d Vector3d::operator *(vec_t s)
122
+{
123
+	return Vector3d(s * mVec[0],
124
+						 s * mVec[1],
125
+						 s * mVec[2]);
126
+}
127
+
128
+
129
+Vector3d Vector3d::operator /(vec_t s)
130
+{
131
+	return Vector3d(mVec[0] / s,
132
+						 mVec[1] / s,
133
+						 mVec[2] / s);
134
+}
135
+
136
+
137
+vec_t Vector3d::operator *(const Vector3d &v)
138
+{
139
+	return dot(*this, v);
140
+}
141
+
142
+
143
+//Vector3d Vector3d::operator *(const Matrix &m)
144
+//{
145
+//	vec3_t v;
146
+//
147
+//	return 
148
+//}
149
+
150
+
151
+////////////////////////////////////////////////////////////
152
+// Public Mutators
153
+////////////////////////////////////////////////////////////
154
+
155
+void Vector3d::normalize()
156
+{
157
+	vec_t norm = magnitude();
158
+	
159
+	mVec[0] /= norm;
160
+	mVec[1] /= norm;
161
+	mVec[2] /= norm;
162
+}
163
+
164
+
165
+void Vector3d::zero()
166
+{
167
+	mVec[0] = 0;
168
+	mVec[1] = 0;
169
+	mVec[2] = 0;
170
+}
171
+
172
+
173
+void Vector3d::operator =(const Vector3d &v)
174
+{
175
+	mVec[0] = v.mVec[0];
176
+	mVec[1] = v.mVec[1];
177
+	mVec[2] = v.mVec[2];
178
+}
179
+
180
+
181
+void Vector3d::operator +=(const Vector3d &v)
182
+{
183
+	mVec[0] += v.mVec[0];
184
+	mVec[1] += v.mVec[1];
185
+	mVec[2] += v.mVec[2];
186
+}
187
+
188
+
189
+void Vector3d::operator -=(const Vector3d &v)
190
+{
191
+	mVec[0] -= v.mVec[0];
192
+	mVec[1] -= v.mVec[1];
193
+	mVec[2] -= v.mVec[2];
194
+}
195
+
196
+
197
+void Vector3d::operator *=(vec_t s)
198
+{
199
+	mVec[0] *= s;
200
+	mVec[1] *= s;
201
+	mVec[2] *= s;
202
+}
203
+
204
+
205
+////////////////////////////////////////////////////////////
206
+// Private Accessors
207
+////////////////////////////////////////////////////////////
208
+
209
+
210
+////////////////////////////////////////////////////////////
211
+// Private Mutators
212
+////////////////////////////////////////////////////////////
213
+
214
+
215
+////////////////////////////////////////////////////////////
216
+// Unit Test code
217
+////////////////////////////////////////////////////////////
218
+
219
+#ifdef UNIT_TEST_VECTOR3D
220
+int runVector3dUnitTest(int argc, char *argv[])
221
+{
222
+	Vector3d test;
223
+
224
+	return 0;
225
+}
226
+
227
+
228
+int main(int argc, char *argv[])
229
+{
230
+	printf("[Vector3d class test]\n");
231
+	runVector3dUnitTest(argc, argv);
232
+
233
+	return 0;
234
+}
235
+#endif

+ 297
- 0
src/hel/Vector3d.h 파일 보기

@@ -0,0 +1,297 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : Hel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : Vector3d
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: Math vector
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- Test Defines -----------------------------------------------
17
+ *           
18
+ * UNIT_TEST_VECTOR3D - Builds Vector3d class as a console unit test 
19
+ *
20
+ *-- History ------------------------------------------------ 
21
+ *
22
+ * 2002.12.24:
23
+ * Mongoose - Created
24
+ ================================================================*/
25
+
26
+
27
+#ifndef GUARD__HEL_MONGOOSE_VECTOR3D_H_
28
+#define GUARD__HEL_MONGOOSE_VECTOR3D_H_
29
+
30
+
31
+#include <hel/math.h>
32
+
33
+class Vector3d
34
+{
35
+ public:
36
+
37
+	////////////////////////////////////////////////////////////
38
+	// Constructors
39
+	////////////////////////////////////////////////////////////
40
+
41
+	Vector3d();
42
+	/*------------------------------------------------------
43
+	 * Pre  : 
44
+	 * Post : Constructs an object of Vector3d
45
+	 *
46
+	 *-- History ------------------------------------------
47
+	 *
48
+	 * 2002.12.24: 
49
+	 * Mongoose - Created
50
+	 ------------------------------------------------------*/
51
+
52
+	Vector3d(vec3_t v);
53
+	/*------------------------------------------------------
54
+	 * Pre  : 
55
+	 * Post : Constructs an object of Vector3d
56
+	 *
57
+	 *-- History ------------------------------------------
58
+	 *
59
+	 * 2002.12.24: 
60
+	 * Mongoose - Created
61
+	 ------------------------------------------------------*/
62
+
63
+	Vector3d(vec_t x, vec_t y, vec_t z);
64
+	/*------------------------------------------------------
65
+	 * Pre  : 
66
+	 * Post : Constructs an object of Vector3d
67
+	 *
68
+	 *-- History ------------------------------------------
69
+	 *
70
+	 * 2002.12.24: 
71
+	 * Mongoose - Created
72
+	 ------------------------------------------------------*/
73
+
74
+	~Vector3d();
75
+	/*------------------------------------------------------
76
+	 * Pre  : Vector3d object is allocated
77
+	 * Post : Deconstructs an object of Vector3d
78
+	 *
79
+	 *-- History ------------------------------------------
80
+	 *
81
+	 * 2002.12.24: 
82
+	 * Mongoose - Created
83
+	 ------------------------------------------------------*/
84
+
85
+
86
+	////////////////////////////////////////////////////////////
87
+	// Public Accessors
88
+	////////////////////////////////////////////////////////////
89
+
90
+	static vec_t dot(const Vector3d &u, const Vector3d &v);
91
+	/*------------------------------------------------------
92
+	 * Pre  : 
93
+	 * Post : Returns dot product of U and V vectors
94
+	 *
95
+	 *-- History ------------------------------------------
96
+	 *
97
+	 * 2002.05.08:
98
+	 * Mongoose - Created
99
+	 ------------------------------------------------------*/
100
+
101
+	static Vector3d cross(const Vector3d &u, const Vector3d &v);
102
+	/*------------------------------------------------------
103
+	 * Pre  : 
104
+	 * Post : Returns cross product of U and V vectors
105
+	 *
106
+	 *-- History ------------------------------------------
107
+	 *
108
+	 * 2002.05.08:
109
+	 * Mongoose - Created
110
+	 ------------------------------------------------------*/
111
+
112
+	vec_t magnitude();
113
+	/*------------------------------------------------------
114
+	 * Pre  : 
115
+	 * Post : Returns magnitude this vector
116
+	 *
117
+	 *-- History ------------------------------------------
118
+	 *
119
+	 * 2002.05.08:
120
+	 * Mongoose - Created
121
+	 ------------------------------------------------------*/
122
+
123
+	Vector3d unit();
124
+	/*------------------------------------------------------
125
+	 * Pre  : 
126
+	 * Post : Returns normalized copy of this vector
127
+	 *
128
+	 *-- History ------------------------------------------
129
+	 *
130
+	 * 2002.05.08:
131
+	 * Mongoose - Created
132
+	 ------------------------------------------------------*/
133
+
134
+	static Vector3d zeroVector();
135
+	/*------------------------------------------------------
136
+	 * Pre  : 
137
+	 * Post : Returns the Zero vector <0, 0, 0>
138
+	 *
139
+	 *-- History ------------------------------------------
140
+	 *
141
+	 * 2003.06.08:
142
+	 * Mongoose - Created
143
+	 ------------------------------------------------------*/
144
+
145
+	Vector3d operator +(const Vector3d &v);
146
+	/*------------------------------------------------------
147
+	 * Pre  : 
148
+	 * Post : Returns a vector = this vector + v
149
+	 *
150
+	 *-- History ------------------------------------------
151
+	 *
152
+	 * 2002.05.08:
153
+	 * Mongoose - Created
154
+	 ------------------------------------------------------*/
155
+
156
+	Vector3d operator -(const Vector3d &v);
157
+	/*------------------------------------------------------
158
+	 * Pre  : 
159
+	 * Post : Returns a vector = this vector - v
160
+	 *
161
+	 *-- History ------------------------------------------
162
+	 *
163
+	 * 2002.05.08:
164
+	 * Mongoose - Created
165
+	 ------------------------------------------------------*/
166
+
167
+	Vector3d operator -();
168
+	/*------------------------------------------------------
169
+	 * Pre  : 
170
+	 * Post : Returns a copy of this vector, negated
171
+	 *
172
+	 *-- History ------------------------------------------
173
+	 *
174
+	 * 2002.05.08:
175
+	 * Mongoose - Created
176
+	 ------------------------------------------------------*/
177
+
178
+	Vector3d operator *(vec_t s);
179
+	/*------------------------------------------------------
180
+	 * Pre  : S is scalar to scale by
181
+	 * Post : Returns scale by S of this vector ( mult )
182
+	 *
183
+	 *-- History ------------------------------------------
184
+	 *
185
+	 * 2002.05.08:
186
+	 * Mongoose - Created
187
+	 ------------------------------------------------------*/
188
+
189
+	Vector3d operator /(vec_t s);
190
+	/*------------------------------------------------------
191
+	 * Pre  : S is scalar to scale by
192
+	 * Post : Returns scale by S of this vector ( div )
193
+	 *
194
+	 *-- History ------------------------------------------
195
+	 *
196
+	 * 2002.05.08:
197
+	 * Mongoose - Created
198
+	 ------------------------------------------------------*/
199
+
200
+	vec_t operator *(const Vector3d &v);
201
+	/*------------------------------------------------------
202
+	 * Pre  : V is vector to dot by
203
+	 * Post : Returns dot by V with this vector
204
+	 *
205
+	 *-- History ------------------------------------------
206
+	 *
207
+	 * 2002.05.08:
208
+	 * Mongoose - Created
209
+	 ------------------------------------------------------*/
210
+
211
+
212
+	////////////////////////////////////////////////////////////
213
+	// Public Mutators
214
+	////////////////////////////////////////////////////////////
215
+
216
+	void normalize();
217
+	/*------------------------------------------------------
218
+	 * Pre  : 
219
+	 * Post : Normalizes *this vector
220
+	 *
221
+	 *-- History ------------------------------------------
222
+	 *
223
+	 * 2002.05.08:
224
+	 * Mongoose - Created
225
+	 ------------------------------------------------------*/
226
+
227
+	void zero();
228
+	/*------------------------------------------------------
229
+	 * Pre  : 
230
+	 * Post :This is set to the Zero vector <0, 0, 0>
231
+	 *
232
+	 *-- History ------------------------------------------
233
+	 *
234
+	 * 2003.06.08:
235
+	 * Mongoose - Created
236
+	 ------------------------------------------------------*/
237
+
238
+	void operator =(const Vector3d &v);
239
+	/*------------------------------------------------------
240
+	 * Pre  : 
241
+	 * Post : this = v, values are assigned   =)
242
+	 *
243
+	 *-- History ------------------------------------------
244
+	 *
245
+	 * 2002.05.08:
246
+	 * Mongoose - Created
247
+	 ------------------------------------------------------*/
248
+
249
+	void operator +=(const Vector3d &v);
250
+	/*------------------------------------------------------
251
+	 * Pre  : 
252
+	 * Post : this += v, values are sumed, assigned   =)
253
+	 *
254
+	 *-- History ------------------------------------------
255
+	 *
256
+	 * 2002.05.08:
257
+	 * Mongoose - Created
258
+	 ------------------------------------------------------*/
259
+
260
+	void operator -=(const Vector3d &v);
261
+	/*------------------------------------------------------
262
+	 * Pre  : 
263
+	 * Post : this -= v, values are diffed, assigned   =)
264
+	 *
265
+	 *-- History ------------------------------------------
266
+	 *
267
+	 * 2002.05.08:
268
+	 * Mongoose - Created
269
+	 ------------------------------------------------------*/
270
+
271
+	void operator *=(vec_t s);
272
+	/*------------------------------------------------------
273
+	 * Pre  : 
274
+	 * Post : this *= s, values are scaled, assigned   =)
275
+	 *
276
+	 *-- History ------------------------------------------
277
+	 *
278
+	 * 2002.05.08:
279
+	 * Mongoose - Created
280
+	 ------------------------------------------------------*/
281
+
282
+	vec3_t mVec;   /* Vector data */
283
+
284
+ private:
285
+
286
+	////////////////////////////////////////////////////////////
287
+	// Private Accessors
288
+	////////////////////////////////////////////////////////////
289
+
290
+
291
+	////////////////////////////////////////////////////////////
292
+	// Private Mutators
293
+	////////////////////////////////////////////////////////////
294
+
295
+};
296
+
297
+#endif

+ 403
- 0
src/hel/ViewVolume.cpp 파일 보기

@@ -0,0 +1,403 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : hel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : ViewVolume
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: This is the viewing volume for culling use
11
+ *
12
+ *           Thanks Mark Morley for the article I used
13
+ *           to get several algorithms.
14
+ *
15
+ *           This file was generated using Mongoose's C++ 
16
+ *           template generator script.  <stu7440@westga.edu>
17
+ * 
18
+ *-- History ------------------------------------------------- 
19
+ *
20
+ * 2002.12.15:
21
+ * Mongoose - Created
22
+ =================================================================*/
23
+
24
+#include <math.h>
25
+#include "ViewVolume.h"
26
+
27
+
28
+////////////////////////////////////////////////////////////
29
+// Constructors
30
+////////////////////////////////////////////////////////////
31
+
32
+ViewVolume::ViewVolume()
33
+{
34
+}
35
+
36
+
37
+ViewVolume::~ViewVolume()
38
+{
39
+}
40
+
41
+
42
+////////////////////////////////////////////////////////////
43
+// Public Accessors
44
+////////////////////////////////////////////////////////////
45
+
46
+bool ViewVolume::isBoundingVolumeInFrustum(BoundingVolume bvol)
47
+{
48
+	return (isBoundingSphereInFrustum(bvol.mSphere) &&
49
+			  isBoundingBoxInFrustum(bvol.mBox));
50
+}
51
+
52
+
53
+bool ViewVolume::isBoundingSphereInFrustum(BoundingSphere bvol)
54
+{
55
+	return (isSphereInFrustum(bvol.mCenter[0],
56
+									  bvol.mCenter[1],
57
+									  bvol.mCenter[2],
58
+									  bvol.mRadius));
59
+}
60
+
61
+
62
+bool ViewVolume::isBoundingBoxInFrustum(BoundingBox bvol)
63
+{
64
+	return (isBboxInFrustum(bvol.mMin, bvol.mMax));
65
+}
66
+
67
+
68
+bool ViewVolume::isPointInFrustum(vec_t x, vec_t y, vec_t z)
69
+{
70
+   unsigned int p;
71
+
72
+
73
+   for (p = 0; p < 6; ++p)
74
+	{
75
+      if (mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + 
76
+			 mFrustum[p][3] <= 0)
77
+		{
78
+         return false;
79
+		}
80
+	}
81
+
82
+   return true;
83
+}
84
+
85
+
86
+bool ViewVolume::isSphereInFrustum(vec_t x, vec_t y, vec_t z, vec_t radius)
87
+{
88
+   unsigned int p;
89
+   vec_t d;
90
+
91
+
92
+   for (p = 0; p < 6; ++p)
93
+   {
94
+      d = mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + mFrustum[p][3];
95
+      if (d <= -radius)
96
+         return false;
97
+   }
98
+
99
+   return true;
100
+}
101
+
102
+
103
+bool ViewVolume::isBboxInFrustum(vec3_t min, vec3_t max)
104
+{
105
+   unsigned int p;
106
+
107
+
108
+   for (p = 0; p < 6; ++p)
109
+   {
110
+      if (mFrustum[p][0] * min[0] + 
111
+			 mFrustum[p][1] * min[1] + 
112
+			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
113
+         continue;
114
+
115
+      if (mFrustum[p][0] * max[0] + 
116
+			 mFrustum[p][1] * max[1] + 
117
+			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
118
+         continue;
119
+
120
+      if (mFrustum[p][0] * min[0] + 
121
+			 mFrustum[p][1] * max[1] + 
122
+			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
123
+         continue;
124
+
125
+      if (mFrustum[p][0] * min[0] + 
126
+			 mFrustum[p][1] * min[1] + 
127
+			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
128
+         continue;
129
+
130
+      if (mFrustum[p][0] * min[0] + 
131
+			 mFrustum[p][1] * max[1] + 
132
+			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
133
+         continue;
134
+
135
+      if (mFrustum[p][0] * max[0] + 
136
+			 mFrustum[p][1] * min[1] + 
137
+			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
138
+         continue;
139
+
140
+      if (mFrustum[p][0] * max[0] + 
141
+			 mFrustum[p][1] * max[1] + 
142
+			 mFrustum[p][2] * min[2] + mFrustum[p][3] > 0)
143
+         continue;
144
+
145
+      if (mFrustum[p][0] * max[0] + 
146
+			 mFrustum[p][1] * min[1] + 
147
+			 mFrustum[p][2] * max[2] + mFrustum[p][3] > 0)
148
+         continue;
149
+
150
+      return false;
151
+   }
152
+
153
+   return true;
154
+}
155
+
156
+
157
+vec_t ViewVolume::getDistToSphereFromNear(vec_t x, vec_t y, vec_t z, 
158
+														vec_t radius)
159
+{
160
+   unsigned int p;
161
+   vec_t d;
162
+
163
+   for (p = 0; p < 6; ++p)
164
+   {
165
+      d = mFrustum[p][0] * x + mFrustum[p][1] * y + mFrustum[p][2] * z + mFrustum[p][3];
166
+      if (d <= -radius)
167
+         return 0;
168
+   }
169
+
170
+   return d + radius;
171
+}
172
+
173
+
174
+vec_t ViewVolume::getDistToBboxFromNear(vec3_t min, vec3_t max)
175
+{
176
+	vec3_t center;
177
+   vec_t d, radius;
178
+
179
+
180
+	helMidpoint3v(min, max, center);
181
+
182
+	// 5 should be near plane
183
+	d = (mFrustum[5][0] * center[0] + 
184
+		  mFrustum[5][1] * center[1] + 
185
+		  mFrustum[5][2] * center[2] + 
186
+		  mFrustum[5][3]);
187
+
188
+	radius = helDist3v(max, center);
189
+
190
+	if (d <= -radius)
191
+		return 0;
192
+
193
+   return d + radius;
194
+}
195
+
196
+
197
+void ViewVolume::getFrustum(vec_t frustum[6][4])
198
+{
199
+	unsigned int plane;
200
+
201
+
202
+	for (plane = 0; plane < 6; ++plane)
203
+   {
204
+		frustum[plane][0] = mFrustum[plane][0];
205
+		frustum[plane][1] = mFrustum[plane][1];
206
+		frustum[plane][2] = mFrustum[plane][2];
207
+		frustum[plane][3] = mFrustum[plane][3];
208
+	}
209
+}
210
+
211
+
212
+void ViewVolume::getPlane(ViewVolumeSide p, vec4_t plane)
213
+{
214
+	plane[0] =  mFrustum[p][0];
215
+	plane[1] =  mFrustum[p][1];
216
+	plane[2] =  mFrustum[p][2];
217
+	plane[3] =  mFrustum[p][3];
218
+}
219
+
220
+
221
+////////////////////////////////////////////////////////////
222
+// Public Mutators
223
+////////////////////////////////////////////////////////////
224
+
225
+void ViewVolume::updateFrame(matrix_t proj, matrix_t mdl)
226
+{
227
+	setModel(mdl);
228
+	setProjection(proj);
229
+	updateClip();
230
+	updateFrustum();
231
+}
232
+
233
+
234
+void ViewVolume::updateFrame()
235
+{
236
+	updateClip();
237
+	updateFrustum();
238
+}
239
+
240
+
241
+void ViewVolume::setModel(matrix_t mdl)
242
+{
243
+	mModel.setMatrix(mdl);
244
+}
245
+
246
+
247
+void ViewVolume::setProjection(matrix_t proj)
248
+{
249
+	/*void setProjection(viewAngle, aspectRatio, near, far)
250
+    ****************************
251
+	 *float far = 4000.0f;
252
+	 *float near = 4.0f;
253
+	 *float viewAngle = 45.0f;
254
+	 *float aspectRatio = 800.0f/600.0f;
255
+	 ****************************
256
+	 *float top = near * tan(PI/180 * viewAngle/2)
257
+    *float bottom = -top
258
+    *float right = top * aspectRatio
259
+    *float left = - right
260
+	 */
261
+
262
+	mProjection.setMatrix(proj);
263
+}
264
+
265
+
266
+
267
+////////////////////////////////////////////////////////////
268
+// Private Accessors
269
+////////////////////////////////////////////////////////////
270
+
271
+
272
+////////////////////////////////////////////////////////////
273
+// Private Mutators
274
+////////////////////////////////////////////////////////////
275
+
276
+void ViewVolume::updateClip()
277
+{
278
+	//mClip = mModel * mProjection;
279
+	mClip = mProjection * mModel;
280
+}
281
+
282
+
283
+void ViewVolume::updateFrustum()
284
+{
285
+	matrix_t clip;
286
+	vec_t t;
287
+
288
+
289
+	mClip.getMatrix(clip);
290
+
291
+   /* Extract the numbers for the RIGHT plane */
292
+   mFrustum[0][0] = clip[ 3] - clip[ 0];
293
+   mFrustum[0][1] = clip[ 7] - clip[ 4];
294
+   mFrustum[0][2] = clip[11] - clip[ 8];
295
+   mFrustum[0][3] = clip[15] - clip[12];
296
+
297
+   /* Normalize the result */
298
+   t = sqrt(mFrustum[0][0] * mFrustum[0][0] + 
299
+				mFrustum[0][1] * mFrustum[0][1] + 
300
+				mFrustum[0][2] * mFrustum[0][2]);
301
+   mFrustum[0][0] /= t;
302
+   mFrustum[0][1] /= t;
303
+   mFrustum[0][2] /= t;
304
+   mFrustum[0][3] /= t;
305
+
306
+   /* Extract the numbers for the LEFT plane */
307
+   mFrustum[1][0] = clip[ 3] + clip[ 0];
308
+   mFrustum[1][1] = clip[ 7] + clip[ 4];
309
+   mFrustum[1][2] = clip[11] + clip[ 8];
310
+   mFrustum[1][3] = clip[15] + clip[12];
311
+
312
+   /* Normalize the result */
313
+   t = sqrt(mFrustum[1][0] * mFrustum[1][0] + 
314
+				mFrustum[1][1] * mFrustum[1][1] + 
315
+				mFrustum[1][2] * mFrustum[1][2]);
316
+   mFrustum[1][0] /= t;
317
+   mFrustum[1][1] /= t;
318
+   mFrustum[1][2] /= t;
319
+   mFrustum[1][3] /= t;
320
+
321
+   /* Extract the BOTTOM plane */
322
+   mFrustum[2][0] = clip[ 3] + clip[ 1];
323
+   mFrustum[2][1] = clip[ 7] + clip[ 5];
324
+   mFrustum[2][2] = clip[11] + clip[ 9];
325
+   mFrustum[2][3] = clip[15] + clip[13];
326
+
327
+   /* Normalize the result */
328
+   t = sqrt(mFrustum[2][0] * mFrustum[2][0] + 
329
+				mFrustum[2][1] * mFrustum[2][1] + 
330
+				mFrustum[2][2] * mFrustum[2][2]);
331
+   mFrustum[2][0] /= t;
332
+   mFrustum[2][1] /= t;
333
+   mFrustum[2][2] /= t;
334
+   mFrustum[2][3] /= t;
335
+
336
+   /* Extract the TOP plane */
337
+   mFrustum[3][0] = clip[ 3] - clip[ 1];
338
+   mFrustum[3][1] = clip[ 7] - clip[ 5];
339
+   mFrustum[3][2] = clip[11] - clip[ 9];
340
+   mFrustum[3][3] = clip[15] - clip[13];
341
+
342
+   /* Normalize the result */
343
+   t = sqrt(mFrustum[3][0] * mFrustum[3][0] + 
344
+				mFrustum[3][1] * mFrustum[3][1] + 
345
+				mFrustum[3][2] * mFrustum[3][2]);
346
+   mFrustum[3][0] /= t;
347
+   mFrustum[3][1] /= t;
348
+   mFrustum[3][2] /= t;
349
+   mFrustum[3][3] /= t;
350
+
351
+   /* Extract the FAR plane */
352
+   mFrustum[4][0] = clip[ 3] - clip[ 2];
353
+   mFrustum[4][1] = clip[ 7] - clip[ 6];
354
+   mFrustum[4][2] = clip[11] - clip[10];
355
+   mFrustum[4][3] = clip[15] - clip[14];
356
+
357
+   /* Normalize the result */
358
+   t = sqrt(mFrustum[4][0] * mFrustum[4][0] + 
359
+				mFrustum[4][1] * mFrustum[4][1] + 
360
+				mFrustum[4][2] * mFrustum[4][2]);
361
+   mFrustum[4][0] /= t;
362
+   mFrustum[4][1] /= t;
363
+   mFrustum[4][2] /= t;
364
+   mFrustum[4][3] /= t;
365
+
366
+   /* Extract the NEAR plane */
367
+   mFrustum[5][0] = clip[ 3] + clip[ 2];
368
+   mFrustum[5][1] = clip[ 7] + clip[ 6];
369
+   mFrustum[5][2] = clip[11] + clip[10];
370
+   mFrustum[5][3] = clip[15] + clip[14];
371
+
372
+   /* Normalize the result */
373
+   t = sqrt(mFrustum[5][0] * mFrustum[5][0] + 
374
+				mFrustum[5][1] * mFrustum[5][1] + 
375
+				mFrustum[5][2] * mFrustum[5][2]);
376
+   mFrustum[5][0] /= t;
377
+   mFrustum[5][1] /= t;
378
+   mFrustum[5][2] /= t;
379
+   mFrustum[5][3] /= t;
380
+}
381
+
382
+
383
+////////////////////////////////////////////////////////////
384
+// Unit Test code
385
+////////////////////////////////////////////////////////////
386
+
387
+#ifdef UNIT_TEST_VIEWVOLUME
388
+int runViewVolumeUnitTest(int argc, char *argv[])
389
+{
390
+	return 0;
391
+}
392
+
393
+
394
+int main(int argc, char *argv[])
395
+{
396
+	ViewVolume test;
397
+
398
+
399
+	printf("[ViewVolume class test]\n");
400
+
401
+	return runViewVolumeUnitTest(argc, argv);
402
+}
403
+#endif

+ 294
- 0
src/hel/ViewVolume.h 파일 보기

@@ -0,0 +1,294 @@
1
+/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
+/*================================================================
3
+ * 
4
+ * Project : hel
5
+ * Author  : Terry 'Mongoose' Hendrix II
6
+ * Website : http://www.westga.edu/~stu7440/
7
+ * Email   : stu7440@westga.edu
8
+ * Object  : ViewVolume
9
+ * License : No use w/o permission (C) 2002 Mongoose
10
+ * Comments: This is the viewing volume for culling use
11
+ *
12
+ *
13
+ *           This file was generated using Mongoose's C++ 
14
+ *           template generator script.  <stu7440@westga.edu>
15
+ * 
16
+ *-- Test Defines -----------------------------------------------
17
+ *           
18
+ * UNIT_TEST_VIEWVOLUME - Builds ViewVolume class as a console unit test 
19
+ *
20
+ *-- History ------------------------------------------------ 
21
+ *
22
+ * 2002.12.15:
23
+ * Mongoose - Created
24
+ ================================================================*/
25
+
26
+
27
+#ifndef GUARD__HEL_MONGOOSE_VIEWVOLUME_H_
28
+#define GUARD__HEL_MONGOOSE_VIEWVOLUME_H_
29
+
30
+#include <hel/Matrix.h>
31
+#include <hel/BoundingVolume.h>
32
+
33
+class ViewVolume
34
+{
35
+ public:
36
+
37
+	enum ViewVolumeSide
38
+	{
39
+		rightSide  = 0, // Right
40
+		leftSide   = 1, // Left
41
+		bottomSide = 2, // Bottom
42
+		topSide    = 3, // Top
43
+		farSide    = 4, // Back
44
+		nearSide   = 5  // Front
45
+	};
46
+
47
+	enum ViewVolumePlane
48
+	{
49
+		planeA = 0, // X value of normal
50
+		planeB = 1, // Y value of normal
51
+		planeC = 2, // Z value of normal
52
+		planeD = 3  // Distance to origin
53
+	};
54
+
55
+
56
+	////////////////////////////////////////////////////////////
57
+	// Constructors
58
+	////////////////////////////////////////////////////////////
59
+
60
+	ViewVolume();
61
+	/*------------------------------------------------------
62
+	 * Pre  : 
63
+	 * Post : Constructs an object of ViewVolume
64
+	 *
65
+	 *-- History ------------------------------------------
66
+	 *
67
+	 * 2002.12.15: 
68
+	 * Mongoose - Created
69
+	 ------------------------------------------------------*/
70
+
71
+	~ViewVolume();
72
+	/*------------------------------------------------------
73
+	 * Pre  : ViewVolume object is allocated
74
+	 * Post : Deconstructs an object of ViewVolume
75
+	 *
76
+	 *-- History ------------------------------------------
77
+	 *
78
+	 * 2002.12.15: 
79
+	 * Mongoose - Created
80
+	 ------------------------------------------------------*/
81
+
82
+
83
+	////////////////////////////////////////////////////////////
84
+	// Public Accessors
85
+	////////////////////////////////////////////////////////////
86
+
87
+	bool isBoundingVolumeInFrustum(BoundingVolume bvol);
88
+	/*------------------------------------------------------
89
+	 * Pre  : 
90
+	 * Post : Returns true if frustum contains the given 
91
+	 *        bounding volume
92
+	 *
93
+	 *-- History ------------------------------------------
94
+	 *
95
+	 * 2002.12.15: 
96
+	 * Mongoose - Created
97
+	 ------------------------------------------------------*/
98
+
99
+	bool isBoundingSphereInFrustum(BoundingSphere bvol);
100
+	/*------------------------------------------------------
101
+	 * Pre  : 
102
+	 * Post : Returns true if frustum contains the given 
103
+	 *        bounding volume
104
+	 *
105
+	 *-- History ------------------------------------------
106
+	 *
107
+	 * 2002.12.15: 
108
+	 * Mongoose - Created
109
+	 ------------------------------------------------------*/
110
+
111
+	bool isBoundingBoxInFrustum(BoundingBox bvol);
112
+	/*------------------------------------------------------
113
+	 * Pre  : 
114
+	 * Post : Returns true if frustum contains the given 
115
+	 *        bounding volume
116
+	 *
117
+	 *-- History ------------------------------------------
118
+	 *
119
+	 * 2002.12.15: 
120
+	 * Mongoose - Created
121
+	 ------------------------------------------------------*/
122
+
123
+	bool isPointInFrustum(vec_t x, vec_t y, vec_t z);
124
+	/*------------------------------------------------------
125
+	 * Pre  : 
126
+	 * Post : 
127
+	 *
128
+	 *-- History ------------------------------------------
129
+	 *
130
+	 * 2002.12.15: 
131
+	 * Mongoose - Created
132
+	 ------------------------------------------------------*/
133
+
134
+	bool isSphereInFrustum(vec_t x, vec_t y, vec_t z, vec_t radius);
135
+	/*------------------------------------------------------
136
+	 * Pre  : Abstract sphere is valid
137
+	 * Post : Returns true if abstract sphere in view volume
138
+	 *
139
+	 *-- History ------------------------------------------
140
+	 *
141
+	 * 2002.12.15: 
142
+	 * Mongoose - Created
143
+	 ------------------------------------------------------*/
144
+
145
+	bool isBboxInFrustum(vec3_t min, vec3_t max);
146
+	/*------------------------------------------------------
147
+	 * Pre  : Abstract bounding box is valid
148
+	 * Post : Returns true if abstract bounding box in view volume
149
+	 *
150
+	 *-- History ------------------------------------------
151
+	 *
152
+	 * 2002.12.15: 
153
+	 * Mongoose - Created
154
+	 ------------------------------------------------------*/
155
+
156
+	vec_t getDistToSphereFromNear(vec_t x, vec_t y, vec_t z, vec_t radius);
157
+	/*------------------------------------------------------
158
+	 * Pre  : Abstract sphere is valid
159
+	 * Post : Returns distance to abstract sphere 
160
+	 *        bounding volume
161
+	 *
162
+	 *-- History ------------------------------------------
163
+	 *
164
+	 * 2002.12.15: 
165
+	 * Mongoose - Created
166
+	 ------------------------------------------------------*/
167
+
168
+	vec_t getDistToBboxFromNear(vec3_t min, vec3_t max);
169
+	/*------------------------------------------------------
170
+	 * Pre  : Abstract bounding box is valid
171
+	 * Post : Returns distance to abstract box
172
+	 *        bounding volume
173
+	 *
174
+	 *-- History ------------------------------------------
175
+	 *
176
+	 * 2002.12.15: 
177
+	 * Mongoose - Created
178
+	 ------------------------------------------------------*/
179
+
180
+	void getFrustum(vec_t frustum[6][4]);
181
+	/*------------------------------------------------------
182
+	 * Pre  : Frustum is allocated 6x4 vec_t
183
+	 * Post : Get a copy of the view volume
184
+	 *
185
+	 *-- History ------------------------------------------
186
+	 *
187
+	 * 2002.12.26:
188
+	 * Mongoose - Created
189
+	 ------------------------------------------------------*/
190
+
191
+	void getPlane(ViewVolumeSide p, vec4_t plane);
192
+	/*------------------------------------------------------
193
+	 * Pre  : 
194
+	 * Post : Get a copy of a given plane in view volume
195
+	 *
196
+	 *-- History ------------------------------------------
197
+	 *
198
+	 * 2002.12.26:
199
+	 * Mongoose - Created
200
+	 ------------------------------------------------------*/
201
+
202
+	
203
+	////////////////////////////////////////////////////////////
204
+	// Public Mutators
205
+	////////////////////////////////////////////////////////////
206
+
207
+	void updateFrame(matrix_t proj, matrix_t mdl);
208
+	/*------------------------------------------------------
209
+	 * Pre  : Given valid projection and model matrices
210
+	 * Post : Updates view volume for this frame
211
+	 *
212
+	 *-- History ------------------------------------------
213
+	 *
214
+	 * 2002.12.15:
215
+	 * Mongoose - Created
216
+	 ------------------------------------------------------*/
217
+
218
+	void updateFrame();
219
+	/*------------------------------------------------------
220
+	 * Pre  : Called setModel() and setProjection()
221
+	 * Post : Updates view volume for this frame
222
+	 *
223
+	 *-- History ------------------------------------------
224
+	 *
225
+	 * 2002.12.15:
226
+	 * Mongoose - Created
227
+	 ------------------------------------------------------*/
228
+
229
+	void setModel(matrix_t mdl);
230
+	/*------------------------------------------------------
231
+	 * Pre  : It's valid model matrix
232
+	 * Post : Sets this class' model matrix
233
+	 *
234
+	 *-- History ------------------------------------------
235
+	 *
236
+	 * 2002.12.15:
237
+	 * Mongoose - Created
238
+	 ------------------------------------------------------*/
239
+
240
+	void setProjection(matrix_t proj);
241
+	/*------------------------------------------------------
242
+	 * Pre  : It's the valid projection matrix
243
+	 * Post : Sets this class' projection matrix
244
+	 *
245
+	 *-- History ------------------------------------------
246
+	 *
247
+	 * 2002.12.15:
248
+	 * Mongoose - Created
249
+	 ------------------------------------------------------*/
250
+
251
+ private:
252
+
253
+	////////////////////////////////////////////////////////////
254
+	// Private Accessors
255
+	////////////////////////////////////////////////////////////
256
+
257
+
258
+	////////////////////////////////////////////////////////////
259
+	// Private Mutators
260
+	////////////////////////////////////////////////////////////
261
+
262
+	void updateClip();
263
+	/*------------------------------------------------------
264
+	 * Pre  : model and projection matrices are set
265
+	 * Post : Computes clipping matrix
266
+	 *
267
+	 *-- History ------------------------------------------
268
+	 *
269
+	 * 2002.12.15:
270
+	 * Mongoose - Created
271
+	 ------------------------------------------------------*/
272
+
273
+	void updateFrustum();
274
+	/*------------------------------------------------------
275
+	 * Pre  : model, projection, clip matrices are set
276
+	 * Post : Computes planes of frustum
277
+	 *
278
+	 *-- History ------------------------------------------
279
+	 *
280
+	 * 2002.12.15:
281
+	 * Mongoose - Created
282
+	 ------------------------------------------------------*/
283
+
284
+
285
+	Matrix mProjection;       	/* Projection matrix */
286
+
287
+	Matrix mModel;         	   /* Model matrix */
288
+
289
+	Matrix mClip;	            /* Clipping matrix */
290
+
291
+	vec_t mFrustum[6][4];      /* View volume */
292
+};
293
+
294
+#endif

+ 0
- 0
src/hel/math.cpp 파일 보기


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.

Loading…
취소
저장