Accessibility
 
Home > Products > Director > Support > Basics of Director 3D
Macromedia Director Support Center - Basics of Director 3D
Adding a sphere to the world

The sample movie uses the Create Sphere behavior, attached to the Create Sphere text sprite, to add a simple sphere to the 3D world.

The Lingo from the Create Sphere behavior is shown here:

on mouseUp(me)

    if voidP( sprite(1).member.model("newSphere")) then 
        tSprite = sprite(1)
        tMember = tSprite.member
        tTempModel = tMember.newModel("newSphere")
        tSphereResource = tMember.newModelResource \
        ("newSphereResource", #sphere)

        tSphereResource.radius = 60
        tTempModel.resource = tSphereResource 
        tTempModel.parent = tMember.group("world")
        tTempModel.addToWorld()     
        tCenterPoint = point(sprite(1).width/2, sprite(1).height/2)
        tPointToVector = tSprite.camera.spriteSpaceToWorldSpace \
        (tCenterPoint - point(tSprite.left,tSprite.top))

        tMember.model (tTempModel.name).transform.position = \
        tPointToVector

        go next
    end if

end

Here is how the script works:

The script creates a new model reference called tTempModel .
A new sphere model resource called tSphereResource is then created. Because a sphere is a primitive, or fundamental shape, this model can be created from scratch in the empty 3D world.
The script then gives the model resource a size by defining the length of its radius.
The newly created model resource is then assigned to the model reference tTempModel .
The model is assigned as a child of the world.
The model is added to the world.
The script then gives the model a location within the world.

Note that the script does not create a light. Instead, lights have been turned on in the 3D world with the Property Inspector. For more information, see the "Working with Lights and Cameras" chapter of What's New in Director 8.5.

To Table of Contents Back to Previous document Forward to next document