So this is what I’m working on…
I’m using a 2D system to pull in the screen coordinates and I translate them into openGL coordinates. I create a line at the center with the center being (0,0) and then the end point being the open GL screen coordinate. It looks fine. Then i wanted to translate the line around on the screen with the keyboard. Ok So I apply a Translation matrix on it. That works fine, it translates around with every key press and still rotates about the right origin.
PushMatrix
Translate(transVec[0],transVec[1], 0)
DrawLine
PopMatrix
Some Variables:
mTransVec[2] = translation vector. x = [0] & y = [1].
mLineEnd[2] = Lines endpoints, openGL coords, in an array. x = [0] & y = [1].
Angle = the rotational angle that the line is at from the origin in degree’s or rads
The Problem:
I’m trying to figure out the math or some way with translation and rotation matrices that when I hit a key to go “forward” that the line will go in the direction/angle the line is pointing.
I’m so lost as to how to do this… been trying a lot so far with rotation, using the angle of rotation and then some how tranlate it along that angle by rotating it… ahhh not working It likes to keep going in circles. =\
Any help or direction of the math behind having the object follow where the cursor is would help so dearly. Thanks.