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

# 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);
    00071
    00072     };
    00079     class _OgreExport PatchMeshPtr : public SharedPtr<PatchMesh>
    00080     {
    00081     public:
    00082         PatchMeshPtr() : SharedPtr<PatchMesh>() {}
    00083         explicit PatchMeshPtr(PatchMesh* rep) : SharedPtr<PatchMesh>(rep) {}
    00084         PatchMeshPtr(const PatchMeshPtr& r) : SharedPtr<PatchMesh>(r) {}
    00085         PatchMeshPtr(const ResourcePtr& r) : SharedPtr<PatchMesh>()
    00086         {
    00087             // lock & copy other mutex pointer
    00088             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
    00089             {
    00090                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
    00091                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
    00092                 pRep = static_cast<PatchMesh*>(r.getPointer());
    00093                 pUseCount = r.useCountPointer();
    00094                 if (pUseCount)
    00095                 {
    00096                     ++(*pUseCount);
    00097                 }
    00098             }
    00099         }
    00100
    00102         PatchMeshPtr& operator=(const ResourcePtr& r)
    00103         {
    00104             if (pRep == static_cast<PatchMesh*>(r.getPointer()))
    00105                 return *this;
    00106             release();
    00107
    00108             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
    00109             {
    00110                 // lock & copy other mutex pointer
    00111                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
    00112                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
    00113                 pRep = static_cast<PatchMesh*>(r.getPointer());
    00114                 pUseCount = r.useCountPointer();
    00115                 if (pUseCount)
    00116                 {
    00117                     ++(*pUseCount);
    00118                 }
    00119             }
    00120             else
    00121             {
    00122                 // RHS must be a null pointer
    00123                 assert(r.isNull() && "RHS must be null if it has no mutex!");
    00124                 setNull();
    00125             }
    00126             return *this;
    00127         }
    00129         PatchMeshPtr& operator=(const MeshPtr& r)
    00130         {
    00131             if (pRep == static_cast<PatchMesh*>(r.getPointer()))
    00132                 return *this;
    00133             release();
    00134             // lock & copy other mutex pointer
    00135             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
    00136             {
    00137                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
    00138                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
    00139                 pRep = static_cast<PatchMesh*>(r.getPointer());
    00140                 pUseCount = r.useCountPointer();
    00141                 if (pUseCount)
    00142                 {
    00143                     ++(*pUseCount);
    00144                 }
    00145             }
    00146             return *this;
    00147         }
    00148     };
    00149
    00150 }
    00151
    00152 #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 30 10:50:57 2007