2 * The 3D Studio File Format Library
3 * Copyright (C) 1996-2001 by J.E. Hoffmann <je-h@gmx.net>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or (at
9 * your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 * License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * $Id: shadow.c,v 1.8 2001/07/07 19:05:30 jeh Exp $
23 #include <lib3ds/shadow.h>
24 #include <lib3ds/chunk.h>
25 #include <lib3ds/io.h>
30 * \defgroup shadow Shadow Map Settings
32 * \author J.E. Hoffmann <je-h@gmx.net>
40 lib3ds_shadow_read(Lib3dsShadow *shadow, Lib3dsIo *io)
44 if (!lib3ds_chunk_read(&c, io)) {
49 case LIB3DS_SHADOW_MAP_SIZE:
51 shadow->map_size=lib3ds_io_read_intw(io);
54 case LIB3DS_LO_SHADOW_BIAS:
56 shadow->lo_bias=lib3ds_io_read_float(io);
59 case LIB3DS_HI_SHADOW_BIAS:
61 shadow->hi_bias=lib3ds_io_read_float(io);
64 case LIB3DS_SHADOW_SAMPLES:
66 shadow->samples=lib3ds_io_read_intw(io);
69 case LIB3DS_SHADOW_RANGE:
71 shadow->range=lib3ds_io_read_intd(io);
74 case LIB3DS_SHADOW_FILTER:
76 shadow->filter=lib3ds_io_read_float(io);
81 shadow->ray_bias=lib3ds_io_read_float(io);
94 lib3ds_shadow_write(Lib3dsShadow *shadow, Lib3dsIo *io)
96 if (fabs(shadow->lo_bias)>LIB3DS_EPSILON) { /*---- LIB3DS_LO_SHADOW_BIAS ----*/
98 c.chunk=LIB3DS_LO_SHADOW_BIAS;
100 lib3ds_chunk_write(&c,io);
101 lib3ds_io_write_float(io, shadow->lo_bias);
104 if (fabs(shadow->hi_bias)>LIB3DS_EPSILON) { /*---- LIB3DS_HI_SHADOW_BIAS ----*/
106 c.chunk=LIB3DS_HI_SHADOW_BIAS;
108 lib3ds_chunk_write(&c,io);
109 lib3ds_io_write_float(io, shadow->hi_bias);
112 if (shadow->map_size) { /*---- LIB3DS_SHADOW_MAP_SIZE ----*/
114 c.chunk=LIB3DS_SHADOW_MAP_SIZE;
116 lib3ds_chunk_write(&c,io);
117 lib3ds_io_write_intw(io, shadow->map_size);
120 if (shadow->samples) { /*---- LIB3DS_SHADOW_SAMPLES ----*/
122 c.chunk=LIB3DS_SHADOW_SAMPLES;
124 lib3ds_chunk_write(&c,io);
125 lib3ds_io_write_intw(io, shadow->samples);
128 if (shadow->range) { /*---- LIB3DS_SHADOW_RANGE ----*/
130 c.chunk=LIB3DS_SHADOW_RANGE;
132 lib3ds_chunk_write(&c,io);
133 lib3ds_io_write_intd(io, shadow->range);
136 if (fabs(shadow->filter)>LIB3DS_EPSILON) { /*---- LIB3DS_SHADOW_FILTER ----*/
138 c.chunk=LIB3DS_SHADOW_FILTER;
140 lib3ds_chunk_write(&c,io);
141 lib3ds_io_write_float(io, shadow->filter);
143 if (fabs(shadow->ray_bias)>LIB3DS_EPSILON) { /*---- LIB3DS_RAY_BIAS ----*/
145 c.chunk=LIB3DS_RAY_BIAS;
147 lib3ds_chunk_write(&c,io);
148 lib3ds_io_write_float(io, shadow->ray_bias);
156 \typedef Lib3dsShadow