OK,
So let's assume I've set up polygon collision on the main object I want to interrogate - object 1 and I've also set up a small sphere (marker) object to pop in to place where the 2d mouse cursor coincides with a collision with the main object. We're looking at the 2d scene through camera 1.
What I want to do is create a function that, noting the current camera, and allowing for polygon collision set up on the relevant object, allows you to id the limb number of the limb under the 2d mouse cursor - not the through the direction the camera is pointing - just the closest limb number under the 2d mouse coordinates, if there is one, otherwise returning a -1
Anyway, here's the code so far - and I give total credit to paul5147 for the code (which I have no doubt ruined now):-
function PickLimb(screen_x,screen_y,object_num,start_limb,end_limb)
l=0
done=-1
pick screen screen_x,screen_y,500
ex=get pick vector x()+camera position x(2)
ey=get pick vector y()+camera position y(2)
ez=get pick vector z()+camera position z(2)
pick screen screen_x,screen_y,-500
sx=get pick vector x()+camera position x(1)
sy=get pick vector y()+camera position y(1)
sz=get pick vector z()+camera position z(1)
hit=sc_raycast(1,sx,sy,sz,ex,ey,ez,0)
If hit = 1
color object marker,rgb(0,255,0)
else
COLOR OBJECT marker,rgb(255,0,0)
ENDIF
if hit=object_num
position object marker,sc_getstaticcollisionx(),sc_getstaticcollisiony(),sc_getstaticcollisionz()
face_hit=sc_getfacehit()+1
while done=-1
old_l=l
lock vertexdata for limb sc_getobjecthit(),l
i_num=get vertexdata index count()/3
v_num=get vertexdata vertex count()/3
`used for index objects
if i_num>0
if face_hit>i_num
inc l
face_hit=face_hit-i_num
endif
endif
`used for triangle list objects
if i_num=0
if face_hit>v_num
inc l
face_hit=face_hit-v_num
endif
endif
if l=old_l
done=l
endif
unlock vertexdata
endwhile
endif
`check if in limb range
if done<start_limb or done>end_limb
done=-1
endif
endfunction done
Help! Where am I going wrong?
a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...