Difference between revisions of "Adding object to scene"

From XStoryPlayer Wiki
Jump to: navigation, search
(Created page with "In this tutorial we will explore different ways to add an object to a scene. ==Steps== <ol> <li>Copy the bench object from the 'Tutorial resource pack' to the sources directo...")
 
Line 3: Line 3:
 
==Steps==
 
==Steps==
 
<ol>
 
<ol>
<li>Copy the bench object from the 'Tutorial resource pack' to the sources directory.</li>
+
<li>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.</li>
 +
<li>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 <code>bench.ma</code> to the <code>scene.ma</code>. Run the [[Filemaker]] and create the scene again. Run the scene, you should see the bench in the scene.</li>
 +
<li>Remove the bench from the scene again using [File->Reference Editor]. Now we will add the object dynamically to the scene.<br>
 +
Add this code to the <code>/init/story/scenes.dat</code> at the bottom off this file.<br>
 +
<syntaxhighlight lang="cpp">
 +
dyn_objecti BENCH1
 +
{
 +
  scene_id = SPACESHIP1;
 +
 
 +
  file_name = "scenes/object/benchShape.obj";
 +
}
 +
</syntaxhighlight>
 +
This will create the bench dynamically in the scene.
 +
</li>
 +
<li>The <code>bench.ini</code> file describes the bench object.<br>
 +
<syntaxhighlight lang="cpp">
 +
rb "benchShape" // A rigidbody object
 +
{
 +
  // Only render the object.
 +
  // In essence it is now the same as a rd (render) object.
 +
  render {}
 +
}
 +
</syntaxhighlight>
 +
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:
 +
<syntaxhighlight lang="cpp">
 +
rb "benchShape"
 +
{
 +
  render {}
 +
  physics
 +
  {
 +
    elem[0] {mesh = "coll1Shape";}
 +
  }
 +
}
 +
</syntaxhighlight>
 +
Run the [[filemaker]] and test the scene, you should collide now with the bench.
 +
</li>
 
</ol>
 
</ol>

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.