I’m trying to convert this old code of mine here to proper Axonometric transformation so that I can get proper isometric particle effects in ND2D…
http://designermichael.com/share/isoWater.html
http://designermichael.com/share/fountainParticle.as
Quite funny how I hacked that together as an experiment years ago…
Here is the code I am trying to convert below… Halfway done! It was originally C++ or Java or something I think… Ummm… This is odd… Why does flash not have a Point3D class? I could have sworn it had a Point3D class… Found one… http://casalib.org/ Casalib has a Point3D class that should work nicely!
Also, it implemented something else “class implements Axonometric_transformer_i”… It doesn’t look like anything is missing… I have no idea what maintaining the z axis ratio means either… Meh…
Edit: Ok… Should be ready to roll… Don’t think I made any mistakes!
package Michael {
import org.casalib.math.geom.Point3d;
public class isoTransformer {
static var axonometricAxesProjection:Boolean=false;
static var maintainAxisRatioZ:Boolean=false;
static var Ratio:Number=2;
static var axialProjection:Number=Math.cos(Math.atan(0.5));
public function isoTransformer():void {
}
public static function screenToDisplay(screenPoint:Point3d):Point3d {
var z:Number=screenPoint.z;
var y:Number=screenPoint.y-screenPoint.x/Ratio+screenPoint.z;
var x:Number=screenPoint.x/Ratio+screenPoint.y+screenPoint.z;
if (! axonometricAxesProjection&&maintainAxisRatioZ) {
z=z*axialProjection;
}
if (axonometricAxesProjection) {
x=x/axialProjection;
y=y/axialProjection;
}
return new Point3d(x,y,z);
}
public static function displayToScreen(displayPoint:Point3d):Point3d {
if (! axonometricAxesProjection&&maintainAxisRatioZ) {
displayPoint.z=displayPoint.z/axialProjection;
}
if (axonometricAxesProjection) {
displayPoint.x=displayPoint.x*axialProjection;
displayPoint.y=displayPoint.y*axialProjection;
}
var z:Number=displayPoint.z;
var y:Number=displayPoint.x+displayPoint.y/Ratio-displayPoint.z;
var x:Number=displayPoint.x-displayPoint.y;
return new Point3d(x,y,z);
}
}
}