]> Dogcows Code - chaz/rasterize/blob - model.h
add opengl support
[chaz/rasterize] / model.h
1
2 /*
3 * CS5600 University of Utah
4 * Charles McGarvey
5 * mcgarvey@eng.utah.edu
6 */
7
8 #ifndef _MODEL_H_
9 #define _MODEL_H_
10
11 #include "array.h"
12 #include "color.h"
13 #include "common.h"
14 #include "mat.h"
15 #include "tri.h"
16
17
18 #define MODEL_TYPE_RAW (1)
19 #define MODEL_TYPE_OBJ (2)
20
21 // create an interface for a vector array
22 DEFINE_ARRAY_TYPE(tri);
23
24
25 /*
26 * A model is a group of geometry and its attributes.
27 */
28 typedef struct model model_t;
29
30
31 /*
32 * Allocate and load a model from a file. The file format of the model will
33 * be inferred from the filename extension.
34 */
35 model_t* model_alloc(const char* filename);
36
37 /*
38 * Allocate and load a model from a file. You must explicitly pass the file
39 * format of the model data.
40 */
41 model_t* model_alloc2(const char* filename, int type);
42
43 /*
44 * Destroy a model, freeing up its memory.
45 */
46 void model_destroy(model_t* m);
47
48
49 /*
50 * Get the model's geometry as an array of triangles.
51 */
52 const array_t* model_geometry(const model_t* m);
53
54 /*
55 * Get the number of triangles that make up the model.
56 */
57 int model_size(const model_t* m);
58
59 /*
60 * Get a string representation for the model (i.e. a filename).
61 */
62 const char* model_name(const model_t* m);
63
64 /*
65 * Get the color of the specular light property of the model.
66 */
67 color_t model_specular(const model_t* m);
68
69 /*
70 * Get the level of shininess of a model for use in lighting calculations.
71 */
72 scal_t model_shininess(const model_t* m);
73
74 /*
75 * Get the current transformation of the model. This can be changed by a call
76 * to model_transform.
77 */
78 void model_transformation(const model_t* m, mat_t* transform);
79
80 /*
81 * Get the color of the texture at the given uv coordinates.
82 */
83 color_t model_tcolor(const model_t* m, vec_t pt);
84
85 /*
86 * Get a copy of the raw texture data. It must be freed when not needed.
87 * Returns NULL if the model has no texture.
88 */
89 void* model_tdata(const model_t* m, int* width, int* height);
90
91
92 /*
93 * Post-multiply a transformation matrix to the internal matrix representing
94 * the model's location and orientation.
95 */
96 void model_transform(model_t* m, const mat_t* transform);
97
98 /*
99 * Set the material attributes of the model.
100 */
101 void model_material(model_t* m, color_t specular, scal_t shininess);
102
103 /*
104 * Set the texture of the model.
105 */
106 void model_texture(model_t* m, const void* p);
107
108
109 #endif // _MODEL_H_
110
This page took 0.036019 seconds and 4 git commands to generate.