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 / Detection, not collision

Author
Message
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 7th Feb 2006 18:57
I basically need some code to detect any intersection between two objects, whether they are just simple primitives or complex .X models.
I don't actually want the objects to collide, since this is for my physics functions it would be up to the user to decide what happens with the collision, so I just need the detection. Perhaps to make it faster RiiDii's shrinkwrap code could be user, unfortunatelly I don't know how any of this could be done, so I ask help from you guys

Classic Evil
19
Years of Service
User Offline
Joined: 4th Nov 2005
Location: watching you through your window
Posted: 7th Feb 2006 21:45
Im not sure if this is what you looking for but you could try something like this:

then if the variable of detect=1 then the user could decide what would happen.
e.g. if detect=1 then delete object obj1
if detect=1 then texture object obj1,texturenumber

There are two types of people in this world: people who are extremly cool and are good at everything and people who are me.
Milkman
19
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 7th Feb 2006 21:52
I was actually working on something like this with sparky's for a while, but gave up on it because i found an easier way to do what i wanted. basically i cast a ray between each connecting vertex of the model, and if any ray hit something, the object had collided. fairly accurate and fast. you might want to try something like this.

formerly xMik
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 7th Feb 2006 21:55
That sounds almost possible, though very slow, and would not work with the faces of the objects, but sounds like a good start.. I assume you would use the vertex commands for this yeah?

Cash Curtis II
20
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 7th Feb 2006 23:26 Edited at: 7th Feb 2006 23:27
Right now, I'm using Sparky's DLL to build collision for models. What I do is build collision points around the .x model and use the intersectobject command. I actually have NGC, but this does this same thing and is faster.

The very first thing that you do is establish the current coordinates as the last known good ones.


Then I test for y feet and y head collision.


Then I apply basic physics and place the model.



Then I test for x and z collision.

This handles x y and z collision separately. It then limits movement on the plain of collision, giving sliding collision. It is very fast. There are plenty of great collision routines on these boards, but none of them did quite what I wanted.

The x and z collision should be done at about the knees. Otherwise, your guy will be colliding with the terrain when he walks. This way, he'll automatically climb slopes that aren't too steep, and stairs if the distance between steps isn't too big.

You can build the x and z collision up more, doing the same checks at several y intervals up the height of the model.

The only way to improve it is to rotate the collision points based on the y-angle of the model. I've halfway implemented this, so it needs a bit of work...


The thing with this though is that the output points cannot be the literal points. You have to track the real point locations with an entity system, pass these values to the function, and the points will be rotated correctly. My games are all set up this way, so it's no big deal for me. It might be a headache for you.

Anyway, this was the first collision system I developed, and I'm working on something much much better. Development has been slow lately, but it's coming...

Hope this all help. It was a lot of typing

Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 7th Feb 2006 23:32
That's usually what I do for collision, but I'm affraid this wont work for complex models. Works fine when you just want to roam about with a player all the time, because then you can preset the collision points for the player, but if you simply want to load a car model onto dbpro and want it to crash against a wall then you wont want to have to set all the points, especially when it's functions made for physics.

Cash Curtis II
20
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 8th Feb 2006 00:09
Well, like I said, I'm working on the solution right now. It should be done fairly soon.

Is Newton out of the question for what you're doing? You could create a convex hull that would fit the car perfectly and crash it into anything you like.

Otherwise, I guess you'll have to keep setting the points, unless you want to use NGC. That's just how intersect object works.

Milkman
19
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 8th Feb 2006 02:37 Edited at: 8th Feb 2006 02:46
hey Zoto, heres a little something i cooked up in a few hours
just copy and paste, but it does require sparky's dll. i used a cube for simplicity, but any object can be used to detect collision accurately as long as the faces are not too big (as you said it does not go off of face data, only vertex).
the only thing that i fear may cause it to run slow is the converting from object to memblock every loop other than that, it does it's job. it doesn't run slow at all for me, and i'm running on a pIII
let me know what you think



obviously the key function is the colliding() function. just pass in the collider object and the target (in that order) and it does the rest. if the collider is set up for collision (ie player to player collision) it will automatically ignore its own collision data. also, the function will not return true unless the object being collided with is the target object.

formerly xMik
Milkman
19
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 8th Feb 2006 23:26
I'll just bump this...

formerly xMik
2D Analyst
AGK Developer
21
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 9th Feb 2006 00:36
yeah RAY IS A GREAT IDEA. Does anyoen know if you can cast a ray in 3d canvas. I know it's set up automatically for you, but can you pick where u want the ray to be cast at?

www.creepyfish.com
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 11th Feb 2006 17:55
xMilk, you're a genius

Login to post a reply

Server time is: 2025-06-08 03:46:51
Your offset time is: 2025-06-08 03:46:51