Pixas Tutorial Series Part 5: Dimension

This entry is part 5 of 5 in the Pixas tutorial series
part 1: building your first application
part 2: coordinate system
part 3: primitives
part 4: color
• part 5: dimension

In this part, we will learn the dimension assigning.

Actually if you have followed the preceding parts, you might already have the idea about how to define the dimension for primitives.

For Brick, SideX and SideY, you should pass two parameters to the constructor which represent the 2 dimensions in x-axis, y-axis or z-axis.
For Cube, you should pass three parameters to the constructor which represent the 3 dimensions in x-axis, y-axis or z-axis.
For Pyramid, the bottom must be a square, which means you just have to pass one parameter to the constructor.
As follows:

var xDms:uint = 20;
var yDms:uint = 30;
var zDms:uint = 40;

var brickDms:BrickDms = new BrickDms(xDms,yDms);
var sideXDms:SideXDms = new SideXDms(xDms, zDms);
var sideYDms:SideYDms = new SideYDms(yDms, zDms);

var cubeDms:CubeDms = new CubeDms (xDms, yDms, zDms);
var pyDms:PyramidDms = new PyramidDms(xDms);

For Pyramid, you might notice that it has another parameter, which means whether to generate a taller pyramid. In 3d pixel isometric projection, there are two types of pyramid.

Now we try to build a pyramid group, assign colors for them by PyramidColor.getByRightColor() mentioned in the previous part, if you run the code below, you will get this:

import com.risonhuang.pixas.colors.PyramidColor;
import com.risonhuang.pixas.dimensions.PyramidDms;
import com.risonhuang.pixas.objects.primitives.Pyramid;
import com.risonhuang.pixas.math.Coord3D;
import com.risonhuang.pixas.math.ColorPattern;
import com.risonhuang.pixas.objects.PixelObject;

var dms:uint = 30;

//out pixel object
var po_out:PixelObject = new PixelObject();

//tall pyramid
var pyTallColor:PyramidColor = PyramidColor.getByRightColor(ColorPattern.YELLOW);
var pyTallDms:PyramidDms = new PyramidDms(dms, true);
var pyTall:Pyramid = new Pyramid(pyTallDms, pyTallColor);
var po_pyTall:PixelObject = new PixelObject(pyTall);

//short pyramid
var pyColor:PyramidColor = PyramidColor.getByRightColor(ColorPattern.GRASS_GREEN);
var pyDms:PyramidDms = new PyramidDms(dms);
var py:Pyramid = new Pyramid(pyDms, pyColor);
var po_py:PixelObject = new PixelObject(py);
po_py.position = new Coord3D((dms - 2) * 2, dms - 2, 0);

//the other short pyramid
var py2Color:PyramidColor = PyramidColor.getByRightColor(ColorPattern.PINK);
var py2Dms:PyramidDms = new PyramidDms(dms);
var py2:Pyramid = new Pyramid(py2Dms, py2Color);
var po_py2:PixelObject = new PixelObject(py2);
po_py2.position = new Coord3D((dms - 2), (dms - 2) * 3);


po_out.x = 240;
po_out.y = 180;

So far, we’ve explored most of the Pixas engine, hope you find it interesting and would like to explore your own idea into it. Any comments, feel free to drop me a line.


Trackbacks / Pingbacks

  1. Pixas part 2 | pixelDiff - 16/08/2012

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s