Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

A ray with an ending position?

This topic is 912 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This snippet is written for an adapter of Irrlicht to argortha
Now, I want to write another adapter for DirectX
Just wondering the code underneath which specifies a lineCollision, it is to me a
line, but when passing to getCollisionPoint, it is a ray.
Can I treat them both the same?
I would use the
D3DXboxBoundProbe function

Rather be

D3DXIntersect instead, sorry

https://msdn.microsoft.com/en-us/library/windows/desktop/bb172713%28v=vs.85%29.aspx
 

irr::core::line3df lineCollision(actorPos, IrrVector3Adapter(io_actor->getPosition() + in_displacement));

irr::core::vector3df outColl;
irr::core::triangle3df outTri;

if (mScmgr->getSceneCollisionManager()->getCollisionPoint(lineCollision, mSelector, outColl, outTri))
Edited by lucky6969b

Share this post


Link to post
Share on other sites
Advertisement
Technically it is more or less the same, two vectors.

Semantically a line is has a start and end which can be represented as (position, position+direction) or (start_position,end_position). Well, a ray is typically a start point with a direction vector, so (position, direction), where direction is typically normalized.

Therefor it is easy to get a ray from a line by just normalizing the direction, either (position,normalize(direction)) or if you have a start-,endpoint you get (start_point, normalize(end_point-start_point)).

But, once you have a ray with an normalized direction, you can't extract the original line back.

Share this post


Link to post
Share on other sites


A ray with an ending position is called a segment.

 

or a displacement vector, but then the origin is unspecified, IE its just a direction and distance.

 

but technically speaking, yes - a line is of infinite length, and a line segment has endpoints.

Share this post


Link to post
Share on other sites

Sorry, back in here again.
I find that D3DXIntersect doesn't suit my needs.
That requires a ID3DXMesh and a Line Segment intersection test.
Just wondering what can replace the D3DXIntersect function to
test between ID3DXMesh and a Line Segment (a line that *does* have
an endpoint)
Thanks
Jack

Share this post


Link to post
Share on other sites

Hi there. You may be able to use D3DXIntersect by converting the line segment to a ray and then checking the pDist returned from the D3DXIntersect. If PDist is greater then the Lines length not a collision.

Share this post


Link to post
Share on other sites

If this is performance critical it would be faster to compare the squared distances to avoid calculating square roots.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!