bump

Is anyone able to help?

It may be that my whole approach to doing this is wrong, I'm very new
to Away 3d.

On Aug 25, 1:13 pm, JamesK <[email protected]> wrote:
> I'm having trouble when trying to create BitmapMaterials from scaled
> bitmap images.
>
> The source images are of different sizes and scales. I'm trying to map
> them onto a 400*300 mesh, adding empty space to the sides of the image
> when the scales differ, so for example an overwide image would be
> scaled down to have width of 400 and then blank space at the top and
> bottom of the image.
>
> I have a function which allows me to create a mesh and add two faces
> using the material which works perfectly.
>
> Later, when I use a near identical function to remove the faces and
> replace them with new faces using a different image, the scale is
> wrong. The faces end up displaying the zoomed center of the source
> image.
>
> Can anybody tell me where I'm going wrong here?
>
> Here's the code I'm using:
>
> //WIDTH = 400 , HEIGHT = 300
>
> var loadedBitmap:Bitmap = event.currentTarget.content as Bitmap;
>
> var newBitmapData:BitmapData =  new BitmapData( WIDTH, HEIGHT, true,
> 0xff );
> var targetRect : Rectangle =  new Rectangle( 0, 0, loadedBitmap.width,
> loadedBitmap.height );
>
> var startX : int = ( WIDTH - loadedBitmap.width ) / 2;
> var startY : int = ( HEIGHT - loadedBitmap.height ) / 2;
> var startPoint : Point = new Point( startX, startY );
>
> newBitmapData.copyPixels( loadedBitmap.bitmapData, targetRect,
> startPoint );
>
> var artMaterial:BitmapMaterial = new BitmapMaterial(newBitmapData,
> {smooth:true, debug:false});
>
> var uva:UV = new UV(1, 1);
> var uvb:UV = new UV(0, 1);
> var uvc:UV = new UV(0, 0);
> var uvd:UV = new UV(1, 0);
>
> var v000a:Vertex = new Vertex(- WIDTH /2, 0, 0);
> var v010a:Vertex = new Vertex(- WIDTH / 2, +HEIGHT, 0);
> var v100a:Vertex = new Vertex(+ WIDTH/2, 0, 0);
> var v110a:Vertex = new Vertex(+ WIDTH/2, +HEIGHT, 0);
>
> //only doing this when replacing the faces
> for ( var i : int = _shape.faces.length-1; i >= 0; i-- )
> {
>         var currentFace : Face = _shape.faces[i];
>         _shape.removeFace( currentFace );
>
> }
>
> _shape.addFace(new Face(v000a, v100a, v010a, artMaterial, uvc, uvd,
> uvb));
> _shape.addFace(new Face(v100a, v110a, v010a, artMaterial, uvd, uva,
> uvb));
>
> _shape.movePivot(0, HEIGHT/2, 0);

Reply via email to