Introduction to HardFX

From LightWiki

Revision as of 22:28, 5 November 2007 by BeeVee (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This time we're going to Build a wall and smash it down with HardFX... Or at least part of it. Go into Modeler and use the Box tool (shift-x) to make a box 90cm wide by 40cm high by 50cm deep. Use the Array tool (ctrl-y)to Rectangular array this 10 in the x axis, 5 in the y and 1 in the Z. Set the offset to manual and the values to x = 1m, y = 50cm and z = 1m. Select the 2nd and 4th rows and move them 50cm left to make a standard brick wall.

Name this layer Wall and in the next layer, draw out a Ball, 1 m in radius. Name this layer Ball and save then export the object to layout.

Image:HardFXWallAndBall.jpg

Drag the ball up behind the wall, to <5m,1.5m,15m>. In the Object Properties Panel, the Dynamics tab, Add Dynamic>Hard to the ball. Click on the panel and in the Basic tab set Gravity to -10. This gives a quick-to-type approximation of gravity as opposed to -9.81 which is the 'real' value.

Image:HardFXBasicTab.jpg

Go now to the Force Tab. This allows you to apply an impulse to your ball so it shoots out at the start of the animation. Set the Velocity (m/s) Z to -25m. Press Calculate at the top of the Dynamics tab. You'll see the ball shoot towards the camera, and fall off to infinity.

Image:HardFXForceTab.jpg

So we need to have it bounce on something. Add a CollisionFX object by clicking on the Dynamics tab>Dynamic Objects>Collision. Set the Type to Plane, at 0 m Radius Level. This setting means different things depending on the Type. For a Plane, it sets how far along the Y axis of the object the collision is for. Planes are infinite, so you can move it anywhere, and you can rotate it to be a slope or whatever. For a Sphere type, it sets the radius of the sphere. Set the Bounce/BindPower to 120%. For LW 100% means no bounce (don't ask me why, bounce is usually referred to as link Coefficient of restitution which is a percentage between 0 and 100%, 0% being no bounce and 100% being a perfect bounce, so why LW does it like this I have no clue). Anything above 100% will make your ball bounce a bit before it stops. Set the Friction power to 40 and Fix power to 40 too. This will slow down your ball as it rolls. Hit calculate.

Image:CollisionFxPanel.jpg

Now those blocks! Select the blocks and add HardFX to them. In the first tab we don't have to touch much, just change Gravity to -9 as before. It's set to Parts, so each individual brick will be treated as a separate entity. In the Collision tab you can see Collision by. This allows us to choose between Sphere (very quick to calculate), Box and Node (slower to calculate). Node is the actual shape of the object. So for simple, nearly spherical objects (like asteroids) you might want to use Spherical. We'll leave it on Node for now though, since this won't tax LW too heavily. Set Self interaction to Box, and the Bounce to 20%. Yup, this value's different here, more like the standard values. You can use Collision Node to restrict collision to a Vmap or a Surface for speed, but we won't need that. Hit Calculate. You'll see the ball go through the Wall, and the boxes settle a little. Not what you'd expect huh?

Image:HardFXWallPassThru.jpg

Now the way LW's dynamics works is cool. In a lot of Dynamics in other packages, cloth objects can fall on rigid objects, but not the other way around, the rigid object tends to fall through. With LW's CollisionFX you can simulate both setups by stacking them, even getting balls to roll around in a blanket held up by its corners. So add a CollisionFX to the Ball. It will automatically set itself to Type Object. Set the Bounce/Bind to 120% again to give it a bit of bounciness. Now if you hit calculate, the wall will settle and then be blown open by the ball.

Image:HardFXWallBrokenSliding.jpg

However, the outside bricks of the wall tend to shift and slide, which is not what you want. Click the bricks and bring up the HardFX panel again.In collision, set the Start by Collision. Now only those bricks hit by the ball will move, and only when it hits them. If the bricks hit each other on the way out, set the Break Distance to 10 or 20cm. This determines how far the bricks move before they start calculating inter brick collisions, useful for getting them out of tight areas.

Image:HardFXWallBrokenStartBy.jpg

Just one more thing. The some of the bricks wriggle a bit at the end of the animation. You can set Stop by in the Collision tab to 'Stabilizer' which will use the Resolution distance set in the the File tab to stop the bricks moving when they move less than a certain threshold. Ideally this would be a separate number, as Resolution also controls the accuracy of the simulation (thus lower numbers slow LW down), but you can tweak this to best effect. Stop By can also use an Event collision object to stop individual bricks, so if most of them are okay, you just need to stop a few, you could use this by passing the Event Object through the Bricks, or use it for other effects like stopping bricks in mid air.

Views