OpenGl GluLookAt. Cannot orient object -


i have 2 objects in different coordinate systems: planet , cylinder. have eye coordinates of both objects. want orient cylinder along vector connects , planet.

orient cylinder along red vector

  glloadmatrixf( planettransform);   // .. draw planet   glloadmatrixf( cylindertransform);   glcolor3f(0, 1, 0);   drawcylinder();    // draw vector connects cylinder , planet   glcolor3f(1, 0, 0);   glloadidentity();   glbegin(gl_lines);      // planet eye pos e.g. (0.045; -0.049; -0.186)      glvertex3f(point1.x, point1.y, point1.z);      // cylinder eye pos e.g. (-0.109; -0.064; -0.203)      glvertex3f(point2.x, point2.y, point2.z);   glend();    // orient cylinder along red vector   // tvector normal(0, 0, 1);   glloadidentity();   glulookat(point2.x, point2.y, point2.z,      point1.x, point1.y, point1.z,      normal.x, normal.y, normal.z);    drawcylinder(); 

draw cylinder code:

  void drawcylinder()   {   glpushmatrix();   glrotatef(90, 1, 0, 0);   glucylinder(gp_quadratic, 0.01, 0, 0.03, 15, 15);   glpopmatrix();   } 

i tried specify normal as:

  tvector normal;   tvector::cross(point2 - point1, tvector(0, 0, 1), normal); 

so @ end expect see 2 cylinders - 1 green, 1 - red. red should oriented along red segment. not see red one. please me find wrong here? red cylinder not appear in center of green cylinder coordinate system..

the glucylinder(/**/)

  1. is built along local z-axis, pointing outwards along red line
  2. the local y-axis global z_axis (pointing viewer), projected onto viewing plane of planet
  3. thus local x-axis poiting along viewing plane of planet
  4. thus after glrotatef(90, 1, 0, 0); cylinder points away user depth of picture , hidden behind planet
  5. thus if instead glrotatef(180, 1, 0 ,0 ); used, should fine afais.

i've quite nightshift behind me, vision may flawed, it's cheap try that, isn't it.

if i'm in error, try using glpolygonmode(gl_front_and_back, gl_line) planet, , cylinder is.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -