Mouse Dragging An Entity

Blitz3D Forums/Blitz3D Programming/Mouse Dragging An Entity

Paulus(Posted 2006) [#1]
Hi

What is the code to select and drag and drop an animated (.b3d) model to a chosen point when it has already been positioned in a Blitz3D scene?

Cheers


stayne(Posted 2006) [#2]
You mean like in those isometric games similar to The Movies?


BlackJumper(Posted 2006) [#3]
You need some mehtod of picking the object, then set a 'flag' to indicate that any input for movement is to apply to only the 'flagged' entity.

I suggest you have a look at the fast picking code by Birdie...

http://www.blitzbasic.com/codearcs/codearcs.php?code=216

and add some code to handle movement on the picked entity.


jhocking(Posted 2006) [#4]
On the one hand, the simplest way to determine where the object should go is to make the ground pickable and use CameraPick.

On the other hand, that method could create issues if you are already doing picks for other stuff, so a while ago (years ago!) I wrote this function based on something from the code archives:

; -----------------------------------------------------------------------------
; Positions an entity in 3D from given 2D coordinates
Function PositionEntityFrom2D(usecam,entity,x2d#,y2d#,height#=0,camZoom#=1)
	gw=GraphicsWidth()
	gh=GraphicsHeight()
	x#=-((gw/2)-x2d)
	y#=(gh/2)-y2d
	parent=GetParent(entity)
	EntityParent entity,usecam
	z#=Abs(EntityZ(entity))
	div#=(gw/(2/camzoom))/z
	x=x/div
	y=y/div
	
;z distance determined by a straight line from camera, through xyz coordinates, to height
	TFormPoint x,y,z,usecam,0
	y3d#=height
	x3d#=TFormedX()
	z3d#=TFormedZ()
	EntityParent entity,parent
	PositionEntity entity,x3d,y3d,z3d
End Function
;-----------------------------------------------------------------------------



Paulus(Posted 2006) [#5]
Thanks guys

Being a relative newbie to Blitz3D I shall go away and have a play.

Anyone else thinks of anything...let me know.

Cheers