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