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 / Movement boundaries, 3D movement restriction.

Author
Message
Nights Bane
14
Years of Service
User Offline
Joined: 15th Dec 2009
Location:
Posted: 4th Sep 2010 18:30
I've uploaded my game code for a dwarf fortress tribute. I've sort of hit a crossroads. I don't really know how to restrict the movement of my 3d camera.

I tried using a collision box, which used a csg difference to carve out a centre, and then 'attached' a hidden object to the camera and it was supposed to reset the position when it collided. But it hasn't worked so far.

I removed that part of the code because Im assuming the csg difference wouldn't allow for collision or something.

Can anyone help?

Attachments

Login to view attachments
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 4th Sep 2010 19:50
It is hard for me to figure out exactly what you are trying to do here. Anyway, you could create a sphere and hide it and move it to where the camera is located (in your main loop). Then, when the user rolls the mouse wheel, do the following:
1. Move the camera sphere.
2. Check for collision with your camera sphere to any other object
3. if a collision occurs, reset the object's location to your previous camera coordinates
4. If no collision occurs, position the camera where the camera sphere object is.

Hope this helps.

LB

So many games to code.......so little time.
Nights Bane
14
Years of Service
User Offline
Joined: 15th Dec 2009
Location:
Posted: 5th Sep 2010 00:46
I've tried something like this, with a camera sphere that moves with the camera.




I realise maybe I did not make it clear what I was trying to accomplish.

If you download the code you will see that the problem is boundaries, just roll the middle mouse out, and you will see the sky sphere from the outside.
Halp!
Nights Bane
14
Years of Service
User Offline
Joined: 15th Dec 2009
Location:
Posted: 5th Sep 2010 01:04 Edited at: 5th Sep 2010 01:43
Okay, think im getting there... Heres my latest code, gonna try and refine it, but by all means someone give us a hand, tell me where im going wrong/right here...
EDIT: Some erroneous bits in my last code post, here is the latest:
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 5th Sep 2010 01:15
I had this all worked out at home, but won't be there until tomorrow.

What I would do when the mouse wheel is moved, move the object, then check for collision with it. If it collides, reset the object position. If it doesn't collide, move the camera to the object's position.

So many games to code.......so little time.
Nights Bane
14
Years of Service
User Offline
Joined: 15th Dec 2009
Location:
Posted: 5th Sep 2010 01:47
*Bump*
Can anyone else help? just download the program, its quite pretty actually..
Nights Bane
14
Years of Service
User Offline
Joined: 15th Dec 2009
Location:
Posted: 5th Sep 2010 02:53
*Bump*
mikewhl
14
Years of Service
User Offline
Joined: 19th Jul 2010
Location: Columbus,Ohio
Posted: 5th Sep 2010 03:30
Can you just get the distance from the cam to the "objects" then limit that distance with, pick object, pick vector, and pick distance?

Mike

put this in your code snippets, code lang = dbp
Nights Bane
14
Years of Service
User Offline
Joined: 15th Dec 2009
Location:
Posted: 6th Sep 2010 23:13
*Bumpity bump*

I wouldnt now where to begin with that vector business, i just need to know how you make a cube within a cube, whereby the camera can only move within the first cube... I tried using csg difference to custom make the object for collision.

Or- if someone knows a way to restrict movement of the camera within a cube type thing, another way...

Login to post a reply

Server time is: 2024-09-28 22:38:13
Your offset time is: 2024-09-28 22:38:13