Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / click and drag terrain with mouse regardless of camera viewing angle....?

Author
Message
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 9th Nov 2012 13:36


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...
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 9th Nov 2012 13:37
here's the terrain color map image for the program-

Home is where my souped-up computer is...
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 11th Nov 2012 00:13 Edited at: 11th Nov 2012 00:14
How would this "click and drag" feature work?
Is it to shift the camera horizontally / vertically or to zoom in and out? Or something else completely?

Basically you would check if the desired mouse button is down (mouseclick()), then you can use the mouseMoveX / mouseMoveY functions to get how many pixels along the respective axis the mouse was dragged. Thereafter it's a simple case of multiplying that value with some suitable factor and then either move the camera forward / backward by the resulting distance or move it sideways (look into the newXValue etc. functions for this. You would use your current (forward) camera angle + 90 degrees to move to the right and -90 degrees to move to the left.


"Why do programmers get Halloween and Christmas mixed up?"
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 11th Nov 2012 04:31
Rudolpho, here's that latest code from what I have so far, it's working the best, but it "flickers" the terrain, so I have to come up with some sort of buffer involving a float variable.



This code almost does what I want, but when you click the mouse button over the terrain and drag the cursor over the screen, the terrain seems to follow the mouse as intended, BUT the terrain jumps around in a strangely predictable way.

Almost there...

Home is where my souped-up computer is...

Login to post a reply

Server time is: 2026-07-11 11:39:36
Your offset time is: 2026-07-11 11:39:36