[Closed] Ortho to Perspective
Hi again
And again i wrote some script. It basicly when youre on some orthographic view (top, right etc) and you rotate view instead of orthographic it switches to perspective:
a = undefined
b = undefined
fn sprawdz_TM1=
(
if(viewport.GetType() == #view_iso_user) then
(
viewport.setType #view_persp_user
b = viewport.getTM()
)
if (b!= undefined) then
(
a = viewport.getTM()
a.row4.z = b.row4.z
viewport.setTm a
)
)
callbacks.addScript #viewportChange "sprawdz_TM1()" id:#zacnyPersp
It works fine BUT
value b stays there constantly so the (viewport.getTM()).row4.z is constantly equals to value from b. When you put b = undefined in:
if (b!= undefined) then
(
a = viewport.getTM()
a.row4.z = b.row4.z
viewport.setTm a
[b] b = undefined[/b]
)
it dont work properly (check yourself ). How can i add timer to change b = undefined afrer 1,5sec? I tried to put timer in different places but there is always error (i think with scope). Something like this:
timer timerX interval:1500 active: false
on timerX tick do
(
b = undefined
timerX.active = false
)
if (b!= undefined) then
(
a = viewport.getTM()
a.row4.z = b.row4.z
viewport.setTm a
timerX.active = true
)
[b]
[/b]
you don’t need timer. if you want to use B as global define it as global:
global a
global b
fn doSomething =
(
if (b != undefined) do
(
...
b = undefined
)
)
Run script please. This is what exactly i was saying, b = undefined dont solve problem. After first run (from callback) and JUST ONE MOVE alt+middle mouse it works perfectly – changes to perspective and setting good view, then after next move it moves around mouse – so the script must run some time OR fully 2-3 times then b = undefined. Changes this value after first loop doesnt solve the problem
Ill put full script after i solve this problem from above This code will start automaticly (startup) – but always around value b until its undefined…and always will calculate a = getViewTm()… setTm…so it will use little calculate power…And i must solve that
Or struct maybe
callbacks.removeScripts id:#zacnyPersp
global orthoToPersp
(
struct otpStruct
(
a , b,
fn sprawdz_TM=
(
if(viewport.GetType() == #view_iso_user) then
(
viewport.setType #view_persp_user
this.b = viewport.getTM()
)
if (b!= undefined) then
(
this.a = viewport.getTM()
this.a.row4.z = this.b.row4.z
viewport.setTm this.a
)
)
)
orthoToPersp = otpStruct()
)
callbacks.addScript #viewportChange "orthoToPersp.sprawdz_TM()" id:#zacnyPersp
So, for the script newbies, what is final script?
Does starts automaticaly with MAX, if we put it in startup scripts?
Or we have to start for every time by hand?
Anyway, this is AWESOME script! And awesome idea…
i see this project like a little joke. are you really think it can work?
there are many situations when i like to work in #view_iso_user mode… it’s more or less ok to switch from ortho to perspective if a ‘point of interest’ in center of the screen. but it still jumps too far from original screen position.
when you change from ortho to iso_user a point stays and the same position. it’s very important behavior when you work for example with vertices (or any other sub objects). that’s why artist who do skinning a lot of time work in orthographic modes.
Im understand you perfectly. Im usually work in ortho modes (mostly in #view_iso_user mode) , but sometimes i want to “just quick check” in perspective mode how it looks (change(in ex. top view) -look (little angle near Top view) – change – look…) and for this purpose is this script. The script itself will be on rollout check button or just as macro script – it will be on/off.
I think it would be useful to replace ViewCube default options to swap to front, top, bottom, left and right not inside orthographic mode, but in normal mode, also when you press on corner – to animate and move inside perspective. Does anyone of you work inside orthographic mode?