Linepick and positioning an object, but exact

Blitz3D Forums/Blitz3D Programming/Linepick and positioning an object, but exact

Jeroen(Posted 2004) [#1]
currentSelection = CameraPick(camera,MouseX(),MouseY())
PositionEntity currentSelection , PickedX#() , PickedY#(), PickedZ#()


With the code above, I can position an object in 3D space, using the mosue coordinates. No big deal.

But here is the problem. (I hope I can explain it right, it's hard)

When I click on the edges of the object, I do not want the object to move so that my mouse is in the middle point of the object. I want my camerapick position to be the basepoint of my selected object.

Imagine a mesh of a big truck. If I click on a wheel, the truck will be moved down, and my mesh will be centered on the camerapick x,y,z coordinates. I don't want this, I want the truck wheel to be the basepoint of moving.

Can someone shine a light on this?

Thanks


jhocking(Posted 2004) [#2]
Find out the exact 3D coordinates of the pick, place a pivot there, parent the truck to the pivot, and now move the pivot with the mouse. When the mouse is released unparent the truck from the pivot and freeentity the pivot.


Jeroen(Posted 2004) [#3]
hmmmm good idea!
I'll try!


jhocking(Posted 2004) [#4]
I hope that works. I haven't actually tested it or anything, that was just the first idea which came to me.


_PJ_(Posted 2004) [#5]
[quote]
Find out the exact 3D coordinates of the pick, place a pivot there, parent the truck to the pivot, and now move the pivot with the mouse. When the mouse is released unparent the truck from the pivot and freeentity the pivot.
[.quote]

That was also what I thought, only I wonder about problems with numerous 'pickable' objects, or when a 'blank' area is clicked...


jhocking(Posted 2004) [#6]
I'm not sure what problems you are referring to with numerous objects. As for clicking a blank area, before placing a pivot check if an object was picked:

If PickedEntity<>0

pivot=CreatePivot()
PositionEntity pivot,PickedX(),PickedY(),PickedZ()
etc.

EndIf