| 9 |
|
*/ |
| 10 |
|
|
| 11 |
|
#include <stdio.h> |
| 12 |
+ |
#include <math.h> |
| 13 |
|
#include <string.h> |
| 14 |
|
#include "parser.h" |
| 15 |
|
#include "lookup.h" |
| 29 |
|
C_MATERIAL *c_cmaterial = &c_unmaterial; |
| 30 |
|
C_VERTEX *c_cvertex = &c_unvertex; |
| 31 |
|
|
| 32 |
< |
static LUTAB clr_tab; /* color lookup table */ |
| 33 |
< |
static LUTAB mat_tab; /* material lookup table */ |
| 34 |
< |
static LUTAB vtx_tab; /* vertex lookup table */ |
| 32 |
> |
static LUTAB clr_tab = LU_SINIT(free,free); /* color lookup table */ |
| 33 |
> |
static LUTAB mat_tab = LU_SINIT(free,free); /* material lookup table */ |
| 34 |
> |
static LUTAB vtx_tab = LU_SINIT(free,free); /* vertex lookup table */ |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
int |
| 135 |
|
c_cmaterial = (C_MATERIAL *)lp->data; |
| 136 |
|
if (ac == 3) { /* use default template */ |
| 137 |
|
*c_cmaterial = c_dfmaterial; |
| 138 |
+ |
c_cmaterial->name = lp->key; |
| 139 |
|
return(MG_OK); |
| 140 |
|
} |
| 141 |
|
lp = lu_find(&mat_tab, av[3]); /* lookup template */ |
| 144 |
|
if (lp->data == NULL) |
| 145 |
|
return(MG_EUNDEF); |
| 146 |
|
*c_cmaterial = *(C_MATERIAL *)lp->data; |
| 147 |
+ |
c_cmaterial->name = lp->key; |
| 148 |
+ |
c_cmaterial->clock = 1; |
| 149 |
|
if (ac > 4) |
| 150 |
|
return(MG_EARGC); |
| 151 |
|
return(MG_OK); |
| 158 |
|
if (c_cmaterial->rd < 0. | c_cmaterial->rd > 1.) |
| 159 |
|
return(MG_EILL); |
| 160 |
|
c_cmaterial->rd_c = *c_ccolor; |
| 161 |
+ |
c_cmaterial->clock++; |
| 162 |
|
return(MG_OK); |
| 163 |
|
case MG_E_ED: /* set diffuse emittance */ |
| 164 |
|
if (ac != 2) |
| 169 |
|
if (c_cmaterial->ed < 0.) |
| 170 |
|
return(MG_EILL); |
| 171 |
|
c_cmaterial->ed_c = *c_ccolor; |
| 172 |
+ |
c_cmaterial->clock++; |
| 173 |
|
return(MG_OK); |
| 174 |
|
case MG_E_TD: /* set diffuse transmittance */ |
| 175 |
|
if (ac != 2) |
| 192 |
|
c_cmaterial->rs_a < 0.) |
| 193 |
|
return(MG_EILL); |
| 194 |
|
c_cmaterial->rs_c = *c_ccolor; |
| 195 |
+ |
c_cmaterial->clock++; |
| 196 |
|
return(MG_OK); |
| 197 |
|
case MG_E_TS: /* set specular transmittance */ |
| 198 |
|
if (ac != 3) |
| 205 |
|
c_cmaterial->ts_a < 0.) |
| 206 |
|
return(MG_EILL); |
| 207 |
|
c_cmaterial->ts_c = *c_ccolor; |
| 208 |
+ |
c_cmaterial->clock++; |
| 209 |
|
return(MG_OK); |
| 210 |
|
} |
| 211 |
|
return(MG_EUNK); |
| 284 |
|
} |
| 285 |
|
|
| 286 |
|
|
| 279 |
– |
static void |
| 280 |
– |
freectx(lp) /* free a context table entry */ |
| 281 |
– |
register LUENT *lp; |
| 282 |
– |
{ |
| 283 |
– |
free((MEM_PTR)lp->key); |
| 284 |
– |
free((MEM_PTR)lp->data); |
| 285 |
– |
} |
| 286 |
– |
|
| 287 |
– |
|
| 287 |
|
void |
| 288 |
|
c_clearall() /* empty context tables */ |
| 289 |
|
{ |
| 290 |
|
c_uncolor = c_dfcolor; |
| 291 |
|
c_ccolor = &c_uncolor; |
| 292 |
< |
lu_done(&clr_tab, freectx); |
| 292 |
> |
lu_done(&clr_tab); |
| 293 |
|
c_unmaterial = c_dfmaterial; |
| 294 |
|
c_cmaterial = &c_unmaterial; |
| 295 |
< |
lu_done(&mat_tab, freectx); |
| 295 |
> |
lu_done(&mat_tab); |
| 296 |
|
c_unvertex = c_dfvertex; |
| 297 |
|
c_cvertex = &c_unvertex; |
| 298 |
< |
lu_done(&vtx_tab, freectx); |
| 298 |
> |
lu_done(&vtx_tab); |
| 299 |
|
} |
| 300 |
|
|
| 301 |
|
|