# OgreManualObject.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004 (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2006 Torus Knot Software Ltd
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023
    00024 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029
    00030 #ifndef __OgreManualObject_H__
    00031 #define __OgreManualObject_H__
    00032
    00033 #include "OgrePrerequisites.h"
    00034 #include "OgreMovableObject.h"
    00035 #include "OgreRenderable.h"
    00036 #include "OgreResourceGroupManager.h"
    00037
    00038
    00039 namespace Ogre
    00040 {
    00101     class _OgreExport ManualObject : public MovableObject
    00102     {
    00103     public:
    00104         ManualObject(const String& name);
    00105         virtual ~ManualObject();
    00106
    00107         //pre-declare ManualObjectSection
    00108         class ManualObjectSection;
    00109
    00119         virtual void clear(void);
    00120
    00128         virtual void estimateVertexCount(size_t vcount);
    00129
    00137         virtual void estimateIndexCount(size_t icount);
    00138
    00148         virtual void begin(const String& materialName,
    00149             RenderOperation::OperationType opType = RenderOperation::OT_TRIANGLE_LIST);
    00150
    00154         virtual void setDynamic(bool dyn) { mDynamic = dyn; }
    00156         virtual bool getDynamic() const { return mDynamic; }
    00157
    00169         virtual void beginUpdate(size_t sectionIndex);
    00177         virtual void position(const Vector3& pos);
    00179         virtual void position(Real x, Real y, Real z);
    00180
    00186         virtual void normal(const Vector3& norm);
    00188         virtual void normal(Real x, Real y, Real z);
    00189
    00198         virtual void textureCoord(Real u);
    00200         virtual void textureCoord(Real u, Real v);
    00202         virtual void textureCoord(Real u, Real v, Real w);
    00204         virtual void textureCoord(const Vector2& uv);
    00206         virtual void textureCoord(const Vector3& uvw);
    00207
    00210         virtual void colour(const ColourValue& col);
    00214         virtual void colour(Real r, Real g, Real b, Real a = 1.0f);
    00215
    00227         virtual void index(uint16 idx);
    00236         virtual void triangle(uint16 i1, uint16 i2, uint16 i3);
    00245         virtual void quad(uint16 i1, uint16 i2, uint16 i3, uint16 i4);
    00246
    00251         virtual ManualObjectSection* end(void);
    00252
    00262         virtual void setMaterialName(size_t subindex, const String& name);
    00263
    00275         virtual MeshPtr convertToMesh(const String& meshName,
    00276             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    00277
    00287         void setUseIdentityProjection(bool useIdentityProjection);
    00288
    00298         bool getUseIdentityProjection(void) const { return mUseIdentityProjection; }
    00299
    00309         void setUseIdentityView(bool useIdentityView);
    00310
    00320         bool getUseIdentityView(void) const { return mUseIdentityView; }
    00321
    00329         void setBoundingBox(const AxisAlignedBox& box) { mAABB = box; }
    00330
    00333         ManualObjectSection* getSection(unsigned int index) const;
    00334
    00337         unsigned int getNumSections(void) const;
    00338
    00339         // MovableObject overrides
    00340
    00342         const String& getMovableType(void) const;
    00344         const AxisAlignedBox& getBoundingBox(void) const;
    00346         Real getBoundingRadius(void) const;
    00348         void _updateRenderQueue(RenderQueue* queue);
    00350         EdgeData* getEdgeList(void);
    00352         bool hasEdgeList(void);
    00354         ShadowRenderableListIterator getShadowVolumeRenderableIterator(
    00355             ShadowTechnique shadowTechnique, const Light* light,
    00356             HardwareIndexBufferSharedPtr* indexBuffer,
    00357             bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
    00358
    00359
    00361         class _OgreExport ManualObjectSection : public Renderable
    00362         {
    00363         protected:
    00364             ManualObject* mParent;
    00365             String mMaterialName;
    00366             mutable MaterialPtr mMaterial;
    00367             RenderOperation mRenderOperation;
    00368
    00369         public:
    00370             ManualObjectSection(ManualObject* parent, const String& materialName,
    00371                 RenderOperation::OperationType opType);
    00372             virtual ~ManualObjectSection();
    00373
    00375             RenderOperation* getRenderOperation(void);
    00377             const String& getMaterialName(void) const { return mMaterialName; }
    00379             void setMaterialName(const String& name);
    00380
    00381             // Renderable overrides
    00383             const MaterialPtr& getMaterial(void) const;
    00385             void getRenderOperation(RenderOperation& op);
    00387             void getWorldTransforms(Matrix4* xform) const;
    00389             const Quaternion& getWorldOrientation(void) const;
    00391             const Vector3& getWorldPosition(void) const;
    00393             Real getSquaredViewDepth(const Ogre::Camera *) const;
    00395             const LightList &getLights(void) const;
    00396
    00397         };
    00399         class _OgreExport ManualObjectSectionShadowRenderable : public ShadowRenderable
    00400         {
    00401         protected:
    00402             ManualObject* mParent;
    00403             // Shared link to position buffer
    00404             HardwareVertexBufferSharedPtr mPositionBuffer;
    00405             // Shared link to w-coord buffer (optional)
    00406             HardwareVertexBufferSharedPtr mWBuffer;
    00407
    00408         public:
    00409             ManualObjectSectionShadowRenderable(ManualObject* parent,
    00410                 HardwareIndexBufferSharedPtr* indexBuffer, const VertexData* vertexData,
    00411                 bool createSeparateLightCap, bool isLightCap = false);
    00412             ~ManualObjectSectionShadowRenderable();
    00414             void getWorldTransforms(Matrix4* xform) const;
    00416             const Quaternion& getWorldOrientation(void) const;
    00418             const Vector3& getWorldPosition(void) const;
    00419             HardwareVertexBufferSharedPtr getPositionBuffer(void) { return mPositionBuffer; }
    00420             HardwareVertexBufferSharedPtr getWBuffer(void) { return mWBuffer; }
    00421
    00422         };
    00423
    00424         typedef std::vector<ManualObjectSection*> SectionList;
    00425
    00426     protected:
    00428         bool mDynamic;
    00430         SectionList mSectionList;
    00432         ManualObjectSection* mCurrentSection;
    00434         bool mCurrentUpdating;
    00436         struct TempVertex
    00437         {
    00438             Vector3 position;
    00439             Vector3 normal;
    00440             Vector3 texCoord[OGRE_MAX_TEXTURE_COORD_SETS];
    00441             ushort texCoordDims[OGRE_MAX_TEXTURE_COORD_SETS];
    00442             ColourValue colour;
    00443         };
    00445         TempVertex mTempVertex;
    00447         bool mFirstVertex;
    00449         bool mTempVertexPending;
    00451         char* mTempVertexBuffer;
    00453         size_t mTempVertexSize;
    00455         uint16* mTempIndexBuffer;
    00457         size_t mTempIndexSize;
    00459         size_t mDeclSize;
    00461         size_t mEstVertexCount;
    00463         size_t mEstIndexCount;
    00465         ushort mTexCoordIndex;
    00467         AxisAlignedBox mAABB;
    00469         Real mRadius;
    00471         bool mAnyIndexed;
    00473         EdgeData* mEdgeList;
    00475         ShadowRenderableList mShadowRenderables;
    00477         bool mUseIdentityProjection;
    00479         bool mUseIdentityView;
    00480
    00481
    00483         virtual void resetTempAreas(void);
    00485         virtual void resizeTempVertexBufferIfNeeded(size_t numVerts);
    00487         virtual void resizeTempIndexBufferIfNeeded(size_t numInds);
    00488
    00490         virtual void copyTempVertexToBuffer(void);
    00491
    00492     };
    00493
    00494
    00496     class _OgreExport ManualObjectFactory : public MovableObjectFactory
    00497     {
    00498     protected:
    00499         MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
    00500     public:
    00501         ManualObjectFactory() {}
    00502         ~ManualObjectFactory() {}
    00503
    00504         static String FACTORY_TYPE_NAME;
    00505
    00506         const String& getType(void) const;
    00507         void destroyInstance( MovableObject* obj);
    00508
    00509     };
    00510 }
    00511
    00512 #endif
    00513

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sat May 10 16:24:59 2008