Author Topic: raycast_cast_ray_v2 doesn’t work  (Read 6110 times)

0 Members and 1 Guest are viewing this topic.

way2sky

  • Newbie
  • *
  • Posts: 5
raycast_cast_ray_v2 doesn’t work
« 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

CaaG

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 29
Re: raycast_cast_ray_v2 doesn’t work
« Reply #1 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)



way2sky

  • Newbie
  • *
  • Posts: 5
Re: raycast_cast_ray_v2 doesn’t work
« Reply #2 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!
« Last Edit: May 27, 2021, 07:50:20 AM by way2sky »

CaaG

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 29
Re: raycast_cast_ray_v2 doesn’t work
« Reply #3 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!

 

way2sky

  • Newbie
  • *
  • Posts: 5
Re: raycast_cast_ray_v2 doesn’t work
« Reply #4 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!
« Last Edit: May 27, 2021, 03:04:51 PM by way2sky »