PDA

View Full Version : Problems with scripting >.<


stupidvampire
10-05-2008, 07:05 PM
Ok first off. I'm a scripting n00b. I'm trying to create a script that will allow me to take an object, create multiple instances depending on the number of uv's the user has input, and then attach those instances to another object at the uv location. This is what I have so far:

//Procedures//

global proc XYZ_moveOnObject()
{
//generate U and V values based on Float sliders
float $U = `floatSliderGrp -q -value countObjectsU`;
float $V = `floatSliderGrp -q -value countObjectsV`;


//use pointOnSurface command to retrieve XYZ Worldspace coordinates
float $coordsXYZ[] = `pointOnSurface -u $U -v $V -position`;

move -ws $coordsXYZ[0] $coordsXYZ[1] $coordsXYZ[2];
}

global proc setTxFld()
{
string $myTextField = "textFieldName";
string $sel[] = `ls -sl`;
textFieldButtonGrp -e -tx $sel[0] $myTextField;
}

global proc setTxFld2()
{
string $myTextField2 = "textFieldName2";
string $sel[] = `ls -sl`;
textFieldButtonGrp -e -tx $sel[0] $myTextField2;
}

//Interface//


string $window = `window -title "JJFeatherSystem" -widthHeight 500 200 -s 0 -rtf 1`;
if (`window -exists $window`)
{ deleteUI -window $window; }
string $window = `window -title "JJFeatherSystem" -widthHeight 500 200 -s 0 -rtf 1`;


columnLayout -columnAttach "both" 10 -cw 500;

$TextFieldInst = `textFieldButtonGrp
-label "Instance :"
-text "Default"
-buttonLabel "set"
-bc setTxFld textFieldName`;

$TextFieldObj = `textFieldButtonGrp
-label "Object :"
-text "Default"
-buttonLabel "set"
-bc setTxFld2 textFieldName2`;

floatSliderGrp -label "U" -field true
-minValue -0 -maxValue 100.0
-fieldMinValue 2.0 -fieldMaxValue 100.0
-value 10 countObjectsU;
floatSliderGrp -label "V" -field true
-minValue -0 -maxValue 100.0
-fieldMinValue 2.0 -fieldMaxValue 100.0
-value 10 countObjectsV;

button -label "Instance and Orient" -c XYZ_moveOnObject;

showWindow $window;

////////////////////////

Any suggestions would be greatly appriciated, cause I'm stumped as to where to go from here. Thank you!

sabathyus
10-06-2008, 03:11 AM
create a hair follicule. Delete the useless stuff and keep the follicule node - it contains a U and V attribute that you can slide along a surface.
OR
You could also use a pointOnSurface node for translate info like you're doing, but you'll need to use something to orient and rotate it to the surface. Look into the information built into the normal constraint or perhaps the rotateHelper plugin in the plugin manager.

While you're at it look at the closestPointOnSurface node for fun and possible future use.

I'd explain these better but I'm in a rush :(

CGTalk Moderation
10-06-2008, 03:11 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.