3d Mouse Control

Blitz3D Forums/Blitz3D Beginners Area/3d Mouse Control

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I don't know about a "super maplet" but I have bin thinking of making a Maplet clone for a few months now. I need to study up on how to make custom meshes. I have figured out how to directly move an object on a 3d grid. Next step I think is to make a square surface by storing the marker position when the mouse is hit and scale the surface to where the mouse is released. Anyone want to help? This could be a cool comunity project and we might end up with a great tool, like Maplet but improved texture, movement and more when we get that much done.

; ModifyTerrain Example
; ---------------------

Graphics3D 800,600,16,3
MoveMouse 400,300
;HidePointer()
SetBuffer BackBuffer()
terra_size=128 ; initial size of terrain, and no. of grids segments, along each  side
x_scale=10 ; x scale of terrain
y_scale=10 ; y scale of terrain
z_scale=10 ; z scale of terrain
marker_x=terra_size/2 ; initial x position of marker
marker_z=terra_size/2 ; initial z position of marker
marker_y=0


camera=CreateCamera()
PositionEntity camera,(terra_size*x_scale)/2,50,0 ; position wherever; just  try and get good view of terrain!
RotateEntity camera,30,0,0 ; again, try and get good view of terrain
CameraClsColor camera, 70,70,250
light=CreateLight()
RotateEntity light,90,0,0

; Create terrain
terra=CreateTerrain(terra_size)
ScaleEntity terra,x_scale,y_scale,z_scale
EntityPickMode terra,2,True
EntityFX terra,4
EntityAlpha terra,.5

; Texture terrain
;grid_tex=LoadTexture("Maper_grid.bmp",4)
;EntityTexture terra,grid_tex
;EntityFX terra,1
;EntityAlpha terra,.5

;SetBuffer TextureBuffer()
grid_tex=CreateTexture( 32,32,4+8 )
ScaleTexture grid_tex,1,1
SetBuffer TextureBuffer( grid_tex )
Color 0,0,255:Rect 0,0,32,32
Color 0,0,0:Rect 0,0,32,32,False

SetBuffer BackBuffer()

EntityTexture terra,grid_tex


; Create marker
marker=CreateSphere()
ScaleEntity marker,1,1,1
EntityColor marker,255,0,0

While Not KeyDown(1)
;left\right
If KeyDown( 205 )=True Then TurnEntity camera,0,-1,0
If KeyDown( 203 )=True Then TurnEntity camera,0,1,0
;up\down
If KeyDown( 208 )=True Then TurnEntity camera,-1,0,0
If KeyDown( 200 )=True Then TurnEntity camera,1,0,0

If KeyDown( 30 )=True Then MoveEntity camera,0,0,1
If KeyDown( 44 )=True Then MoveEntity camera,0,0,-1

If MouseHit(3) Then
	PositionEntity camera,marker_x,marker_y+40,marker_z
	
EndIf
 




marker_x=Int(PickedX#())/x_scale*x_scale
marker_y=Int(PickedY#())/y_scale*y_scale
marker_z=Int(PickedZ#())/z_scale*z_scale


CameraPick(camera,MouseX(),MouseY())
 

PositionEntity marker,marker_x,marker_y,marker_z

UpdateWorld 
RenderWorld

Color 250,210,150
Text 0,40,"PickedX: "+PickedX#()
Text 0,60,"PickedY: "+PickedY#()
Text 0,80,"PickedZ: "+PickedZ#()
Text 180,40,"marker_X: "+marker_X
Text 180,60,"marker_Y: "+marker_y
Text 180,80,"marker_Y: "+marker_z

Flip

Wend

End