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 / Collision Detection: Point within Object

Author
Message
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 19th Jun 2012 00:32 Edited at: 19th Jun 2012 00:33
I have a point x,y,z and I need to test if it is within/in collision with that object and return the collision point.

Is there a collision system that can do this? I am not using objects I am actually using particles. I'm just coming up with a way to integrate a particle system with a collision system.

Any ideas?

Thanks in advanced,

DigitalFury

Get Out Alive (Zombie WIP): My latest zombie game I am working on.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Jun 2012 01:10
Sparky's collision does all sorts of tests, I'm sure that it is able to get a position, and even if it can't you can put a box there.

DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 19th Jun 2012 01:21
@Pincho Paxton - Looked though sparkies collision help file and I couldn't find anything that would work for testing just a point. You have to setup an object to get it to work and I can't use just place holder objects because they need geometry which would take up a bunch of polys for 1000's of particles.

DigitalFury

Get Out Alive (Zombie WIP): My latest zombie game I am working on.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Jun 2012 02:53 Edited at: 19th Jun 2012 03:02
No but you could put the same box in all of the positions using a distance formula to just check the nearest points. So that's just 12 poly's. It's the same as going through an array, but the array is physical.

DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 19th Jun 2012 03:25
@Pincho Paxton - So basically go though each point and compare it to that point x,y,z then find the closest point. What do I do with the closest point then?

DigitalFury

Get Out Alive (Zombie WIP): My latest zombie game I am working on.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Jun 2012 14:24
As the particles are positioned you can either have a grid system that is much like an array. The grid separates the 3D environment into a map. Or you can use a distance formula. When the particles are a certain distance from an object you put a cube at the particle location and test for a collision with the cube. As far as I can tell you would have to do an X/Y/Z test anyway, so the cube just saves you programming this test. I don't know if your X/Y/Z test would be faster than Sparky's cube test.

DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 19th Jun 2012 21:57
@Pincho Paxton - I think I get what you mean. You take a cube and use object hit or object collision commands to test for a collision. The particle size will also be the cube size. You position the cube at every particle position one at a time until a collision registers then you handle the collision.

Thanks,

DigitalFury

Get Out Alive (Zombie WIP): My latest zombie game I am working on.
DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 20th Jun 2012 21:16
@Pincho Paxton - Was I right of how to do the cube test by what I posted above?

Get Out Alive (Zombie WIP): My latest zombie game I am working on.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Jun 2012 21:24 Edited at: 20th Jun 2012 21:26
With a distance routine to result in less tests. There is also a vertex collision in Sparky's that can do a similar thing. I think that the cube test is better. Where a vertex needs to be pointed in the right direction, a cube doesn't.

DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 20th Jun 2012 21:27
@Pincho Paxton - So I should use sparkies collision to do the collision test? Also I don't know what you mean by the cube test as i've never heard of it. Also, how do you mess with the collision routines like with a distance routine if sparkies collision is a close system?

DigitalFury

Get Out Alive (Zombie WIP): My latest zombie game I am working on.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Jun 2012 21:31
Well say you had a face mask, and a welding torch. You don't want to check particles flying away from the mask, so you use a distance routine to cut down on the checks. The face mask has its own X/Y/Z, so you use that to begin with. Then you need more accuracy for the shape of the welding mask, so you switch over to Spark's for accuracy. Distance formulas can be found all over TGC as just standard maths.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 20th Jun 2012 21:34
Is the object a complex object (no symmetrical form)? I'm having trouble visualising your problem.

TheComet

DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 20th Jun 2012 21:53
@Pincho Paxton -

Basically:



Right?

DigitalFury

Get Out Alive (Zombie WIP): My latest zombie game I am working on.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Jun 2012 22:04 Edited at: 20th Jun 2012 22:05
Test particle for collision via sparkies collision...

Position Object Cube,Particle(P).X, Particle(P).Y,Particle(P).Z

And test for collision. If the particles are plains then you can use them, but you will only get flat results.

DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 20th Jun 2012 22:09 Edited at: 20th Jun 2012 22:10
Modified:


Can't I just do this?:


DigitalFury

Get Out Alive (Zombie WIP): My latest zombie game I am working on.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Jun 2012 22:14
That is the in-built collision, and it works, but I believe it is slower than Sparky's.

DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 20th Jun 2012 22:21 Edited at: 20th Jun 2012 22:23
I used sparkies. Will this work? Does this require each object is setup using sparkies collision setup object commands?

Final code:


Thanks,

DigitalFury

Get Out Alive (Zombie WIP): My latest zombie game I am working on.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Jun 2012 22:38
I think you need this at the beginning as well...

SC_SetupComplexObject obj,1,2
SC_UpdateObject obj

DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 20th Jun 2012 22:40
@Pincho Paxton - So i'll have to do that for every object?

DigitalFury

Get Out Alive (Zombie WIP): My latest zombie game I am working on.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Jun 2012 22:44 Edited at: 20th Jun 2012 22:45
Well that's what makes Sparky's fast, because it is pre-built collision. But you only have 1 cube so that is good.

DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 20th Jun 2012 22:48
@Pincho Paxton - Wait u only need to setup the cube because you only have this:



Which I think should be changed to this?


or is that the object that i'm testing?

Isn't setting up every object a lot of data?

Wouldn't dbp's built in command be faster because you don't have to setup every object?

DigitalFury

Get Out Alive (Zombie WIP): My latest zombie game I am working on.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Jun 2012 23:05 Edited at: 20th Jun 2012 23:07
The setup at the beginning of all complex objects is the speed boost that you need for game speed. Try both out, and see which one you prefer. Limbed objects count as one object, so if you want to limb the object together you might prefer that method.

DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 20th Jun 2012 23:10
@Pincho Paxton - ok, thanks. Now I have what I need to work on my blood particle system.

DigitalFury

Get Out Alive (Zombie WIP): My latest zombie game I am working on.
Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 21st Jun 2012 01:43
Try:
DYN OVERLAP CHECK SPHERE positionVec3ID, radius, flag

It returns true if inside an object.

DigitalFury
15
Years of Service
User Offline
Joined: 30th Jul 2010
Location: United States
Posted: 21st Jun 2012 02:07
@Matty H - Thanks, that's an idea that way I can use DYN particles and test for collision.

DigitalFury

Get Out Alive (Zombie WIP): My latest zombie game I am working on.
basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 21st Jun 2012 13:12
you can come round this problem very easy:



Login to post a reply

Server time is: 2026-07-07 19:09:39
Your offset time is: 2026-07-07 19:09:39