Skip to main content
gamedev.net
🔒 Locked

Ray Tracing Problem

Started by marcus12 0 replies 750+ views
Original Post
marcus12
marcus12
Hi,
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
Indie Game Developer Game Studio: Freakout Games
Shaarigan
Shaarigan
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.