Re: How to Hair to curves?

Date : Fri, 04 Jan 2008 14:53:11 +0100
To : XSI(at)Softimage.COM
From : Guillaume Laforge <guillaume(at)alamaison.fr>
Subject : Re: How to Hair to curves?
>Merci Guillaume, t'es définitivement passé par-là toi aussi...tu réponds à mes questions de hair même sur la liste d'Houdini ;)

Then if you need to write those curves in a .geo file for Houdini, you can ask me too (but I don't know on which list :P ).


Cheers

Guillaume


Marc-Andre Carbonneau a écrit :
Nice, it works perfectly.

Merci Guillaume, t'es définitivement passé par-là toi aussi...tu réponds à mes questions de hair même sur la liste d'Houdini ;)


-----Original Message-----
From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Guillaume Laforge
Sent: January 3, 2008 3:36 PM
To: XSI(at)Softimage.COM
Subject: Re: How to Hair to curves?


Happy 2008 !

Select your hair object and run. It creates one curve by guide.
If you need to merge some of the curves, you will need an other script ( I send it to the list some time ago). 

//***************************************
var xHair = Selection(0);

HairPointsValues( xHair )


function HairPointsValues( xHair )
{
		
	var PointsPerGuideHair = 14 ; // This is always true
	var valuesPerPosition = 3 ; // x,y,z
	var gHair = xHair.ActivePrimitive.Geometry;
	var aAllPositions = gHair.Points.PositionArray.toArray();

	var cntGuideHairs = aAllPositions.length / ( valuesPerPosition * PointsPerGuideHair ) ;
	var oMesh = HairPolymesh(xHair); 
	var oPoints = oMesh.Geometry.Points;

	for ( i = 0 ; i < cntGuideHairs ; i++ )
	{
		var posArray = new Array();
		
		var oHairRootx = oPoints.item(i).position.x;
		var oHairRooty = oPoints.item(i).position.y;
		var oHairRootz = oPoints.item(i).position.z;
		
		logmessage("guide n : "+i);

		posArray.push(oHairRootx);
		posArray.push(oHairRooty);
		posArray.push(oHairRootz);
		posArray.push(1);

		indexHairRoot = i * valuesPerPosition * PointsPerGuideHair ;
		
		
		
		for ( k = 0 ; k < PointsPerGuideHair ; k++ )
		{					
			xIndex = k*valuesPerPosition + indexHairRoot ;
			posArray.push( aAllPositions[xIndex ]);
			posArray.push( aAllPositions[xIndex + 1]);
			posArray.push( aAllPositions[xIndex + 2]);
			posArray.push( 1 );
		}
		var degrees = [1];
		var params = [siUniformParameterization];
		var closed = [false];
		var initCurve = ActivesceneRoot.AddNurbsCurveList2(1, posArray, null, null, null, closed, degrees, params, siSINurbs, "LinesFromGuides" );
	}


// return the geometry source
function HairPolymesh(HairObject)
{
	//Find the hair operator.
	oEnum = new Enumerator( HairObject.ActivePrimitive.ConstructionHistory );
	for (;!oEnum.atEnd();oEnum.moveNext())
	{
		if( oEnum.item().name == "Hair Generator Operator" )
		{
			oOp = oEnum.item();
			oEnumInPort = new Enumerator( oOp.InputPorts ) ;
			for (;!oEnumInPort.atEnd();oEnumInPort.moveNext() )
			{
				var oInPort = oEnumInPort.item () ;
				if(oInPort.GroupName == "Group_0")
				{
					var oMesh = oInPort.Target2;
					return oMesh;
				}
			}
		}
	}
}

//***********************************************

Cheers !

--
Guillaume Laforge | La Maison

PS : If you use Linux you must add those line before the script :

// Add a push method to the JScript Array Object
// (at)cc_on
// (at)if ((at)_jscript_version < 5.5)
var push = function(){
	for( var i = 0; arguments[ i ] != null; i++ )
		this[this.length++] = arguments[ i ];
	return( this );
	}
Array.prototype.push = push;
// (at)end



On Thu, 3 Jan 2008 15:19:13 -0500, "Marc-Andre Carbonneau" <marc-andre.carbonneau(at)ubisoft.com> wrote:
  
Heya!

 

First, Happy New Year! Wish you all the best for 2008. Lots of exciting
projects for you all I'm sure!

 

My TD is still on holyday so could anyone help me convert hair to
curves? Anyone wrote such a script or plu
    


---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi
  
--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi

Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.