what is wrong with my AnimateTextureMaterial

Software: Away3D 4.x

datouaizi, Member
Posted: 19 July 2012 04:01 PM   Total Posts: 98

it doesn`t` change material! why? please help me!

 

File Attachments
AnimateTextureMaterial.as  (File Size: 2KB - Downloads: 218)
   

Richard Olsson, Administrator
Posted: 19 July 2012 04:30 PM   Total Posts: 1192   [ # 1 ]

Please describe the issue, or upload your code to some other place where it can be easily displayed (e.g. paste it into gist.github.com).

   

datouaizi, Member
Posted: 19 July 2012 11:47 PM   Total Posts: 98   [ # 2 ]

https://gist.github.com/3147687

I flow your advice,pased it .someone can help me?

   

Richard Olsson, Administrator
Posted: 20 July 2012 10:38 AM   Total Posts: 1192   [ # 3 ]

Let me guess, it only shows the first frame?

Unless I’m mistaken, you can’t use the clipRect property of BitmapData.draw() that way. Have a look at this Stack Overflow question: http://stackoverflow.com/questions/1880601/does-cliprect-parameter-of-the-bitmapdata-draw-method-really-clips-the-source

You should probably be using copyPixels() instead if you want to do what you are doing.

But then you probably shouldn’t be doing what you’re doing at all, because it effectively uploads a new texture to the GPU every frame. You also create a new material every frame, and never dispose the old one or the texture, so after a minute or so you should be running out of texture resources and start getting errors thrown at you.

The correct way to create something like this is to apply your animation strip (the large image with all the frames) as the texture to your object. Then scale the object’s UV coordinates so that they only map to one frame (i.e. set SubMesh.scaleU to 1/numFrames) and then offset the U every frame using SubMesh.offsetU. Also set animateUVs to true on the material to have it respect the UV transform.

That way you’re not sending any unnecessary information to the GPU every frame.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X