Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Papervision3D Essentials

You're reading from  Papervision3D Essentials

Product type Book
Published in Sep 2009
Publisher Packt
ISBN-13 9781847195722
Pages 428 pages
Edition 1st Edition
Languages

Table of Contents (18) Chapters

Papervision3D Essentials
Credits
About the Authors
About the Reviewers
1. Preface
1. Setting Up 2. Building Your First Application 3. Primitives 4. Materials 5. Cameras 6. Moving Things Around 7. Shading 8. External Models 9. Z-Sorting 10. Particles 11. Filters and Effects 12. 3D Vector Drawing and Text 13. Optimizing Performance

Accessing vertices


Let's go back for a moment to the basic elements of a 3D object—vertices. The vertices of every do3D are stored in an array. You can access them through the geometry property.

do3D.geometry.vertices

Suppose you would like to know the x and y coordinates of all the vertices of the plane that we built in PlaneExample. Because the vertices are stored in an array, you can find out how many there are by using the length property.

var numberOfVertices = plane.geometry.vertices.length;

Then you can iterate through the array using a for loop.

for(var i:uint = 0; i < numberOfVertices; i++)
{
trace("x: " + plane.geometry.vertices[i].x,
"y: " + plane.geometry.vertices[i].y,
"z: " + plane.geometry.vertices[i].z)
}

This will output:

x: -150 y: -150 z: 0
x: -150 y: 150 z: 0
x: 150 y: -150 z: 0
x: 150 y: 150 z: 0

As you can see, only the x, y, and z positions of four points are given. Maybe you would have expected the positions of six points because every triangle has three vertices...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}