<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Matrix Extrude</title>
	<atom:link href="http://blog.joa-ebert.com/2007/03/13/matrix-extrude/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.joa-ebert.com/2007/03/13/matrix-extrude/</link>
	<description>Actionscript3, Flash, Scala, Java, C#, C++, Algorithms &#38; Imageprocessing</description>
	<lastBuildDate>Sun, 05 Feb 2012 21:26:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Florentine3d</title>
		<link>http://blog.joa-ebert.com/2007/03/13/matrix-extrude/comment-page-1/#comment-173728</link>
		<dc:creator>Florentine3d</dc:creator>
		<pubDate>Mon, 03 Aug 2009 13:59:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/03/13/matrix-extrude/#comment-173728</guid>
		<description>Please, may you send on my e-mail this project for Flex. Your class print error:
A file found in a source-path can not have more than one externally visible definition. Extrude;NormalExtrude.</description>
		<content:encoded><![CDATA[<p>Please, may you send on my e-mail this project for Flex. Your class print error:<br />
A file found in a source-path can not have more than one externally visible definition. Extrude;NormalExtrude.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joa</title>
		<link>http://blog.joa-ebert.com/2007/03/13/matrix-extrude/comment-page-1/#comment-55394</link>
		<dc:creator>joa</dc:creator>
		<pubDate>Mon, 15 Oct 2007 19:38:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/03/13/matrix-extrude/#comment-55394</guid>
		<description>Has been done with an _old_ version of PV3D. I also had a function to clone the geometry object of a DisplayObject3D involved there somewhere.

&lt;code&gt;
class Extrude
{
	public function Extrude( geometry: GeometryObject3D, faces: Array, direction: Number3D )
	{
		var cloneVertices: Array = new Array;
		var usedInFaces: Dictionary = new Dictionary;
		
		var m: int;
		var n: int;
		var o: int;
		
		var i: int;
		var j: int;
		var k: int;
		
		var vertex: Vertex3D;
		
		n = faces.length;
		
		//-- LOOP THROUGH FACES
		//-- CLONE ALL VERTICES THAT ARE INVOLVED
		//-- DO NOT CREATE DUPLICATES!
		for ( i = 0; i &lt; n; i   )
		{
			var face: Face3D = faces[ i ];
			var vertices: Array = face.vertices;
			
			m = vertices.length;
			
			for ( j = 0; j &lt; m; j   )
			{
				vertex = vertices[ j ];
				
				if ( !inArray( cloneVertices, vertex ) )
					cloneVertices.push( [ vertex, null ] );
							
				if ( usedInFaces[ vertex ] == null )
					usedInFaces[ vertex ] = 1;
				else
					usedInFaces[ vertex ]  ;
			}
		}
		
		n = cloneVertices.length;
		
		//-- LOOP THROUGH NEW VERTICES
		//-- CLONE VERTEX AND MOVE BY DIRECTION
		for ( i = 0; i &lt; n; i   )
		{
			vertex = cloneVertex( ( cloneVertices[ i ] as Array )[ int( 0 ) ] );

			vertex.x  = direction.x;
			vertex.y  = direction.y;
			vertex.z  = direction.z;
			
			( cloneVertices[ i ] as Array )[ int( 1 ) ] = vertex
			geometry.vertices.push( vertex );
		}
		
		n = faces.length;
		o = cloneVertices.length;
		
		var cloned: Array;
		
		//-- LOOP THROUGH FACES AGAIN
		//-- FIND CLONED VERTICES THAT BELONG TO OLD FACE AND CREATE NEW ONE
		//-- CREATE NEW FACE AS WELL IF VERTEX IS NOT ACCESSED BY MORE THAN 1 FACE
		for ( i = 0; i &lt; n; i   )
		{
			face = faces[ i ];
			vertices = face.vertices;
		
			cloned = new Array;
			m = vertices.length;
			
			for ( j = 0; j &lt; m; j   )
			{
				vertex = vertices[ j ];
				
				for ( k = 0; k &lt; o; k   )
					if ( ( cloneVertices[ k ] as Array )[ int( 0 ) ] == vertex )
						cloned.push( ( cloneVertices[ k ] as Array )[ int( 1 ) ] );
			}
			
			geometry.faces.push( new Face3D( cloned ) );
			
			var jp1: int;
			
			for ( j = 0; j &lt; m; j   )
			{
				jp1 = j   1;
				
				if ( jp1 == m )
					jp1 = 0;
					
				var v0: Vertex3D = vertices[ j   ];
				var v1: Vertex3D = vertices[ jp1 ];
				
				if ( usedInFaces[ v0 ] &gt; 1 &amp;&amp; usedInFaces[ v1 ] &gt; 1 )
					continue;
				
				var c0: Vertex3D = cloned[ j   ];
				var c1: Vertex3D = cloned[ jp1 ];
				
				geometry.faces.push( new Face3D( [ v0, c0, v1 ] ) );
				geometry.faces.push( new Face3D( [ v1, c1, c0 ] ) );
			}
		}
	}
	
	private function cloneVertex( vertex: Vertex3D ): Vertex3D
	{
		var clone: Vertex3D = new Vertex3D( vertex.x, vertex.y, vertex.z );
		clone.extra = vertex.extra;
		
		return clone;
	}
	
	private function inArray( a: Array, v: Vertex3D ): Boolean
	{
		var n: int = a.length;
		
		for ( var i: int = 0; i &lt; n; i   )
		{
			if ( ( a[ i ] as Array )[ int( 0 ) ] == v )
				return true;
		}
		
		return false;
	}
}

class NormalExtrude
{
	public function NormalExtrude( geometry: GeometryObject3D, face: Face3D, distance: Number )
	{
		var v0: Vertex3D = face.vertices[ int( 0 ) ];
		var v1: Vertex3D = face.vertices[ int( 1 ) ];
		var v2: Vertex3D = face.vertices[ int( 2 ) ];
		
		var c0: Vertex3D = cloneVertex( v0 );
		var c1: Vertex3D = cloneVertex( v1 );
		var c2: Vertex3D = cloneVertex( v2 );
		
		geometry.vertices.push( c0, c1, c2 );
		
		const normal: Number3D = calcNormal( face );
		
		applyDistance( c0, normal, distance );
		applyDistance( c1, normal, distance );
		applyDistance( c2, normal, distance );
		
		geometry.faces.push( new Face3D( [ c0, c1, c2 ] ) );
		
		var cloned: Array = [ c0, c1, c2 ];
		var jp1: int;
			
		for ( var j: int = 0; j &lt; 3; j   )
		{
			jp1 = j   1;
			
			if ( jp1 == 3 )
				jp1 = 0;
				
			v0 = face.vertices[ j   ];
			v1 = face.vertices[ jp1 ];
			
			c0 = cloned[ j   ];
			c1 = cloned[ jp1 ];
			
			geometry.faces.push( new Face3D( [ v0, c0, v1 ] ) );
			geometry.faces.push( new Face3D( [ v1, c1, c0 ] ) );
		}
	}
	
	private function applyDistance( vertex: Vertex3D, normal: Number3D, distance: Number ): void
	{
		vertex.x  = normal.x * distance;
		vertex.y  = normal.y * distance;
		vertex.z  = normal.z * distance;
	}
	
	private function cloneVertex( vertex: Vertex3D ): Vertex3D
	{
		var clone: Vertex3D = new Vertex3D( vertex.x, vertex.y, vertex.z );
		clone.extra = vertex.extra;
		
		return clone;
	}
	
	private function calcNormal( face: Face3D ): Number3D
	{
		var normal: Number3D = new Number3D;
		
		var v0: Vertex3D = face.vertices[ int( 0 ) ];
		var v1: Vertex3D = face.vertices[ int( 1 ) ];
		var v2: Vertex3D = face.vertices[ int( 2 ) ];
		
		var t0: Vertex3D = new Vertex3D;
		var t1: Vertex3D = new Vertex3D;
		
		t0.x = v0.x - v1.x;
		t0.y = v0.y - v1.y;
		t0.z = v0.z - v1.z;
		
		t1.x = v1.x - v2.x;
		t1.y = v1.y - v2.y;
		t1.z = v1.z - v2.z;
		
		normal.x = t0.y * t1.z - t0.z * t1.y;
		normal.y = t0.z * t1.x - t0.x * t1.z;
		normal.z = t0.x * t1.y - t0.y * t1.x;
		
		var length: Number = Math.sqrt( normal.x * normal.x   normal.y * normal.y   normal.z * normal.z );
		
		if ( length == 0 )
			length = 1;
		
		normal.x /= length;
		normal.y /= length;
		normal.z /= length;
		
		return normal;
	}
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Has been done with an _old_ version of PV3D. I also had a function to clone the geometry object of a DisplayObject3D involved there somewhere.</p>
<p><code><br />
class Extrude<br />
{<br />
	public function Extrude( geometry: GeometryObject3D, faces: Array, direction: Number3D )<br />
	{<br />
		var cloneVertices: Array = new Array;<br />
		var usedInFaces: Dictionary = new Dictionary;</p>
<p>		var m: int;<br />
		var n: int;<br />
		var o: int;</p>
<p>		var i: int;<br />
		var j: int;<br />
		var k: int;</p>
<p>		var vertex: Vertex3D;</p>
<p>		n = faces.length;</p>
<p>		//-- LOOP THROUGH FACES<br />
		//-- CLONE ALL VERTICES THAT ARE INVOLVED<br />
		//-- DO NOT CREATE DUPLICATES!<br />
		for ( i = 0; i < n; i   )<br />
		{<br />
			var face: Face3D = faces[ i ];<br />
			var vertices: Array = face.vertices;</p>
<p>			m = vertices.length;</p>
<p>			for ( j = 0; j < m; j   )<br />
			{<br />
				vertex = vertices[ j ];</p>
<p>				if ( !inArray( cloneVertices, vertex ) )<br />
					cloneVertices.push( [ vertex, null ] );</p>
<p>				if ( usedInFaces[ vertex ] == null )<br />
					usedInFaces[ vertex ] = 1;<br />
				else<br />
					usedInFaces[ vertex ]  ;<br />
			}<br />
		}</p>
<p>		n = cloneVertices.length;</p>
<p>		//-- LOOP THROUGH NEW VERTICES<br />
		//-- CLONE VERTEX AND MOVE BY DIRECTION<br />
		for ( i = 0; i < n; i   )<br />
		{<br />
			vertex = cloneVertex( ( cloneVertices[ i ] as Array )[ int( 0 ) ] );</p>
<p>			vertex.x  = direction.x;<br />
			vertex.y  = direction.y;<br />
			vertex.z  = direction.z;</p>
<p>			( cloneVertices[ i ] as Array )[ int( 1 ) ] = vertex<br />
			geometry.vertices.push( vertex );<br />
		}</p>
<p>		n = faces.length;<br />
		o = cloneVertices.length;</p>
<p>		var cloned: Array;</p>
<p>		//-- LOOP THROUGH FACES AGAIN<br />
		//-- FIND CLONED VERTICES THAT BELONG TO OLD FACE AND CREATE NEW ONE<br />
		//-- CREATE NEW FACE AS WELL IF VERTEX IS NOT ACCESSED BY MORE THAN 1 FACE<br />
		for ( i = 0; i < n; i   )<br />
		{<br />
			face = faces[ i ];<br />
			vertices = face.vertices;</p>
<p>			cloned = new Array;<br />
			m = vertices.length;</p>
<p>			for ( j = 0; j < m; j   )<br />
			{<br />
				vertex = vertices[ j ];</p>
<p>				for ( k = 0; k < o; k   )<br />
					if ( ( cloneVertices[ k ] as Array )[ int( 0 ) ] == vertex )<br />
						cloned.push( ( cloneVertices[ k ] as Array )[ int( 1 ) ] );<br />
			}</p>
<p>			geometry.faces.push( new Face3D( cloned ) );</p>
<p>			var jp1: int;</p>
<p>			for ( j = 0; j < m; j   )<br />
			{<br />
				jp1 = j   1;</p>
<p>				if ( jp1 == m )<br />
					jp1 = 0;</p>
<p>				var v0: Vertex3D = vertices[ j   ];<br />
				var v1: Vertex3D = vertices[ jp1 ];</p>
<p>				if ( usedInFaces[ v0 ] > 1 &#038;&#038; usedInFaces[ v1 ] > 1 )<br />
					continue;</p>
<p>				var c0: Vertex3D = cloned[ j   ];<br />
				var c1: Vertex3D = cloned[ jp1 ];</p>
<p>				geometry.faces.push( new Face3D( [ v0, c0, v1 ] ) );<br />
				geometry.faces.push( new Face3D( [ v1, c1, c0 ] ) );<br />
			}<br />
		}<br />
	}</p>
<p>	private function cloneVertex( vertex: Vertex3D ): Vertex3D<br />
	{<br />
		var clone: Vertex3D = new Vertex3D( vertex.x, vertex.y, vertex.z );<br />
		clone.extra = vertex.extra;</p>
<p>		return clone;<br />
	}</p>
<p>	private function inArray( a: Array, v: Vertex3D ): Boolean<br />
	{<br />
		var n: int = a.length;</p>
<p>		for ( var i: int = 0; i < n; i   )<br />
		{<br />
			if ( ( a[ i ] as Array )[ int( 0 ) ] == v )<br />
				return true;<br />
		}</p>
<p>		return false;<br />
	}<br />
}</p>
<p>class NormalExtrude<br />
{<br />
	public function NormalExtrude( geometry: GeometryObject3D, face: Face3D, distance: Number )<br />
	{<br />
		var v0: Vertex3D = face.vertices[ int( 0 ) ];<br />
		var v1: Vertex3D = face.vertices[ int( 1 ) ];<br />
		var v2: Vertex3D = face.vertices[ int( 2 ) ];</p>
<p>		var c0: Vertex3D = cloneVertex( v0 );<br />
		var c1: Vertex3D = cloneVertex( v1 );<br />
		var c2: Vertex3D = cloneVertex( v2 );</p>
<p>		geometry.vertices.push( c0, c1, c2 );</p>
<p>		const normal: Number3D = calcNormal( face );</p>
<p>		applyDistance( c0, normal, distance );<br />
		applyDistance( c1, normal, distance );<br />
		applyDistance( c2, normal, distance );</p>
<p>		geometry.faces.push( new Face3D( [ c0, c1, c2 ] ) );</p>
<p>		var cloned: Array = [ c0, c1, c2 ];<br />
		var jp1: int;</p>
<p>		for ( var j: int = 0; j < 3; j   )<br />
		{<br />
			jp1 = j   1;</p>
<p>			if ( jp1 == 3 )<br />
				jp1 = 0;</p>
<p>			v0 = face.vertices[ j   ];<br />
			v1 = face.vertices[ jp1 ];</p>
<p>			c0 = cloned[ j   ];<br />
			c1 = cloned[ jp1 ];</p>
<p>			geometry.faces.push( new Face3D( [ v0, c0, v1 ] ) );<br />
			geometry.faces.push( new Face3D( [ v1, c1, c0 ] ) );<br />
		}<br />
	}</p>
<p>	private function applyDistance( vertex: Vertex3D, normal: Number3D, distance: Number ): void<br />
	{<br />
		vertex.x  = normal.x * distance;<br />
		vertex.y  = normal.y * distance;<br />
		vertex.z  = normal.z * distance;<br />
	}</p>
<p>	private function cloneVertex( vertex: Vertex3D ): Vertex3D<br />
	{<br />
		var clone: Vertex3D = new Vertex3D( vertex.x, vertex.y, vertex.z );<br />
		clone.extra = vertex.extra;</p>
<p>		return clone;<br />
	}</p>
<p>	private function calcNormal( face: Face3D ): Number3D<br />
	{<br />
		var normal: Number3D = new Number3D;</p>
<p>		var v0: Vertex3D = face.vertices[ int( 0 ) ];<br />
		var v1: Vertex3D = face.vertices[ int( 1 ) ];<br />
		var v2: Vertex3D = face.vertices[ int( 2 ) ];</p>
<p>		var t0: Vertex3D = new Vertex3D;<br />
		var t1: Vertex3D = new Vertex3D;</p>
<p>		t0.x = v0.x - v1.x;<br />
		t0.y = v0.y - v1.y;<br />
		t0.z = v0.z - v1.z;</p>
<p>		t1.x = v1.x - v2.x;<br />
		t1.y = v1.y - v2.y;<br />
		t1.z = v1.z - v2.z;</p>
<p>		normal.x = t0.y * t1.z - t0.z * t1.y;<br />
		normal.y = t0.z * t1.x - t0.x * t1.z;<br />
		normal.z = t0.x * t1.y - t0.y * t1.x;</p>
<p>		var length: Number = Math.sqrt( normal.x * normal.x   normal.y * normal.y   normal.z * normal.z );</p>
<p>		if ( length == 0 )<br />
			length = 1;</p>
<p>		normal.x /= length;<br />
		normal.y /= length;<br />
		normal.z /= length;</p>
<p>		return normal;<br />
	}<br />
}<br />
</code></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andrew</title>
		<link>http://blog.joa-ebert.com/2007/03/13/matrix-extrude/comment-page-1/#comment-55393</link>
		<dc:creator>andrew</dc:creator>
		<pubDate>Mon, 15 Oct 2007 15:47:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/03/13/matrix-extrude/#comment-55393</guid>
		<description>ok :) do u have any link about that code needed to extrude a face?
thank u!</description>
		<content:encoded><![CDATA[<p>ok :) do u have any link about that code needed to extrude a face?<br />
thank u!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joa</title>
		<link>http://blog.joa-ebert.com/2007/03/13/matrix-extrude/comment-page-1/#comment-55385</link>
		<dc:creator>joa</dc:creator>
		<pubDate>Fri, 12 Oct 2007 15:16:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/03/13/matrix-extrude/#comment-55385</guid>
		<description>Somewhere in the history of the PV3D mailing list I posted codes how you can extrude a face. This one is like a simple extrude but you do more steps and shift the face normals around.</description>
		<content:encoded><![CDATA[<p>Somewhere in the history of the PV3D mailing list I posted codes how you can extrude a face. This one is like a simple extrude but you do more steps and shift the face normals around.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andrew</title>
		<link>http://blog.joa-ebert.com/2007/03/13/matrix-extrude/comment-page-1/#comment-55384</link>
		<dc:creator>andrew</dc:creator>
		<pubDate>Fri, 12 Oct 2007 15:04:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.je2050.de/2007/03/13/matrix-extrude/#comment-55384</guid>
		<description>Very nice! any chance to see the source code of it? 
thank u
A.</description>
		<content:encoded><![CDATA[<p>Very nice! any chance to see the source code of it?<br />
thank u<br />
A.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

