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

Revision 657, 6.0 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

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        SceneDetailLevel mRenderDetail;
82                /// The LOD number of the material to use, calculated by Entity::_notifyCurrentCamera
83                unsigned short mMaterialLodIndex;
84
85        /// blend buffer details for dedicated geometry
86        VertexData* mBlendedVertexData;
87        /// Quick lookup of buffers
88        TempBlendedBufferInfo mTempBlendedBuffer;
89        /** Internal method for preparing this Entity for use in animation. */
90        void prepareTempBlendBuffers(void);
91
92    public:
93        /** Gets the name of the Material in use by this instance.
94        */
95        const String& getMaterialName() const;
96
97        /** Sets the name of the Material to be used.
98            @remarks
99                By default a SubEntity uses the default Material that the SubMesh
100                uses. This call can alter that so that the Material is different
101                for this instance.
102        */
103        void setMaterialName( const String& name );
104
105        /** Tells this SubEntity whether to be visible or not. */
106        virtual void setVisible(bool visible);
107
108        /** Returns whether or not this SubEntity is supposed to be visible. */
109        virtual bool isVisible(void) const;
110
111        /** Accessor method to read mesh data.
112        */
113        SubMesh* getSubMesh(void);
114
115        /** Overridden - see Renderable.
116        */
117        const MaterialPtr& getMaterial(void) const;
118
119        /** Overridden - see Renderable.
120        */
121        Technique* getTechnique(void) const;
122
123        /** Overridden - see Renderable.
124        */
125        void getRenderOperation(RenderOperation& op);
126
127        /** Overridden - see Renderable.
128        */
129        void getWorldTransforms(Matrix4* xform) const;
130        /** @copydoc Renderable::getWorldOrientation */
131        const Quaternion& getWorldOrientation(void) const;
132        /** @copydoc Renderable::getWorldPosition */
133        const Vector3& getWorldPosition(void) const;
134        /** Overridden - see Renderable.
135        */
136        bool getNormaliseNormals(void) const;     
137        /** Overridden - see Renderable.
138        */
139        unsigned short getNumWorldTransforms(void) const;
140        /** Overridden, see Renderable */
141        Real getSquaredViewDepth(const Camera* cam) const;
142        /** Sets the rendering level (solid, wireframe) of this SubEntity. */
143        void setRenderDetail(SceneDetailLevel renderDetail) { mRenderDetail = renderDetail; }
144        /** Overridden, see Renderable */
145        SceneDetailLevel getRenderDetail() const {return mRenderDetail;}
146        /** @copydoc Renderable::getLights */
147        const LightList& getLights(void) const;
148        /// Get the temporary blended vertex data for this subentity
149        const VertexData* getBlendedVertexData(void) { return mBlendedVertexData; }
150        /** @copydoc Renderable::getCastsShadows */
151        bool getCastsShadows(void) const;
152                /** Advanced method to get the temporarily blended vertex information
153                for entities which are software skinned.
154                */
155                const VertexData* _getBlendedVertexData(void) const;
156    };
157
158}
159
160
161#endif
Note: See TracBrowser for help on using the repository browser.