Notice: Array to string conversion in /var/www/wiki.sourcebinder.org/includes/Setup.php on line 304

Warning: Parameter 1 to Language::getMagic() expected to be a reference, value given in /var/www/wiki.sourcebinder.org/includes/StubObject.php on line 58
Simple 3D scene with physics - SourceBinder Wiki

Simple 3D scene with physics

From SourceBinder Wiki

Jump to: navigation, search

Playing with physics systems is fun. SourceBinder supports JiglibFlash which is a 3D Physics engine written in Flash.

The following tutorial shows you how to create a simple 3D scene with physics.

Contents

Engines

Basically, there are two parts.

  • the rendering engine that calculates colors, textures etc.., this'll be done by PaperVision 3D which is a really good 3D rendering engine in Flash.
  • the physics engine that calculates the position of the objects. This'll be JiglibFlash.


Creating the scene without physics

To create a basic 3D scene, let's create a floor and two cubes. The floor is a simple Plane node which w and h values are big enough, let's say 2000.

After that, let's say that the cubes have GouraudMaterial material and the floor has FlatShadeRandom material.

cubes.jpg

plane.jpg

planesettings.jpg

You also need a renderer node, which is a PaperVisionRenderer. This node will render the cubes and the plane correctly.

Connect this node the Output node

scenewithoutphysics.jpg


First step to make it move

Let's apply the JiglibFlash physics engine to this scene.

In JiglibFlash every object is made of several primitive objects like box and plane. So, you have to decide how you want to represent your objects in JiglibFlash.

In this lucky case, the two cubes are jiglibbox in JiglibFlash as well, and the floor is a simple jiglibplane.

jiglibbox.jpg

jiglibplane.jpg


But if you had a more complex object like a human body, you should approximate it with hundreds of boxes in JiglibFlash.

You also need a special node called JiglibPhysicsSystem that does the calculating.

engine.jpg


Connect the nodes together

Connect the JiglibBox nodes and the JiglibPlane node to the JiglibPhysicsSystem node as bodies

connectasbodies.jpg

connecttogether.jpg


Make a floor

You have to tell the physics engine that you have a floor that does not move. You can do it by double clicking on the JiglibPlane and check off the movable parameter

movable.jpg


You also need to rotate it by setting the rotationX to 70

rotation70.jpg


Replay the simulation

You can replay the simulation by pressing the middle button at the top.

replaybutton.jpg


Overall

scene.jpg


Here you can find this composition.

Personal tools