GL Studio SCECpp Runtime Library
gls_triangle_mesh.h
Go to the documentation of this file.
1 #ifndef _GLS_TRIANGLE_MESH_H
2 #define _GLS_TRIANGLE_MESH_H
3 
4 /*! \file gls_triangle_mesh.h
5 
6 \brief This header defines the GlsTriangleMesh class
7  in the GL Studio DO-178B Runtime Library.
8 
9 \par Copyright Information
10 Copyright (C) 1999-2012 The DiSTI Corporation<br>
11 Orlando, FL USA<br>
12 All rights reserved.<br>
13 
14  This file is copyrighted software and contains proprietary trade secrets of
15 DiSTI, and embodies substantial creative efforts as well as confidential
16 information, ideas, and expressions.
17 
18  Permission to use, and copy this software and its documentation for any
19 purpose is hereby granted per the Distribution Agreement and/or the Licensing
20 Agreement signed with DiSTI. This permission is granted provided that:
21  1. The above copyright notice appears in all copies.
22  2. That both the copyright notice and this permission notice appear in
23  the supporting documentation.
24  3. That the names DiSTI and GL Studio not be used in advertising or
25  publicity pertaining to distribution of the software without specific,
26  written prior permission of DiSTI.
27 
28  Permission to modify the software is granted, but not the right to
29 distribute the source code whether modified, or non-modified. Modifying the
30 software might invalidate the DO-178B certification package.
31 
32  Permission to distribute binaries produced by compiling source code, or
33 modified source code is granted, provided you:
34  1. Provide your name and address as the primary contact for the support
35  of your modified version.
36  2. Retain our contact information in regard to use of the base software.
37 
38  DiSTI does not provide warranty for this software or guarantee that it
39 satisfies any specification or requirement unless otherwise stated in a
40 specific contractual arrangement between the customer and DiSTI.
41 
42 */
43 
44 #include "gls_include.h"
45 #include "gls_render_object.h"
46 #include "gls_vertex.h"
48 #include "gls_state_manager.h"
49 #include "gls_class_invariant.h"
50 
51 /** This class encapsulates a mesh of triangle faces.
52  * \invariant base class invariant holds,
53  * GLS_NULL != _faces, _numFaces > 0u,
54  * _vertices invariant holds,
55  * for each element in _faces:
56  * v1,v2,v3 < _vertices.GetSize(),
57  * textureIndex < _texturePalette.GetSize()
58  */
60 {
61 public:
63 
64  /** describes a single triangle face in the mesh */
65  struct TriangleFace
66  {
67  GlsUInt32 v1; /**< index of first vertex in triangle face */
68  GlsUInt32 v2; /**< index of second vertex in triangle face */
69  GlsUInt32 v3; /**< index of third vertex in triangle face */
70  GlsUInt32 textureIndex; /**< index of texture for face else GlsTexturePalette::NO_TEXTURE */
71  };
72 
73  /** Initialization parameters for a GlsTriangleMesh */
75  {
76  const GlsRenderObject::InitParameters renderInitParameters; /**< base class init parameters */
77 
79  const GlsUInt32 numFaces; /**< number of faces in triangle mesh
80  * ( >= 1 ) */
81  const TriangleFace* const faces; /**< array of faces in triangle mesh */
82 
83  #if defined( GLS_DEBUG )
84  /** Determine if the initialization parameters are vaild ( GLS_DEBUG only )
85  * \return GLS_TRUE if valid else GLS_FALSE
86  * \pre none
87  * \post none
88  */
89  GlsBool IsValid( void ) const;
90  #endif // GLS_DEBUG
91  };
92 
93  /** Constructor - create an instance
94  * \param initParameters initialization parameters
95  * \param eventDispatcher event dispatcher for this object else GLS_NULL
96  * \pre initParameters.isValid()
97  * \post instance is created
98  */
99  GlsTriangleMesh( const InitParameters &initParameters, GlsEventDispatcher* const eventDispatcher );
100 
101  /** Draws the triangle mesh
102  * \param gl GL State manager for OpenGL into which object is drawn
103  * \param time the elaspsed time in seconds since program start
104  * \pre time >= 0.0
105  * \post object is drawn to OpenGL if visible and not blinked off
106  */
107  virtual void Draw( GlsStateManager &gl, const GlsFloat64 time );
108 
109  /** Set the desired texture index
110  * \param textureIndex desired texture index into palette else GlsTexturePalette::NO_TEXTURE
111  * \pre textureIndex is less than the size of the texture palette, else GlsTexturePalette::NO_TEXTURE,
112  * object's texture palette must have a valid texture (not an empty palette entry) at textureIndex
113  * if textureIndex != GlsTexturePalette::NO_TEXTURE
114  * \post object has new texture index or is untextured if textureIndex == GlsTexturePalette::NO_TEXTURE
115  */
116  virtual void SetTextureIndex( const GlsUInt32 textureIndex );
117 
118  /** Offset the texture on the object
119  * \param offset x, y offset for texture
120  * \pre offset.IsValid()
121  * \post offset is added to the texture coordinates
122  */
123  virtual void OffsetTexture( const GlsVector2D &offset );
124 
125 protected:
126  const GlsUInt32 _numFaces; /**< number of faces in faces array */
127  TriangleFace* const _faces; /**< array of faces in triangle mesh */
128  GlsTextureVertexArray _vertices; /**< vertices in triangle mesh */
129 
130  /** Destructor - shall never be called
131  * \pre none
132  * \post none
133  */
134  virtual ~GlsTriangleMesh();
135 
136 private:
137  typedef GlsRenderObject _BaseClass;
138 
139  // Disable implicit generated Members
140  GlsTriangleMesh& operator=( const GlsTriangleMesh &rhs );
141  GlsTriangleMesh( const GlsTriangleMesh &src );
142 };
143 
144 #endif // _GLS_TRIANGLE_MESH_H
GlsUInt32 v2
Definition: gls_triangle_mesh.h:68
Definition: gls_state_manager.h:63
Definition: gls_event.h:304
Definition: gls_triangle_mesh.h:59
GlsUInt32 v1
Definition: gls_triangle_mesh.h:67
const GlsTextureVertexArray::InitParameters verticesInitParameters
Definition: gls_triangle_mesh.h:78
This header defines a GLS_DEBUG only macro for facilitating evaluating class invariants in the GL Stu...
This header defines the GL State Manager class for managing the GL state in the GL Studio DO-178B Run...
const GlsRenderObject::InitParameters renderInitParameters
Definition: gls_triangle_mesh.h:76
unsigned int GlsUInt32
Definition: gls_types.h:73
GlsUInt32 textureIndex
Definition: gls_triangle_mesh.h:70
This header defines any preprocessor defines needed to configure the GL Studio DO-178B Runtime Librar...
virtual void Draw(GlsStateManager &gl, const GlsFloat64 time)
virtual void OffsetTexture(const GlsVector2D &offset)
This header defines GlsTextureVertexArray which encapsulates an array of GlsTextureVertex 's in the G...
const GlsUInt32 _numFaces
Definition: gls_triangle_mesh.h:126
TriangleFace *const _faces
Definition: gls_triangle_mesh.h:127
Definition: gls_texture_vertex_array.h:55
#define GLS_CLASS_INVARIANT_DECLARATION(ClassName)
Definition: gls_class_invariant.h:80
virtual ~GlsTriangleMesh()
This header defines an abstract class for a display object that is directly rendered to OpenGL (not a...
Definition: gls_texture_vertex_array.h:61
const GlsUInt32 numFaces
Definition: gls_triangle_mesh.h:79
Definition: gls_vertex.h:49
Definition: gls_render_object.h:69
bool GlsBool
Definition: gls_types.h:96
Definition: gls_triangle_mesh.h:74
GlsTextureVertexArray _vertices
Definition: gls_triangle_mesh.h:128
Definition: gls_render_object.h:82
GlsTriangleMesh(const InitParameters &initParameters, GlsEventDispatcher *const eventDispatcher)
GlsUInt32 v3
Definition: gls_triangle_mesh.h:69
Definition: gls_triangle_mesh.h:65
This header defines classes for working with 2D and 3D vectors, vertices and textured vertices in the...
const TriangleFace *const faces
Definition: gls_triangle_mesh.h:81
double GlsFloat64
Definition: gls_types.h:87
virtual void SetTextureIndex(const GlsUInt32 textureIndex)
Definition: gls_display_object.h:64