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 / dbPickScreen

Author
Message
Alberto
20
Years of Service
User Offline
Joined: 24th Oct 2003
Location:
Posted: 4th Jun 2005 08:06
Hello

I have problem with this comand :

dbPickScreen ( int iX, int iY, float fDistance )

Suppose the camera is on the y axis for example :
dbPositionCamera ( 1, 0, 100, 0 ) ;
looking at the origin:
dbRotateCamera ( 1, 90, 0, 0 );

Let's consider a point on the xz plane.
I get its screen ccordinates using :
iX = dbMouseX() and iY = dbMouseY()
then fDistance = 100;

I understood that this comand should store in a vector the x,z world coordinates of the point and the y offset from the camera.
Ok, it works.
But if I tilt the camera, mantaining the same position,for example :

dbPositionCamera ( 1, 0, 100, 0 ) ;
dbRotateCamera ( 1, 60, 0, 0 );

It does not work any longer.
I calculate the screen coords of each point on the xz plane as before, and manually its distance from the non parralel screen plane,

What's wrong?

Thanks in advance for your support

Alberto
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 4th Jun 2005 20:42
Alberto
20
Years of Service
User Offline
Joined: 24th Oct 2003
Location:
Posted: 4th Jun 2005 23:42
Here it is

// update camera
// it includes dbRotateCamera and dbPositionCamera comands

camera->update();

float x = dbMouseX();
float y = dbMouseY();
float z = dbMouseZ();

// it gets the distance from the camera to xz plane and the rotation angle around x axis, the camera is in 0,y,0

float dist = camera->getY();
int angle = dbCameraAngleX(1);

// the screen is 1024 x 768

dist = (768-y)*dbTan(angle) + dist/dbCos(angle);

dbPickScreen ( x, y, dist ) ;

// World coordinate x,z , the camera is still in 0,y,0

float x_Pos = dbGetPickVectorX ( ) ;
float z_Pos = dbGetPickVectorZ ( ) ;

Alberto

Login to post a reply

Server time is: 2024-04-19 13:40:02
Your offset time is: 2024-04-19 13:40:02