blob: 3c5958477d4b98978b951c8ebef40e72f32f08d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
|
/** \file elbeem/intern/ntl_world.h
* \ingroup elbeem
*/
/******************************************************************************
*
* El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method
* Copyright 2003-2006 Nils Thuerey
*
* Main renderer class
*
*****************************************************************************/
#ifndef NTL_RAYTRACER_HH
#define NTL_RAYTRACER_HH
#include "ntl_vector3dim.h"
#include "ntl_ray.h"
#include "ntl_lighting.h"
#include "ntl_geometryobject.h"
#include "simulation_object.h"
#include "elbeem.h"
class ntlOpenGLRenderer;
class ntlScene;
class SimulationObject;
class ntlRandomStream;
class ntlWorld
{
public:
/*! Constructor for API init */
ntlWorld();
/*! Constructor */
ntlWorld(string filename, bool commandlineMode);
/*! Destructor */
virtual ~ntlWorld( void );
/*! default init for all contructors */
void initDefaults();
/*! common world contruction stuff once the scene is set up */
void finishWorldInit();
/*! add domain for API init */
int addDomain(elbeemSimulationSettings *simSettings);
/*! render a whole animation (command line mode) */
int renderAnimation( void );
/*! render a whole animation (visualization mode) */
int renderVisualization( bool );
/*! render a single step for viz mode */
int singleStepVisualization( void );
/*! advance simulations by time frame time */
int advanceSims(int framenum);
/*! advance simulations by a single step */
void singleStepSims(double targetTime);
/*! set stop rend viz flag */
void setStopRenderVisualization(bool set) { mStopRenderVisualization = set; }
/*! should the rendering viz thread be stopped? */
bool getStopRenderVisualization() { return mStopRenderVisualization; }
/*! render scene (a single pictures) */
virtual int renderScene( void );
/*! set single frame rendering to filename */
void setSingleFrameOut( string singleframeFilename );
/* access functions */
/*! set&get render globals */
inline void setRenderGlobals( ntlRenderGlobals *set) { mpGlob = set; }
inline ntlRenderGlobals *getRenderGlobals( void ) { return mpGlob; }
/*! set&get render globals */
inline void setSimulationTime( double set) { mSimulationTime = set; }
inline double getSimulationTime( void ) { return mSimulationTime; }
/*! set&get single step debug mode */
inline void setSingleStepDebug( bool set) { mSingleStepDebug = set; }
inline bool getSingleStepDebug( void ) { return mSingleStepDebug; }
/*! &get simulation object vector (debugging) */
inline vector<SimulationObject*> *getSimulations( void ) { return mpSims; }
/*! get opengl renderer */
inline ntlOpenGLRenderer *getOpenGLRenderer() { return mpOpenGLRenderer; }
private:
protected:
/*! global render settings needed almost everywhere */
ntlRenderGlobals *mpGlob;
/*! a list of lights in the scene (geometry is store in ntl_scene) */
vector<ntlLightObject*> *mpLightList;
/*! surface materials */
vector<ntlMaterial*> *mpPropList;
/*! sims list */
vector<SimulationObject*> *mpSims;
/*! opengl display */
ntlOpenGLRenderer *mpOpenGLRenderer;
/*! stop rend viz? */
bool mStopRenderVisualization;
/*! rend viz thread currently running? */
bool mThreadRunning;
/*! remember the current simulation time */
double mSimulationTime;
/*! first simulation that is valid */
int mFirstSim;
/*! single step mode for debugging */
bool mSingleStepDebug;
/*! count no. of frame for viz render */
int mFrameCnt;
};
//! Class that handles global rendering parameters
class ntlRenderGlobals
{
public:
//! Standard constructor
ntlRenderGlobals();
//! Destructor
~ntlRenderGlobals();
//! Returns the renderscene manager (scene changes for each frame)
inline ntlScene *getRenderScene(void) { return mpRenderScene; }
//! Set the renderscene manager
inline void setRenderScene(ntlScene *set) { mpRenderScene = set;}
//! Returns the simulation scene manager (static scene with sim objects)
inline ntlScene *getSimScene(void) { return mpSimScene; }
//! Set the simulation scene manager
inline void setSimScene(ntlScene *set) { mpSimScene = set;}
//! Returns the light object list
inline vector<ntlLightObject*> *getLightList(void) { return mpLightList; }
//! Set the light list
inline void setLightList(vector<ntlLightObject*> *set) { mpLightList = set;}
//! Returns the property object list
inline vector<ntlMaterial*> *getMaterials(void) { return mpMaterials; }
//! Set the property list
inline void setMaterials(vector<ntlMaterial*> *set) { mpMaterials = set;}
//! Returns the list of simulations
inline vector<SimulationObject*> *getSims(void) { return mpSims; }
//! Set the pointer to the list of simulations
inline void setSims(vector<SimulationObject*> *set) { mpSims = set;}
//! Set the x resolution
inline void setResX(unsigned int set) { mResX = set; }
//! Set the y resolution
inline void setResY(unsigned int set) { mResY = set; }
//! Set the anti-aliasing depth
inline void setAADepth(int set) { mAADepth = set; }
//! Set the max color value
inline void setMaxColVal(unsigned int set) { mMaxColVal = set; }
//! Set the maximum ray recursion
inline void setRayMaxDepth(unsigned int set) { mRayMaxDepth = set; }
//! Set the eye point
inline void setEye(ntlVec3Gfx set) { mvEye = set; }
//! Set the look at vector
inline void setLookat(ntlVec3Gfx set) { mvLookat = set; }
//! Set the up vector
inline void setUpVec(ntlVec3Gfx set) { mvUpvec = set; }
//! Set the image aspect
inline void setAspect(float set) { mAspect = set; }
//! Set the field of view
inline void setFovy(float set) { mFovy = set; }
//! Set the background color
inline void setBackgroundCol(ntlColor set) { mcBackgr = set; }
//! Set the ambient lighting color
inline void setAmbientLight(ntlColor set) { mcAmbientLight = set; }
//! Set the debug output var
inline void setDebugOut(int set) { mDebugOut = set; }
//! Set the animation start time
inline void setAniStart(int set) { mAniStart = set; }
//! Set the animation number of frames
inline void setAniFrames(int set) { mAniFrames = set; }
//! Set the animation
inline void setAniCount(int set) { mAniCount = set; }
//! Set the ray counter
inline void setCounterRays(int set) { mCounterRays = set; }
//! Set the ray shades counter
inline void setCounterShades(int set) { mCounterShades = set; }
//! Set the scenen intersection counter
inline void setCounterSceneInter(int set) { mCounterSceneInter = set; }
//! Set if existing frames should be skipped
inline void setFrameSkip(int set) { mFrameSkip = set; }
//! Set the outfilename
inline void setOutFilename(string set) { mOutFilename = set; }
//! get Maximum depth for BSP tree
inline void setTreeMaxDepth( int set ) { mTreeMaxDepth = set; }
//! get Maxmimum nr of triangles per BSP tree node
inline void setTreeMaxTriangles( int set ) { mTreeMaxTriangles = set; }
//! set the enable flag of the test sphere
inline void setTestSphereEnabled( bool set ) { mTestSphereEnabled = set; }
//! set the center of the test sphere
inline void setTestSphereCenter( ntlVec3Gfx set ) { mTestSphereCenter = set; }
//! set the radius of the test sphere
inline void setTestSphereRadius( gfxReal set ) { mTestSphereRadius = set; }
//! set the material name of the test sphere
inline void setTestSphereMaterialName( char* set ) { mTestSphereMaterialName = set; }
//! set debugging pixel coordinates
inline void setDebugPixel( int setx, int sety ) { mDebugPixelX = setx; mDebugPixelY = sety; }
//! set test mode flag
inline void setTestMode( bool set ) { mTestMode = set; }
//! set single frame mode flag
inline void setSingleFrameMode(bool set) {mSingleFrameMode = set; };
//! set single frame mode filename
inline void setSingleFrameFilename(string set) {mSingleFrameFilename = set; };
//! Return the x resolution
inline unsigned int getResX(void) { return mResX; }
//! Return the y resolution
inline unsigned int getResY(void) { return mResY; }
//! Return the anti-aliasing depth
inline int getAADepth(void) { return mAADepth; }
//! Return the max color value for ppm
inline unsigned int getMaxColVal(void) { return mMaxColVal; }
//! Return the maximum ray recursion
inline unsigned int getRayMaxDepth(void) { return mRayMaxDepth; }
//! Return the eye point
inline ntlVec3Gfx getEye(void) { return mvEye; }
//! Return the look at vector
inline ntlVec3Gfx getLookat(void) { return mvLookat; }
//! Return the up vector
inline ntlVec3Gfx getUpVec(void) { return mvUpvec; }
//! Return the image aspect
inline float getAspect(void) { return mAspect; }
//! Return the field of view
inline float getFovy(void) { return mFovy; }
//! Return the background color
inline ntlColor getBackgroundCol(void) { return mcBackgr; }
//! Return the ambient color
inline ntlColor getAmbientLight(void) { return mcAmbientLight; }
//! Return the debug mode setting
inline int getDebugOut(void) { return mDebugOut; }
//! Return the animation start time
inline int getAniStart(void) { return mAniStart; }
//! Return the animation frame number
inline int getAniFrames(void) { return mAniFrames; }
//! Return the animation counter
inline int getAniCount(void) { return mAniCount; }
//! Return the ray counter
inline int getCounterRays(void) { return mCounterRays; }
//! Return the ray shades counter
inline int getCounterShades(void) { return mCounterShades; }
//! Return the scene intersection counter
inline int getCounterSceneInter(void) { return mCounterSceneInter; }
//! Check if existing frames should be skipped
inline int getFrameSkip( void ) { return mFrameSkip; }
//! Return the outfilename
inline string getOutFilename(void) { return mOutFilename; }
//! get Maximum depth for BSP tree
inline int getTreeMaxDepth( void ) { return mTreeMaxDepth; }
//! get Maxmimum nr of triangles per BSP tree node
inline int getTreeMaxTriangles( void ) { return mTreeMaxTriangles; }
//! get open gl attribute list
inline AttributeList* getOpenGlAttributes( void ) { return mpOpenGlAttr; }
//! get blender output attribute list
inline AttributeList* getBlenderAttributes( void ) { return mpBlenderAttr; }
//! is the test sphere enabled?
inline bool getTestSphereEnabled( void ) { return mTestSphereEnabled; }
//! get the center of the test sphere
inline ntlVec3Gfx getTestSphereCenter( void ) { return mTestSphereCenter; }
//! get the radius of the test sphere
inline gfxReal getTestSphereRadius( void) { return mTestSphereRadius; }
//! get the materialname of the test sphere
inline char *getTestSphereMaterialName( void) { return mTestSphereMaterialName; }
//! get the debug pixel coordinate
inline int getDebugPixelX( void ) { return mDebugPixelX; }
//! get the debug pixel coordinate
inline int getDebugPixelY( void ) { return mDebugPixelY; }
//! get test mode flag
inline bool getTestMode( void ) { return mTestMode; }
//! set single frame mode flag
inline bool getSingleFrameMode() { return mSingleFrameMode; };
//! set single frame mode filename
inline string getSingleFrameFilename() { return mSingleFrameFilename; };
private:
/*! Scene storage (dynamic rendering scene) */
ntlScene *mpRenderScene;
/*! Scene storage (static sim scene, inited only once) */
ntlScene *mpSimScene;
//! List of light objects
vector<ntlLightObject*> *mpLightList;
//! List of surface properties
vector<ntlMaterial*> *mpMaterials;
/*! storage for simulations */
vector<SimulationObject*> *mpSims;
//! resolution of the picture
unsigned int mResX, mResY;
//! Anti-Aliasing depth
int mAADepth;
//! max color value for ppm
unsigned int mMaxColVal;
/* Maximal ray recursion depth */
int mRayMaxDepth;
//! The eye point
ntlVec3Gfx mvEye;
//! The look at point
ntlVec3Gfx mvLookat;
//! The up vector
ntlVec3Gfx mvUpvec;
//! The image aspect = Xres/Yres
float mAspect;
//! The horizontal field of view
float mFovy;
//! The background color
ntlColor mcBackgr;
//! The ambient color
ntlColor mcAmbientLight;
//! how much debug output is needed? off by default
char mDebugOut;
//! animation properties, start time
int mAniStart;
//! animation properties, number of frames to render
int mAniFrames;
//! animation status, current frame number
int mAniCount;
/*! Should existing picture frames be skipped? */
int mFrameSkip;
//! count the total number of rays created (also used for ray ID's)
int mCounterRays;
//! count the total number of rays shaded
int mCounterShades;
//! count the total number of scene intersections
int mCounterSceneInter;
/*! filename of output pictures (without suffix or numbers) */
string mOutFilename;
//! get Maximum depth for BSP tree
int mTreeMaxDepth;
//! get Maxmimum nr of triangles per BSP tree node
int mTreeMaxTriangles;
//! attribute list for opengl renderer
AttributeList *mpOpenGlAttr;
//! attribute list for blender output
AttributeList *mpBlenderAttr;
//! Enable test sphere?
bool mTestSphereEnabled;
//! Center of the test sphere
ntlVec3Gfx mTestSphereCenter;
//! Radius of the test sphere
gfxReal mTestSphereRadius;
//! Materialname of the test sphere
char *mTestSphereMaterialName;
//! coordinates of the debugging pixel
int mDebugPixelX, mDebugPixelY;
//! test mode for quick rendering activated?, inited in ntl_scene::buildScene
bool mTestMode;
//! single frame flag
bool mSingleFrameMode;
//! filename for single frame mode
string mSingleFrameFilename;
};
#endif
|