📄 t3dlib7.h
字号:
inline void VERTEX4DTV1_COPY(VERTEX4DTV1_PTR vdst, VERTEX4DTV1_PTR vsrc)
{ *vdst = *vsrc; }
inline void VERTEX4DTV1_INIT(VERTEX4DTV1_PTR vdst, VERTEX4DTV1_PTR vsrc)
{ *vdst = *vsrc; }
inline float VECTOR4D_Length_Fast2(VECTOR4D_PTR va)
{
// this function computes the distance from the origin to x,y,z
int temp; // used for swaping
int x,y,z; // used for algorithm
// make sure values are all positive
x = fabs(va->x) * 1024;
y = fabs(va->y) * 1024;
z = fabs(va->z) * 1024;
// sort values
if (y < x) SWAP(x,y,temp)
if (z < y) SWAP(y,z,temp)
if (y < x) SWAP(x,y,temp)
int dist = (z + 11 * (y >> 5) + (x >> 2) );
// compute distance with 8% error
return((float)(dist >> 10));
} // end VECTOR4D_Length_Fast2
// TYPES ///////////////////////////////////////////////////////////////////
// EXTERNALS ///////////////////////////////////////////////////////////////
extern UCHAR logbase2ofx[513];
extern UCHAR rgblightlookup[4096][256]; // rgb 8.12 lighting table lookup
extern char texture_path[80]; // root path to ALL textures, make current directory for now
// PROTOTYPES //////////////////////////////////////////////////////////////
char *Extract_Filename_From_Path(char *filepath, char *filename);
int Set_OBJECT4DV2_Frame(OBJECT4DV2_PTR obj, int frame);
int Destroy_OBJECT4DV2(OBJECT4DV2_PTR obj);
int Init_OBJECT4DV2(OBJECT4DV2_PTR obj, // object to allocate
int _num_vertices,
int _num_polys,
int _num_frames,
int destroy=0);
void Translate_OBJECT4DV2(OBJECT4DV2_PTR obj, VECTOR4D_PTR vt);
void Scale_OBJECT4DV2(OBJECT4DV2_PTR obj, VECTOR4D_PTR vs, int all_frames=0);
void Transform_OBJECT4DV2(OBJECT4DV2_PTR obj, MATRIX4X4_PTR mt,
int coord_select, int transform_basis, int all_frames=0);
void Rotate_XYZ_OBJECT4DV2(OBJECT4DV2_PTR obj,
float theta_x,
float theta_y,
float theta_z,
int all_frames);
void Model_To_World_OBJECT4DV2(OBJECT4DV2_PTR obj, int coord_select = TRANSFORM_LOCAL_TO_TRANS, int all_frames=0);
int Cull_OBJECT4DV2(OBJECT4DV2_PTR obj, CAM4DV1_PTR cam, int cull_flags);
void Remove_Backfaces_OBJECT4DV2(OBJECT4DV2_PTR obj, CAM4DV1_PTR cam);
void Remove_Backfaces_RENDERLIST4DV2(RENDERLIST4DV2_PTR rend_list, CAM4DV1_PTR cam);
void World_To_Camera_OBJECT4DV2(OBJECT4DV2_PTR obj, CAM4DV1_PTR cam);
void Camera_To_Perspective_OBJECT4DV2(OBJECT4DV2_PTR obj, CAM4DV1_PTR cam);
void Perspective_To_Screen_RENDERLIST4DV2(RENDERLIST4DV2_PTR rend_list,
CAM4DV1_PTR cam);
void Camera_To_Perspective_Screen_RENDERLIST4DV2(RENDERLIST4DV2_PTR rend_list,
CAM4DV1_PTR cam);
void Camera_To_Perspective_RENDERLIST4DV2(RENDERLIST4DV2_PTR rend_list,
CAM4DV1_PTR cam);
void Camera_To_Perspective_Screen_OBJECT4DV2(OBJECT4DV2_PTR obj, CAM4DV1_PTR cam);
void Perspective_To_Screen_OBJECT4DV2(OBJECT4DV2_PTR obj, CAM4DV1_PTR cam);
void Convert_From_Homogeneous4D_OBJECT4DV1(OBJECT4DV1_PTR obj);
int Insert_POLY4DV2_RENDERLIST4DV2(RENDERLIST4DV2_PTR rend_list,
POLY4DV2_PTR poly);
int Insert_POLYF4DV2_RENDERLIST4DV2(RENDERLIST4DV2_PTR rend_list,
POLYF4DV2_PTR poly);
int Insert_OBJECT4DV2_RENDERLIST4DV2(RENDERLIST4DV2_PTR rend_list,
OBJECT4DV2_PTR obj,
int insert_local);
void Reset_OBJECT4DV2(OBJECT4DV2_PTR obj);
int Compute_OBJECT4DV2_Poly_Normals(OBJECT4DV2_PTR obj);
void Draw_OBJECT4DV2_Wire(OBJECT4DV2_PTR obj, UCHAR *video_buffer, int lpitch);
void Draw_OBJECT4DV2_Wire16(OBJECT4DV2_PTR obj, UCHAR *video_buffer, int lpitch);
void Draw_RENDERLIST4DV2_Wire(RENDERLIST4DV2_PTR rend_list,
UCHAR *video_buffer, int lpitch);
void Draw_RENDERLIST4DV2_Wire16(RENDERLIST4DV2_PTR rend_list,
UCHAR *video_buffer, int lpitch);
void Draw_RENDERLIST4DV2_Solid(RENDERLIST4DV2_PTR rend_list,
UCHAR *video_buffer, int lpitch);
void Draw_RENDERLIST4DV2_Solid16(RENDERLIST4DV2_PTR rend_list,
UCHAR *video_buffer, int lpitch);
void Draw_OBJECT4DV2_Textured(OBJECT4DV2_PTR obj, UCHAR *video_buffer, int lpitch);
void Draw_RENDERLIST4DV2_Textured(RENDERLIST4DV2_PTR rend_list,
UCHAR *video_buffer, int lpitch, BITMAP_IMAGE_PTR texture);
void Draw_RENDERLIST4DV2_Textured16(RENDERLIST4DV2_PTR rend_list,
UCHAR *video_buffer, int lpitch, BITMAP_IMAGE_PTR texture);
void Draw_OBJECT4DV1_Solid2_16(OBJECT4DV1_PTR obj,
UCHAR *video_buffer, int lpitch);
void Draw_RENDERLIST4DV1_Solid2(RENDERLIST4DV1_PTR rend_list,
UCHAR *video_buffer, int lpitch);
void Draw_OBJECT4DV1_Solid2(OBJECT4DV1_PTR obj,
UCHAR *video_buffer, int lpitch);
void World_To_Camera_RENDERLIST4DV2(RENDERLIST4DV2_PTR rend_list,
CAM4DV1_PTR cam);
void Draw_OBJECT4DV1_Solid2_16(OBJECT4DV1_PTR obj,
UCHAR *video_buffer, int lpitch);
void Draw_RENDERLIST4DV1_Solid2(RENDERLIST4DV1_PTR rend_list,
UCHAR *video_buffer, int lpitch);
void Draw_OBJECT4DV1_Solid2(OBJECT4DV1_PTR obj,
UCHAR *video_buffer, int lpitch);
void Draw_OBJECT4DV1_Textured(OBJECT4DV1_PTR obj, UCHAR *video_buffer, int lpitch);
void Draw_RENDERLIST4DV1_Textured(RENDERLIST4DV1_PTR rend_list,
UCHAR *video_buffer, int lpitch, BITMAP_IMAGE_PTR texture);
void Draw_RENDERLIST4DV1_Textured16(RENDERLIST4DV1_PTR rend_list,
UCHAR *video_buffer, int lpitch, BITMAP_IMAGE_PTR texture);
void Draw_RENDERLIST4DV2_Gouraud16(RENDERLIST4DV2_PTR rend_list,
UCHAR *video_buffer, int lpitch);
void Draw_RENDERLIST4DV1_Solid2_16(RENDERLIST4DV1_PTR rend_list,
UCHAR *video_buffer, int lpitch);
void Draw_OBJECT4DV1_Solid2_16(OBJECT4DV1_PTR obj,
UCHAR *video_buffer, int lpitch);
void Draw_RENDERLIST4DV1_Solid2_16(RENDERLIST4DV1_PTR rend_list,
UCHAR *video_buffer, int lpitch);
void Draw_OBJECT4DV1_Solid2_16(OBJECT4DV1_PTR obj,
UCHAR *video_buffer, int lpitch);
void Draw_RENDERLIST4DV1_Solid2(RENDERLIST4DV1_PTR rend_list,
UCHAR *video_buffer, int lpitch);
void Draw_OBJECT4DV1_Solid2(OBJECT4DV1_PTR obj,
UCHAR *video_buffer, int lpitch);
float Compute_OBJECT4DV2_Radius(OBJECT4DV2_PTR obj);
int Compute_OBJECT4DV2_Vertex_Normals(OBJECT4DV2_PTR obj);
int Load_OBJECT4DV2_PLG(OBJECT4DV2_PTR obj, // pointer to object
char *filename, // filename of plg file
VECTOR4D_PTR scale, // initial scaling factors
VECTOR4D_PTR pos, // initial position
VECTOR4D_PTR rot, // initial rotations
int vertex_flags=0); // flags to re-order vertices
int Load_OBJECT4DV2_3DSASC(OBJECT4DV2_PTR obj, // pointer to object
char *filename, // filename of ASC file
VECTOR4D_PTR scale, // initial scaling factors
VECTOR4D_PTR pos, // initial position
VECTOR4D_PTR rot, // initial rotations
int vertex_flags=0); // flags to re-order vertices
int Load_OBJECT4DV2_COB(OBJECT4DV2_PTR obj, // pointer to object
char *filename, // filename of Caligari COB file
VECTOR4D_PTR scale, // initial scaling factors
VECTOR4D_PTR pos, // initial position
VECTOR4D_PTR rot, // initial rotations
int vertex_flags=0); // flags to re-order vertices
// and perform transforms
void Reset_RENDERLIST4DV2(RENDERLIST4DV2_PTR rend_list);
int RGB_12_8_Lighting_Table_Builder(LPPALETTEENTRY src_palette, // source palette
UCHAR rgblookup[4096][256]); // lookup table
int Light_OBJECT4DV2_World16(OBJECT4DV2_PTR obj, // object to process
CAM4DV1_PTR cam, // camera position
LIGHTV1_PTR lights, // light list (might have more than one)
int max_lights); // maximum lights in list
int Light_OBJECT4DV2_World(OBJECT4DV2_PTR obj, // object to process
CAM4DV1_PTR cam, // camera position
LIGHTV1_PTR lights, // light list (might have more than one)
int max_lights); // maximum lights in list
int Light_RENDERLIST4DV2_World(RENDERLIST4DV2_PTR rend_list, // list to process
CAM4DV1_PTR cam, // camera position
LIGHTV1_PTR lights, // light list (might have more than one)
int max_lights); // maximum lights in list
int Light_RENDERLIST4DV2_World16(RENDERLIST4DV2_PTR rend_list, // list to process
CAM4DV1_PTR cam, // camera position
LIGHTV1_PTR lights, // light list (might have more than one)
int max_lights); // maximum lights in list
// z-sort algorithm (simple painters algorithm)
void Sort_RENDERLIST4DV2(RENDERLIST4DV2_PTR rend_list, int sort_method);
// avg z-compare
int Compare_AvgZ_POLYF4DV2(const void *arg1, const void *arg2);
// near z-compare
int Compare_NearZ_POLYF4DV2(const void *arg1, const void *arg2);
// far z-compare
int Compare_FarZ_POLYF4DV2(const void *arg1, const void *arg2);
void Draw_Textured_Triangle(POLYF4DV2_PTR face, UCHAR *dest_buffer, int mem_pitch);
void Draw_Textured_TriangleFS(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch); // bytes per line, 320, 640 etc.
void Draw_Textured_Triangle16(POLYF4DV2_PTR face, UCHAR *dest_buffer, int mem_pitch);
void Draw_Textured_TriangleFS16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch); // bytes per line, 320, 640 etc.
void Draw_Gouraud_Triangle16(POLYF4DV2_PTR face, // ptr to face
UCHAR *_dest_buffer, // pointer to video buffer
int mem_pitch); // bytes per line, 320, 640 etc.
void Draw_Gouraud_Triangle(POLYF4DV2_PTR face, // ptr to face
UCHAR *dest_buffer, // pointer to video buffer
int mem_pitch); // bytes per line, 320, 640 etc.
void Draw_Top_Tri2_16(float x1, float y1,
float x2, float y2,
float x3, float y3,
int color,
UCHAR *_dest_buffer, int mempitch);
void Draw_Bottom_Tri2_16(float x1, float y1,
float x2, float y2,
float x3, float y3,
int color,
UCHAR *_dest_buffer, int mempitch);
void Draw_Triangle_2D2_16(float x1, float y1,
float x2, float y2,
float x3, float y3,
int color,
UCHAR *dest_buffer, int mempitch);
void Draw_Top_Tri2(float x1, float y1,
float x2, float y2,
float x3, float y3,
int color,
UCHAR *_dest_buffer, int mempitch);
void Draw_Bottom_Tri2(float x1, float y1,
float x2, float y2,
float x3, float y3,
int color,
UCHAR *_dest_buffer, int mempitch);
void Draw_Triangle_2D2(float x1, float y1,
float x2, float y2,
float x3, float y3,
int color,
UCHAR *dest_buffer, int mempitch);
int Load_Bitmap_File2(BITMAP_FILE_PTR bitmap, char *filename);
int Load_Bitmap_PCX_File(BITMAP_FILE_PTR bitmap, char *filename);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -