Re: [Maya2osg-users] Discussion of next changes
Status: Alpha
Brought to you by:
jtaibo
From: Javier T. <jav...@gm...> - 2011-05-26 14:57:46
|
Hi J-S, On Thu, May 26, 2011 at 3:27 PM, Jean-Sébastien Guay <jea...@cm...> wrote: > Hi Javier, > >> You can create the attributes editable or visible as you need. This >> avoid users to touch them, even see them (though seeing them should be >> useful for debugging, and artists still can't break anything) > > OK, I'll have a look. Can you give me an example of how to create an > attribute? Through scripting I assume... And then in Maya where will I > see this attribute? And in the C++ plugin code? OK. Let's say you want to create new attributes to a node. First, select the node. If it is a Maya material (e.g. lambert1), for instance, and you have selected its tab in the Attribute Editor and push the button "Select". This way you have selected the material node and not the geometry you first selected. In the Attribute Editor menu, select "Attributes" > "Add Attribute". This opens a dialog where you must select at least the attribute name and the data type. The newly created attribute appears at the end in the section "Extra Attributes". This is the manual way to create attributes. Now let's see how can we make it from MEL. Open the Script Editor and take a look at the MEL attributes that were called to create the attribute (addAttr and setAttr). This is a good place to learn how things are done in MEL (apart from reading documentation). If you want to see more verbosity go to the menu "History" and check the option "Echo all commands", but for the attribute creation, it shouldn't be necessary. If you want to hide the attribute, specify "-hidden" parameter to "addAttr" and if you want to make it not editable, specify "-lock" to setAttr. You can use getAttr to access the attribute values. For more information about addAttr, setAttr and getAttr syntax, check the documentation (F1) at the end, in section "Technical Documentation" -> "Commands". From C++ you can access the attributes with the plug interface (see MPlug and MFnDependencyNode classes in C++ API documentation). You can see several examples of this along the Maya2OSG code. For instance, take a look at particle.cpp to see how attributes like "lifespan" are accessed: MObject obj; // this is the Maya node MFnDependencyNode dnodefn(obj); MStatus status; MPlug lifespan = dnodefn.findPlug("lifespan", &status); float ls = lifespan.asFloat(); Hope that helps. >> I am wondering... is the way you export materials and treat them in >> your engine incompatible with Maya2OSG exported GLSL shaders? > > Yes, we use our own shaders which do special things (for example, we use > defines for number and types of lights, which allows us to do per-pixel > lighting even on older cards). Also, we need to support various > hardware, so we cannot guarantee that a given shader will always work > for us, and so putting shaders in the .osg file directly is not a good > idea for us. Yes, this is a difficult issue. Shaders are very system dependent. Regards. -- Javier Taibo |