Understanding ColDet - Mesh Collision

Blitz3D Forums/Blitz3D Beginners Area/Understanding ColDet - Mesh Collision

Imperium(Posted 2013) [#1]
Understanding ColDet - Collision Detection.
http://telias.free.fr/3d_blitz3d.html

The following code below reads easily enough but how exactly do you make the two meshes act solid? In the example below the objects collide and report the collision but pass through one another. I'm interested in using ColDet to replace Blitz3d built in collision detection. My level maps use about 30 polygons for collision with the player object while the level mesh itself contains over 63534 vertices.




RemiD(Posted 2013) [#2]

In the example below the objects collide and report the collision but pass through one another.


Maybe use vectors to move each entity and if a collision is detected, position the entity back to its previous position ? or move the entity back until it does not collide anymore ?


Imperium(Posted 2013) [#3]
Not sure how that would affect gravity. Right now I just have a very simple routine pushing the player downward. If the player collides with the collision mesh then gravity would = 0. I suppose I first need to code a proper crouch and jump.


RemiD(Posted 2013) [#4]

Not sure how that would affect gravity. Right now I just have a very simple routine pushing the player downward. If the player collides with the collision mesh then gravity would = 0.


I don't think this will be a problem.
First you retrieve the coordinates of the character before moving him. (pointA)
Then you move the character with his movement speed.
Then you move the character with his gravity speed.
Then you retrieve the coordinates of the character. (pointB)
With these 2 points you can calculate a vector.
Then you calculate if a collision has happened between his collider and the ground collider.
If there is a collision, you move the character up by steps until he is not collided (for example if his gravity speed is 0.1, you can move him up up to 10 times at 0.01 until he is not collided.)
Then you calculate if a collision has happened between his collider and a wall collider, an obstacle collider, another character collider.
If there is a collision, you move the character at the opposite direction of his movement by steps until he is not collided (for example if his movement speed is 0.1, you can move him in the opposite direction up to 10 times at 0.01 until he is not collided.)

That's the idea.

However i suggest to use linepick to determine where a character is related to the ground, and a collider to determine where a character is related to the walls, the obstacles, the others characters.

Also why complicate things using Coldet ? I think that Blitz3d collision system is good enough for your game.


Imperium(Posted 2013) [#5]
Thank you for that explanation. I'm interested in Coldet not only for player collisions with my maps but also for calculating weapon ballistics. I'm experimenting with a few different ideas for other projects separate from my Aliens FPS project. One is seriously starting to push the graphics envelop and would benefit from optimizing blitz3d collisions.

I have amassed quite a collection of Blitz related libraries and other addons so I'm going through everything that has peaked my interest.


Imperium(Posted 2013) [#6]
It might be worthwhile to tie this post with this one:
http://www.blitzbasic.com/Community/posts.php?topic=100759