• opengl笔记——旋转,一段代码的理解


    重看:opengl笔记——OpenGL好资料备忘

    在找到这段代码,对理解opengl旋转很有帮助


    ...
    glPushMatrix();
    
    // initialze ModelView matrix
    glLoadIdentity();
    
    // First, transform the camera (viewing matrix) from world space to eye space
    // Notice all values are negated, because we move the whole scene with the
    // inverse of camera transform
    //要理解这段代码:opengl 没有提供操作相机的函数,移动相机就是反向移动模型坐标
    //可以理解为:把物体移到视野中去
    glRotatef(-cameraAngle[2], 0, 0, 1); // roll
    glRotatef(-cameraAngle[1], 0, 1, 0); // heading
    glRotatef(-cameraAngle[0], 1, 0, 0); // pitch
    glTranslatef(-cameraPosition[0], -cameraPosition[1], -cameraPosition[2]);
    
    // draw the grid at origin before model transform
    // 注意:表示
    drawGrid();
    
    // transform the object (model matrix)
    // The result of GL_MODELVIEW matrix will be:
    // ModelView_M = View_M * Model_M
    glTranslatef(modelPosition[0], modelPosition[1], modelPosition[2]);
    glRotatef(modelAngle[0], 1, 0, 0);
    glRotatef(modelAngle[1], 0, 1, 0);
    glRotatef(modelAngle[2], 0, 0, 1);
    
    // draw a teapot with model and view transform together
    drawTeapot();
    
    glPopMatrix();
    ...
    


    比较:

    // transform the object (model matrix)
    // The result of GL_MODELVIEW matrix will be:
    // ModelView_M = View_M * Model_M
    glTranslatef(modelPosition[0], modelPosition[1], modelPosition[2]);
    glRotatef(modelAngle[0], 1, 0, 0);
    glRotatef(modelAngle[1], 0, 1, 0);
    glRotatef(modelAngle[2], 0, 0, 1);
    
    
    //放在这,区别:网格随物体移动(当改变modelPosition时)
    drawGrid();
    // draw a teapot with model and view transform togetherdrawTeapot();
    
    
    
    
    

    http://www.songho.ca/opengl/gl_transform.html#overview


  • 相关阅读:
    struts开发步骤
    线程同步及同步变量
    pthread_detach pthread_join pthread_create
    NSThread
    Java线程中run和start方法的区别
    java的守护线程与非守护线程
    多线程的多重属性
    Java Observer 观察者
    Java_观察者模式(Observable和Observer)
    任务、进程和线程
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3310657.html
Copyright © 2020-2023  润新知