
! script name: 3drender.d/shadelight
! 3dtopic: change location of light source for shading

!A
!A NAME:
!A
!A 	Light Source
!A
!A DESCRIPTION:
!A
!A 	This script allows the direction of the light source to change.
!A
!B INSTRUCTIONS:
!B
!B 	X,Y,Z POSITION OF LIGHT SOURCE: Enter the X,Y,Z position of the light
!B 		source.
!B
!B 	SPECULAR REFLECTION INDEX (0.0 to 1.0): This factor controls the amount
!B 		of light that bounces off an image. It is one of the factors
!B 		that control the brightness of an image.
!B
!B 	REFLECTIVITY (0.0 to 1.0): This factor controls the direct reflection
!B 		off the image.
!B
!B 	AMBIENT LIGHT (0.0 to 1.0): This controls the uniform light that comes
!B 		from all directions.  This factor gives the areas hidden from
!B 		the light source their brightness.  The smaller the ambient
!B 		light factor, the darker the surface will appear.
!B
!B 	SURFACE TEXTURE (0.0 (no grain) to 10.0 (grainy) ): A nonzero surface
!B 		texture will add a granular appearance to the image.  A typical
!B 		value would be between 2 and 3.
!B

OPTION BASE 1

Stat=ChangeLabelStr("ScriptNameStatus","Function: shade light ")



DIM Destination$[256]
DIM Answer$[256]
DIM Question$(10)[80]
DIM Reply$(10)[80]

DeActivateUndo
Start:!

Tol=NamedVarVal("3D Shade Tol",Ws3DSystemVars,0.06)

lightx=1
lighty=1
lightz=2
specular=0.9
reflectivity=0.95
ambient=0.05
texture=0.00

Question$(1)="X POSITION OF LIGHT SOURCE"
Reply$(1)= VAL$(lightx)
Question$(2)="Y POSITION OF LIGHT SOURCE"
Reply$(2)= VAL$(lighty)
Question$(3)="Z POSITION OF LIGHT SOURCE"
Reply$(3)= VAL$(lightz)
Question$(4)="SPECULAR REFLECTION INDEX (0.0 to 1.0)"
Reply$(4)= VAL$(specular)
Question$(5)="REFLECTIVITY (0.0 to 1.0)"
Reply$(5)= VAL$(reflectivity)
Question$(6)="AMBIENT LIGHT (0.0 to 1.0)"
Reply$(6)= VAL$(ambient)
Question$(7)="SURFACE TEXTURE (0.0 (no grain) to 10.0 (grainy) )"
Reply$(7)= VAL$(texture)


Display_ques:!
Stat=ChangeLabelStr("MultiLineShell","Shading Light Source")
Stat=MultiInput(Question$(*),Reply$(*))
IF (ExitScript(Destination$)) THEN Leave
! IF Stat > 0 then user has cancelled the input
IF Stat>0 THEN Leave

Stat=SetInputFormat("n4","")
Q_count=1
Answer$= Reply$(Q_count)
Stat=  EvaluateAnswer(Answer$,lightx)
Reply$(Q_count)= VAL$(lightx)
IF Stat THEN Input_error
Q_count= Q_count+1

Answer$= Reply$(Q_count)
Stat=  EvaluateAnswer(Answer$,lighty)
Reply$(Q_count)= VAL$(lighty)
IF Stat THEN Input_error
Q_count= Q_count+1

Answer$= Reply$(Q_count)
Stat=  EvaluateAnswer(Answer$,lightz)
Reply$(Q_count)= VAL$(lightz)
IF Stat THEN Input_error
Q_count= Q_count+1

Answer$= Reply$(Q_count)
Stat=  EvaluateAnswer(Answer$,specular)
Reply$(Q_count)= VAL$(specular)
IF Stat THEN Input_error
Q_count= Q_count+1

Answer$= Reply$(Q_count)
Stat=  EvaluateAnswer(Answer$,reflectivity)
Reply$(Q_count)= VAL$(reflectivity)
IF Stat THEN Input_error
Q_count= Q_count+1

Answer$= Reply$(Q_count)
Stat=  EvaluateAnswer(Answer$,ambient)
Reply$(Q_count)= VAL$(ambient)
IF Stat THEN Input_error
Q_count= Q_count+1

Answer$= Reply$(Q_count)
Stat=  EvaluateAnswer(Answer$,texture)
Reply$(Q_count)= VAL$(texture)
IF Stat THEN Input_error
Q_count= Q_count+1


Vnum=1
Stat=Setup3dShade(Vnum,Tol,lightx,lighty,lightz,specular,reflectivity,ambient,texture)

GOTO Leave

Input_error:!
Stat= DisplayMessage("BAD INPUT: "&Question$(Q_count))
GOTO Display_ques


Leave:!
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
