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.

Dark GDK / explain dbintersectobject to me

Author
Message
Modis
18
Years of Service
User Offline
Joined: 17th Apr 2006
Location:
Posted: 2nd May 2006 21:24
This call takes a object id as it's first param, is this id of the object your casting the ray from or the object your testing a ray to?

When I use the object id of the player (were the ray starts) the code is very very slow and gives odd results.

When I use the id of the target object it is very fast but seems to always return 0 for distance.

Thanks,
Modis
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 2nd May 2006 22:33
Quote: "This call takes a object id as it's first param, is this id of the object your casting the ray from or the object your testing a ray to?"

I believe its the object that you are casting the ray from.

Intersect Object is very hard to use - unfortunately the docs. on this are very woeful.

I have found that you need to set the starting positions outside the objects size sphere, otherwise it will detect itself...

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 3rd May 2006 04:03
I dont have DGSDK but if the command has the same params as INTERSECT OBJECT from DBP, then;

The first number specified isnt the object the ray is being sent from/to at all, it is instead the object that the ray is checking for intersection with. In other words, this is the object that the system checks to see if any of it's normals or verts pass through the next 6 params.

The next 3 params are the X,Y,Z of the starting point of the ray, and the 3 params after that are the ending points of the ray.

What is returned is the distance, not a true or false value, to the itnersection point from the starting X,Y,Z coords of the ray.

So, if you wanted to check if a sphere object went in between a player and 100 units infront of the player, and the sphere's ID was 7, you'd use these params;

7, PlayerX, PlayerY, PlayerZ, XCheck, YCheck, ZCheck

Where X,Y and Z Check are the positions 100 units infront of the user. This would then return the distance to the closest intersection point, so if the sphere intersected twice, the distance returned would be the distance to the side of the sphere facing the user.

When people use this command for sliding collision/any collision detection purposes, they usually cast the ray from the player's old positions the the player's new positions, checking for either 1 main map object or using a for/next loop to check for an assortment of objects at once. This way, even if the user is going so fast that they would eseentially not run into the wall (since moving an object is really just positioning an object), an intersection will still be picked up. (eg if theres a wall 10 units infront of the user, and the user moves forward 100 units in 1 loop, a distance of 10 will be returned. Using this value, you can move the user backwards by their speed minus the distance, in this case 90 units, positioning them at the point of intersection (though you may also decide to add on half the user's z scale or some other factor like that to the backward movement so as to avoid having half of the object going through the wall).

I can write up some DBP code for you explaining the command more, but Im not sure if you can compile that or not with DGSDK (like I said Ive not used it before but Im assumming you'd have to convert all of the commands to dbCommandName(), and fix the variable definitions to be proper to tandard C++)

Hope its been of some help,
- RUC'

Modis
18
Years of Service
User Offline
Joined: 17th Apr 2006
Location:
Posted: 5th May 2006 22:12
very helpful Ruccus!

I'll adjust my code to what I now understand from your explanation and that of Flappy Frogs to avoid detecting the player in the test and see how that turns out.

I wouldn't mind seeing your dbpro code to compare to, I can translate from db to c++ easy enough.

Thanks for the help,
Modis

Login to post a reply

Server time is: 2024-11-19 06:40:52
Your offset time is: 2024-11-19 06:40:52