Given a bitmapData and a UV coord I'm trying to accurately calculate
the x,y position on the bitmapData. I need this so I can decorate each
side of my primitive with a different colour.  I'm pretty sure I have
the calculations right the problem is they don't quite match up to
Away3Ds - I'm often left with a 1px white strip on a given side.

Does away3d already have a function to do this? I'm struggling to find
it.

Here's my attempt:

The function takes a bitmap and a UV bounds object (minU:Number,
maxU:Number, minV:Number, maxV:Number) and attempts to return a
rectangle relating to the bitmap.

public static function
translateUVBoundsToRectangle(bitmapData:BitmapData,
uvBounds:UVBounds):Rectangle {
        // UV coords are bottom left - screen is top left
        var bounds:Rectangle = new Rectangle();

        bounds.x = bitmapData.width * uvBounds.minU;
        bounds.y = bitmapData.height - (bitmapData.height * uvBounds.maxV);
        bounds.width = (bitmapData.width * uvBounds.maxU) - bounds.x;
        bounds.height = bitmapData.height - (bitmapData.height *
uvBounds.minV) - bounds.y;

        return bounds
}

Thanks!

Pete

Reply via email to