2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
6 // $Header: r:/t2repos/thief2/src/render/slitprop.cpp,v 1.15 1999/03/04 17:30:37 XEMU Exp $
22 // Must be last header
26 ////////////////////////////////////////////////////////////
27 // SELF-ILLUMINATION PROP API
31 ////////////////////////////////////////////////////////////
32 // SELF-ILLUMINATION PROPERTY CREATION
35 static IIntProperty
* gSelfLitProp
= NULL
;
37 static sPropertyDesc selflitprop_desc
=
40 kPropertyNoInherit
|kPropertyInstantiate
,
42 { "Renderer", "Dynamic Light" },
45 void SelfLitPropInit(void)
47 gSelfLitProp
= CreateIntProperty(&selflitprop_desc
, kPropertyImplDense
);
51 BOOL
ObjGetSelfLit(ObjID obj
, int *psl
)
55 BOOL retval
= gSelfLitProp
->Get(obj
,psl
);
61 BOOL
ObjSetSelfLit(ObjID obj
, int sl
)
66 gSelfLitProp
->Set(obj
,sl
);
74 // Update all self-lit objects
77 extern "C" BOOL g_lgd3d
;
79 void SelfLitUpdateAll(void)
84 IIntProperty
* prop
= gSelfLitProp
;
85 sPropertyObjIter iter
;
89 prop
->IterStart(&iter
);
90 while(prop
->IterNextValue(&iter
,&obj
,&light
))
91 if (OBJ_IS_CONCRETE(obj
) && ObjHasRefs(obj
))
93 ObjPos
* pos
= ObjPosGet(obj
);
94 // @HACK for EEE: larger radius in hardware
99 ObjColorGet(obj
, &hue
, &saturation
);
100 portal_convert_hsb_to_rgb(&r
,&g
,&b
,hue
,saturation
);
101 portal_set_normalized_color(r
,g
,b
);
104 add_dynamic_light(&pos
->loc
, light
, g_lgd3d
? 10.0 : 4.0);
106 prop
->IterStop(&iter
);
110 static IIntProperty
* g_pShadowProp
= NULL
;
112 static sPropertyDesc shadow_prop_desc
=
115 kPropertyNoInherit
|kPropertyInstantiate
,
117 { "Renderer", "Shadow" },
120 void ShadowPropInit(void)
122 g_pShadowProp
= CreateIntProperty(&shadow_prop_desc
,
127 BOOL
ObjGetShadow(ObjID obj
, int *s
)
130 BOOL retval
= g_pShadowProp
->Get(obj
, s
);
136 BOOL
ObjSetShadow(ObjID obj
, int s
)
140 g_pShadowProp
->Set(obj
, s
);
148 // Update all objects with shadows
151 // Up to this distance from the object's center, the shadow is
153 #define kShadowCutoff 6.0
154 // If the floor is further than this, there's no shadow.
155 #define kShadowMaxDist 15.0
157 void ShadowUpdateAll(void)
162 IIntProperty
* prop
= g_pShadowProp
;
163 sPropertyObjIter iter
;
169 Location EndLoc
, HitLoc
;
171 prop
->IterStart(&iter
);
172 while(prop
->IterNextValue(&iter
, &obj
, &iLevel
))
173 if (OBJ_IS_CONCRETE(obj
) && ObjHasRefs(obj
)) {
175 pos
= ObjPosGet(obj
);
178 EndLoc
.vec
.z
-= kShadowMaxDist
;
180 if (!PortalRaycast(&pos
->loc
, &EndLoc
, &HitLoc
, 0)) {
181 fZDiff
= pos
->loc
.vec
.z
- HitLoc
.vec
.z
;
182 if (fZDiff
> kShadowCutoff
)
183 fIntensity
*= (kShadowMaxDist
- fZDiff
)
184 / (kShadowMaxDist
- kShadowCutoff
);
187 portal_add_simple_dynamic_dark(fIntensity
, fIntensity
,
191 prop
->IterStop(&iter
);