Like trees? Help me to animate one!

Started by InCreator, Fri 03/09/2010 18:33:43

Previous topic - Next topic

InCreator

Long story short, I've exhausted all ideas on how to animate those top-down-viewed trees.
I want them to sway in wind, with leaves shaking and stuff. And it should be fluid enough to make it dependent on wind speed (which randomly rises and lowers in game)...

Despite numerous attempts to either automate or craft this, I do not get even semi-realistic result
All I need is a technique, one nice-looking tree or tutorial... something I could use to animate much more trees.



Can YOU help?

Calin Leafshade

#1
Hmm well I havent thought through the details but you could use a kind of physicsy sim.

Imagine all those leafy things are particles.
then apply a force to them (wind) but also apply another, lesser force designed to pull the leaves back to their original position.
make this pull back force proportional to the distance from their starting position so that the pull back force becomes greater the further away they are from where they started
make some of the particles effectively 'weigh' more. That is to say that they are not affected by the force as much as others.

as you crank up the wind some particles will move further than others due to the weight and they will reach equialibrium once the pull back force (which grows the further they have been pushed) equals the wind you are applying.

as you decrease the wind force the pullback force will gradually shrink until the particles are back where they started.

they just randomise the wind

EDIT: bear in mind that I am not a programmer or a physicist so I have no idea if that would work :P

Anian

#2
Uuu this is for the tower defence game, sweet.  :)

Evergreen trees - closer to the ground they are, they move less and slower, as you go higher they move more and faster
Oaks and stuff (which you seem to have drawn) - they don't have a middle trunk usually, but brach out more, so branches closer to wind source move first and more, branches farther from the wind source move less (look like they're are affected less, because the wind force is sort of lessen by branches before them). But to this movement you can add the evergreen tree movement (the higher up, the effects are stronger).

I have no idea how to program this, probably some fuction like Calin mentioned, where the force might be the same but particles (vertical tree levels with sprites on them, I think 3-4 levels per regular size tree would suffice). Then add "weight" to them or rather make them affected more by the wind the higher from the ground a level is.
Don't know how you'd do that for non-evergreen trees though, might even be easier to draw.

EDIT: did you do this in Max? There's a flex modifier you might try using.
I don't want the world, I just want your half

GarageGothic

Since you need variable wind in-game, I'd suggest two approaches combined:

1. In-game: Use multiple leaf layers for each tree (e.g. 4). When wind is applied, you move each layer back and forth in the breeze, creating a parallax illusion of depth. As the wind grows stronger, you can displace all the layers in the direction of the wind, with the top of the tree pushed further that the lower branches - taking it far enough, the tree will look like it's about to fall over.

Along with this I suggest:

2. Pre-rendered/drawn: Animate a wind "ripple" effect in the individual layers - you can either do this by hand or using some video effect, but Calin's suggestion of particle animation could be an easier approach. In a light breeze, you'll then play this animation back at a slow speed and increase the speed for stronger wind. This animation shouldn't suggest any direction to the wind, because then we'll need to rotate it.

Now, I imagine this being rendered on a DrawingSurface in AGS, so all the animation would be handled in rep_exec(). When you initialize the tree animation code, you can randomize the starting frame of each layer of each tree, to avoid identical trees. Of course you also have a number of animations for each tree layer and randomize between these for further diversity.

InCreator

* Indeed it's for Enclosed: Tower Defense

* Those trees are pure pixels. No 3D model... in fact, animating would be probably MUCH easier if I'd use 3D-renders instead of simple tree. But I love pixels and making a 3D tree is quite difficult. Also, it's like killing a fly with a cannon... Then again, I've already used some rendered 3D for graphics elsewhere in this project  ;)

* I'm thinking about simple 10-16 frame animation. Not some crazy layer/physics. The wind in game will only affect animation speed.

* Putting branchfuls of leaves on different layers and animating swaying few pixels forth and back, did this. Sadly, every attempt at this sucks for some reason.
Actually, thinking about calin's/garagegothic's suggestion, maybe putting tree into game as set pieces with physics applied might even work.

I will try this.

* What I would absolutely love to end up with is something as realistic (or atleast cool looking) as trees in Stronghold (see 0:13+) or Settlers 2. Just top-down, not side-view.

Calin Leafshade

Those trees look prerendered in 3D to me.

InCreator

#6
Well, I can ensure you that 3D they are NOT.

After few hours of thinking and last miserable attempt to animate this by hand, following happened:



Grab it here: http://www.indrek.org/i/pull/tree_creator.rar

It spits out custom number of alpha-channeled PNG frames for a (somewhat) procedural, animated, customizable tree... Maybe I need a a doctor, but this felt only way to go. There's also a GMK source, for GM enthusiasts.

Thanks for leading me there!  :)

Anian

Wow, cool. This could really be used even for strategies, just slap on a tree trunk and this animation over it etc.

One thing though, and I know this what you don't actually need for you game, but - there's no branch (there's leaves, but no for the whole branch) shake intensity modification, which was kind of the "realistic" movement part.
I don't want the world, I just want your half

GarageGothic

I think it works fine without branches - as long as there's leaves on a tree you can barely spot the branches under the canopy from a bird's eye view. Check out satellite images on Google Maps if you don't believe me, for example Central Park.

Great work, InCreator. The interface is simple but flexible, and the results look very nice. I can't say whether you need a doctor, but if coding this is a sign of madness, let me be the first to welcome you to the asylum! I would have done the same had it been my game, though most likely I'd try to get it running in realitime in AGS, only to find myself yet again cursing the sluggish DrawingSurface functions (good choice to go the pre-rendered route, btw). You wouldn't believe half the overcomplicated features I've built prototypes and editors for, one of them coincidentally a perspective shifting module for semi-3D trees! (which snowballed into experiments with displacement mapping, voxel landscapes, and self-shading normal-mapped sprites - pushing AGS boundaries is, if not a mental illness, certainly an addiction ;)).

Anian

Quote from: GarageGothic on Sat 04/09/2010 00:35:35
I think it works fine without branches - as long as there's leaves on a tree you can barely spot the branches under the canopy from a bird's eye view. Check out satellite images on Google Maps if you don't believe me, for example.
If this was aimed at me, I kinda phrased it wrong, I meant for strategies as in like InC mentioned Settlers 2. Like if you wanted to make a game with a different camera/viewing angle.
I don't want the world, I just want your half

GarageGothic

@anian: Ah, sorry, I get your point now. Could be that I'm just not used to the stylistic conventions of strategy games. I haven't played one in a decade and a half and isometric views weren't that common back then - SimCity, Colonization, Railroad Tycoon, Warlords, and so on.

InCreator

Well, as little as I like it, pre-rendering via generator seems only option. I'd love to keep trees that dynamic as they are in gen, but resource usage in generator shows clearly how badly it'll slow down everything else, if used in game.

I think I'll tweak generator a bit today to suit my needs, use custom brushes for leaves & simulate brightness/height better and close the deal.

SMF spam blocked by CleanTalk