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 Discussion / Ray casting has a limit??

Author
Message
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd May 2009 20:09 Edited at: 24th May 2009 16:16
Hello!

So whenever I move a waypoint and drop it with the mouse, the program casts a ray starting at the waypoints position x,y+50000,z and ending at the waypoints position x,y-50000,z to find the ground.

But no matter where you drop it, it wont find the ground. There is no collision at all, even if it is over the level. Is there a reason why the ray is not colliding with the level?

TheComet

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 24th May 2009 06:35
Why a 100000 unit range ? but that's beside the point... Why not just reduce that range to see if it is the cause?

Also what is the ground? What I mean is, what type of collision are you using on the ground? And what function(s) are you using to return the collision values?

Enjoy your day.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 24th May 2009 11:28 Edited at: 24th May 2009 11:45
It works when reduced to 1000.

I use spakry's, so to set up the object, I use SetupComplexObjectDBC(100,1,2) (so polygon collision), then I cast the ray with if IntersectObjectDBC(100,0,wx,50000,wz,wx,-50000,wz,1) then blabla, but that doesn't collide.

If I do the same and use if IntersectObjectDBC(100,0,wx,500,wz,wx,-500,wz,1) then blalbla it works.

I am using a 100000 unit range because I am not expecting a level to be higher than that for my editor.

TheComet

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 24th May 2009 19:21
Are you returning the height of the land? And if so, what functions are you using for that, specifically?

You should be using
getStaticCollisionX()
getStaticCollisionY()
getStaticCollisionZ()

In this line:

if IntersectObjectDBC(100,0,wx,50000,wz,wx,-50000,wz,1)
the 1 at the end is an exclusion of object 1, it's not being tested. What happens if you change this value to 0?

Also make sure you are using float values for xyz .

Make sure your landscape has it's normals pointing outwards, towards the ray. The ray will not return collision detection if it is hitting the back of a face. That means if you are inside a box and casting the ray from inside the box, it will not detect collision with the walls unless the box is inside out. Likewise, is you are under the terrain and cast a ray up, it will not detect collision unless your terrain has normals on both sides.

And it doesn't seem to be the range, this bit of code returns true on collision:



Make sure you are using updateObjectDBC(<objNum>

Enjoy your day.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th May 2009 14:26 Edited at: 25th May 2009 14:28
All of your requirements are fulfilled, I just can't figure it...

EDIT:

Found the problem! Here is the code:



The problem was, that it should be sy#+50000.0 and not sy#+50000

Thanks Latch!

TheComet


Make the path of your enemies easier with Waypoint Pro!
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th May 2009 20:39
Sorry for double posting, but another problem has come about.

Please download the attachment, The short program loads in the object displayed below, and casts a ray from x#,y#+50000.0,z#,x#,y#-50000.0,z#, where the coordinates x#,y#,z# are the objects positions, and positions a red cube at the collision point.

The X object is one sided. Why is it that the collision is on the middle plain?



TheComet


Make the path of your enemies easier with Waypoint Pro!

Attachments

Login to view attachments
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 28th May 2009 12:27
Anyone?


Make the path of your enemies easier with Waypoint Pro!
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th May 2009 13:20
Only thing that comes to mind is the normals for your object may be a little off and the greater the distance of the ray cast, the greater the margin of error. It seems to work at 32767 (I was checking 15 bit numbers just in case that was a limit for speed's sake) and my test of the cube works at 50000.

Enjoy your day.

Login to post a reply

Server time is: 2025-05-16 20:19:08
Your offset time is: 2025-05-16 20:19:08