07.12.2012 Views

Adobe Director Basics

Adobe Director Basics

Adobe Director Basics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ADOBE DIRECTOR BASICS<br />

3D: Controlling appearance<br />

-- 1. Create a new mesh<br />

vMesh = member("3D").newMesh( \<br />

"Trick Card Mesh", \<br />

vFaceList.count, \<br />

vVertexList.count, \<br />

vNormalCount, \<br />

vColorList.count, \<br />

vTextureCoordinateList.count \<br />

)<br />

-- 2. Apply the vertex, color, face and texture data<br />

vMesh.vertexList = vVertexList<br />

vMesh.colorList = vColorList<br />

vMesh.textureCoordinateList = vTextureCoordinateList<br />

-- 3. Define each of the faces<br />

vCount = vFaceList.count<br />

repeat with ii = 1 to vCount<br />

vMesh.face[ii].vertices = vFaceList[ii]<br />

vMesh.face[ii].colors = [1, 1, 1]<br />

vMesh.face[ii].textureCoordinates = vTextureFaceMap[ii]<br />

end repeat<br />

-- 4. Create a flat mesh<br />

vMesh.generateNormals(#flat)<br />

-- 5. Complete the process<br />

vMesh.build()<br />

Creating a model from a mesh resource<br />

You can now treat your mesh resource like any other modelResource. The following code:<br />

Creates a model from the mesh resource<br />

Creates a texture from a bitmap member named “Trick Card”<br />

Creates a shader to use the texture<br />

Applies the shader to the model<br />

vMember = member("3D")<br />

vName = "Trick Card"<br />

vModel = vMember.newModel(vName, vMesh)<br />

vTexture = vMember.newTexture(vName)<br />

vTexture.member = member(vName)<br />

vShader = vMember.newShader(vName, #standard)<br />

vShader.texture = vTexture<br />

vModel.shader = vShader<br />

Manipulating the vertexList and normalList<br />

You have direct access at all times to the various lists stored by a #mesh resource. See “Manipulating a mesh resource”<br />

on page 182 to see how to fold this Trick Card model so that it appears to be either a Jack of Spades or a Queen of<br />

Hearts.<br />

Creating a terrain mesh<br />

A terrain mesh resembles a 2D plane that has been deformed to create an interesting landscape. Normally, the end user<br />

only sees the top surface of a terrain mesh, and no objects falls through it. This means that you have to use some<br />

method of collision detection on the terrain.<br />

Last updated 8/26/2011<br />

176

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!