資源簡介
本程序在qt下,使用opengl讀取并處理obj模型,包括兩種:包含紋理的obj模型以及使用顏色處理的obj模型。
注意:由于是qt的源碼文件,涉及到資源路徑問題,請將源碼放在桌面上,例如:C:/..../桌面/QT

代碼片段和文件信息
#include?“glwidget.h“
#include?
glWidget::glWidget(QWidget*?parent):
????QGLWidget(parent)
{
????mode?=?true;
????xPos?=0.0;
????yeye?=0.0;
????yPos?=?zPos?=?20.0;
????xangle?=?yangle?=?0;
????scale?=?1.0;
????pCastle?=?new?objloader();
????pframe?=?new?objloader();
????pframe2?=?new?objloader();
????pframe3?=?new?objloader();
????pframe4?=?new?objloader();
????pframe5?=?new?objloader();
????pframe6?=?new?objloader();
????pLand?=?new?landform();
????texLand?=?new?GLuint();
}
void?glWidget::initLight()
{
????//set?lights
????//GLfloat?mat_specular[]?=?{1.01.01.01.0};
????//GLfloat?mat_shiniess[]?=?{100.0};
????GLfloat?light_ambient?[4]?=?{1.01.01.01.0};
????GLfloat?light_diffuse?[4]?=?{1.01.01.01.0};
????GLfloat?light_specular[4]?=?{1.01.01.01.0};
????GLfloat?light_position[4]?=?{1500.01500.01500.00.0};
????//GLfloat?lmodel_ambient?[]?=?{1.01.01.01.0};
????//create?light
????//glMaterialfv(GL_FRONTGL_SPECULARmat_specular);
????//glMaterialfv(GL_FRONTGL_SHININESSmat_shiniess);
????glLightfv(GL_LIGHT0?GL_AMBIENT?light_ambient);
????glLightfv(GL_LIGHT0?GL_DIFFUSE?light_diffuse);
????glLightfv(GL_LIGHT0?GL_SPECULARlight_specular);
????glLightfv(GL_LIGHT0?GL_POSITIONlight_position);
????//glLightModelfv(GL_LIGHT_MODEL_AMBIENTlmodel_ambient);???//全局環(huán)境光
????//glLightModeli(GL_LIGHT_MODEL_TWO_SIDEGL_TRUE);//多次渲染?(normal*-1)?貌似什么效果
????//glLightModeli(?GL_FRONT?GL_AMBIENT_AND_DIFFUSE?);
????glEnable(GL_LIGHTING);
????glEnable(GL_LIGHT0);
????glEnable(GL_DEPTH_TEST);
}
void?glWidget::initializeGL()
{
????char?desktopPath[100];
????int?i;
????for(i=0;?i ????{
????????desktopPath[i]?=?QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)[i].toLatin1();
????}
????desktopPath[i]?=?‘\0‘;
????//setGeometry(0.00.01000680);
????glClearColor(0.00.00.00.0);
????glShadeModel(GL_SMOOTH);
????initLight();
????//tex
????glEnable(GL_TEXTURE_2D);
????char?path[100];
????strcpy(pathdesktopPath);
????strcat(desktopPath“/Qt/ourhouse/resource/house_obj.obj“);
????pCastle->loading(desktopPath);
????loadTexture(“C:/Users/Liew?Dennis/Desktop/Qt/ourHouse/resource/house_diffuse.jpg“pCastle->texture);
????strcpy(desktopPathpath);
????strcat(desktopPath“/Qt/ourhouse/resource/frame.obj“);
????pCastle->loading(desktopPath);
????loadTexture(“:/new/resource/gdragon.jpg“pframe->texture);
????pframe2->loading(desktopPath);
????loadTexture(“:/new/resource/gdragon2.jpg“pframe2->texture);
????pframe3->loading(desktopPath);
????loadTexture(“:/new/resource/lsm1.jpg“pframe3->texture);
????pframe4->loading(desktopPath);
????loadTexture(“:/new/resource/lsm2.jpg“pframe4->texture);
????pframe5->loading(desktopPath);
????loadTexture(“:/new/resource/lsm3.jpg“pframe5->texture);
????pframe6->loading(desktopPath);
????loadTexture(“:/new/resource/lsm4.jpg“pFra
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-08-28?10:27??Qt\
?????目錄???????????0??2016-08-28?10:27??Qt\ourHouse\
?????文件????????6275??2016-08-28?10:14??Qt\ourHouse\glwidget.cpp
?????文件?????????809??2016-08-08?18:13??Qt\ourHouse\glwidget.h
?????文件?????????690??2016-08-09?00:13??Qt\ourHouse\image.qrc
?????文件????????3267??2016-08-07?22:21??Qt\ourHouse\landform.cpp
?????文件?????????458??2016-08-07?20:45??Qt\ourHouse\landform.h
?????文件?????????183??2016-08-07?08:57??Qt\ourHouse\main.cpp
?????文件????????4141??2016-08-08?18:30??Qt\ourHouse\mainwindow.cpp
?????文件?????????774??2016-08-08?17:16??Qt\ourHouse\mainwindow.h
?????文件?????????654??2016-08-07?08:57??Qt\ourHouse\mainwindow.ui
?????文件????????3368??2016-08-09?00:28??Qt\ourHouse\objloader.cpp
?????文件?????????454??2016-08-09?00:32??Qt\ourHouse\objloader.h
?????文件?????????563??2016-08-08?17:15??Qt\ourHouse\ourHouse.pro
?????文件???????18063??2016-08-28?09:39??Qt\ourHouse\ourHouse.pro.user
?????文件????????4977??2016-08-28?10:24??Qt\ourHouse\point.h
?????目錄???????????0??2016-08-28?10:27??Qt\ourHouse\resource\
?????文件?????????222??2016-08-05?20:47??Qt\ourHouse\resource\fr
?????文件????????3973??2016-08-05?20:47??Qt\ourHouse\resource\fr
?????文件??????394041??2016-08-07?14:21??Qt\ourHouse\resource\gdragon.jpg
?????文件???????71213??2016-08-07?19:57??Qt\ourHouse\resource\gdragon2.jpg
?????文件?????2398864??2016-08-07?08:56??Qt\ourHouse\resource\house_diffuse.jpg
?????文件?????????288??2009-05-20?20:43??Qt\ourHouse\resource\house_obj.mtl
?????文件??????133681??2009-05-20?20:42??Qt\ourHouse\resource\house_obj.obj
?????文件?????1665002??2016-07-31?20:35??Qt\ourHouse\resource\landform.obj
?????文件?????1306099??2016-08-08?17:50??Qt\ourHouse\resource\landform1.jpg
?????文件??????844991??2016-08-08?16:22??Qt\ourHouse\resource\lsm1.jpg
?????文件??????249152??2016-08-08?16:23??Qt\ourHouse\resource\lsm2.jpg
?????文件??????462503??2016-08-08?16:26??Qt\ourHouse\resource\lsm3.jpg
?????文件??????578151??2016-08-08?16:28??Qt\ourHouse\resource\lsm4.jpg
?????文件??????410104??2016-08-01?22:26??Qt\ourHouse\resource\lsm_heart.obj
............此處省略2個文件信息
評論
共有 條評論