Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

d73bmh

Keeping up the precision

This topic is 6295 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

Hi, I have been developing a nice networked sports game for which the requirements stated a true physics model. So I decided to implement the system in partial 3D i.e. the physics layer in 3D and the presentation layer in isometric. However by representing player positions using floats I am introducing rounding error when plotting. This causes the players to shake slightly when the camera scrolls accross the playing area. Is there anyway I could improve this without resorting to moving the camera/sprites around in screen space? Cheers. John. Edited by - d73bmh on February 19, 2001 3:37:22 PM

Share this post


Link to post
Share on other sites
Advertisement
Replace all floats with doubles. If this doesn''t help then u might have a conversion problem somewhere.

Share this post


Link to post
Share on other sites
The actual unit positions of the sprites is in the order of 1000s so the precision of the position is not really the problem, it''s the rounding caused by transformation of the 3D float position into 2D integer screen co-ords that is causing the shaking. I could just ensure that the positions of each of the sprites lies on a resolved integer boundary, but this seems to be really ugly to implement. The only other way would be to only use integer co-ords for the sprites and operate on them in screen space, however all my physics routines would have a fit!

Share this post


Link to post
Share on other sites
Hmmm sorry man maybe your problem is that the center of a square,pix is in the mid:

X-----X <--Have u positioned your sprites here
|--X--|
|--X--| <--Or here?
|--X--|
X-----X

There shouldn't be any rounding problems from 3D to 2D if the math fits. If this doesn't help you, then sorry man.

Edited by - Jonus on February 19, 2001 5:52:20 PM

Share this post


Link to post
Share on other sites
for a second I thought that was it but the sprites are positioned at the top left. I have noticed that the problem is really the shaking between sprites, which might be due to the camera also having a floating point position. If I was to transform that first and then offset all the sprites in screen space that might fix it? I dunno, any ideas?

Share this post


Link to post
Share on other sites
One issue that can develop is that float to int is not true rounding.
i.e.

1.6f = 1, but should be 2

1.2f = 1

to get true rounding, add 0.5f to the float before conversion.

Maybe this will help?





mat williams
Lead Programmer, Designer
Zero Sum Software
www.zero-sum.com

Share this post


Link to post
Share on other sites
It seems that true rounding just changes the boundary at which the players jump on screen. When doing 3D there must be a similar positioning problem between objects (within an object the vertices will all accumulate the same error, so end up sticking closely together), how do they fix that? All the stuff I have seen relates to scanline rendering of polygons which doesn''t really count with bitmaps. hmmm..

Share this post


Link to post
Share on other sites
quote:
Original post by d73bmh
how do they fix that? All the stuff I have seen relates to scanline rendering of polygons which doesn''t really count with
bitmaps. hmmm..


When you are not scrolling does this *wobbling* still occur?

Are your sprites positions using fractions?

I think the problem ,just a guess, is that you are using mixing two coordinate systems. I tend to hold all positions in integers
calculate the floating point stuff then demote it back to
the integer space. But it should not matter either way as long
as you are consistent.

If all your objects,including the map, go through the same
transformation math then they will all have the same error
accumulation and you should not see any wobbling.





Share this post


Link to post
Share on other sites
I actually managed to fix it over the weekend, it was pretty simple. The wobble was caused by the camera transformation being done in world space, I just moved this to screen space and voila!

Cheers,

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!