~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to include/SSharedMeshBuffer.h

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
 
2
// This file is part of the "Irrlicht Engine".
 
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
 
4
 
 
5
#ifndef __S_SHARED_MESH_BUFFER_H_INCLUDED__
 
6
#define __S_SHARED_MESH_BUFFER_H_INCLUDED__
 
7
 
 
8
#include "irrArray.h"
 
9
#include "IMeshBuffer.h"
 
10
 
 
11
namespace irr
 
12
{
 
13
namespace scene
 
14
{
 
15
        //! Implementation of the IMeshBuffer interface with shared vertex list
 
16
        struct SSharedMeshBuffer : public IMeshBuffer
 
17
        {
 
18
                //! constructor
 
19
                SSharedMeshBuffer() : IMeshBuffer(), Vertices(0), ChangedID_Vertex(1), ChangedID_Index(1), MappingHintVertex(EHM_NEVER), MappingHintIndex(EHM_NEVER)
 
20
                {
 
21
                        #ifdef _DEBUG
 
22
                        setDebugName("SSharedMeshBuffer");
 
23
                        #endif
 
24
                }
 
25
 
 
26
                //! constructor
 
27
                SSharedMeshBuffer(core::array<video::S3DVertex> *vertices) : IMeshBuffer(), Vertices(vertices)
 
28
                {
 
29
                        #ifdef _DEBUG
 
30
                        setDebugName("SSharedMeshBuffer");
 
31
                        #endif
 
32
                }
 
33
 
 
34
                //! returns the material of this meshbuffer
 
35
                virtual const video::SMaterial& getMaterial() const
 
36
                {
 
37
                        return Material;
 
38
                }
 
39
 
 
40
                //! returns the material of this meshbuffer
 
41
                virtual video::SMaterial& getMaterial()
 
42
                {
 
43
                        return Material;
 
44
                }
 
45
 
 
46
                //! returns pointer to vertices
 
47
                virtual const void* getVertices() const
 
48
                {
 
49
                        if (Vertices)
 
50
                                return Vertices->const_pointer();
 
51
                        else
 
52
                                return 0;
 
53
                }
 
54
 
 
55
                //! returns pointer to vertices
 
56
                virtual void* getVertices()
 
57
                {
 
58
                        if (Vertices)
 
59
                                return Vertices->pointer();
 
60
                        else
 
61
                                return 0;
 
62
                }
 
63
 
 
64
                //! returns amount of vertices
 
65
                virtual u32 getVertexCount() const
 
66
                {
 
67
                        if (Vertices)
 
68
                                return Vertices->size();
 
69
                        else
 
70
                                return 0;
 
71
                }
 
72
 
 
73
                //! returns pointer to Indices
 
74
                virtual const u16* getIndices() const
 
75
                {
 
76
                        return Indices.const_pointer();
 
77
                }
 
78
 
 
79
                //! returns pointer to Indices
 
80
                virtual u16* getIndices()
 
81
                {
 
82
                        return Indices.pointer();
 
83
                }
 
84
 
 
85
                //! returns amount of indices
 
86
                virtual u32 getIndexCount() const
 
87
                {
 
88
                        return Indices.size();
 
89
                }
 
90
 
 
91
                //! returns an axis aligned bounding box
 
92
                virtual const core::aabbox3d<f32>& getBoundingBox() const
 
93
                {
 
94
                        return BoundingBox;
 
95
                }
 
96
 
 
97
                //! set user axis aligned bounding box
 
98
                virtual void setBoundingBox( const core::aabbox3df& box)
 
99
                {
 
100
                        BoundingBox = box;
 
101
                }
 
102
 
 
103
                //! returns which type of vertex data is stored.
 
104
                virtual video::E_VERTEX_TYPE getVertexType() const
 
105
                {
 
106
                        return video::EVT_STANDARD;
 
107
                }
 
108
 
 
109
                //! recalculates the bounding box. should be called if the mesh changed.
 
110
                virtual void recalculateBoundingBox()
 
111
                {
 
112
                        if (!Vertices || Vertices->empty() || Indices.empty())
 
113
                                BoundingBox.reset(0,0,0);
 
114
                        else
 
115
                        {
 
116
                                BoundingBox.reset((*Vertices)[Indices[0]].Pos);
 
117
                                for (u32 i=1; i<Indices.size(); ++i)
 
118
                                        BoundingBox.addInternalPoint((*Vertices)[Indices[i]].Pos);
 
119
                        }
 
120
                }
 
121
 
 
122
                //! append the vertices and indices to the current buffer
 
123
                virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) {}
 
124
 
 
125
                //! append the meshbuffer to the current buffer
 
126
                virtual void append(const IMeshBuffer* const other) {}
 
127
 
 
128
 
 
129
                //! get the current hardware mapping hint
 
130
                virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
 
131
                {
 
132
                        return MappingHintVertex;
 
133
                }
 
134
 
 
135
                //! get the current hardware mapping hint
 
136
                virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
 
137
                {
 
138
                        return MappingHintIndex;
 
139
                }
 
140
 
 
141
                //! set the hardware mapping hint, for driver
 
142
                virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX )
 
143
                {
 
144
                        if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_VERTEX)
 
145
                                MappingHintVertex=NewMappingHint;
 
146
                        if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_INDEX)
 
147
                                MappingHintIndex=NewMappingHint;
 
148
                }
 
149
 
 
150
 
 
151
                //! flags the mesh as changed, reloads hardware buffers
 
152
                virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
 
153
                {
 
154
                        if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_VERTEX)
 
155
                                ++ChangedID_Vertex;
 
156
                        if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_INDEX)
 
157
                                ++ChangedID_Index;
 
158
                }
 
159
 
 
160
                //! Get the currently used ID for identification of changes.
 
161
                /** This shouldn't be used for anything outside the VideoDriver. */
 
162
                virtual u32 getChangedID_Vertex() const {return ChangedID_Vertex;}
 
163
 
 
164
                //! Get the currently used ID for identification of changes.
 
165
                /** This shouldn't be used for anything outside the VideoDriver. */
 
166
                virtual u32 getChangedID_Index() const {return ChangedID_Index;}
 
167
 
 
168
                //! Material of this meshBuffer
 
169
                video::SMaterial Material;
 
170
 
 
171
                //! Shared Array of vertices
 
172
                core::array<video::S3DVertex> *Vertices;
 
173
 
 
174
                //! Array of Indices
 
175
                core::array<u16> Indices;
 
176
 
 
177
                //! ID used for hardware buffer management
 
178
                u32 ChangedID_Vertex;
 
179
 
 
180
                //! ID used for hardware buffer management
 
181
                u32 ChangedID_Index;
 
182
 
 
183
                //! Bounding box
 
184
                core::aabbox3df BoundingBox;
 
185
 
 
186
                //! hardware mapping hint
 
187
                E_HARDWARE_MAPPING MappingHintVertex;
 
188
                E_HARDWARE_MAPPING MappingHintIndex;
 
189
 
 
190
        };
 
191
 
 
192
 
 
193
} // end namespace scene
 
194
} // end namespace irr
 
195
 
 
196
#endif
 
197