But like the original 2d asteroids, the universe should be repeating itself. That means, that if you fly out on the top then you should re-enter at the bottom.

But the problem is: How does one do this?

I know its no problem to check if the user has passed the boundary of the universe-box and then change his position accordingly. But the real problem is how the user will be able to see correctly. That means if he is for example at the bottom of the universe-box and looking down and there is an asteroid at the top of the universe, then the user should see it of course. So for the user, the universe should seem endless.

Maybe thats more of a logic question then a Java3d question.

Any ideas appreciated.

thanx,

Usul

It's times like this that I wish I'd listened to what my dad used to tell me. Yeah? What was that?I don't know. I never listened. - Dr. Venkman and Mr. Zeddemore

I think the key to this problem is understanding the shape of the universe in this wrapping scenario.

In a 2d game like CIVILIZATION, where the game world wraps around the left/right edges but not top/bottom, what you have is a game world projected into 2d from the surface of a 2d cylinder.

In a 2d game like ASTEROIDS, where the game world wraps around the left/right and top/bottom edges, what you have is a game world projected from the surface of a 3d torus.

Maybe you can approach your 3d wrapping world problem by visualizing your game world as a 4d torus, and then mapping the coordinate system into 3d space.

You can think about this in 3d->2d first. For instance it is very easy to think about the surface of a 3d torus with a viewpoint somewhere on the surface. Then take the torus surface and 'slice' it on the edges opposite the viewpoint. This sliced surface can then be unwrapped into a 2d plane.

True I don't know if Java3D has any direct support for something like this. I would assume that you need to manage your world space and transform your points from your 4d torus into 3d space each frame before rendering. I know that's exactly how it would be done in OpenGL. If Java3D has some kind of '4d torus scenegraph' support, then by all means use it!

I wasn't trying to complicate things, he said one of his goals was to render the 3d world in such a way that the view wraps around the edge just like the player does. If you just teleport the viewport around in a static pile of 3d objects you won't be able to see past the edge until you abruptly teleport across it.

If this is a 2D game then frankly I dont think I'd use Java3D for this.

You *might* be able to set the view transform to correct for the curvature of the space, its pretty flexible, but thats a lot of heavy math and difficult work to do soemthing pretty simple.

I'd just use JOGL and do this as a 2D plane. Id store the object positions individually and rather then moving the view, Id adjust the object positions around an origin centered on the ship. Again to get the wrap Id simply bound X and Y in the animation.

Come to think of it you could do this with J3D too but it still feels like its way much over-kill.

Got a question about Java and game programming? Just new to the Java Game Development Community? Try my FAQ. Its likely you'll learn something!

Its not 2d its 3d! The universe is supposed to be a 3d-box and if you are at the edge you should see whats on the other side.

Maybe I'll try a cheap trick: if the player is near the edge, then all the objects which are on the other side are "copied" in front of him, even though their real position is on the other site.

This is the stnadard approach most people use. They have 27 boxes in a 3x3x3 grid, of which 26 are clones of the central one. When the player moves into any box, the 9 boxes furthest away are copied to the other side, so the player is always in the central one.

More intellgient variants are to jump the player inside the central box so that you have no problems with your co-ordinates being different from what you expect, and cleverer routines that ensure you never see geometry twice on screen (the copy in your current box and the copy in your far box) - although this can usually be fixed by doing some visibilty clipping so that you can always see exactly 1 x box-length into the distance (along the 3 axes, so it's not just a distance, but distance along axes), which automatically guarantees you will never see duplicates.

PS part of the reason it's standard is that it can then be trivially upgraded at a later date to an infinite universe in a shared multiplayer game....most MMORPGs use this basic scheme to support efficient loading and holding of "infinite" amounts of 3D data etc on the client

Even in 3D it seems like way too much work if you are keeping the view centered on the player.

Instead, you could just KEEP the player at origin and transform everyone else according to inverse of the player's movement.

Remember, Einstien showed us that all motion is relative.

AIR objects didnt enter on teh far side of asteroids til they totally left the screen, they wer never half on one side and half on the other. To get that effect all you need to do to do that is to have the play space be enough biger then the near side of the view frustrum that the ship wholly leaves the screen before you warp it to the other side

P.S. Im stil not sure I understand how this game is 3D.. do you intend to let the user rotate thier ship in 3D and rotate their viewalong with it?

Got a question about Java and game programming? Just new to the Java Game Development Community? Try my FAQ. Its likely you'll learn something!

P.S. Im stil not sure I understand how this game is 3D.. do you intend to let the user rotate thier ship in 3D and rotate their viewalong with it?

Ever played Descent? Or Freelancer? Or Wing Commander? I dont know how to explain it. Just normal 3D.

Yup I know Descent.

So its a first person, not a third person game. That makes a big change from Asteroids.

If thats the case then you can still warp objects, the trick is this:

(1) Imagine that you are always at the origin in a fixed poitn of view(2) Everything else rotates around you and moves in and out.(3) At some distance from you D, which is bigger then your far clippign plane, you warp the object by flipping the sign on its coordinate on that axis.

Got a question about Java and game programming? Just new to the Java Game Development Community? Try my FAQ. Its likely you'll learn something!

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org