convert line ends
[canaan.git] / prj / tech / h / newskel.h
blobf806cfd52ac40fde7bf5c29e5785dd9cfb0ffd43
1 /*
2 * $Source: x:/prj/tech/libsrc/newskel/RCS/newskel.h $
3 * $Revision: 1.2 $
4 * $Author: TOML $
5 * $Date: 1996/10/23 09:21:46 $
7 * Skeleton libary includes
9 */
11 #ifndef __SKEL_H
12 #define __SKEL_H
14 #include <3d.h>
15 #include <res.h>
17 // Data types for a cylindrical bitmap object
18 // eventually we'll want one for a full 3d one
20 typedef struct {
21 int nviews; // number of views
22 fix ppu; // pixels per unit
23 fix len; // length from anchor to anchor
24 bool bisym; // bilateral symmetry or not (means its a mirror)
25 int off[1]; // offsets, in reality there should be off[nview] of them
26 } CylBMObj; // cylindrical 3d bitmap object
28 typedef struct {
29 grs_bitmap bm;
30 signed char u1,v1; // anchor point 1
31 signed char u2,v2; // anchor point 2
32 fix vper1; // v1 / (v2-v1)
33 fix vper2; // (h-v2) / (v2-v1)
34 fix uper; // (w - u) / u
35 } CylBMFrame; // one frame of the cylindrical bm object. Always put the bits after this.
37 typedef void (*CylBMDecalFunc)(void *data, grs_vertex *v, uchar frame);
39 // Segment flag, mirror image
40 #define SKF_MIRROR 1
41 // Are joints 1 and 2 exposed to light or not
42 #define SKF_EXPOSE1 2
43 #define SKF_EXPOSE2 4
44 #define SKF_DONTRENDER 16 // take a big guess
46 typedef enum {
47 LINE,
48 CYL,
49 BMAP,
50 POLY
51 } ske_segtype;
53 typedef enum {
54 NONE,
55 FAST,
56 MEDIUM,
57 SLOW
58 } ske_sorttype;
60 // Structure for each segment
61 typedef struct {
62 ubyte p1; // offsets of points 1 and 2
63 ubyte p2;
64 ubyte or; // offset of orientation vector
65 ubyte flag; // flags, for instance, is it mirrored,exposed?,locked?
66 union {
67 struct { // for cylinder dude
68 fix len;
69 fix rad;
70 long col;
72 struct {
73 ulong handle; // for locking
74 union {
75 struct { // for bitmap dude
76 CylBMObj *co;
77 ubyte *clut;
78 CylBMDecalFunc decfunc; // decal rendering function
79 void *decdata; // data for decal rendering func
81 struct { // for 3d model dude
82 ubyte *model;
83 fix *parm;
88 } sks_seginfo;
90 typedef struct sks_skel;
92 // The skeleton structure, followed by seginfo
93 // then orientation vectors, then joints
94 typedef struct _sks {
95 ske_segtype type; // type of skeleton
96 ubyte segn; // number of segments
97 ubyte pointn; // number of points
98 ubyte orn; // number of orientation vectors
99 void (*qsort) (struct _sks *s,ubyte *rl,g3s_phandle *tmp); // pointer to sorter
100 sks_seginfo *sg; // pointer to start of seg info
101 g3s_vector *pn; // pointer to start of list of vectors
102 g3s_vector *or; // first in array of local orientation vectors
103 } sks_skel;
105 void sk_init(void);
107 // Allocate space for a skeleton
108 // given a model
109 sks_skel *sk_alloc_skel(ubyte segn,ubyte pointn,ubyte orn);
111 // initialize a skeleton given the model
112 sks_skel *sk_init_skel(sks_skel *sk,ubyte segn,ubyte pointn,ubyte orn);
114 // returns target size of the skeleton, given the model
115 int sk_size_skel(ubyte segn,ubyte pointn,ubyte orn);
117 // Free a skeleton, does not unlock it
118 void sk_free_skel(sks_skel *s);
120 // Set this skeleton to use the given color lookup table when rendering
121 // in bitmap limb mode. NULL (default) means no clut
122 void sk_set_bmap_clut(sks_skel *s, ubyte *clut);
124 // Set the quick sorter for this model
125 void sk_set_skel_sort(sks_skel *sk,void (*qsort)(sks_skel *s,ubyte *rl,g3s_phandle *tmp));
127 // Lock down the cylinder bmap objects for a bmap object, ignore otherwise
128 void sk_res_lock(sks_skel *sk,Id resid);
129 void sk_res_unlock(sks_skel *sk,Id resid);
131 // lock down bmap objects, assuming handle IS refid
132 void sk_lock(sks_skel *sk);
133 void sk_unlock(sks_skel *sk);
135 // Render a skeleton given
136 // skeleton and model
137 // assuming all other things have been set,
138 // points transformed, etc.
139 void sk_render_skel(sks_skel *s,ske_sorttype);
141 // phandle of transformed point, pointer to g3s_vector
142 typedef void (*skt_vcall_func)(g3s_phandle p,g3s_vector *v);
144 // Do a callback at the joint in question, passes in
145 // g3s_phandle of point.
146 void sk_set_joint_call(int seg_id,skt_vcall_func v_func,int j);
147 void sk_set_seg_call(int set_id,skt_vcall_func v_func,fix xoff,fix yoff,fix zoff);
149 // Do a vhot set that puts the world coords into sk_vhot_vecs[vhot_num];
150 void sk_set_joint_vhot(int seg_id,int vhot_num,int j);
151 void sk_set_seg_vhot(int set_id,int vhot_num,fix xoff,fix yoff,fix zoff);
152 void sk_vhot_skel(sks_skel *s);
153 extern g3s_vector skd_vhot_vecs[];
154 extern uchar skd_light_detail;
156 // 0 = maximum
157 // 1 = front only
158 #define sk_set_light_detail(x) (skd_light_detail = (x))
159 #define sk_vhot_vec(x) (&skd_vhot_vecs[x])
161 // Provide it the segment info and the endpoints, orientation vector, transformed endpoints, and clut or not
162 void sk_render_bmap_piece(sks_seginfo *cseg,g3s_vector *j1,g3s_vector *j2,g3s_vector *or,g3s_phandle p1,g3s_phandle p2);
163 void sk_render_poly_piece(sks_seginfo *cseg,g3s_vector *j1,g3s_vector *j2,g3s_vector *or);
167 #endif /* __SKEL_H */