1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://www.ogre3d.org/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #ifndef __VertexIndexData_H__
|
---|
26 | #define __VertexIndexData_H__
|
---|
27 |
|
---|
28 | #include "OgrePrerequisites.h"
|
---|
29 | #include "OgreHardwareVertexBuffer.h"
|
---|
30 | #include "OgreHardwareIndexBuffer.h"
|
---|
31 |
|
---|
32 | namespace Ogre {
|
---|
33 |
|
---|
34 | /// Define a list of usage flags
|
---|
35 | typedef std::vector<HardwareBuffer::Usage> BufferUsageList;
|
---|
36 |
|
---|
37 |
|
---|
38 | /** Summary class collecting together vertex source information. */
|
---|
39 | class _OgreExport VertexData
|
---|
40 | {
|
---|
41 | private:
|
---|
42 | /// Protected copy constructor, to prevent misuse
|
---|
43 | VertexData(const VertexData& rhs); /* do nothing, should not use */
|
---|
44 | /// Protected operator=, to prevent misuse
|
---|
45 | VertexData& operator=(const VertexData& rhs); /* do not use */
|
---|
46 | public:
|
---|
47 | VertexData();
|
---|
48 | ~VertexData();
|
---|
49 |
|
---|
50 | /** Declaration of the vertex to be used in this operation.
|
---|
51 | @remarks Note that this is created for you on construction.
|
---|
52 | */
|
---|
53 | VertexDeclaration* vertexDeclaration;
|
---|
54 | /** The vertex buffer bindings to be used.
|
---|
55 | @remarks Note that this is created for you on construction.
|
---|
56 | */
|
---|
57 | VertexBufferBinding* vertexBufferBinding;
|
---|
58 | /// The base vertex index to start from
|
---|
59 | size_t vertexStart;
|
---|
60 | /// The number of vertices used in this operation
|
---|
61 | size_t vertexCount;
|
---|
62 |
|
---|
63 | /** Clones this vertex data, potentially including replicating any vertex buffers.
|
---|
64 | @remarks The caller is expected to delete the returned pointer when ready
|
---|
65 | */
|
---|
66 | VertexData* clone(bool copyData = true) const;
|
---|
67 |
|
---|
68 | /** Modifies the vertex data to be suitable for use for rendering shadow geometry.
|
---|
69 | @remarks
|
---|
70 | Preparing vertex data to generate a shadow volume involves firstly ensuring that the
|
---|
71 | vertex buffer containing the positions is a standalone vertex buffer,
|
---|
72 | with no other components in it. This method will therefore break apart any existing
|
---|
73 | vertex buffers if position is sharing a vertex buffer.
|
---|
74 | Secondly, it will double the size of this vertex buffer so that there are 2 copies of
|
---|
75 | the position data for the mesh. The first half is used for the original, and the second
|
---|
76 | half is used for the 'extruded' version. The vertex count used to render will remain
|
---|
77 | the same though, so as not to add any overhead to regular rendering of the object.
|
---|
78 | Both copies of the position are required in one buffer because shadow volumes stretch
|
---|
79 | from the original mesh to the extruded version.
|
---|
80 | @par
|
---|
81 | It's important to appreciate that this method can fundamentally change the structure of your
|
---|
82 | vertex buffers, although in reality they will be new buffers. As it happens, if other
|
---|
83 | objects are using the original buffers then they will be unaffected because the reference
|
---|
84 | counting will keep them intact. However, if you have made any assumptions about the
|
---|
85 | structure of the vertex data in the buffers of this object, you may have to rethink them.
|
---|
86 | */
|
---|
87 | void prepareForShadowVolume(void);
|
---|
88 |
|
---|
89 | /** Additional shadow volume vertex buffer storage.
|
---|
90 | @remarks
|
---|
91 | This additional buffer is only used where we have prepared this VertexData for
|
---|
92 | use in shadow volume contruction, and where the current render system supports
|
---|
93 | vertex programs. This buffer contains the 'w' vertex position component which will
|
---|
94 | be used by that program to differentiate between extruded and non-extruded vertices.
|
---|
95 | This 'w' component cannot be included in the original position buffer because
|
---|
96 | DirectX does not allow 4-component positions in the fixed-function pipeline, and the original
|
---|
97 | position buffer must still be usable for fixed-function rendering.
|
---|
98 | @par
|
---|
99 | Note that we don't store any vertex declaration or vertex buffer binding here becuase this
|
---|
100 | can be reused in the shadow algorithm.
|
---|
101 | */
|
---|
102 | HardwareVertexBufferSharedPtr hardwareShadowVolWBuffer;
|
---|
103 |
|
---|
104 |
|
---|
105 | /** Reorganises the data in the vertex buffers according to the
|
---|
106 | new vertex declaration passed in. Note that new vertex buffers
|
---|
107 | are created and written to, so if the buffers being referenced
|
---|
108 | by this vertex data object are also used by others, then the
|
---|
109 | original buffers will not be damaged by this operation.
|
---|
110 | Once this operation has completed, the new declaration
|
---|
111 | passed in will overwrite the current one.
|
---|
112 | @param newDeclaration The vertex declaration which will be used
|
---|
113 | for the reorganised buffer state. Note that the new delcaration
|
---|
114 | must not include any elements which do not already exist in the
|
---|
115 | current declaration; you can drop elements by
|
---|
116 | excluding them from the declaration if you wish, however.
|
---|
117 | @param bufferUsages Vector of usage flags which indicate the usage options
|
---|
118 | for each new vertex buffer created. The indexes of the entries must correspond
|
---|
119 | to the buffer binding values referenced in the declaration.
|
---|
120 | */
|
---|
121 | void reorganiseBuffers(VertexDeclaration* newDeclaration, const BufferUsageList& bufferUsage);
|
---|
122 |
|
---|
123 | /** Reorganises the data in the vertex buffers according to the
|
---|
124 | new vertex declaration passed in. Note that new vertex buffers
|
---|
125 | are created and written to, so if the buffers being referenced
|
---|
126 | by this vertex data object are also used by others, then the
|
---|
127 | original buffers will not be damaged by this operation.
|
---|
128 | Once this operation has completed, the new declaration
|
---|
129 | passed in will overwrite the current one.
|
---|
130 | This version of the method derives the buffer usages from the existing
|
---|
131 | buffers, by using the 'most flexible' usage from the equivalent sources.
|
---|
132 | @param newDeclaration The vertex declaration which will be used
|
---|
133 | for the reorganised buffer state. Note that the new delcaration
|
---|
134 | must not include any elements which do not already exist in the
|
---|
135 | current declaration; you can drop elements by
|
---|
136 | excluding them from the declaration if you wish, however.
|
---|
137 | */
|
---|
138 | void reorganiseBuffers(VertexDeclaration* newDeclaration);
|
---|
139 |
|
---|
140 |
|
---|
141 |
|
---|
142 | };
|
---|
143 |
|
---|
144 | /** Summary class collecting together index data source information. */
|
---|
145 | class _OgreExport IndexData
|
---|
146 | {
|
---|
147 | protected:
|
---|
148 | /// Protected copy constructor, to prevent misuse
|
---|
149 | IndexData(const IndexData& rhs); /* do nothing, should not use */
|
---|
150 | /// Protected operator=, to prevent misuse
|
---|
151 | IndexData& operator=(const IndexData& rhs); /* do not use */
|
---|
152 | public:
|
---|
153 | IndexData();
|
---|
154 | ~IndexData();
|
---|
155 | /// pointer to the HardwareIndexBuffer to use, must be specified if useIndexes = true
|
---|
156 | HardwareIndexBufferSharedPtr indexBuffer;
|
---|
157 |
|
---|
158 | /// index in the buffer to start from for this operation
|
---|
159 | size_t indexStart;
|
---|
160 |
|
---|
161 | /// The number of indexes to use from the buffer
|
---|
162 | size_t indexCount;
|
---|
163 |
|
---|
164 | /** Clones this index data, potentially including replicating the index buffer.
|
---|
165 | @remarks The caller is expected to delete the returned pointer when finished
|
---|
166 | */
|
---|
167 | IndexData* clone(bool copyData = true) const;
|
---|
168 | };
|
---|
169 |
|
---|
170 |
|
---|
171 | }
|
---|
172 | #endif
|
---|
173 |
|
---|