i'm writing a very basic 3d renderer in as3/flashpunk in preperation for 7dfps.
I've managed to billboard sprites ok (after a huge amount of work), but I want to draw a simple rectangular floor in a solid colour.
So far, if you are completely outside of the area of coloured floor, you can view the shape as it should, but since the y position is based on the distance from the camera, the corners go BACK INTO the shape when you are standing on it.
here is what I have:
http://dl.dropbox.com/u/8943931/threed/threed%20%282%29.swfcontrols are WASD to move, and JL to turn left/right
to get your bearings, press "3" to turn the 3d off and view the world top-down.
I am only drawing the outline of the floor in 3d so far. I suggest moving to a corner of the floor, just outside it, then walk towards the center. it just fucks up royally.
here is the messy uncommented code:
var angle1:Number, angle2:Number, angle3:Number, angle4:Number, dist1:Number, dist2:Number, dist3:Number, dist4:Number, x1:Number, x2:Number, x3:Number, x4:Number, y1:Number, y2:Number, y3:Number, y4:Number;
bit = new BitmapData(FP.width, FP.height, true, 0x00000000);
angle1 = FP.angleDiff(FP.angle(floorRect.left, floorRect.top, Main.camera.x, Main.camera.y), Main.camera.direction * FP.DEG);
angle2 = FP.angleDiff(FP.angle(floorRect.left, floorRect.bottom, Main.camera.x, Main.camera.y), Main.camera.direction * FP.DEG);
angle3 = FP.angleDiff(FP.angle(floorRect.right, floorRect.top, Main.camera.x, Main.camera.y), Main.camera.direction * FP.DEG);
angle4 = FP.angleDiff(FP.angle(floorRect.right, floorRect.bottom, Main.camera.x, Main.camera.y), Main.camera.direction * FP.DEG);
dist1 = FP.distance(floorRect.left, floorRect.top, Main.camera.x, Main.camera.y);
dist2 = FP.distance(floorRect.left, floorRect.bottom, Main.camera.x, Main.camera.y);
dist3 = FP.distance(floorRect.right, floorRect.top, Main.camera.x, Main.camera.y);
dist4 = FP.distance(floorRect.right, floorRect.bottom, Main.camera.x, Main.camera.y);
x1 = (FP.halfWidth) + (FP.halfWidth * Math.sin(angle1 * FP.RAD) * Main.FOV);
x2 = (FP.halfWidth) + (FP.halfWidth * Math.sin(angle2 * FP.RAD) * Main.FOV);
x3 = (FP.halfWidth) + (FP.halfWidth * Math.sin(angle3 * FP.RAD) * Main.FOV);
x4 = (FP.halfWidth) + (FP.halfWidth * Math.sin(angle4 * FP.RAD) * Main.FOV);
y1 = FP.halfHeight + ((10) / (dist1 / FP.halfHeight));
y2 = FP.halfHeight + ((10) / (dist2 / FP.halfHeight));
y3 = FP.halfHeight + ((10) / (dist3 / FP.halfHeight));
y4 = FP.halfHeight + ((10) / (dist4 / FP.halfHeight));
//bit.floodFill(
bit.setPixel32(x1, y1, color);
bit.setPixel32(x2, y2, color);
bit.setPixel32(x3, y3, color);
bit.setPixel32(x4, y4, color);
can anyone help??