45 lines
865 B
C
45 lines
865 B
C
/*
|
|
* stl.h
|
|
* Author: Josh Holtrop
|
|
* Date: 2007-06-02
|
|
* From information at http://en.wikipedia.org/wiki/STL_(file_format)
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* macros */
|
|
#define STL_HEADER_LENGTH 80
|
|
#define stl_num_faces(stlp) ((stlp)->n_faces)
|
|
#define stl_face(stlp,facenum) ((stlp)->faces[(facenum)])
|
|
#define stl_attr_color_valid(attr) ((attr) & 0x8000)
|
|
#define stl_attr_color_r(attr) (((attr) & 0x7C00) >> 7)
|
|
#define stl_attr_color_g(attr) (((attr) & 0x03E0) >> 2)
|
|
#define stl_attr_color_b(attr) (((attr) & 0x001F) << 3)
|
|
|
|
|
|
/* types */
|
|
typedef struct stl_face_s
|
|
{
|
|
float normal[3];
|
|
float vertices[3][3];
|
|
unsigned short attribute;
|
|
} stl_face_t;
|
|
|
|
typedef struct stl_s
|
|
{
|
|
char header[STL_HEADER_LENGTH];
|
|
unsigned int n_faces;
|
|
stl_face_t faces[1];
|
|
} stl_t;
|
|
|
|
|
|
/* functions */
|
|
stl_t * stl_load(const char * filename);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|