zenilib: zenilib/jni/external/lib3ds/src/lib3ds_shadow.c Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lib3ds_shadow.c
Go to the documentation of this file.
1 /*
2 Copyright (C) 1996-2008 by Jan Eric Kyprianidis <www.kyprianidis.com>
3 All rights reserved.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published
7 by the Free Software Foundation, either version 2.1 of the License, or
8 (at your option) any later version.
9
10 Thisprogram is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "lib3ds_impl.h"
19
20
21 void
22 lib3ds_shadow_read(Lib3dsShadow *shadow, Lib3dsIo *io) {
23 Lib3dsChunk c;
24
25 lib3ds_chunk_read(&c, io);
26 switch (c.chunk) {
27 case CHK_SHADOW_MAP_SIZE: {
28 shadow->map_size = lib3ds_io_read_intw(io);
29 break;
30 }
31
32 case CHK_LO_SHADOW_BIAS: {
33 shadow->low_bias = lib3ds_io_read_float(io);
34 break;
35 }
36
37 case CHK_HI_SHADOW_BIAS: {
38 shadow->hi_bias = lib3ds_io_read_float(io);
39 break;
40 }
41
42 case CHK_SHADOW_FILTER: {
43 shadow->filter = lib3ds_io_read_float(io);
44 break;
45 }
46
47 case CHK_RAY_BIAS: {
48 shadow->ray_bias = lib3ds_io_read_float(io);
49 break;
50 }
51 }
52 }
53
54
55 void
56 lib3ds_shadow_write(Lib3dsShadow *shadow, Lib3dsIo *io) {
57 if (fabs(shadow->low_bias) > LIB3DS_EPSILON) { /*---- CHK_LO_SHADOW_BIAS ----*/
58 Lib3dsChunk c;
59 c.chunk = CHK_LO_SHADOW_BIAS;
60 c.size = 10;
61 lib3ds_chunk_write(&c, io);
62 lib3ds_io_write_float(io, shadow->low_bias);
63 }
64
65 if (fabs(shadow->hi_bias) > LIB3DS_EPSILON) { /*---- CHK_HI_SHADOW_BIAS ----*/
66 Lib3dsChunk c;
67 c.chunk = CHK_HI_SHADOW_BIAS;
68 c.size = 10;
69 lib3ds_chunk_write(&c, io);
70 lib3ds_io_write_float(io, shadow->hi_bias);
71 }
72
73 if (shadow->map_size) { /*---- CHK_SHADOW_MAP_SIZE ----*/
74 Lib3dsChunk c;
75 c.chunk = CHK_SHADOW_MAP_SIZE;
76 c.size = 8;
77 lib3ds_chunk_write(&c, io);
78 lib3ds_io_write_intw(io, shadow->map_size);
79 }
80
81 if (fabs(shadow->filter) > LIB3DS_EPSILON) { /*---- CHK_SHADOW_FILTER ----*/
82 Lib3dsChunk c;
83 c.chunk = CHK_SHADOW_FILTER;
84 c.size = 10;
85 lib3ds_chunk_write(&c, io);
86 lib3ds_io_write_float(io, shadow->filter);
87 }
88 if (fabs(shadow->ray_bias) > LIB3DS_EPSILON) { /*---- CHK_RAY_BIAS ----*/
89 Lib3dsChunk c;
90 c.chunk = CHK_RAY_BIAS;
91 c.size = 10;
92 lib3ds_chunk_write(&c, io);
93 lib3ds_io_write_float(io, shadow->ray_bias);
94 }
95 }
96
lib3ds_io_write_intw
void lib3ds_io_write_intw(Lib3dsIo *io, int16_t w)
Definition: lib3ds_io.c:368
lib3ds_io_read_intw
int16_t lib3ds_io_read_intw(Lib3dsIo *io)
Definition: lib3ds_io.c:203
Lib3dsShadow::ray_bias
float ray_bias
Definition: lib3ds.h:108
Lib3dsShadow::map_size
short map_size
Definition: lib3ds.h:104
Lib3dsChunk
Definition: lib3ds_impl.h:295
Lib3dsShadow::filter
float filter
Definition: lib3ds.h:107
CHK_SHADOW_FILTER
Definition: lib3ds_impl.h:92
lib3ds_chunk_read
void lib3ds_chunk_read(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:34
CHK_LO_SHADOW_BIAS
Definition: lib3ds_impl.h:87
Lib3dsChunk::size
uint32_t size
Definition: lib3ds_impl.h:297
lib3ds_shadow_read
void lib3ds_shadow_read(Lib3dsShadow *shadow, Lib3dsIo *io)
Definition: lib3ds_shadow.c:22
Lib3dsShadow::low_bias
float low_bias
Definition: lib3ds.h:105
Lib3dsShadow
Definition: lib3ds.h:103
lib3ds_io_write_float
void lib3ds_io_write_float(Lib3dsIo *io, float l)
Definition: lib3ds_io.c:402
c
const GLfloat * c
Definition: glew.h:14913
CHK_RAY_BIAS
Definition: lib3ds_impl.h:93
lib3ds_io_read_float
float lib3ds_io_read_float(Lib3dsIo *io)
Definition: lib3ds_io.c:237
Lib3dsShadow::hi_bias
float hi_bias
Definition: lib3ds.h:106
LIB3DS_EPSILON
#define LIB3DS_EPSILON
Definition: lib3ds_impl.h:55
Lib3dsIo
Definition: lib3ds.h:56
lib3ds_chunk_write
void lib3ds_chunk_write(Lib3dsChunk *c, Lib3dsIo *io)
Definition: lib3ds_chunk.c:111
lib3ds_shadow_write
void lib3ds_shadow_write(Lib3dsShadow *shadow, Lib3dsIo *io)
Definition: lib3ds_shadow.c:56
Lib3dsChunk::chunk
uint16_t chunk
Definition: lib3ds_impl.h:296
CHK_SHADOW_MAP_SIZE
Definition: lib3ds_impl.h:89
fabs
double fabs(double x)
Definition: s_fabs.c:29
lib3ds_impl.h
CHK_HI_SHADOW_BIAS
Definition: lib3ds_impl.h:88