资源简介
axes.zip
代码片段和文件信息
#include “axes.h“
Axes::Axes(QWidget *parent) : QOpenGLWidget(parent) _eye(0 0 20) _center(0 0 0) _up(0 1 0)
{
}
void Axes::initializeGL()
{
initializeOpenGLFunctions();
// glClearColor(0.75 0.75 0.75 1.0);
glClearColor(0.0 0.0 0.0 1.0);
glPolygonMode(GL_FRONT_AND_BACK GL_FILL);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glColorMaterial(GL_FRONT_AND_BACK GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHT0);
glDisable(GL_LIGHTING);
// We need a valid OpenGL context before building the 3D font display lists.
float glyphWidth = 3;
int numGlyphs = 256;
QFont font = QFont(“Sans“ 20 QFont::Normal);
_textRender.setFont(font glyphWidth numGlyphs);
}
void Axes::resizeGL(int w int h)
{
glViewport(0 0 width() height());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
perspective(10 float(w) / h 2 200);
glMatrixMode(GL_MODELVIEW);
}
void Axes::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
lookAt(_eye _center _up);
DrawSpaceAxes();
}
void Axes::DrawSpaceAxes()
{
GLdouble axesLen = 0.1;
GLdouble radius = 0.03;
GLdouble base = 0.01;
GLdouble top = 0.01;
GLdouble baseRadius = 0.03;
GLdouble topRadius = 0.0;
GLUquadricObj *objCylinder = gluNewQuadric();
//---------------------------------------------------------------------z
glPushMatrix();
glColor3f(1.0f 0.0f 0.0f);
glutSolidSphere(radius66);
glColor3f(0.0f0.0f 1.0f);
gluCylinder(objCylinderbase top axesLen 10 5); //Z
glTranslatef(00axesLen);
gluCylinder(objCylinderbaseRadius topRadius baseRadius 10 5); //Z
glPopMatrix();
glPushMatrix();
glTranslatef(0 axesLen / 2axesLen);
DrawSpaceText(“Z“);
glPopMatrix();
//---------------------------------------------------------------------y
glPushMatrix();
glColor3f(0.0f1.0f 0.0f);
glRotatef(-901.00.00.0);
gluCylinder(objCylinderbase top axesLen 10 5); //Y
glTranslatef(00axesLen);
gluCylinder(objCylinderbaseRadius topRadius baseRadius 10 5); //Y
glPopMatrix();
glPushMatrix();
glTranslatef(axesLen / 2axesLen0);
DrawSpaceText(“Y“);
glPopMatrix();
//---------------------------------------------------------------------x
glPushMatrix();
glColor3f(1.0f0.0f 0.0f);
glRotatef(900.01.00.0);
gluCylinder(objCylinderbase top axesLen 10 5); //X
glTranslatef(00axesLen);
gluCylinder(objCylinderbaseRadius topRadius baseRadius 10 5); //X
glPopMatrix();
glPushMatrix();
glTranslatef(axesLenaxesLen / 20);
DrawSpaceText(“X“);
glPopMatrix();
}
void Axes::DrawSpaceText(QString text)
{
// Draw 3D text.
QVector3D position(0 0 0);
int align = Qt::AlignHCenter | Qt::Al
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-12-03 07:54 axes\
文件 4981 2019-03-18 15:06 axes\QtFont3D.cpp
文件 1539 2019-03-18 15:06 axes\QtFont3D.h
文件 7381 2020-12-03 07:54 axes\axes.cpp
文件 1251 2020-12-03 15:57 axes\axes.h
文件 1166 2020-12-03 05:25 axes\axes.pro
文件 24192 2020-12-03 05:41 axes\axes.pro.user
目录 0 2020-12-03 07:54 axes\build\
文件 739 2020-12-03 04:53 axes\build\.qmake.stash
文件 25180 2020-12-03 05:25 axes\build\Makefile
文件 919608 2020-12-03 04:59 axes\build\QtFont3D.o
文件 1321504 2020-12-03 07:54 axes\build\axes
文件 784248 2020-12-03 07:54 axes\build\axes.o
文件 914232 2020-12-03 07:54 axes\build\main.o
文件 2614 2020-12-03 07:54 axes\build\moc_axes.cpp
文件 826992 2020-12-03 07:54 axes\build\moc_axes.o
文件 13992 2020-12-03 04:59 axes\build\moc_predefs.h
文件 347 2020-12-03 05:55 axes\main.cpp
相关资源
- saber2016crack.zip
- PAT蓝桥LeetCode学习路径刷题经验_v2.4
- OA_Office_System.zip
- 奇妙三代2013.zip
- 算法图解.zip290111
- ssm实验室设备管理系统.zip
- DiskGenius4.6.2注册版.zip
- 秒余额灰色项目源码.zip
- [奥本海姆]信号与系统(第二版)中文
- 《鸟哥的Linux私房菜-基础篇》第四版
- Book.zip
- 最新IDM已注册.zip
- 数字信号处理4版中文版.zip
- ADS2011射频电路设计与仿真_徐兴福著
- 宠物购物网测试设计与实施.rar
- Boltzmann方法的理论及应用何雅玲.zip
- CPLEX中文教程.zip
- 机器人航路规划代码合集.zip
- 软件测试报告范例.zip
- 基于状态空间的模型预测控制ssmpc.z
- 矩阵分析与应用习题解答.zip
- NavicatPremium12.zip
- ssh_depot.zip
- FGSM.zip
- Office2013-2019C2RInstall组件定义.zip
- PhaseLockedLoop.zip
- 41_springboot二手交易市场实现.zip
- 天龙源码.zip
- LMSImagine.LabAMESim系统建模和仿真参考手
- fefd802dcb3be4c86d64e6e67145ede9.pdf
评论
共有 条评论