1 /* 2 ----------------------------------------------------------------------------- 3 This source file is part of OGRE 4 (Object-oriented Graphics Rendering Engine) 5 For the latest info, see http://www.ogre3d.org/ 6 7 Copyright (c) 2000-2014 Torus Knot Software Ltd 8 9 Permission is hereby granted, free of charge, to any person obtaining a copy 10 of this software and associated documentation files (the "Software"), to deal 11 in the Software without restriction, including without limitation the rights 12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 copies of the Software, and to permit persons to whom the Software is 14 furnished to do so, subject to the following conditions: 15 16 The above copyright notice and this permission notice shall be included in 17 all copies or substantial portions of the Software. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 THE SOFTWARE. 26 ----------------------------------------------------------------------------- 27 */ 28 #ifndef __Ogre_Volume_IsoSurface_H__ 29 #define __Ogre_Volume_IsoSurface_H__ 30 31 #include "OgreVolumePrerequisites.h" 32 #include "OgrePrerequisites.h" 33 34 namespace Ogre { 35 namespace Volume { 36 /** \addtogroup Optional 37 * @{ 38 */ 39 /** \addtogroup Volume 40 * @{ 41 */ 42 class Source; 43 class MeshBuilder; 44 45 /** Abstract IsoSurface. 46 */ 47 class _OgreVolumeExport IsoSurface : public UtilityAlloc 48 { 49 protected: 50 51 /// The value where our isosurface is. 52 static const Real ISO_LEVEL; 53 54 /// To get the isovalue and normal. 55 const Source *mSrc; 56 57 /** Constructor. 58 @param src 59 The source to use. 60 */ 61 explicit IsoSurface(const Source *src); 62 63 public: 64 65 /// To call Marching Squares with a cube on its front. 66 static const size_t MS_CORNERS_FRONT[4]; 67 68 /// To call Marching Squares with a cube on its back. 69 static const size_t MS_CORNERS_BACK[4]; 70 71 /// To call Marching Squares with a cube on its left. 72 static const size_t MS_CORNERS_LEFT[4]; 73 74 /// To call Marching Squares with a cube on its right. 75 static const size_t MS_CORNERS_RIGHT[4]; 76 77 /// To call Marching Squares with a cube on its top. 78 static const size_t MS_CORNERS_TOP[4]; 79 80 /// To call Marching Squares with a cube on its bottom. 81 static const size_t MS_CORNERS_BOTTOM[4]; 82 83 virtual ~IsoSurface(void); 84 85 /** Adds triangles to a MeshBuilder via Marching Cubes. 86 @param corners 87 The corners of the cube to triangulate via Marching Cubes. 88 @param volumeValues 89 The cached volume values, one Vector4 consists of gradient (x, y, z) and density (w). If 0 is given, it will be calculated. 90 @param mb 91 The MeshBuilder to add the triangles to. 92 */ 93 virtual void addMarchingCubesTriangles(const Vector3 *corners, const Vector4 *volumeValues, MeshBuilder *mb) const = 0; 94 95 /** Adds triangles to a MeshBuilder via Marching Squares. 96 @param corners 97 The corners of the cube where one side is to be triangulated. 98 @param volumeValues 99 The cached volume values, one Vector4 consists of gradient (x, y, z) and density (w). If 0 is given, it will be calculated. 100 @param indices 101 The four corners of the cube (== one side) to triangulate. 102 @param maxDistance 103 The maximum distance to the surface where triangles are generated. 104 @param mb 105 The MeshBuilder to add the triangles to. 106 */ 107 virtual void addMarchingSquaresTriangles(const Vector3 *corners, const Vector4 *volumeValues, const size_t *indices, const Real maxDistance, MeshBuilder *mb) const = 0; 108 }; 109 /** @} */ 110 /** @} */ 111 } 112 } 113 114 #endif 115