As mentioned in the previous section, in order to get a model on screen you need first to create a model resource and then create a model based on it.
In order to create a model resource you need to call the following method:
aName: is the name you give to the model resource. Beware not to use a previously used name. Shockwave 3D requires unique names, otherwise you'll get a script error. You can use this name latter to change the model resource properties
aType: specifies the resource type. See bellow for more info.
aVisibility: this is an optional argument. It specifies the visibility of the resource. See bellow for more info.
This method should be called for the Shockwave 3D cast member. For instance, assuming that there is a Shockwave 3D cast member on the cast called "world", then you could write something like:
The return value of this method is a model resource.
As mentioned before, the second parameter specifies the type of primitive. The following are available by default:
The properties of each of these types (except particle) will be explored in the following sections.
Before checking out the visibility options there are a few concepts you should be aware. A model is made of meshes. You may thing of meshes as parts of the object. For instance a box is made of six meshes, one for each side. A mesh is made of faces. Faces are made of triangles, where each vertex is a 3D point. For instance a side from a box is made of two triangles. Faces have a front side and a back side. Depending on your visibility settings you can show both sides or only one of them. For optimisation purposes you should only set the visibility settings that you really require. For instance it doesn't make sense to have a closed box where the inside of the box is also being rendered to screen. The inside of the box will never be visible but Director doesn't know this. By setting the visibility to #both, a box gets 12 sides, instead of 6 and this naturally affects performance.
In order to determine which is the front side of a face you check the order in which the vertices are specified. The front side is where the vertices are connected in a counter clockwise direction. The back side follows the clockwise direction.
You wont need to know all this stuff when working with primitives. However you must be aware of this when creating your own meshes.
The visibility options are:
Once a model resource is created you can refer to it in different ways. Each Shockwave 3D cast member will keep an array of model resources. The following are valid ways to get a model resource from a 3D cast member:
In the first line, the argument of the method is the name of the model resource.
"Hey, why is the index equal to 2 in the second line?" This is because when you create a Shockwave 3D cast member, it already contains some stuff. Amongst other stuff, a model resource for a plane is already included. Therefore the first model resource you create has an index equal to 2, not 1.
Try it. Create a Shockwave 3D cast member, give it a name, and before you do anything with it write on the message window:
and this is what you get: