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.

Dark GDK / dbPickObject() bugged?

Author
Message
billy the kid
14
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 5th Feb 2005 01:35 Edited at: 5th Feb 2005 01:37
Im using dbPickObject() to pick an object on the screen and then you can move or rotate the object using the mouse. Right now I am just using the generic shapes like cube, sphere, etc. The code is a little ugly but commented. Anyway the object seems to jump whenever I am trying to position it. What you will see is that the object will jump around when you left click on it. And if you right click, it will jump in rotation. So not sure if this actually my fault or a bug in the SDK. Only thing I can think of if its my fault is timing. But putting dbWait() doesnt seem to help much unless I put a large value, and that decreases FPS a lot. The controls are:

POSITIONING
- click object and hold left mouse button and move mouse, selects object and moves object along x and z axis.
- click object and hold left mouse button and move scroll button, selects object and moves object along y axis.

ROTATING
- click object and hold right mouse button and move mouse, selects object and rotates object.
- click object and hold right mouse button and move scroll button, selects object and rotates object differently.

MOVING CAMERA
- click up arrow to move forward and click down arrow to move backward.
- hold CTRL and move the mouse, move the camera like in a FPS.

Also this code is for a console win32 program, delete main() if you want to use a regular win32 program.

editor.cpp


editor.h
Paranoid Android
14
Years of Service
User Offline
Joined: 5th Feb 2005
Location:
Posted: 5th Feb 2005 08:04
I don't have the time to run your code, but I'll guess the cause for your problem.

dbMouseMoveX() (and the same for MoveY...) returns the following value: The number of pixels you moved your mouse since the last call of dbMouseMoveX().

Because you are not calling dbMouseMoveX() in every itteration of your code, and calling it only when you are clicking your mouse on some object, in the first itteration after the click, dbMouseMoveX() will return a large value (and the object will rotate more than you wanted to).

What you can do, is call dbMouseMoveX() once at the beginning of every itteration and store that value in some global integer, so you always know how many pixels the mouse moved since your previous itteration (and not since the last time you released a picked object or other specific event). After you stored the value, you can use it in your code instead of calling dbMouseMoveX() again and again in the same itteration.

Cheers,
Paranoid Android.
billy the kid
14
Years of Service
User Offline
Joined: 7th Dec 2004
Location:
Posted: 5th Feb 2005 18:41
Yep that was problem. I figured it was some sort of problem like that, but it never occured to me that dbMouseMoveX() returns the number of pixels since the last call. So basically I just needed to call dbMouseMoveX() before I called dbPickObject(). Thanks.
Paranoid Android
14
Years of Service
User Offline
Joined: 5th Feb 2005
Location:
Posted: 17th Feb 2005 00:16
Welcome

Cheers,
Paranoid Android.

Login to post a reply

Server time is: 2019-08-18 23:19:32
Your offset time is: 2019-08-18 23:19:32