 |
 |
|
 | |
Primitives Tutorial
Models
After the model resource is created you can move on and create the actual model. In order to do this you should call the following method:
newModel(aName,aModelResource)
Parameters:
aName: this is the name your model will be know for. You can use this name later to retrieve or alter the models properties.
aModelResource: the model resource used to create this model
This method should be called for a Shockwave 3D cast member. If the model resource does not exist you'll get a script error.
For instance, assuming that there is a Shockwave 3D cast member on the cast called "world" with a model resource called "box", then you could write something like:
aBoxResource = member("world").modelResource("aBox")
member("world").newModel("aBoxInstance",aBoxResource)
The return value of this method is a model.
Once a model is created you can refer to it in different ways. Each Shockwave 3D cast member will keep an array of models. The following are valid ways to get a model from a 3D cast member:
member("world").model("aBox")
member("world").model[1]
Note: as opposed to model resources, obviously there are no pre-defined models in a clean 3D cast member.
The following script creates a box, just attach it to a Shockwave 3D sprite. It assumes that there is a Shockwave 3D cast member named "world".
on beginSprite
w = member("world")
w.resetWorld()
mr = w.newModelResource("aBox", #box, #front)
member("world").newModel("aBoxInstance",mr)
end
The method resetWorld reverts the world to the default values, thereby eliminating any model resources and models you create during runtime. Shockwave 3D cast members keep their state in authoring time between runs. This means that if you create a box, the box will still be there when you stop and rewind your movie. If you don't reset your Shockwave 3D cast members then you get a script error on the second time you try to run it inside Director. The error is caused by the fact that you're trying to create a something with a name that already exists.
|