SimplyMaya
Community
The SimplyMaya Forums
View all Forums
A place you can ask or answer VFX related questions
Latest forum posts
how to clean up?
Can't find save file
Manipulator axis orientation
Older Maya files
Cannot duplicate layered texture node
Strange Issue Accessing this site
News and articles
News & Articles
Vfx related news and articles
Random news
Webinar: Making Maya Easier to Use
Texture collaboration system (Coming Soon)
Upload or Download textures
A place to download great textures or share your own with the community
Legacy Resources
Latest uploads to our system
View new Posts
Edit your profile
View threads your subscribed to
User control panel
Training
Maya Training and Tutorials
View all training
View hundreds of hours of Maya training online or via download
Looking for something specific?
Focus on Archviz & Environments
Focus on Organics
Focus on Hard Surface
Focus on Lighting, Rendering & Texturing
Focus on Dynamics, Rigging & Animation
Post Production
Training options on SimplyMaya
Current member status:
Not logged in
Create Account
Pick a streaming payment plan
We offer several different subscription options for our online training
Try streaming for free
Watch up-to three hours of training over a 10 day period for free
Buy training for download
Choose the content you want and buy it outright, downloads don't expire and you can keep them for as long as you'd like
Latest training
Integrating 3D models with photography
Substance Painter 2017
Complex UV Layout in Maya 2018
Training you might like
Burt The Cartoon Dinosaur Vol 1 - Modeling
Complex UV Layout in Maya
If you want to ask a SimplyMaya training related question use this forum:
SimplyMaya tutorials
Create Account
Sign in
Username
Password
Sign in
Forgot Password?
SimplyMaya Forums
Welcome to the forum, feel free to ask questions here.
SM Forums
/
Maya Questions
/
Programming
/ Camera setup script finished..enjoy
Register
FAQ
Calendar
Mark Forums Read
Programming
MEL Scripts, Expressions & Programming Related Topics
Join the conversation. Reply to post
Thread Tools
25-10-2005, 07:41 PM
#
1
Grayth
Subscriber
Join Date: Oct 2003
Location: Brantford Ontario Canada
Posts: 43
Camera setup script finished..enjoy
here's a script I've been working on. It'll make camera animation alot easier. Some people have helped me create it when I got stuck on the coding, so if you like it use it.
What it will do is create a number of cameras with a name ou provide and create group transforms so you can animate easily for each transform node, as I lock out the non editable/animatable transforms you don't want..
here's the code...
//This script is inspired from Eric Hanson's Digital Sets DVd's
//Many thanks to alot of folks on cgtalk
//especially Andrew, aka Westimad and Robert Bateman
//Please distribute this script freely
global proc Procam()
{
//variable creation here
string $grp1 = "XYZ_Trans";
string $grp2 = "YRot_Pan";
string $grp3 = "XRot_Tilt";
string $grp4 = "ZRot_Roll";
string $winName = "ProCam";
string $camnode = "1NodeCam";
string $camnode2 = "2NodeCam";
string $camnode3 = "3NodeCam";
//window check
if(`window -exists $winName`)
deleteUI -window $winName;
windowPref -remove $winName;
//window creation Layout here
string $myWindow= `window -title "Pro Camera Setup"
-w 260 -h 185 -s 0 -mnb 0 -mxb 0
$winName`;
//Main window Controls
string $form = `formLayout -nd 260 myform`;
string $labl= `text -label "Camera Name"`;
string $cameraName = `textField -w 150 Newname`;
string $sep =`separator -st "single" -w 225 divider`;
string $checka = `checkBox -l $camnode onenode`;
string $checkb = `checkBox -l $camnode2 twonode`;
string $checkc = `checkBox -l $camnode3 threenode`;
string $butn = `button -label "Create Camera" -c "Values" mybutton`;
//embedded form layout here
string $newform =`frameLayout -l "Select Editable Nodes" -w 225 -h 65 -p myform
-la "top" -bs "etchedIn"
-cll 0 -cl 0 embedform`;
//child of embededform Controls
string $form1 =`formLayout -nd 225 -p embedform nodeform`;
string $check1 = `checkBox -l $grp1 xyztrans`;
string $check2 = `checkBox -l $grp2 yrot`;
string $check3 = `checkBox -l $grp3 xrot`;
string $check4 = `checkBox -l $grp4 zrot`;
//Layout for embeded form Controls here
formLayout -e -af $check1 "top" 8
-af $check1 "left" 15
-af $check2 "top" 24
-af $check2 "left" 15
-af $check3 "top" 8
-af $check3 "left" 135
-af $check4 "top" 24
-af $check4 "left" 135 nodeform;
//layout for main window Controls here
formLayout -e -af $labl "top" 10
-af $labl "left" 10
-af $cameraName "top" 7
-af $cameraName "left" 85
-af $checka "top" 35
-af $checka "left" 10
-af $checkb "top" 35
-af $checkb "left" 90
-af $checkc "top" 35
-af $checkc "left" 170
-af $sep "top" 55
-af $sep "left" 11
-af $newform "top" 60
-af $newform "left" 11
-af $butn "top" 130
-af $butn "left" 75 myform;
showWindow $winName;
}
//procedure to query all the values from the window
//and run tests for error messages
global proc Values()
{
//variable Creation
string $grp1 = "XYZ_Trans";
string $grp2 = "YRot_Pan";
string $grp3 = "XRot_Tilt";
string $grp4 = "ZRot_Roll";
//query the values of the controls from main form
string $CamName = `textField -q -tx Newname`;
string $xyz = `checkBox -q -v xyztrans`;
string $yrotate = `checkBox -q -v yrot`;
string $xrotate = `checkBox -q -v xrot`;
string $zrotate = `checkBox -q -v zrot`;
int $node1 = `checkBox -q -v onenode`;
int $node2 = `checkBox -q -v twonode`;
int $node3 = `checkBox -q -v threenode`;
//check for error messages
if($CamName == "")
error "You forgot to give the Camera a name";
int $totalnode = $node1 + $node2 + $node3;
if($totalnode <1)
error "You didn't select a Camera Type";
if($totalnode >1)
error "You selected more than one Camera Type";
string $editnode = $xyz + $yrotate + $xrotate + $zrotate;
if($editnode =="0000")
error "You didn't select any Editable Nodes";
//camera creation statements
string $attrsToLock[] = {"tx","ty","tz","sx","sy","sz","rx","ry","rz"};
if ($node1 ==1)
camnode($CamName,1,$attrsToLock);
if ($node2 ==1)
camnode($CamName,2,$attrsToLock);
if ($node3 ==1)
camnode($CamName,3,$attrsToLock);
//selecting the top node in hypergraph
select -r $CamName;
pickWalk -d up;
//setting attrib of the zrot node
if ($zrotate =="1")
zrot($grp4);
//setting attrib of the xrot node
if ($xrotate =="1")
xrot($grp3);
//setting attrib of the yrot node
if ($yrotate =="1")
yrot($grp2);
//setting attrib of the xyz translate node
if ($xyz =="1")
xyztrans($grp1);
}
//creation procedure for the cameras
global proc camnode(string $CamName,int $val,string $attrsToLock[])
{
camera -centerOfInterest 5 -focalLength 35 -lensSqueezeRatio 1 -cameraScale 1 -horizontalFilmAperture 1.41732 -horizontalFilmOffset 0 -verticalFilmAperture 0.94488 -verticalFilmOffset 0 -filmFit Fill -overscan 1 -motionBlur 0 -shutterAngle 144 -nearClipPlane 0.01 -farClipPlane 1000 -orthographic 0 -orthographicWidth 30;
cameraMakeNode $val "";
rename $CamName;
doLockAttrs($CamName,$attrsToLock);
}
//procedure to lock out the camera transforms
global proc doLockAttrs(string $CamName, string $attrsToLock[])
{
for( $attr in $attrsToLock )
setAttr -lock true ($CamName +"." + $attr);
}
//procedure for the zrotate node
global proc zrot(string $grp4)
{
group -name $grp4; xform -os -piv 0 0 0;
string $groupname = $grp4;
string $attrsToLock[] = {"tx","ty","tz","sx","sy","sz","rx","ry","v"};
dogroupLock($groupname,$attrsToLock);
}
//procedure for the xrotate node
global proc xrot(string $grp3)
{
group -name $grp3; xform -os -piv 0 0 0;
string $groupname = $grp3;
string $attrsToLock[] = {"tx","ty","tz","sx","sy","sz","ry","rz","v"};
dogroupLock($groupname,$attrsToLock);
}
//procedure for the yrotate node
global proc yrot(string $grp2)
{
group -name $grp2; xform -os -piv 0 0 0;
string $groupname = $grp2;
string $attrsToLock[] = {"tx","ty","tz","sx","sy","sz","rx","rz","v"};
dogroupLock($groupname,$attrsToLock);
}
//procedure for the xyz translate node
global proc xyztrans(string $grp1)
{
group -name $grp1; xform -os -piv 0 0 0;
string $groupname = $grp1;
string $attrsToLock[] = {"sx","sy","sz","rx","ry","rz","v"};
dogroupLock($groupname,$attrsToLock);
}
//procedure to lock attributes of group nodes
global proc dogroupLock(string $groupname, string $attrsToLock[])
{
for( $attr in $attrsToLock )
setAttr -lock true ($groupname +"." + $attr);
}
__________________
Think Twice Split Poly Once
Reply with quote
Grayth
View Public Profile
Find More Posts by Grayth
Reply
«
Previous Thread
|
Next Thread
»
Thread Tools
Show Printable Version
Email this Page
Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Zoom camera with image plane attached
defiant3d
Maya Basics & Newbie Lounge
0
30-01-2013
03:19 PM
changing the "Quick help" window size in the maya 2012 script editor.
Jouri
Programming
3
27-11-2011
06:15 AM
Camera setup Question.......
ieoie
Maya Basics & Newbie Lounge
2
15-01-2008
12:28 AM
Camera set up script
Grayth
Programming
0
18-10-2005
05:23 PM
camera filmback mel
olivermagno
Programming
14
07-06-2003
04:10 AM