View Full Version : Camera Script question?
Levitateme 08-26-2004, 06:19 PM My friend wrote this script to work like Wings3d camera. and i JUST found out that if you turn of ORTHO locked in tumble tools for the camera you can rotate in ortho mode. but this script does a few things that wings3d dont. and i would ask my friend but i think he lost his house in a hurricane.
1. if you go to front, top , side its always the same posisition. in wings 3d the camera does not do this.
could anyone who knows how the wings3d persp camera works try to rework this script to work more like wings3d camera?
// Author: Paul Franz (paul@paulfranz.com)
// Date: February 11, 2004
// Description: suggested by a Wings3d user
// a UI with shortcuts to XYZ and and orth toggle
//
// If ya wanna use or modify it (in other
// scripts), i dont really care. Just let me know.
// xyzCam.mel START
global proc xyzCam()
{
string $win = "xyzCam";
string $cam = "persp";
if (`window -exists $win`)
deleteUI $win;
window -t "XYZ" $win;
columnLayout -adj true;
button -l "X camera" -c ("xyzMoveCam(\"x\", \"" + $cam + "\")") xButton;
button -l "Y camera" -c ("xyzMoveCam(\"y\", \"" + $cam + "\")") yButton;
button -l "Z camera" -c ("xyzMoveCam(\"z\", \"" + $cam + "\")") zButton;
checkBox -onc ("camera -e -o 1 " + $cam) -ofc ("camera -e -o 0 " + $cam) -l "Orthographic";
showWindow $win;
}
global proc xyzMoveCam(string $dir, string $cam){
float $camTrans[] = `xform -q -t persp`;
float $camRot[] = `xform -q -ro persp`;
float $distAway = 25;
switch ($dir) {
case "x":
xform -t $distAway 0 0 -ro 0 90 0 $cam;
break;
case "y":
xform -t 0 $distAway 0 -ro -90 0 0 $cam;
break;
case "z":
xform -t 0 0 $distAway -ro 0 0 0 $cam;
break;
}
camera -e -wci 0 0 0 $cam;
}
xyzCam();
// xyzCam.mel END
|
|
DanNeufeldt
08-26-2004, 07:55 PM
sorry, i posted something not like what you were looking for. What was the problem with the script, I ran it and it seemed to work fine. Did you want the grid to show up in the ortho views?
Levitateme
08-26-2004, 09:35 PM
well its like this. in wings 3d if you go to side view the persp camera goes there, and if your camera is at
-t 0 37 0
then go to front view your cameras translation are
-t 0 37 0
the problem this script does is it always goes to the same posistion, the only thing that should be happening is the camera rotating instead it moves the camera...maybe you would have to see wings3d camera work in action. but its the best imo, and like i said thats the only real problem i have with the script.
DanNeufeldt
08-26-2004, 10:23 PM
ok, this isn't exactly what you want, but its similar
{
string $windowName = "djnCamButtons";
if (`window -exists $windowName`) deleteUI $windowName;
window -t "Quick Camera Switch" -tlb 1 $windowName;
int $w = 30;
int $h = 50;
rowColumnLayout -nc 4 -cw 1 $w -cw 2 $w -cw 3 $w -cw 4 $w;
button -l "P" -c "lookThru persp";
button -l "X" -c "lookThru side";
button -l "Y" -c "lookThru top";
button -l "Z" -c "lookThru front";
setParent..;
window -e -wh ($w * 4 + 8) 45 $windowName;
showWindow $windowName;
}
The main problem is that this one is just switching cameras.
I'd like to get a script working for you, but I need to finish up something I'm doing here first. I can probably have one for you a little later on today, if you don't mind the wait.
edit...
Actually, what I gave isn't what you want at all, sorry, a little later today I should be able to help.
Levitateme
08-27-2004, 02:31 PM
Hi dan, of course ill wait! i have been waiting for a camera script to work like wings script for about a year now! yeah please do what you gotta do that would be increible.
DanNeufeldt
08-28-2004, 03:49 AM
Hey, here's something closer. Tell me what you think, I downloaded wings and I think I know what you mean now.
{
global proc wingsCam()
{
string $windowName = "xyzCam";
if (`window -exists $windowName`)
deleteUI $windowName;
window -t "wingsCam" $windowName;
columnLayout -adj true;
button -l "X camera" -c "wingsCamMove x";
button -l "Y camera" -c "wingsCamMove y";
button -l "Z camera" -c "wingsCamMove z";
checkBox -onc "wingsCamTglOrtho 1" -ofc "wingsCamTglOrtho 0" -l "Orthographic";
// edit the buttons
setParent..;
showWindow $windowName;
}
global proc wingsCamTglOrtho(int $on)
{
string $camera = `lookThru -q`;
camera -e -o $on $camera;
}
global proc wingsCamMove(string $axis)
{
string $camera = `lookThru -q`;
float $t[] = `xform -q -t persp`;
float $r[] = `xform -q -ro persp`;
float $c[] = `camera -q -wci $camera`;
vector $tr = <<$t[0], $t[1], $t[2]>>;
vector $ct = <<$c[0], $c[1], $c[2]>>;
print $ct;
print "\n";
float $d = mag($tr - $ct);
switch ($axis)
{
case "x":
camera -e -p (($c[0] + $d) * -1) $c[1] $c[2] $camera;
camera -e -rot 0 -90 0 $camera;
break;
case "y":
camera -e -p $c[0] (($c[1] + $d) * -1) $c[2] $camera;
camera -e -rot 90 0 0 $camera;
break;
case "z":
camera -e -p $c[0] $c[1] ($c[2] + $d) $camera;
camera -e -rot 0 0 0 $camera;
break;
default:
break;
}
}
wingsCam;
}
Right now it's retaining the camera's point of interest. That seems to change a lot more in Maya than in Wings, so it can lead to some odd behavior, but selecting your object and hitting "f" fixes it.
wrend
08-28-2004, 09:22 AM
i'd find this of value too, so i had a look also. upon comparison, i did pretty much exactly the same as dan, but in order to keep the centre of interest after transforming the camera around you need to reset it to its original, querried location. as a side note, you can querry the distance of centre of interest from camera by querying the same named attribute on the camera.
we wont be able to perfectly emulate the wings approach, quite simply because it has a different camera model than maya (it appears to rotate world around the last focus point). so whlst we may be able to achieve the same framing (which i like), we wont be able to retain how you rotate/tumble out, which would be quite distracting i think. what we have is pretty good. as an addition, it might be worth adding a check to see which octant, with respect to the COI, the camera lies in and use this to determine which way the camera swings, "behind/infornt, above/below". and for those who want the grid, just toggle off the world, and on construction planes when you swap, and a scriptJob that monitors the camera's rotate, and as soon as it budges toggle them back.
Levitateme
08-28-2004, 02:45 PM
Hi dane, first i can't thank you enough for even bothering with this, because i just tried it out for about 5 min and it works imo how it works in wings. sometimes if i go to view a axis i dont see my object but wings does that as well. thanks SO much for working on this. i have one last question. my friend also did this toggle for ortho switch. now when i toggle ortho sometimes my camera JUMPS like far back or something, in wings 3d it always toggles and the camera looks as if its in the same posistion. do you know how to get around that? cause its just frustrating trying to model some faces and toggle ortho and then your zoomed out alot and have to zoom back in. does that make sense? also i dont know mel like you guys do at all, but what WREND said, is that possibel to make into the script as well? it sounds like really good ideas, just curious if you were done with this yet. thanks again.
proc string getCurrentCamera() // lifted from Maya-HowTo at www.ewertb.com (http://www.ewertb.com)
{
string $camera;
// First get the panel that currently has focus
string $panel = `getPanel -wf`;
// Compare the panel's type to confirm it is a "modelPanel"
if ( "modelPanel" == `getPanel -to $panel` )
{
// Get the name of the camera using the 377modelEditor377 command
$camera = `modelEditor -q -camera $panel`;
}
return $camera;
}
int $orthOnOff;
string $currentCam = getCurrentCamera();
if ($orthOnOff){
camera -e -o 0 $currentCam;
$orthOnOff--;
}
else{
camera -e -o 1 $currentCam;
$orthOnOff++;
}
Levitateme
08-28-2004, 02:47 PM
oops also, when i go to Y it goes underneath my grid , i tried typing int -90 in the code and that didn't help at all.
DanNeufeldt
08-28-2004, 09:23 PM
Ok, just a small change, i fixed it to go above instead of below in Y, and fixed the ortho jump.
{
global proc wingsCam()
{
string $windowName = "xyzCam";
if (`window -exists $windowName`)
deleteUI $windowName;
window -t "wingsCam" $windowName;
columnLayout -adj true;
button -l "X camera" -c "wingsCamMove x";
button -l "Y camera" -c "wingsCamMove y";
button -l "Z camera" -c "wingsCamMove z";
checkBox -onc "wingsCamTglOrtho 1" -ofc "wingsCamTglOrtho 0" -l "Orthographic";
// edit the buttons
setParent..;
showWindow $windowName;
}
global proc wingsCamTglOrtho(int $on)
{
string $camera = `lookThru -q`;
float $d = `camera -q -coi $camera`;
camera -e -o $on $camera;
camera -e -ow ($d + 1) $camera;
}
global proc wingsCamMove(string $axis)
{
string $camera = `lookThru -q`;
float $t[] = `xform -q -t persp`;
float $r[] = `xform -q -ro persp`;
float $c[] = `camera -q -wci $camera`;
float $d = `camera -q -coi $camera`;
switch ($axis)
{
case "x":
camera -e -p (($c[0] + $d) * -1) $c[1] $c[2] $camera;
camera -e -rot 0 -90 0 $camera;
camera -e -wci $c[0] $c[1] $c[2] $camera;
break;
case "y":
camera -e -p $c[0] (($c[1] + $d)) $c[2] $camera;
camera -e -rot -90 0 0 $camera;
camera -e -wci $c[0] $c[1] $c[2] $camera;
break;
case "z":
camera -e -p $c[0] $c[1] ($c[2] + $d) $camera;
camera -e -rot 0 0 0 $camera;
camera -e -wci $c[0] $c[1] $c[2] $camera;
break;
default:
break;
}
}
wingsCam;
}
it might be worth adding a check to see which octant, with respect to the COI, the camera lies in and use this to determine which way the camera swings, "behind/infornt, above/below".I agree, that would be very useful. I'm working on a couple other things right now, but I'll try and add that functionality in a little later.
wrend
08-29-2004, 02:13 AM
i got pretty keen to matching wings' framing, it makes some kinda aesthetic sense to me. my comments above about losing the COI being distracting hasnt proved to be the case. the peculair thing about this method is that it centres about the last framing/fousing point ...which just seems to give a great response, but is fairly dependent on your camera usage and selection framing, if you wong your camera all about the place and frame infrequently, then you'll probably find this style not as predictable as the other, COI based approach. try both and see what you liek i guess.
ive added the +/- choice for whether you go infront/behind, above/below (so one up on wings, heh :)), and optional reference planes.
if you dont read the usage notes, you'll be lost.
/*
edit - schnipp.
kripes, i havent been exercising this script, but sitting down to it now, there are some serrious undo problems. it performs the functionality correctly, but as always you have undo problems when you try to build practically any form of scripted dynamic interactivity within maya. i've sorted most of it out, but i need to spend a day using it normally (ie not happy tidy dev enviroment) before i post a revision. appologies for any hassels this might have caused to anyone who tried it. :blush:
*/
cheers, c.
Levitateme
09-13-2004, 05:03 PM
so wrend, your script is meant to replace the F key? is that what i do to get yours working? i have been wanting to try yours for some time now. but i never could get it to work right. also are you going to share us with your virtual mirror script?
wrend
09-14-2004, 01:06 AM
partially, yes (its more of an augmentation than a replacement). how did you go following the instructions? which bit didnt you understand.
as for the virtual mirror, there are a couple of things i still want to sort out before i release it, which i havent got round to. realise that this script only aims to replicate the wings behaviour of the vertices being constrained to the mirror plane, which in this case is only done for the world orthogs (though you can generalise it if you want).
CGTalk Moderation
01-19-2006, 12:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.