Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  repeating/endless universe  (Read 2208 times)
0 Members and 1 Guest are viewing this topic.
Offline Usul

Senior Newbie




I hunt bugs


« Posted 2005-08-05 09:46:16 »

hi,

I'm trying to do a 3d asteroids game. 

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
Offline anarchotron

Junior Member




...precious bodily fluids.


« Reply #1 - Posted 2005-08-05 16:18:09 »

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.

Check out
http://enderton.org/eric/torus/

Hope that helps!
Offline Usul

Senior Newbie




I hunt bugs


« Reply #2 - Posted 2005-08-05 16:46:29 »

Thanx for your reply but I dont see how that can be implemented with Java3d.  Its a very theoretical and mathematical approach.

There are probably/hopefully better solutions.

Any other ideas?

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
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline anarchotron

Junior Member




...precious bodily fluids.


« Reply #3 - Posted 2005-08-05 16:50:59 »

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!
Offline Usul

Senior Newbie




I hunt bugs


« Reply #4 - Posted 2005-08-05 17:44:04 »

I googled and it doesn seem that java3d supports this.

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
Offline Jeff

JGO Coder




Got any cats?


« Reply #5 - Posted 2005-08-06 00:16:29 »

Do it exactly the same way asteroids does.

In your animation, when you hit the bounds of your "world",  warp yourself to the other side.

Ocam's Razor strikes again.

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!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline anarchotron

Junior Member




...precious bodily fluids.


« Reply #6 - Posted 2005-08-06 02:07:59 »

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.
Offline Jeff

JGO Coder




Got any cats?


« Reply #7 - Posted 2005-08-06 02:53:59 »

Oh. I wasn't clear he was trying to scroll the view.

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!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Usul

Senior Newbie




I hunt bugs


« Reply #8 - Posted 2005-08-06 10:12:33 »

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.

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
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #9 - Posted 2005-08-06 13:20:30 »

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.

malloc will be first against the wall when the revolution comes...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #10 - Posted 2005-08-06 13:21:40 »

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

malloc will be first against the wall when the revolution comes...
Offline Usul

Senior Newbie




I hunt bugs


« Reply #11 - Posted 2005-08-06 15:27:36 »

Thank you blah^3 !

So thats the way to go then.

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
Offline Jeff

JGO Coder




Got any cats?


« Reply #12 - Posted 2005-08-07 04:42:56 »

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 view
along 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!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Usul

Senior Newbie




I hunt bugs


« Reply #13 - Posted 2005-08-07 07:18:44 »

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 view
along with it?

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

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
Offline Jeff

JGO Coder




Got any cats?


« Reply #14 - Posted 2005-08-09 01:06:46 »

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 view
along 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!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Usul

Senior Newbie




I hunt bugs


« Reply #15 - Posted 2005-08-09 08:49:55 »

thanx jeff, but I think I'll use the blahblahblah approach.

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
Offline rdcarvallo

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #16 - Posted 2005-08-09 19:20:38 »

Good point Jeff,
 
    Never  found out a way to repeat the objects..

    Blah3's method works very well with static geometries like terrain (I have a terrain generator that makes the terrains tileables)

     Now I' will  try to make it work !

     Rafael.-


Offline Usul

Senior Newbie




I hunt bugs


« Reply #17 - Posted 2005-08-09 20:39:28 »

     Now I' will  try to make it work !

So you are trying the same thing?  Please tell me if it worked, because I'm going to vacations this week and I wont start this until I'm back.

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
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (28 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (72 views)
2014-09-10 06:39:09

Tekkerue (37 views)
2014-09-09 02:24:56

mitcheeb (57 views)
2014-09-08 06:06:29

BurntPizza (43 views)
2014-09-07 01:13:42

Longarmx (27 views)
2014-09-07 01:12:14

Longarmx (34 views)
2014-09-07 01:11:22

Longarmx (34 views)
2014-09-07 01:10:19

mitcheeb (40 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!