O'Reilly logo

3D Programming for Windows® by Charles Petzold

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Why Not Share the Vertices?

The three XAML files that display a square cuboid all define the six faces of the image independently. This results in a Positions collection that has 24 points rather than just 8 points for the 8 vertices of the figure. Why not just put 8 points in the Positions collection and share the vertices among the faces?

Don't fall into the trap of thinking you'll get better performance with 8 points in the Positions collection rather than 24. The rendering of 3D objects is triangle-driven and not vertex-driven. But let's try it. The following XAML file has only eight points in the Positions collection and defines the TriangleVertices collection appropriately.

Example 1-9. SharedVerticesSquareCuboid.xaml

<!-- ============================================================= ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required