Crystal Space 2.0.0: 5.13.1 A Simple 3D Sprite

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

### 5.13.1 A Simple 3D Sprite

Let us consider a simple 3D sprite—a 24 sided prism meant to look like a cylinder. Each side is made from two triangles, and the ends are made from 24 polygons (you could make the ends from 23 polygons, but that's not how artists do things :-).

This sprite has 96 triangles. If we treat each triangle as a separate object, it has 288 vertices. Every frame each of those 288 vertices has to be transformed from local coordinates to screen space coordinates.

Each vertex is also consuming some memory. If each vertex only has three 32 bit float coordinates, then the sprite uses 3456 bytes of memory, but in practice each vertex also has texture alignment, color, and surface normal data, and if the sprite has precalculated animation, that data is multiplied by the number of frames.

However, the 3D sprite structure is compressed so that triangles can share vertices. Instead of 288 vertices, the cylinder sprite has 48 vertices shared by the 96 triangles. Each triangle is simply three indices to to the vertex list.

- Vertices
- Triangles

This document was generated using texi2html 1.76.