//**************************************************
//	Digit Widgets Spiral Module
// 	Object Spiral Manipulation 
//	Made to be called from Hyperlinked Digit_Widgets Script
//
// Version 3.0 - 09/12/01 - Added Animation Script to Widgets
//	Version 3.1 - 09/15/01 - Updated with Advanced and Standard Animation Scripts
//**************************************************
<zscriptinsert,"Digit_Widgets_Common.txt">
[PD]
[FontSetColor,255,200,0]Spiral Object Functions[FontSetColor,160,160,160]
[PD]
//***************************
//Spiral Manipulation Variables
//***************************
[VarDef,spiralpts,63]
[VarDef,growth,.1]
[VarDef,sangle,0]
[VarDef,anglepts,1]
[VarDef,tmp3,0]
[VarDef,tmp4,0]
[VarDef,tmp5,0]
[VarDef,scurx,0]
[VarDef,scury,0]
[VarDef,scurz,0]
[VarDef,sshift,1]
[VarDef,Markselection,2]
[VarDef,ccntr,1]
[VarDef,cptr,1]
[VarDef,crecurse,0]
[VarDef,resultxs,0]
[VarDef,resultys,0]
[VarDef,resultzs,0]
[VarDef,resultxr,0]
[VarDef,resultyr,0]
[VarDef,resultzr,0]
[iSlider,"Iterations",0,.1,0,200,"Number of Spiral Points ",[VarSet,spiralpts,zscript:Iterations],0,[TextCalcWidth,Distance1453]]
[iSlider,"AnglePlier",1,.1,0,63,"Space between angle increments ",[VarSet,anglepts,zscript:AnglePlier],0,[TextCalcWidth,Distance1453]]
[iSlider,"XYScale",10,.01,.01,100,"Growth Factor ",[VarSet,growth,zscript:XYScale],0,[TextCalcWidth,XYAngle12345]]
[iSlider,"ZSAngle",0,.1,-1000,1000,"Z Angle ",[VarSet,zdangle,zscript:ZSAngle],0,[TextCalcWidth,ZAngle123456]]
[iSlider,"Shift",1,1,1,3,"Shift Axis ",[VarSet,sshift,zscript:Shift],0,[TextCalcWidth,ZAngle123456]]
[iSwitch,"Ztype",0,"Change Z calc"] 
[iSwitch,"SizeDepth",0,"Size to Zdepth"] 
[iSwitch,"SizeRotateMarkers",0,"Size and rotate to Markers"] 
[iSlider,"EndMarker",2,1,1,10,"Select End Marker for size and rotation ",[VarSet,Markselection,zscript:EndMarker],0,[TextCalcWidth,ZAngle123456]]
[iSwitch,"S-Point",0,"Rotate Object to point at NosePoint"] 
[iSwitch,"S-LastPoint",0,"Rotate Object to point at Last Point drawn",
	//there is a problem with the first move in that what is the last move? so I will help this situation by doing this
	[if,[isDisabled,transform:move],
		//if no object is selected then make it the current pointer coords
		[VarSet,kx,curmX]
		[VarSet,ky,curmY]
		[VarSet,kz,curmZ]
	,//else
		//make it the current object coords
		[TransformGet,kx,ky,kz]
	]
] 
[iSwitch,"SpiralFromMark",0,"Center Object at current Mark"] 
[iButton,"A-ShiftAxis","Change RGB Axis for Shifting Color",
	[VarInc,Aptr]
	[if,Aptr=3,[VarSet,Aptr,0]]
	[if,Aptr=0,	[note,"XYZ = RGB",,1]]
	[if,Aptr=1,	[note,"XYZ = GBR",,1]]
	[if,Aptr=2,	[note,"XYZ = BRG",,1]]
		
]
[iSwitch,"S-ShiftColor",0,"Span Color Gradient"] 
[iSwitch,"S-ZColorit",0,"Set Color according to Zdepth"] 
[iButton," Do Sprial ","Draw Object Spiral",

	[if,[iGet,zscript:SpiralFromMark],
		[TransformSet,MarkX(MarkIndex),MarkY(MarkIndex),MarkZ(MarkIndex),MarkXS(MarkIndex),MarkYS(MarkIndex),MarkZS(MarkIndex)]
	]
	// got to get how much time the number of iterations are
	[if,[IGet,zscript:SizeRotateMarkers],
		[VarSet,ccntr,1.0/spiralpts]	
		[VarSet,cptr,1]	
	]

	[TransformGet,scurx,scury,scurz]

	[VarSet,tmp5,0]
	[VarSet,sangle,0]
	[Loop,spiralpts,
		[if,sshift=1,
			[VarSet,XD1,sangle*COS(tmp5)]
			[VarSet,YD1,sangle*SIN(tmp5)]
			[if,[iGet,zscript:Ztype],
				[VarSet,ZD1,zdangle*sangle]
			,//else
				// use rotate around z axis for z
				[VarSet,tmp3,SIN(zdangle)*XD1]
				[VarAdd,tmp4,COS(zdangle)*YD1]
				[VarSet,ZD1,tmp3+tmp4]
			]
		]
		[if,sshift=2,
			[VarSet,ZD1,sangle*COS(tmp5)]
			[VarSet,XD1,sangle*SIN(tmp5)]
			[if,[iGet,zscript:Ztype],
				[VarSet,YD1,zdangle*sangle]
			,//else
				// use rotate around z axis for z
				[VarSet,tmp3,SIN(zdangle)*ZD1]
				[VarAdd,tmp4,COS(zdangle)*XD1]
				[VarSet,YD1,tmp3+tmp4]
			]
		]
		[if,sshift=3,
			[VarSet,YD1,sangle*COS(tmp5)]
			[VarSet,ZD1,sangle*SIN(tmp5)]
			[if,[iGet,zscript:Ztype],
				[VarSet,XD1,zdangle*sangle]
			,//else
				// use rotate around z axis for z
				[VarSet,tmp3,SIN(zdangle)*YD1]
				[VarAdd,tmp4,COS(zdangle)*ZD1]
				[VarSet,XD1,tmp3+tmp4]
			]
		]
		[VarSet,tmp5,tmp5-growth]
		[VarSet,XD1,XD1+scurx]
		[VarSet,YD1,YD1+scury]
		[VarSet,ZD1,ZD1+scurz]
		[TransformSet,XD1,YD1,ZD1]
		[if,[iGet,zscript:SizeDepth],
			[TransformGet,IcurrX,IcurrY,IcurrZ,IcurrXS,IcurrYS,IcurrZS]
			[RoutineCall,DepthCalc]
		]//Endif
		[if,[IGet,zscript:SizeRotateMarkers],
			[VarSet,crecurse,ccntr*cptr]
			[VarSet,resultxs,[Interpolate,crecurse,MarkXS(MarkIndex),MarkXS(Markselection)]]
			[VarSet,resultys,[Interpolate,crecurse,MarkYS(MarkIndex),MarkYS(Markselection)]]
			[VarSet,resultzs,[Interpolate,crecurse,MarkZS(MarkIndex),MarkZS(Markselection)]]
			[VarSet,resultxr,[Interpolate,crecurse,MarkXR(MarkIndex),MarkXR(Markselection)]]
			[VarSet,resultyr,[Interpolate,crecurse,MarkYR(MarkIndex),MarkYR(Markselection)]]
			[VarSet,resultzr,[Interpolate,crecurse,MarkZR(MarkIndex),MarkZR(Markselection)]]
			[TransformSet,,,,resultxs,resultys,resultzs,resultxr,resultyr,resultzr]
			[VarInc,cptr]
		]
		
		[if,[IGet,zscript:S-Point],
			[TransformGet,IcurrX,IcurrY,IcurrZ,IcurrXS,IcurrYS,IcurrZS]
			[routineCall,PointFromTo,ICurrX,ICurrY,ICurrZ,curmX,curmY,curmZ,Xangle,Yangle]
			[transformSet,,,,,,,Xangle,Yangle,CurrZR]
		]
		[if,[IGet,zscript:S-LastPoint],
			[TransformGet,IcurrX,IcurrY,IcurrZ,IcurrXS,IcurrYS,IcurrZS,currxr,curryr,currzr]
			[routineCall,PointFromTo,IcurrX,IcurrY,IcurrZ,kx,ky,kz,Xangle,Yangle]
			[transformSet,,,,,,,Xangle,Yangle,currzr]
			[VarSet,KX,IcurrX]
			[VarSet,KY,IcurrY]
			[VarSet,KZ,IcurrZ]
		]

		[if,[iGet,zscript:S-ShiftColor],
			[TransformGet,IcurrX,IcurrY,IcurrZ]
			[RoutineCall,Shiftcolor,IcurrX,IcurrY,IcurrZ,aptr]
		]
		
		[if,[iGet,zscript:S-ZColorit],
			[TransformGet,IcurrX,IcurrY,IcurrZ]
			[RoutineCall,ZcolorCalc,IcurrX,IcurrY,IcurrZ]
		]

		//snapshot this bugger
		[IPress,Transform:Snapshot]
		[VarSet,sangle,sangle+anglepts]
	]
]

[PD]
[PD]
<zscriptinsert,"Widgets_Index_Include.txt">
[PD]
[PD]
[fontSetSizeSmall]\C00e0e0Digit Widget Spiral Revision 3.3, created by Digits\Cc0c0c0
