set display mode desktop width(), desktop height(), 32
set window off
autocam off
backdrop on
color backdrop rgb(90,90,255)
set ambient light 5
set camera range .1, 5000
load image "terrain_c_map.bmp", 1
Dim TransitConnector(25000) as TransitConnector
type TransitConnector
XPos as integer
YPos as integer
ZPos as integer
ConnectorID as integer
ConnectorType as integer
ConnectorExist as integer
AttachPoint1 as integer
AttachPoint2 as integer
AttachPoint3 as integer
AttachPoint4 as integer
endtype
Dim TransitLink(25000) as TransitLink
type TransitLink
LinkID as integer
ConnectorAttachA as integer
ConnectorAttachB as integer
LinkTransitType as integer
LinkExist as integer
AXPos as integer
AYPos as integer
AZPos as integer
BXPos as integer
BYPos as integer
BZPos as integer
endtype
global XAng as float
global LowestTerrainSpot as integer
global TerrainHeightAverage as float
global YAng as float
global CameraDist as float
global mx as float
global my as float
global xpos as float
global ypos as float
global zpos as float
global mmx as float
global mmy as float
global mmz as float
global mmzr as float
mmzr = .025
global smmx as float
global smmy as float
global rmmx as float
global rmmy as float
global dXAng as float
global dYAng as float
global CullState = 1
global num_objects = 20
global lmb
global CameraTickRate = 0
global tag_state = 0
global tempmousex as float
global tempmousey as float
global tempmousez as float
global xposdiff as float
global yposdiff as float
global zposdiff as float
global OriginalZPos
global tmx
global tmy
global num_objects=50
dXAng = 0
TransitConnector(1).ConnectorID = 5
make object terrain 1
set terrain heightmap 1, "terrain_h_map.bmp"
` split value by 16 * 16
`set terrain split 1, 4
` detail map tiling
set terrain tiling 1, 2
` light - xdir, ydir, zdir, red, green, blue, intensity
set terrain light 1, 1, -0.25, 0, 1, 1, 0.78, 0.5
set terrain scale 1, 1, .5, 1
` base and detail texture
set terrain texture 1, 1, 3
` finally build the terrain
build terrain 1
position object 1, 0, 0, 0
make object sphere 2, 1, 8, 16
position object 2, 0, 0, 0
YAng = 90
CameraDist=-450
Rotate Camera 0, 0, XAng, 0.0
point camera 0, 0, -1, 0
Move Camera 0, CameraDist
ControlCamera()
`----------------------------------------Begin Main Loop--------------------------------
while escapekey()=0
ControlCamera()
text 0, 0, str$(xpos)
text 0, 10, str$(ypos)
text 0, 20, str$(zpos)
text 0, 30, str$(mousex())
text 0, 40, str$(mousey())
text 0, 50, str$(tempmousex)
text 0, 60, str$(tempmousey)
text 0, 70, str$(screen fps())
endwhile
`----------------------------------------End Main Loop----------------------------------
function ControlCamera()
mx=mousex()
my=mousey()
mmx = MouseMoveX()
mmy = MouseMoveY()
mmz = MouseMoveZ() * (mmzr-(CameraDist*.0001))
if MouseClick() = 1 and tag_state=0
`Take a snapshot of initial mouse cursor click location on the planet
if pick object(mx, my,1,1) =1
xpos = (get pick vector x() + camera position x())
ypos = (get pick vector y() + camera position y())
zpos = (get pick vector z() + camera position z())
tempmousex = xpos
tempmousey = ypos
tempmousez = zpos
tag_state=1
endif
endif
if MouseClick()=4 and shiftkey()=0
XAng = XAng + ((mmx)*.15)
YAng = YAng + ((mmy)*.15)
endif
if MouseClick()=4 and shiftkey()=1
XAng = XAng + ((mmx)*.0075)
YAng = YAng + ((mmy)*.0075)
endif
If MouseClick() = 1 and tag_state=1
if pick object(mx,my,1,1) = 1
xpos = (tempmousex - (xpos))
zpos = (tempmousez - (zpos))
endif
endif
if YAng>90 then YAng=90
if YAng<0 then YAng=0
CameraDist = CameraDist + mmz
if CameraDist>-.25 then CameraDist = -.25
Position object 2, xpos, ypos, zpos
Position Camera 0, xpos, ypos+.125, zpos
Rotate Camera 0, YAng, XAng, 0.0
Move Camera 0, CameraDist
mmx=0
mmy=0
mmz=0
if MouseCLick() = 0
tag_state = 0
endif
`point object 3, camera position x(0), camera position y(0), camera position z(0)
endfunction
Here's the code I have so far. Right now I can use the middle mouse button to change the viewing angle of the camera with no problem.
I would however like to add a "click and drag" feature by using the left mouse button but so far have failed to come up with a working system.
The terrain itself doesn't move, just the camera. And the camera commands are setup in order to allow the kind of viewing angle of the camera to work smoothly.
I know there must be a way to get this to work...but I been trying for the past several days on this and now I am here asking for some help.
If there is already an existing thread on this point me in the direction if you could. Thanks again-
Home is where my souped-up computer is...
