Dozz Posted May 1, 2011 Share Posted May 1, 2011 Well, I am getting on well with my cpp testing, achieving results in hours whereas I was expecting a big learning curve. Leadwerks & this forum = great. Using CameraPick, I am selecting and highlighting objects no problem, and displaying pick.X etc.. I have defined: float distanceto = 0.0; and inside the main loop: DrawText(10,70,"distance: %f",distanceto); after the CameraPick: distanceto = EntityDistance(cam,pick.entity); ...this does give the distance to the selected object ok, but to its pivot point. I want the distance to the exact picked point on the object given in pick.X, .Y & .Z What is the proper way to do that? I know its not to work out the trig manually between x,y & z points. Thanks for your help Quote Link to comment Share on other sites More sharing options...
Pixel Perfect Posted May 1, 2011 Share Posted May 1, 2011 I know its not to work out the trig manually between x,y & z points. Well thats exactly how I do it! I wrote a small function that takes two vec3s for the positions and uses pythagoras to work out the distance returning the float. Failing that, you could temporarily position a pivot entity at that position and use that in the EntityDistance function. Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Josh Posted May 1, 2011 Share Posted May 1, 2011 dx = pick.position.x - camera.position.x dy = pick.position.y - camera.position.y dz = pick.position.z - camera.position.z d = sqrt(dx*dx+dy*dy+dz*dz) Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Dozz Posted May 2, 2011 Author Share Posted May 2, 2011 thanks Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted May 3, 2011 Share Posted May 3, 2011 I had this in class last week. Only in 2d instead of 3d. Quote Link to comment Share on other sites More sharing options...
Canardia Posted May 3, 2011 Share Posted May 3, 2011 Mathlib has already a Length() function which does that, it's automatically available when you #include "engine.h". Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.