00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
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