OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreInstanceBatchHW_VTF.h
Go to the documentation of this file.
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-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __InstanceBatchHW_VTF_H__
29 #define __InstanceBatchHW_VTF_H__
30 
31 #include "OgreInstanceBatchVTF.h"
32 
33 namespace Ogre
34 {
60  {
61  protected:
63  {
64  float * RESTRICT_ALIAS mDest; //Pointer to VTF texture
69  size_t floatsPerEntity,
70  size_t entitiesPerPadding,
71  size_t widthFloatsPadding ) :
72  mDest( dstPtr ),
73  mFloatsPerEntity( floatsPerEntity ),
74  mEntitiesPerPadding( entitiesPerPadding ),
75  mWidthFloatsPadding( widthFloatsPadding ) {}
76  };
78  {
81  size_t floatsPerEntity,
82  size_t entitiesPerPadding,
83  size_t widthFloatsPadding ) :
84  TransformsToTexture( dstPtr, floatsPerEntity,
85  entitiesPerPadding, widthFloatsPadding ),
86  mInstancesWritten( 0 ) {}
87  FORCEINLINE void operator () ( const MovableObject *mo );
88  };
90  {
95  size_t floatsPerEntity,
96  size_t entitiesPerPadding,
97  size_t widthFloatsPadding,
98  const Mesh::IndexMap *indexMap ) :
99  TransformsToTexture( dstPtr, floatsPerEntity,
100  entitiesPerPadding, widthFloatsPadding ),
101  mInstancesWritten( 0 ),
102  boneIdxStart( indexMap->begin() ),
103  boneIdxEnd( indexMap->end() ) {}
104  FORCEINLINE void operator () ( const MovableObject *mo );
105  };
107  {
112  size_t floatsPerEntity,
113  size_t entitiesPerPadding,
114  size_t widthFloatsPadding,
115  const Mesh::IndexMap *indexMap,
116  size_t numLutEntries ) :
117  TransformsToTexture( dstPtr, floatsPerEntity,
118  entitiesPerPadding, widthFloatsPadding ),
119  mWrittenPositions( numLutEntries, false ),
120  boneIdxStart( indexMap->begin() ),
121  boneIdxEnd( indexMap->end() ) {}
122  FORCEINLINE void operator () ( const MovableObject *mo );
123  };
125  {
130  size_t floatsPerEntity,
131  size_t entitiesPerPadding,
132  size_t widthFloatsPadding,
133  const Mesh::IndexMap *indexMap ) :
134  TransformsToTexture( dstPtr, floatsPerEntity,
135  entitiesPerPadding, widthFloatsPadding ),
136  mInstancesWritten( 0 ),
137  boneIdxStart( indexMap->begin() ),
138  boneIdxEnd( indexMap->end() ) {}
139  FORCEINLINE void operator () ( const MovableObject *mo );
140  };
141 
142  //Pointer to the buffer containing the per instance vertex data
144 
145  void setupVertices( const SubMesh* baseSubMesh );
146  void setupIndices( const SubMesh* baseSubMesh );
147 
149  void createVertexSemantics( VertexData *thisVertexData, VertexData *baseVertexData,
150  const HWBoneIdxVec &hwBoneIdx, const HWBoneWgtVec& hwBoneWgt );
151 
154  void fillVertexBufferOffsets(void);
155 
156  void fillVertexBufferLUT( const MovableObjectArray *culledInstances );
157 
158  virtual bool checkSubMeshCompatibility( const SubMesh* baseSubMesh );
159 
163  size_t updateVertexTexture(Camera *currentCamera , const Camera *lodCamera);
164 
166  virtual void createAllInstancedEntities(void);
167 
168  virtual bool matricesTogetherPerRow() const { return true; }
169  public:
170  InstanceBatchHW_VTF( IdType id, ObjectMemoryManager *objectMemoryManager,
171  InstanceManager *creator, MeshPtr &meshReference,
172  const MaterialPtr &material, size_t instancesPerBatch,
173  const Mesh::IndexMap *indexToBoneMap );
174  virtual ~InstanceBatchHW_VTF();
176  size_t calculateMaxNumInstances( const SubMesh *baseSubMesh, uint16 flags ) const;
177 
179  void _boundsDirty(void);
180 
182  virtual void _updateRenderQueue( RenderQueue* queue, Camera *camera, const Camera *lodCamera );
183 
184  virtual void instanceBatchCullFrustumThreaded( const Frustum *frustum,
185  const Camera *lodCamera,
186  uint32 combinedVisibilityFlags )
187  {
188  instanceBatchCullFrustumThreadedImpl( frustum, lodCamera, combinedVisibilityFlags );
189  }
190  };
191 
192 }
193 
194 #endif
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:82
HardwareVertexBufferSharedPtr mInstanceVertexBuffer
unsigned int uint32
Definition: OgrePlatform.h:420
#define _OgreExport
Definition: OgrePlatform.h:255
SendAllSingleTransformsToTexture(float *RESTRICT_ALIAS dstPtr, size_t floatsPerEntity, size_t entitiesPerPadding, size_t widthFloatsPadding)
vector< uint8 >::type HWBoneIdxVec
A frustum represents a pyramid, capped at the near and far end which is used to represent either a vi...
Definition: OgreFrustum.h:84
SendAllAnimatedTransformsToTexture(float *RESTRICT_ALIAS dstPtr, size_t floatsPerEntity, size_t entitiesPerPadding, size_t widthFloatsPadding, const Mesh::IndexMap *indexMap)
Shared pointer implementation used to share vertex buffers.
Wrap-around class that contains multiple ArrayMemoryManager, one per render queue.
Abstract class defining a movable object in a scene.
#define RESTRICT_ALIAS
Definition: OgrePlatform.h:448
const T * const_iterator
Definition: OgreFastArray.h:95
Ogre::uint32 IdType
Big projects with lots, lots of units for very long periods of time (MMORPGs?) may want to define thi...
Definition: OgreId.h:36
SendAllLUTToTexture(float *RESTRICT_ALIAS dstPtr, size_t floatsPerEntity, size_t entitiesPerPadding, size_t widthFloatsPadding, const Mesh::IndexMap *indexMap, size_t numLutEntries)
Defines a part of a complete mesh.
Definition: OgreSubMesh.h:60
virtual void instanceBatchCullFrustumThreaded(const Frustum *frustum, const Camera *lodCamera, uint32 combinedVisibilityFlags)
InstancingTheadedCullingMethod,
Summary class collecting together vertex source information.
SendAllDualQuatTexture(float *RESTRICT_ALIAS dstPtr, size_t floatsPerEntity, size_t entitiesPerPadding, size_t widthFloatsPadding, const Mesh::IndexMap *indexMap)
virtual bool matricesTogetherPerRow() const
Affects VTF texture's width dimension.
TransformsToTexture(float *RESTRICT_ALIAS dstPtr, size_t floatsPerEntity, size_t entitiesPerPadding, size_t widthFloatsPadding)
Instancing implementation using vertex texture through Vertex Texture Fetch (VTF) This implementation...
Class to manage the scene object rendering queue.
This is the main starting point for the new instancing system.
#define FORCEINLINE
Definition: OgrePlatform.h:104
unsigned short uint16
Definition: OgrePlatform.h:421
Instancing implementation using vertex texture through Vertex Texture Fetch (VTF) and hardware instan...