00001 // Copyright (C) 2005 Dave Griffiths 00002 // 00003 // This program is free software; you can redistribute it and/or modify 00004 // it under the terms of the GNU General Public License as published by 00005 // the Free Software Foundation; either version 2 of the License, or 00006 // (at your option) any later version. 00007 // 00008 // This program is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 // GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License 00014 // along with this program; if not, write to the Free Software 00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00016 00017 #include "Primitive.h" 00018 00019 #ifndef N_NURBSPRIM 00020 #define N_NURBSPRIM 00021 00022 namespace Fluxus 00023 { 00024 00027 class NURBSPrimitive : public Primitive 00028 { 00029 public: 00030 NURBSPrimitive(); 00031 NURBSPrimitive(const NURBSPrimitive &other); 00032 virtual ~NURBSPrimitive(); 00033 00037 virtual NURBSPrimitive* Clone() const; 00038 virtual void Render(); 00039 virtual void RecalculateNormals(bool smooth); 00040 virtual dBoundingBox GetBoundingBox(); 00041 virtual void ApplyTransform(bool ScaleRotOnly=false); 00042 virtual string GetTypeName() { return "NURBSPrimitive"; } 00044 00049 void Init(int orderu, int orderv, int ucvs, int vcvs) { m_UOrder=orderu; m_VOrder=orderv; m_UCVCount=ucvs; m_VCVCount=vcvs; } 00050 void AddCV(const dVector &CV) { m_CVVec->push_back(CV); } 00051 void AddN(const dVector &N) { m_NVec->push_back(N); } 00052 void AddTex(const dVector &ST) { m_STVec->push_back(ST); } 00053 void AddUKnot(float k) { m_UKnotVec.push_back(k); } 00054 void AddVKnot(float k) { m_VKnotVec.push_back(k); } 00056 00057 protected: 00058 00059 virtual void PDataDirty(); 00060 void SetupSurface(); 00061 00062 vector<dVector> *m_CVVec; 00063 vector<dVector> *m_STVec; 00064 vector<dVector> *m_NVec; 00065 vector<float> m_UKnotVec; 00066 vector<float> m_VKnotVec; 00067 00068 int m_UOrder; 00069 int m_VOrder; 00070 int m_UCVCount; 00071 int m_VCVCount; 00072 int m_Stride; 00073 00074 GLUnurbsObj *m_Surface; 00075 }; 00076 00077 }; 00078 00079 #endif