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