7fd59977 |
1 | |
2 | #include <OpenGl_tgl_all.hxx> |
3 | |
4 | #include <stddef.h> |
5 | #include <stdio.h> |
6 | #include <GL/gl.h> |
7 | #include <GL/glu.h> |
8 | |
9 | #include <OpenGl_cmn_varargs.hxx> |
10 | #include <OpenGl_telem_attri.hxx> |
11 | #include <OpenGl_tsm.hxx> |
12 | #include <OpenGl_telem.hxx> |
13 | #include <OpenGl_telem_inquire.hxx> |
14 | #include <OpenGl_Memory.hxx> |
15 | |
16 | static TStatus SurfaceAreaPropertiesDisplay( TSM_ELEM_DATA, Tint, cmn_key* ); |
17 | static TStatus SurfaceAreaPropertiesAdd( TSM_ELEM_DATA, Tint, cmn_key* ); |
18 | static TStatus SurfaceAreaPropertiesDelete( TSM_ELEM_DATA, Tint, cmn_key* ); |
19 | static TStatus SurfaceAreaPropertiesPrint( TSM_ELEM_DATA, Tint, cmn_key* ); |
20 | static TStatus SurfaceAreaPropertiesInquire( TSM_ELEM_DATA, Tint, cmn_key* ); |
21 | |
22 | static TStatus (*MtdTbl[])( TSM_ELEM_DATA, Tint, cmn_key* ) = |
23 | { |
24 | 0, /* PickTraverse */ |
25 | SurfaceAreaPropertiesDisplay, |
26 | SurfaceAreaPropertiesAdd, |
27 | SurfaceAreaPropertiesDelete, |
28 | SurfaceAreaPropertiesPrint, |
29 | SurfaceAreaPropertiesInquire |
30 | }; |
31 | |
32 | |
33 | MtblPtr |
34 | TelSurfaceAreaPropertiesInitClass( TelType *el ) |
35 | { |
36 | *el = TelSurfaceAreaProperties; |
37 | return MtdTbl; |
38 | } |
39 | |
40 | static TStatus |
41 | SurfaceAreaPropertiesAdd( TSM_ELEM_DATA d, Tint n, cmn_key *k ) |
42 | { |
43 | tel_surf_prop data = new TEL_SURF_PROP();; |
44 | |
45 | //cmn_memreserve( data, 1, 0 ); |
46 | if( !data ) |
47 | return TFailure; |
48 | |
49 | *data = *(tel_surf_prop)(k[0]->data.pdata); |
50 | |
51 | ((tsm_elem_data)(d.pdata))->pdata = data; |
52 | |
53 | return TSuccess; |
54 | } |
55 | |
56 | |
57 | static TStatus |
58 | SurfaceAreaPropertiesDisplay( TSM_ELEM_DATA data, Tint n, cmn_key *k ) |
59 | { |
60 | CMN_KEY key; |
61 | |
62 | key.id = TelSurfaceAreaProperties; |
63 | key.data.pdata = data.pdata; |
64 | TsmSetAttri( 1, &key ); |
65 | |
66 | return TSuccess; |
67 | } |
68 | |
69 | |
70 | static TStatus |
71 | SurfaceAreaPropertiesDelete( TSM_ELEM_DATA data, Tint n, cmn_key *k ) |
72 | { |
73 | //cmn_freemem( data.pdata ); |
74 | if (data.pdata) |
75 | delete data.pdata; |
76 | return TSuccess; |
77 | } |
78 | |
79 | |
80 | |
81 | |
82 | static TStatus |
83 | SurfaceAreaPropertiesPrint( TSM_ELEM_DATA data, Tint n, cmn_key *k ) |
84 | { |
85 | tel_surf_prop p; |
86 | |
87 | p = (tel_surf_prop)data.pdata; |
88 | |
89 | fprintf( stdout, "TelSurfaceAreaProperties\n" ); |
90 | fprintf( stdout, "\tAmbient Coeff: %f\n", p->amb ); |
91 | fprintf( stdout, "\tDiffuse Coeff: %f\n", p->diff ); |
92 | fprintf( stdout, "\tSpecular Coeff: %f\n", p->spec ); |
93 | fprintf( stdout, "\tTransparency Coeff: %f\n", p->trans ); |
94 | fprintf( stdout, "\tShininess: %f\n", p->shine ); |
95 | fprintf( stdout, "\tSpecular colour: R = %f, G = %f, B = %f\n", |
96 | p->speccol.rgb[0], p->speccol.rgb[1], p->speccol.rgb[2] ); |
97 | fprintf( stdout, "\n" ); |
98 | |
99 | return TSuccess; |
100 | } |
101 | |
102 | |
103 | static TStatus |
104 | SurfaceAreaPropertiesInquire( TSM_ELEM_DATA data, Tint n, cmn_key *k ) |
105 | { |
106 | Tint i; |
107 | tel_surf_prop p; |
108 | |
109 | p = (tel_surf_prop)data.pdata; |
110 | |
111 | for( i = 0; i < n; i++ ) |
112 | { |
113 | switch( k[i]->id ) |
114 | { |
115 | case INQ_GET_SIZE_ID: |
116 | { |
117 | k[i]->data.ldata = sizeof( Tint ); |
118 | break; |
119 | } |
120 | case INQ_GET_CONTENT_ID: |
121 | { |
122 | TEL_INQ_CONTENT *c; |
123 | Teldata *w; |
124 | |
125 | c = (tel_inq_content)k[i]->data.pdata; |
126 | w = c->data; |
127 | c->act_size = 0; |
128 | w->surf_prop = *p; |
129 | break; |
130 | } |
131 | } |
132 | } |
133 | |
134 | return TSuccess; |
135 | } |