|
3DText2
When you open and play the 3DText2 sample movie, you can extrude text to the 3D world by clicking the top left button on the Stage. You can then use the other two buttons to apply a shader to every other letter or to every letter. All three buttons include behaviors that call the following handlers, which you'll find in the movie script.
The following code is an error trap that causes the handler to exit if a model called 3dText is already in the world. If the model exists and you try to create another model of the same name, an error message appears.
on extrudeTextToWorld
if not(member("scene").model("3dText").voidP) then exit
The prepareShaders handler calls the handler that creates all the shaders used in the movie. The prepareLightAndCamera handler calls the handler that sets up the lighting and camera position for the movie. By preparing the lights and camera position, you ensure that your text is visible in the movie.
The following code defines the extruded text as a model resource and assigns it to a variable for convenience:
textModelResource = member("textSample").extrude3d(member("scene"))
The following code creates a new model, which uses the new textModelResource variable:
nm = member("scene").newModel("3dText", textModelResource)
The new model is extruded from the text "I'm shocked!" Because the text has 11 characters (including punctuation), it has 11 shadersone for each character.
The following repeat loop assigns the same shader to each character. |