
! script name: 3drender.d/setreflectprop
! 3dtopic: assign surface reflection properties

!A
!A NAME:
!A
!A 	Surface Reflection Properties
!A
!A DESCRIPTION:
!A
!A 	This script allows reflectivity properties to be assigned to surfaces.
!A
!B INSTRUCTIONS:
!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

Stat=ChangeLabelStr("ScriptNameStatus","Function: reflection properties ")

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

DeActivateUndo
specular=0.9
reflectivity=0.95
ambient=0.05
texture=0.00
emission=0.00

Start:!

Question$(1)="SPECULAR REFLECTION INDEX (0.0 to 1.0)"
Reply$(1)= VAL$(specular)
Question$(2)="REFLECTIVITY (0.0 to 1.0)"
Reply$(2)= VAL$(reflectivity)
Question$(3)="AMBIENT LIGHT (0.0 to 1.0)"
Reply$(3)= VAL$(ambient)
Question$(4)="SURFACE TEXTURE (0.0 (no grain) to 10.0 (grainy) )"
Reply$(4)= VAL$(texture)

Stat= DisplayMessage(" ")

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$,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


Pick_surface:Stat=SetPickMask(WsPickSurfOnly)
Stat=SetPickMask(WsPickSurfOnly)
Stat=SetInputFormat("n4a1",",N,")
Surface=PickEntity("PICK SURFACE, New values ",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "N" THEN Start
IF NOT ValidGeometry(Surface) THEN Pick_surface
Stat=SetPickMask(WsPickGeometry)

Stat= SetSurfaceProp(Surface,reflectivity,specular,ambient,emission,texture)

GOTO Pick_surface

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

Leave:!
Stat=SetPickMask(WsPickGeometry)
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
