//***************************************************
// A Digit's Widget - Zbrush Zscript
// Animation Widget
// 3D Animation Functions
// Version 3.1 - 09/12/01 * Fixed Frame Problem and added automatic filename for Export Frame Function
//***************************************************
<zscriptinsert,"Digit_Widgets_Common_Std.txt">
[VarDef,ptr,0]
[VarDef,doSave,0]
[VarDef,Look,0]
//object data
[VarDef,type(10)]
[VarDef,Active(10)]
[VarDef,mat(10)]
[VarDef,mode(10)]
[VarDef,px(10)]
[VarDef,py(10)]
[VarDef,pz(10)]
[VarDef,pxs(10)]
[VarDef,pys(10)]
[VarDef,pzs(10)]
[VarDef,pxr(10)]
[VarDef,pyr(10)]
[VarDef,pzr(10)]
[VarDef,epx(10)]
[VarDef,epy(10)]
[VarDef,epz(10)]
[VarDef,epxs(10)]
[VarDef,epys(10)]
[VarDef,epzs(10)]
[VarDef,epxr(10)]
[VarDef,epyr(10)]
[VarDef,epzr(10)]
[VarDef,pr(10)]
[VarDef,pg(10)]
[VarDef,pb(10)]
[VarDef,timeincr,0]
[VarDef,crecurse,0]
[VarDef,RepeatCount,10]
[VarDef,resultx,0]
[VarDef,resulty,0]
[VarDef,resultz,0]
[VarDef,resultxs,0]
[VarDef,resultys,0]
[VarDef,resultzs,0]
[VarDef,resultxr,0]
[VarDef,resultyr,0]
[VarDef,resultzr,0]
[VarDef,which,0]
[VarDef,Frame,0]
[VarDef,Pick,-1]
[VarDef,swaptmp,0]
//***************************
//Curve Point
//***************************
[VarDef,pointX(5)]
[VarDef,pointY(5)]
[VarDef,pointZ(5)]
[VarDef,pointXS(5)]
[VarDef,pointYS(5)]
[VarDef,pointZS(5)]
[VarDef,pointXR(5)]
[VarDef,pointYR(5)]
[VarDef,pointZR(5)]
[PD]
[FontSetColor,255,200,0]Animation Functions[FontSetColor,160,160,160]
[PD]

[ISlider,"Max Number of Frames ",10,1,1,360,"Number of Frames",
	[VarSet,RepeatCount,ZScript:MaxNumberofFrames]
	[ISetMax,zscript:SelectFrame,RepeatCount]
,0,[TextCalcWidth,SelectMark12322222233333333333333]]

[ISwitch,"Best Render",0,"Select Best Render"]
[PD]
[PaintPageBreak]
[PD]
[PD]
[FontSetColor,255,200,0]**************** Object 1 ****************[FontSetColor,160,160,160]
[PD]
[ISwitch,"Sel_1",0,"Select"]
[iSwitch,"Curve_1",0,"1 Point Spline Interpolate",
	[VarSet,ptr,0]
	[ISetStatus,zscript:LoadPoint_1,1]
	[IEnable,zscript:Move_1]
	[VarSet,mode(ptr),1]
]
[iButton," LoadPoint_1 ","Load Current Object Position to use as Spline Point in Curve",
	[VarSet,ptr,0]
	[TransformGet,pointX(ptr),pointY(ptr),pointZ(ptr),pointXS(ptr),pointYS(ptr),pointZS(ptr),pointXR(ptr),pointYR(ptr),pointZR(ptr)]
,1
]//End Load Point 1

[iButton," Move_1 ","Load Current Object Position to LoadPoint_1",
	[VarSet,ptr,0]
	[TransformSet,pointX(ptr),pointY(ptr),pointZ(ptr),pointXS(ptr),pointYS(ptr),pointZS(ptr),pointXR(ptr),pointYR(ptr),pointZR(ptr)]
,1
]

[iButton," GetStart1","Get Starting Parameters",
	[note,"getting info",,1]
	[VarSet,ptr,0]
	[VarSet,which,0]
	[if,[IGet,zscript:Curve_1],
		[VarSet,mode(ptr),1]
	,//else
		[VarSet,mode(ptr),0]
		[ISetStatus,zscript:LoadPoint_1,0]
		[IDisable,zscript:Move_1]
	]
	[RoutineCall,GetObjData,ptr,which]
	[if,[Iget,zscript:Sel_1],
		[varset,swaptmp,0],
		[IToggle,zscript:Sel_1]
	]
]
[iButton," GetEnd1","Get Ending Parameters",
	[note,"getting info",,1]
	[VarSet,ptr,0]
	[VarSet,which,1]
	[if,[IGet,zscript:Curve_1],
		[VarSet,mode(ptr),1]
	,//else
		[VarSet,mode(ptr),0]
		[ISetStatus,zscript:LoadPoint_1,0]
		[IDisable,zscript:Move_1]
	]
	[RoutineCall,GetObjData,ptr,which]
	[if,[Iget,zscript:Sel_1],
		[varset,swaptmp,0],
		[IToggle,zscript:Sel_1]
	]
]
[iButton," Recall Start_1","doodah",
	[VarSet,ptr,0]
	[if,[IGet,zscript:Sel_1],
		//If you don't have an object selected pull the recorded object
		// This allows you to select another object and set it to this objects place
		[if,[IGet,Transform:DrawPointer] > 0,
			[ISet,Tool:ItemInfo,type(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
			[IPress,Transform:Move]
			[ISet,Material:ItemInfo,mat(ptr)]
			[IColorSet,pr(ptr),pg(ptr),pb(ptr)]
		]
		[TransformSet,px(ptr),py(ptr),pz(ptr),pxs(ptr),pys(ptr),pzs(ptr),pxr(ptr),pyr(ptr),pzr(ptr)]
	]
]
[iButton," Recall End_1","doodah",
	[VarSet,ptr,0]
	[if,[IGet,zscript:Sel_1],
		//If you don't have an object selected pull the recorded object
		[if,[IGet,Transform:DrawPointer] > 0,
			[ISet,Tool:ItemInfo,type(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
			[IPress,Transform:Move]
			[ISet,Material:ItemInfo,mat(ptr)]
			[IColorSet,pr(ptr),pg(ptr),pb(ptr)]
		]
		[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
		[TransformSet,epx(ptr),epy(ptr),epz(ptr),epxs(ptr),epys(ptr),epzs(ptr),epxr(ptr),epyr(ptr),epzr(ptr)]
	]
]
[iButton," Swap_1","Swap Start and End",
	[note,"Swapping.....",,1]
	[VarSet,ptr,0]
	[VarSet,Swaptmp,px(ptr)]
	[VarSet,px(ptr),epx(ptr)]
	[VarSet,epx(ptr),Swaptmp]

	[VarSet,Swaptmp,py(ptr)]
	[VarSet,py(ptr),epy(ptr)]
	[VarSet,epy(ptr),Swaptmp]

	[VarSet,Swaptmp,pz(ptr)]
	[VarSet,pz(ptr),epz(ptr)]
	[VarSet,epz(ptr),Swaptmp]
]
[PD]
[PaintPageBreak]
[PD]
[PD]
[FontSetColor,255,200,0]**************** Object 2 ****************[FontSetColor,160,160,160]
[PD]
[ISwitch,"Sel_2",0,"Select"]
[iSwitch,"Curve_2",0,"1 Point Spline Interpolate",
	[VarSet,ptr,1]
	[ISetStatus,zscript:LoadPoint_2,1]
	[IEnable,zscript:Move_2]
	[VarSet,mode(ptr),1]
]
[iButton," LoadPoint_2 ","Load Current Object Position to use as Spline Point in Curve",
	[VarSet,ptr,1]
	[TransformGet,pointX(ptr),pointY(ptr),pointZ(ptr),pointXS(ptr),pointYS(ptr),pointZS(ptr),pointXR(ptr),pointYR(ptr),pointZR(ptr)]
,1
]//End Load Point 2

[iButton," Move_2 ","Load Current Object Position to LoadPoint_1",
	[VarSet,ptr,1]
	[TransformSet,pointX(ptr),pointY(ptr),pointZ(ptr),pointXS(ptr),pointYS(ptr),pointZS(ptr),pointXR(ptr),pointYR(ptr),pointZR(ptr)]
,1
]
[iButton," GetStart2","Get Starting Parameters",
	[note,"getting info",,1]
	[VarSet,ptr,1]
	[VarSet,which,0]
	[if,[IGet,zscript:Curve_2],
		[VarSet,mode(ptr),1]
	,//else
		[VarSet,mode(ptr),0]
		[ISetStatus,zscript:LoadPoint_2,0]
		[IDisable,zscript:Move_2]
	]
	[RoutineCall,GetObjData,ptr,which]
	[if,[Iget,zscript:Sel_2],
		[varset,swaptmp,0],
		[IToggle,zscript:Sel_2]
	]
]
[iButton," GetEnd2","Get Ending Parameters",
	[note,"getting info",,1]
	[VarSet,ptr,1]
	[VarSet,which,1]
	[if,[IGet,zscript:Curve_2],
		[VarSet,mode(ptr),1]
	,//else
		[VarSet,mode(ptr),0]
		[ISetStatus,zscript:LoadPoint_2,0]
		[IDisable,zscript:Move_2]
	]
	[RoutineCall,GetObjData,ptr,which]
	[if,[Iget,zscript:Sel_2],
		[varset,swaptmp,0],
		[IToggle,zscript:Sel_2]
	]
]
[iButton," Recall Start_2","doodah",
	[VarSet,ptr,1]
	[if,[IGet,zscript:Sel_2],
		[if,[IGet,Transform:DrawPointer] > 0,
			[ISet,Tool:ItemInfo,type(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
			[IPress,Transform:Move]
			[ISet,Material:ItemInfo,mat(ptr)]
			[IColorSet,pr(ptr),pg(ptr),pb(ptr)]
		]
		[TransformSet,px(ptr),py(ptr),pz(ptr),pxs(ptr),pys(ptr),pzs(ptr),pxr(ptr),pyr(ptr),pzr(ptr)]
	]
]
[iButton," Recall End_2","doodah",
	[VarSet,ptr,1]
	[if,[IGet,zscript:Sel_2],
		[if,[IGet,Transform:DrawPointer] > 0,
			[ISet,Tool:ItemInfo,type(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
			[IPress,Transform:Move]
			[ISet,Material:ItemInfo,mat(ptr)]
			[IColorSet,pr(ptr),pg(ptr),pb(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
		]
		[TransformSet,epx(ptr),epy(ptr),epz(ptr),epxs(ptr),epys(ptr),epzs(ptr),epxr(ptr),epyr(ptr),epzr(ptr)]
	]
]
[iButton," Swap_2","Swap Start and End",
	[note,"Swapping.....",,1]
	[VarSet,ptr,1]
	[VarSet,Swaptmp,px(ptr)]
	[VarSet,px(ptr),epx(ptr)]
	[VarSet,epx(ptr),Swaptmp]

	[VarSet,Swaptmp,py(ptr)]
	[VarSet,py(ptr),epy(ptr)]
	[VarSet,epy(ptr),Swaptmp]

	[VarSet,Swaptmp,pz(ptr)]
	[VarSet,pz(ptr),epz(ptr)]
	[VarSet,epz(ptr),Swaptmp]
]
[PD]
[PaintPageBreak]
[PD]
[PD]
[FontSetColor,255,200,0]**************** Object 3 ****************[FontSetColor,160,160,160]
[PD]
[ISwitch,"Sel_3",0,"Select"]
[iSwitch,"Curve_3",0,"1 Point Spline Interpolate",
	[Varset,ptr,2]
	[ISetStatus,zscript:LoadPoint_3,1]
	[IEnable,zscript:Move_3]
	[VarSet,mode(ptr),1]
]
[iButton," LoadPoint_3 ","Load Current Object Position to use as Spline Point in Curve",
	[VarSet,ptr,2]
	[TransformGet,pointX(ptr),pointY(ptr),pointZ(ptr),pointXS(ptr),pointYS(ptr),pointZS(ptr),pointXR(ptr),pointYR(ptr),pointZR(ptr)]
,1
]//End Load Point 3

[iButton," Move_3 ","Load Current Object Position to LoadPoint_1",
	[VarSet,ptr,2]
	[TransformSet,pointX(ptr),pointY(ptr),pointZ(ptr),pointXS(ptr),pointYS(ptr),pointZS(ptr),pointXR(ptr),pointYR(ptr),pointZR(ptr)]
,1
]
[iButton," GetStart3","Get Starting Parameters",
	[note,"getting info",,1]
	[VarSet,ptr,2]
	[VarSet,which,0]
	[if,[IGet,zscript:Curve_3],
		[VarSet,mode(ptr),1]
	,//else
		[VarSet,mode(ptr),0]
		[ISetStatus,zscript:LoadPoint_3,0]
		[IDisable,zscript:Move_3]
	]
	[RoutineCall,GetObjData,ptr,which]
	[if,[Iget,zscript:Sel_3],
		[varset,swaptmp,0],
		[IToggle,zscript:Sel_3]
	]
]
[iButton," GetEnd3","Get Ending Parameters",
	[note,"getting info",,1]
	[VarSet,ptr,2]
	[VarSet,which,1]
	[RoutineCall,GetObjData,ptr,which]
	[if,[IGet,zscript:Curve_3],
		[VarSet,mode(ptr),1]
	,//else
		[VarSet,mode(ptr),0]
		[ISetStatus,zscript:LoadPoint_3,0]
		[IDisable,zscript:Move_3]
	]
	[if,[Iget,zscript:Sel_3],
		[varset,swaptmp,0],
		[IToggle,zscript:Sel_3]
	]
]
[iButton," Recall Start_3","doodah",
	[VarSet,ptr,2]
	[if,[IGet,zscript:Sel_3],
		[if,[IGet,Transform:DrawPointer] > 0,
			[ISet,Tool:ItemInfo,type(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
			[IPress,Transform:Move]
			[ISet,Material:ItemInfo,mat(ptr)]
			[IColorSet,pr(ptr),pg(ptr),pb(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
		]
		[TransformSet,px(ptr),py(ptr),pz(ptr),pxs(ptr),pys(ptr),pzs(ptr),pxr(ptr),pyr(ptr),pzr(ptr)]
	]
]
[iButton," Recall End_3","doodah",
	[VarSet,ptr,2]
	[if,[IGet,zscript:Sel_3],
		[if,[IGet,Transform:DrawPointer] > 0,
			[ISet,Tool:ItemInfo,type(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
			[IPress,Transform:Move]
			[ISet,Material:ItemInfo,mat(ptr)]
			[IColorSet,pr(ptr),pg(ptr),pb(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
		]
		[TransformSet,epx(ptr),epy(ptr),epz(ptr),epxs(ptr),epys(ptr),epzs(ptr),epxr(ptr),epyr(ptr),epzr(ptr)]
	]
]
[iButton," Swap_3","Swap Start and End",
	[note,"Swapping.....",,1]
	[VarSet,ptr,2]
	[VarSet,Swaptmp,px(ptr)]
	[VarSet,px(ptr),epx(ptr)]
	[VarSet,epx(ptr),Swaptmp]

	[VarSet,Swaptmp,py(ptr)]
	[VarSet,py(ptr),epy(ptr)]
	[VarSet,epy(ptr),Swaptmp]

	[VarSet,Swaptmp,pz(ptr)]
	[VarSet,pz(ptr),epz(ptr)]
	[VarSet,epz(ptr),Swaptmp]
]
[PD]
[PaintPageBreak]
[PD]
[PD]
[FontSetColor,255,200,0]**************** Object 4 ****************[FontSetColor,160,160,160]
[PD]
[ISwitch,"Sel_4",0,"Select"]
[iSwitch,"Curve_4",0,"1 Point Spline Interpolate",
	[VarSet,ptr,3]
	[ISetStatus,zscript:LoadPoint_4,1]
	[IEnable,zscript:Move_4]
	[VarSet,mode(ptr),1]
]
[iButton," LoadPoint_4 ","Load Current Object Position to use as Spline Point in Curve",
	[VarSet,ptr,3]
	[TransformGet,pointX(ptr),pointY(ptr),pointZ(ptr),pointXS(ptr),pointYS(ptr),pointZS(ptr),pointXR(ptr),pointYR(ptr),pointZR(ptr)]
,1
]//End Load Point 4

[iButton," Move_4 ","Load Current Object Position to LoadPoint_4",
	[VarSet,ptr,3]
	[TransformSet,pointX(ptr),pointY(ptr),pointZ(ptr),pointXS(ptr),pointYS(ptr),pointZS(ptr),pointXR(ptr),pointYR(ptr),pointZR(ptr)]
,1
]
[iButton," GetStart4","Get Starting Parameters",
	[note,"getting info",,1]
	[VarSet,ptr,3]
	[VarSet,which,0]
	[if,[IGet,zscript:Curve_4],
		[VarSet,mode(ptr),1]
	,//else
		[VarSet,mode(ptr),0]
		[ISetStatus,zscript:LoadPoint_4,0]
		[IDisable,zscript:Move_4]
	]
	[RoutineCall,GetObjData,ptr,which]
	[if,[Iget,zscript:Sel_4],
		[varset,swaptmp,0],
		[IToggle,zscript:Sel_4]
	]
]
[iButton," GetEnd4","Get Ending Parameters",
	[note,"getting info",,1]
	[VarSet,ptr,3]
	[VarSet,which,1]
	[if,[IGet,zscript:Curve_4],
		[VarSet,mode(ptr),1]
	,//else
		[VarSet,mode(ptr),0]
		[ISetStatus,zscript:LoadPoint_4,0]
		[IDisable,zscript:Move_4]
	]
	[RoutineCall,GetObjData,ptr,which]
	[if,[Iget,zscript:Sel_4],
		[varset,swaptmp,0],
		[IToggle,zscript:Sel_4]
	]
]
[iButton," Recall Start_4","doodah",
	[VarSet,ptr,3]
	[if,[IGet,zscript:Sel_4],
		[if,[IGet,Transform:DrawPointer] > 0,
			[ISet,Tool:ItemInfo,type(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
			[IPress,Transform:Move]
			[ISet,Material:ItemInfo,mat(ptr)]
			[IColorSet,pr(ptr),pg(ptr),pb(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
		]
		[TransformSet,px(ptr),py(ptr),pz(ptr),pxs(ptr),pys(ptr),pzs(ptr),pxr(ptr),pyr(ptr),pzr(ptr)]
	]
]
[iButton," Recall End_4","doodah",
	[VarSet,ptr,3]
	[if,[IGet,zscript:Sel_4],
		[if,[IGet,Transform:DrawPointer] > 0,
			[ISet,Tool:ItemInfo,type(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
			[IPress,Transform:Move]
			[ISet,Material:ItemInfo,mat(ptr)]
			[IColorSet,pr(ptr),pg(ptr),pb(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
		]
		[TransformSet,epx(ptr),epy(ptr),epz(ptr),epxs(ptr),epys(ptr),epzs(ptr),epxr(ptr),epyr(ptr),epzr(ptr)]
	]
]
[iButton," Swap_4","Swap Start and End",
	[note,"Swapping.....",,1]
	[VarSet,ptr,3]
	[VarSet,Swaptmp,px(ptr)]
	[VarSet,px(ptr),epx(ptr)]
	[VarSet,epx(ptr),Swaptmp]

	[VarSet,Swaptmp,py(ptr)]
	[VarSet,py(ptr),epy(ptr)]
	[VarSet,epy(ptr),Swaptmp]

	[VarSet,Swaptmp,pz(ptr)]
	[VarSet,pz(ptr),epz(ptr)]
	[VarSet,epz(ptr),Swaptmp]
]

[PD]
[PaintPageBreak]
[PD]
[PD]
[FontSetColor,255,200,0]**************** Object 5 ****************[FontSetColor,160,160,160]
[PD]
[ISwitch,"Sel_5",0,"Select"]
[iSwitch,"Curve_5",0,"1 Point Spline Interpolate",
	[VarSet,ptr,4]
	[ISetStatus,zscript:LoadPoint_5,1]
	[IEnable,zscript:Move_5]
	[VarSet,mode(ptr),1]
]
[iButton," LoadPoint_5 ","Load Current Object Position to use as Spline Point in Curve",
	[VarSet,ptr,4]
	[TransformGet,pointX(ptr),pointY(ptr),pointZ(ptr),pointXS(ptr),pointYS(ptr),pointZS(ptr),pointXR(ptr),pointYR(ptr),pointZR(ptr)]
,1
]//End Load Point 5

[iButton," Move_5 ","Load Current Object Position to LoadPoint_5",
	[VarSet,ptr,4]
	[TransformSet,pointX(ptr),pointY(ptr),pointZ(ptr),pointXS(ptr),pointYS(ptr),pointZS(ptr),pointXR(ptr),pointYR(ptr),pointZR(ptr)]
,1
]
[iButton," GetStart5","Get Starting Parameters",
	[note,"getting info",,1]
	[VarSet,ptr,4]
	[VarSet,which,0]
	[if,[IGet,zscript:Curve_5],
		[VarSet,mode(ptr),1]
	,//else
		[VarSet,mode(ptr),0]
		[ISetStatus,zscript:LoadPoint_5,0]
		[IDisable,zscript:Move_5]
	]
	[RoutineCall,GetObjData,ptr,which]
	[if,[Iget,zscript:Sel_5],
		[varset,swaptmp,0],
		[IToggle,zscript:Sel_5]
	]
]
[iButton," GetEnd5","Get Ending Parameters",
	[note,"getting info",,1]
	[VarSet,ptr,4]
	[VarSet,which,1]
	[if,[IGet,zscript:Curve_5],
		[VarSet,mode(ptr),1]
	,//else
		[VarSet,mode(ptr),0]
		[ISetStatus,zscript:LoadPoint_5,0]
		[IDisable,zscript:Move_5]
	]
	[RoutineCall,GetObjData,ptr,which]
	[if,[Iget,zscript:Sel_5],
		[varset,swaptmp,0],
		[IToggle,zscript:Sel_5]
	]
]
[iButton," Recall Start_5","doodah",
	[VarSet,ptr,4]
	[if,[IGet,zscript:Sel_5],
		[if,[IGet,Transform:DrawPointer] > 0,
			[ISet,Tool:ItemInfo,type(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
			[IPress,Transform:Move]
			[ISet,Material:ItemInfo,mat(ptr)]
			[IColorSet,pr(ptr),pg(ptr),pb(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
		]
		[TransformSet,px(ptr),py(ptr),pz(ptr),pxs(ptr),pys(ptr),pzs(ptr),pxr(ptr),pyr(ptr),pzr(ptr)]
	]
]
[iButton," Recall End_5","doodah",
	[VarSet,ptr,4]
	[if,[IGet,zscript:Sel_5],
		[if,[IGet,Transform:DrawPointer] > 0,
			[ISet,Tool:ItemInfo,type(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
			[IPress,Transform:Move]
			[ISet,Material:ItemInfo,mat(ptr)]
			[IColorSet,pr(ptr),pg(ptr),pb(ptr)]
			[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
		]
		[TransformSet,epx(ptr),epy(ptr),epz(ptr),epxs(ptr),epys(ptr),epzs(ptr),epxr(ptr),epyr(ptr),epzr(ptr)]
	]
]
[iButton," Swap_5","Swap Start and End",
	[note,"Swapping.....",,1]
	[VarSet,ptr,4]
	[VarSet,Swaptmp,px(ptr)]
	[VarSet,px(ptr),epx(ptr)]
	[VarSet,epx(ptr),Swaptmp]

	[VarSet,Swaptmp,py(ptr)]
	[VarSet,py(ptr),epy(ptr)]
	[VarSet,epy(ptr),Swaptmp]

	[VarSet,Swaptmp,pz(ptr)]
	[VarSet,pz(ptr),epz(ptr)]
	[VarSet,epz(ptr),Swaptmp]
]
[PaintPageBreak]
[FontSetColor,255,200,0]**************** Render and Export ****************[FontSetColor,160,160,160]
[PD]
[IButton,"  Preview without saving  ","Preview",
	//clear area make sure current object isn't active
	[IPress,Transform:DrawPointer]
	[ipress,Layer:Modifiers:Clear]
	[VarSet,ptr,0]
	[RoutineCall,ReadSwitches]
	[VarSet,Look,0]
	[VarSet,doSave,0]
	[VarSet,Frame,0]
	[VarSet,Pick,-1]
	[loop,RepeatCount + 1,
		[RoutineCall,DoIt,Frame,Look,Pick]
		[VarInc,Frame]
	]
	//put Frame back to users selection
	[VarSet,Frame,[IGet,zscript:SelectFrame]]
]
[IButton,"  Execute and export images  ","Execute",
	//clear area
	[IPress,Transform:DrawPointer]
	[ipress,Layer:Modifiers:Clear]
	[VarSet,ptr,0]
	[RoutineCall,ReadSwitches]
	[VarSet,doSave,1]
	[VarSet,Frame,0]
	[VarSet,Look,0]
	[VarSet,Pick,-1]
	//Get Document Ready
	[IPress,document:exportimage]
	[VarSet,name,[FileNameGetLastTyped]]

	[loop,RepeatCount + 1,
		[RoutineCall,DoIt,Frame,Look,Pick]
		[VarInc,Frame]
	]
	//put Frame back to users selection
	[VarSet,Frame,[IGet,zscript:SelectFrame]]
]
[PD]
[iSlider,"SelectFrame",0,1,0,RepeatCount,"Select Frame Index",
	[varSet,Frame,[IGet,zscript:SelectFrame]]
	[Note,"Frame....",,-1]
	[Note,Frame,,1]
,0,[TextCalcWidth,SelectMark123]]
[iButton,"F+ ","Increment Frame",
	[VarInc,Frame]
	[if, Frame>(RepeatCount),[VarSet,Frame,0]]
	[ISet,zscript:SelectFrame,Frame]
,0,0,.]
[iButton,"F- ","Decrement Frame",
	[VarDec,Frame]
	[if, Frame<0,[VarSet,Frame,RepeatCount]]
	[ISet,zscript:SelectFrame,Frame]
]
[iButton," PlayFrame ","Load Current Object Frame",
	[RoutineCall,ReadSwitches]
	[IPress,Transform:DrawPointer]
	[IPress,Layer:Modifiers:Clear]
	[VarSet,ptr,0]
	[VarSet,Look,1]
	[VarSet,doSave,0]
	[VarSet,Pick,-1]
	[RoutineCall,DoIt,Frame,Look,Pick]	
]
[iButton," ExportFrame ","Export Current Frame",
	//Get Document Ready
	[if,Frame == 0,
		[if,[MessageYesNo,"New Filename?","Frame 0 Initialization"],
			[IPress,document:exportimage]
			[VarSet,name,[FileNameGetLastTyped]]
			[VarSet,#name,[FileNameAdvance,#name,2]] 
		,
			[FileNameSetNext, #name ] 
			[IPress,document:exportimage]
			[VarSet,#name,[FileNameAdvance,#name,2]] 
		]
	,//else
			[FileNameSetNext, #name ] 
			[IPress,document:exportimage]
			[VarSet,#name,[FileNameAdvance,#name,2]] 
	]
[Note,"Saving...",,1]
]
[iButton,"Put_1 ","Put Object on Canvas",
	[RoutineCall,ReadSwitches]
	[VarSet,ptr,0]
	[VarSet,Look,1]
	[VarSet,doSave,0]
	[VarSet,Pick,ptr]
	[RoutineCall,DoIt,Frame,Look,Pick]	
]
[iButton,"Put_2 ","Put Object on Canvas",
	[RoutineCall,ReadSwitches]
	[VarSet,ptr,1]
	[VarSet,Look,1]
	[VarSet,doSave,0]
	[VarSet,Pick,ptr]
	[RoutineCall,DoIt,Frame,Look,Pick]	
]
[iButton,"Put_3 ","Put Object on Canvas",
	[RoutineCall,ReadSwitches]
	[VarSet,ptr,2]
	[VarSet,Look,1]
	[VarSet,doSave,0]
	[VarSet,Pick,ptr]
	[RoutineCall,DoIt,Frame,Look,Pick]	
]
[iButton,"Put_4 ","Put Object on Canvas",
	[RoutineCall,ReadSwitches]
	[VarSet,ptr,3]
	[VarSet,Look,1]
	[VarSet,doSave,0]
	[VarSet,Pick,ptr]
	[RoutineCall,DoIt,Frame,Look,Pick]	
]
[iButton,"Put_5 ","Put Object on Canvas",
	[RoutineCall,ReadSwitches]
	[VarSet,ptr,4]
	[VarSet,Look,1]
	[VarSet,doSave,0]
	[VarSet,Pick,ptr]
	[RoutineCall,DoIt,Frame,Look,Pick]	
]
[PD]

[RoutineDef,DoIt,
		[VarDef,looper,5]
		[VarSet,looper,5]
		[VarSet,ptr,0]
		[VarSet,timeincr,1.0/(repeatcount)]

		[VarSet,crecurse,timeincr*IFrame]
		//Only want to draw one of the five
		[if,IPick > -1,
			[VarSet,ptr,IPick]
			[VarSet,looper,1]
		]
		[Loop,looper,
			[if,Active(ptr) == 1,
				[ISet,Tool:ItemInfo,type(ptr)]
				[ISet,Material:ItemInfo,mat(ptr)]
				[IColorSet,pr(ptr),pg(ptr),pb(ptr)]
				[CanvasClick,px(ptr),py(ptr),px(ptr)+10,py(ptr)+10]
				[IPress,Transform:Rotate]
				[if,mode(ptr) == 0,
					//Position
					[VarSet,resultx,[Interpolate,crecurse,px(ptr),epx(ptr)]]
					[VarSet,resulty,[Interpolate,crecurse,py(ptr),epy(ptr)]]
					[VarSet,resultz,[Interpolate,crecurse,pz(ptr),epz(ptr)]]
					//Scale
					[VarSet,resultxs,[Interpolate,crecurse,pxs(ptr),epxs(ptr)]]
					[VarSet,resultys,[Interpolate,crecurse,pys(ptr),epys(ptr)]]
					[VarSet,resultzs,[Interpolate,crecurse,pzs(ptr),epzs(ptr)]]
					//Rotation
					[VarSet,resultxr,[Interpolate,crecurse,pxr(ptr),epxr(ptr)]]
					[VarSet,resultyr,[Interpolate,crecurse,pyr(ptr),epyr(ptr)]]
					[VarSet,resultzr,[Interpolate,crecurse,pzr(ptr),epzr(ptr)]]
				,//else Curve
					//position
					[VarSet,resultx,[Interpolate,crecurse,px(ptr),pointX(ptr),epx(ptr)]]
					[VarSet,resulty,[Interpolate,crecurse,py(ptr),pointY(ptr),epy(ptr)]]
					[VarSet,resultz,[Interpolate,crecurse,pz(ptr),pointZ(ptr),epz(ptr)]]
					//Scale
					[VarSet,resultxs,[Interpolate,crecurse,pxs(ptr),pointXS(ptr),epxs(ptr)]]
					[VarSet,resultys,[Interpolate,crecurse,pys(ptr),pointYS(ptr),epys(ptr)]]
					[VarSet,resultzs,[Interpolate,crecurse,pzs(ptr),pointZS(ptr),epzs(ptr)]]
					//Rotation
					[VarSet,resultxr,[Interpolate,crecurse,pxr(ptr),pointXR(ptr),epxr(ptr)]]
					[VarSet,resultyr,[Interpolate,crecurse,pyr(ptr),pointYR(ptr),epyr(ptr)]]
					[VarSet,resultzr,[Interpolate,crecurse,pzr(ptr),pointZR(ptr),epzr(ptr)]]
				]
				[TransformSet,resultx,resulty,resultz,resultxs,resultys,resultzs,resultxr,resultyr,resultzr]
				[IUnpress,Transform:Rotate]
			]
			[VarInc,ptr]
		]
		[VarSet,ptr,0]
		[if,[iget,zscript:bestrender],
			[IPress,Render:BestRenderer]
		]
		[If,doSave==1, 
			[delay,1]
			[FileNameSetNext, #name ] 
			[IPress,document:exportimage]
			[VarSet,#name,[FileNameAdvance,#name,2]] 
		]
		[if,IFrame< RepeatCount,
			[if,ILook == 0,
				[Ipress,Layer:Modifiers:Clear]
			]
		]
		[delay,1]
//***********Parameters**********
,Iframe,ILook,IPick
]


[RoutineDef,GetObjData,
	//Gather pertinent info about the object
	[VarSet,type(iptr),[IGet,TOOL:iteminfo]]
	[VarSet,mat(iptr),[IGet,MATERIAL:iteminfo]]
	[if,iwhich ==0,
		[TransformGet,px(iptr),py(iptr),pz(iptr),pxs(iptr),pys(iptr),pzs(iptr),pxr(iptr),pyr(iptr),pzr(iptr)]
	,//else
		[TransformGet,epx(iptr),epy(iptr),epz(iptr),epxs(iptr),epys(iptr),epzs(iptr),epxr(iptr),epyr(iptr),epzr(iptr)]
	]
	[VarSet,pr(iptr),[IGet,Color:Redcomponent]]
	[VarSet,pg(iptr),[IGet,Color:Greencomponent]]
	[VarSet,pb(iptr),[IGet,Color:Bluecomponent]]


,iptr,iwhich
]
[RoutineDef,ReadSwitches,
	[if,[IGet,zscript:Sel_1],
		[VarSet,Active(0),1]
	,
		[VarSet,Active(0),0]
	]		
	[if,[IGet,zscript:Curve_1],
		[VarSet,Mode(0),1]
	,
		[VarSet,Mode(0),0]
		[ISetStatus,zscript:LoadPoint_1,0]
		[IDisable,zscript:Move_1]
	]		
	[if,[IGet,zscript:Sel_2],
		[VarSet,Active(1),1]
	,
		[VarSet,Active(1),0]
	]		
	[if,[IGet,zscript:Curve_2],
		[VarSet,Mode(1),1]
	,
		[VarSet,Mode(1),0]
		[ISetStatus,zscript:LoadPoint_2,0]
		[IDisable,zscript:Move_2]
	]		
	[if,[IGet,zscript:Sel_3],
		[VarSet,Active(2),1]
	,
		[VarSet,Active(2),0]
	]		
	[if,[IGet,zscript:Curve_3],
		[VarSet,Mode(2),1]
	,
		[VarSet,Mode(2),0]
		[ISetStatus,zscript:LoadPoint_3,0]
		[IDisable,zscript:Move_3]
	]		
	[if,[IGet,zscript:Sel_4],
		[VarSet,Active(3),1]
	,
		[VarSet,Active(3),0]
	]		
	[if,[IGet,zscript:Curve_4],
		[VarSet,Mode(3),1]
	,
		[VarSet,Mode(3),0]
		[ISetStatus,zscript:LoadPoint_4,0]
		[IDisable,zscript:Move_4]
	]		
	[if,[IGet,zscript:Sel_5],
		[VarSet,Active(4),1]
	,
		[VarSet,Active(4),0]
	]		
	[if,[IGet,zscript:Curve_5],
		[VarSet,Mode(4),1]
	,
		[VarSet,Mode(4),0]
		[ISetStatus,zscript:LoadPoint_5,0]
		[IDisable,zscript:Move_5]
	]		
]
[PD]
[PD]
<zscriptinsert,"Widgets_Index_Include_Std.txt">
[pd][penMove,0,8]
\C00e0e0About This ZScript:\Cc0c0c0
This script make it easy to create complex animation frames using Zbrush. I would suggest getting familiar with the Interpolation Widget in preperation to using this script as the object Movement Functions are very simuliar.

Enter the \Cffa000Max Number of Frames\Cc0c0c0 that you wish to create, this number can be changed at anytime but it will have a effect on the resolution of the interpolation calculations. i.e. More frames the better the resolution.
The \Cffa000Best Render\Cc0c0c0 switch can be enabled to tell the routine to render the frame in Best Render mode. If you want to have shadows, transparency, different material properties or fog make sure this switch is on when you want to export your animation

You can control up to 5 different objects at one time by using the controls. You can increase the number of objects by also utilizing the Position Markers in creative ways and also by rendering each frame separately into a layer by itself and then returning to the layer an setting up another set of 5 markers. 

Each Object has a set of controls: These controls set the Movement of the object.

\C00e0e0Object Controls\Cc0c0c0

The \Cffa000Sel_\Cc0c0c0 switch is automatically enabled when a Object is intialized. You can then turn this switch off to exclude the object when rendering the animation.

The \Cffa000Curve_\Cc0c0c0 switch allows the use of a Spline Point in the interpolation movement, if unselected the object path follows a straight line from the Start Position to the End Position. When selected the \Cffa000LoadPoint_\Cc0c0c0 and the \Cffa000Move_\Cc0c0c0 buttons become enabled. Set this Spline point by positioning an object on the canvas at the desired XYZ value and press the \Cffa000LoadPoint_\Cc0c0c0 button. You can return the object to this position at anytime by pressing the \Cffa000Move_\Cc0c0c0 Button

Set the Starting Position of the object by pressing the \Cffa000GetStart\Cc0c0c0 button and likewise the Ending Position by pressing the \Cffa000GetEnd\Cc0c0c0 button. You can return a object to these positions at anytime by pressing the \Cffa000Recall Start\Cc0c0c0 or \Cffa000Recall End\Cc0c0c0. You can Swap the Start with the End position by pressing the \Cffa000Swap\Cc0c0c0 button. This is useful for adding to a animation sequence, by making your End Position your Start Position you can then create a new End Position and continue on. 

\C00e0e0IMPORTANT FACT\Cc0c0c0 If you are not holding an object, no gyro, then pressing either the \Cffa000Recall Start\Cc0c0c0 or \Cffa000Recall End\Cc0c0c0 button will create the saved object with material, color etc... If you are holding an object, the gyro is visible, then it just moves that object to the position and doesn't interfere with the material, size or Color of the object. This is useful for assigning other objects to the same location as other animation objects.

\C00e0e0Render and Export Controls\Cc0c0c0

The \Cffa000Preview without Saving\Cc0c0c0 button will automatically render each frame sequentially starting with Frame 0 without exporting each frame to disk.

The \Cffa000Execute and Export\Cc0c0c0 button will automatically render and export each frame sequentially starting with Frame 0. At the start you will be asked for a filename, then as the process continues each frame a number is appended to the basefilename. Example: ani01, ani02, ani03 etc...

You can also preview and export the animation on a frame by frame basis.
Enter the desired frame into the \Cffa000SelectFrame\Cc0c0c0 slider or incremently change the framenumber by using the \Cffa000F-\Cc0c0c0 and \Cffa000F+\Cc0c0c0 buttons.
Render the current frame by pressing the \Cffa000Play Frame\Cc0c0c0 button. This will clear the canvas layer and draw each object in the frame on the canvas. You can also place each object in the frame on the canvas separately by pressing one of the \Cffa000Put\Cc0c0c0 buttons. This can be useful like when you have a head that you want to model and transform a bit in each frame, you would press the Put button, hit "t" for edit and do your changes before you export the frame.

Export each frame separately by pressing the \Cffa000ExportFrame\Cc0c0c0 button. If the current frame and only if the current framenumber is 0 then the widget will ask you if you would like to create a new filename. Answer yes to enter the basefile name and then as you progress thru the frames the basefile name will be incremented with a number. If you are currently working with a valid BaseFilename answer no and the Widget will continue using the Active Basefilename to export the frames to disk.
[PD]
[iButton,"Example ","Animation Widget Example",
	[if,[Ireset],
	[IcolorSet,239,234,30]
	[Note,"Selecting 10 Frames in Max Number of Frames",zscript:example,3]
	[ISet,zscript:MaxNumberofFrames,10]
	[note,"I will select a Cube for Object one and provide 2 Points that we will connect",zscript:example,2]
	[ISet,Tool:ItemInfo,9]
	[CanvasClick,DocMidX,DocMidY,DocMidX+10,DocMidY+10]
	[IPress,Transform:Move]
	[TransformSet,100,100,0,10,10,10,0,45,-180]
	[note,"This will be the Start for Object 1 so I will press GetStart1",zscript:example,3]
	[IPress,zscript:GetStart1]
	[TransformSet,320,240,0,30,30,30,0,0,180]
	[note,"This will be the End Position for Object 1 so I will press GetEnd1",zscript:example,3]
	[IPress,zscript:GetEnd1]
	[Note,"I would like this cube to curve as it moves so next I will turn on the Curve_1 switch and provide the spline point",zscript:example,0]
	[if,[Iget,zscript:curve_1],
	,
		[IToggle,zscript:curve_1]
	]
	[Note,"The LoadPoint_1 button now becomes enabled so I will move the object to where I want the spline point to be and press it",zscript:example,3]
	[TransformSet,30,240,0,30,30,30,0,0,180]
	[Ipress,zscript:LoadPoint_1]

	[note,"Now I will quickly set up Object 2 a Ring which will end up around the cube much in the same way",zscript:example,0]
	[IcolorSet,69,234,30]
	[ISet,Tool:ItemInfo,12]
	[CanvasClick,DocMidX,DocMidY,DocMidX+10,DocMidY+10]
	[IPress,Transform:Move]
	[TransformSet,540,100,0,10,10,10,0,45,-180]
	[IPress,zscript:GetStart2]
	[TransformSet,320,240,0,30,80,80,0,0,180]
	[IPress,zscript:GetEnd2]
	[if,[Iget,zscript:curve_2],
	,
		[IToggle,zscript:curve_2]
	]
	[TransformSet,610,240,0,30,30,30,0,0,180]
	[Ipress,zscript:LoadPoint_2]
	[Ipress,transform:DrawPointer]
	[Note,"Lets preview the whole animation by pressing the Preview without Saving Button",zscript:example,0]
	[Ipress,zscript:Previewwithoutsaving]
	[Note,"We can also render each frame by utilizing the F+ and F- buttons and pressing PlayFrame",zscript:example,0]
	[IPress,zscript:Playframe]
	[Note,"This is Frame 0",zscript:example,0]
	[ISet,zscript:SelectFrame,5]
	[IPress,zscript:Playframe]
	[Note,"This is Frame 5",zscript:example,0]
	[IPress,Layer:Modifiers:Clear]
	[Note,"We can also recall objects to the canvas separately with the Put Buttons",zscript:example,0]
	[IPress,zscript:Put_1]
	[Note,"Here is the Cube at Frame 5",zscript:example,3]
	[IPress,zscript:Put_2]
	[Note,"Here is the Ring at Frame 5",zscript:example,3]
	[Note,"You can also Export each frame separately by using the Export Frame button or automatically by using the Execute and Export Images button. Please Drive Safely!",zscript:example,0]
,//else
	[Note,"Aborting! Maybe another day eh?",,3]
]
]	


[PD]
[PD]
[fontSetSizeSmall]\C00e0e0Standard Digit Widget Animation Revision 1.0, created by Digits\Cc0c0c0
