Tutorial 2.2: Adding An Actor To The Scene
Once we have loaded our model, we need to draw it on screen. We do this using an "Actor". Actors are classes that reference a model and have certain settings, like Position, Rotation, Scale, etc. Multiple actors can use one model, so you can save memory by using one model and setting different positions, rotations, etc.

Add an actor with the following code in your Initialize() function:
XScene.AddActor("ShipActor", "ShipModel");

The first parameter sets the name of the actor, and the second specifies what model it will use.

Setting an actors properties
Before we move on to the final step, I will take a moment to resize the ship model, becuase it is huge compared to the current scale of our scene. To size it down, I will adjust the actor's scale, using the following code, right after declaring our actor.
XScene.Actor("ShipActor").Scale = new Vector3(0.05f);

The XScene.Actor function will return the actor sepecifies in the parenthesis. From there, you can adjust its position, rotation, and scale.

The last thing we need to do is add a camera to our scene so we can see the model. To do so, head to Tutorial 2.3: Adding a camera to the scene.

Last edited Mar 23, 2008 at 6:49 AM by Hazardous101, version 3


No comments yet.