As ball moves away from view it updates less and less
I'm having a problem where as i update the graphics of a ball moving away from the viewer and back again, the further i move the ball away from the view the less in updates.
I draw the ball with its diameter being 900/ Zaxis . ( 45(start of Zaxis) * 20(size of ball in pixels) = 900 )
The axis runs from 45 to 135 so the balls size varies from 20 pixels(when close) down to 6 pixels(when away) wide.
As the ball moves further down the Zaxis (45++) the size of the ball gets smaller and the screen updates.
but the further away it is the less the size decreases and it appears the game is slowing down (though it is not).
I calculated some of the computations that the cpu and i found where the promblem is!
This is writen in MicroJava2 so there are no support for floats or doubles so anything after the decimal point is just discarded (not rounded)
loop count.....Zaxis.......Ballsize
1..................45...........20........................1
2..................46...........19.56
3..................47............19.14...................2
4..................48............18.75
5..................49.............18.36
6...................50.............18......................3
7..................51...............17.64
8...................52...............17.3.................2
9..................53..............16.98
10...............54..............16.66
11...............55.............16.36
12................56............16.07.....................4
13...............57..............15.78
14...............58...............15.51
15..............59................15.25
16.............60...............15..........................4
17..............61..............14.75
18..............62..............14.51
19..............63..............14.28
20..............64..............14.06......................4
21..............65..............13.84
22..............66..............13.63
23..............67...............13.432
24..............68..............13.23
25.............69.............13.04........................5
26.............70..............12.85
27..............71..............12.67
28..............72..............12.5
29..............73...............12.32.
30............74.............12.16
31............75............12...............................6
as the number gets larger 45>>>75 the number of loops the game goes through before the ball is updated increase from 1 to 6 and it continues to get worse!
I was trying to come up with some other of doing the like have the Zaxis run from maybe a different set of numbers so always a new whole number is returned??
Is this possible and would it fix the problem if it was??
Thanks Brian
[edited by - Woody FX on July 21, 2003 2:22:24 PM]
I fail to see the problem, if the size is in pixels, the smallest change you will be able to make out is a 1 pixel reduction.
You''re running the diameter through the perspective transform, so the final diameter is not linear -- so its rate of change is guaranteed to vary with distance.
Stuff a Z value in the corner to show that the game is still updating, or just ignore it until you have more things in the world.
You''re running the diameter through the perspective transform, so the final diameter is not linear -- so its rate of change is guaranteed to vary with distance.
Stuff a Z value in the corner to show that the game is still updating, or just ignore it until you have more things in the world.
I would like the rate of change to be linear!
But maybe you have answered my Question.
Maybe i am looking at it the wrong way.
The size off the ball has to be linked to the distance the ball is away from the view point but maybe i will just have to leave things!
But would rather the balls size increase and decrease in a linear fasion.
Brian
But maybe you have answered my Question.
Maybe i am looking at it the wrong way.
The size off the ball has to be linked to the distance the ball is away from the view point but maybe i will just have to leave things!
But would rather the balls size increase and decrease in a linear fasion.
Brian
You don''t have the use the same transformation to get the size of the ball for a given z position as you do to determine where the ball should be positioned on the screen. Assuming you want the ball to be 20 pixels when at z = 45 and 6 pixels when z = 135, you need some function such that
f(45) = 20
f(135) = 6
and the function varies linearly between these points.
f(z) = m*z + b
f(45) = 20 = m*45 + b
f(135) = 6 = m*135 + b
Solving for m and b gives m = -7/45, b = 27.
The results might look weird, however, in that physically the ball should scale in size at the same rate as its x and y positions move towards the centre of the view as z increases.
f(45) = 20
f(135) = 6
and the function varies linearly between these points.
f(z) = m*z + b
f(45) = 20 = m*45 + b
f(135) = 6 = m*135 + b
Solving for m and b gives m = -7/45, b = 27.
The results might look weird, however, in that physically the ball should scale in size at the same rate as its x and y positions move towards the centre of the view as z increases.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement