Jump to content

Recommended Posts

Posted

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

Posted

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.

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++

Posted

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)

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

Mathlib has already a Length() function which does that, it's automatically available when you #include "engine.h".

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...