PDA

View Full Version : Getting starting MEL UI design: Quick questions


lxdengar
05-10-2007, 07:46 PM
Hi All,

I tried looking through the forum before I asked these questions, but couldn't find the answer to my question. I appreciate the help.

I have a UI built, which creates and manipulates particle systems (changes amount, speed, adds fields etc). I have a delete button which correctly deletes the emitter and various systems, and rather than have the user close the window to recreate the system, I added a button for it.

The new system gets correctly created from my main proceedure, but the window values/sliders in the dialog window remained greyed out. Despite the system nodes being named the same, it looks like window doesn't recognize the new system. Closing the window and calling it again allows the system to be manipulated! I assume this is just a window refresh, but I can find anything in the mel reference about doing this.

***

Secondly, I'd like the user to be able to pick a mesh to emit particles from, and using size() and a selection array I can limit the selection to one object, but is there a way to test what kind of object it is? I assume that many, many people have done this before, so I was curious if anyone could point in the right direction. I did find

if (`nodeType ($item)` == "mesh")

But I'm sure there's more i could be checking.

Thanks for the help!

Buexe
05-10-2007, 11:33 PM
Usually when I create controls they are enabled by default, do you have any flag that disables them, like "-en 0" or something like that? And by whic hmechanism do you bind the controls to the node`s attributes. Maybe you could give an example of how you create the control and attach it to the node`s attributes to check your problem.

The other thing with testing nodes is, that you can use nodeType to get the exact type of node, but remember that some "objects" like a polyMesh consist of a transform and a shape node, so to see which kind of object you deal with in this situation probably the nodeType command on the shape node is the better choice.
Hope this helps

lxdengar
05-11-2007, 01:46 AM
Usually when I create controls they are enabled by default, do you have any flag that disables them, like "-en 0" or something like that? And by whic hmechanism do you bind the controls to the node`s attributes. Maybe you could give an example of how you create the control and attach it to the node`s attributes to check your problem.


Thanks - no, no '-en 0' specific controls. Essentially, the window immediately calls a 'check' function which checks to see if the particle system exists (which consists of a particle object, and emitter, and an object from which to emit from):

global proc Check()
{
global string $Pshape[];
global string $ParticleObj[];

if (`particleExists $Pshape[0]` == 1)
{
print "Found existing Particle system.\n";
select $ParticleObj[0];
getPSAttr();
}
else if (`particleExists $Pshape[0]` == 0)
{
createPS();
}
}

The getPSAttr call goes and gets the attributes custom ones, and returns the shape[0], the Plane[0], and the Emit[0] objects. CreatePS goes and creates a new system, and then calls the getPSAttr function again, to get the custom values again. These are Per-Particle attributes like Speed, visibility, Opacity, etc.

I have a delete button, which deletes all of the objects above; a create button puts them back (calls createPS). The system gets created again, but the values in my sliders and fields remain grey.
Again, simply closing the window and calling showWindow again makes all the fields and sliders live!

the window creation sliders look something like this:

floatSliderGrp
-label "Particle Rate" -field true -cw 1 115
-value 10 -minValue 0 -maxValue 100 -step 1
-fieldMinValue 0 -fieldMaxValue 10000
PRate;

and one of the getPSAttr calls looks like this:

getAttr ($PEmit[0] + ".rate");

I'm sure its something simple, but I don't know what I'm missing. The fields go grey the moment I hit delete.

As for the nodetype command - is there an easy way to have it check the shape node?

Thanks for the help!

Buexe
05-12-2007, 11:49 AM
I think that once you want the control to control a new node and it`s attribute you simply have to use the edit mode ( -e ) to tell the control. Check this:

window -title "Attr Field Slider Groups";
string $objName[] = `sphere`;
columnLayout;

// I use a global string here so that it can be read by other procedures
global string $myAttrCtrl;
$myAttrCtrl = `attrFieldSliderGrp -min -10.0 -max 10.0 -at ($objName[0]+".tx")`;
showWindow;

// This deletes the object and the control gets greyed out
delete $objName[0]

// Create a new object
string $newObject[] = `polyCube`;

// Attach the control to the node and some attribute ( note the -e flag)
attrFieldSliderGrp -e -min -10.0 -max 10.0 -at ($newObject[0]+".tx") $myAttrCtrl;

I hope this helps

CGTalk Moderation
05-12-2007, 11:49 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.