BlobbyPrimitive.h

Go to the documentation of this file.
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 <set>
00018 
00019 #include "Primitive.h"
00020 #include "PolyPrimitive.h"
00021 
00022 #ifndef N_BLOBBYPRIM
00023 #define N_BLOBBYPRIM
00024 
00025 namespace Fluxus
00026 {
00027 
00033 class BlobbyPrimitive : public Primitive
00034 {
00035 public:
00036     
00037     BlobbyPrimitive(int dimx, int dimy, int dimz, dVector size);
00038     BlobbyPrimitive(const BlobbyPrimitive &other);
00039     virtual  ~BlobbyPrimitive();
00040     
00044     virtual BlobbyPrimitive* Clone() const;
00045     virtual void Render();
00046     virtual dBoundingBox GetBoundingBox();
00047     virtual void RecalculateNormals(bool smooth);
00048     virtual void ApplyTransform(bool ScaleRotOnly=false);
00049     virtual string GetTypeName() { return "BlobbyPrimitive"; }
00051     
00055     virtual void AddInfluence(const dVector &Vert, float Strength); 
00056     
00059     void ConvertToPoly(PolyPrimitive &poly, float isolevel=1.0f);
00060     
00061 protected:
00062     class Triangle 
00063     {
00064     public:
00065         dVector p[3];
00066     };
00067 
00068     class Cell 
00069     {
00070     public:
00071         dVector p[8];
00072         float val[8];
00073         dColour col[8];
00074     };
00075     
00076     void Draw(float isolevel, bool calcnormals, bool colour);
00077     void Interpolate(dVertex &vert, float isolevel, int cell, int a, int b);
00078     float Sample(const dVector &pos);
00079     float SampleCol(const dVector &pos, dColour &col);
00080         
00081     virtual void PDataDirty();
00082     
00083     vector<dVector> *m_PosData;
00084     vector<float> *m_StrengthData;
00085     vector<dColour> *m_ColData;
00086     
00087     vector<Cell> m_Voxels;
00088 };
00089 
00090 };
00091 
00092 #endif

Generated on Tue Sep 4 23:22:18 2007 for The Fluxus Renderer (libfluxus) by  doxygen 1.5.1