Geeks3D Forums

GeeXLab => GeeXLab - english forum => Topic started by: way2sky on May 26, 2021, 09:52:14 AM

Title: raycast_cast_ray_v2 doesn’t work
Post by: way2sky on May 26, 2021, 09:52:14 AM
hello,

i’m trying to cast ray by using raycast_cast_ray_v2() in lua, but it doesn’t return any hit. ray and mesh are correct. geexlab version is 0.38.

does anyone happen to know this? thx
Title: Re: raycast_cast_ray_v2 doesn’t work
Post by: CaaG on May 26, 2021, 07:01:00 PM
Salut!

Frequent use, always works very well (remember: valid face_index >= 0)

Take a look at: https://www.geeks3d.com/geexlab/reference/scripting_utils.php#raycast_cast_ray_v2

(last GeeXLab 0.42.1)


Title: Re: raycast_cast_ray_v2 doesn’t work
Post by: way2sky on May 27, 2021, 07:33:50 AM
thanks for checking, CaaG.

i tried 0.42 but still got same error.  i’m looking the demo in learn pack / 02-intermediate / 02-normal-mapping, and added below code at line 210:

mx, my = gh_input.mouse_getpos()
rox,roy,roz, rdx,rdy,rdz = gh_utils.raycast_get_ray(mx,my,camera)
cx,cy,cz,ct,fi = gh_utils.raycast_cast_ray_v2(dragon, rox,roy,roz,rdx,rdy,rdz,1)

and above execution always return null for face index fi, even though my mouse is on the dragon model in rendering window (which should have found face index of intersection).  this confused me. does anyone could help check if any error in the code? thx so much!
Title: Re: raycast_cast_ray_v2 doesn’t work
Post by: CaaG on May 27, 2021, 12:30:09 PM
Hi,

I'm affraid you do not retrieve the values correctly ; right order is as  follows:

face_index, time, x, y, z =

hopeful suggestion!

 
Title: Re: raycast_cast_ray_v2 doesn’t work
Post by: way2sky on May 27, 2021, 03:02:55 PM
yes you are right, the order is not right.

in addition, i found another reason for it not intersecting anything is, i’m trying to cast ray to a model (parent node of a number of meshes), not a mesh.  so next i’m trying to figure out a way to find mesh id for each child mesh of the parent model. thx so much.



Hi,

I'm affraid you do not retrieve the values correctly ; right order is as  follows:

face_index, time, x, y, z =

hopeful suggestion!