Sign in to follow this  

Sprites and animation.... problems...

This topic is 4858 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey there, im using the DirectX 9 SDK(b) before the summer update... anyway ive got a problem with sprite animation... i have a sprite map 396x45, which contains 18 animations... but tihs is irelevent really.... anyway each given sprite is 22x45 so i just use an incrementing loop to give each sprite in the animation its own rect so animation 1 would be: Animation_Rect[0].left = 0; Animation_Rect[0].right = 22; Animation_Rect[0].top = 0; Animation_Rect[0].bottom = 45; and animation 2 would be: Animation_Rect[1].left = 22; Animation_Rect[1].right = 44; Animation_Rect[1].top = 0; Animation_Rect[1].bottom = 45; anyway im sure you budding mathematicians get the forumla here.. anyway when i go to the image using the sprite it doesnt show it correctly. It cuts off sections and when i animate it and by animation 4 it shows half of animation 3 and the 1st half of animation 4.... anyway heres some screenshots beneath so you know what i mean... http://www.distortedtruths.co.uk/grofit/Other/Input.bmp http://www.distortedtruths.co.uk/grofit/Other/Output.bmp Anyone know why its not mapping this correctly when rendering? i read somewhere about texels/pixel offsets..but there was no solution... anyway any help would be great...as i dont really want to have to hardcode each animations attributes... anyway thanks for any help :)

Share this post


Link to post
Share on other sites
mm.. I'm not too experienced with DX myself. So I can't propably help you but usually you can't render 22x45 textures(or sprites) and only sizes which are in powers of two can render properly. (2x2,4x4,8x8,16x16 etc.)

Share this post


Link to post
Share on other sites
Quote:
Original post by Grofit
i have a sprite map 396x45, which contains 18 animations... but tihs is irelevent really....


It's very relavent. When you try to laod in a non-power2 texture, direct3d would load it into a power of 2 texture and black out th eextra bits. THen your're offsets would automatically be wrong on this new texture size. 512 may be a waste, but sometimes it would be the only wayto do it. Besides you can get 512x46 instead of 512x512, but then agian, some cards dont even like non-square textures, so, that might mess up too.

Or you could probably reformat the texture into a 128x128 image so that it takes up less space?

Share this post


Link to post
Share on other sites
I recommend storing in more than one row. You currently store all 18 frames on the first row. If you store 5 on the first, 5 on the second, 5 on the third, and 3 on the last, so you have to have a texture minimum of 5x22 wide and 4x45 high which is 110x180, of course which means you'd need to pad the final texture to a 256x256 to make it work. Or, you could take out some of the height, and add it to the width. 6 on first row, 6 on second, 6 on third. Now, you have 6x22 for width and 3x45 for height...viola it's 132x135. I'm sure that you could reduce your frames by 1 pixel in the width and 2 in the height. Then you could use a 128x128. It's good to try to optimize when you can...but make sure it's a savings that will be worth the effort.

Chris

Share this post


Link to post
Share on other sites

This topic is 4858 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this