-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path3dLight.c
74 lines (69 loc) · 2.21 KB
/
3dLight.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*****************************************************************************
* File: 3dLtSource.c
*
* Purpose: Generates an octahedron as a representation of a light source.
*
* © 1989 Mark M. Owen. All rights reserved.
*****************************************************************************
*/
#include "3dHier.h"
#include "3dLight.h"
#include "3dExtern.h"
#include "3dQuad.h"
#include "3dFMath.h"
/*****************************************************************************
*
* Function: NewLightSourcePatch(É)
*
* Purpose: Generates a solid unit (size 1) octahedron as a specified
* group/patch which serves as a representation of a light
* source, via a call to SolidUnitSphere. An instance matrix
* is attached which locates the object at the light source's
* coordinates, and scales the object by a factor equal to its
* intensity level.
*
* Returns: SolidUnitSphere result
*
*****************************************************************************
*/
int
#if XVT_CC_PROTO
NewLightSourcePatch(pGroup pG,int ixP,pLtSource pLS)
#else
NewLightSourcePatch(pG, ixP, pLS)
pGroup pG;
int ixP;
pLtSource pLS;
#endif
{
RendAttr RA;
Matrix3D xf;
RA.R = XVT_COLOR_GET_RED(pLS->color);
RA.G = XVT_COLOR_GET_GREEN(pLS->color);
RA.B = XVT_COLOR_GET_BLUE(pLS->color);
RA.diffusion = 130;
RA.specIndex = 0;
RA.frameColor = XVT_MAKE_COLOR(RA.R, RA.G, RA.B);
RA.lightSource = TRUE;
RA.distanceEffect = TRUE;
RA.ambientEffect = TRUE;
RA.normalVisibility = TRUE;
RA.framed = FALSE;
RA.patterned = FALSE;
RA.grayScaled = FALSE;
RA.specularity = 0; /* specular reflection coefficient */
RA.ambience = 0; /* ambient reflection coefficient */
RA.absorption = 0; /* reserved for expansion */
RA.translucence = 0; /* reserved for expansion */
RA.refraction = 0; /* reserved for expansion */
RA.transparency = 0; /* transparency coefficient ( 0 = opaque ) */
RA.texture = TX_NONE; /* texture type code */
xf = Identity;
xf.v[0][0] =
xf.v[1][1] =
xf.v[2][2] = pLS->level;
xf.v[3][0] = pLS->location.x;
xf.v[3][1] = pLS->location.y;
xf.v[3][2] = pLS->location.z;
return SolidUnitSphere( Int2Fix(6), pG, ixP, RA, &xf );
}