Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Positioning Objects out to extreme ranges causes issues - why?

Author
Message
LightningSky
14
Years of Service
User Offline
Joined: 22nd Feb 2010
Location:
Posted: 9th Apr 2010 06:15
Howdy all, relatively new to DBPRO. I need something explained to me because I can't figure out why this is happening. In the following code:


I am playing around with X, Y, and Z positions for objects. When an object stays within the bounds of -10000,-10000,-10000 -> 0,0,0 <- 10000,10000,10000 the object remains stable. However, when I increase the distance of the object from the origin point of 0,0,0 the object starts to become unstable while the camera is moving. Go out to say 0,0,300000 and position the camera so the distance from the object to the camera is close and you'll notice as you move the camera the object starts to bounce around. It doesn't remain stable on the x,y,z position that you gave it. Can someone explain why this is? Please, no smartass answers, I'm new to 3D programming and I realize I have a lot to learn. I thank you for your time in reviewing this issue for me.

- A man from nowhere, prophesized to fail, blazed beyond the brightest of them all.
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 9th Apr 2010 18:17 Edited at: 9th Apr 2010 18:19
This is common in a lot of game engines. It has to do with floating point inaccuracy.

The most common solution is to scale everything for your game down, so you stay within the area where you don't get the bouncing.

Another solution, although not as popular, is to not move the player, but move everything else in relation to the player when they move.

luskos
17
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 10th Apr 2010 03:13
The answer is that everything have boundaries, sometimes they are so far away that you may think they do not exist but they are.

Try what KISTech says.I like scaling more than moving everything else, because it`s like moving a building to see what is behind when you can really go arround and see by yourself, but all depends of the game really.

If you look at my code you will se how fast really you can reach any bounadry.Sometimes is a matter of seconds.

This simple program show you the max value dbpro can handle to count to.Which i think is 1 infinite, if there is a number with this name.




Where there is a will, there is a way.
I often edit my posts, that`s who i am
LightningSky
14
Years of Service
User Offline
Joined: 22nd Feb 2010
Location:
Posted: 10th Apr 2010 04:39
Hey there, thank you very much for your fast responses on this. I'll play around with scaling. Scaling adds complexity, which adds computational processing, which of course has an adverse affect on performance. So much to learn, yet I have so thoroughly enjoyed the journey thus far.

Again, thank you for your time.

- A man from nowhere, prophesized to fail, blazed beyond the brightest of them all.
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 10th Apr 2010 07:53 Edited at: 10th Apr 2010 07:57
The ideal solution would be if the engine used Double Floats for more precision, but that's not likely to happen with DBPro or any other engine that currently uses floats, because they would have to change ALL of the functions that used floats for positioning to use Double Floats. It could be an easy task, but it's probably not.

The really strange thing is, my game has players go all the way from -400,000 to 400,000 in all directions, and I don't have the bounce problem. What I DO have no matter where the player is, is drift. Since floats are being used for their position and rotation, and I'm constantly processing their ship's movement and angle, if they are sitting still the ship tends to "drift" because small floating point inaccuracies cause a tiny amount to be added to their current position and angle each loop.

LightningSky
14
Years of Service
User Offline
Joined: 22nd Feb 2010
Location:
Posted: 10th Apr 2010 10:08
It's right around the 350,000 to 500,000 that it starts getting jittery. However, a .X model looses cohesion around 200,000. But this may also be my lack of completely understanding what I am doing when creating .X models.

I guess the good thing about this is, is that it forces me to learn matrix's and vector transformations, of which I knew I would have to get into sooner or later. Was hoping for later

Right now that seems as daunting as the concept of "...there is no spoon..."

- A man from nowhere, prophesized to fail, blazed beyond the brightest of them all.
Serial Velocity
16
Years of Service
User Offline
Joined: 24th Aug 2008
Location:
Posted: 10th Apr 2010 13:23 Edited at: 10th Apr 2010 13:24
How I did it in Starscape One was to keep the player centered at 0, 0, 0 and move everything else in relation to the player so the player appears to be moving.

The easiest way to do this is to keep hold of the velocity vector (XYZ speed) of the object your tracking, and use a function to make use of the velocity vector to move every object in relation to the one your tracking.

Untested Code:


Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 10th Apr 2010 15:37
Try using double precision floats.

"everyone forgets a semi-colon sometimes." - Phaelax
Masqutti
14
Years of Service
User Offline
Joined: 8th Jan 2010
Location: insanity
Posted: 11th Apr 2010 02:09
How about set camera range? I'm not sure if it affects distance, but I've realized that If I've made a huge plain to act as water, then set the camera range near value to a minimal, like 0.0001 the waterplain(2 polys) starts to bounce. even at very close. Everything else may seem like ok, but that hugely scaled 2 poly-plain starts to bounce. Then set camera sange near value to 1,m the bouncing stops / goes unnoticable.

hmmmh.. that didn't compile
LightningSky
14
Years of Service
User Offline
Joined: 22nd Feb 2010
Location:
Posted: 11th Apr 2010 04:47
Serial, I like the concept. I was trying to do something along the same lines, adjusting each objects positional vector. Basically each object would have two positional vectors. A true location vector, and an actual drawn vector. I can use the true location vector as navigational targets to draw something on the screen for the player to click on. I'm trying right now to just understand the full concept of vectors. Rather than using 3 variables to control speed I should be able to use the "magnitude" of the players ship vector which would increase or decrease based on the rate of speed the player is travelling at. I'm also trying to work out when I would actually draw the object versus just showing a small dot, based on the object's distance from the player. My goal is to work out the realism of flying within a solar system. I don't want the planets to just be warp points and I don't care for the idea of warp gates. My hope is to allow the player to simply point their ship in a direction and hit the "whatever you want to call them" engines to get you to within a planet's gravity well, while at the same time allowing for engines to fail and you getting stuck between orbiting bodies, or if the player wants to stop as well before reaching their destination. So the idea of keeping the player at 0,0,0 would work. You just basically move the universe around the player, thanks Serial.

Zotoaster, I tried using floats. Nothing worked. As long as I work within a -200,000 <-> 200,000 zone I have no issues.

- A man from nowhere, prophesized to fail, blazed beyond the brightest of them all.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 12th Apr 2010 02:33
Not floats, double precision floats. I believe the keyword in DBP is "double float", though I might be wrong: "x as double float". They're more accurate.

"everyone forgets a semi-colon sometimes." - Phaelax
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 12th Apr 2010 18:40
Feeding double floats into the movement or positioning functions wouldn't make a difference would it? Those functions are expecting floats.

LightningSky
14
Years of Service
User Offline
Joined: 22nd Feb 2010
Location:
Posted: 14th Apr 2010 06:49
WOOOOOT!!! I got it finally. Using simply a velocity and heading/pitch angles I can now position my character at 0,0,0, while walking a vector variable around the universe, which the inverse of becomes what the orbiting objects use to move to and from the main character. This now allows me to create a true solar system with the appropriate numbers, knowing that anything drawn with detail will always be around 0,0,0, negating the damn floating point problem of the 3d engine. This is AWESOME!

Thanks everyone for your input. It's good to know I've joined a community that helps out.

I've still got some tweaking to do, but I am finally on the right path, again.

From what I have read on other posts, Matrix4's would probably simplify what I have done, but here's part of my code:


Just set Velocity to the speed of your character and your good. Now I haven't worked out the up/down angle's yet, that's the tweaking I still need to do. Anyone with Matrix4 experience, I'd love to see how it's done with them.

- A man from nowhere, prophesized to fail, blazed beyond the brightest of them all.

Login to post a reply

Server time is: 2024-11-23 17:01:34
Your offset time is: 2024-11-23 17:01:34