PDA

View Full Version : Stretcher Model script qt



FrankyGTH
04-30-2009, 01:18 PM
hi all :)

have done some experiments and shows here a little modeller script, but I am not sure how I can build in a random factor for the axis...

by the way: what is randu ? ;)

anybody can check the script if it's running??? thanks in advance! :)

...

main
{
var center,vt,c1,c2;
var axis = recall("axis",1);
var factor = recall("Factor",1.0);
var random = recall("Random",2.0);
var buttons[4];
buttons[1] = "X";
buttons[2] = "Y";
buttons[3] = "Z";
buttons[4] = "ZERO"; // something else...

// debug()

if(pointcount() < 1)
return;



reqbegin("Stretcher DEMO");
c1 = ctlchoice("Axis:",axis,buttons);
c2 = ctlnumber("Factor:",factor);
c3 = ctlnumber("Random:",random);

if(reqpost())
{
axis = getvalue(c1);
factor = getvalue(c2);
random = getvalue(c3);
store("Axis",axis);
store("Factor",factor);
store("Random",random);
}
else return;


reqend();

selmode(USER);

editbegin();

vt = boundingbox();
center = center(vt);
editend();

switch(axis)
{
case 1:
scale(<factor,1,1>,center);
break;

case 2:
scale(<1,factor,1>,center);
break;

case 3:
scale(<1,1,factor>,center);
break;

case 4:
scale(<random(1,2),random(1,2),random(1,2)>,center); // <x, y, z>
break;

}
}
// randu, rnd


cheerio, FrankyGTH

FrankyGTH
05-01-2009, 06:07 AM
hi again:)

I tried to add new things into the script I have found last night :)

so I would only like to know if it's possible to

a) store("Random",random);

b) c3 = ctlnumber("Random:",random);

c) case 4:
scale(<random(1,2),random(1,2),random(1,2)>,center ); // <x, y, z>
break;

I am learning by modifying old scripts... or make they running, that's the best way to learn new stuff:)

I am using for my scripts the lw script editor and conTEXT, nice little things! :)

ciao, best regards, I love LW :D, Franky GTH
ps: I am not quite fit with lw script language, sorry... ;)

FrankyGTH
05-08-2009, 10:11 AM
ok, have solved my little problem :) the script runs now as well as I wished... copied something wrong from my texteditor into conText, ciao, thank you for massive replies ;) this little script was a good learning tool for myself as beginner :) missing a lot of well function usable lw script by newtek...

have looked after things like this one:

rad = 0.05 * maxlen * (1 + randu());

thank you mike green lw script help :) !

when the script is complete and ready I will send it ...

this script below does run already ;)

// begin

main
{
var center,vt,c1,c2;
var axis = recall("axis",1);
var factor = recall("Factor",1.0);
var randu = recall("Random",1);
var buttons[4];
buttons[1] = "X";
buttons[2] = "Y";
buttons[3] = "Z";
buttons[4] = "ZERO";

// debug()

if(pointcount() < 1)
return;



reqbegin("Stretcher DEMO");
c1 = ctlchoice("Axis:",axis,buttons);
c2 = ctlnumber("Factor:",factor);
c3 = ctlnumber("Random:",randu);

if(reqpost())
{
axis = getvalue(c1);
factor = getvalue(c2);
random = getvalue(c3);
store("Axis",axis);
store("Factor",factor);
store("Random",randu);
}
else return;

// debug()

reqend();

selmode(USER);

editbegin();

vt = boundingbox();
center = center(vt);
editend();

switch(axis)
{
case 1:
scale(<factor,1,1>,center);
break;

case 2:
scale(<1,factor,1>,center);
break;

case 3:
scale(<1,1,factor>,center);
break;

case 4:
scale(<randu(1,4),randu(1,4),randu(1,4)>,center); // <x, y, z>
break;

}
}
// end

I will check if it's possible to make a random stretching effect for the model... that's my task... and the Zero Button should have some added function :)

ciao, FrankyGTH