Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions plugins/weberpenntree/include/WeberPennTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ struct WeberPennTreeParameters{
// Fractional height of split (if BaseSplits>0)
float BaseSplitSize, BaseSplitSizeV;

// Tilt of the trunk
helios::vec2 BaseTilt, BaseTiltV;

// x and y spread values for the positions of the nodes along the trunk
// If 0, the base will be perfectly straight. Otherwise it will be more winding or crooked.
helios::vec2 BaseAlignmentV;

// Size and scaling of tree
float Scale, ScaleV, ZScale, ZScaleV;

Expand Down
39 changes: 37 additions & 2 deletions plugins/weberpenntree/src/WeberPennTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ uint WeberPennTree::buildTree( const char* treename, helios::vec3 origin, float
if( base_size > 0 && parameters.BaseSizeV > 0 )
base_size += getVariation(parameters.BaseSizeV);

helios::vec2 base_tilt = parameters.BaseTilt;
base_tilt.x += getVariation(parameters.BaseTiltV.x);
base_tilt.y += getVariation(parameters.BaseTiltV.y);

//Region above trunk base

if( base_splits > 0 ){ //trunk splits at base
Expand All @@ -190,7 +194,16 @@ uint WeberPennTree::buildTree( const char* treename, helios::vec3 origin, float
for( uint i=1; i<base_nodes; i++ ){

//nodes.at(i) = nodes.at(i-1) + rotatePoint( make_vec3( 0, 0, length0*(1-parameters.BaseSize)/parameters.nCurveRes.at(0) ), theta, phi );
nodes.at(i) = nodes.at(i-1) + make_vec3( 0, 0, length0*base0/float(base_nodes) );
nodes.at(i) = make_vec3(
i * base_tilt.x / base_nodes,
i * base_tilt.y / base_nodes,
nodes.at(i-1).z
) +
make_vec3(
getVariation(parameters.BaseAlignmentV.x),
getVariation(parameters.BaseAlignmentV.y),
length0*base0/float(base_nodes)
);

float y = std::max( 0.f, 1.f-8.f*nodes.at(i).z/length0 );
float flarez = parameters.Flare*(pow(100.f,y)-1.f)/100.f+1.f;
Expand Down Expand Up @@ -233,7 +246,20 @@ uint WeberPennTree::buildTree( const char* treename, helios::vec3 origin, float

//---- nodes ----//

nodes.at(i) = nodes.at(i-1) + rotatePoint( make_vec3( 0, 0, dlength0 ), theta, phi );
nodes.at(i) = make_vec3(
i * base_tilt.x / parameters.nCurveRes.at(0),
i * base_tilt.y / parameters.nCurveRes.at(0),
nodes.at(i-1).z
) +
rotatePoint(
make_vec3(
getVariation(parameters.BaseAlignmentV.x),
getVariation(parameters.BaseAlignmentV.y),
dlength0
),
theta,
phi
);

vec3 current_normal = nodes.at(i)-nodes.at(i-1);
current_normal.normalize();
Expand Down Expand Up @@ -892,6 +918,15 @@ void WeberPennTree::loadXML( const char* filename ){
params.BaseSplitSizeV = bssv;
}

// * Base tilt * //
params.BaseTilt = XMLloadvec2(p, "BaseTilt");

// * Base tilt V * //
params.BaseTiltV = XMLloadvec2(p, "BaseTiltV");

// * Base alignment variation * //
params.BaseAlignmentV = XMLloadvec2(p, "BaseAlignmentV");

// * Scale * //
pugi::xml_node scale_node = p.child("Scale");

Expand Down
3 changes: 3 additions & 0 deletions samples/weberpenntree_orchard/config/tree.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<BaseSplitsV> 2 </BaseSplitsV>
<BaseSplitSize> 0.4 </BaseSplitSize>
<BaseSplitSizeV> 0.1 </BaseSplitSizeV>
<BaseTilt> 0 0 </BaseTilt>
<BaseTiltV> 0.05 0.05 </BaseTiltV>
<BaseAlignmentV> 0.05 0.05 </BaseAlignmentV>
<Scale> 2 </Scale>
<ScaleV> 0.5 </ScaleV>
<ZScale> 2 </ZScale>
Expand Down
Loading