7 #ifndef __vegetation_Tree_h__ 8 #define __vegetation_Tree_h__ 15 typedef DenseVector<F64>
VectorN;
16 typedef SparseMatrix<F64>
MatrixN;
29 void initialize(
void);
30 virtual void reset(
void);
35 virtual void generate(
const Record seed);
36 virtual void addBranch(U32 a_fromIndex,U32 a_toIndex,
37 U32 a_level,Real a_radius1,Real a_radius2,
40 virtual void prepare(
void);
41 virtual void update(
const Real deltaT);
43 virtual U32 numSticks(
void)
const 44 { FEASSERT(m_sticks==m_stickArray.size());
47 { FEASSERT(index<m_stickMap.size());
48 I32 compactIndex=m_stickMap[index];
49 return compactIndex<0? NULL:
50 m_stickArray[compactIndex]; }
52 virtual U32 numLeaves(
void)
const 53 {
return m_leafArray.size(); }
55 { FEASSERT(index<numLeaves());
56 return m_leafArray[index]; }
58 const SpatialVector* leafPoints(
void)
const {
return m_pLeafPoints; }
60 const SpatialVector* leafNormals(
void)
const {
return m_pLeafNormals; }
62 virtual U32 stickBundles(
void)
const 63 { FEASSERT(m_bundles==m_bundleSize.size());
65 virtual U32 stickBundleSize(U32 bundle)
const 66 { FEASSERT(bundle<stickBundles());
67 return m_bundleSize[bundle]; }
70 { FEASSERT(bundle<stickBundles());
71 return m_stickTransformBundles[bundle]; }
74 { FEASSERT(bundle<stickBundles());
75 return m_stickScaleBundles[bundle]; }
77 const Real* stickBaseScale(U32 bundle)
const 78 { FEASSERT(bundle<stickBundles());
79 return m_stickBaseScaleBundles[bundle]; }
81 const U32* stickSlices(U32 bundle)
const 82 { FEASSERT(bundle<stickBundles());
83 return m_stickSliceBundles[bundle]; }
86 { m_location=location; }
90 virtual sp<SurfaceI> collider(
void) {
return m_spCollider; }
92 { m_spCollider=a_spCollider; }
95 {
return m_colliderTransform; }
96 virtual void setColliderTransform(
98 { m_colliderTransform=a_rColliderTransform; }
101 {
return m_effectorForce; }
104 { m_gravity=a_gravity; }
105 virtual void setUniformVelocity(
const SpatialVector& a_velocity)
106 { m_uniformVelocity=a_velocity; }
107 virtual void setUniformRigidity(
const Real a_rigidity)
108 { m_uniformRigidity=a_rigidity; }
109 virtual void setDamping(
const Real a_damping)
110 { m_damping=a_damping; }
111 virtual void setReactivity(
const Real a_reactivity)
112 { m_reactivity=a_reactivity; }
113 virtual void setThreshold(
const Real a_threshold)
114 { m_threshold=a_threshold; }
115 virtual void setCollisionMethod(
const String a_collisionMethod)
116 { m_collisionMethod=a_collisionMethod; }
117 virtual void setCollideEnd(
const BWORD a_collideEnd)
118 { m_collideEnd=a_collideEnd; }
119 virtual void setRepulsion(
const Real a_repulsion)
120 { m_repulsion=a_repulsion; }
121 virtual void setRepulsionFalloff(
const Real a_repulsionFalloff)
122 { m_repulsionFalloff=a_repulsionFalloff; }
123 virtual void setDepletion(
const Real a_depletion)
124 { m_depletion=a_depletion; }
125 virtual void setDepletionFalloff(
const Real a_depletionFalloff)
126 { m_depletionFalloff=a_depletionFalloff; }
127 virtual void setWindHampering(
const Real a_windHampering)
128 { m_windHampering=a_windHampering; }
129 virtual void setWindFalloff(
const Real a_windFalloff)
130 { m_windFalloff=a_windFalloff; }
131 virtual void setPlasticity(
const Real a_plasticity)
132 { m_plasticity=a_plasticity; }
133 virtual void setCompensation(
const BWORD a_compensation)
134 { m_compensation=a_compensation; }
135 virtual void setCorrection(
const BWORD a_correction)
136 { m_correction=a_correction; }
149 virtual ~
Leaf(
void) {}
150 virtual const SpatialVector& center(
void)
const {
return m_center; }
151 virtual const SpatialVector& normal(
void)
const {
return m_normal; }
165 m_children.setAutoDestruct(TRUE);
168 virtual ~
Stick(
void) {}
192 set(m_lastAddPosition);
197 m_children.deleteAll();
198 m_leafIndexArray.clear();
202 virtual const SpatialVector& base(
void)
const {
return m_base; }
203 virtual const SpatialVector& span(
void)
const {
return m_span; }
205 {
return m_rotation; }
206 virtual Real radius1(
void)
const 207 {
return m_radius1; }
208 virtual Real radius2(
void)
const 209 {
return m_radius2; }
210 virtual I32 resolution(
void)
const 211 {
return m_resolution; }
212 virtual String stateString(
void)
const 218 m_rest[0]+m_position[0],
219 m_rest[1]+m_position[1]);
222 virtual void setWindVelocity(
224 { m_windVelocity=a_windVelocity; }
225 virtual void setTarget(
227 { m_target=a_target; }
228 virtual void setTargeted(
229 const I32 a_targeted)
230 { m_targeted=a_targeted; }
232 void attach(
Stick* pChild)
234 m_children.append(pChild);
235 pChild->m_pParent=
this;
237 void attachLeaf(U32 leafIndex)
239 const U32 size=m_leafIndexArray.size();
240 m_leafIndexArray.resize(size+1);
241 m_leafIndexArray[size]=leafIndex;
244 void grow(
sp<Tree>& rspTree,U32& stick,
245 const U32 segment,
const U32 level,
246 const F32 a_fullLength,
const F32 along,
247 const F32 baseRotate,
const F32 rotate);
248 void populate_static(
sp<Tree>& rspTree,
249 MatrixN* dfdx,MatrixN* dfdv,
251 Real effectOfEffector(
sp<Tree>& rspTree,
254 void populate_dynamic(
sp<Tree>& rspTree,
257 VectorN* addPosition,
258 VectorN* addVelocity,
260 void forward_kine(U32 thread,
262 const VectorN* deltaV,
263 const VectorN* addPosition,
264 const VectorN* addVelocity,
267 void forward_kine_recursive(U32 thread,
270 const VectorN* deltaV,
271 const VectorN* addPosition,
272 const VectorN* addVelocity,
319 U32 index=m_kineArray.
size();
320 m_kineArray.resize(index+1,NULL);
321 m_kineArray[index]=pStick;
325 if(index>=m_stickArray.size())
327 m_stickArray.resize(index+1,NULL);
329 m_stickArray[index]=pStick;
334 const U32 size=m_leafArray.size();
335 m_leafArray.resize(size+1);
336 m_leafArray[size]=
new Leaf();
340 void forward_kine_thread(U32 thread,I32 index);
343 static F32 shapeFunction(
const F32 along,
344 const F32 valleybase,
349 void bindLevel(
const U32 level);
383 Real m_uniformRigidity;
389 BWORD m_compensation;
393 Real m_repulsionFalloff;
395 Real m_depletionFalloff;
396 Real m_windHampering;
414 VectorN m_velocity[2];
415 VectorN m_addPosition[2];
416 VectorN m_addVelocity[2];
417 VectorN m_tempVector1[2];
418 VectorN m_tempVector2[2];
426 VectorN m_invSqrtA[2];
430 MatrixN m_tempMatrix[2];
441 void runSolvers(
void);
444 class SolverWorker:
public Thread::Functor
450 m_hpJobQueue(a_spJobQueue) {}
452 virtual void operate(
void);
Stem Segment in a PlantModelI.
Definition: PlantModelI.h:28
Fully Bidirectional Doubly-Linked List.
Definition: List.h:496
kernel
Definition: namespace.dox:3
TreeSeed RecordView.
Definition: TreeSeed.h:26
Organ of photosynthesis and transpiration.
Definition: PlantModelI.h:47
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
Segment of a branch.
Definition: Tree.h:158
Dense vector - size fixed by template.
Definition: Vector.h:19
Vegetation model for a Dynamic Tree.
Definition: Tree.h:23
Leaf on a Tree.
Definition: Tree.h:139
Safe handle for shared pointer.
Definition: Handled.h:61
String & sPrintf(const char *fmt,...)
Populate the string in the manner of sprintf().
Definition: String.cc:529
Automatically reference-counted string container.
Definition: String.h:128
Reference to an instance of a Layout.
Definition: RecordSB.h:35
StickLevel RecordView.
Definition: StickLevel.h:35
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
U32 size(const Vector< N, T > &lhs)
Return the number of elements.
Definition: Vector.h:635
solve Ax=b for x
Definition: ConjugateGradient.h:38
Vegetation subsystem.
Definition: PlantModelI.h:20
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192