Thread: normals [state]
View Single Post
# 10 06-04-2006 , 10:31 AM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Here's a copy-paste of my getFaceNormals procedure, which I wrote for my auto map script. It takes in a string variable containing the name of the polygon object and returns a vector array containing face normals.

Code:
// getFaceNormals by kbrown
//
proc vector[] getFaceNormals(string $sPolyObject)
{
	vector $vNormals[];
	int $i;

	// get all face normals in to a string array
	string $sFaceNormals[] = `polyInfo -fn $sPolyObject`;
	
	// parse the string array and create a vector array holding the normal info
	for($i = 0; $i < size($sFaceNormals); $i++)
	{
		string $sBuffer[];
		tokenize($sFaceNormals[$i], $sBuffer);
		float $fX = $sBuffer[2];
		float $fY = $sBuffer[3];
		float $fZ = $sBuffer[4];
		$vNormals[$i] = <<$fX, $fY, $fZ>>;
	}
	
	// free some memory
	clear($sFaceNormals);
	
	// return the vector array
	return $vNormals;
}


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!