Did you see this?
http://www.blitzbasic.com/Community/posts.php?topic=57611
Ross C posted:
Graphics3D 800,600
SetBuffer BackBuffer()
Global camera = CreateCamera()
PositionEntity camera,0,5,-10
RotateEntity camera,45,0,0
Global light = CreateLight()
Global plane = CreatePlane()
PositionEntity plane,0,-0.5,0
EntityColor plane,100,255,100
EntityPickMode plane,2
Global sx = 0
Global sy = 0
Global st_x# = 0
Global st_z# = 0
Global fin_x# = 0
Global fin_z# = 0
Global mouse_down = 0
Type entity
Field mesh
Field selected
End Type
e.entity = New entity
e\mesh = CreateCube()
EntityColor e\mesh,0,100,0
e\selected = 0
PositionEntity e\mesh,3,0,3
e.entity = New entity
e\mesh = CreateCube()
EntityColor e\mesh,0,100,0
e\selected = 0
PositionEntity e\mesh,3,0,-3
While Not KeyHit(1)
If MouseDown(1) Then
If mouse_down = 0 Then
mouse_down = 1
CameraPick(camera,MouseX(),MouseY())
st_x = PickedX()
st_z = PickedZ()
DebugLog("setting - "+st_x+","+st_z)
sx = MouseX()
sy = MouseY()
End If
Else
If mouse_down = 1 Then
CameraPick(camera,MouseX(),MouseY())
fin_x = PickedX()
fin_z = PickedZ()
If fin_x < st_x Then
temp# = st_x
st_x = fin_x
fin_x = temp
End If
If fin_z < st_z Then
temp# = st_z
st_z = fin_z
fin_z = temp
End If
mouse_down = 0
select_entity()
End If
End If
UpdateWorld
RenderWorld
draw_bounding_box()
Rect MouseX(),MouseY(),2,2
Text 0,0,st_x+" , "+st_z
Flip
Wend
End
Function draw_bounding_box()
If mouse_down = 1 Then
temp_sx = sx
temp_sy = sy
temp_fx = MouseX()
temp_fy = MouseY()
If temp_fx < temp_sx Then
temp# = temp_sx
temp_sx = temp_fx
temp_fx = temp
End If
If temp_fy < temp_sy Then
temp# = temp_sy
temp_sy = temp_fy
temp_fy = temp
End If
Rect temp_sx,temp_sy,temp_fx-temp_sx,temp_fy-temp_sy,0
End If
End Function
Function select_entity()
For e.entity = Each entity
If EntityX(e\mesh) > st_x And EntityX(e\mesh) < fin_x Then
If EntityZ(e\mesh) > st_z And EntityZ(e\mesh) < fin_z Then
e\selected = 1
EntityColor e\mesh,0,255,0
DebugLog("selected!")
Else
e\selected = 0
EntityColor e\mesh,0,100,0
End If
Else
e\selected = 0
EntityColor e\mesh,0,100,0
End If
Next
End Function
|