PDA

View Full Version : user interface wonderings


Geuse
03-06-2008, 03:29 PM
Hi all. I'm in the process of rigging and I guess I'll be doing a mel scripted gui so you can execute it by hitting a shelf button, but why are gui's really needed? Can't you just as well select manually?
For gui's, is there a way to save it with your scene file or should i simply place it into a shelf labeled my character. also, should this mel script be a global procedure or should i just paste the code to a shelf and send this shelf with the character scene file to whomever will be animating.


When it comes to rigging controls. Do you prefer to have them in a layer so you can hide them from there or to have an attribute on the rig to show or hide them.
Cause I can see there could be quite some layers when animating your character in a big scene so maybe you'd want to have as few layers as possible to keep track?


Well that's it for now I guess. Appreciate u sharing thoughts, ideas, and advices!

JohnPark
03-06-2008, 05:44 PM
The best people to ask are your animators. We tend to have ours split down the middle; half like a GUI and half like on-screen selection.

If you do make a GUI, saving it with the scene is pretty convenient. Check out AttributeCollection (comes with the "Bonus Tools") to see one way of doing it.

I do think it's a good idea to place your on-screen controls on their own layer, or provide some other way (a button on your GUI) to toggle them on and off. A quick and dirty way is to make all of your on-screen controls out of NURBS curves, so that turning off the camera viewport's display of curves will effectively hide them. You're right, having to dig through layers turning them off one-by-one if the scene has a bunch of characters in it is a bit of a pain.

-JP

mberglund
03-06-2008, 09:03 PM
Also If you are setting up more advanced Ik/Fk switching you’re going to need a Gui to fire off some mel commands. It's almost essential if you want the switching to be in the background to animator and have the ik snap to fk and vice versa.

Geuse
03-07-2008, 12:09 AM
All right. thank you both very much. I get it a little bit clearer now. So I guess I'll start writing a gui and put it in the expression so it fires up when the scene file is opened, but if I close it how should I execute it again without having to write the command for it and without creating a shelf button since you can't save shelves with your scene file? And there is no idea in using the channel box using an enum to open or close it cause you can't execute scripts from there, right?

mberglund
03-07-2008, 02:37 PM
Not that I know of...

Geuse
03-07-2008, 06:35 PM
Actually, I got it working as I wanted. If you'd be interested here's the code for it so it fires up when selecting an object you've named "ui_openwin". I created a text curve named UI which is parented to my character's "COG_ctrl". It's all placed inside the expression editor in a single code. I'm still new to this as you know so the tabs don't display as they should, I want them to extend to the whole view around them so there ought to be some command I don't know of. Also on the radio buttons I'd like to know if you can customize it, maybe push them together, cause there is no point in having them that much space between. Also how do you set a predefined mark in one of the radio buttons so when starting the script the character's mesh is already hidden.

The buttons are just for placeholders. Will be a picture of the body and the face with the controls marked out so it's easily selected and also some advanced ik fk matching switches etc. Also, I encontered when selecting "ui_openwin" object that the screen flashes for some seconds after a while when continue selecting the object to fire off the command. Not sure how to approach this since it still works, just seems there's something buggy? Yeah, there's a bunch of things concerning the interface code which I don't fully understand how to customize, for instance if you can set the top panel to be one size and not scale out with the view.

Well that's it for now, now I'm gonna get my belly filled up with pizza!
I sincerely appreciate your thought, inputs, comments so keeep 'em coming!
Au revoir!

if (`window -exists CharacterWinAdv`) deleteUI
CharacterWinAdv;
window -t "Character Controls"
CharacterWinAdv;

//This creates a large top panel, and a small bottom panel:

paneLayout -configuration "horizontal2" -paneSize 1 100 20
TopPanels;


setParent TopPanels;
columnLayout;
frameLayout -w 1000 -h 1000 -l "Visibility" -cll true -cl
false -bs "out";
columnLayout;

checkBoxGrp -l "Show Face Rig"
-onCommand "setAttr face_rig_ui.v 1"
-offCommand "setAttr face_rig_ui.v 0";

checkBoxGrp -l "Show Body Rig"
-onCommand "setAttr face_rig_ui.v 1"
-offCommand "setAttr face_rig_ui.v 0";

checkBoxGrp -l "Show Stand-In Geometry"
-onCommand "setAttr stand_in_geometry.v 1"
-offCommand "setAttr stand_in_geometry.v 0";

separator -width 1000 -horizontal 1;

radioButtonGrp -cal 1 left -numberOfRadioButtons 3 -l "Character Visibility"
-labelArray3 "Show" "Template" "Hide"

-on1 {"setAttr skin.v 1; toggle -state off -template rig"}
-on2 {"setAttr skin.v 1; toggle -state on -template rig"}
-on3 {"setAttr skin.v 0; toggle -state off -template rig"}
;


setParent TopPanels;


//create the tabs

scrollLayout;

string $form = `formLayout`;
string $tabs = `tabLayout -innerMarginWidth 5 -innerMarginHeight 5`;
formLayout -edit

-attachForm $tabs "top" 0
-attachForm $tabs "left" 0
-attachForm $tabs "bottom" 0
-attachForm $tabs "right" 0

$form;


//create content of first tab:


string $tabcontent1 = `columnLayout`;

setParent..;
setParent..;

//create content of second tab:


string $tabcontent2 = `columnLayout`;

if (`window -exists CharacterWinAdv`) deleteUI
CharacterWinAdv;
window -t "Character Controls"
CharacterWinAdv;

//This creates a large top panel, and a small bottom panel:

paneLayout -configuration "horizontal2" -paneSize 1 100 20
TopPanels;


setParent TopPanels;
columnLayout;
frameLayout -w 1000 -h 1000 -l "Visibility" -cll true -cl
false -bs "out";
columnLayout;

checkBoxGrp -l "Show Face Rig"
-onCommand "setAttr face_rig_ui.v 1"
-offCommand "setAttr face_rig_ui.v 0";

checkBoxGrp -l "Show Body Rig"
-onCommand "setAttr face_rig_ui.v 1"
-offCommand "setAttr face_rig_ui.v 0";

checkBoxGrp -l "Show Stand-In Geometry"
-onCommand "setAttr stand_in_geometry.v 1"
-offCommand "setAttr stand_in_geometry.v 0";

separator -width 1000 -horizontal 1;

radioButtonGrp -cal 1 left -numberOfRadioButtons 3 -l "Character Visibility"
-labelArray3 "Show" "Template" "Hide"

-on1 {"setAttr skin.v 1; toggle -state off -template rig"}
-on2 {"setAttr skin.v 1; toggle -state on -template rig"}
-on3 {"setAttr skin.v 0; toggle -state off -template rig"}
;


setParent TopPanels;


//create the tabs

scrollLayout;

string $form = `formLayout`;
string $tabs = `tabLayout -innerMarginWidth 5 -innerMarginHeight 5`;
formLayout -edit

-attachForm $tabs "top" 0
-attachForm $tabs "left" 0
-attachForm $tabs "bottom" 0
-attachForm $tabs "right" 0

$form;


//create content of first tab:


string $tabcontent1 = `columnLayout`;

setParent..;
setParent..;

//create content of second tab:


string $tabcontent2 = `columnLayout`;

if (`window -exists CharacterWinAdv`) deleteUI
CharacterWinAdv;
window -t "Character Controls"
CharacterWinAdv;

//This creates a large top panel, and a small bottom panel:

paneLayout -configuration "horizontal2" -paneSize 1 100 20
TopPanels;


setParent TopPanels;
columnLayout;
frameLayout -w 1000 -h 1000 -l "Visibility" -cll true -cl
false -bs "out";
columnLayout;

checkBoxGrp -l "Hide Face Rig"
-onCommand "setAttr face_rig_ui.v 0"
-offCommand "setAttr face_rig_ui.v 1";

checkBoxGrp -l "Hide Body Rig"
-onCommand "setAttr face_rig_ui.v 0"
-offCommand "setAttr face_rig_ui.v 1";

checkBoxGrp -l "Hide Stand-In Geometry"
-onCommand "setAttr stand_in_geometry.v 0"
-offCommand "setAttr stand_in_geometry.v 1";

separator -width 1000 -horizontal 1;

radioButtonGrp -cal 1 left -numberOfRadioButtons 3 -l "Character Visibility"
-labelArray3 "Show" "Template" "Hide"

-on1 {"setAttr skin.v 1; toggle -state off -template rig"}
-on2 {"setAttr skin.v 1; toggle -state on -template rig"}
-on3 {"setAttr skin.v 0; toggle -state off -template rig"}
;


setParent TopPanels;


//create the tabs

scrollLayout;

string $form = `formLayout`;
string $tabs = `tabLayout -innerMarginWidth 5 -innerMarginHeight 5`;
formLayout -edit

-attachForm $tabs "top" 0
-attachForm $tabs "left" 0
-attachForm $tabs "bottom" 0
-attachForm $tabs "right" 0

$form;

//This creates the content of the first tab:
string $child1 = `rowColumnLayout -numberOfColumns 3`;

checkBox -label "Show Skin" -align left
-onCommand
"setAttr alien_cowboy_body.v 1"
-offCommand
"setAttr alien_cowboy_body.v 0"



button; button; button;
setParent..;





//This creates the content of the second tab:
string $child2 = `rowColumnLayout -numberOfColumns 2`;

checkBox -label "Show Face UI" -align left
-onCommand
"setAttr alien_cowboy_facial_ui.v 1"
-offCommand
"setAttr alien_cowboy_facial_ui.v 0"

button; button; button;


setParent..;




//This edits the tabLayout command to label each tab:

tabLayout -edit

-tabLabel $child1 "Body"
-tabLabel $child2 "Face"
$tabs;


//second panel
setParent TopPanels;



window -edit -wh 480 450 -topLeftCorner 200 1200
CharacterWinAdv;

showWindow;

Geuse
03-08-2008, 04:01 PM
Actually I got most of it under control for now, but I can't seem to find where to set the predefined setting for the radio buttons. As I want the show to be on by default. However when opening the UI up they are all marked off and the skin is shown as I want it to be so I just settle with that for now.

Also by deleting the scrollLayout in the tabs it would be displayed as intended.

Now all I need is to incorporate a picture and html coding to select the controls with using this guide. http://www.rvancleave.com/tutorials/imageMapGUI.htm

Wish me luck!
I'm unsure if I should put it all in one single expression or should I divide it into several?
Suggestions appreciated.

Geuse
03-10-2008, 02:32 PM
I encountered a number of errors when following that guide. Somehow I must be doing something wrong, but I can't see what. I'd be most grateful if someone could take the some of their precious time to have a look at it.

I'll post the mel-code with the gui image and the html-file.


http://img2.putfile.com/thumb/3/6909291819.jpg (http://www.putfile.com/pic/7802931)


global proc RingoGUI ()
{
//loads the GUI

//declare global variables to hold namespace & file location
global string $RingoNameSpace;
global string $RingoGUIlocation;

string $chNode = "Ringo_all_anim"; //unique name of character's "Top Node"

//check for namespace
if (!(`objExists ($RingoNameSpace + $chNode)`))
RingogetNameSpace

//check for file location
if ($RingoGUIlocation == "")
RingoLocateGUI;
else
RingoGUIWin;

}





global proc RingoGUIWin ()
{
//builds the GUI window

global string $RingoGUIlocation;

//delete's the GUI window if it's already open
if (`window -exists "RingoGUI"`)
deleteUI "RingoGUI";

window -t "Ringo GUI" -w 300 -h 400 -rtf 1 "RingoGUI";

columnLayout -w 300
panelLayout -w 300 -h 400;
//width and height should match image
webBrowser -width 300 -height 400 -url ("file://" + $RingoGUIlocation);
setParent..;
setparent..;

showWindow "RingoGUI";


}








global proc RingoLocateGUI ()
{
//promts the user to locate the HTML file

//delete the window if for some crazy reason it exists
if(`window -exists "RingoFindWin"`)
deleteUI "RingoFindWin";

window -w 250 _t "Locate RingoGUI" -rtf 1 "RingoFindWin";

columnLayout -w 250;
//button calls RingoLocateFile and closes the window
button -w 250 -t "Locate RingoGUI.html"
-c "RingoLocateFile; deleteUI \"RingoFindWin\";";
setParent..;

showWindow "RingoFindWin";



}









global proc RingoLocateFile ()
{
//loads HTML file location into global variable

global string $RingoGUIlocation;

$RingoGUIlocation = `fileDialog -dm "RingoGUI.html"`;
RingoGUIWin;


}














global proc RingoGetNameSpace()
{
//finds character namespace (if present) and loads into global variavble

global string $RingoNameSpace;

string $chNode = "Ringo_all_anim"; //The unique name of the character's "top node"
string $ns;

string $lsBuffer[];
string $tokBuffer[];

if (`objExists $chNode`) //sets namespace as blank if nonamespace is present
{
$ns = "";
}

else //searches through every transform node 'til it finds the "top node"
{
$lsBuffer = `lsType "transform"`;
for ($i=0; $i<(size($lsBuffer)); $i++)
{
tokensize $lsBuffer[$i] ":" $tokBuffer;
for ($j=1; $j<(size($tokBuffer)); $j++=)

{
if ($tokBuffer [$j] == $chNode)
{
$ns = ($tokBuffer[0] + ":");
}
}
}
}
$RingoNameSpace = $ns;


}









global proc RingoSelect (string $control, int $tool)
{
//selects desired control and sets proper tool

global string $RingoNameSpace;
string $ns = $RingoNameSpace;

string $ctxMove = `manipMoveContext`;
string $ctxRot = `manipRotateContext`;

if (!(objExists ($ns + "Ringo_all_anim")`)) RingoGetNameSpace;

select -r ($ns + $control);

if ($tool == 1) setToolTO $ctxRot;
else if ($tool == 2) setToolTo $ctxMove;


}




<html>
<head>
<title>Ringo GUI
</head>
<div id="Layer1" style="position:absolute; width:300px; height:400px; z-index:1; top:0px; left:0px " >

<img src="Ringo_GUI_img.jpg" width="300" height="400" border="0" usemap="#Map" />
<map name="Map" id="Map">

<area shape="poly" coords="150,27,129,33,116,51,110,79,113,106,125,128,150,140,173,128,186,105,189,81,185,54,170,33" href="mel://Alien_Cowboy_Select("head_ctrl",1);">
<area shape="circle" coords="100,142,14" href="mel://RingoSelect(%22R_upper_shoulder_ctrl%22,1);">
<area shape="circle" coords="200,143,14" href="mel://RingoSelect(%22L_upper_shoulder_ctrl%22,1);">
<area shape="circle" coords="98,201,13" href="mel://RingoSelect(%22R_lower_shoulder_ctrl%22,1);">
<area shape="circle" coords="203,200,13" href="mel://RingoSelect(%22L_lower_shoulder_ctrl%22,1);">
<area shape="rect" coords="157,372,202,399" href="mel://RingoSelect(%22R_foot_IK_ctrl%22,1);">
<area shape="rect" coords="98,372,143,399" href="mel://RingoSelect(%22R_foot_IK_ctrl%22,1);">
<area shape="rect" coords="109,177,189,195" href="mel://RingoSelect(%22spine2_FK_ctrl%22,1);">
<area shape="rect" coords="109,203,189,224" href="mel://RingoSelect(%22spine1_FK_ctrl%22,1);">
<area shape="rect" coords="83,261,214,279" href="mel://RingoSelect(%22cog_ctrl%22,1);">
<area shape="rect" coords="99,235,197,260" href="mel://RingoSelect(%22hips_ctrl%22,1);">
<area shape="rect" coords="30,223,54,247" href="mel://RingoSelect(%22R_upper_arm_IK_ctrl%22,1);">
<area shape="rect" coords="247,223,270,246" href="mel://RingoSelect(%22L_upper_arm_IK_ctrl%22,1);">
<area shape="rect" coords="55,258,78,281" href="mel://RingoSelect(%22R_lower_arm_IK_ctrl%22,1);">
<area shape="rect" coords="222,258,244,280" href="mel://RingoSelect(%22L_lower_arm_IK_ctrl%22,1);">
<area shape="rect" coords="114,148,181,174" href="mel://RingoSelect(%22spine_offset_ctrl%22,1);">
<area shape="rect" coords="134,320,166,370" href="mel://RingoSelect(%22Alien_Cowboy_master_ctrl%22,1);">
<area shape="rect" coords="36,177,56,197" href="mel://RingoSelect(%22R_upper_arm_pole_vector_ctrl%22,1);">
<area shape="rect" coords="244,178,263,197" href="mel://RingoSelect(%22L_upper_arm_pole_vector_ctrl%22,1);">
<area shape="rect" coords="58,212,77,231" href="mel://RingoSelect(%22R_upper_arm_pole_vector_ctrl%22,1);" />
<area shape="rect" coords="222,212,242,232" href="mel://RingoSelect(%22R_upper_arm_pole_vector_ctrl%22,1);" />







<area shape="circle" coords="69,193,12" href="#" />
<area shape="circle" coords="24,257,12" href="#" />
<area shape="circle" coords="80,240,12" href="#" />
<area shape="circle" coords="60,295,12" href="#" />
<area shape="circle" coords="231,194,12" href="#" />
<area shape="circle" coords="275,257,11" href="#" />
<area shape="circle" coords="220,240,12" href="#" />
<area shape="circle" coords="240,296,12" href="#" />
<area shape="circle" coords="119,291,12" href="#" />
<area shape="circle" coords="119,324,12" href="#" />
<area shape="circle" coords="119,362,12" href="#" />
<area shape="circle" coords="181,291,12" href="#" />
<area shape="circle" coords="181,324,13" href="#" />
<area shape="circle" coords="181,361,12" href="#" />


<area shape="rect" coords="6,66,40,100" href="#" />
<area shape="rect" coords="46,66,80,100" href="#" />
<area shape="rect" coords="219,65,253,100" href="#" />
<area shape="rect" coords="260,66,294,100" href="#" />
<area shape="rect" coords="6,127,40,161" href="#" />
<area shape="rect" coords="46,127,80,161" href="#" />
<area shape="rect" coords="219,127,253,161" href="#" />
<area shape="rect" coords="260,127,293,161" href="#" />
<area shape="rect" coords="6,362,41,396" href="#" />
<area shape="rect" coords="46,362,80,396" href="#" />
<area shape="rect" coords="219,362,253,396" href="#" />
<area shape="rect" coords="260,362,294,396" href="#" />


</map>

</div>
</body>
</html>

CGTalk Moderation
03-10-2008, 02:32 PM
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.