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 / Is there a command for checking camera collision against an object?

Author
Message
Kingius Returns
11
Years of Service
User Offline
Joined: 17th Oct 2013
Location: UK
Posted: 17th Oct 2013 23:42
Is there a command for checking camera collision against an object?

I've been away from Dark Basic for a long time. I can see that I can test one object against another with:



I realise that I can make an object occupy the same space as the camera and test it that way, but I was wondering, is there a better way in DB Pro to do camera collision detection against a specific object? I am thinking of a switch that the player activates by bumping into it.
Sph!nx
16
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 18th Oct 2013 02:30
It's easier to work with positions and dimension and compare those.

Regards Sph!nx
www.mental-image.net
SamKM
15
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 18th Oct 2013 04:39
A simple way to test how far you are from an object could work like this:



Not doing much except adding to what Sph!nx already said, but hope it helps
chafari
Valued Member
19
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Oct 2013 11:51
Hi there

@Kingius Returns
If we just want to check distance to objects ,could be ok a distance formula, but if we want to check camera collision with the poligons of our level, we had better use what you suggest, adding another object in same x,y,z coords. of the camera .

Cheers.

I'm not a grumpy grandpa
Kingius Returns
11
Years of Service
User Offline
Joined: 17th Oct 2013
Location: UK
Posted: 18th Oct 2013 11:57
Thanks guys.

I checked some old code I had lying around for how I used to do this and found a good distance calculator function... dated July 2000! Anyway I dropped this in to the code this morning and got it working. It's actually a better performing solution than moving the object around with the camera.
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 18th Oct 2013 14:24
Like any collision model every object has a collision body and so does the camera, a bounding box or sphere (you'd set to it). Depending on how complex you want it you can do it all with maths, but it'll become very computatious when you have rotating bodies and complex objects. This is why Sparky's Collision was invented. Doing the maths, especially when sphere casting, you'd get no where near the speed as Sparky's.

"Get in the Van!" - Van B
Kingius Returns
11
Years of Service
User Offline
Joined: 17th Oct 2013
Location: UK
Posted: 18th Oct 2013 15:10
Sparky's Collision sounds interesting, what is it?
chafari
Valued Member
19
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Oct 2013 15:14
Quote: "Like any collision model every object has a collision body and so does the camera,"


@Sasuke
At first I thought it was a command of Matrix1utils or Sparky's...that is easy to do with math, and that would be nice there was such command...what did you mean ?

I'm not a grumpy grandpa
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 18th Oct 2013 15:55
Quote: "At first I thought it was a command of Matrix1utils or Sparky's...that is easy to do with math, and that would be nice there was such command"


No I don't know what you mean

I was talking about a system of collision (model) that every collide object has a body you collide with. Sometimes this is polygonal, bounding box/sphere or is custom.

What is it your trying to achieve. Is is just camera collision?

"Get in the Van!" - Van B
chafari
Valued Member
19
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Oct 2013 16:06
Quote: "What is it your trying to achieve. Is is just camera collision?"


Not me...!!! I just was pointing to Kingius Returns that the way to achieve what he need, was just what he suggested...using an object in the same place of the camera...but I had understood that you meant that the camera has collision in your comment... sorry if I misunderstood.

Cheers...

I'm not a grumpy grandpa
Derek Darkly
13
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 18th Oct 2013 19:50 Edited at: 18th Oct 2013 19:52
[SNIP]

D.D.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 18th Oct 2013 23:21
I know the issue has been solved. Just letting you know that you could use an object as the camera container; you can put the camera inside a hidden object.

There is an automatic camera collision command, for the record:

Quote: "AUTOMATIC CAMERA COLLISION
This command will set the specified camera to automatic collision.

Syntax

AUTOMATIC CAMERA COLLISION Camera Number, Radius, Response

AUTOMATIC CAMERA COLLISION Camera Number, Radius, Response, Stand Ground Mode"


Use that if you want a quick solution, otherwise make use of standard object collision commands, Sparkys collision and/or PhysX collision to see if the camera needs to be moved off of obstacles.

Kingius Returns
11
Years of Service
User Offline
Joined: 17th Oct 2013
Location: UK
Posted: 19th Oct 2013 18:21
For the record I am running three forms of collision detection in my rapidly evolving game.

The first is handled by the static volume command, which is checking against the static level created in FPS Creator.

The second is handled by automatic object collision CAMERA_OBJECT,20,0. This checks against my DBPro objects (which can be considered dynamic) such as doors that have collision boxes. Both the first and second collision checks are to simply keep the camera from entering the geometry and essentially constrain the player on the level.

The third is a set of math which runs to check against specific areas of the level that the player can enter or touch against. For example, a switch which can open a door.

Login to post a reply

Server time is: 2025-05-15 20:38:00
Your offset time is: 2025-05-15 20:38:00