Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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-2005 The OGRE Team
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 */
00025 
00026 #ifndef __OgreManualObject_H__
00027 #define __OgreManualObject_H__
00028 
00029 #include "OgrePrerequisites.h"
00030 #include "OgreMovableObject.h"
00031 #include "OgreRenderable.h"
00032 #include "OgreResourceGroupManager.h"
00033 
00034 
00035 namespace Ogre
00036 {
00091     class _OgreExport ManualObject : public MovableObject
00092     {
00093     public:
00094         ManualObject(const String& name);
00095         virtual ~ManualObject();
00096 
00104         virtual void clear(void);
00105         
00111         virtual void estimateVertexCount(size_t vcount);
00112 
00118         virtual void estimateIndexCount(size_t icount);
00119 
00129         virtual void begin(const String& materialName, 
00130             RenderOperation::OperationType opType = RenderOperation::OT_TRIANGLE_LIST);
00138         virtual void position(const Vector3& pos);
00140         virtual void position(Real x, Real y, Real z);
00141 
00147         virtual void normal(const Vector3& norm);
00149         virtual void normal(Real x, Real y, Real z);
00150 
00159         virtual void textureCoord(Real u);
00161         virtual void textureCoord(Real u, Real v);
00163         virtual void textureCoord(Real u, Real v, Real w);
00165         virtual void textureCoord(const Vector2& uv);
00167         virtual void textureCoord(const Vector3& uvw);
00168 
00171         virtual void colour(const ColourValue& col);
00175         virtual void colour(Real r, Real g, Real b, Real a = 1.0f);
00176 
00188         virtual void index(uint16 idx);
00197         virtual void triangle(uint16 i1, uint16 i2, uint16 i3);
00206         virtual void quad(uint16 i1, uint16 i2, uint16 i3, uint16 i4);
00207 
00209         virtual void end(void);
00210 
00222         virtual MeshPtr convertToMesh(const String& meshName, 
00223             const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
00224 
00225         // MovableObject overrides
00226 
00228         const String& getMovableType(void) const;
00230         const AxisAlignedBox& getBoundingBox(void) const;
00232         Real getBoundingRadius(void) const;
00234         void _updateRenderQueue(RenderQueue* queue);
00236         EdgeData* getEdgeList(void);
00238         ShadowRenderableListIterator getShadowVolumeRenderableIterator(
00239             ShadowTechnique shadowTechnique, const Light* light, 
00240             HardwareIndexBufferSharedPtr* indexBuffer, 
00241             bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
00242 
00243 
00245         class _OgreExport ManualObjectSection : public Renderable
00246         {
00247         protected:
00248             ManualObject* mParent;
00249             String mMaterialName;
00250             mutable MaterialPtr mMaterial;
00251             RenderOperation mRenderOperation;
00252             
00253         public:
00254             ManualObjectSection(ManualObject* parent, const String& materialName,
00255                 RenderOperation::OperationType opType);
00256             virtual ~ManualObjectSection();
00257             
00259             RenderOperation* getRenderOperation(void);
00261             const String& getMaterialName(void) const { return mMaterialName; }
00262             
00263             // Renderable overrides
00265             const MaterialPtr& getMaterial(void) const;
00267             void getRenderOperation(RenderOperation& op);
00269             void getWorldTransforms(Matrix4* xform) const;
00271             const Quaternion& getWorldOrientation(void) const;
00273             const Vector3& getWorldPosition(void) const;
00275             Real getSquaredViewDepth(const Ogre::Camera *) const;
00277             const LightList &getLights(void) const;
00278                     
00279         };
00281         class _OgreExport ManualObjectSectionShadowRenderable : public ShadowRenderable
00282         {
00283         protected:
00284             ManualObject* mParent;
00285             // Shared link to position buffer
00286             HardwareVertexBufferSharedPtr mPositionBuffer;
00287             // Shared link to w-coord buffer (optional)
00288             HardwareVertexBufferSharedPtr mWBuffer;
00289 
00290         public:
00291             ManualObjectSectionShadowRenderable(ManualObject* parent, 
00292                 HardwareIndexBufferSharedPtr* indexBuffer, const VertexData* vertexData, 
00293                 bool createSeparateLightCap, bool isLightCap = false);
00294             ~ManualObjectSectionShadowRenderable();
00296             void getWorldTransforms(Matrix4* xform) const;
00298             const Quaternion& getWorldOrientation(void) const;
00300             const Vector3& getWorldPosition(void) const;
00301             HardwareVertexBufferSharedPtr getPositionBuffer(void) { return mPositionBuffer; }
00302             HardwareVertexBufferSharedPtr getWBuffer(void) { return mWBuffer; }
00303 
00304         };
00305 
00306         typedef std::vector<ManualObjectSection*> SectionList;
00307         
00308     protected:
00310         SectionList mSectionList;
00312         ManualObjectSection* mCurrentSection;
00314         struct TempVertex
00315         {
00316             Vector3 position;
00317             Vector3 normal;
00318             Vector3 texCoord[OGRE_MAX_TEXTURE_COORD_SETS];
00319             ushort texCoordDims[OGRE_MAX_TEXTURE_COORD_SETS];
00320             ColourValue colour;
00321         };
00323         TempVertex mTempVertex;
00325         bool mFirstVertex;
00327         bool mTempVertexPending;
00329         char* mTempVertexBuffer;
00331         size_t mTempVertexSize;
00333         uint16* mTempIndexBuffer;
00335         size_t mTempIndexSize;
00337         size_t mDeclSize;
00339         ushort mTexCoordIndex;
00341         AxisAlignedBox mAABB;
00343         Real mRadius;
00345         bool mAnyIndexed;
00347         EdgeData* mEdgeList;
00349         ShadowRenderableList mShadowRenderables;
00350 
00351 
00353         virtual void resetTempAreas(void);
00355         virtual void resizeTempVertexBufferIfNeeded(size_t numVerts);
00357         virtual void resizeTempIndexBufferIfNeeded(size_t numInds);
00358 
00360         virtual void copyTempVertexToBuffer(void);
00361 
00362     };
00363 
00364 
00366     class _OgreExport ManualObjectFactory : public MovableObjectFactory
00367     {
00368     protected:
00369         MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
00370     public:
00371         ManualObjectFactory() {}
00372         ~ManualObjectFactory() {}
00373 
00374         static String FACTORY_TYPE_NAME;
00375 
00376         const String& getType(void) const;
00377         void destroyInstance( MovableObject* obj);  
00378 
00379     };
00380 }
00381 
00382 #endif
00383 

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:43 2006