CDN Progressive Format

From Sirikata Wiki
Jump to: navigation, search

PDAE (Progressive Digital Asset Exchange) File Format

Notes about parsing base mesh

The progressive format assumes that the base mesh is parsed intelligently. COLLADA allows for different source arrays (vertex, normal, texture coordinate) to be indexed separately, but when sending to the graphics card, a single index must be give for each triangle's vertex. A naive implementation would just create a source array entry for every single vertex and then set the triangle indices to be from 1 to N*3 where N is the number of triangles. Instead, the progressive format assumes that a source array entry is only created for each unique set of vertex indices. Then, the vertex indices can be re-used when a vertex points to the same set of indices. The vertex indices in the progressive format assume that the uniqueness has been calculated starting from the beginning of the array. The triangle indices refer to the expanded triangle index, such that index i refers to the i/3 triangle and the i%3 vertex in that triangle.

ASCII

The ASCII file format consists of the header, followed by a series of lines. The header contains the number of progressive refinements to follow in the file. Each progressive refinement contains the number of operations contained, followed by some number of "v", "u", and "t" lines. See below for description.

Header

  • The string "PDAE" followed by a newline.
  • The number of progressive refinements, followed by a newline.

Progressive Refinement

Description: Contains the number of operations within the progressive refinement. Format:

N

Example:

7

v

Description: Add a unique set of vertex information to the end of the vertex source array. v1-v3 is the vertex information (X,Y,Z), n1-3 is the normal information (X,Y,Z) and u-v is the texture coordinate (U,V) Format:

v v1 v2 v3 n1 n2 n3 u v

Example:

v 889.211 747.1346 292.3802 0.349573 0.870764 0.345787 0.7733477 0.4360528

t

Description: Add a triangle at the end of the triangle list. i1-i3 are the index values indexing into the vertex source array. Format:

t i1 i2 i3

Example:

t 1611 2348 1686

u

Description: Update triangle index location ti to vertex index vi Format:

u ti vi

Example:

u 3333 2351

PDAE Example

PDAE
2
7
v 889.211 747.1346 292.3802 0.349573 0.870764 0.345787 0.7733477 0.4360528
v 889.211 747.1346 292.3802 0.349573 0.870764 0.345787 0.9263274 0.4431856
t 1611 2348 1686
t 1656 2349 1682
u 2717 2348
u 2730 2349
u 2656 2348
9
v 981.3076 765.1611 202.6041 0.321965 0.939617 -0.116016 0.7673832 0.4037398
v 981.3076 765.1611 202.6041 0.645074 0.228829 -0.729052 0.674786 0.442541
v 965.4113 724.5516 215.2124 0.650398 -0.741869 0.163133 0.6845703 0.4528548
v 981.3076 765.1611 202.6041 0.950511 -0.146462 -0.274005 0.7673832 0.4037398
v 965.4113 724.5516 215.2124 0.86448 -0.440579 -0.242001 0.7953826 0.4032472
t 2030 2351 2352
t 2353 1667 2354
u 2747 2350
u 3333 2351

Binary

To come