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 / Pan Camera Program

Author
Message
Dimension
22
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 3rd Dec 2012 05:26
I am working on a 3D Modeling program and I am making a program that will pan the camera just like in other programs. In other programs such as AutoCAD when panning the camera the mouse stays parallel to the default grid. I have almost made this program work but seems to move the camera to fast. Does anybody know how to make this program work so the mouse stays parralell to the grid when panning the camera.

(Center click and hold to pan)


This program uses the mouse movement and converts the 2D screen coordinates to 3D coordinates uses this information to calculate the camera movement.
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Dec 2012 06:30
Works fine for me, how do you meen it is too fast?

Did you try VSYNC?

Also notice you have some strange "\" in the text lines... I had to remove these to compile, but this works fine for me... oh btw you have SYNC RATE 0... try 60...



Dimension
22
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 3rd Dec 2012 08:54
"\\" is c++ syntax for REM. The newer DarkBASIC profesional editor supports this. The compiler I use works somewhat but the grid doesn't stay parallel to the mouse (if you center click on the grid and move it the position of the point you pick moves around). I don't think that VSYNC is recognized by DarkBASIC profesional and setting the sync to 60 still generates the same problem.
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Dec 2012 09:09
SET DISPLAY MODE XXXX, XXXX, XX, V <-- VSYNC FLAG

You only had a single "\" in that code... Hence my mention...

Have you tried simply applying the mouse pos to the movement of the grid?

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 3rd Dec 2012 10:04 Edited at: 3rd Dec 2012 10:07
\\ is not C++ syntax for REM, this is --> //

In any case, this language is BASIC, and the keyword REM should be used because that's the standard for BASIC.

@ MrValentine

Setting Vsync is not going to solve this problem in any way at all, because mouse input isn't dependent on the screen refresh rate.

@ Dimension

I've simplified your code to use absolute movement rather than relative movement. The theory behind it is to store the current camera and mouse positions as soon as the button is clicked (I used storex# and storez#), and then you subtract the new coordinates from the stored ones. Here's the code:



TheComet

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Dec 2012 10:24
TheComet- I was wondering when you would pop by ^^

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 3rd Dec 2012 11:06 Edited at: 3rd Dec 2012 11:07
Using pick screen wouldn't work accurately due to fov I believe. If I remember correctly you'd need to unproject the viewport by the mouse pos to get the world coords, then a standard drag sum to find the new camera position. Though we don't have viewport.unproject in dbp and I'm not sure on the math behind it. Hmm... I might look into this.

Saying that, you could do some simpler projection math to do this. I will have a play cause I've never done this in 3d before
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Dec 2012 18:13
Not quite sure what the problem is here - but this version works smoothly for me, i.e. the cube doesn't jiggle about. In the original snippet the cube was moved before the camera was moved - it looks better after.

I've also removed the extra slashes in the code that MrValentine was worrying about (why do those appear in some snippets?).

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Dec 2012 18:27
Who said I was worried?

It's not my code... Just pointing out fact...



TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 3rd Dec 2012 18:47
...Was my post really that transparent?

TheComet

Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Dec 2012 21:43
Quote: "why do those appear in some snippets?"

they are used for escaping the quotes. Every time you click post button these get added but sometimes posting doesn't succeed in the first try so those slashes appear in your post

Dimension
22
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 4th Dec 2012 10:18
"Using pick screen wouldn't work accurately due to fov I believe." (by Sasuke)

I thought that was the purpose of pick screen to find the 3D coordinates based on the 2D mouse position.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 4th Dec 2012 13:05
Quote: "I thought that was the purpose of pick screen to find the 3D coordinates based on the 2D mouse position."


The issue is it doesn't work for camera dragging for say an editor. Really you'd want to set up an Orthographic Camera for this. But I'm thinking you could drag accurately with a projective camera. So if I dragged from say a point over an object, the mouse cursor would sit over the object no matter where you dragged the camera in the view point.

Now after alittle playing. I found out how pick screen works (IanM's plugin required):


I wonder if using a ortho matrix instead of a proj matrix could be the fix to keeping things in place at mouse cursor. More playing must be done!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Dec 2012 17:55
Quote: "they are used for escaping the quotes. Every time you click post button these get added but sometimes posting doesn't succeed in the first try so those slashes appear in your post"


Not quite sure what you mean. They are not in my snippet but are in two other snippets in this thread.

I see Dimension still hasn't told us what the problem really is.
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 4th Dec 2012 18:34
Quote: "Not quite sure what you mean. They are not in my snippet but are in two other snippets in this thread."


google what escaping qoutes mean. They are inserted into the post when you submit it but they are not rendered on screen. If the posting doesn't succeed in the first try and you submit again the slashes become part of the post

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 4th Dec 2012 19:21
Does that happen to have anything to do with people writing like this?

I'\\\ve eaten GG'\\\s cookies

TheComet

Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 4th Dec 2012 19:32
Quote: " Does that happen to have anything to do with people writing like this?"

LOL, i don't know

if it was written like this then probably does:
I'\\\"ve eaten GG'\\\"s cookies

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Dec 2012 19:54
I want my cookies back please - with or without google quote thingies.

This thread seems to have panned away from the main point - as far as I can tell anyway.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 4th Dec 2012 23:29 Edited at: 4th Dec 2012 23:30
I just realised that something I said earlier is the answer to this:

Quote: "Really you'd want to set up an Orthographic Camera for this"


That's it.

Annoyingly I can't see of anyway to set the view matrix of a camera since Ian M removed apply view matrix from his plugin. So Cloggy's Dll is the only other way I can think of of making a orthographic camera. I'll be looking into this.

Login to post a reply

Server time is: 2026-07-07 13:15:49
Your offset time is: 2026-07-07 13:15:49