MODULE*************************************************************************** Convenience Procedures ***************************************************************************VectorLightGO EXPORTSVectorLightGO ,VectorLightGOProxy ; IMPORT BooleanPropPrivate, Color, ColorPropPrivate, GO, GOPrivate, GraphicsBase, GraphicsBasePrivate, LightGO, Point3, PointProp, PointPropPrivate, Prop; PROCEDURENew (c : Color.T; dir : Point3.T) : T = VAR light := NEW (T).init (); BEGIN LightGO.SetColour (light, c); LightGO.SetSwitch (light, TRUE); SetDirection (light, dir); RETURN light; END New; REVEAL T = Public BRANDED OBJECT OVERRIDES init := Init; draw := Draw; damageIfDependent := DamageIfDependent; END; PROCEDUREInit (self : T) : T = BEGIN EVAL GO.T.init (self); IF MkProxyT # NIL AND self.proxy = NIL THEN MkProxyT (self); END; RETURN self; END Init; PROCEDUREDamageIfDependent (self : T; pn : Prop.Name) = BEGIN IF pn = LightGO.Switch OR pn = LightGO.Colour OR pn = Direction OR pn = GO.Transform THEN self.damaged := TRUE; END; END DamageIfDependent; PROCEDUREDraw (self : T; state : GraphicsBase.T) = BEGIN state.push (self); IF LightGO.Switch.getState (state) THEN state.addVectorLight (LightGO.Colour.getState (state), Direction.getState (state)); END; state.pop (self); END Draw;
PROCEDURESetDirection (o : GO.T; v : Point3.T) = BEGIN o.setProp (Direction.bind (PointProp.NewConst (v))); END SetDirection; BEGIN Direction := NEW (PointProp.Name).init (Point3.T {1.0, 1.0, 1.0}); END VectorLightGO.