source: OGRE/trunk/ogrenew/OgreMain/include/OgrePatchMesh.h @ 657

Revision 657, 5.1 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#ifndef __PatchMesh_H__
26#define __PatchMesh_H__
27
28#include "OgrePrerequisites.h"
29#include "OgreMesh.h"
30#include "OgrePatchSurface.h"
31
32namespace Ogre {
33
34    /** Patch specialisation of Mesh.
35    @remarks
36        Instances of this class should be created by calling MeshManager::createBezierPatch.
37    */
38    class _OgreExport PatchMesh : public Mesh
39    {
40    protected:
41        /// Internal surface definition
42        PatchSurface mSurface;
43        /// Vertex declaration, cloned from the input
44        VertexDeclaration* mDeclaration;
45    public:
46        /// Constructor
47        PatchMesh(ResourceManager* creator, const String& name, ResourceHandle handle,
48            const String& group);
49
50        /// Define the patch, as defined in MeshManager::createBezierPatch
51        void define(void* controlPointBuffer,
52            VertexDeclaration *declaration, size_t width, size_t height,
53            size_t uMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
54            size_t vMaxSubdivisionLevel = PatchSurface::AUTO_LEVEL,
55            PatchSurface::VisibleSide visibleSide = PatchSurface::VS_FRONT,
56            HardwareBuffer::Usage vbUsage = HardwareBuffer::HBU_STATIC_WRITE_ONLY,
57            HardwareBuffer::Usage ibUsage = HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
58            bool vbUseShadow = false, bool ibUseShadow = false);
59
60        /* Sets the current subdivision level as a proportion of full detail.
61        @param factor Subdivision factor as a value from 0 (control points only) to 1 (maximum
62            subdivision). */
63        void setSubdivision(Real factor);
64    protected:
65        /// Overridden from Resource
66        void loadImpl(void);
67
68    };
69    /** Specialisation of SharedPtr to allow SharedPtr to be assigned to PatchMeshPtr
70    @note Has to be a subclass since we need operator=.
71    We could templatise this instead of repeating per Resource subclass,
72    except to do so requires a form VC6 does not support i.e.
73    ResourceSubclassPtr<T> : public SharedPtr<T>
74    */
75    class _OgreExport PatchMeshPtr : public SharedPtr<PatchMesh>
76    {
77    public:
78        PatchMeshPtr() : SharedPtr<PatchMesh>() {}
79        explicit PatchMeshPtr(PatchMesh* rep) : SharedPtr<PatchMesh>(rep) {}
80        PatchMeshPtr(const PatchMeshPtr& r) : SharedPtr<PatchMesh>(r) {}
81        PatchMeshPtr(const ResourcePtr& r) : SharedPtr<PatchMesh>()
82        {
83                        // lock & copy other mutex pointer
84                        OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
85                        OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
86            pRep = static_cast<PatchMesh*>(r.getPointer());
87            pUseCount = r.useCountPointer();
88            if (pUseCount)
89            {
90                ++(*pUseCount);
91            }
92        }
93
94        /// Operator used to convert a ResourcePtr to a PatchMeshPtr
95        PatchMeshPtr& operator=(const ResourcePtr& r)
96        {
97            if (pRep == static_cast<PatchMesh*>(r.getPointer()))
98                return *this;
99            release();
100                        // lock & copy other mutex pointer
101                        OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
102                        OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
103            pRep = static_cast<PatchMesh*>(r.getPointer());
104            pUseCount = r.useCountPointer();
105            if (pUseCount)
106            {
107                ++(*pUseCount);
108            }
109            return *this;
110        }
111        /// Operator used to convert a MeshPtr to a PatchMeshPtr
112        PatchMeshPtr& operator=(const MeshPtr& r)
113        {
114            if (pRep == static_cast<PatchMesh*>(r.getPointer()))
115                return *this;
116            release();
117                        // lock & copy other mutex pointer
118                        OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
119                        OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
120            pRep = static_cast<PatchMesh*>(r.getPointer());
121            pUseCount = r.useCountPointer();
122            if (pUseCount)
123            {
124                ++(*pUseCount);
125            }
126            return *this;
127        }
128    };
129
130}
131
132#endif
Note: See TracBrowser for help on using the repository browser.