GL Studio C++ Runtime API
gls_glo_file.h
Go to the documentation of this file.
1 /*! \file
2  \brief Provides classes for reading and writing GL Studio Object initialization files
3  (GLO files).
4 
5  \par Copyright Information
6 
7  Copyright (c) 2017 by The DiSTI Corporation.<br>
8  11301 Corporate Blvd; Suite 100<br>
9  Orlando, Florida 32817<br>
10  USA<br>
11  <br>
12  All rights reserved.<br>
13 
14  This Software contains proprietary trade secrets of DiSTI and may not be
15 reproduced, in whole or part, in any form, or by any means of electronic,
16 mechanical, or otherwise, without the written permission of DiSTI. Said
17 permission may be derived through the purchase of applicable DiSTI product
18 licenses which detail the distribution rights of this content and any
19 Derivative Works based on this or other copyrighted DiSTI Software.
20 
21  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
22 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
23 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
24 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
25 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
26 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
27 
28  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
29 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
30 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
31 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
32 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
33 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
34 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
35 EXCEED FIVE DOLLARS (US$5.00).
36 
37  The aforementioned terms and restrictions are governed by the laws of the
38 State of Florida and the United States of America.
39 
40 */
41 #if !defined( _GLS_GLO_FILE_H_ )
42 # define _GLS_GLO_FILE_H_
43 
44 # include "display_frame.h"
45 # include "dynamic_array.h"
46 # include "gls_include.h"
47 # include "gls_matrix_affine.h"
48 # include "vertex.h"
49 
50 //////////////////// Provides support for creating DLLs ////////////////////////
51 # if( defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
52  && defined( _MSC_VER )
53 # if defined( GLS_EXPORT_GENERATED )
54 # define GLSGEN_GlsGloFile_EXPORT __declspec( dllexport )
55 # else
56 # define GLSGEN_GlsGloFile_EXPORT __declspec( dllimport )
57 # endif
58 # else
59 # define GLSGEN_GlsGloFile_EXPORT
60 # endif
61 
62 namespace disti
63 {
64 // Forward declarations.
65 class DisplayFrame;
66 class GlsGloFileAttribute;
67 
68 // Byte swapping functions used by this class.
69 float SwapFloatToNet( float val );
70 double SwapDoubleToNet( double val );
71 unsigned int SwapLongToNet( unsigned int val );
72 unsigned int SwapSignedLongToNet( int val );
73 unsigned short SwapShortToNet( unsigned short val );
74 short SwapSignedShortToNet( short val );
75 
76 // Exception thrown from GlsGloFile contstructor
77 class GLSGEN_GlsGloFile_EXPORT GlsGloFileNotFoundException
78 {
79 };
80 
82 {
83 public:
84  // Forward declarations.
85  class WriteBuffer;
86 
87  static const unsigned int NUM_OBJECTS_OFFSET = 16;
88 
89  /** The size of the timestamp written into the GLO file. */
90  static const unsigned int GLO_FILE_TIMESTAMP_SIZE = 6;
91 
92  // Object Initializer Enumeration
93  enum
94  {
95  // From display_types.h
96  GLS_GLO_INSTANCE_NAME = 1,
97  GLS_GLO_LOCATION,
98  GLS_GLO_ROTATION_POINT,
99  GLS_GLO_ACTION_CALLBACK,
100  GLS_GLO_OBJECT_NAME,
101  GLS_GLO_ATTRIBUTE_NAME,
102  GLS_GLO_TEXTURE_INDEX,
103  GLS_GLO_TEXTURE_REPEAT,
104  GLS_GLO_TEXTURE_MAP_MODE,
105  GLS_GLO_TEXTURE_MIN_FILTER,
106  GLS_GLO_TEXTURE_MAG_FILTER,
107  GLS_GLO_TEXTURE_BLEND_COLOR,
108  GLS_GLO_TEXTURE_ROTATION,
109  GLS_GLO_TEXTURE_SCALE_H,
110  GLS_GLO_TEXTURE_SCALE_V,
111  GLS_GLO_TEXTURE_OFFSET_X,
112  GLS_GLO_TEXTURE_OFFSET_Y,
113  GLS_GLO_POLYGON_MODE,
114  GLS_GLO_POLYGON_END,
115  GLS_GLO_POLYGON_OFFSET,
116  GLS_GLO_COLOR,
117  GLS_GLO_COLOR_MATERIAL_MODE,
118  GLS_GLO_LINE_WIDTH,
119  GLS_GLO_LINE_STIPPLE_PATTERN,
120  GLS_GLO_LINE_STIPPLE_MULTIPLIER,
121  GLS_GLO_VISIBILITY,
122  GLS_GLO_CULLBACKFACE,
123  GLS_GLO_ALPHAMODE,
124  GLS_GLO_ANTIALIAS,
125  GLS_GLO_ZBUFFER,
126  GLS_GLO_SHADING,
127  GLS_GLO_BLINKING,
128  GLS_GLO_BLINK_RATE,
129  GLS_GLO_PICKABLE,
130  GLS_GLO_LIGHTING_ENABLED,
131  GLS_GLO_MATERIAL_INDEX,
132  GLS_GLO_MATERIAL_INDICES,
133  GLS_GLO_DCS_MATRIX,
134  GLS_GLO_COMPONENT_ABSOLUTE_PLACEMENT,
135  GLS_GLO_COMPONENT_EDITOR_TRANSFORM,
136  GLS_GLO_TEXTURE_POINTS,
137 
138  // From component_base.h
139  GLS_GLO_COMPONENT_USE_PARENT_LIGHTING,
140 
141  // From display.h
142  GLS_GLO_NEED_CALCULATE,
143  GLS_GLO_NEED_PREDRAW,
144  GLS_GLO_NUMBER_OF_VERTICES,
145  GLS_GLO_VERTICES,
146  GLS_GLO_NORMALS,
147  GLS_GLO_TEXTURE_COORDINATES,
148 
149  // From gls_cylinder.h
150  GLS_GLO_CYLINDER_COLOR,
151  GLS_GLO_CYLINDER_SEGMENTS,
152  GLS_GLO_CYLINDER_FACES,
153  GLS_GLO_CYLINDER_FACE_START,
154  GLS_GLO_CYLINDER_FACE_END,
155  GLS_GLO_CYLINDER_TOP_SIZE,
156  GLS_GLO_CYLINDER_BOTTOM_SIZE,
157  GLS_GLO_CYLINDER_TOP_FACE,
158  GLS_GLO_CYLINDER_BOTTOM_FACE,
159  GLS_GLO_CYLINDER_RADII,
160 
161  // From gls_eyepoint.h
162  GLS_GLO_EYEPOINT_FOV,
163  GLS_GLO_EYEPOINT_ORTHOGRAPHIC,
164  GLS_GLO_EYEPOINT_ORTHO_SIZE,
165  GLS_GLO_EYEPOINT_FOV_IS_HORIZONTAL,
166  GLS_GLO_EYEPOINT_ASPECT,
167  GLS_GLO_EYEPOINT_NEAR_CLIP,
168  GLS_GLO_EYEPOINT_FAR_CLIP,
169  GLS_GLO_EYEPOINT_MAINTAIN_ASPECT,
170  GLS_GLO_EYEPOINT_VIEW_VECTORS,
171  GLS_GLO_EYEPOINT_OTHER_FOV,
172  GLS_GLO_EYEPOINT_OTHER_ORTHO_SIZE,
173  GLS_GLO_EYEPOINT_HORIZONTAL_CONSTRAINT,
174  GLS_GLO_EYEPOINT_VERTICAL_CONSTRAINT,
175 
176  // From gls_light_source.h
177  GLS_GLO_LIGHT_SOURCE_AMBIENT,
178  GLS_GLO_LIGHT_SOURCE_DIFFUSE,
179  GLS_GLO_LIGHT_SOURCE_SPECULAR,
180  GLS_GLO_LIGHT_SOURCE_SPOT_CUTOFF,
181  GLS_GLO_LIGHT_SOURCE_SPOT_EXPONENT,
182  GLS_GLO_LIGHT_SOURCE_CONSTANT_ATTENUATION,
183  GLS_GLO_LIGHT_SOURCE_LINEAR_ATTENUATION,
184  GLS_GLO_LIGHT_SOURCE_QUADRATIC_ATTENUATION,
185  GLS_GLO_LIGHT_SOURCE_LIGHT_TYPE,
186 
187  // From gls_sphere.h
188  GLS_GLO_SPHERE_MAPPING,
189  GLS_GLO_SPHERE_COLOR,
190  GLS_GLO_SPHERE_STACKS,
191  GLS_GLO_SPHERE_SLICES,
192  GLS_GLO_SPHERE_SLICE_START,
193  GLS_GLO_SPHERE_SLICE_END,
194  GLS_GLO_SPHERE_STACK_START,
195  GLS_GLO_SPHERE_STACK_END,
196  GLS_GLO_SPHERE_RADII,
197 
198  // from gls_text.h
199  GLS_GLO_TEXT_BORDER,
200  GLS_GLO_TEXT_CELL_HEIGHT,
201  GLS_GLO_TEXT_CELL_WIDTH,
202  GLS_GLO_TEXT_CONSTRAIN_CELL_RATIO,
203  GLS_GLO_TEXT_CONTROL_CELL_SIZE,
204  GLS_GLO_TEXT_FONT,
205  GLS_GLO_TEXT_HALO,
206  GLS_GLO_TEXT_LINESPACING,
207  GLS_GLO_TEXT_LOCK_CELL_SIZE,
208  GLS_GLO_TEXT_JUSTIFY,
209  GLS_GLO_TEXT_SHADOW,
210  GLS_GLO_TEXT_STRING,
211  GLS_GLO_TEXT_UPPERCASE,
212  GLS_GLO_TEXT_WRAP,
213  GLS_GLO_TEXT_HALO_COLOR,
214  GLS_GLO_TEXT_SHADOW_COLOR,
215  GLS_GLO_TEXT_SHADOW_DISTANCE,
216  GLS_GLO_TEXT_BASELINE,
217  GLS_GLO_TEXT_BG_COLOR,
218  GLS_GLO_TEXT_TEXT_COLOR,
219  GLS_GLO_TEXT_CHAR_SCALING,
220  GLS_GLO_TEXT_CHAR_SPACING,
221  GLS_GLO_TEXT_FAUX_BOLD,
222  GLS_GLO_TEXT_INVERSE,
223  GLS_GLO_TEXT_STRIKE_THRU,
224  GLS_GLO_TEXT_UNDERLINE,
225 
226  // From gltrimesh.h
227  GLS_GLO_TRIMESH_FIRST_VALUE,
228  GLS_GLO_TRIMESH_USE_DISPLAY_LIST,
229  GLS_GLO_TRIMESH_FACES,
230 
231  // From gls_3d_cable.h
232  GLS_GLO_3DCABLE_FIRST_VALUE,
233  GLS_GLO_3DCABLE_FLEXIBILITY,
234  GLS_GLO_3DCABLE_NUMBEROFSEGMENTS,
235  GLS_GLO_3DCABLE_NUMBEROFSIDES,
236  GLS_GLO_3DCABLE_RADIUS,
237  GLS_GLO_3DCABLE_LENGTH,
238  GLS_GLO_3DCABLE_GRAVITY,
239  GLS_GLO_3DCABLE_SECTIONSLACKPCT,
240  GLS_GLO_3DCABLE_SECTIONFLOORDIST,
241  GLS_GLO_3DCABLE_COLLISIONSTYLE,
242  GLS_GLO_3DCABLE_FILLCOLOR,
243  GLS_GLO_3DCABLE_LINECOLOR,
244 
245  // From gls_button.h
246  GLS_GLO_GLSBUTTON_CHANGE_CALLBACK,
247  GLS_GLO_GLSBUTTON_TOGGLE,
248  GLS_GLO_GLSBUTTON_WHICH_OBJ_POS_UP,
249  GLS_GLO_GLSBUTTON_WHICH_OBJ_POS_DOWN,
250  GLS_GLO_GLSBUTTON_STATE,
251  GLS_GLO_GLSBUTTON_EMIT_STATE_CHANGE_EVENT,
252 
253  // From gls_angular_scale.h
254  GLS_GLO_ANGULAR_SCALE_FIRST_VALUE,
255  GLS_GLO_ANGULAR_SCALE_RADII,
256  GLS_GLO_ANGULAR_SCALE_DECONFLICT_TICKS,
257  GLS_GLO_ANGULAR_SCALE_HALO_ENABLED,
258  GLS_GLO_ANGULAR_SCALE_HALO_WIDTH,
259  GLS_GLO_ANGULAR_SCALE_HALO_COLOR,
260  GLS_GLO_ANGULAR_SCALE_USE_SCALABLE_LINES,
261  GLS_GLO_ANGULAR_SCALE_RADIUS,
262  GLS_GLO_ANGULAR_SCALE_DATA,
263 
264  // From gls_clipping_group.h
265  GLS_GLO_CLIPPING_GROUP_STATE,
266  GLS_GLO_CLIPPING_GROUP_CLIPPING_ACTIVE,
267  GLS_GLO_CLIPPING_GROUP_BOTTOM_LEFT_CORNER,
268  GLS_GLO_CLIPPING_GROUP_TOP_RIGHT_CORNER,
269  GLS_GLO_CLIPPING_GROUP_SHOW_OUTLINE,
270 
271  // From gls_dynamic_path.h
272  GLS_GLO_DYNAMICPATH_FIRST_VALUE,
273  GLS_GLO_DYNAMICPATH_AFFECTS_LOCATION_X,
274  GLS_GLO_DYNAMICPATH_AFFECTS_LOCATION_Y,
275  GLS_GLO_DYNAMICPATH_AFFECTS_LOCATION_Z,
276  GLS_GLO_DYNAMICPATH_AFFECTS_ROTATION_X,
277  GLS_GLO_DYNAMICPATH_AFFECTS_ROTATION_Y,
278  GLS_GLO_DYNAMICPATH_AFFECTS_ROTATION_Z,
279  GLS_GLO_DYNAMICPATH_AFFECTS_SCALE_X,
280  GLS_GLO_DYNAMICPATH_AFFECTS_SCALE_Y,
281  GLS_GLO_DYNAMICPATH_AFFECTS_SCALE_Z,
282  GLS_GLO_DYNAMICPATH_USE_SHORT_ROTATION_PATHS,
283  GLS_GLO_DYNAMICPATH_STATE_COUNT,
284  GLS_GLO_DYNAMICPATH_STATE,
285 
286  // From gls_mutex_group.h
287  GLS_GLO_MUTEX_GROUP_STATE,
288  GLS_GLO_MUTEX_GROUP_CALC_INVISIBLE_STATES,
289  GLS_GLO_MUTEX_GROUP_PICK_INVISIBLE_STATES,
290  GLS_GLO_MUTEX_GROUP_PREDRAW_INVISIBLE_STATES,
291  GLS_GLO_MUTEX_GROUP_INPUT_DEVICE_BEHAVIOR,
292 
293  // From gls_multi_view.h
294  GLS_GLO_GLSMULTIVIEW_FIRST_VALUE,
295  GLS_GLO_GLSMULTIVIEW_VIEW_DATA,
296  GLS_GLO_GLSMULTIVIEW_VIEW_DRAWING_STATE,
297 
298  // From gls_linear_scale.h
299  GLS_GLO_LINEAR_SCALE_FIRST_VALUE,
300  GLS_GLO_LINEAR_SCALE_RADII,
301  GLS_GLO_LINEAR_SCALE_DECONFLICT_TICKS,
302  GLS_GLO_LINEAR_SCALE_HALO_ENABLED,
303  GLS_GLO_LINEAR_SCALE_HALO_WIDTH,
304  GLS_GLO_LINEAR_SCALE_HALO_COLOR,
305  GLS_GLO_LINEAR_SCALE_TICK_ANCHOR,
306  GLS_GLO_LINEAR_SCALE_USE_SCALABLE_LINES,
307  GLS_GLO_LINEAR_SCALE_DATA,
308 
309  // From gls_knob.h
310  GLS_GLO_GLSKNOB_CHANGE_CALLBACK,
311  GLS_GLO_GLSKNOB_ANGLERANGE,
312  GLS_GLO_GLSKNOB_CONTINUOUS,
313  GLS_GLO_GLSKNOB_POSITIONVAL,
314  GLS_GLO_GLSKNOB_DETENTPOSITIONS,
315  GLS_GLO_GLSKNOB_WHICHOBJECT,
316  GLS_GLO_GLSKNOB_STARTANGLE,
317  GLS_GLO_GLSKNOB_EMITDETENTVALEVENT,
318  GLS_GLO_GLSKNOB_EMITPOSITIONVALEVENT,
319  GLS_GLO_GLSKNOB_EMITLIMITEVENT,
320  GLS_GLO_GLSKNOB_EMITRELEASEEVENT,
321  GLS_GLO_GLSKNOB_SHOWDETENTSONLY,
322  GLS_GLO_GLSKNOB_CLICKSELECTSDETENT,
323 
324  // From gls_ellipse.h
325  GLS_GLO_ELLIPSE_FIRST_VALUE,
326  GLS_GLO_ELLIPSE_RADII,
327  GLS_GLO_ELLIPSE_THICKNESS,
328  GLS_GLO_ELLIPSE_SOLID,
329  GLS_GLO_ELLIPSE_INTERVAL,
330  GLS_GLO_ELLIPSE_START_ANGLE,
331  GLS_GLO_ELLIPSE_END_ANGLE,
332  GLS_GLO_ELLIPSE_COLOR,
333 
334  // From gls_switch.h
335  GLS_GLO_GLSSWITCH_INITIAL_DETENT_VAL,
336  GLS_GLO_GLSSWITCH_WHICH_OBJECT_BACKGROUND,
337  GLS_GLO_GLSSWITCH_FIRST_DETENT_SNAPBACK,
338  GLS_GLO_GLSSWITCH_LAST_DETENT_SNAPBACK,
339  GLS_GLO_GLSSWITCH_EMIT_DETENT_VAL_EVENT,
340  GLS_GLO_GLSSWITCH_EMIT_LIMIT_EVENT,
341  GLS_GLO_GLSSWITCH_EMIT_RELEASE_EVENT,
342 
343  // From gls_thumb_wheel.h
344  GLS_GLO_GLSTHUMBWHEEL_INITIAL_VAL,
345  GLS_GLO_GLSTHUMBWHEEL_EMIT_DETENT_VAL_EVENT,
346  GLS_GLO_GLSTHUMBWHEEL_EMIT_LIMIT_EVENT,
347  GLS_GLO_GLSTHUMBWHEEL_EMIT_RELEASE_EVENT,
348  GLS_GLO_GLSTHUMBWHEEL_NUMBER_OF_DETENTS,
349  GLS_GLO_GLSTHUMBWHEEL_CONTINUOUS_DRAG,
350  GLS_GLO_GLSTHUMBWHEEL_DETENT_VAL,
351  GLS_GLO_GLSTHUMBWHEEL_WHICH_OBJECT_THUMBWHEEL,
352  GLS_GLO_GLSTHUMBWHEEL_WHICH_OBJECT_ODOMETER,
353  GLS_GLO_GLSTHUMBWHEEL_SOUND_INDEX,
354 
355  // From gls_text_grid.h
356  GLS_GLO_TEXT_GRID_SIZE,
357  GLS_GLO_TEXT_GRID_LEFT_TO_RIGHT,
358 
359  // From gls_schematic_tee_interconnect.h
360  GLS_GLO_SCHEMATICTEEINTERCONNECT_FIRST_VALUE,
361  GLS_GLO_SCHEMATICTEEINTERCONNECT_LEFT_LINE_THICKNESS,
362  GLS_GLO_SCHEMATICTEEINTERCONNECT_RIGHT_LINE_THICKNESS,
363  GLS_GLO_SCHEMATICTEEINTERCONNECT_BASE_LINE_THICKNESS,
364  GLS_GLO_SCHEMATICTEEINTERCONNECT_LEFT_INTERCONNECT_TEXTURE_INDEX,
365  GLS_GLO_SCHEMATICTEEINTERCONNECT_RIGHT_INTERCONNECT_TEXTURE_INDEX,
366  GLS_GLO_SCHEMATICTEEINTERCONNECT_BASE_INTERCONNECT_TEXTURE_INDEX,
367  GLS_GLO_SCHEMATICTEEINTERCONNECT_LEFT_INTERCONNECT_TEXTURE_REPEAT_LENGTH,
368  GLS_GLO_SCHEMATICTEEINTERCONNECT_RIGHT_INTERCONNECT_TEXTURE_REPEAT_LENGTH,
369  GLS_GLO_SCHEMATICTEEINTERCONNECT_BASE_INTERCONNECT_TEXTURE_REPEAT_LENGTH,
370  GLS_GLO_SCHEMATICTEEINTERCONNECT_LEFT_FLOW_TEXTURE_INDEX,
371  GLS_GLO_SCHEMATICTEEINTERCONNECT_RIGHT_FLOW_TEXTURE_INDEX,
372  GLS_GLO_SCHEMATICTEEINTERCONNECT_BASE_FLOW_TEXTURE_INDEX,
373  GLS_GLO_SCHEMATICTEEINTERCONNECT_LEFT_FLOW_TEXTURE_REPEAT_LENGTH,
374  GLS_GLO_SCHEMATICTEEINTERCONNECT_RIGHT_FLOW_TEXTURE_REPEAT_LENGTH,
375  GLS_GLO_SCHEMATICTEEINTERCONNECT_BASE_FLOW_TEXTURE_REPEAT_LENGTH,
376  GLS_GLO_SCHEMATICTEEINTERCONNECT_LEFT_SHOW_FLOW,
377  GLS_GLO_SCHEMATICTEEINTERCONNECT_RIGHT_SHOW_FLOW,
378  GLS_GLO_SCHEMATICTEEINTERCONNECT_BASE_SHOW_FLOW,
379  GLS_GLO_SCHEMATICTEEINTERCONNECT_LEFT_FLOW_RATE,
380  GLS_GLO_SCHEMATICTEEINTERCONNECT_RIGHT_FLOW_RATE,
381  GLS_GLO_SCHEMATICTEEINTERCONNECT_BASE_FLOW_RATE,
382  GLS_GLO_SCHEMATICTEEINTERCONNECT_LEFT_SHOW_FLOW_BLINK,
383  GLS_GLO_SCHEMATICTEEINTERCONNECT_RIGHT_SHOW_FLOW_BLINK,
384  GLS_GLO_SCHEMATICTEEINTERCONNECT_BASE_SHOW_FLOW_BLINK,
385  GLS_GLO_SCHEMATICTEEINTERCONNECT_LEFT_FLOW_BLINK_RATE,
386  GLS_GLO_SCHEMATICTEEINTERCONNECT_RIGHT_FLOW_BLINK_RATE,
387  GLS_GLO_SCHEMATICTEEINTERCONNECT_BASE_FLOW_BLINK_RATE,
388  GLS_GLO_SCHEMATICTEEINTERCONNECT_LEFT_FLOW_BLINK_START_COLOR,
389  GLS_GLO_SCHEMATICTEEINTERCONNECT_RIGHT_FLOW_BLINK_START_COLOR,
390  GLS_GLO_SCHEMATICTEEINTERCONNECT_BASE_FLOW_BLINK_START_COLOR,
391  GLS_GLO_SCHEMATICTEEINTERCONNECT_LEFT_FLOW_BLINK_END_COLOR,
392  GLS_GLO_SCHEMATICTEEINTERCONNECT_RIGHT_FLOW_BLINK_END_COLOR,
393  GLS_GLO_SCHEMATICTEEINTERCONNECT_BASE_FLOW_BLINK_END_COLOR,
394  GLS_GLO_SCHEMATICTEEINTERCONNECT_USE_DISPLAY_LIST,
395  GLS_GLO_SCHEMATICTEEINTERCONNECT_TOP_VISIBLE,
396  GLS_GLO_SCHEMATICTEEINTERCONNECT_TOP_LINE_THICKNESS,
397  GLS_GLO_SCHEMATICTEEINTERCONNECT_TOP_INTERCONNECT_TEXTURE_INDEX,
398  GLS_GLO_SCHEMATICTEEINTERCONNECT_TOP_INTERCONNECT_TEXTURE_REPEAT_LENGTH,
399  GLS_GLO_SCHEMATICTEEINTERCONNECT_TOP_FLOW_TEXTURE_INDEX,
400  GLS_GLO_SCHEMATICTEEINTERCONNECT_TOP_FLOW_TEXTURE_REPEAT_LENGTH,
401  GLS_GLO_SCHEMATICTEEINTERCONNECT_TOP_SHOW_FLOW,
402  GLS_GLO_SCHEMATICTEEINTERCONNECT_TOP_FLOW_RATE,
403  GLS_GLO_SCHEMATICTEEINTERCONNECT_TOP_SHOW_FLOW_BLINK,
404  GLS_GLO_SCHEMATICTEEINTERCONNECT_TOP_FLOW_BLINK_RATE,
405  GLS_GLO_SCHEMATICTEEINTERCONNECT_TOP_FLOW_BLINK_START_COLOR,
406  GLS_GLO_SCHEMATICTEEINTERCONNECT_TOP_FLOW_BLINK_END_COLOR,
407 
408  // From gls_schematic_polyline_interconnect.h
409  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_FIRST_VALUE,
410  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_ORIENTATION,
411  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_LINE_THICKNESS,
412  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_ROUNDED_CORNERS,
413  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_CORNER_RADIUS,
414  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_FORCE_EXACT_CORNER_RADIUS,
415  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_CORNER_SEGMENTS,
416  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_INTERCONNECT_TEXTURE_REPEAT_LENGTH,
417  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_FLOW_TEXTURE_INDEX,
418  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_FLOW_TEXTURE_REPEAT_LENGTH,
419  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_SHOW_FLOW,
420  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_FLOW_RATE,
421  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_SHOW_FLOW_BLINK,
422  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_FLOW_BLINK_RATE,
423  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_FLOW_BLINK_START_COLOR,
424  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_FLOW_BLINK_END_COLOR,
425  GLS_GLO_SCHEMATICPOLYLINEINTERCONNECT_USE_DISPLAY_LIST,
426 
427  // From gls_poly_line.h
428  GLS_GLO_POLY_LINE_FIRST_VALUE,
429  GLS_GLO_POLY_LINE_THICKNESS,
430  GLS_GLO_POLY_LINE_HALO,
431  GLS_GLO_POLY_LINE_HALO_COLOR,
432  GLS_GLO_POLY_LINE_HALO_THICKNESS,
433  GLS_GLO_POLY_LINE_NORMAL,
434 
435  // From gls_path_manager.h
436  GLS_GLO_PATHMANAGER_FIRST_VALUE,
437  GLS_GLO_PATHMANAGER_PATHOBJPAIR_COUNT,
438  GLS_GLO_PATHMANAGER_PATHOBJPAIR,
439 
440  // From gls_odometer.h
441  GLS_GLO_GLSODOMETER_VALUE,
442  GLS_GLO_GLSODOMETER_MIN_VALUE,
443  GLS_GLO_GLSODOMETER_MAX_VALUE,
444  GLS_GLO_GLSODOMETER_BASE_SYSTEM,
445  GLS_GLO_GLSODOMETER_BEHAVIOR_TYPE,
446  GLS_GLO_GLSODOMETER_GEOMETRY_TYPE,
447  GLS_GLO_GLSODOMETER_TEXTURE_SCALE,
448  GLS_GLO_GLSODOMETER_DEGREES_PER_DIGIT,
449  GLS_GLO_GLSODOMETER_ORDER_OF_MAGNITUDE,
450  GLS_GLO_GLSODOMETER_ROLLOVER_THRESHOLD,
451 
452  // From gls_nurb_curve.h
453  GLS_GLO_GLSNURBCURVE_FIRST_VALUE,
454  GLS_GLO_GLSNURBCURVE_EMITEVENT,
455 
456  // From gls_nine_patch.h
457  GLS_GLO_NINE_PATCH_FIRST_VALUE,
458  GLS_GLO_NINE_PATCH_CENTER_VISIBLE,
459  GLS_GLO_NINE_PATCH_EDGES,
460  GLS_GLO_NINE_PATCH_TEXTURE_EDGES,
461  GLS_GLO_NINE_PATCH_RADII,
462  GLS_GLO_NINE_PATCH_TEXTURE_POINTS,
463  GLS_GLO_NINE_PATCH_COLOR,
464 
465  // From serial_morph_mesh.h
466  GLS_GLO_SERIAL_MORPH_MESH_KEYFRAME_INDEX,
467 
468  // From gls_geometry_resource_mesh.h
469  GLS_GLO_GEOMETRY_RESOURCE_MESH_DATA,
470  GLS_GLO_GEOMETRY_RESOURCE_MESH_TRANSFORM,
471  GLS_GLO_GEOMETRY_RESOURCE_MESH_REFERENCE,
472  GLS_GLO_GEOMETRY_RESOURCE_MESH_INDEX_BUF_EFFECTS,
473 
474  // From gls_lod_group.h
475  GLS_GLO_LOD_GROUP_DISTANCE_RANGE,
476  GLS_GLO_LOD_GROUP_LOD_POSITIONS,
477 
478  // From gls_text_box.h
479  GLS_GLO_TEXT_BOX_VERTICAL_ALIGNMENT,
480  GLS_GLO_TEXT_BOX_LEFT_TO_RIGHT,
481  GLS_GLO_TEXT_BOX_RESIZE_MODE,
482  GLS_GLO_TEXT_BOX_MAX_WIDTH,
483  GLS_GLO_TEXT_BOX_MAX_HEIGHT,
484 
485  // From gls_ctl_text_box.h
486  GLS_GLO_CTL_TEXT_BOX_VERTICAL_ALIGNMENT,
487  GLS_GLO_CTL_TEXT_BOX_ELLIPSIZE_MODE,
488  GLS_GLO_CTL_TEXT_BOX_HORIZONTAL_SCALE,
489  GLS_GLO_CTL_TEXT_BOX_VERTICAL_SCALE,
490  GLS_GLO_CTL_TEXT_BOX_TEXT_DIRECTION,
491  GLS_GLO_CTL_TEXT_BOX_RESIZE_MODE,
492  GLS_GLO_CTL_TEXT_BOX_MAX_WIDTH,
493  GLS_GLO_CTL_TEXT_BOX_MAX_HEIGHT,
494 
495  // From gls_linear_float_controller.h
496  GLS_GLO_LINEAR_FLOAT_CONTROLLER_KEYARRAY,
497 
498  // From gls_moving_eye.h
499  GLS_GLO_MOVINGEYE_EMIT_EVENT,
500  GLS_GLO_MOVINGEYE_LOOK_AT_OBJECT,
501  GLS_GLO_MOVINGEYE_MAX_SPEED,
502  GLS_GLO_MOVINGEYE_MOVEMENT,
503  GLS_GLO_MOVINGEYE_ROUTE,
504  GLS_GLO_MOVINGEYE_DISABLE_HISTORY,
505 
506  // From gls_mimic_group.h
507  GLS_GLO_MIMIC_GROUP_MIMIC_ACTIVE,
508  GLS_GLO_MIMIC_GROUP_AUTO_REDRAW,
509  GLS_GLO_MIMIC_GROUP_BOTTOM_LEFT_CORNER,
510  GLS_GLO_MIMIC_GROUP_TOP_RIGHT_CORNER,
511  GLS_GLO_MIMIC_GROUP_SHOW_OUTLINE,
512  GLS_GLO_MIMIC_GROUP_TEXTURE_HEIGHT,
513  GLS_GLO_MIMIC_GROUP_TEXTURE_WIDTH,
514  GLS_GLO_MIMIC_GROUP_HAS_DEPTH_BUFFER,
515  GLS_GLO_MIMIC_GROUP_DEPTH_TEST,
516  GLS_GLO_MIMIC_GROUP_GENERATE_MIPMAPS,
517  GLS_GLO_MIMIC_GROUP_DRAW_MIMIC_POLYGON,
518  GLS_GLO_MIMIC_GROUP_ATTACHED_TEXTURE_INDEX,
519  GLS_GLO_MIMIC_GROUP_CLEAR_COLOR,
520  GLS_GLO_MIMIC_GROUP_USE_OPAQUE_TEXTURE,
521 
522  GLS_GLO_TEXT_SHADOW_OFFSET
523  };
524 
525  static const unsigned int MAX_STANDARD_ATTR_SIZE = 255;
526  static const unsigned int ATTR_SIZE_EXTENDED = 0;
527 
529  {
530  char magic[ 4 ]; // 'GLO\0'
531  int glsMajor; // GL Studio major version
532  int glsMinor; // GL Studio minor version
533  int glsBuild; // GL Studio build version
534  unsigned int numObjects; // Number of objects in this file
535  unsigned char timestamp[ GLO_FILE_TIMESTAMP_SIZE ]; // Time signature for this file
536  char padding[ 2 ];
537  };
538 
539  enum
540  {
541  TEXTURE_PRESENT = 0x01,
542  MATERIAL_PRESENT = 0x02
543  };
544 
546  {
547  unsigned int numberOfFaces; // Number of faces in the array
548  int defaultTexture; // Default texture for faces if none present in file
549  unsigned int defaultMaterial; // Default materia for faces if none present in file
550  unsigned char indexSize; // Size of each index in bytes (a,b,c)
551  unsigned char textureSize; // Size of texture index in bytes
552  unsigned char materialSize; // Size of material index in bytes
553  unsigned char componentsPresent; // bitfield
554  // 0x01 Textures present in file
555  // 0x02 Materials present in file
556  };
557 
558  /** The current version of the GlsGeometryResourceData. */
559  static const int GlsGeometryResourceData_Version = 2;
560 
562  {
563  unsigned int version; // Should be GlsGeometryResourceData_Version
564  unsigned int vertexSize; // Size of a single vertex (in bytes)
565  unsigned int numberOfVertices; // Size of the vertex array
566  unsigned int numberOfIndexBuffers; // Number of index buffers
567 
568  unsigned char numberOfTextureCoords; // Number of texture coords
569  unsigned char numberOfVertexAttribs; // Number of vertex attributes
570  bool hasNormal;
571  bool hasColor;
572 
573  bool hasSecondaryColor;
574  bool hasTangentAttrib;
575  unsigned char tangentAttribIndex;
576  bool hasBinormalAttrib;
577 
578  unsigned char binormalAttribIndex;
579  unsigned char padding1;
580  unsigned short padding2;
581 
582  // The structure is followed by:
583  // numberOfVertices vertex data structures (vertexSize*numberOfVertices bytes)
584  // numberOfIndexBuffers index buffer arrays
585  // Each index buffer array looks like this
586  // unsigned int size;
587  // <list of unsigned ints (size*4 bytes)>
588  };
589 
590  // The current version of the GlsGeometryResourceMeshIndexBufEffects
591  static const int GlsGeometryResourceMeshIndexBufEffects_Version = 2;
592 
594  {
595  unsigned int version; // Should be GlsGeometryResourceData_Version
596  unsigned int effectCount; // Number of effects
597 
598  // The header is followed <effectCount> GlsGeometryResourceMeshIndexBufEffect structures
599  };
600 
602  {
603  unsigned int materialIndex;
604  unsigned int diffuseTextureIndex;
605  unsigned int normalTextureIndex;
606  unsigned int specularTextureIndex;
607  unsigned int reflectionTextureIndex;
608 
609  // new for v2
610  float diffuseAmount;
611  float normalAmount;
612  float specularAmount;
613  float reflectionAmount;
614 
615  bool useVertexColors;
616  bool normalMapFlipGreen;
617  unsigned short padding; // just
618 
619  // diffuse UVW settings
620  float diffuse_uOffset;
621  float diffuse_vOffset;
622  float diffuse_uTiling;
623  float diffuse_vTiling;
624  float diffuse_angle;
625  // normal UVW settings
626  float normal_uOffset;
627  float normal_vOffset;
628  float normal_uTiling;
629  float normal_vTiling;
630  float normal_angle;
631  // specular UVW settings
632  float specular_uOffset;
633  float specular_vOffset;
634  float specular_uTiling;
635  float specular_vTiling;
636  float specular_angle;
637  };
638 
639  class Writer
640  {
641  public:
642  static const unsigned int MAX_STANDARD_ATTR_SIZE = 255;
643 
644  static const unsigned int ATTR_SIZE_EXTENDED = 0;
645 
646  // Create a GLO file writer for the given file
647  Writer( const std::string& filename, const bool open, const unsigned char* timestamp );
648 
649  // Destroy the writer
650  ~Writer();
651 
652  std::string Filename();
653 
654  std::string BaseFilename();
655 
656  inline unsigned char* Timestamp() { return _header.timestamp; }
657 
658  // Open file and prepare to write
659  void OpenForWriting( void );
660 
661  void DefaultChecking( bool val ) { _defaultChecking = val; }
662 
663  // Start writing an object record
664  void StartObjectRecord( void );
665 
666  // Add an object attribute to the file for the current object
667  void AddObjectAttribute( const unsigned int enumeration, const unsigned int size, const void* data );
668 
669  // Methods to add parameters to file
670  void AddBoolean( const unsigned int enumerator, const bool value );
671  void AddU8( const unsigned int enumerator, const unsigned char value );
672  void AddU16( const unsigned int enumerator, const unsigned short value );
673  void AddS16( const unsigned int enumerator, const short value );
674  void AddU32( const unsigned int enumerator, const unsigned int value );
675  void AddS32( const unsigned int enumerator, const int value );
676  void AddString( const unsigned int enumerator, const std::string& value );
677  void AddCString( const unsigned int enumerator, const char* value );
678  void AddFloat( const unsigned int enumerator, const float value );
679  void AddDouble( const unsigned int enumerator, const double value );
680  void AddVector( const unsigned int enumerator, const Vector& value );
681  void AddGlsColor( const unsigned int enumerator, const glsColor& value );
682  void AddMatrix( const unsigned int enumerator, const GlsMatrixAffineD& value );
683  void AddVertexArray( const unsigned int enumerator, const unsigned int nVertices, const Vertex verts[] );
684  void AddVectorArray( const unsigned int enumerator, const unsigned int nVertices, const Vector verts[] );
685  void AddFloatArray( const unsigned int enumerator, const unsigned int nVertices, const float verts[] );
686  void AddDoubleArray( const unsigned int enumerator, const unsigned int nVertices, const double verts[] );
687  void AddMaterialIndices( const unsigned int enumerator, DynamicArray<int>& values );
688 
689  // Same as AddVectorArray but only writes X & Y coordinates
690  void AddVector2DArray( const unsigned int enumerator, const unsigned int nVertices, const Vector verts[] );
691 
692  // Use these to write custom data structures to the file
693  unsigned int AddExtendedAttributeHeader( unsigned int enumerator, unsigned int size = 0 );
694  unsigned int AddAttributeHeader( unsigned int enumerator, unsigned char size = 0 );
695 
696  // Methods to add parameters to file, but check for value = default
697  void AddBoolean( const unsigned int enumerator, const bool value, const bool defVal );
698  void AddU8( const unsigned int enumerator, const unsigned char value, const unsigned char defVal );
699  void AddU16( const unsigned int enumerator, const unsigned short value, const unsigned short defVal );
700  void AddS16( const unsigned int enumerator, const short value, const short defVal );
701  void AddU32( const unsigned int enumerator, const unsigned int value, const unsigned int defVal );
702  void AddS32( const unsigned int enumerator, const int value, const int defVal );
703  void AddGlsColor( const unsigned int enumerator, const glsColor& value, const glsColor& defVal );
704  void AddFloat( const unsigned int enumerator, const float value, const float defVal );
705  void AddDouble( const unsigned int enumerator, const double value, const double defVal );
706 
707  // Writes data to file. Doesn't write attribute headers, just writes straight data
708  // Data is byte swapped into Big Endian format
709  void WriteU8( const unsigned char val );
710  void WriteS8( const char val );
711  void WriteU16( const unsigned short val );
712  void WriteS16( const short val );
713  void WriteU32( const unsigned int val );
714  void WriteS32( const int val );
715  void WriteFloat( const float val );
716  void WriteDouble( const double val );
717  void WriteGlsColor( const glsColor& value );
718 
719  // Writes data to file. Doesn't write attribute headers, just writes straight data
720  // Data is byte swapped into Big Endian format. Writes at the specified offset
721  void WriteU8( const unsigned char val, const unsigned int offset );
722  void WriteU32( const unsigned int val, const unsigned int offset );
723 
724  // Method to add matrix, but only if it isn't identity
725  void AddMatrix( const unsigned int enumerator, const GlsMatrixAffineD& value, const bool checkForIdentity );
726 
727  // End the current object record
728  void EndObjectRecord();
729 
730  // Flush the current buffer to disk and rewind
731  void Flush();
732 
733  // Close the file
734  void Close( void );
735 
736  protected:
737  std::string _filename;
738  bool _initialized;
739  FILE* _out;
740  bool _defaultChecking;
741  unsigned char _timestamp[ GLO_FILE_TIMESTAMP_SIZE ];
742  GloFileHeader _header;
743 
744  // Current count of the number of objects in the file
745  unsigned int _numObjects;
746 
747  // Current count of the number of params in the current object
748  short _numParams;
749 
750  // Byte buffer to store params in
751  WriteBuffer* _buffer;
752 
753  void WriteFileHeader();
754  };
755 
756  class Reader
757  {
758  public:
759  /** Do not bother caching GLO files that are larger than 1 MB. */
760  static const unsigned int GLO_SIZE_CACHING_LIMIT = 1024 * 1024;
761 
762  // Create a GLO file reader for the given file
763  Reader( const std::string& filename, const bool open );
764 
765  // Destroy the reader
766  ~Reader( void );
767 
768  // Open file and prepare to read
769  bool OpenForReading( void );
770 
771  // Get the number of object records in this file
772  unsigned int GetNumberOfObjectRecords() { return _header.numObjects; }
773 
774  unsigned int GetGLStudioVersionMajor() { return _header.glsMajor; }
775  unsigned int GetGLStudioVersionMinor() { return _header.glsMinor; }
776  unsigned int GetGLStudioBuildNumber() { return _header.glsBuild; }
777 
778  unsigned char* GetTimestamp() { return _header.timestamp; }
779 
780  // Close the file
781  void Close( void );
782 
783  // Data retrieval methods.
784  std::string GetString( const unsigned int size )
785  {
786  std::string retval( _fileDataPointer );
787  _fileDataPointer += size;
788  return retval;
789  }
790 
791  bool GetBoolean()
792  {
793  bool data = false;
794  memcpy( &data, _fileDataPointer, sizeof( bool ) );
795  _fileDataPointer += sizeof( bool );
796  return data;
797  }
798 
799  char GetByte()
800  {
801  char data = 0;
802  memcpy( &data, _fileDataPointer, sizeof( char ) );
803  _fileDataPointer += sizeof( char );
804  return data;
805  }
806 
807  unsigned char GetUnsignedByte()
808  {
809  unsigned char data = 0u;
810  memcpy( &data, _fileDataPointer, sizeof( unsigned char ) );
811  _fileDataPointer += sizeof( unsigned char );
812  return data;
813  }
814 
815  short GetShort()
816  {
817  short data = 0;
818  memcpy( &data, _fileDataPointer, sizeof( short ) );
819  _fileDataPointer += sizeof( short );
820  return data;
821  }
822 
823  unsigned short GetUnsignedShort()
824  {
825  unsigned short data = 0u;
826  memcpy( &data, _fileDataPointer, sizeof( unsigned short ) );
827  _fileDataPointer += sizeof( unsigned short );
828  return data;
829  }
830 
831  int GetInt()
832  {
833  int data = 0;
834  memcpy( &data, _fileDataPointer, sizeof( int ) );
835  _fileDataPointer += sizeof( int );
836  return data;
837  }
838 
839  unsigned int GetUnsignedInt()
840  {
841  unsigned int data = 0u;
842  memcpy( &data, _fileDataPointer, sizeof( unsigned int ) );
843  _fileDataPointer += sizeof( unsigned int );
844  return data;
845  }
846 
847  float GetFloat()
848  {
849  float data = 0.0f;
850  memcpy( &data, _fileDataPointer, sizeof( float ) );
851  _fileDataPointer += sizeof( float );
852  return data;
853  }
854 
855  double GetDouble()
856  {
857  double data = 0.0;
858  memcpy( &data, _fileDataPointer, sizeof( double ) );
859  _fileDataPointer += sizeof( double );
860  return data;
861  }
862 
863  void GetBytes( const unsigned int size, char** data )
864  {
865  memcpy( *data, _fileDataPointer, size );
866  _fileDataPointer += size;
867  }
868 
869  glsColor GetColor()
870  {
871  glsColor data = glsColor();
872  memcpy( &data, _fileDataPointer, sizeof( glsColor ) );
873  _fileDataPointer += sizeof( glsColor );
874  return data;
875  }
876 
877  DynamicArray<int> GetMaterialIndices()
878  {
879  unsigned int count = (unsigned int)GetInt();
880  DynamicArray<int> materialIndices( count );
881  for( unsigned int i = 0; i < count; i++ )
882  {
883  materialIndices.PushBack( GetInt() );
884  }
885  return materialIndices;
886  }
887 
888  bool IsInitialized() { return _initialized; }
889 
890  const std::string& GetFilename() { return _filename; }
891 
892  protected:
893  std::string _filename;
894  bool _initialized;
895  FILE* _in;
896  unsigned int _numberOfObjectRecords;
897  unsigned int _glsMajor;
898  unsigned int _glsMinor;
899  unsigned int _glsBuild;
900  unsigned char _timestamp[ GLO_FILE_TIMESTAMP_SIZE ];
901  GloFileHeader _header;
902  char* _fileData;
903  const char* _fileDataPointer;
904  };
905 
907  {
908  public:
909  WriteBuffer( const unsigned int initialSize );
910 
911  ~WriteBuffer();
912 
913  // Ensure the buffer is at least the specified size
914  void Resize( const unsigned int minimumSize );
915 
916  // Enlarge buffer by at least incrementalSize
917  void Enlarge( const unsigned int incrementalSize );
918 
919  // Get the buffer pointer
920  unsigned char* Buffer();
921 
922  // Get the current buffer size
923  unsigned int Size();
924 
925  // Write data to the buffer at the current offset, moving the
926  // current write position
927  void WriteData( const void* data, const unsigned int size );
928 
929  // Write data to the buffer at a specific offset, not moving the
930  // current write position
931  void WriteData( const void* data, const unsigned int size, const unsigned int offset );
932 
933  // Rewind to beginning of buffer
934  void Rewind();
935 
936  protected:
937  // Total size of the params for the current object
938  unsigned int _current;
939 
940  // Size of the param buffer
941  unsigned int _bufSize;
942 
943  // Buffer containing the params for the current object
944  unsigned char* _buf;
945  };
946 
948  {
949  public:
950  ObjectData( Reader* reader );
951 
952  ~ObjectData();
953 
954  void SetNumAttributes( const short numAttributes )
955  {
956  _numAttributes = numAttributes;
957  }
958 
959  bool HasAttributes()
960  {
961  return ( _numAttributes > 0 );
962  }
963 
964  GlsGloFileAttribute* GetNextAttribute();
965 
966  private:
967  Reader* _reader;
968  short _numAttributes;
969  GlsGloFileAttribute* _glsGloFileAttribute;
970  };
971 
972  // constructor - throws GlsGloFileNotFoundException if glow file isn't found.
973  GLSGEN_GlsGloFile_EXPORT GlsGloFile( const std::string& filename, const bool readMode = true );
974  GLSGEN_GlsGloFile_EXPORT ~GlsGloFile();
975  ObjectData* GetNextObject();
976  GLSGEN_GlsGloFile_EXPORT void VerifyTimestamp( const unsigned char* timestamp, const char* className );
977 
978 protected:
979  Reader* _reader;
980  int _numObjectsRemaining;
981  ObjectData* _objectData;
982 
983  // Stores the name of the file that we're reading; currently only used to make the error
984  // messages more intelligent.
985  std::string _filename;
986 };
987 
989 {
990 public:
992  : _reader( reader )
993  , _enumeration( 0 )
994  , _size( 0 )
995  {
996  }
997 
999  {
1000  }
1001 
1002  void SetEnumeration( const unsigned int enumeration )
1003  {
1004  _enumeration = enumeration;
1005  }
1006 
1007  void SetSize( const unsigned int size )
1008  {
1009  _size = size;
1010  }
1011 
1012  // Data Retrieval Methods
1013  unsigned int Enumeration()
1014  {
1015  return _enumeration;
1016  }
1017  unsigned int Size()
1018  {
1019  return _size;
1020  }
1021 
1022  std::string GetString()
1023  {
1024  return _reader->GetString( _size );
1025  }
1026 
1027  void GetVector( Vector& rval )
1028  {
1029  rval.x = _reader->GetFloat();
1030  rval.y = _reader->GetFloat();
1031  rval.z = _reader->GetFloat();
1032  }
1033  void GetVertex( Vertex& rval )
1034  {
1035  rval.x = _reader->GetFloat();
1036  rval.y = _reader->GetFloat();
1037  rval.z = _reader->GetFloat();
1038  rval.color.R( _reader->GetUnsignedByte() );
1039  rval.color.G( _reader->GetUnsignedByte() );
1040  rval.color.B( _reader->GetUnsignedByte() );
1041  rval.color.A( _reader->GetUnsignedByte() );
1042  }
1043 
1044  glsColor GetColor()
1045  {
1046  return _reader->GetColor();
1047  }
1048 
1049  void GetColor( glsColor& rval )
1050  {
1051  // Call the assignment version of this overload.
1052  rval = GetColor();
1053  }
1054 
1055  bool GetBoolean()
1056  {
1057  return _reader->GetBoolean();
1058  }
1059 
1060  char GetByte()
1061  {
1062  return _reader->GetByte();
1063  }
1064 
1065  unsigned char GetUnsignedByte()
1066  {
1067  return _reader->GetUnsignedByte();
1068  }
1069 
1070  short GetShort()
1071  {
1072  return _reader->GetShort();
1073  }
1074 
1075  unsigned short GetUnsignedShort()
1076  {
1077  return _reader->GetUnsignedShort();
1078  }
1079 
1080  int GetInt()
1081  {
1082  return _reader->GetInt();
1083  }
1084 
1085  unsigned int GetUnsignedInt()
1086  {
1087  return _reader->GetUnsignedInt();
1088  }
1089 
1090  float GetFloat()
1091  {
1092  return _reader->GetFloat();
1093  }
1094 
1095  double GetDouble()
1096  {
1097  return _reader->GetDouble();
1098  }
1099 
1100  char* GetBytes()
1101  {
1102  char* rval = new char[ _size ];
1103  _reader->GetBytes( _size, &rval );
1104  return rval;
1105  }
1106 
1107  DynamicArray<int> GetMaterialIndices()
1108  {
1109  return _reader->GetMaterialIndices();
1110  }
1111 
1112  void GetBytes( const unsigned int size, void* data )
1113  {
1114  _reader->GetBytes( size, (char**)&data );
1115  }
1116 
1117 private:
1118  GlsGloFile::Reader* _reader;
1119  unsigned int _enumeration;
1120  unsigned int _size;
1121 };
1122 
1123 // Byte swapping functions used by this class.
1124 float SwapFloatToNet( float val );
1125 double SwapDoubleToNet( double val );
1126 unsigned int SwapLongToNet( unsigned int val );
1127 unsigned int SwapSignedLongToNet( int val );
1128 unsigned short SwapShortToNet( unsigned short val );
1129 short SwapSignedShortToNet( short val );
1130 
1131 } // namespace disti
1132 
1133 #endif
GlsColor glsColor
Alias for backwards compatibility.
Definition: gls_color.h:272
Definition: gls_glo_file.h:906
Definition: vertex.h:409
unsigned char R(void) const
Definition: gls_color.h:208
The disti::DynamicArray class. A templated array of objects capable of dynamically growing...
unsigned char B(void) const
Definition: gls_color.h:214
Definition: gls_glo_file.h:77
The GlsMatrixAffine class.
A file for all GL Studio files to include.
Definition: gls_glo_file.h:988
Definition: gls_glo_file.h:947
Definition: gls_glo_file.h:545
Definition: gls_glo_file.h:81
static const unsigned int GLO_FILE_TIMESTAMP_SIZE
Definition: gls_glo_file.h:90
The disti::Vertex class. A class for manipulating 3D vertices.
unsigned char G(void) const
Definition: gls_color.h:211
Definition: gls_glo_file.h:756
Definition: gls_color.h:53
Definition: gls_glo_file.h:639
static const unsigned int GLO_SIZE_CACHING_LIMIT
Definition: gls_glo_file.h:760
The disti::DisplayFrame class.
Definition: gls_glo_file.h:528
Definition: vertex.h:84
unsigned char A(void) const
Definition: gls_color.h:217
Definition: bmpimage.h:46
static const int GlsGeometryResourceData_Version
Definition: gls_glo_file.h:559