geometry - Opengl - Moving object along (parallel or perpendicular) the view plane -
i think have unique problem. have 2 objects. 1 cube static. have sphere want move. glulookat is:
float theta = (float) math.toradians(yrot); float phi = (float) math.toradians(xrot); glu.glulookat(math.sin(phi) * math.cos(theta) * cameramovementradius, math.sin(phi) * math.sin(theta) * cameramovementradius, math.cos(phi) * cameramovementradius, 0, 0, 0, math.cos(theta), math.sin(theta), 1);
this positions camera along spherical path. want move sphere along view-plane no matter angel looking @ cube. example: if looking @ cube from: phi = 30 & theta = 85, sphere's forward , backward movement should perpendicular view-plane not towards origin (illustrated below). how achieve this? trying transform navigation of sphere.
| | | forward & backward movement of sphere | | ---------------- view plane (forward & backward movement viewed top) ___________ left & right movement of sphere ---------------- view plane (forward & backward movement viewed top)
update: able achieve forward backward movement finding direction vector parallel line of sight (camera position , origin). however, cant perpendicular movement. understand there infinite number of perpendicular vector need move left or right , or down. maybe not looking @ problem right way!?!
Comments
Post a Comment