I’ve been playing around with some 3D in flash lately and I’ve rendered every mesh by only showing their sides (lineTo etc…). But now I want to show real fills on the sides, and not just lines.
This is how it looks like at the moment:
This does not look good, only the green polygon is placed right!
I’m creating each side of the cube with this class:
public class Poly {
public var v1:Vertex, v2:Vertex, v3:Vertex, v4:Vertex;
public function Poly(v1:Vertex, v2:Vertex, v3:Vertex, v4:Vertex) {
this.v1 = v1; this.v2 = v2; this.v3 = v3; this.v4 = v4;
}
}
And this is the Vertex-class:
public class Vertex {
public var X:Number, Y:Number, Z:Number;
public function Vertex(X:Number, Y:Number, Z:Number) {
this.X = X; this.Y = Y; this.Z = Z;
}
public function rotateX(a:Number):Vertex {
var radian:Number = a * (Math.PI / 180);
var Y:Number = (this.Y * Math.cos(radian)) - (this.Z * Math.sin(radian));
var Z:Number = (this.Y * Math.sin(radian)) + (this.Z * Math.cos(radian));
return new Vertex(X, Y, Z);
}
public function rotateY(a:Number):Vertex {
var radian:Number = a * (Math.PI / 180);
var Z:Number = (this.Z * Math.cos(radian)) - (this.X * Math.sin(radian));
var X:Number = (this.Z * Math.sin(radian)) + (this.X * Math.cos(radian));
return new Vertex(X, Y, Z);
}
public function rotateZ(a:Number):Vertex {
var radian:Number = a * (Math.PI / 180);
var X:Number = (this.X * Math.cos(radian)) - (this.Y * Math.sin(radian));
var Y:Number = (this.X * Math.sin(radian)) + (this.Y * Math.cos(radian));
return new Vertex(X, Y, Z);
}
}
I’m totally clueless on how to sort these polygons right, so **any **tips or help is really appreciated!:facepalm:
~Tompa