# 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-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 #ifndef __PatchMesh_H__
    00026 #define __PatchMesh_H__
    00027
    00028 #include "OgrePrerequisites.h"
    00029 #include "OgreMesh.h"
    00030 #include "OgrePatchSurface.h"
    00031
    00032 namespace Ogre {
    00033
    00038     class _OgreExport PatchMesh : public Mesh
    00039     {
    00040     protected:
    00042         PatchSurface mSurface;
    00044         VertexDeclaration* mDeclaration;
    00045     public:
    00047         PatchMesh(ResourceManager* creator, const String& name, ResourceHandle handle,
    00048             const String& group);
    00049
    00051         void define(void* controlPointBuffer,
    00052             VertexDeclaration *declaration, size_t width, size_t height,
    00053             size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
    00054             size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
    00055             PatchSurface::VisibleSide visibleSide = PatchSurface::VS_FRONT,
    00056             HardwareBuffer::Usage vbUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
    00057             HardwareBuffer::Usage ibUsage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
    00058             bool vbUseShadow = false, bool ibUseShadow = false);
    00059
    00060         /* Sets the current subdivision level as a proportion of full detail.
    00061         @param factor Subdivision factor as a value from 0 (control points only) to 1 (maximum
    00062             subdivision). */
    00063         void setSubdivision(Real factor);
    00064     protected:
    00066         void loadImpl(void);
    00067
    00068     };
    00075     class _OgreExport PatchMeshPtr : public SharedPtr<PatchMesh>
    00076     {
    00077     public:
    00078         PatchMeshPtr() : SharedPtr<PatchMesh>() {}
    00079         explicit PatchMeshPtr(PatchMesh* rep) : SharedPtr<PatchMesh>(rep) {}
    00080         PatchMeshPtr(const PatchMeshPtr& r) : SharedPtr<PatchMesh>(r) {}
    00081         PatchMeshPtr(const ResourcePtr& r) : SharedPtr<PatchMesh>()
    00082         {
    00083             // lock & copy other mutex pointer
    00084             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
    00085             {
    00086                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
    00087                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
    00088                 pRep = static_cast<PatchMesh*>(r.getPointer());
    00089                 pUseCount = r.useCountPointer();
    00090                 if (pUseCount)
    00091                 {
    00092                     ++(*pUseCount);
    00093                 }
    00094             }
    00095         }
    00096
    00098         PatchMeshPtr& operator=(const ResourcePtr& r)
    00099         {
    00100             if (pRep == static_cast<PatchMesh*>(r.getPointer()))
    00101                 return *this;
    00102             release();
    00103
    00104             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
    00105             {
    00106                 // lock & copy other mutex pointer
    00107                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
    00108                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
    00109                 pRep = static_cast<PatchMesh*>(r.getPointer());
    00110                 pUseCount = r.useCountPointer();
    00111                 if (pUseCount)
    00112                 {
    00113                     ++(*pUseCount);
    00114                 }
    00115             }
    00116             return *this;
    00117         }
    00119         PatchMeshPtr& operator=(const MeshPtr& r)
    00120         {
    00121             if (pRep == static_cast<PatchMesh*>(r.getPointer()))
    00122                 return *this;
    00123             release();
    00124             // lock & copy other mutex pointer
    00125             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
    00126             {
    00127                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
    00128                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
    00129                 pRep = static_cast<PatchMesh*>(r.getPointer());
    00130                 pUseCount = r.useCountPointer();
    00131                 if (pUseCount)
    00132                 {
    00133                     ++(*pUseCount);
    00134                 }
    00135             }
    00136             return *this;
    00137         }
    00138     };
    00139
    00140 }
    00141
    00142 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 17 15:39:10 2006