home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fujiology Archive
/
fujiology_archive_v1_0.iso
/
!FALCON
/
LINEOUT
/
OUT.ZIP
/
SOURCE.ZIP
/
FORMAT.TXT
< prev
next >
Wrap
Text File
|
2002-01-19
|
4KB
|
109 lines
HumanFly 2.x object format
============================================================================
The HumanFly objectstructure looks like this:
All offsets are in bytes. All words should be handled as unsigned. Vertices
are just three signed words. Texturevertices are 2 unsigned words using only
the lower byte (lameness, I know).
offset | size | discription
-----------+------+---------------------------------------------------------
0 | word | amount of vertices + normal vectors (n)
2 | word | amount of normal vectors (m)
4 | var | vertex table, n-m entries of 3 (x,y,z) words
(n-m)*6+4 | var | normal vector table, m entries of (x,y,z) words
n*6+4 | word | amount of texturevertices (t)
n*6+6 | var | texturevertex table, t entries of 2 (u,v) words
n*6+t*4+6 | word | amount of primitives (p)
n*6+t*4+8 | var | primitive list, p entries
----------------------------------------------------------------------------
primitive format:
offset | size | discription
--------+------+------------------------------------------------------------
0 | word | header:
2 | var | index table, v word indices
v*2+2 | var | 1st optional second index/coefficient table, v word entries
v*4+2 | var | 2nd optional second index/coefficient table, v word entries
header = vertices-1 (v-1)<<10 | shadetype<<13 | pal/texture nr.
"<<x" denotes shifted left x bits.
The index tables contains indices into the vertextable. So an index 23
indexes the 24th vertex in the vertex table. This is offset=4+24*6.
The existance of the optional tables depend on the shadetype. See below for
more details.
Vertices v-1 denotes primitivetype. This means: 0=sprite, 1=line,
2=triangle, 3=quadrangle, etc. Up to octangles are supported.
The shadetype stands for:
FLATSHADED: =%0000000000000000
GOURAUDSHADED:=%0010000000000000
PHONGSHADED: =%0100000000000000
TEXTUREMAPPED:=%0110000000000000
ENVMAPPED: =%1000000000000000
ALPHATEXTURED:=%1010000000000000
BUMPMAPPED: =%1100000000000000
These work for polygons. Lines can only have the first three shadetypes.
Sprites are always the same shadetype (0).
Shadetypes except (0:FLATSHADED) use at least the first optional index
table. Gouraud uses the first table entries directly as colorintensities.
Phong uses them to index normal vectors (starting at index n-m !).
Texture, alpha and bump use them to index into the texturevertex table.
The most heavy shadetypes alpha and bump also use the second table to index
normal vectors. Again these are located in the vertex table, starting at
index n-m.
Shadetype and primitivetype determine the size of a primitive, so beware.
----------------------------------------------------------------------------
HumanFly format handling:
Important to know is how various shadetypes use the palettes and textures
in the HumanFly engine.
The simplest shadetypes are flat, gouraud and phong. These only use the
color palettes (128 entries). Flatshading uses color 64 out of a palette
which should be the middle. Gouraud and phong can use the whole range. The
pal/texture number is used as the palette selector here.
An example: a flatshaded polygon with pal nr 2 indexes pixel 2*128+64 in the
colortable. This colortable is a sequence of palettes of 128 pixels each.
And is passed to HumanFly at the initialisation stage.
The simple texturebased shadetypes are texturemapped and environmentmapped.
These handled quit straightforward. The HumanFly interface accepts 256*256
pixel textures as standard. So the (u,v) range is always ([0..255],[0..255])
The engine knows the textures by means of a table of texturepointers.
So a textured polygon with texturenr 3 maps uses the third texture pointed
to in your table.
The last types are the hardest and use (u0,v0,u1,v1) pairs for every
polygonvertex. They both use two textures. The (u0,v0) maps to the first,
the (u1,v1) one to the second. The optional coefficient tables are both
used and indexes are paired (!).
An example: For a particular bumpmapped triangle you may have:
header,v1,v2,v3,s0,t0,s1,t1,s2,t2
Where s denotes texture 1 (bumpy surface texture on surface)
And t denotes texture 2 (lighting texture)
For an alphamapped texture:
s denotes the surface texture
t denotes the lighting texture