Noob in need of some feedback

If you have a design you're proud of, share the cfdg file here. It's also a good place to ask for feedback and collaborate.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
daedlus
Posts: 1
Joined: Fri Dec 16, 2005 2:04 pm

Noob in need of some feedback

Post by daedlus »

Hi,

I just started at this a little while ago and was wondering about how to get a couple of things done. But first, my assemblage of code. (Most of it is taken from other works and slightly modified as I'm not familiar enough with CFDG to do certain things.)

Code: Select all

startshape ground
background { hue 210 sat 0.1 b 1 }

rule ground {
	Lawn { x -20.0 }
	Lawn2 { x 150.0 }
	CIRCLE { x 50.0 y 50.0 s 10.0 hue 55 sat 1 b 1 }
	Rays { x 50 y 50 s 3 }
	forest { }
}

rule forest {
	tree { y 1.0 s 1.0 }
	forest { x 15 }
}

rule forest 1.5 {
	tree { y 1.0 s 0.5 }
	forest { x 7 }
}

rule forest 0.2 { }

rule Lawn { Grass { hue 90 sat 0.5 b 0.5 } Lawn { x 0.2 s 0.999 } }
rule Lawn2{ Grass { hue 90 sat 0.5 b 0.5 } Lawn2 { x -0.2 s 0.999 } }

rule tree {
	limb { |hue 30 |b 1 |sat 0 } 
}

rule limb {
	SQUARE { }
	limb { y 1.0 s 0.99 r 1.5 b 0.02| hue 0.5| sat 0.9| }
}

rule limb 0.05 { branch { } }

rule limb 0.05 {
	SQUARE { }
	branch { y 1.0 s 0.95 r 1.5 }
	limb { y 1.0 s 0.5 r -20 }
	branch { y 1.0 s 0.5 r 20 }

}

rule branch { 
	SQUARE { }
	branch { y 1.0 s 0.99 r -1.5 }
}

rule branch 0.05 {
	SQUARE { }
	limb { y 1.0  s 0.9 r 1.5 }
	branch { y 1.0 s 0.5 r -60 }
	limb { y 1.0 s 0.5 r 60 }
}

rule Rays {
	Grass { hue 55 sat 1 b 1 }
	Rays { s 0.99 r 5 }
}

rule Grass 2 { Grass {b 0.1} }
rule Grass { Grass {s 1.1} }
rule Grass { Grass {s 0.9} }
rule Grass 2 { GrassL {s 0.3} }
rule Grass { GrassR {s 0.3} }

rule GrassL 15 {FilledSquare{} GrassL{y 0.5} }
rule GrassL 3 {GrassL{r -2} }
rule GrassL 3 {GrassL{r -1} }
rule GrassL 10 {GrassL{s 0.95} }
rule GrassL 2 {GrassR{} }

rule GrassR 15 {FilledSquare{} GrassR{y 0.5} }
rule GrassR 3 {GrassR{r 2} }
rule GrassR 3 {GrassR{r 1} }
rule GrassR 10 {GrassR{s 0.95} }
rule GrassR 10 {GrassL{} }

rule FilledSquare { SQUARE{} }
So, the questions are fairly simple, but I'm sure the answers aren't so simple. First off, how would one get the rays to go all around the sun instead of radiating from the centre? This would permit me to make it look cleaner. I first tried a simple x y r addition but then quickly realised that y and x would have to decrease after a while and so it didn't work.

Also, how would I get the grass to spawn at the bottom of the scene. Currently it spawns a little over it and you can see the background under it.

Finally, how would I keep the trees from bending over and going through the grass? (Going through the sun is fine because sometimes trees do in fact block out the sun. However, I've yet to see a full sized tree bend it's branches and go through the ground. (Some shrubs actually do it but I digress...))

Thanks for any help!

Image

*Edit: Found out phpBB doesn't like png files as images. Switched to jpg.*

robo git
Posts: 47
Joined: Sat Jul 09, 2005 11:36 pm
Location: looking for his marbles
Contact:

Post by robo git »

Grass at bottom: CF places a border around the image of the default colour. There has been some talk of providing the option to disable this, but for now you'll have to "cut it to the grass" manually

Sun: Nice reuse of the grass code! Probably the simplest way to do it is to start 4x rays in the same place, each 90 degrees around from the other (or 5x @ 72deg, 6x@60, 8x@45, etc)

EG:

Code: Select all

rule ground {
   Lawn { x -20.0 }
   Lawn2 { x 150.0 }
   CIRCLE { x 50.0 y 50.0 s 10.0 hue 55 sat 1 b 1 }
   Rays { x 50 y 50 s 3 }
   Rays { x 50 y 50 s 3 r 120 }
   Rays { x 50 y 50 s 3 r -120 }
   forest { }
}
As for the trees... I guess you could add a "trunk" to lift them away from the ground-level before using the current "tree" code, though that is fairly inelegant.

Post Reply