Skip to content

ND3D make your own Primitives

OK, ND3D just became awesomer. I’m now making my own 3D primitives for everything. This is because primitives are MUCH smaller in K weight, and therefore more versatile. Admittedly, I will eventually break it down to a “primitive.as” class of it’s own and just force feed it random shapes, but tonight I WIN, and that’s all I care about.

Here is an example of my “Dollar.as” class making a high and low ploy version of a “$”. Thanks to [ SupaMonke ] for the models.


This animation is 24k.
(suck it papervision)
The raw ASE file for the low poly is 64k…
the primitive file is 72k, but is absorbed in the swf when compiled!


(this needs cleanup, and I’ll do that for the official class):

Here is how I’m calling it:


// dollar sign LowPoly
 var mat:Material = new Material(0x0000ff, 1, true, true, true);
 var buck:Dollar = new Dollar(50, mat);
 // admittedly I still have no idea what the angles are... they seem to be between 0-3 or something stupid.
 buck.angleX = 1.8;
 buck.angleZ = 1.8;
 buck.xPos = -100;

 renderList.push(buck);

 // dollar sign HighPoly
 var mat:Material = new Material(0x009900, 1, true, true, true);
 var buck2:Dollar = new Dollar(50, mat, true);
 buck2.container = new Sprite(); // if you want to add a filter add it to the sprite.

 buck2.angleX = 1.55;
 buck2.angleZ = 1.55;
 buck2.xPos = 100;

 renderList.push(buck2);

The Dollar Class:

package de.nulldesign.nd3d.objects
{
	import de.nulldesign.nd3d.geom.UV;
	import de.nulldesign.nd3d.geom.Vertex;
	import de.nulldesign.nd3d.material.Material;	

	public class Dollar extends Mesh
	{

		private var Vert:Array;

		public function Dollar(size:Number, mat:Material, highPoly:Boolean = false )
		{

			if(!highPoly)
			{
			// low polygon version
			Vert = [[0 ,-0.4572 ,-1.2321 ,0.0423],[515 ,0.4572 ,-0.2583 ,-0.5363]];
// seriously I am NOT putting all 516 vertexes on my blog.
/*
   basically the array is: [ vertex count, X, Y, Z ]
   I stripped the data from an ASE file.
   ASE files are like girlfriends: hard to find a good one and when you do they are expensive.
*/
			} else {
			// high polygon version
			Vert = [[0,-1.1176,-1.7897,-0.9848],[1883,-1.1874,-1.1504,-2.1646]];
// if you want models, you can give some money to SupeMonke and he might do 'em for you.
			}

			var row:Array = [];
			var i:uint;
			var x:Number;
			var y:Number;
			var z:Number;

			for(i = 0;i < Vert.length; i++)
			{

				x = size * Vert[i][1];
				y = size * Vert[i][2];
				z = size * Vert[i][3];

				v = new Vertex(x, y, z);
				row.push(v);

				if( row.length > 2 )
				{

					addFace(row[0], row[1], row[2], mat);
					row = [];
				}

			}

		}

	}
}

One Trackback/Pingback

  1. » ND3D: The Revenge.DrPunchBlog on Sunday, November 6, 2011 at 11:16 PM

    [...] getting tired writing this, I'm going to coast along for the rest of this… read my other post [here] to figure this shit out… I’m going to [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*