Skocz do zawartości

joint to mesh


witjah

Rekomendowane odpowiedzi

  • Odpowiedzi 7
  • Created
  • Ostatniej odpowiedzi

Top Posters In This Topic

Top Posters In This Topic

that's simple:skończyłem własnie skinować postać, gotowy szkielet uzmysłowił mi kilka błedów na siatce, ale mesh wole poprawiać w zbrushu, dlatego przydałby mi sie wzor rigu wyrzucony do geometrii,zapięty w tle jako subtool.

Odnośnik do komentarza
Udostępnij na innych stronach

if(`window -exists "addGeoWindow"`)
deleteUI "addGeoWindow";

if(`windowPref -exists "addGeoWindow"`)
windowPref -r "addGeoWindow";

// Prepare the UI

window -rtf true -title "Add geometry to selected." addGeoWindow;
columnLayout -rowSpacing 5 addGeoControlColumn1;
	text -label "Geometry Orientation";
	separator -ann "Geometry Orientation" -w 250;
	radioCollection addGeoRadioGrp1;
	rowLayout -numberOfColumns 3 addGeoControlRow1;
			radioButton -label "+X" posX;
			radioButton -label "+Y" posY;
			radioButton -label "+Z" posZ;
	setParent ..;
	rowLayout -numberOfColumns 3 addGeoControlRow2;
			radioButton -label "-X" negX;
			radioButton -label "-Y" negY;
			radioButton -label "-Z" negZ;
	setParent ..;
	separator -w 250;
	button -c "addGeoPrep" -label "Create";
setParent ..;
showWindow addGeoWindow;

radioCollection -e -sl posX addGeoRadioGrp1;

// Preparation phase

global proc addGeoPrep(){
$sel = `ls -sl`;
string $a;
float $length;

// See if we have anything selected

if (size($sel) == 0){
	error "Select a target";
}

// Recurence trough selection

for($a in $sel){

		$child = `listRelatives -c $a`;

		if (size($child) > 0 && nodeType($child[0]) == "joint"){	// If the target is a joint calculate the length
			float $componentX = `getAttr ($child[0] + ".tx")`;
			float $componentY = `getAttr ($child[0] + ".ty")`;
			float $componentZ = `getAttr ($child[0] + ".tz")`;
			$length = `mag (>)`; 
		} else {													// If not - set length to 1
			$length = 1;
		}
					// Read values
	float $width = `getAttr ($a + ".radius")`;
	//float $rad = `floatSliderGrp -q -value "FKradius"`;
	string $orient = `radioCollection -q -sl addGeoRadioGrp1`;
	addGeo( $width, $length, $a, $orient);		// Make the main function
}
}

global proc string addGeo ( float $width, float $height, string $targetName, string $orient) {
$mesh = `polyCube -w $width -d $width-h $height -n ($targetName + "_joint_geo")`;
setAttr ($mesh[0] + ".translateY") ($height / 2);
xform -ws -piv 0 0 0 $mesh[0];
if ($orient == "posX"){
	setAttr ($mesh[0] + ".rotateZ") -90;
	makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 $mesh[0];
}
if ($orient == "negX"){
	setAttr ($mesh[0] + ".rotateZ") 90;
	makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 $mesh[0];
}
if ($orient == "negY"){
	setAttr ($mesh[0] + ".rotateZ") 180;
	makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 $mesh[0];
}

if ($orient == "posZ"){
	setAttr ($mesh[0] + ".rotateX") 90;
	makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 $mesh[0];
}
if ($orient == "negZ"){
	setAttr ($mesh[0] + ".rotateZ") -90;
	makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 $mesh[0];
}

copyMatrixAddGeo($targetName, $mesh[0], 1);

// constraint the scale to the .translateX attribute of a bone

$child = `listRelatives -c $targetName`;
if (`objExists($child[0])`){
	$multDiv = `createNode -n ($mesh[0] + "_multDiv") multiplyDivide`;
	setAttr ($multDiv + ".input2X") (`getAttr ($child[0] + ".translateX")`);
	connectAttr ($child[0] + ".translateX") ($multDiv + ".input1X");
	setAttr ($multDiv + ".operation") 2;
	connectAttr ($multDiv + ".outputX") ($mesh[0] + ".scaleX");
}
parent $mesh[0] $targetName;
// return the mesh name
return $mesh[0]; 
}

global proc copyMatrixAddGeo( string $sourceObj, string $targetObj, int $worldSpace){
string $command;
float $sourceMatrix[];
if($worldSpace == 1){
	$sourceMatrix = `xform -q -ws -m $sourceObj`;
	$command = "xform -ws -m ";
} else {
	$sourceMatrix = `xform -q -os -m $sourceObj`;
	$command = "xform -os -m ";
}



string $matrix;
string $a;
for($a in $sourceMatrix){
	$matrix += $a;
	$matrix += " ";
}

$command += $matrix;
$command += $targetObj;

eval($command);
}

 

Dawno tego narzedzia nie uzywalem ale powinno ci pomoc. Dodaje do zaznaczonych jointow geometrie (nie dziala na pelnej hierarhii wiec musisz sobie pozaznaczac wszystkie jointy ktore chcesz tym potraktowac.

To co napisze ponizej pisze "z dyni" wiec moge sie pomylic ale:

 

$sel = `ls -sl -l`;
selectHierarhy($sel[size($sel) - 1]);

proc selectHierarhy (string $obj){
$children = `listRelatives -c -f $obj`;
for ($child in $children){
	if ((`nodeType($child)`) == "joint"){
		select -add $child;
		selectHierarhy($child);
	}
}
}

 

 

Ten kod powinien zaznaczac wszystkie jointy w hierarchii. Musisz sprawdzic czy dziala wogole.

 

Pozdrowki

Odnośnik do komentarza
Udostępnij na innych stronach

Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto

Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.

Zarejestruj nowe konto

Załóż nowe konto. To bardzo proste!

Zarejestruj się

Zaloguj się

Posiadasz już konto? Zaloguj się poniżej.

Zaloguj się



×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Wykorzystujemy cookies. Przeczytaj więcej Polityka prywatności