has anyone created any code that can return the nearest x y z coordinate of a 2d x y viewport coordinate?
reverse camera project
Blitz3D Forums/Blitz3D Programming/reverse camera project Correct me if I'm wrong, but I believe what you're looking for is the CameraPick function which you can find out more about in the Blitz manual.
no because that requires you to pick an entity in order to get the x y z coordinates. but thanks anyways.
i found a nifty one in the code archives for orthogonic view which is what i was looking for.
i found a nifty one in the code archives for orthogonic view which is what i was looking for.
orthogonal will just be wrong if you don't use that camera
no because that requires you to pick an entity in order to get the x y z coordinates
But if you don't pick to an entity, how can you possibly determine the Z component of the position?
If you don't want to make all your entities pickable, how about pick against using your skybox or ground plane instead? You could even place a vertical sprite in front of the camera, set the order to render behind anything else, then pick against that. Should be quick enough as you can use a really short pick range.
Why not build up a list of onscreen entities. Grab all there 2d co-ords onscreen and compare against the mousex and y co-ords?
Or... colour the backround black. Have each entity have it's own colour. Grab the colour of the pixel on the screen at the mouse X and Y co-ords. And look it up against the entity colours? You'll need to keep track of your entities via types or array, which is always handy to do anyway :o)
Or... colour the backround black. Have each entity have it's own colour. Grab the colour of the pixel on the screen at the mouse X and Y co-ords. And look it up against the entity colours? You'll need to keep track of your entities via types or array, which is always handy to do anyway :o)
Uh, only way i can think of to easily do it in Blitz3D: have an invisible yete pickable quad in front of the camera and camerapick it. Z will always be whatever you want it to be, just set the plane at Z in front of the camera and align it to the camera.
I think he's wanting to click somewhere on the screen, at the mouse's co-ords and get the nearest entity's xyz co-ords.
the one i got works perfectly. i have 3 views which use ortho, top left and front. i only need two axises for each view. the one i got in the code archives works beautifully.
basically i needed it so i can draw 3d geometry like ms paint LOL, best part is it works like paint with 3 views