Camera Pick Code/Tutorial
BlitzMax Forums/BlitzMax Programming/Camera Pick Code/Tutorial
| ||
Does anyone have any code for camera picking or even know of a tutorial? I.e Something like in b3d, hit=CameraPick MyCam,XPixel,YPIxel if hit x = pickedx() y = pickedy() z = pickedz() endif Would it involve the use of a linepick function or is done with a custom matrix? |
| ||
What are you exactly talking of? As there is no camera, you can do a simple CollideRect test to find all objects the mouse pointer collides with at click for example. |
| ||
I think you need to go the martix route, as Dreamora says there is no Entity Type called Camera but you do have the projection matrix to play with. |
| ||
Well there is a camera entity class in what i'm using(TrinityV2) I'm just not sure how to approach it. I keep finding links pointing towards supposedly a good tutorial on the subject but none of them are working anymore. Anyone got a link to a working version? I can see the projection matrix idea working if I download gl projection matrix and use a simple point in poly test on each tri. With this I could easily determine which entity is hit but I'd still be at a loss when it comes to finding out the exact x,y,z of the intersection. I'm sure blitz returned this. Mark! MARK! |
| ||
There's a lot of tutorials out there. Google for "OpenGL picking tutorial". I used this one a couple of weeks ago: http://www.lighthouse3d.com/opengl/picking/ |
| ||
Thanks for that but I was under the impression that regular gl picking can only identify on a per entity basis rather than specifying an exact tri and the location of the hit? Any idea how mark did it in b3d? |
| ||
you got msn ant? add slightlyevilmonkee@... dont mind helping out |
| ||
An easy and fast way of finding the picked X, Y and Z coordinates could be reading the depth of a pixel, then creating a vector from the appropriate place of the forefront of the view frustum with the length of the depth. The picked X, Y and Z coordinates are where this vector ends. Hah it's impossible to express such stuff in English :/ Maybe this image can help: ![]() |