Newbie texture question

Software: Away3D 4.x

Rob, Newbie
Posted: 19 October 2011 09:42 AM   Total Posts: 2

Hi there,

I just started using Away 3D (version 4.0 + AIR 3) and ran into my first problem. Basically what I want to do is to map the contents of a flash sprite onto a Plane.

I seems that texture-wise I’m limited to 512*512 pixel bitmaps – correct?

So if my sprite was a square I could just draw a Bitamp of it and create a Bitmap material, which I then could use a texture.

But what if my sprite has a sizes of let’s say 390*800 pixels?  What I could do is scale the sprite to 512*512 pixels then draw a bitmap and use the Bitmap data as a texture ….

This however seems very cumbersome to me. Is there a better/ easier way of doing this?

Cheers


Robin

   

Richard Olsson, Administrator
Posted: 19 October 2011 11:45 AM   Total Posts: 1192   [ # 1 ]

Textures have to be square (if mip-mapping is enabled) and their width and height a power of two. So no, there is no easier way. The TextureUtil class provides a way to calculate the closest compatible number.

d = TextureUtil.getBestPowerOf2(Math.min(spr.width, spr.height));
spr.width = spr.height = d;
bmp = new BitmapData(d, d);
bmp.draw(spr, spr.transform.matrix);

It is likely that the TextureUtil class will soon provide methods for scaling as well (i.e. the above code wrapped in a method) but for now you have to do it manually.

   

Rob, Newbie
Posted: 19 October 2011 11:53 AM   Total Posts: 2   [ # 2 ]

Ok – will do it the hard way then grin
Thanks for your reply!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X