Blender V2.61 - r43446

ntl_world.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  * Main renderer class
00010  *
00011  *****************************************************************************/
00012 #ifndef NTL_RAYTRACER_HH
00013 #define NTL_RAYTRACER_HH
00014 
00015 #include "ntl_vector3dim.h"
00016 #include "ntl_ray.h"
00017 #include "ntl_lighting.h"
00018 #include "ntl_geometryobject.h"
00019 #include "simulation_object.h"
00020 #include "elbeem.h"
00021 class ntlOpenGLRenderer;
00022 class ntlScene;
00023 class SimulationObject;
00024 class ntlRandomStream;
00025 
00026 class ntlWorld
00027 {
00028     public:
00030         ntlWorld();
00032         ntlWorld(string filename, bool commandlineMode);
00034         virtual ~ntlWorld( void );
00036         void initDefaults();
00038         void finishWorldInit();
00040         int addDomain(elbeemSimulationSettings *simSettings);
00041 
00043         int renderAnimation( void );
00045         int renderVisualization( bool );
00047         int singleStepVisualization( void );
00049         int advanceSims(int framenum);
00051         void singleStepSims(double targetTime);
00052 
00054         void setStopRenderVisualization(bool set) { mStopRenderVisualization = set; }
00056         bool getStopRenderVisualization() { return mStopRenderVisualization; }
00057 
00059         virtual int renderScene( void );
00060 
00062         void setSingleFrameOut( string singleframeFilename );
00063 
00064         /* access functions */
00065 
00067         inline void setRenderGlobals( ntlRenderGlobals *set) { mpGlob = set; }
00068         inline ntlRenderGlobals *getRenderGlobals( void )    { return mpGlob; }
00069 
00071         inline void setSimulationTime( double set) { mSimulationTime = set; }
00072         inline double getSimulationTime( void ) { return mSimulationTime; }
00073 
00075         inline void setSingleStepDebug( bool set) { mSingleStepDebug = set; }
00076         inline bool getSingleStepDebug( void ) { return mSingleStepDebug; }
00077 
00079         inline vector<SimulationObject*> *getSimulations( void ) { return mpSims; }
00080 
00082         inline ntlOpenGLRenderer *getOpenGLRenderer() { return mpOpenGLRenderer; }
00083 
00084     private:
00085 
00086     protected:
00087 
00089         ntlRenderGlobals        *mpGlob;
00090 
00092         vector<ntlLightObject*> *mpLightList;
00094         vector<ntlMaterial*>    *mpPropList;
00096         vector<SimulationObject*> *mpSims;
00097 
00099         ntlOpenGLRenderer *mpOpenGLRenderer;
00100 
00102         bool mStopRenderVisualization;
00103 
00105         bool mThreadRunning;
00106 
00108         double mSimulationTime;
00109 
00111         int mFirstSim;
00112 
00114         bool mSingleStepDebug;
00115 
00117         int mFrameCnt;
00118 };
00119 
00120 
00122 class ntlRenderGlobals
00123 {
00124     public:
00126         ntlRenderGlobals();
00128         ~ntlRenderGlobals();
00129 
00131         inline ntlScene *getRenderScene(void) { return mpRenderScene; }
00133         inline void setRenderScene(ntlScene *set) { mpRenderScene = set;} 
00134 
00136         inline ntlScene *getSimScene(void) { return mpSimScene; }
00138         inline void setSimScene(ntlScene *set) { mpSimScene = set;} 
00139 
00141         inline vector<ntlLightObject*> *getLightList(void) { return mpLightList; }
00143         inline void setLightList(vector<ntlLightObject*> *set) { mpLightList = set;} 
00144 
00146         inline vector<ntlMaterial*> *getMaterials(void) { return mpMaterials; }
00148         inline void setMaterials(vector<ntlMaterial*> *set) { mpMaterials = set;} 
00149 
00151         inline vector<SimulationObject*> *getSims(void) { return mpSims; }
00153         inline void setSims(vector<SimulationObject*> *set) { mpSims = set;} 
00154 
00156         inline void setResX(unsigned int set) { mResX = set; }
00158         inline void setResY(unsigned int set) { mResY = set; }
00160         inline void setAADepth(int set) { mAADepth = set; }
00162         inline void setMaxColVal(unsigned int set) { mMaxColVal = set; }
00164         inline void setRayMaxDepth(unsigned int set) { mRayMaxDepth = set; }
00166         inline void setEye(ntlVec3Gfx set) { mvEye = set; }
00168         inline void setLookat(ntlVec3Gfx set) { mvLookat = set; }
00170         inline void setUpVec(ntlVec3Gfx set) { mvUpvec = set; }
00172         inline void setAspect(float set) { mAspect = set; }
00174         inline void setFovy(float set) { mFovy = set; }
00176         inline void setBackgroundCol(ntlColor set) { mcBackgr = set; }
00178         inline void setAmbientLight(ntlColor set) { mcAmbientLight = set; }
00180         inline void setDebugOut(int  set) { mDebugOut = set; }
00181 
00183         inline void setAniStart(int set) { mAniStart = set; }
00185         inline void setAniFrames(int set) { mAniFrames = set; }
00187         inline void setAniCount(int set) { mAniCount = set; }
00189         inline void setCounterRays(int set) { mCounterRays = set; }
00191         inline void setCounterShades(int set) { mCounterShades = set; }
00193         inline void setCounterSceneInter(int set) { mCounterSceneInter = set; }
00195         inline void setFrameSkip(int set) { mFrameSkip = set; }
00196 
00198         inline void setOutFilename(string set) { mOutFilename = set; }
00199 
00201         inline void setTreeMaxDepth( int set ) { mTreeMaxDepth = set; }
00203         inline void setTreeMaxTriangles( int set ) { mTreeMaxTriangles = set; }
00204 
00206         inline void setTestSphereEnabled( bool set ) { mTestSphereEnabled = set; }
00208         inline void setTestSphereCenter( ntlVec3Gfx set ) { mTestSphereCenter = set; }
00210         inline void setTestSphereRadius( gfxReal set ) { mTestSphereRadius = set; }
00212         inline void setTestSphereMaterialName( char* set ) { mTestSphereMaterialName = set; }
00214         inline void setDebugPixel( int setx, int sety ) { mDebugPixelX = setx; mDebugPixelY = sety; }
00216         inline void setTestMode( bool set ) { mTestMode = set; }
00218         inline void setSingleFrameMode(bool set) {mSingleFrameMode = set; };
00220         inline void setSingleFrameFilename(string set) {mSingleFrameFilename = set; };
00221         
00222 
00224         inline unsigned int getResX(void) { return mResX; }
00226         inline unsigned int getResY(void) { return mResY; }
00228         inline int getAADepth(void) { return mAADepth; }
00230         inline unsigned int getMaxColVal(void) { return mMaxColVal; }
00232         inline unsigned int getRayMaxDepth(void) { return mRayMaxDepth; }
00234         inline ntlVec3Gfx getEye(void) { return mvEye; }
00236         inline ntlVec3Gfx getLookat(void) { return mvLookat; }
00238         inline ntlVec3Gfx getUpVec(void) { return mvUpvec; }
00240         inline float getAspect(void) { return mAspect; }
00242         inline float getFovy(void) { return mFovy; }
00244         inline ntlColor getBackgroundCol(void) { return mcBackgr; }
00246         inline ntlColor getAmbientLight(void) { return mcAmbientLight; }
00248         inline int getDebugOut(void) { return mDebugOut; }
00249 
00251         inline int getAniStart(void) { return mAniStart; }
00253         inline int getAniFrames(void) { return mAniFrames; }
00255         inline int getAniCount(void) { return mAniCount; }
00257         inline int getCounterRays(void) { return mCounterRays; }
00259         inline int getCounterShades(void) { return mCounterShades; }
00261         inline int getCounterSceneInter(void) { return mCounterSceneInter; }
00263         inline int getFrameSkip( void ) { return mFrameSkip; }
00264 
00265 
00267         inline string getOutFilename(void) { return mOutFilename; }
00268 
00270         inline int getTreeMaxDepth( void ) { return mTreeMaxDepth; }
00272         inline int getTreeMaxTriangles( void ) { return mTreeMaxTriangles; }
00273         
00275         inline AttributeList* getOpenGlAttributes( void ) { return mpOpenGlAttr; }
00277         inline AttributeList* getBlenderAttributes( void ) { return mpBlenderAttr; }
00278         
00280         inline bool getTestSphereEnabled( void ) { return mTestSphereEnabled; }
00282         inline ntlVec3Gfx getTestSphereCenter( void ) { return mTestSphereCenter; }
00284         inline gfxReal getTestSphereRadius( void) { return mTestSphereRadius; }
00286         inline char *getTestSphereMaterialName( void) { return mTestSphereMaterialName; }
00288         inline int getDebugPixelX( void ) { return mDebugPixelX; }
00290         inline int getDebugPixelY( void ) { return mDebugPixelY; }
00292         inline bool getTestMode( void ) { return mTestMode; }
00294         inline bool getSingleFrameMode() { return mSingleFrameMode; };
00296         inline string getSingleFrameFilename() { return mSingleFrameFilename; };
00297 
00298   
00299 private:
00300 
00302     ntlScene *mpRenderScene;
00304     ntlScene *mpSimScene;
00305 
00307   vector<ntlLightObject*> *mpLightList;
00309   vector<ntlMaterial*> *mpMaterials;
00311     vector<SimulationObject*> *mpSims;
00312 
00314   unsigned int mResX, mResY;
00316   int mAADepth;
00318   unsigned int mMaxColVal;
00319   /* Maximal ray recursion depth */
00320   int mRayMaxDepth;
00322   ntlVec3Gfx  mvEye;
00324   ntlVec3Gfx  mvLookat;
00326   ntlVec3Gfx  mvUpvec;
00328   float  mAspect;
00330   float  mFovy;
00332   ntlColor  mcBackgr;
00334   ntlColor  mcAmbientLight;
00336   char mDebugOut;
00337 
00338 
00340   int mAniStart;
00342   int mAniFrames;
00344   int mAniCount;
00346     int mFrameSkip;
00347 
00348 
00350   int  mCounterRays;
00352   int  mCounterShades;
00354   int  mCounterSceneInter;
00355 
00357   string mOutFilename;
00358 
00360     int mTreeMaxDepth;
00362     int mTreeMaxTriangles; 
00363 
00365     AttributeList *mpOpenGlAttr;
00367     AttributeList *mpBlenderAttr;
00368 
00369 
00371     bool mTestSphereEnabled;
00373     ntlVec3Gfx mTestSphereCenter;
00375     gfxReal mTestSphereRadius;
00377     char *mTestSphereMaterialName;
00379     int mDebugPixelX, mDebugPixelY;
00380 
00382     bool mTestMode;
00383 
00385     bool mSingleFrameMode;
00387     string mSingleFrameFilename;
00388 };
00389 
00390 
00391 
00392 #endif