Jump to content
  • Advertisement
Sign in to follow this  

Ray Tracing Problem

This topic is 2894 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

I am trying to implement a Laser beam and use ray tracing to detect the collision.

In the figure it can be seen that if the beam is in 'A' position then there is no collision and when the Laser is in
'B' position then the collision is detected and it is indicated by turning into red.

but when the laser is rotated then the same collision is not working as in the case of 'C'

For ray I am using t = startPoint + t * direction; equation

The problem I am seeing is that the calculation of start point position
THe start point of the ray is different in the case of 'C' but after using glRotatef() when I try to fetch the start point value
it gives the position same as in the case of 'A' and 'B'

How to find the updated position after rotation or is there any alternative way of doing it.

All suggestions are welcome

Share this post

Link to post
Share on other sites
We take this in our Engine to determine if the player is facing an interactable object or other player.
Here is a the Next-Function from our Ray-Class.

public virtual void Next(int steps)
Vector3 v = this.view;

for (int i = 0; i < steps; i++)
v.X -= (float)Math.Sin(-this.Rotation.Y * Math.PI / 180.0) * stepWidth;
v.Z -= (float)Math.Cos(-this.Rotation.Y * Math.PI / 180.0) * stepWidth;
v.Y += (float)Math.Sin(-this.Rotation.X * Math.PI / 180.0) * stepWidth;

this.view = v;

I already taked it too to have a simple fujnktion that lets a pong ball move and calculates the
incoming/outcoming colision angel.

Hope it helps you

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!