Texture animation in Away3d 4

Software: Away3D 4.x

Felix44, Newbie
Posted: 27 June 2012 07:43 AM   Total Posts: 3

hi,
For a Kinect driven game, I’m trying to make a Sprite3D animated.
For the moment I’m updating the texture’s bitmapData. It’s working but I’m not sure it’s the best way to do that kind of things.
I read about updating UVmaping of a single bitmapdata but I have no idea how to do that.
Is there a kind of MovieMaterial method like in Away3D 3.x ?

thanks

   

Richard Olsson, Administrator
Posted: 27 June 2012 04:25 PM   Total Posts: 1192   [ # 1 ]

What kind of animation are you trying to achieve? How large is the sprite/texture?

If you just want to move something around, UV transformation is the perfect solution. If, however, you want to do frame based animation, you can also achieve that through UV transformation by splitting a larger texture up into frames and translating the UVs enough to jump from one frame to the next in the texture. This is what is referred to as “spritesheet” animation.

Whether or not you can use spritesheet animation depends on your use case. If you explain more about the type of content you want to animate it will be easier to give good advice.

   

Felix44, Newbie
Posted: 28 June 2012 08:41 AM   Total Posts: 3   [ # 2 ]

It’s a third person game (A bird flying in a sky). Since there is a lot of elements in the scene we decided to included almost of them as Sprite3D.
Actually the hero is 1024x512px wide and the animated texture if for frame based animation (flapping wing, bird’s turn…).
We already thought about spriteSheets but don’t know how handle it (in the TextureMaterial ?). Is there a Class to easily do that ?

Thx

   

Richard Olsson, Administrator
Posted: 28 June 2012 08:44 AM   Total Posts: 1192   [ # 3 ]

No, there is no shorthand for this in Away3D 4.0, although I’ve built several in single-purpose (client) cases and it really is not very difficult.

Just calculate the UV space dimensions of each sprite in your sheet. If you have 4x4 sprites, each sprite is 0.25 on the U axis and 0.25 on the V axis.

Then just scale the UVs down to 0.25 on your mesh (SubMesh.scaleU, SubMesh.scaleV) and to swap between frames, offset the UVs similarly using SubMesh.offsetU and SubMesh.offsetV. Make sure to set animateUVs to true on your material.

   

Avatar
Alexander Seifert, Moderator
Posted: 03 July 2012 09:47 AM   Total Posts: 129   [ # 4 ]

The thing is that Sprite3D doesn’t support uv transformations since it doesn’t extend Mesh and does not have a SubMesh, in which its Geometry is encapsulated. I’d use a custom class that extends Sprite3D. You need to copy over the uv transform matrix and related stuff from SubMesh. Then you need an update method that you can call to change scaleU/V and offsetU/V, as Richard explained above.

 Signature 
signature_image

http://www.deltastrike.org

   

CraigMurray, Newbie
Posted: 29 January 2013 11:24 PM   Total Posts: 4   [ # 5 ]

Would it be a performance problem to have each frame of animation as it’s own material and swap between them using mySprite3D.material = _aniFrames[x]; ?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X