3d coordinates

Started by
6 comments, last by Supernat02 19 years, 6 months ago
I want to point the mouse at certain position on the screen and fed back with its x,y,z, positions of the scene, just like 3dsmax In the VB, where 2D is the case, I can create 2 textboxes and code them like this sub mouse_click (X as long, Y as long...) text1.text = Str(X) text2.text = Str(Y) end sub How to do it? but in C++ Thanks Jack
Advertisement
The DirectX SDK has a picking example. You can also search the forums or google for picking examples.

Chris
Chris ByersMicrosoft DirectX MVP - 2005
Hi Chris,
The picking example from DX9 only works on triangles of a mesh.
I want to 'pick' the world coordinate positions... Thanks
Just like when I rollover some point in the world space, I can get the x,y,z positions of where my mouse pointing at immediately.
Jack
I have used this function to place a mesh where the mouse is in a perspective viewport.

D3DXVec3Unproject( _
VOut As D3DVECTOR, _
V As D3DVECTOR, _
Viewport As D3DVIEWPORT8, _
Projection As D3DMATRIX, _
View As D3DMATRIX, _
World As D3DMATRIX)

Projects a vector from screen space into object space. Search this function in the DirectX SDK.
______________________________Perry Butler aka iosysiosys Website | iosys Music | iosys Engine
I'm a little confused. You can't get a z value unless you have something that the mouse pointer is intersecting. Are you just interested in the x and y values? Or are you assuming an invisible plane at Z=0 and this is what you want to get the z value from? If that is the case, you can use a pick example and just use a quad lying in the z=0 plane for the test (instead of a mesh). You could then optimize from there.

Chris
Chris ByersMicrosoft DirectX MVP - 2005
Actually, I am wanting to pick two vectors and record them and let the object moves along by interpolation....
Am I on the right track? or anyone suggests a better solution?
Thanks
Jack
I remember the game "Age of Empire", of that when you click in orth. view, the characters could still move to the correct positions although it is in 3d space. Am I correct?
Thanks
Jack
If the object will be moving in the same z plane, then you can achieve this by making that invisible z=0 plane into a z=Some Value plane, where some value is the center z value of the object you want to slide around.

Chris
Chris ByersMicrosoft DirectX MVP - 2005

This topic is closed to new replies.

Advertisement