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 / Just a question on how to get my mouse to work properly in 3D space

Author
Message
DLS
22
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 1st May 2011 21:59
Hi guys.

it's been a long time since i've frequented these forums. years to be truthful.

i decided the other day to dig out DBP and give it another bash. so far so good considering the the length of time away. working menu , 3D playing field(matrix) and a mouse that kinda works in 3D space, and thats the question at hand.

as i've said i've got a semi working mouse that does almost what i need it to do, but the Z axis is reversed.(code below)



I've tried doing 'pick screen mousex(),10, - mousey()' but that puts it behind my camera.

i spent the day looking for tips and solution via a forum search to this problem and couldn't find much to help me even though there's shed loads of different ideas.

any ideas to help put this to bed? i'm guessing i have to subtract/add the mouse pos from the current one is some way

oh and on a side note, you'll probably see a commented out IF statement. Thats a failed attempt at making my camera movable via the mouse and not the keyboard. Sort of works if ya want to make yourself dizzy.

how can i solve that issue as well as having a zoom function working? i understand what i need to do, its just getting it down so the program understands.

sorry for asking a lot but i wanna get this sorted so i can move on to selecting and moving things about the place.

PC spec: AMD Phemon II X4 940@ 3Ghz, 8Gb DDR2 Ram, 1x 60Gb SSD and 2x 500 gb HDD, GForce STX260 876Mb, Windows 7 64bit
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 1st May 2011 22:24
Double check the help for PICK SCREEN, the parameters are,

Screen X, Screen Y, Distance

DLS
22
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 2nd May 2011 01:02 Edited at: 2nd May 2011 02:18
i know that... but it doesn't move along the z axis like i want it to with it like that with the code i originally had before my alterations

this is one of the reasons why i'm asking for some guidance on the matter.

anyway... problem sorted. i remembered a video i saw on youtube about a dark ai tutorial and it had a mouse code in it. thought i'd give it a whirl and what do you know. it works perfectly.



and it doesn't matter where you point the camera either which is a bonus.

now to try and fix the camera issue. How can i get my camera to point where i want it when i hold down the right mouse button.

this is the code i've got atm but
1)its erratic when you move the mouse quite a way and press the mouse button; and

2) i know its not quite right



i'll do some hunting for a solution presuming there is one out there for this. if i can get this nailed with your help i'll gladly put the full code up for you to use.

also i'll need a way of zooming in.

[Edit]
ok i had a look around the search and found mouse looks for FPS and 3rd person but nothing for a free mouse look.

i've used the following codes and they work, but not in the way i would like them to.



and i gave this a try



turns out they are both the same in the way they perform. adding a /5 in the second one does help make things a little less twitchy, but if i move my mouse substantially to the left or right it flicks to that point. thats the bit i can't figure out how to stop from happening.

PC spec: AMD Phemon II X4 940@ 3Ghz, 8Gb DDR2 Ram, 1x 60Gb SSD and 2x 500 gb HDD, GForce STX260 876Mb, Windows 7 64bit
DLS
22
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Wet And Windy Britain
Posted: 2nd May 2011 17:14
I'm still struggling with the free look camera routine. I may have to function it i'm guessing.

since i'm more awake than i was when i posted above i can explain it better.

What i need to know is; how do i keep the previous angle of the camera , so that when the right mouse button is pressed after the cursor has been moved, the camera doesn't suddenly jump like 270 degrees round?

This is what i came up with. Its FAR FAR FAR from adequate, but its stopping the camera going nuts on me at least.



while i've been typing this i did think of an idea.

would it work if i was to set the vars that store the mousemovey() and mousemovex() back to 0 when i press the right mouse button and then add the new mouse move amount to the camera angle that governs the corresponding horizontal and vertical mouse movements?

i'm not gonna try it just yet as my head hurts from thinking too much. need a coffee and a break lol

PC spec: AMD Phemon II X4 940@ 3Ghz, 8Gb DDR2 Ram, 1x 60Gb SSD and 2x 500 gb HDD, GForce STX260 876Mb, Windows 7 64bit

Login to post a reply

Server time is: 2026-07-11 13:58:29
Your offset time is: 2026-07-11 13:58:29