Visualization LibraryA lightweight C++ OpenGL middleware for 2D/3D graphics |
[Home] [Tutorials] [All Classes] [Grouped Classes] |
00001 /**************************************************************************************/ 00002 /* */ 00003 /* Visualization Library */ 00004 /* http://www.visualizationlibrary.com */ 00005 /* */ 00006 /* Copyright (c) 2005-2010, Michele Bosi */ 00007 /* All rights reserved. */ 00008 /* */ 00009 /* Redistribution and use in source and binary forms, with or without modification, */ 00010 /* are permitted provided that the following conditions are met: */ 00011 /* */ 00012 /* - Redistributions of source code must retain the above copyright notice, this */ 00013 /* list of conditions and the following disclaimer. */ 00014 /* */ 00015 /* - Redistributions in binary form must reproduce the above copyright notice, this */ 00016 /* list of conditions and the following disclaimer in the documentation and/or */ 00017 /* other materials provided with the distribution. */ 00018 /* */ 00019 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */ 00020 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */ 00021 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ 00022 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */ 00023 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ 00024 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */ 00025 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ 00026 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ 00027 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ 00028 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00029 /* */ 00030 /**************************************************************************************/ 00031 00032 #ifndef BezierSurface_INCLUDE_ONCE 00033 #define BezierSurface_INCLUDE_ONCE 00034 00035 #include <vlGraphics/Geometry.hpp> 00036 00037 namespace vl 00038 { 00044 class VLGRAPHICS_EXPORT BezierPatch: public Object 00045 { 00046 public: 00048 typedef std::vector< vec3 > Points; 00049 virtual const char* className() { return "vl::BezierPatch"; } 00051 BezierPatch(): mX(0), mY(0) {} 00053 BezierPatch(int x, int y): mX(0), mY(0) { resize(x,y); } 00056 void resize(int x, int y); 00058 int x() const { return mX; } 00060 int y() const { return mY; } 00062 Points& points() { return mControlPoints; } 00064 const Points& points() const { return mControlPoints; } 00066 vec3& at(int i, int j) { return mControlPoints[i + mX*j]; } 00068 const vec3& at(int i, int j) const { return mControlPoints[i + mX*j]; } 00069 protected: 00070 Points mControlPoints; 00071 int mX; 00072 int mY; 00073 }; 00074 00086 class VLGRAPHICS_EXPORT BezierSurface: public Geometry 00087 { 00088 public: 00089 virtual const char* className() { return "vl::BezierSurface"; } 00091 BezierSurface(): mDetail(16) {} 00092 00094 std::vector< ref<BezierPatch> >& patches() { return mPatches; } 00096 const std::vector< ref<BezierPatch> >& patches() const { return mPatches; } 00097 00099 void setDetail(unsigned i) { mDetail = i; } 00100 00102 unsigned detail() const { return mDetail; } 00103 00108 void updateBezierSurface(bool gen_tex_coords=true); 00109 00110 protected: 00111 std::vector< ref<BezierPatch> > mPatches; 00112 unsigned mDetail; 00113 }; 00114 } 00115 00116 #endif