91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 8KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-05
  • 語(yǔ)言: 其他
  • 標(biāo)簽: Qt??OpenGL??

資源簡(jiǎn)介

里面是一個(gè)簡(jiǎn)單的demo,實(shí)現(xiàn)用鼠標(biāo)控制視角的變換。

資源截圖

代碼片段和文件信息

#include?“glwidget.h“
#include
#include
#include
#include
#include
GLWidget::GLWidget(QWidget?*parent):QGLWidget(parent)
{

????/*初始化成員*/
????eyex=0.1;
????eyey=0.1;
????eyez=0.1;

????upx=0;
????upy=0.1;
????upz=0;

????CurrentAngleZ=0;
????CurrentAngleY=0;
????LastAngleZ=M_PI/4;
????LastAngleY=M_PI/4;

}


void?GLWidget::initializeGL()
{
????glShadeModel(GL_SMOOTH);
????glClearColor(0.00.00.00.0);
????glClearDepth(1.0);
????glEnable(GL_DEPTH_TEST);
????glDepthFunc(GL_LEQUAL);
????glHint(GL_PERSPECTIVE_CORRECTION_HINT?GL_NICEST);
}

void?GLWidget::resizeGL(int?w?int?h)
{
????glViewport(00(GLint)w(GLint)h);
????glMatrixMode(GL_PROJECTION);
????glLoadIdentity();


}

void?GLWidget::paintGL()
{
????glClear(GL_COLOR_BUFFER_BIT?|?GL_DEPTH_BUFFER_BIT);
????glMatrixMode(GL_MODELVIEW);
????glLoadIdentity();

????gluLookAt(eyex*0.1eyey*0.1eyez*0.1000upx*0.1upy*0.1upz*0.1);
????drawCoordinate();
????glColor3f(101);

????DrawShape(Id);
}

void?GLWidget::drawCoordinate()
{
????/*紅色軸是X軸,綠色是Y軸,藍(lán)色是Z軸*/
????glBegin(GL_LINES);
????glColor3f(1.0f0.00.0);
????glVertex3f(0.00.00.0);
????glVertex3f(0.50.00.0);
????glEnd();
????glPushMatrix();
????glTranslatef(0.5?0.0f?0.0f);
????glRotatef(90.0f0.0f1.0f0.0f);
????glutWireCone(0.0270.091010);
????glPopMatrix();


????glBegin(GL_LINES);
????glColor3f(0.01.00.0);
????glVertex3f(0.00.00.0);
????glVertex3f(0.00.50.0);
????glEnd();
????glPushMatrix();
????glTranslatef(0.0?0.5f?0.0f);
????glRotatef(-90.0f1.0f0.0f0.0f);
????glutWireCone(0.0270.091010);
????glPopMatrix();


????glBegin(GL_LINES);
????glColor3f(0.00.01.0);
????glVertex3f(0.00.00.0);
????glVertex3f(0.00.00.5);
????glEnd();
????glPushMatrix();
????glTranslatef(0.0?0.0f?0.5f);
????glutWireCone(0.0270.091010);
????glPopMatrix();

}

void?GLWidget::RotateViewPoint()
{
????float?avAnale=M_PI/180*0.6;?//把每次移動(dòng)的角度單位化

????/*把每次移動(dòng)點(diǎn)跟開始按下鼠標(biāo)記錄的點(diǎn)作差,然后乘以avAngle最后把上一次釋放鼠標(biāo)后時(shí)記錄的
??????角度相加起來(lái)*/
????CurrentAngleZ=(EndPoint.x()-StartPoint.x())*avAnale;
????CurrentAngleZ+=LastAngleZ;
????CurrentAngleY=(EndPoint.y()-StartPoint.y())*avAnale;
????CurrentAngleY+=LastAngleY;


????QVector3D?vector1(sin(CurrentAngleY)*sin(CurrentAngleZ)cos(CurrentAngleY)sin(CurrentAngleY)*cos(CurrentAngleZ));
????vector1=vector1.normalized();??//將坐標(biāo)單位化
????eyex=vector1.x();
????eyey=vector1.y();
????eyez=vector1.z();

????/*主要計(jì)算第三組坐標(biāo)*/
????QVector3D?vectorA(0sin(CurrentAngleY)0);
????QVector3D?vectorB=QVector3D(000)-QVector3D(sin(CurrentAngleY)*sin(CurrentAngleZ)0sin(CurrentAngleY)*cos(CurrentAngleZ));
????QVector3D?vectorAB=QVector3D::crossProduct(vectorAvectorB);


????QVector3D?vectorC=QVector3D(000)-vector1;
????QVector3D?vector2=QVector3D::crossProduct(vectorCvectorAB);
????vector2=vector2.normalized();
????upx=vector2.x();
????upy=vector2.y();
????upz=vector2.z();

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-09-27?19:56??GLDrawingProject\
?????文件?????????488??2013-09-27?19:53??GLDrawingProject\GLDrawingProject.pro
?????文件???????31422??2013-09-27?19:56??GLDrawingProject\GLDrawingProject.pro.user
?????文件????????4936??2013-09-27?19:55??GLDrawingProject\glwidget.cpp
?????文件????????1234??2013-09-27?19:43??GLDrawingProject\glwidget.h
?????文件?????????273??2013-09-17?16:17??GLDrawingProject\main.cpp
?????文件????????1532??2013-09-20?16:21??GLDrawingProject\mainwindow.cpp
?????文件?????????789??2013-09-20?16:19??GLDrawingProject\mainwindow.h
?????文件?????????654??2013-09-17?16:11??GLDrawingProject\mainwindow.ui

評(píng)論

共有 條評(píng)論