ScummVM API documentation
shade.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1999-2000 Revolution Software Ltd.
9  * This code is based on source code created by Revolution Software,
10  * used with permission.
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifndef ICB_SHADE_H
28 #define ICB_SHADE_H
29 
30 #include "engines/icb/gfx/psx_pcdefines.h"
31 #include "engines/icb/gfx/rlp_api.h"
32 
33 namespace ICB {
34 
35 typedef struct FVECTOR {
36  float vx;
37  float vy;
38  float vz;
39 } FVECTOR;
40 
41 // Handy maths function
42 void makePlaneEquation(FVECTOR *v0, FVECTOR *v1, FVECTOR *v2, int32 *d, FVECTOR *pn);
43 
44 void preprocessShadeData(FVECTOR v[3], ShadeTriangle *s);
45 
46 void preprocessShadeData(FVECTOR v[4], ShadeQuad *s);
47 
48 #define DOT_PRODUCT(v0x, v0y, v0z, v1x, v1y, v1z) (((v0x) * (v1x)) + ((v0y) * (v1y)) + ((v0z) * (v1z)))
49 
50 #define CROSS_PRODUCT(v0x, v0y, v0z, v1x, v1y, v1z, v2x, v2y, v2z) \
51  { \
52  v2x = ((v0y) * (v1z)) - ((v0z) * (v1y)); \
53  v2y = ((v0z) * (v1x)) - ((v0x) * (v1z)); \
54  v2z = ((v0x) * (v1y)) - ((v0y) * (v1x)); \
55  }
56 
57 #define VEC_SUB(v0x, v0y, v0z, v1x, v1y, v1z, v2x, v2y, v2z) \
58  { \
59  v2x = v0x - v1x; \
60  v2y = v0y - v1y; \
61  v2z = v0z - v1z; \
62  }
63 
64 #define VEC_ADD(v0x, v0y, v0z, v1x, v1y, v1z, v2x, v2y, v2z) \
65  { \
66  v2x = v0x + v1x; \
67  v2y = v0y + v1y; \
68  v2z = v0z + v1z; \
69  }
70 
71 #define DOT_PRODUCT(v0x, v0y, v0z, v1x, v1y, v1z) (((v0x) * (v1x)) + ((v0y) * (v1y)) + ((v0z) * (v1z)))
72 
73 #define CROSS_PRODUCT(v0x, v0y, v0z, v1x, v1y, v1z, v2x, v2y, v2z) \
74  { \
75  v2x = ((v0y) * (v1z)) - ((v0z) * (v1y)); \
76  v2y = ((v0z) * (v1x)) - ((v0x) * (v1z)); \
77  v2z = ((v0x) * (v1y)) - ((v0y) * (v1x)); \
78  }
79 
80 #define NORMALISE(v0x, v0y, v0z) \
81  { \
82  double r = sqrt(DOT_PRODUCT(v0x, v0y, v0z, v0x, v0y, v0z)); \
83  (v0x) = (float)((v0x) / r); \
84  (v0y) = (float)((v0y) / r); \
85  (v0z) = (float)((v0z) / r); \
86  }
87 
88 #define NORMALISE_VECTOR(v) NORMALISE((v).vx, (v).vy, (v).vz)
89 
90 #define DOT_PRODUCT_VECTOR(v0, v1) DOT_PRODUCT(((v0).vx), ((v0).vy), ((v0).vz), ((v1).vx), ((v1).vy), ((v1).vz))
91 
92 #define CROSS_PRODUCT_VECTOR(v0, v1, v2) CROSS_PRODUCT(((v0).vx), ((v0).vy), ((v0).vz), ((v1).vx), ((v1).vy), ((v1).vz), ((v2).vx), ((v2).vy), ((v2).vz), )
93 
94 #define VEC_ADD_VECTOR(v0, v1, v2) VEC_ADD(((v0).vx), ((v0).vy), ((v0).vz), ((v1).vx), ((v1).vy), ((v1).vz), ((v2).vx), ((v2).vy), ((v2).vz), )
95 
96 #define VEC_SUB_VECTOR(v0, v1, v2) VEC_SUB(((v0).vx), ((v0).vy), ((v0).vz), ((v1).vx), ((v1).vy), ((v1).vz), ((v2).vx), ((v2).vy), ((v2).vz), )
97 
98 #define DOT_PRODUCT_SVECTOR(v0, v1) (DOT_PRODUCT((v0.vx), (v0.vy), (v0.vz), (v1.vx), (v1.vy), (v1.vz)))
99 
100 } // End of namespace ICB
101 
102 #endif // #ifndef SHADE_H
Definition: actor.h:32
Definition: rlp_api.h:136
Definition: shade.h:35
Definition: rlp_api.h:152