Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ntl_geometryobject.h « intern « elbeem « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2c2291933587f95e86fab412f7bfd00e21319e86 (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
/** \file elbeem/intern/ntl_geometryobject.h
 *  \ingroup elbeem
 */
/******************************************************************************
 *
 * El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method
 * Copyright 2003-2006 Nils Thuerey
 *
 * a geometry object
 * all other geometry objects are derived from this one
 *
 *****************************************************************************/
#ifndef NTL_GEOMETRYOBJECT_H
#define NTL_GEOMETRYOBJECT_H

#include "ntl_geometryclass.h"
#include "ntl_lighting.h"
#include "ntl_ray.h"

#ifdef WITH_CXX_GUARDEDALLOC
#  include "MEM_guardedalloc.h"
#endif

class ntlRenderGlobals;
class ntlTriangle;

#define DUMP_FULLGEOMETRY 1
#define DUMP_PARTIAL      2

#define VOLUMEINIT_VOLUME 1
#define VOLUMEINIT_SHELL  2
#define VOLUMEINIT_BOTH   (VOLUMEINIT_SHELL|VOLUMEINIT_VOLUME)

class ntlGeometryObject : public ntlGeometryClass
{

	public:
		//! Default constructor
		ntlGeometryObject();
		//! Default destructor
		virtual ~ntlGeometryObject();

		//! Return type id
		virtual int getTypeId() { return GEOCLASSTID_OBJECT; }

		/*! Init attributes etc. of this object */
		virtual void initialize(ntlRenderGlobals *glob);

		/*! Get the triangles from this object */
		virtual void getTriangles(double t, vector<ntlTriangle> *triangles, 
				vector<ntlVec3Gfx> *vertices, 
				vector<ntlVec3Gfx> *normals, int objectId ) = 0;
		
		/*! notify object that dump is in progress (e.g. for particles) */
		virtual void notifyOfDump(int dumptype, int frameNr,char *frameNrStr,string outfilename, double simtime);

		/*! Search the material for this object from the material list */
		void searchMaterial(vector<ntlMaterial *> *mat);

		/* Acces methods */
		/*! Set the property of this object */
		inline void setMaterial(ntlMaterial *p) { mpMaterial = p; }
		/*! Get the surface property of this object */
		inline ntlMaterial *getMaterial( void ) { return mpMaterial; }
		/*! Set the object property name */
		inline void setMaterialName(string set) { mMaterialName = set; }
		/*! Get the object property name */
		inline string getMaterialName( void ) { return mMaterialName; }

		/*! Sets the receive shadows attribute */
		inline void setReceiveShadows(int set) { mReceiveShadows=set; }
		/*! Returns the receive shadows attribute */
		inline int getReceiveShadows() const { return mReceiveShadows; }

		/*! Sets the cast shadows attribute */
		inline void setCastShadows(int set) { mCastShadows=set; }
		/*! Returns the cast shadows attribute */
		inline int getCastShadows() const { return mCastShadows; }

		/*! Returns the geo init typ */
		inline void setGeoInitType(int set) { mGeoInitType=set; }
		/*! Returns the geo init typ */
		inline int getGeoInitType() const { return mGeoInitType; }

		/*! Set/get the intersect init flag */
		inline bool getGeoInitIntersect() const { return mGeoInitIntersect; }
		inline void setGeoInitIntersect(bool set) { mGeoInitIntersect=set; }

		/*! Set/get the part slip value*/
		inline float getGeoPartSlipValue() const { return mGeoPartSlipValue; }
		inline void setGeoPartSlipValue(float set) { mGeoPartSlipValue=set; }

		/*! Set/get the impact corr factor channel */
		inline float getGeoImpactFactor(double t) { return mcGeoImpactFactor.get(t); }
		inline void setGeoImpactFactor(float set) { mcGeoImpactFactor = AnimChannel<float>(set); }

		/*! Set/get the part slip value*/
		inline int getVolumeInit() const { return mVolumeInit; }
		inline void setVolumeInit(int set) { mVolumeInit=set; }

		/*! Set/get the cast initial veocity attribute */
		void setInitialVelocity(ntlVec3Gfx set);
		ntlVec3Gfx getInitialVelocity(double t);

		/*! Set/get the local inivel coords flag */
		inline bool getLocalCoordInivel() const { return mLocalCoordInivel; }
		inline void setLocalCoordInivel(bool set) { mLocalCoordInivel=set; }
		
		/****************************************/
		/* fluid control features */
		/****************************************/
		/*! Set/get the particle control set attract force strength */
		inline float getCpsTimeStart() const { return mCpsTimeStart; }
		inline void setCpsTimeStart(float set) { mCpsTimeStart=set; }
		
		/*! Set/get the particle control set attract force strength */
		inline float getCpsTimeEnd() const { return mCpsTimeEnd; }
		inline void setCpsTimeEnd(float set) { mCpsTimeEnd=set; }
		
		/*! Set/get the particle control set quality */
		inline float getCpsQuality() const { return mCpsQuality; }
		inline void setCpsQuality(float set) { mCpsQuality=set; }
		
		inline AnimChannel<float> getCpsAttrFStr() const { return mcAttrFStr; }
		inline AnimChannel<float> getCpsAttrFRad() const { return mcAttrFRad; }
		inline AnimChannel<float> getCpsVelFStr() const { return mcVelFStr; }
		inline AnimChannel<float> getCpsVelFRad() const { return mcVelFRad; }
		
		/****************************************/
		
		/*! Init channels from float arrays (for elbeem API) */
		void initChannels(
				int nTrans, float *trans, int nRot, float *rot, int nScale, float *scale,
				int nAct, float *act, int nIvel, float *ivel,
				int nAttrFStr, float *attrFStr,
				int nAttrFRad, float *attrFRad,
				int nVelFStr, float *velFStr,
				int nVelFRad, float *velFRad
				);

		/*! is the object animated? */
		inline bool getIsAnimated() const { return mIsAnimated; }
		/*! init object anim flag */
		bool checkIsAnimated();
		/*! is the mesh animated? */
		virtual bool getMeshAnimated();
		/*! init triangle divisions */
		virtual void calcTriangleDivs(vector<ntlVec3Gfx> &verts, vector<ntlTriangle> &tris, gfxReal fsTri);

		/*! apply object translation at time t*/
		void applyTransformation(double t, vector<ntlVec3Gfx> *verts, vector<ntlVec3Gfx> *norms, int vstart, int vend, int forceTrafo);

		/*! Prepare points for moving objects */
		void initMovingPoints(double time, gfxReal featureSize);
		/*! Prepare points for animated objects */
		void initMovingPointsAnim(
		 double srctime, vector<ntlVec3Gfx> &srcpoints,
		 double dsttime, vector<ntlVec3Gfx> &dstpoints,
		 vector<ntlVec3Gfx> *dstnormals,
		 gfxReal featureSize, ntlVec3Gfx geostart, ntlVec3Gfx geoend );
		/*! Prepare points for moving objects (copy into ret) */
		void getMovingPoints(vector<ntlVec3Gfx> &ret, vector<ntlVec3Gfx> *norms = NULL);
		/*! Calculate max. velocity on object from t1 to t2 */
		ntlVec3Gfx calculateMaxVel(double t1, double t2);
		/*! get translation at time t*/
		ntlVec3Gfx getTranslation(double t);
		/*! get active flag time t*/
		float getGeoActive(double t);

		/*! add triangle to scene and init flags */
		//  helper function for getTriangles
		void sceneAddTriangle(
				ntlVec3Gfx  p1,ntlVec3Gfx  p2,ntlVec3Gfx  p3,
				ntlVec3Gfx pn1,ntlVec3Gfx pn2,ntlVec3Gfx pn3,
				ntlVec3Gfx trin, bool smooth,
				vector<ntlTriangle> *triangles,
				vector<ntlVec3Gfx>  *vertices,
				vector<ntlVec3Gfx>  *vertNormals);
		void sceneAddTriangleNoVert(int *trips,
				ntlVec3Gfx trin, bool smooth,
				vector<ntlTriangle> *triangles);

	protected:

		/* initialized for scene? */
		bool mIsInitialized; 

		/*! Point to a property object describing the surface of this object */
		ntlMaterial *mpMaterial;

		/*! Name of the surcace property */
		string mMaterialName;

		/*! Cast shadows on/off */
		int mCastShadows;
		/*! REceive shadows on/off */
		int mReceiveShadows;

		/* fluid init data */
		/*! fluid object type (fluid, obstacle, accelerator etc.) */
		int mGeoInitType;
		/*! initial velocity for fluid objects */
		ntlVec3Gfx mInitialVelocity;
		AnimChannel<ntlVec3Gfx> mcInitialVelocity;
		/*! use object local inflow? */
		bool mLocalCoordInivel;
		/*! perform more accurate intersecting geo init for this object? */
		bool mGeoInitIntersect;
		/*! part slip bc value */
		float mGeoPartSlipValue;
		/*! obstacle impact correction factor */
		AnimChannel<float> mcGeoImpactFactor;
		/*! only init as thin object, dont fill? */
		int mVolumeInit;

		/*! initial offset for rot/scale */
		ntlVec3Gfx mInitialPos;
		/*! animated channels for postition, rotation and scale */
		AnimChannel<ntlVec3Gfx> mcTrans, mcRot, mcScale;
		/*! easy check for animation */
		bool mIsAnimated;
		
		/*! moving point/normal storage */
		vector<ntlVec3Gfx> mMovPoints;
		vector<ntlVec3Gfx> mMovNormals;
		/*! cached points for non moving objects/timeslots */
		bool mHaveCachedMov;
		vector<ntlVec3Gfx> mCachedMovPoints;
		vector<ntlVec3Gfx> mCachedMovNormals;
		/*! precomputed triangle divisions */
		vector<int> mTriangleDivs1,mTriangleDivs2;
		/*! inited? */
		float mMovPntsInited;
		/*! point with max. distance from center */
		int mMaxMovPnt;

		/*! animated channels for in/outflow on/off */
		AnimChannel<float> mcGeoActive;
		
		/* fluid control settings */
		float mCpsTimeStart;
		float mCpsTimeEnd;
		float mCpsQuality;
		AnimChannel<float> mcAttrFStr, mcAttrFRad, mcVelFStr, mcVelFRad;

	public:

private:
#ifdef WITH_CXX_GUARDEDALLOC
	MEM_CXX_CLASS_ALLOC_FUNCS("ELBEEM:ntlGeometryObject")
#endif
};

#endif