Blender  V2.59
ntl_geometryobject.h
Go to the documentation of this file.
00001 
00004 /******************************************************************************
00005  *
00006  * El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method
00007  * Copyright 2003-2006 Nils Thuerey
00008  *
00009  * a geometry object
00010  * all other geometry objects are derived from this one
00011  *
00012  *****************************************************************************/
00013 #ifndef NTL_GEOMETRYOBJECT_H
00014 #define NTL_GEOMETRYOBJECT_H
00015 
00016 #include "ntl_geometryclass.h"
00017 #include "ntl_lighting.h"
00018 #include "ntl_ray.h"
00019 class ntlRenderGlobals;
00020 class ntlTriangle;
00021 
00022 #define DUMP_FULLGEOMETRY 1
00023 #define DUMP_PARTIAL      2
00024 
00025 #define VOLUMEINIT_VOLUME 1
00026 #define VOLUMEINIT_SHELL  2
00027 #define VOLUMEINIT_BOTH   (VOLUMEINIT_SHELL|VOLUMEINIT_VOLUME)
00028 
00029 class ntlGeometryObject : public ntlGeometryClass
00030 {
00031 
00032         public:
00034                 ntlGeometryObject();
00036                 virtual ~ntlGeometryObject();
00037 
00039                 virtual int getTypeId() { return GEOCLASSTID_OBJECT; }
00040 
00042                 virtual void initialize(ntlRenderGlobals *glob);
00043 
00045                 virtual void getTriangles(double t, vector<ntlTriangle> *triangles, 
00046                                 vector<ntlVec3Gfx> *vertices, 
00047                                 vector<ntlVec3Gfx> *normals, int objectId ) = 0;
00048                 
00050                 virtual void notifyOfDump(int dumptype, int frameNr,char *frameNrStr,string outfilename, double simtime);
00051 
00053                 void searchMaterial(vector<ntlMaterial *> *mat);
00054 
00055                 /* Acces methods */
00057                 inline void setMaterial(ntlMaterial *p) { mpMaterial = p; }
00059                 inline ntlMaterial *getMaterial( void ) { return mpMaterial; }
00061                 inline void setMaterialName(string set) { mMaterialName = set; }
00063                 inline string getMaterialName( void ) { return mMaterialName; }
00064 
00066                 inline void setReceiveShadows(int set) { mReceiveShadows=set; }
00068                 inline int getReceiveShadows() const { return mReceiveShadows; }
00069 
00071                 inline void setCastShadows(int set) { mCastShadows=set; }
00073                 inline int getCastShadows() const { return mCastShadows; }
00074 
00076                 inline void setGeoInitType(int set) { mGeoInitType=set; }
00078                 inline int getGeoInitType() const { return mGeoInitType; }
00079 
00081                 inline bool getGeoInitIntersect() const { return mGeoInitIntersect; }
00082                 inline void setGeoInitIntersect(bool set) { mGeoInitIntersect=set; }
00083 
00085                 inline float getGeoPartSlipValue() const { return mGeoPartSlipValue; }
00086                 inline void setGeoPartSlipValue(float set) { mGeoPartSlipValue=set; }
00087 
00089                 inline float getGeoImpactFactor(double t) { return mcGeoImpactFactor.get(t); }
00090                 inline void setGeoImpactFactor(float set) { mcGeoImpactFactor = AnimChannel<float>(set); }
00091 
00093                 inline int getVolumeInit() const { return mVolumeInit; }
00094                 inline void setVolumeInit(int set) { mVolumeInit=set; }
00095 
00097                 void setInitialVelocity(ntlVec3Gfx set);
00098                 ntlVec3Gfx getInitialVelocity(double t);
00099 
00101                 inline bool getLocalCoordInivel() const { return mLocalCoordInivel; }
00102                 inline void setLocalCoordInivel(bool set) { mLocalCoordInivel=set; }
00103                 
00104                 /****************************************/
00105                 /* fluid control features */
00106                 /****************************************/
00108                 inline float getCpsTimeStart() const { return mCpsTimeStart; }
00109                 inline void setCpsTimeStart(float set) { mCpsTimeStart=set; }
00110                 
00112                 inline float getCpsTimeEnd() const { return mCpsTimeEnd; }
00113                 inline void setCpsTimeEnd(float set) { mCpsTimeEnd=set; }
00114                 
00116                 inline float getCpsQuality() const { return mCpsQuality; }
00117                 inline void setCpsQuality(float set) { mCpsQuality=set; }
00118                 
00119                 inline AnimChannel<float> getCpsAttrFStr() const { return mcAttrFStr; }
00120                 inline AnimChannel<float> getCpsAttrFRad() const { return mcAttrFRad; }
00121                 inline AnimChannel<float> getCpsVelFStr() const { return mcVelFStr; }
00122                 inline AnimChannel<float> getCpsVelFRad() const { return mcVelFRad; }
00123                 
00124                 /****************************************/
00125                 
00127                 void initChannels(
00128                                 int nTrans, float *trans, int nRot, float *rot, int nScale, float *scale,
00129                                 int nAct, float *act, int nIvel, float *ivel,
00130                                 int nAttrFStr, float *attrFStr,
00131                                 int nAttrFRad, float *attrFRad,
00132                                 int nVelFStr, float *velFStr,
00133                                 int nVelFRad, float *velFRad
00134                                 );
00135 
00137                 inline bool getIsAnimated() const { return mIsAnimated; }
00139                 bool checkIsAnimated();
00141                 virtual bool getMeshAnimated();
00143                 virtual void calcTriangleDivs(vector<ntlVec3Gfx> &verts, vector<ntlTriangle> &tris, gfxReal fsTri);
00144 
00146                 void applyTransformation(double t, vector<ntlVec3Gfx> *verts, vector<ntlVec3Gfx> *norms, int vstart, int vend, int forceTrafo);
00147 
00149                 void initMovingPoints(double time, gfxReal featureSize);
00151                 void initMovingPointsAnim(
00152                  double srctime, vector<ntlVec3Gfx> &srcpoints,
00153                  double dsttime, vector<ntlVec3Gfx> &dstpoints,
00154                  vector<ntlVec3Gfx> *dstnormals,
00155                  gfxReal featureSize, ntlVec3Gfx geostart, ntlVec3Gfx geoend );
00157                 void getMovingPoints(vector<ntlVec3Gfx> &ret, vector<ntlVec3Gfx> *norms = NULL);
00159                 ntlVec3Gfx calculateMaxVel(double t1, double t2);
00161                 ntlVec3Gfx getTranslation(double t);
00163                 float getGeoActive(double t);
00164 
00166                 //  helper function for getTriangles
00167                 void sceneAddTriangle(
00168                                 ntlVec3Gfx  p1,ntlVec3Gfx  p2,ntlVec3Gfx  p3,
00169                                 ntlVec3Gfx pn1,ntlVec3Gfx pn2,ntlVec3Gfx pn3,
00170                                 ntlVec3Gfx trin, bool smooth,
00171                                 vector<ntlTriangle> *triangles,
00172                                 vector<ntlVec3Gfx>  *vertices,
00173                                 vector<ntlVec3Gfx>  *vertNormals);
00174                 void sceneAddTriangleNoVert(int *trips,
00175                                 ntlVec3Gfx trin, bool smooth,
00176                                 vector<ntlTriangle> *triangles);
00177 
00178         protected:
00179 
00180                 /* initialized for scene? */
00181                 bool mIsInitialized; 
00182 
00184                 ntlMaterial *mpMaterial;
00185 
00187                 string mMaterialName;
00188 
00190                 int mCastShadows;
00192                 int mReceiveShadows;
00193 
00194                 /* fluid init data */
00196                 int mGeoInitType;
00198                 ntlVec3Gfx mInitialVelocity;
00199                 AnimChannel<ntlVec3Gfx> mcInitialVelocity;
00201                 bool mLocalCoordInivel;
00203                 bool mGeoInitIntersect;
00205                 float mGeoPartSlipValue;
00207                 AnimChannel<float> mcGeoImpactFactor;
00209                 int mVolumeInit;
00210 
00212                 ntlVec3Gfx mInitialPos;
00214                 AnimChannel<ntlVec3Gfx> mcTrans, mcRot, mcScale;
00216                 bool mIsAnimated;
00217                 
00219                 vector<ntlVec3Gfx> mMovPoints;
00220                 vector<ntlVec3Gfx> mMovNormals;
00222                 bool mHaveCachedMov;
00223                 vector<ntlVec3Gfx> mCachedMovPoints;
00224                 vector<ntlVec3Gfx> mCachedMovNormals;
00226                 vector<int> mTriangleDivs1,mTriangleDivs2,mTriangleDivs3;
00228                 float mMovPntsInited;
00230                 int mMaxMovPnt;
00231 
00233                 AnimChannel<float> mcGeoActive;
00234                 
00235                 /* fluid control settings */
00236                 float mCpsTimeStart;
00237                 float mCpsTimeEnd;
00238                 float mCpsQuality;
00239                 AnimChannel<float> mcAttrFStr, mcAttrFRad, mcVelFStr, mcVelFRad;
00240 
00241         public:
00242 
00243 };
00244 
00245 #endif
00246