OgrePatchMesh.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 #ifndef __PatchMesh_H__
00030 #define __PatchMesh_H__
00031 
00032 #include "OgrePrerequisites.h"
00033 #include "OgreMesh.h"
00034 #include "OgrePatchSurface.h"
00035 
00036 namespace Ogre {
00037 
00042     class _OgreExport PatchMesh : public Mesh
00043     {
00044     protected:
00046         PatchSurface mSurface;
00048         VertexDeclaration* mDeclaration;
00049     public:
00051         PatchMesh(ResourceManager* creator, const String& name, ResourceHandle handle,
00052             const String& group);
00053 
00055         void define(void* controlPointBuffer, 
00056             VertexDeclaration *declaration, size_t width, size_t height,
00057             size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL, 
00058             size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
00059             PatchSurface::VisibleSide visibleSide = PatchSurface::VS_FRONT,
00060             HardwareBuffer::Usage vbUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY, 
00061             HardwareBuffer::Usage ibUsage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
00062             bool vbUseShadow = false, bool ibUseShadow = false);
00063 
00064         /* Sets the current subdivision level as a proportion of full detail.
00065         @param factor Subdivision factor as a value from 0 (control points only) to 1 (maximum
00066             subdivision). */
00067         void setSubdivision(Real factor);
00068     protected:
00070         void loadImpl(void);
00072         void prepareImpl(void) {}
00073 
00074     };
00081     class _OgreExport PatchMeshPtr : public SharedPtr<PatchMesh> 
00082     {
00083     public:
00084         PatchMeshPtr() : SharedPtr<PatchMesh>() {}
00085         explicit PatchMeshPtr(PatchMesh* rep) : SharedPtr<PatchMesh>(rep) {}
00086         PatchMeshPtr(const PatchMeshPtr& r) : SharedPtr<PatchMesh>(r) {} 
00087         PatchMeshPtr(const ResourcePtr& r) : SharedPtr<PatchMesh>()
00088         {
00089             // lock & copy other mutex pointer
00090             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
00091             {
00092                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
00093                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
00094                 pRep = static_cast<PatchMesh*>(r.getPointer());
00095                 pUseCount = r.useCountPointer();
00096                 if (pUseCount)
00097                 {
00098                     ++(*pUseCount);
00099                 }
00100             }
00101         }
00102 
00104         PatchMeshPtr& operator=(const ResourcePtr& r)
00105         {
00106             if (pRep == static_cast<PatchMesh*>(r.getPointer()))
00107                 return *this;
00108             release();
00109 
00110             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
00111             {
00112                 // lock & copy other mutex pointer
00113                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
00114                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
00115                 pRep = static_cast<PatchMesh*>(r.getPointer());
00116                 pUseCount = r.useCountPointer();
00117                 if (pUseCount)
00118                 {
00119                     ++(*pUseCount);
00120                 }
00121             }
00122             else
00123             {
00124                 // RHS must be a null pointer
00125                 assert(r.isNull() && "RHS must be null if it has no mutex!");
00126                 setNull();
00127             }
00128             return *this;
00129         }
00131         PatchMeshPtr& operator=(const MeshPtr& r)
00132         {
00133             if (pRep == static_cast<PatchMesh*>(r.getPointer()))
00134                 return *this;
00135             release();
00136             // lock & copy other mutex pointer
00137             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
00138             {
00139                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
00140                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
00141                 pRep = static_cast<PatchMesh*>(r.getPointer());
00142                 pUseCount = r.useCountPointer();
00143                 if (pUseCount)
00144                 {
00145                     ++(*pUseCount);
00146                 }
00147             }
00148             return *this;
00149         }
00150     };
00151 
00152 }
00153 
00154 #endif

Copyright © 2008 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 27 22:02:24 2009