//*************************************************** // Digit's Widgets - A Zbrush Zscript // Position Marker Tutorial //*************************************************** //Document stuff [VarSet,docWidth,DOCUMENT:MODIFIERS:WIDTH] [VarSet,docHeight,DOCUMENT:MODIFIERS:HEIGHT] [VarSet,docMidX,docWidth/2] [VarSet,docMidY,docHeight/2] //**************************** //Position Mark Common //**************************** [VarDef,maxAvailablemarks,10] [VarDef,MarkTool(maxAvailablemarks+1),0] [VarDef,MarkMat(maxAvailablemarks+1),0] [VarDef,MarkR(maxAvailablemarks+1),0] [VarDef,MarkG(maxAvailablemarks+1),0] [VarDef,MarkB(maxAvailablemarks+1),0] [varDef,MarkX(maxAvailablemarks+1)] [varDef,MarkY(maxAvailablemarks+1)] [varDef,MarkZ(maxAvailablemarks+1)] [varDef,MarkXS(maxAvailablemarks+1)] [varDef,MarkYS(maxAvailablemarks+1)] [varDef,MarkZS(maxAvailablemarks+1)] [varDef,MarkXR(maxAvailablemarks+1)] [varDef,MarkYR(maxAvailablemarks+1)] [varDef,MarkZR(maxAvailablemarks+1)] [varDef,MarkIndex,1] [PD] [FontSetColor,255,200,0]Position Marker Tutorial[FontSetColor,160,160,160] [PD] //*************************************************** // Widget_Marker_Main - Include File // Master Marker Include //************************************************************************** //********************Position Marks**************************************** //************************************************************************** [varDef,MZ,0] [varDef,MY,0] [varDef,MZ,0] [varDef,M1,0] [varDef,M2,0] [varDef,M3,0] [FontSetColor,255,200,0]Position Marks..[FontSetColor,160,160,160] [iSlider,"SelectMark",1,1,1,10,"Select Mark Index", [varSet,MarkIndex,zscript:SelectMark] [note,"Selected Mark...",,-1] [Note,MarkIndex,,1] ,0,[TextCalcWidth,SelectMark123]] [iButton,"M+ ","Increment Mark", [VarInc,MarkIndex] [if, MarkIndex>10,[VarSet,MarkIndex,1]] [ISet,zscript:SelectMark,MarkIndex] ,0,0,.] [iButton,"M- ","Decrement Mark", [VarDec,MarkIndex] [if, MarkIndex<1,[VarSet,MarkIndex,10]] [ISet,zscript:SelectMark,MarkIndex] ] [iButton," Save ","Save Current Object Mark", [VarSet,MarkIndex,[IGet,zscript:SelectMark]] [note,"Saving Mark....",,-1] [note,MarkIndex,,1] [TransformGet,MarkX(MarkIndex),MarkY(MarkIndex),MarkZ(MarkIndex),MarkXS(MarkIndex),MarkYS(MarkIndex),MarkZS(MarkIndex),MarkXR(MarkIndex),MarkYR(MarkIndex),MarkZR(MarkIndex)] //Gather pertinent info about the object [VarSet,MarkTool(MarkIndex),[IGet,TOOL:iteminfo]] [VarSet,MarkMat(MarkIndex),[IGet,MATERIAL:iteminfo]] [VarSet,MarkR(MarkIndex),[IGet,Color:Redcomponent]] [VarSet,MarkG(MarkIndex),[IGet,Color:Greencomponent]] [VarSet,MarkB(MarkIndex),[IGet,Color:Bluecomponent]] ,,,CTRL+'m' ] [iButton," Load ","Load Current Object Mark", [RoutineCall,LoadMark,MarkIndex] ,,,SHIFT+"l" ] [RoutineDef,LoadMark, [VarDef,newchk,0] [VarDef,isold,0] [VarSet,newchk,0] [if,[IGet,Transform:DrawPointer] == 1,[VarSet,isold,1],[VarSet,isold,0]] [ISet,zscript:SelectMark,imptr] [VarSet,MX,MarkX(imptr)] [VarSet,MY,MarkY(imptr)] [VarSet,MZ,MarkZ(imptr)] [VarSet,newchk,MX+MY+MZ] //check to see if a new marker //if user isn't holding an object make the original [if,isold == 1, [if,newchk <> 0, [ISet,Tool:ItemInfo,MarkTool(imptr)] [CanvasClick,MX,MY,MX+10,MY+10] [ISet,Transform:Move,1] [ISet,Material:ItemInfo,MarkMat(imptr)] [IColorSet,MarkR(MarkIndex),MarkG(imptr),MarkB(imptr)] ] ] [if,newchk <> 0, [if,isold == 1, [TransformSet,MX,MY,MZ,MarkXS(imptr),MarkYS(imptr),MarkZS(imptr),MarkXR(imptr),MarkYR(imptr),MarkZR(imptr)] ,//else [TransformSet,MX,MY,MZ] ] ,//else [Note,"New Marker...",,-1] [note,MarkIndex,,1] ] //parameter ,imptr] [iButton,"M1","Load Current Object Mark", [ISet,zscript:SelectMark,1] ,,,SHIFT+'1' ] [iButton,"M2","Load Current Object Mark", [ISet,zscript:SelectMark,2] ,,,SHIFT+'2' ] [iButton,"M3","Load Current Object Mark", [ISet,zscript:SelectMark,3] ,,,SHIFT+'3' ] [iButton,"M4","Load Current Object Mark", [ISet,zscript:SelectMark,4] ,,,SHIFT+'4' ] [iButton,"M5","Load Current Object Mark", [ISet,zscript:SelectMark,5] ,,,SHIFT+'5' ] [iButton,"M6","Load Current Object Mark", [ISet,zscript:SelectMark,6] ,,,SHIFT+'6' ] [iButton,"M7","Load Current Object Mark", [ISet,zscript:SelectMark,7] ,,,SHIFT+'7' ] [iButton,"M8","Load Current Object Mark", [ISet,zscript:SelectMark,8] ,,,SHIFT+'8' ] [iButton,"M9","Load Current Object Mark", [ISet,zscript:SelectMark,9] ,,,SHIFT+'9' ] [iButton,"M10","Load Current Object Mark", [ISet,zscript:SelectMark,10] ,,,SHIFT+'0' ] [PD] [iButton,"Example ","Position Markers Example", //[if,[IReset], [note,"For our first marker I will select a Sphere",zscript:example,0] [ISet,Tool:ItemInfo,8] [note,"Drag it onto Canvas",zscript:example,1] [CanvasClick,DocMidX,DocMidY,DocMidX+20,DocMidY+20] [Note,"Give it some random color and material",zscript:example,1] [IColorSet,RAND(255),RAND(255),RAND(255)] [ISet,Material:ItemInfo,RAND(20)] [IPress,Transform:Move] [TransformSet,100,100,0,20,20,20,rand(180),Rand(180),rand(180)] [note,"Notice that I am holding the object now in a Transform Move, Scale, or Rotation mode and that the Gyro is visible. Next I will use the Position Marker Widget feature and save its Position as Marker 1",zscript:example,0] [ISet,zscript:SelectMark,1] [note,"Saving ",zscript:Save,1] [Ipress,zscript:Save] [IPress,Transform:Snapshot] [IPress,Transform:DrawPointer] [Note,"For Marker 2 I will create a cube and give it some random attributes",zscript:example,0] [ISet,Tool:ItemInfo,9] [note,"Drag it onto Canvas",zscript:example,1] [CanvasClick,DocMidX,DocMidY,DocMidX+30,DocMidY+30] [Note,"Give it some random color and material",,1] [IColorSet,RAND(255),RAND(255),RAND(255)] [ISet,Material:ItemInfo,RAND(10)] [IPress,Transform:Move] [TransformSet,500,400,0,30,30,30,rand(180),rand(180),rand(180)] [Note,"I will use the Short Cut keys Shift + 2 to select Marker number 2",zscript:example,0] [ISet,zscript:selectmark,2] [Note,"Next I will use the Short Cut Key CNTRL m to save this object to Position Marker number 2",zscript:Save,0] [IPress,zscript:Save] [IPress,Transform:DrawPointer] [Note,"Now we will see if it all works, I will first clear the layer",zscript:example,0] [Ipress,layer:Modifiers:clear] [Note,"Using Shift + 1 to select Marker 1",zscript:m1,2] [ISet,zscript:selectmark,1] [Note,"Pressing Shift + l to load Position Marker 1",zscript:Load,2] [IPress,zscript:Load] [Note,"We should now have our Marker 1 Sphere back with all its properties intact",zscript:example,0] [Note,"Using Shift + 2 to select Marker 2",zscript:m2,2] [IPress,Transform:DrawPointer] [ISet,zscript:selectmark,2] [Note,"Pressing Shift + l to load Position Marker 2",zscript:load,2] [IPress,zscript:Load] [Note,"Here is our Marker 2 Cube!",zscript:example,2] [Note,"Now we will create another object and see what happens when you have it active and you load a marker",zscript:example,0] [IPress,Transform:DrawPointer] [ISet,Tool:ItemInfo,10] [note,"Drag it onto Canvas",zscript:example,1] [CanvasClick,DocMidX,DocMidY,DocMidX+40,DocMidY+40] [Note,"Give it some random color and material",zscript:example,1] [IColorSet,RAND(255),RAND(255),RAND(255)] [ISet,Material:ItemInfo,RAND(10)] [IPress,Transform:Move] [TransformSet,rand(DocWidth),rand(DocHeight),0,40,40,40,rand(180),rand(180),rand(180)] [note,"OkayDokey, we have an object and we are holding it with gyro visible, I will then press Load to call back marker 2",zscript:load,0] [Ipress,zscript:load] [Note,"Loading Marker 2 caused the currently selected object to move to Marker 2 Position but not assign any other properties, we could now assign this to marker 3 and have this object exactly at marker 2 position",zscript:example,0] [Note,"That is all there is to it, easy isn't it?",,3] //,//else // [Note,"Maybepossiblyperhaps another time eh?",,2] //] ] [PD] [pd][penMove,0,8] \C00e0e0About This ZScript:\Cc0c0c0 Position Markers are much like Zbrushes internal Markers in that they allow you to save and recall an object's properties to and from the canvas. But unlike Zbrushes internal Markers thier information may be used by functions included in Digit's Widgets. Also when another Digit Widget Script is loaded any Position Markers that have been defined are lost and must be input again if needed. \C00e0e0User Shortcut Keys\Cc0c0c0 In addition to using the \Cffa000SelectMark\Cc0c0c0 slider, \Cffa000M+\Cc0c0c0 and \Cffa000M-\Cc0c0c0 buttons and the individual \Cffa000M1 through M0\Cc0c0c0 buttons a few shortcut keys have been defined to quickly utilize the Markers during creation of an image. \Cffa000SHIFT + 1 to 0\Cc0c0c0 Select Marker \Cffa000SHIFT + l\Cc0c0c0 Load Currently Selected Marker to the Canvas. \Cffa000CNTRL + m\Cc0c0c0 Save the currently active object to the Currently Selected Marker \C00e0e0NOTE\Cc0c0c0 Using the Keyboard Shortcut or pressing the \Cffa000Load\Cc0c0c0 button will recall the saved object's Color, Material, Position, Size, and Rotation if the user is not currently holding an object in an active state i.e. a Gyro is visible and the object is in a Move, Scale, or Rotate transformation mode. If the user is holding active a object or tool pressing the \Cffa000Load\Cc0c0c0 function will just move the object to the saved data in the Marker. This is useful for assigning other objects the same positional data of another Marker. [PD] [PD] [fontSetSizeSmall]\C00e0e0Digit Widget Position Marker Tutorial, created by Digits\Cc0c0c0