Adding object to scene

From XStoryPlayer Wiki
Revision as of 13:25, 16 January 2015 by Xwikip (Talk | contribs)

Jump to: navigation, search

In this tutorial we will explore different ways to add an object to a scene.

Steps

  1. Copy the bench files from the 'Tutorial resource pack' to the sources directory. It is a simple bench that will be placed in the cell.
  2. The most simple way to add an object to a scene is to use the reference editor in Maya. Do [File->Create Reference] in Maya and add the bench.ma to the scene.ma. Run the Filemaker and create the scene again. Run the scene, you should see the bench in the scene.
  3. Remove the bench from the scene again using [File->Reference Editor]. Now we will add the object dynamically to the scene.
    Add this code to the /init/story/scenes.dat at the bottom off this file.
    dyn_objecti BENCH1
    {
      scene_id = SPACESHIP1; // The scene
     
      pos = (0,0,-1); // Position
      rot = (0,0,0);  // Rotation
     
      file_name = "scenes/object/benchShape.obj"; // The object file
    }

    This will create the bench dynamically in the scene.

  4. The bench.ini file describes the bench object.
    rb "benchShape" // A rigidbody object
    {
      // Only render the object.
      // In essence it is now the same as a rd (render) object.
      render {}
    }

    We want to add a collider to the object. Place a cube named coll1Shape around the bench and change the code of the bench.ini to this:

    rb "benchShape"
    {
      render {}
      physics
      {
        elem[0] {mesh = "coll1Shape";}
      }
    }

    Run the filemaker and test the scene, you should collide now with the bench.

  5. Now lets make the object dynamic. Change the bench.ini to this:
    rb "benchShape"
    {
      dynamic = true; // Object is dynamic
     
      render {}
     
      physics
      {
        density = 200; // 200 kg per cubic meter
        fc      = 0.1; // Low friction
     
        elem[0] {mesh = "coll1Shape";}
      }
    }

    Run the filemaker and test the scene, run into the bench and it should move.

  6. Now lets make a soft body object of the bench.