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.

DarkBASIC Professional Discussion / First post - 3d issues

Author
Message
Garry1540
15
Years of Service
User Offline
Joined: 28th May 2011
Location:
Posted: 28th May 2011 19:14
Hi this is my first post, I have been using DBP for just a couple of days and thought the best way to learn about it was to try and build a simple game - so far I feel it is going quite well but I have a few issues that I can't think of ways to sort.

The first is that my game takes place in a 3d box where I can move in any of 6 directions. When I reach the side of the box I reappear on the opposite side - think of a 2d game and going off one side of the screen to appear on the opposite side.

This works well by just resetting the side value for the opposite value. The problem is that the sides still look like a wall in that I can't see beyond it until I cross through it.

Can anyone think of a way to 'see' what is coming up, i.e. see what is on the opposite side of the space? I hope that makes sense.

Thanks in advance.
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 28th May 2011 20:14
Welcome then

Two approaches off the top of my head;

1) Duplicate the scene (yes, or at least as much of it as you can see from the edge of your box) on each side (rotated to be mirrored) of your main, central box. As the player moves into any of the outer boxes you'll re-position him at the appropriate place within the main box. Given that everything is lined up correctly, it would look as if just continuing around.

2) You can set up secondary cameras around the edges of your box and capture their viewports to images that you then project to plains positioned at the corresponding edges. Beware that you can only have 7 (or is it 8, including the main?) cameras at once though, so it might be a waste. Also it will slow things down as the scene will need to be rendered once for every camera in every loop cycle (whether that will make a noticeable difference depends on the complexity of your scene + power of your graphics card).
If you go with this approach you would position the cameras at the edge's positions, subtracted with the distance to the player from that particular edge... I think that should work anyway.

Good luck


"Why do programmers get Halloween and Christmas mixed up?"
Garry1540
15
Years of Service
User Offline
Joined: 28th May 2011
Location:
Posted: 29th May 2011 00:58
Rudolpho

Thanks for the quick reply and the tips.

I'm not sure about option 2 unless there is a way to overlay two cameras. As I approached the edge (barrier) I would need a camera to show what is beyond, but in scale to my current position but I would also need my main camera showing my current view and anything before the edge. I'm not sure if this is possible or even if I could program it.

Option 1 has some possibilities. Perhaps I could duplicate the scene offset somehow, (in the direction I'm moving), to include everything from about half way in the actual game area and everything from behind me, and place a camera in that area until the transition back into the actual game area. I'm not sure I'm bright enough to handle the code for this and I also need some collision detection across the actual and duplicated views.

I somehow thought there must be a trick used in games where you can fly off in one direction and end up arriving back where you started without a noticeable wall or barrier to cross. It works on 2D Asteroids etc, is there not a standard or easy 3d solution?
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 29th May 2011 15:29 Edited at: 29th May 2011 16:19
I am unsure what you mean exactly? A screenie might be nice to give us more idea what you mean. I cannot see the problem at the min, and the only thing I can think of is say pac man going from left edge to right edge, etc but still cannot see what the problem is?
Edit - Oh do you mean any angle and position as in asteroids perhaps?
I would imagine the easiest way is to use your co-ordinates and simply flip them on the edge. I can't see what difference 2D or 3D would make to this offhand, apart from making co-ordinates easier to handle as 0 will always be the left edge and 640 the right for instance. Not sure again what you mean by "wall".
Edit - I have done a quick example for you as I am hoping this is what you mean.



Let me know if this helps or you are after something else. It is very rough and ready and obviously dependent on your scene you will have to play with your co-ordinates.

http://s6.bitefight.org/c.php?uid=103081
Garry1540
15
Years of Service
User Offline
Joined: 28th May 2011
Location:
Posted: 30th May 2011 15:05
I'm probably not expressing myself very well. In Asteroids when you go off one side of the screen you reappear at the opposite side. Just like the excellent example you game.

Now think of 3D asteroids but in first person so your view is from the ship. If you travel to the edge of the game area, you reappear at the opposite side. So in effect you can travel in one direction forever but always cross the same area

I have set the maximum game area, x,y,z to 1000. It all works quite well in that I can fly around in all directions in 3D using buttons and changing camera angles to the direction I'm travelling. When I hit a value of 1000 in any direction it resets to 0 (and if I hit 0 it resets to 1000) so it is like going off one side and reappearing at the opposite side.

The problem is that I really want this transition to be transparent to the player from their cockpit view. At present if I'm travelling in one direction and reach a value of 900 for example I can only see objects between 900 and 1000. I can't see beyond this (essentially 0 and beyond) until I reach 1000 and it resets back to 0.

Does that make more sense? How can I see what I'm approaching before I cross over to the other side of the game area?
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 31st May 2011 01:42
It makes sense to me from the start however implementing this would be difficult unless you reposition everything to fit in with your 'WORLD' coordinates. All the asteroids are floating around, and you go out of the sphere of the playing area. The scenery will change if zapped to other coordinates (if in a cube or sphere mapped background)

Solutions:

1: make a transform from edge to edge (easiest), scenery changes but somewhere else... (also show the edge coming up so the player knows its inevitable)

2: move all other objects instead of your own. If they go out of your space then delete them (after a count out).

3: I'll leave that for the rest of the gang to answer...

Warning! May contain Nuts!
Garry1540
15
Years of Service
User Offline
Joined: 28th May 2011
Location:
Posted: 31st May 2011 10:35
Thanks WLGfx.

I only used Asteroids as an example. I'm only trying to learn by using a simple game as a project so I don't have any thing moving like Asteroids, just the player. It is actually more like a 3D maze and all objects once placed are static. And I'm only ever moving in straight lines and turning at right angles.

I'm not sure I understand what you mean by making a 'transform'. Is this a command? I can't find any reference to it.

I had thought about actually keeping static and moving the whole 3D world around me. Perhaps putting the objects in an array and moving their places in it relative to my position somehow. Would this work? It might be beyond my abilities to do this so I wouldn't want to start down that road unless I'm sure it would give the effect I'm after.
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 31st May 2011 20:27 Edited at: 31st May 2011 20:32
Oh a 3D view! Lol, when you mentioned asteroids I obviously thought of normal asteroids using 3d objects. As WLGfx says to do what you want is difficult because of your view. The only way I can think of is implementing a similar system to a 2d scroll technique. Option 2 on WLGfx's list. Don't move your ship, move all the objects, when the object lies behind you, place it back in front at the relevant co-ords. So instead of moving through the scene and repositioning your ship at the start of the scene move the objects of your scene back in front as you pass them. Quite easy if you only move forwards and backwards, say if you wanted a train track to seem to run forever for instance. More difficult if you can fly anywhere though, but ultimately possible. Just a lot more to do. You should be able to have a loop-able scene doing that.

This doesn't seem like a particularly simple starter project to me though. I normally go for simple things to cut my teeth on a language, say a very simple 2D shooter for starters. Hangman is also a good way to learn a lot of things about string manipulation. By all means jump into 3D, it's the reason I purchased Dark Basic all those years ago (I was amazed at the scorpion demo at the time, considering it was in BASIC.), but if you are starting out it may be best to start simpler. You may be a veteran of course. Just not used to 3D.
Hope that helps. I would write a little routine to show you, but am busy on a project at the moment. If you are still stuck I will have a look when I can.

http://s6.bitefight.org/c.php?uid=103081
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 1st Jun 2011 02:47 Edited at: 1st Jun 2011 03:04
I did something like this in a 2d asteroids game:
http://www.youtube.com/watch?v=cQ1n1-ls2CQ&t=3m5s

you can see that whenever the ship reaches the edge of the playing field, it is visible on the other edge.

To do this... I just drew the ship 9 times, so if a function draw(x,y), drew a spaceship at (x,y), and w was the width of the screen, and h was the height of the screen, I'd just be calling:
draw(x-w,y-h) : draw(x,y-h) : draw(x+w,y-h)
draw(x-w,y) : draw(x,y) : draw(x+w,y)
draw(x-w,y+h) : draw(x,y+h) : draw(x+w,y+h)

so draw 9 screens (a 3x3 rectangle). this is the lazy way, and if you did the exact same thing in 3d, you'd need to draw 27 (3x3x3) objects for every object you made. (instead of writing out 27 lines, you could say



That's a really simple, nice way to do it though. For any optimization you'd need to check if an object is in view, aaand you can do that using math, or functions like pick screen and tests to see if the object is visible.

So, easy answer: draw 27 times the number of objects
hard answer: optimize to draw only the objects on screen


Tell me if there's a broken link to images in a thread I post, and I'll fix 'em.

Login to post a reply

Server time is: 2026-07-10 21:41:09
Your offset time is: 2026-07-10 21:41:09