I'm working on a tool that uses a spinner to tweak the projection modifier cage in the view port in real time (yes, I realize that's how the projection modifier already works - bear w/ me :poly124:). Pretty much trying to mimic the same spinner in the command panel of the projection mod. Mine however lags like crazy and multiplies the users input. I'm not getting a 1:1 ratio if that makes sense. Clicking on the arrows works fine, its when I try and drag that things go awry.
Any ideas on this? I've already tried flagging meshes as foreground / background, but I think the problem lies elsewhere.
Thanks!
-Tyler
Replies
enableSceneRedraw();
completeRedraw();
maybe sceneRedraw is not activated, or try to force a redraw ( completeRedraw(); )on each spinner change iteration
From the docs:
[php]Projection>.pushValue Float default: 0.0 -- world units; Push_Value[/php]
Its a getter / setter. Setting it though just updates the spinner field, but doesn't actually fire off a changed event. So that's useless.
Next step was trying this method (which I'm using, but its lagging!!!!!!):
Projection : Modifier[php]<void>pushCage <float>amount[/php]
To see what I mean, toss a projection modifier on a mesh, then eval this and use the spinner. Going one direction is fine, but try to go back and forth (positive and negative spins):
[php]rollout projSpin "Projection Mod Spinnerl"
(
spinner sPushCage "Push Cage:" range:[-500,500,0] type:#integer
on sPushCage changed val do
(
$.modifiers[1].pushCage(val)
)
)
theNewFloater = newRolloutFloater "Test" 300 220
addRollout projSpin theNewFloater[/php]
Am I missing something? BTW, I tried this bit of code w/ the redraw and flag foreground stuff. No luck there.
-Tyler
I had attempted to trap the last push value, however the spinner works in an odd way. Once a value is applied, it gets zeroed out, which means getting the last value always returns 0. Which should mean you don't need to subtract the previous push amount from the amount you're about to add.
Nonetheless, I had the same thoughts you did in that the lag is because the push amount is constantly being multiplied. Just not sure how to get around it because the spinner keeps zeroing out.
Any ideas? Maybe I'm looking at this the wrong way?
-Tyler
I'd say it's not your fault. The pushCage function applies two transformations in one shot, the first is like setting the Push Amount value, and the second is like setting the Percent value at 100%, meaning you got the first shift doubled for each amount variation, so it looks like a multiplication.
Here is a working code: sets the Percent at -100% each time the spinner is accessed and revert it to 0% after the shift.
Thanks for the fix! One question for you though -
[php]-- uncomment this to reset the spinner after each adjustment
-- sPushCage.value = 0.0[/php]
Did you actually get this to work as well? It resets the spinner to zero (just the projection mod does), however on the next spin the cage gets reset as well. It's more of a nit picky item.
Cheers on the fix! I too have no idea why two values are needed for this one operation.
-Tyler
New buttonUp event: It should work well now (tested).
-Tyler