Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre_src_v1-9-0/OgreMain/include/OgreInstanceBatchHW_VTF.h @ 148

Last change on this file since 148 was 148, checked in by patricwi, 6 years ago

Added new dependencies for ogre1.9 and cegui0.8

File size: 4.3 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2013 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28#ifndef __InstanceBatchHW_VTF_H__
29#define __InstanceBatchHW_VTF_H__
30
31#include "OgreInstanceBatchVTF.h"
32#include "OgreTexture.h"
33
34namespace Ogre
35{
36        /** \addtogroup Core
37        *  @{
38        */
39        /** \addtogroup Scene
40        *  @{
41        */
42
43        /** Instancing implementation using vertex texture through Vertex Texture Fetch (VTF) and
44                hardware instancing.
45                @see BaseInstanceBatchVTF and @see InstanceBatchHW
46
47                The advantage over TextureVTF technique, is that this implements a basic culling algorithm
48                to avoid useless processing in vertex shader and uses a lot less VRAM and memory bandwidth
49
50                Basically it has the benefits of both TextureVTF (skeleton animations) and HWInstancingBasic
51                (lower memory consumption and basic culling) techniques
52
53        @remarks
54                        Design discussion webpage: http://www.ogre3d.org/forums/viewtopic.php?f=4&t=59902
55        @author
56            Matias N. Goldberg ("dark_sylinc")
57        @version
58            1.2
59     */
60        class _OgreExport InstanceBatchHW_VTF : public BaseInstanceBatchVTF
61        {
62        protected:
63                bool    mKeepStatic;
64
65                //Pointer to the buffer containing the per instance vertex data
66                HardwareVertexBufferSharedPtr mInstanceVertexBuffer;
67
68                void setupVertices( const SubMesh* baseSubMesh );
69                void setupIndices( const SubMesh* baseSubMesh );
70
71                /** Creates 2 TEXCOORD semantics that will be used to sample the vertex texture */
72                void createVertexSemantics( VertexData *thisVertexData, VertexData *baseVertexData,
73                        const HWBoneIdxVec &hwBoneIdx, const HWBoneWgtVec& hwBoneWgt );
74
75                /** updates the vertex buffer containing the per instance data
76                @param[in] isFirstTime Tells if this is the first time the buffer is being updated
77                @param[in] currentCamera The camera being used for render (valid when using bone matrix lookup)
78                @return The number of instances to be rendered
79                */
80                virtual size_t updateInstanceDataBuffer(bool isFirstTime, Camera* currentCamera);
81
82
83                virtual bool checkSubMeshCompatibility( const SubMesh* baseSubMesh );
84
85                /** Keeps filling the VTF with world matrix data. Overloaded to avoid culled objects
86                        and update visible instances' animation
87                */
88                size_t updateVertexTexture( Camera *currentCamera );
89
90                virtual bool matricesTogetherPerRow() const { return true; }
91        public:
92                InstanceBatchHW_VTF( InstanceManager *creator, MeshPtr &meshReference, const MaterialPtr &material,
93                                                        size_t instancesPerBatch, const Mesh::IndexMap *indexToBoneMap,
94                                                        const String &batchName );
95                virtual ~InstanceBatchHW_VTF();
96                /** @see InstanceBatch::calculateMaxNumInstances */
97                size_t calculateMaxNumInstances( const SubMesh *baseSubMesh, uint16 flags ) const;
98
99                /** @copydoc InstanceBatchHW::_boundsDirty */
100                void _boundsDirty(void);
101
102                /** @copydoc InstanceBatchHW::setStaticAndUpdate */
103                void setStaticAndUpdate( bool bStatic );
104
105                bool isStatic() const { return mKeepStatic; }
106
107                /** Overloaded to visibility on a per unit basis and finally updated the vertex texture */
108                virtual void _updateRenderQueue( RenderQueue* queue );
109        };
110
111}
112
113#endif
Note: See TracBrowser for help on using the repository browser.