Blender V2.61 - r43446

subd_patch.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2011, Blender Foundation.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #ifndef __SUBD_PATCH_H__
00020 #define __SUBD_PATCH_H__
00021 
00022 #include "util_boundbox.h"
00023 #include "util_types.h"
00024 
00025 CCL_NAMESPACE_BEGIN
00026 
00027 class Mesh;
00028 
00029 /* Base */
00030 
00031 class Patch {
00032 public:
00033     virtual ~Patch() {}
00034     virtual void eval(float3 *P, float3 *dPdu, float3 *dPdv, float u, float v) = 0;
00035     virtual bool is_triangle() = 0;
00036     virtual BoundBox bound() = 0;
00037 };
00038 
00039 /* Linear Quad Patch */
00040 
00041 class LinearQuadPatch : public Patch {
00042 public:
00043     float3 hull[4];
00044 
00045     void eval(float3 *P, float3 *dPdu, float3 *dPdv, float u, float v);
00046     bool is_triangle() { return false; }
00047     BoundBox bound();
00048 };
00049 
00050 /* Linear Triangle Patch */
00051 
00052 class LinearTrianglePatch : public Patch {
00053 public:
00054     float3 hull[3];
00055 
00056     void eval(float3 *P, float3 *dPdu, float3 *dPdv, float u, float v);
00057     bool is_triangle() { return true; }
00058     BoundBox bound();
00059 };
00060 
00061 /* Bicubic Patch */
00062 
00063 class BicubicPatch : public Patch {
00064 public:
00065     float3 hull[16];
00066 
00067     void eval(float3 *P, float3 *dPdu, float3 *dPdv, float u, float v);
00068     bool is_triangle() { return false; }
00069     BoundBox bound();
00070 };
00071 
00072 /* Bicubic Patch with Tangent Fields */
00073 
00074 class BicubicTangentPatch : public Patch {
00075 public:
00076     float3 hull[16];
00077     float3 utan[12];
00078     float3 vtan[12];
00079 
00080     void eval(float3 *P, float3 *dPdu, float3 *dPdv, float u, float v);
00081     bool is_triangle() { return false; }
00082     BoundBox bound();
00083 };
00084 
00085 /* Gregory Patches */
00086 
00087 class GregoryQuadPatch : public Patch {
00088 public:
00089     float3 hull[20];
00090 
00091     void eval(float3 *P, float3 *dPdu, float3 *dPdv, float u, float v);
00092     bool is_triangle() { return false; }
00093     BoundBox bound();
00094 };
00095 
00096 class GregoryTrianglePatch : public Patch  {
00097 public:
00098     float3 hull[20];
00099 
00100     void eval(float3 *P, float3 *dPdu, float3 *dPdv, float u, float v);
00101     bool is_triangle() { return true; }
00102     BoundBox bound();
00103 };
00104 
00105 CCL_NAMESPACE_END
00106 
00107 #endif /* __SUBD_PATCH_H__ */
00108