View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Roll Snap For Rollercoaster Simulation

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1laylay  Members

Posted 04 November 2012 - 01:17 PM

I'm working on a rollercoaster simulation, I have a path of points so that means I have the tangents for each point.
I'm calculating the binormals and normals as explained here: http://www.cs.cmu.ed...sst2camera.html

The problem with that is the normals start to roll when going up and turning, so when the path comes back down, the normals aren't facing directly up like you'd expect. What I want to do is lock the rolling of the track so for example, if you tried to create a loop, the path would start to twist when getting near to the top so there's never any roll in the track.

So I've found a paper that I think solves this but I'm having trouble understanding what they mean at the "roll snap" section.

https://dip.felk.cvu...er_2010bach.pdf

It first off starts by saying "Using a dot product, we calculate the angle between the vector pointing straight up ((0, 1, 0)?) and a vector being the up vector that we want to straighten."

That itself confuses me because if i dot a normal of (0,1,0) and (0,1,0), that's going to give me a value of 1. That is not an angle i should be applying to the normal because in that situation the normal is correct and doesn't need to be corrected.

Tried to explain as best I could. If not, here's an image that explains what I want to happen.

If I have a track like this that has roll, I want to remove all roll by rotating the normal around the tangent.

The reason why I need to do this is so the user can define the roll of each node instead of the track rolling on its own when creating the track.

Edited by laylay, 04 November 2012 - 01:22 PM.

### #2laylay  Members

Posted 04 November 2012 - 04:15 PM

I seem to have fixed it.

This is the part I think I was getting wrong.
"Using dot product, we calculate the angle between the vector pointing straight up and the vector that we want to straighten"

I translated that to
float angle = normal.Dot(Vector3f(0.0f, 1.0f, 0.0f));

When it should be
float angle = normal.Dot(tangent.Cross(Vector3f(0.0f, 1.0f, 0.0f)));

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.