What’s the best way to swap a Bitmap texture? Currently, I’m changing it by setting the bitmapData property of a bitmap texture object. When I set the property, I get a short performance hit and a frame rate drop? So, is there a more efficient way to do this that would keep my animation running smoothly?
Quickest and best way to swap a bitmap textureSoftware: Away3D 4.x |
||
|
||
bart_the_13th, Newbie
Posted: 24 January 2013 04:27 PM Total Posts: 14 [ # 1 ] I believe that when you set/change the bitmapData, the 3d renderer must write the bitmap from memory to graphic card’s memory, maybe that’s the cause of the performance hit. |
||
Monkey on a laptop, Newbie
Posted: 25 January 2013 03:03 PM Total Posts: 4 [ # 2 ] I have a similar problem. I understand the idea of shifting the UV of a spritesheet texture to animate it but I can’t figure out how to do it. Could it be possible to have an example? |
||
Fabrice Closier, Administrator
Posted: 25 January 2013 03:51 PM Total Posts: 1265 [ # 3 ] If you use a sprite sheet divided 4 images for instance. Another way to do it and way more efficient is to precalculate the uvs during the build of the sheet. and runtime simply pass them as uv’s. Because it’s predefined, you can in case of transparent images, push more data, (more images) per spritesheets. An even smarter material would allow reverse anim, cell transforms, sequences within cells etc.. |
||
Monkey on a laptop, Newbie
Posted: 25 January 2013 04:11 PM Total Posts: 4 [ # 4 ] That’s what I was trying to do. The one thing I was missing was that I didn’t set material.animateUVs = true. |
||
Fabrice Closier, Administrator
Posted: 25 January 2013 04:37 PM Total Posts: 1265 [ # 5 ] Here a little example of the hardcoded approach _uvs = new Vector.<Number>();
and in your update code do something like. and yes animateUV must be true You can also ensure that your playrate fit your anim |
||
Monkey on a laptop, Newbie
Posted: 25 January 2013 07:17 PM Total Posts: 4 [ # 6 ] Thank you for your help. One last question, when I set animateUV to true, flash starts tracing the same line over and over : Warning: animateUVs is set to true with an IRenderable without a uvTransform. Identity matrix assumed.
|
||
Fabrice Closier, Administrator
Posted: 25 January 2013 08:34 PM Total Posts: 1265 [ # 7 ] Simply ensure that you render with animateUV true when you have applied at least one time. Now your probably set to true, render a few frames then set the transforms. You may also have set it to another mesh and do not animate the uvs on this one. |
||
mkfui, Jr. Member
Posted: 20 October 2016 07:27 AM Total Posts: 31 [ # 8 ] sir, it didn’t work mat = new TextureMaterial(Cast.bitmapTexture(mynum)); private function _onEnterFrame(e:Event):void for (var k:uint=0;k |
||
|
||
Fabrice Closier, Administrator
Posted: 21 October 2016 09:32 AM Total Posts: 1265 [ # 10 ] Because you set animateUV to true, doesn’t mean they actually animate. To animate uv’s you need an AnimatorBase. Use either UVAnimator or SpriteSheetAnimator. |