Notice: Array to string conversion in /var/www/ on line 304

Warning: Parameter 1 to Language::getMagic() expected to be a reference, value given in /var/www/ 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.



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.




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


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.



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.


Connect the nodes together

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



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


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


Replay the simulation

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




Here you can find this composition.

Personal tools