Home My Page Projects Code Snippets Project Openings 3D graphics for Standard ML
Summary Activity SCM

SCM Repository

[sml3d] View of /trunk/sml3d/examples/md3-viewer/md3.sml
ViewVC logotype

View of /trunk/sml3d/examples/md3-viewer/md3.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 391 - (download) (annotate)
Tue Jan 13 23:01:40 2009 UTC (10 years, 6 months ago) by jhr
File size: 1629 byte(s)
  Fixed type errors
(* md3.sml
 *
 * COPYRIGHT (c) 2008 John Reppy (http://cs.uchicago.edu/~jhr)
 * All rights reserved.
 *
 * Representation of "Quake 3: Arena" model files (MD3 files).
 *)


structure MD3 =
   struct

    structure DB = DataBuffer

    type float= SML3dTypes.float
    type vec3f = SML3dTypes.vec3f
    type uint = SML3dTypes.uint

    datatype tag = TAG of {
	name : string,
	frame : FloatONB.frame
      }

    datatype shader = SHADER of {
	name : string,			(* pathname of shader in PK3 file *)
	index : int			(* shader index *)
      }

    datatype model = MODEL of {
	tags : tag list,		(* tags *)
	frames : frame list,		(* the bounding info for each animation frame *)
	surfs : surface list		(* surfaces; each surface has its own *)
					(* animations *)
      }

  (* bounding info for an animation frame *)
    and frame = FRAME of {
	name : string,
	minBounds : vec3f,		(* min corner of AABB *)
	maxBounds : vec3f,		(* max corner of AABB *)
	localOrigin : vec3f,		(* local origin *)
	radius : float			(* radius of bounding sphere *)
      }

  (* a surface (mesh) in the model *)
    and surface = SURF of {
	name : string,
	numVerts : int,			(* number of vertices in the surface *)
	shaders : shader list,
	tris : uint DB.buffer,		(* vertex indices for the triangles (flattened) *)
	texCoords : float DB.buffer2,	(* texture coordinates (one per vertex) *)
	frames : mesh list		(* the per-frame mesh data *)
      }

  (* the mesh data for a single single animation frame of a surface *)
    and mesh = MESH of {
	verts : float DB.buffer3,	(* vertex buffer *)
	norms : float DB.buffer3	(* normal buffer *)
      }

  end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0