Forest Problem

If you're having trouble using Context Free or don't understand the language, ask for help here.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
Kris

Forest Problem

Post by Kris »

Hello, i've been mucking around with this program for less than a week, and i was curious about a problem i have.

Basically i'm using a whole lot of trees to create a forest effect, with the trees at the back being lighter in colour to create depth.

But when i execute the effect, the trees at the back sometimes overlap the front, making it just look busy.

Wondering if you could help me out, what i'm trying to acheive is sort of a layer, keeping the back row of trees to the back row, and so on.

______________________
______________________
startshape TREETEST

rule TREETEST {
ROWSETS{}
}
rule ROWSETS{
ROWS{}
ROWS {y .5 b .1}
ROWS{y .7 b .2}
ROWS{y .9 b .3}
ROWS{y 1.1 b .4}
ROWS{y 1.3 b .5}
ROWS{y 1.5 b .6}
ROWS{y 1.7 b .7}
ROWS{y 1.9 b .8}
}
rule ROWS{
TREE{}
TREE{x .5}
TREE{x 1}
TREE{x 1.5}
TREE{x 2}
TREE{x 2.5}
TREE{x 3}
TREE{x 3.5}
TREE{x 4}
TREE{x 4.5}
TREE{x 5}
TREE{x 5.5}
}
rule TREE 20 {
CIRCLE {size 0.25 }
TREE {y 0.1 size 0.97 }
}
rule TREE 1.6 {
BRANCH {}
}
rule BRANCH {
BRANCH_LEFT { }
BRANCH_RIGHT { }
}
rule BRANCH_LEFT {
TREE { rotate 20 }
}
rule BRANCH_LEFT {
TREE { rotate 30 }
}
rule BRANCH_LEFT {
TREE { rotate 40 }
}
rule BRANCH_LEFT {}
rule BRANCH_RIGHT {
TREE { rotate -20 }
}
rule BRANCH_RIGHT {
TREE { rotate -30 }
}
rule BRANCH_RIGHT {
TREE { rotate -40 }
}
rule BRANCH_RIGHT {}

aqua_scumm

Post by aqua_scumm »

dont have time to really look over it, but conceptually this is what you want:

create a line of light trees, randomly spaced, perhaps some random movement up/down

drop down in the screen a bit, make the line darker, create a line of sparser, larger trees (dont want too many or you wont see the old ones!

rinse and repeat as necessary.

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Post by MtnViewJohn »

Your re-ordering suggestion improves the situation a little. But the shape evaluation algorithm wants to draw small shapes on top of (i.e. after) large shapes. Sooner or later it will sort the shapes-to-be-evaluated and your re-ordering of the rows will be for naught.

There are some hacks that can be used to cause the lighter colored rows to draw behind the darker rows. But they are not very reliable. The next version of Context Free/CFDG will have z-axis parameters that will let you dictate which row gets drawn on top of which.

Post Reply