📄 3dsftk.h
字号:
/****************************************************************************
*
* 3DSFTK.H - 3D Studio File Toolkit for Release 3 library header
*
* (C) Copyright 1997 by Autodesk, Inc.
*
* This program is copyrighted by Autodesk, Inc. and is licensed to you under
* the following conditions. You may not distribute or publish the source
* code of this program in any form. You may incorporate this code in object
* form in derivative works provided such derivative works are (i.) are de-
* signed and intended to work solely with Autodesk, Inc. products, and (ii.)
* contain Autodesk's copyright notice "(C) Copyright 1995 by Autodesk, Inc."
*
* AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. AUTODESK SPE-
* CIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR USE. AUTODESK, INC. DOES NOT WARRANT THAT THE OPERATION OF
* THE PROGRAM WILL BE UNINTERRUPTED OR ERROR FREE.
*
***************************************************************************/
#ifndef FTK3DS_H
#define FTK3DS_H
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Note: Item's prefixed with a "Priv" comment are internally used, are not
part of the toolkit's published interface, and should not be used
by non-ftk library functions */
/* Data Type Synonyms For Portability */
#define char3ds char
#define uchar3ds unsigned char
#define byte3ds char
#define ubyte3ds unsigned char
#define short3ds short int
#define ushort3ds unsigned short int
#define long3ds long int
#define ulong3ds unsigned long int
#define float3ds float
#define double3ds double
#define int3ds int
#define void3ds void
/* 3DS File Toolkit revision level. Future revisions will increment this
integer number */
#define FTKRevisionLevel3ds 2
/*------------------------------------
Error reporting and testing macros
----------------------------------*/
/* Pending error flag values for ftkerr3ds global */
#define FTK_ERROR True3ds
#define FTK_NO_ERROR False3ds
/*--- If ftkerr3ds shows that an error has occured, return */
#define ON_ERROR_RETURN {if(ftkerr3ds && !ignoreftkerr3ds) return;}
#define ON_ERROR_RETURNR(rval) {if(ftkerr3ds && !ignoreftkerr3ds) return rval;}
/*--- If ftkerr3ds shows that an error has occured, push error and return */
#define ADD_ERROR_RETURN(id) {if(ftkerr3ds){PushErrList3ds(id); if (!ignoreftkerr3ds) return;}}
#define ADD_ERROR_RETURNR(id, rval) {if(ftkerr3ds){PushErrList3ds(id); if (!ignoreftkerr3ds) return rval;}}
/*--- If ftkerr3ds shows that an error has occured, push error */
#define ADD_ERROR(id) {if (ftkerr3ds){PushErrList3ds(id);}}
/*--- Reset the the error flag */
#define CLEAR_ERROR {if (ftkerr3ds){ClearErrList3ds();}}
/*--- Simply set the error state: Good if you need to clean-up before returning */
#define SET_ERROR {ftkerr3ds=True3ds;}
/*--- Set error state, push an error ID and return */
#define SET_ERROR_RETURN(id) {PushErrList3ds(id); if (!ignoreftkerr3ds) return;}
#define SET_ERROR_RETURNR(id, rval) {PushErrList3ds(id); if (!ignoreftkerr3ds) return rval;}
/* Prints errors and exits application */
#define PRINT_ERRORS_EXIT(file) {if(ftkerr3ds && file){DumpErrList3ds(file); if (!ignoreftkerr3ds) exit(0x3D);}}
/*----------------------------------------
Commonly used structures and constants
--------------------------------------*/
/* Constants to define True and False in a compiler independant way. */
#define TRUE3DS (1==1)
#define FALSE3DS (1!=1)
static const byte3ds True3ds = (1==1);
static const byte3ds False3ds = (1!=1);
/* point3ds - 3D point structure */
typedef struct
{
float3ds x, y, z;
} point3ds;
/* fcolor3ds - Floating point color definition */
typedef struct {
float3ds r; /* RGB Color components */
float3ds g;
float3ds b;
} fcolor3ds;
/* face3ds - Face list element */
typedef struct
{
ushort3ds v1, v2, v3, flag;
} face3ds;
/* textvert3ds - Texture assignment coordinate */
typedef struct
{
float3ds u, v;
} textvert3ds;
/* Priv */ /* trackheader3ds - Global track settings */
/* Priv */ typedef struct
/* Priv */ {
/* Priv */ ushort3ds flags;
/* Priv */ ulong3ds nu1, nu2;
/* Priv */ ulong3ds keycount; /* Number of keys in the track */
/* Priv */ } trackheader3ds;
/* keyheader3ds - Animation key settings */
typedef struct
{
ulong3ds time; /* Key's frame position */
ushort3ds rflags; /* Spline terms used flag */
float3ds tension; /* Flagged with 0x01 */
float3ds continuity; /* Flagged with 0x02 */
float3ds bias; /* Flagged with 0x04 */
float3ds easeto; /* Flagged with 0x08 */
float3ds easefrom; /* Flagged with 0x10 */
} keyheader3ds;
/* kfrotkey3ds - Rotation key */
typedef struct {
float3ds angle; /* angle of rotation */
float3ds x; /* rotation axis vector */
float3ds y;
float3ds z;
} kfrotkey3ds;
/* kfmorphkey3ds - Object morph key */
typedef struct {
char3ds name[13]; /* name of target morph object */
} kfmorphkey3ds;
/* Error codes generated by toolkit */
typedef enum
{
NO_FTK_ERRORS = 0, /* No errors are pending */
ERR_NO_MEM, /* Not enough memory to complete operation */
ERR_INVALID_ARG, /* The argument passed to the function invalid. Usually */
/* caused by a NULL pointer or an out of range numeric */
/* argument. */
ERR_INVALID_DATA, /* The structure passed as an argument to the function has */
/* invalid or out of range data in its fields. */
ERR_INVALID_CHUNK, /* An invalid chunk structure was encountered while reading */
/* the database. Usually caused by a corrupt database or */
/* file */
ERR_INVALID_DATABASE, /* The database passed as an argument has not be created */
/* yet. */
ERR_WRONG_DATABASE, /* The database passed as an argument is the wrong kind of */
/* database for this function. */
ERR_UNFOUND_CHUNK, /* The database is missing important file chunks needed to */
/* fill out the requested structure. Usually caused by a */
/* corrupt database or file */
ERR_WRONG_OBJECT, /* The name passed to the functions exists, but is not the */
/* type of object asked for. For example, asking for a mesh */
/* object with the GetCameraByName3ds function. */
ERR_NO_SUCH_FILE, /* The filename passed as an argument for reading does not exist */
ERR_INIT_FAILED, /* Failed to initialize structure passed as an argument */
ERR_OPENING_FILE, /* Could not open requested file */
ERR_CLOSING_FILE, /* Could not close requested file */
ERR_READING_FILE, /* Error occured while reading file */
ERR_CREATING_DATABASE, /* Error occured while creating database */
ERR_READING_DATABASE, /* Error occured while reading database */
ERR_WRITING_DATABASE, /* Error occured while writing database */
ERR_WRITING_FILE, /* Error occured while writing file */
ERR_STRING_TOO_LONG, /* String encountered in file, structure, or as an */
/* argument was longer than expected. Possibly caused by */
/* an uninitialed pointer, corrupt file or database */
ERR_TOO_MANY_FILES, /* The toolkit has reached its maximum open file limit of */
/* 252 files. */
ERR_GET_FAIL, /* Failed to get new data from database */
ERR_PUT_FAIL, /* Failed to add new data to the database */
N_ERRORS
}errorid3ds;
typedef struct {
errorid3ds id;
const char3ds *desc;
} ErrRec3ds;
/* Priv */ /* chunktag3ds - enumeration of all possible chunk type identifiers. See appendix for */
/* Priv */ /* more information concerning chunk structures */
/* Priv */ typedef enum
/* Priv */ {
/* Priv */ /* Trick Chunk Flags For ChunkSyntax function */
/* Priv */ NULL_CHUNK = 0x0000,
/* Priv */ ChunkType = 0x0995,
/* Priv */ ChunkUnique = 0x0996,
/* Priv */ NotChunk = 0x0997,
/* Priv */ Container = 0x0998,
/* Priv */ IsChunk = 0x0999,
/* Priv */ /* Dummy Chunk that sometimes appears in 3ds files created by prerelease 3D Studio R2 */
/* Priv */ DUMMY = 0xFFFF,
/* Priv */ /* Trick Chunk Types For Open*, Write*, Close* functions */
/* Priv */ POINT_ARRAY_ENTRY = 0xF110,
/* Priv */ POINT_FLAG_ARRAY_ENTRY = 0xF111,
/* Priv */ FACE_ARRAY_ENTRY = 0xF120,
/* Priv */ MSH_MAT_GROUP_ENTRY = 0xF130,
/* Priv */ TEX_VERTS_ENTRY = 0xF140,
/* Priv */ SMOOTH_GROUP_ENTRY = 0xF150,
/* Priv */ POS_TRACK_TAG_KEY = 0xF020,
/* Priv */ ROT_TRACK_TAG_KEY = 0xF021,
/* Priv */ SCL_TRACK_TAG_KEY = 0xF022,
/* Priv */ FOV_TRACK_TAG_KEY = 0xF023,
/* Priv */ ROLL_TRACK_TAG_KEY = 0xF024,
/* Priv */ COL_TRACK_TAG_KEY = 0xF025,
/* Priv */ MORPH_TRACK_TAG_KEY = 0xF026,
/* Priv */ HOT_TRACK_TAG_KEY = 0xF027,
/* Priv */ FALL_TRACK_TAG_KEY = 0xF028,
/* Priv */
/* Priv */ /* 3DS File Chunk IDs */
/* Priv */ M3DMAGIC = 0x4D4D,
/* Priv */ SMAGIC = 0x2D2D,
/* Priv */ LMAGIC = 0x2D3D,
/* Priv */ MLIBMAGIC = 0x3DAA,
/* Priv */ MATMAGIC = 0x3DFF,
/* Priv */ M3D_VERSION = 0x0002,
/* Priv */ M3D_KFVERSION = 0x0005,
/* Priv */ /* Mesh Chunk Ids */
/* Priv */ MDATA = 0x3D3D,
/* Priv */ MESH_VERSION = 0x3D3E,
/* Priv */ COLOR_F = 0x0010,
/* Priv */ COLOR_24 = 0x0011,
/* Priv */ LIN_COLOR_24 = 0x0012,
/* Priv */ LIN_COLOR_F = 0x0013,
/* Priv */ INT_PERCENTAGE = 0x0030,
/* Priv */ FLOAT_PERCENTAGE = 0x0031,
/* Priv */ MASTER_SCALE = 0x0100,
/* Priv */ BIT_MAP = 0x1100,
/* Priv */ USE_BIT_MAP = 0x1101,
/* Priv */ SOLID_BGND = 0x1200,
/* Priv */ USE_SOLID_BGND = 0x1201,
/* Priv */ V_GRADIENT = 0x1300,
/* Priv */ USE_V_GRADIENT = 0x1301,
/* Priv */ LO_SHADOW_BIAS = 0x1400,
/* Priv */ HI_SHADOW_BIAS = 0x1410,
/* Priv */ SHADOW_MAP_SIZE = 0x1420,
/* Priv */ SHADOW_SAMPLES = 0x1430,
/* Priv */ SHADOW_RANGE = 0x1440,
/* Priv */ SHADOW_FILTER = 0x1450,
/* Priv */ RAY_BIAS = 0x1460,
/* Priv */
/* Priv */ O_CONSTS = 0x1500,
/* Priv */
/* Priv */ AMBIENT_LIGHT = 0x2100,
/* Priv */ FOG = 0x2200,
/* Priv */ USE_FOG = 0x2201,
/* Priv */ FOG_BGND = 0x2210,
/* Priv */ DISTANCE_CUE = 0x2300,
/* Priv */ USE_DISTANCE_CUE = 0x2301,
/* Priv */ LAYER_FOG = 0x2302,
/* Priv */ USE_LAYER_FOG = 0x2303,
/* Priv */ DCUE_BGND = 0x2310,
/* Priv */ DEFAULT_VIEW = 0x3000,
/* Priv */ VIEW_TOP = 0x3010,
/* Priv */ VIEW_BOTTOM = 0x3020,
/* Priv */ VIEW_LEFT = 0x3030,
/* Priv */ VIEW_RIGHT = 0x3040,
/* Priv */ VIEW_FRONT = 0x3050,
/* Priv */ VIEW_BACK = 0x3060,
/* Priv */ VIEW_USER = 0x3070,
/* Priv */ VIEW_CAMERA = 0x3080,
/* Priv */ VIEW_WINDOW = 0x3090,
/* Priv */ NAMED_OBJECT = 0x4000,
/* Priv */ OBJ_HIDDEN = 0x4010,
/* Priv */ OBJ_VIS_LOFTER = 0x4011,
/* Priv */ OBJ_DOESNT_CAST = 0x4012,
/* Priv */ OBJ_MATTE = 0x4013,
/* Priv */ OBJ_FAST = 0x4014,
/* Priv */ OBJ_PROCEDURAL = 0x4015,
/* Priv */ OBJ_FROZEN = 0x4016,
/* Priv */ OBJ_DONT_RCVSHADOW = 0x4017,
/* Priv */ N_TRI_OBJECT = 0x4100,
/* Priv */ POINT_ARRAY = 0x4110,
/* Priv */ POINT_FLAG_ARRAY = 0x4111,
/* Priv */ FACE_ARRAY = 0x4120,
/* Priv */ MSH_MAT_GROUP = 0x4130,
/* Priv */ OLD_MAT_GROUP = 0x4131,
/* Priv */ TEX_VERTS = 0x4140,
/* Priv */ SMOOTH_GROUP = 0x4150,
/* Priv */ MESH_MATRIX = 0x4160,
/* Priv */ MESH_COLOR = 0x4165,
/* Priv */ MESH_TEXTURE_INFO = 0x4170,
/* Priv */ PROC_NAME = 0x4181,
/* Priv */ PROC_DATA = 0x4182,
/* Priv */ MSH_BOXMAP = 0x4190,
/* Priv */ N_D_L_OLD = 0x4400,
/* Priv */ N_CAM_OLD = 0x4500,
/* Priv */ N_DIRECT_LIGHT = 0x4600,
/* Priv */ DL_SPOTLIGHT = 0x4610,
/* Priv */ DL_OFF = 0x4620,
/* Priv */ DL_ATTENUATE = 0x4625,
/* Priv */ DL_RAYSHAD = 0x4627,
/* Priv */ DL_SHADOWED = 0x4630,
/* Priv */ DL_LOCAL_SHADOW = 0x4640,
/* Priv */ DL_LOCAL_SHADOW2 = 0x4641,
/* Priv */ DL_SEE_CONE = 0x4650,
/* Priv */ DL_SPOT_RECTANGULAR = 0x4651,
/* Priv */ DL_SPOT_OVERSHOOT = 0x4652,
/* Priv */ DL_SPOT_PROJECTOR = 0x4653,
/* Priv */ DL_EXCLUDE = 0x4654,
/* Priv */ DL_RANGE = 0x4655, /* Not used in R3 */
/* Priv */ DL_SPOT_ROLL = 0x4656,
/* Priv */ DL_SPOT_ASPECT = 0x4657,
/* Priv */ DL_RAY_BIAS = 0x4658,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -