这两天写了一个用数据手套驱动3ds手骨骼模型实时运动的程序(使用的3dsftk),发现用这个工具操作3ds模型有些固定的模式和这种格式固有的特点,总结如下:
3ds使用小结:
3ds格式说明:
Autodesk 3D Studio File Format
一个3ds程序例子:
另外还有一个开源的3ds库对3ds支持的多一些--lib3ds,具有生成normal等等信息的功能,对3ds的封装也更好。
lib3ds帮助文档:lib3ds documentation
一个lib3ds的入门程序:Lib3ds tutorial: My first model
3ds ftk采用的数据格式:
typedef struct {
char3ds name[11]; /* Object name */
byte3ds ishidden; /* Hidden object flag */
byte3ds isvislofter; /* Lofter visibility flag */
byte3ds ismatte; /* Matte object flag */
byte3ds isnocast; /* Doesn't cast shadow's flag */
byte3ds isfast; /* Fast display flag */
byte3ds isnorcvshad; /* Doesn't recieve shadows */
byte3ds isfrozen; /* Frozen object flag */
ushort3ds nvertices; /* Vertice count */
point3ds *vertexarray; /* List of vertices */
ushort3ds nvflags; /* Number of vertex flags */
ushort3ds *vflagarray; /* List of vertex flags */
ushort3ds ntextverts; /* Number of texture vertices */
textvert3ds *textarray; /* List of texture coordinates */
byte3ds usemapinfo; /* Boolean for use of mapping icon information */
mapinfo3ds map; /* Mapping icon info */
float3ds locmatrix[12]; /* Object orientation matrix */
ushort3ds nfaces; /* Face count */
face3ds *facearray; /* List of faces */
ulong3ds *smootharray; /* Smoothing group assignment list */
byte3ds useboxmap; /* Boolean used to indicate the use of box mapping */
char3ds boxmap[6][17]; /* Material names used in boxmapping */
ubyte3ds meshcolor; /* UI color assigned to the mesh */
ushort3ds nmats; /* Assigned materials count */
objmat3ds *matarray; /* Material assignment list */
byte3ds useproc; /* Use animated stand-in flag */
ulong3ds procsize; /* Size of animated stand-in data */
char3ds procname[13]; /* Name of animated stand-in procedure */
void3ds *procdata; /* Animated stand-in data */
} mesh3ds;
3ds的运动数据格式:
typedef struct {
char3ds name[11]; /* Name of mesh */
char3ds parent[22]; /* Name of parent object */
ushort3ds flags1; /* flags field from node header */
ushort3ds flags2; /* flags2 field from node header */
point3ds pivot; /* Object pivot point */
char3ds instance[11]; /* Object instance name */
point3ds boundmin; /* Minimum bounding box point for dummy objects */
point3ds boundmax; /* Maximum bounding box point for dummy objects */
ulong3ds npkeys; /* Number of position keys */
short3ds npflag; /* Loop control flag for position keys */
keyheader3ds *pkeys; /* Spline values for position keys */
point3ds *pos; /* Mesh position keys */
ulong3ds nrkeys; /* Number of rotation keys */
short3ds nrflag; /* Loop control flag for rotation keys */
keyheader3ds *rkeys; /* Spline values for rotation keys */
kfrotkey3ds *rot; /* Rotation keys */
ulong3ds nskeys; /* Number of scaling keys */
short3ds nsflag; /* Loop control flag for scaling keys */
keyheader3ds *skeys; /* Spline values for scaling */
point3ds *scale; /* Mesh scaling keys */
ulong3ds nmkeys; /* Number of morph keys */
short3ds nmflag; /* Loop control flag for morph keys */
keyheader3ds *mkeys; /* Spline values for morph keys */
kfmorphkey3ds *morph; /* Morph keys */
ulong3ds nhkeys; /* Number of hide keys */
short3ds nhflag; /* Loop control flag for hide keys */
keyheader3ds *hkeys; /* Spline values for hide keys */
float3ds msangle; /* Morph smoothing group angle */
} kfmesh3ds;