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.

AppGameKit Classic Chat / 3D collision - current best practice?

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 27th Apr 2017 20:50 Edited at: 27th Apr 2017 20:51
I thought I'd start a thread where we can define and discuss any current best practice or methods.

I've knocked up a few testing scenarios and there's a lot of ways to approach this.

Some collision methods work best for bullets, lasers and the like where as others are needed when working with environments or many-to-many checks.

For instance, right now my current game needs a selection of 3D collision techniques and I have a number of options about how to implement them.

1. Basic environment / proximity checks - Stage 1: the "initial check filter"
So, I'll be using a checkerboard approach here, to filter out most of my detail checks. I only need to operate this on the X and Z axis.
There are other options, like basic distance checks, but I am currently using a model where I keep track of everything in the arena at grid positions of tile size (x,z) and some items can occupy the same square without invoking 2nd stage collision checks.

2. Object->object collision - Stage 2: the "3D equivalent of 2D pixel perfect collision"
We could use ray casting, but it does seem quite slow to me if you aren't careful (e.g. only look ahead 1 or n frames to cast your ray) - and it doesn't cater well for complex object->complex object*. This can and will be fine for me with bullets/lasers and reasonably fast moving, simple geometry objects.
For characters and complex shapes, we could use the Bullet engine by setting up some zero mass objects (both as bounding boxes and the actual collision object shape). This is what I'm about to set up my next test bed for.

3. Of course we don't need to check everything, every frame. However, I'm finding it difficult to know if my collision shapes are correct. It would be really useful to have some visualization of collision shapes in 3D. When (if at all) will this be in?

So, to my main question; I need to use shapes then, because of complex object->complex object so is setting up all complex collision objects (for the precision, final check) can only be done currently as a physics object?
It seems a bit odd, but I'll go along with it then, if I need to physics enable an object, just to get access to better collision detection.

* I originally thought that sphere-casting was a spherical distance check (or a raycast in all directions), but my current understanding now tells me that the "sphere" part is that it's just a single ray which is made into a bigger cylinder, not that the entire sphere is checked? Clarification of this would be most beneficial. If it is a cylinder, what parts of the cylinder are checked?

[edit] Sorry - can a mod change the title and take out "physics" as I meant general 3D collision
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 29th Apr 2017 21:01
Well, seems I am unable to use the physics collision shapes for regular object collision
I thought it might have been possible to hijack those checks and use the convex hull shape checks, but no? I get some very weird results and have spent several hours today trying to get it to work.

Anyone else managed this?
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 30th Apr 2017 19:59
Quote: "Well, seems I am unable to use the physics collision shapes for regular object collision "


Please explain, show a code example. Maybe you are doing something wrong.
The coffee is lovely dark and deep,and I have code to write before I sleep.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 30th Apr 2017 20:22
I can't really at the moment - it's a bit of a mess. I'd have to rig up a test bed outside of my main code.

It does work (per se) but I've run into problems with collisions on child objects generated with LoadObjectWithChildren() which is where I expect the actual problem lies.

The collision is showing true for unusual or impossible intersections on the child objects.

I'll put together an example.
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 30th Apr 2017 21:10
This will apply to the 3D physics commands.
Ok, I think I understand what you are doing. LoadObjectWithChildren() loads an object with all its child meshes.
When you create a rigid body for this object it includes all the meshes when it creates the collision shape.
You can not get a separate collision body for each child mesh, so you will not get a collision hit on child meshes.
The coffee is lovely dark and deep,and I have code to write before I sleep.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 1st May 2017 21:48
I guessed as much. well, saves me the need to make a demo of it.

Login to post a reply

Server time is: 2024-11-24 17:01:57
Your offset time is: 2024-11-24 17:01:57