PDA

View Full Version : Zscript question for the Zscript Gurus



Digits
07-18-01, 01:11 PM
A couple of questions I have wanted to ask for awhile and I just can't hold it in anymore. *Lets out deep breath*

1. The Interpolate Function.

[VarSet,startX,0]
[VarSet,endX,1000]
[Interpolate, 0.25, startX, endX] Returns an interpolated value (startX*(1.0-0.25))+(endX*.025)

This one is pretty straight forward, a straight line from 0 to 1000. The result from this would be a value of 250 at a time of .25

[Interpolate,0.25,list1,list2,list3] Returns an interpolated list caculated as a spline at t=.25

This one I can't figure out. list 1,2 and 3, can be a number, a varible or a list or array. I take it if you use a list, you still have to index it like this

[VarDef,list1(100)]
[VarDef,list2(100)]
[VarDef,list3(100)]

[RoutineCall,Filluplistswithinterestingdata] //fill up array with stuff
[VarSet,IData,[Interpolate,0.25,list1(1),list2(2),list3(3)]]

What is IData going to be? at 0, .25, .50, .75, 1 second?


A while back Davey explained a couple of things

"[RoutineCall,Digits-example,someX,someY,someZ]

There's plenty more where that came from. If/then/else's, trig functions, 3 kinds of interpolation, and lots more. And yes, ZScripts are simply text files.

You could cut and paste the above into another script, or you could save it with a file name like "Digits-example.txt", then put this in another ZScript:

<ZScript-Insert,Digits-example.txt>"

2. 3 types of Interpolation, what are they?

3. I haven't been able to use his example <ZScript-Insert,Digits-example.txt> to include a file into a script, has the syntax been changed?


Thanks in advance! I know you guys are still doin the Chinese Fire Dance to get things wrapped up

Digits
07-18-01, 02:13 PM
Course the minute I posted the question, I had a brainstorm and figured it out.

[Interpolate,.25,0,500,1000]

this is just like a straight line
250,500,750,1000

[Interpolate,.25,0,250,1000]
This is a curve, I don't have the exact data but it might be something like this
125,400,825,1000

basically you are, like it says in the docs, creating a Spline.

Still would like to know what the 3rd type of interpolation is and how to use the include statement

Thanks again!

Kaz
07-18-01, 02:58 PM
I have not gotten my hands on this yet, so I don't have any hard data, but back in the old days of scripting animation on the Atari ST, there were 3 types of splines:

1. Straight - intersects all points
2. Curve - Intersects all points
3. Curve - Averages points, does not actually intersect.

I don't recall the names of all these splines, but they are basic mathematical functions (One is a b-spline).
Any of this help?

-kaz

Digits
07-18-01, 05:14 PM
Thanks Kaz, I think what you say is pretty much how this works, I don't know if it is averaged or not thou.


To demonstrate the Spline type of Interpolate I threw together a little script if you want to check it out.

Curve_Widget.txt (http://www2.zbrushcentral.com/zbc_uploads/user_file-995501539eto.txt)

http://www2.zbrushcentral.com/zbc_uploads0/user_image-995502848jpf.jpg

You will see some controls for Position Marks, you will need 2 of them

1. Draw an object (any object) size and position (xyz) it on the canvas where you would like to start a curved line.
2. Press the Marker "Save" key
3. Press the M+ key to increment to marker 2
4. Move your still selected object to another point xyz where you want the curve to end, you might go ahead and snapshot "Shift S" your first and your second mark to give you a reference
5. Now move your object anywhere on the canvas XYZ, this is your spline control.
6. In the curve controls put in .02 for time (this will give you a 50 point resolution
7. The control is already default StartMarker at 1 and EndMarker at 2
8. Press all the C-Snap, C-Size, C-Rotate etc.. switches
9. Press the Curveit-3 button and watch what happens

If your mark1 has different Rotate and/or Size than Mark 2 it will interpolate the rotation and size as well

If your Spline object, the one you move around before you hit the curve button is a different size, it will interpolate that as well, but it will always start at StartMark Size and be at the Endmark size when it is finished.

by Changing your Spline Object size, XY position and Zdepth you will get various looking curves.

http://www2.zbrushcentral.com/zbc_uploads/user_image-995504895dww.jpg

I might mention that the CMult slider will multiply your spline object's position thereby changing the slope of the curve
i.e. a factor of 2 will be like putting the spline object twice as far away.

davey
07-19-01, 05:43 AM
Hi, Digits.

I should be getting ready for the show, thought I'd check in on the board real quick-like.

I'll have to check my notes on the Interpolate function, but from memory, if you specify two points (or lists of points), ZScript does a linear interpolation (straight line); if you specify three points, ZScript does a spline-type interpolation (curve through the third point); if you specify four points, ZScript does a Bezier-type interpolation (that is, two of the points are endpoints, the other two are "control" points which act like magnets -- the curve doesn't pass through them. Just like curve handles in Postscript applications like Illustrator or Photoshop).

Unfortunately, off the top of my head, I can't remember which are the endpoints and which are the control points. Perhaps you can do a bit of experimenting and figure it out?

As for the ZScript-insert function, the syntax is:

<zscriptinsert,"inserted-zscript.txt">

And, added just recently, ZScripts now allow you to specify a ZScript name using [FileNameSetNext...] and pressing the Load button in the ZScript palette (to avoid confusion you may need to call it by number; i.e. [IPress,7427]). This gives you a kind of "hyperlink" button a la HTML.

I'm off to an exciting Macworld show -- our booth is getting mobbed!

dave

Digits
07-19-01, 06:57 AM
Thanks Davey!

Just the information I needed, I appreciate it. Good luck at MacWorld, party hardy!