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 Professional Discussion / in absence of dkshop, trying to use sc collisions commands to pick an object limb

Author
Message
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 1st Oct 2011 17:39 Edited at: 2nd Oct 2011 12:16
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):-



Help! Where am I going wrong?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 2nd Oct 2011 11:37
Hi Duffer,that looks just like the limb picking code i gave you a while back,i take it the screen_x and screen_y are the mouse co-ordinates and the 500 and -500 are supposed to be the distance behind and in front of the screen plain.You did remeber that the limb ranges need to be set and an object with no limbs set is actually limb 0.
I still use this function in a lot of my programs and it works just fine,the only things i have to change sometimes are the pick screen distances depending on the size of the objects im using,if its a big terrain or something like that you may need to make the 500`s into something a lot larger depending on the scale of the objects.
Has DKshop not been upgraded to the latest DBPro version yet?
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 2nd Oct 2011 12:23 Edited at: 2nd Oct 2011 12:24
@ paul5147,

Sorry - couldn't trace the original thread but certainly v happy to give you credit for this useful code (see above). (Remembered everything you mentioned.)

I hope you can help.

Using sc collisions, what I ideally want is a standalone (with sc collisions installed, of course) DBPro function - say,

return integer from PICK_LIMB ( ObjId , 2dScreenX , 2dScreenY , startLimb , endLimb )

(I suppose you could also have a parameter for the CameraID - else it would assume the current Camera?)

ie. So your camera would be wherever on the screen, pointing wherever, but, irrespective of where the centre of the screen was (in the 3d sense) and irrespective of the position and direction of the current camera, the function would pick the nearest ObjID limb under the 2d screen_x and screen_y co-ordinates.... (ie. no need for a marker object etc...).

(That would be a straight replacement for at least the DK Pick Limb command - unfortunately DMitryK has'nt come back further (he did email back but that was a long time ago now) re an upgrade of his plugins to make them compatible with U7.7+...)

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 2nd Oct 2011 12:56
Duffer, the code above doesnt use the marker object for anything other than a marker,simply delete any mention to the marker object in the function

and delete the part of your routine were that object is made,you can even delete the global variable "marker".It will still work without it unless you use the position of it for anything else,or you could just hide object marker after its created.
Hope this helps.

Login to post a reply

Server time is: 2026-07-11 14:36:55
Your offset time is: 2026-07-11 14:36:55