raycast_cast_ray_v2 doesn’t work

Started by way2sky, May 26, 2021, 09:52:14 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

way2sky

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

CaaG

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)



way2sky

#2
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!

CaaG

Hi,

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

face_index, time, x, y, z =

hopeful suggestion!


way2sky

#4
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.



Quote from: 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!