Difference between revisions of "Adding object to scene"

From XStoryPlayer Wiki
Jump to: navigation, search
Line 27: Line 27:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
We want to add a collider to the object.
 
We want to add a collider to the object.
Place a cube named <code>coll1Shape</code> around the bench and change the code of the bench.ini to this:
+
Place a cube named <code>coll1Shape</code> around the bench and change the code of the <code>bench.ini</code> to this:
 
<syntaxhighlight lang="cpp">
 
<syntaxhighlight lang="cpp">
 
rb "benchShape"
 
rb "benchShape"

Revision as of 13:16, 16 January 2015

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;
     
      file_name = "scenes/object/benchShape.obj";
    }

    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.