source: OGRE/trunk/ogrenew/OgreMain/include/OgreSubEntity.h @ 692

Revision 692, 8.4 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

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-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#ifndef __SubEntity_H__
26#define __SubEntity_H__
27
28#include "OgrePrerequisites.h"
29
30#include "OgreString.h"
31#include "OgreRenderable.h"
32#include "OgreHardwareBufferManager.h"
33
34namespace Ogre {
35
36    /** Utility class which defines the sub-parts of an Entity.
37        @remarks
38            Just as meshes are split into submeshes, an Entity is made up of
39            potentially multiple SubMeshes. These are mainly here to provide the
40            link between the Material which the SubEntity uses (which may be the
41            default Material for the SubMesh or may have been changed for this
42            object) and the SubMesh data.
43        @par
44            The SubEntity also allows the application some flexibility in the
45            material properties for this section of a particular instance of this
46            Mesh, e.g. tinting the windows on a car model.
47        @par
48            SubEntity instances are never created manually. They are created at
49            the same time as their parent Entity by the SceneManager method
50            createEntity.
51    */
52    class _OgreExport SubEntity: public Renderable
53    {
54        // Note no virtual functions for efficiency
55        friend class Entity;
56        friend class SceneManager;
57    protected:
58        /** Private constructor - don't allow creation by anybody else.
59        */
60        SubEntity(Entity* parent, SubMesh* subMeshBasis);
61
62        /** Private destructor.
63        */
64        virtual ~SubEntity();
65
66        /// Pointer to parent.
67        Entity* mParentEntity;
68
69        /// Name of Material in use by this SubEntity.
70        String mMaterialName;
71
72        /// Cached pointer to material.
73        MaterialPtr mpMaterial;
74
75        // Pointer to the SubMesh defining geometry.
76        SubMesh* mSubMesh;
77
78        /// Is this SubEntity visible?
79        bool mVisible;
80
81                /// The LOD number of the material to use, calculated by Entity::_notifyCurrentCamera
82                unsigned short mMaterialLodIndex;
83
84        /// blend buffer details for dedicated geometry
85        VertexData* mSkelAnimVertexData;
86        /// Quick lookup of buffers
87        TempBlendedBufferInfo mTempSkelAnimInfo;
88                /// Temp buffer details for software Vertex anim geometry
89                TempBlendedBufferInfo mTempVertexAnimInfo;
90                /// Vertex data details for software Vertex anim of shared geometry
91                VertexData* mSoftwareVertexAnimVertexData;
92                /// Vertex data details for hardware Vertex anim of shared geometry
93                /// - separate since we need to s/w anim for shadows whilst still altering
94                ///   the vertex data for hardware morphing (pos2 binding)
95                VertexData* mHardwareVertexAnimVertexData;
96                /// Have we applied any vertex animation to geometry?
97                bool mVertexAnimationAppliedThisFrame;
98                /// Number of hardware blended poses supported by material
99                ushort mHardwarePoseCount;
100
101        /** Internal method for preparing this Entity for use in animation. */
102        void prepareTempBlendBuffers(void);
103
104    public:
105        /** Gets the name of the Material in use by this instance.
106        */
107        const String& getMaterialName() const;
108
109        /** Sets the name of the Material to be used.
110            @remarks
111                By default a SubEntity uses the default Material that the SubMesh
112                uses. This call can alter that so that the Material is different
113                for this instance.
114        */
115        void setMaterialName( const String& name );
116
117        /** Tells this SubEntity whether to be visible or not. */
118        virtual void setVisible(bool visible);
119
120        /** Returns whether or not this SubEntity is supposed to be visible. */
121        virtual bool isVisible(void) const;
122
123        /** Accessor method to read mesh data.
124        */
125        SubMesh* getSubMesh(void);
126
127        /** Overridden - see Renderable.
128        */
129        const MaterialPtr& getMaterial(void) const;
130
131        /** Overridden - see Renderable.
132        */
133        Technique* getTechnique(void) const;
134
135        /** Overridden - see Renderable.
136        */
137        void getRenderOperation(RenderOperation& op);
138
139        /** Overridden - see Renderable.
140        */
141        void getWorldTransforms(Matrix4* xform) const;
142        /** @copydoc Renderable::getWorldOrientation */
143        const Quaternion& getWorldOrientation(void) const;
144        /** @copydoc Renderable::getWorldPosition */
145        const Vector3& getWorldPosition(void) const;
146        /** Overridden - see Renderable.
147        */
148        bool getNormaliseNormals(void) const;     
149        /** Overridden - see Renderable.
150        */
151        unsigned short getNumWorldTransforms(void) const;
152        /** Overridden, see Renderable */
153        Real getSquaredViewDepth(const Camera* cam) const;
154        /** @copydoc Renderable::getLights */
155        const LightList& getLights(void) const;
156        /** @copydoc Renderable::getCastsShadows */
157        bool getCastsShadows(void) const;
158                /** Advanced method to get the temporarily blended vertex information
159                for entities which are software skinned.
160        @remarks
161            Internal engine will eliminate software animation if possible, this
162            information is unreliable unless added request for software animation
163            via Entity::addSoftwareAnimationRequest.
164        @note
165            The positions/normals of the returned vertex data is in object space.
166                */
167                VertexData* _getSkelAnimVertexData(void);
168                /** Advanced method to get the temporarily blended software morph vertex information
169        @remarks
170            Internal engine will eliminate software animation if possible, this
171            information is unreliable unless added request for software animation
172            via Entity::addSoftwareAnimationRequest.
173        @note
174            The positions/normals of the returned vertex data is in object space.
175                */
176                VertexData* _getSoftwareVertexAnimVertexData(void);
177                /** Advanced method to get the hardware morph vertex information
178        @note
179            The positions/normals of the returned vertex data is in object space.
180                */
181                VertexData* _getHardwareVertexAnimVertexData(void);
182                /** Advanced method to get the temp buffer information for software
183                skeletal animation.
184                */
185                TempBlendedBufferInfo* _getSkelAnimTempBufferInfo(void);
186                /** Advanced method to get the temp buffer information for software
187                morph animation.
188                */
189                TempBlendedBufferInfo* _getVertexAnimTempBufferInfo(void);
190                /// Retrieve the VertexData which should be used for GPU binding
191                VertexData* getVertexDataForBinding(void);
192
193                /** Mark all vertex data as so far unanimated.
194                */
195                void _markBuffersUnusedForAnimation(void);
196                /** Mark all vertex data as animated.
197                */
198                void _markBuffersUsedForAnimation(void);
199                /** Are buffers already marked as vertex animated? */
200                bool _getBuffersMarkedForAnimation(void) const { return mVertexAnimationAppliedThisFrame; }
201                /** Internal method to copy original vertex data to the morph structures
202                should there be no active animation in use.
203                */
204                void _restoreBuffersForUnusedAnimation(bool hardwareAnimation);
205
206                /** Overridden from Renderble to provide some custom behaviour. */
207                void _updateCustomGpuParameter(
208                        const GpuProgramParameters::AutoConstantEntry& constantEntry,
209                        GpuProgramParameters* params) const;
210    };
211
212}
213
214
215#endif
Note: See TracBrowser for help on using the repository browser.