Accessibility
 
Home > Products > Director > Support > Basics of Director 3D
Macromedia Director Support Center - Basics of Director 3D
Adding a box

Once the sphere has begun spinning, click the line of text that says "Create Box" to add a simple box using the Create Box script. That script contains the following Lingo:

on mouseUp(me)
    if voidP( sprite(1).member.model("newBox")) then  
        tSprite = sprite(1)
        tMember = tSprite.member
        tTempModel = tMember.newModel("newBox")   
        tBoxResource = tMember.newModelResource \
        ("newBoxResource", #box)

        tBoxResource.width = 20
        tBoxResource.height = 20
        tBoxResource.length = 20  
        tBoxResource.left = 1
        tBoxResource.right = 1
        tBoxResource.top = 1
        tBoxResource.bottom = 1     
        tBoxResource.front = 1
        tBoxResource.back = 1     
        tTempModel.resource = tBoxResource 
        tTempModel.parent = tMember.group("world")
        tTempModel.addToWorld()     
        tCenterPoint = point(sprite(1).width/4, sprite(1).height/3)
        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 Create Box script works:

It creates a model called newBox.
It then creates a new model resource of type #box . Because a box is a primitive, or fundamental shape, this model can be created from scratch in the 3D world.
The script then gives the model resource a size and indicates that all of the sides should be drawn.
The new model resource is assigned to the newBox model.
The model is added to the world and assigned as a child of the world.
The model is given a position within the world.

In this case, the default shader is used and no texture is assigned.

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