[Closed] Max script controller lagging in viewport
Hi there! I have created a basic slider. When I try to use it, it rotates very fast and then slows down when it get’s back to the middle. How can I enable a “real time” (if I may use that term) slider?
group "sliders"
(
slider tilt "Camera Rotation" orient:#horizonal ticks:10 range:[-150,150,0]
)
on tilt changed val do
(
rotate $ (angleaxis val [1,0,0])
)
Thanks!
so here’s the whole thing in case anyone had any ideas. I think it could be a time saver as I generally animate my camera with the spinners. Thanks again.
Rollout PolyFormTools "PolyForm Camera Tools"
(
group "Camera Tools"
(
-- button _CylinderUVWMap "UVW Map - Cylinder" align:#left across:2
-- button _BoxUVWMap "UVW Map - Box" align:#right
-- button _PlanarUVWMap "UVW Map - Planar" align:#center
-- radiobuttons alignment "Alignment" labels:#("x","y","z") align:#left
spinner xRot "X Rotation:" range:[-360,360,0] fieldwidth:40 align:#left across:3 type:#float enabled:true
button _plus5x "x5+" align:#right enabled:true
button _minus5x "x5-" align:#right enabled:true
spinner yRot "Y Rotation:" range:[-360,360,0] fieldwidth:40 across:3 align:#left type:#float enabled:true
button _plus5y "y5+" align:#right enabled:true
button _minus5y "y5-" align:#right enabled:true
spinner zRot "Z Rotation:" range:[-360,360,0] fieldwidth:40 across:3 align:#left type:#float enabled:true
button _plus5z "z5+" align:#right enabled:true
button _minus5z "z5-" align:#right enabled:true
radiobuttons setCam "Set Camera" labels:#("1","2","3","4","5") align:#center
radiobuttons getCam "Select Camera" labels:#("1","2","3","4","5") align:#center
)
group "sliders"
(
slider tilt "Camera Rotation" orient:#horizonal ticks:10 range:[-150,150,0]
)
on tilt changed val do
(
rotate $ (angleaxis val [1,0,0]) --= val
)
on setCam changed state do
(
local cam1 = $Camera001
local cam2 = $Camera002
local cam3 = $Camera003
local cam4 = $Camera004
local cam5 = $Camera005
case state of
(
1: (viewport.setCamera cam1)
2: (viewport.setCamera cam2)
3: (viewport.setCamera cam3)
4: (viewport.setCamera cam4)
5: (viewport.setCamera cam5)
)
)
on getCam changed state do
(
local cam1 = $Camera001
local cam2 = $Camera002
local cam3 = $Camera003
local cam4 = $Camera004
local cam5 = $Camera005
case state of
(
1: (select cam1)
2: (select cam2)
3: (select cam3)
4: (select cam4)
5: (select cam5)
)
)
on _plus5x pressed do
(
toolMode.coordsys #local
rotate $ (angleaxis 5 [1,0,0])
)
on _minus5x pressed do
(
toolMode.coordsys #local
rotate $ (angleaxis -5 [1,0,0])
)
on _plus5y pressed do
(
toolMode.coordsys #local
rotate $ (angleaxis 5 [0,1,0])
)
on _minus5y pressed do
(
toolMode.coordsys #local
rotate $ (angleaxis -5 [0,1,0])
)
on _plus5z pressed do
(
toolMode.coordsys #local
rotate $ (angleaxis 5 [0,0,1])
)
on _minus5z pressed do
(
toolMode.coordsys #local
rotate $ (angleaxis -5 [0,0,1])
)
on xRot changed val do
(
toolMode.coordsys #local
rotate $ (angleaxis xRot.value [0,0,1])
)
on yRot changed val do
(
toolMode.coordsys #local
rotate $ (angleaxis xRot.value [0,1,0])
)
on zRot changed val do
(
toolMode.coordsys #local
rotate $ (angleaxis zRot.value [0,0,1])
)
)
Createdialog PolyFormTools width:250 height:300
does nobody else have this issue or is the solution so obvious and I am being too lazy?
“on tilt changed val do (rotate $ (angleaxis val [1,0,0]))”, well what this does is it adds its value as rotation everytime the value changes. that’s causing the weird behaviour. you prolly want to set (not add) the rotation values according to the slider.
also, this would only work on a ‘free camera’, for a ‘target camera’ you’ll have to check “use target as up node” and the “roll” button right below in the look at parameters (motion tab), and then drive the camera target rotation with your slider.