I'm using this method to convert from 3d space to 2d in order to draw
in the bitmap of the texture that I load in my terrain:
public static function transformTo2DScale(point:Point,
terrainDimensions:ITerrain):Point
{
var new2DPoint:Point = new Point();
/*
* For a terrain with 2000x2000 we've got this scale
* terrain area -> [-1000, 1000] / (x1, xn)
* draw area -> [0, 1000] / (x1', xn')
* IMPORTANT!!!! -> The draw area is always [0, 1000]
* Conversion from (x1, xn) to (x1', xn'):
* x' = ((x - min{x1, xn}) / (max{x1, xn} - min{x1,
xn})) * max{x1',
xn'}
*/
new2DPoint.x = ((point.x - terrainDimensions.minW) /
(terrainDimensions.maxW - terrainDimensions.minW)) * 1000;
new2DPoint.y = 1000 - ((point.y -
terrainDimensions.minH) /
(terrainDimensions.maxH - terrainDimensions.minH)) * 1000;
new2DPoint.x += (new2DPoint.x / 1000) * 24;
new2DPoint.y += (new2DPoint.y / 1000) * 24;
return new2DPoint;
}
I'm sorry I know it may be a bit confusing but hope it helps.
On Jun 7, 12:08 pm, craiggrummitt <[email protected]> wrote:
> Bump...