資源簡(jiǎn)介
基于OPenGL的場(chǎng)景漫游及模型加載,包括了場(chǎng)景的創(chuàng)建, obj的導(dǎo)入,還有可編程流水線的應(yīng)用
代碼片段和文件信息
//based?on?.11??用虛擬跟蹤球?qū)崿F(xiàn)立方體旋轉(zhuǎn)程序
//Recreated?by?Crystal
/*?Rotating?with?trackball?*/
#undef?UNICODE
#include?
#include
#include?
#include?
#include
#include?“LoadObj.h“
#include?“l(fā)ight.h“
#define?bool?int
#define?false?0
#define?true?1
#define?M_PI?3.14
int??winWidth?winHeight;
float??angle?=?0.0?axis[3]?trans[3];
bool??trackingMouse?=?false;
bool?redrawContinue?=?false;
bool???trackballMove?=?false;
int?transformMode?=?0;
int?midfill?=?1;
Light*?light;
/*?Draw?the?cube?*/
GLfloat?vertices[][3]?=?{
{?1.214124?0.000000?1.589309?}
{?0.375185?1.154701?1.589309?}
{?-0.982247?0.713644?1.589309?}
{?-0.982247?-0.713644?1.589309?}
{?0.375185?-1.154701?1.589309?}
{?1.964494?0.000000?0.375185?}
{?0.607062?1.868345?0.375185?}
{?-1.589309?1.154701?0.375185?}
{?-1.589309?-1.154701?0.375185?}
{?0.607062?-1.868345?0.375185?}
{?1.589309?1.154701?-0.375185?}
{?-0.607062?1.868345?-0.375185?}
{?-1.964494?0.000000?-0.375185?}
{?-0.607062?-1.868345?-0.375185?}
{?1.589309?-1.154701?-0.375185?}
{?0.982247?0.713644?-1.589309?}
{?-0.375185?1.154701?-1.589309?}
{?-1.214124?0.000000?-1.589309?}
{?-0.375185?-1.154701?-1.589309?}
{?0.982247?-0.713644?-1.589309?}
};
GLfloat?colors[][3]?=?{
{?0.5?0.5?0.5?}?{?1.0?0.0?0.0?}
{?1.0?1.0?0.0?}?{?0.0?1.0?0.0?}?{?0.0?0.0?1.0?}
{?1.0?0.0?1.0?}?{?1.0?0.3?0.3?}?{?0.0?1.0?1.0?}
{?0.7?0.7?0.7?}?{?1?0?0?}?{?1?1?0?}?{?0?1?0?}
};
void?polygon(int?a?int?b?int?c?int?d?int?e?int?face)
{
/*?draw?a?polygon?via?list?of?vertices?*/
if?(midfill?==?1)
{
glBegin(GL_POLYGON);
}
else
{
glBegin(GL_LINE_LOOP);
}
glColor3fv(colors[face]);
glVertex3fv(vertices[a]);
glVertex3fv(vertices[b]);
glVertex3fv(vertices[c]);
glVertex3fv(vertices[d]);
glVertex3fv(vertices[e]);
glEnd();
}
void?colorcube(void)
{
/*?map?vertices?to?faces?*/
polygon(0?1?2?3?4?0);
polygon(0?5?10?6?1?1);
polygon(1?6?11?7?2?2);
polygon(2?7?12?8?3?3);
polygon(3?8?13?9?4?4);
polygon(4?9?14?5?0?5);
polygon(15?10?5?14?19?6);
polygon(16?11?6?10?15?7);
polygon(17?12?7?11?16?8);
polygon(18?13?8?12?17?9);
polygon(19?14?9?13?18?10);
polygon(19?18?17?16?15?11);
}
/*?These?functions?implement?a?simple?trackball-like?motion?control?*/
float?lastPos[3]?=?{?0.0F?0.0F?0.0F?};
int?curx?cury;
int?startX?startY;
void?trackball_ptov(int?x?int?y?int?width?int?height?float?v[3])
{
float?d?a;
/*?project?xy?onto?a?hemisphere?centered?within?width?height?*/
v[0]?=?(2.0F*x?-?width)?/?width;
v[1]?=?(height?-?2.0F*y)?/?height;
d?=?(float)sqrt(v[0]?*?v[0]?+?v[1]?*?v[1]);
v[2]?=?(float)cos((M_PI?/?2.0F)?*?((d?1.0F)???d?:?1.0F));
a?=?1.0F?/?(float)sqrt(v[0]?*?v[0]?+?v[1]?*?v[1]?+?v[2]?*?v[2]);
v[0]?*=?a;
v[1]?*=?a;
v[2]?*=?a;
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????74440??2012-10-26?23:51??Cube\Cube\20130827050204354655.jpg
?????文件???????1793??2015-06-01?21:25??Cube\Cube\anji.mtl
?????文件?????153383??2015-06-01?21:25??Cube\Cube\anji.obj
?????文件????2161637??2014-05-25?22:50??Cube\Cube\AS_Creation_AmbassadorII_733023_ba
?????文件???????3832??2015-05-26?21:57??Cube\Cube\chair.obj
?????文件???????4308??2015-06-17?11:27??Cube\Cube\Cube.vcxproj
?????文件???????1403??2015-06-17?11:27??Cube\Cube\Cube.vcxproj.filters
?????文件????????801??2015-06-01?21:21??Cube\Cube\Debug\Cube.Build.CppClean.log
?????文件???????2254??2015-06-17?11:37??Cube\Cube\Debug\Cube.log
?????文件????????648??2015-06-17?11:37??Cube\Cube\Debug\Cube.tlog\cl.command.1.tlog
?????文件??????30666??2015-06-17?11:37??Cube\Cube\Debug\Cube.tlog\CL.read.1.tlog
?????文件????????468??2015-06-17?11:37??Cube\Cube\Debug\Cube.tlog\CL.write.1.tlog
?????文件????????176??2015-06-17?11:37??Cube\Cube\Debug\Cube.tlog\Cube.lastbuildstate
?????文件???????2432??2015-06-17?11:37??Cube\Cube\Debug\Cube.tlog\li
?????文件???????3518??2015-06-17?11:37??Cube\Cube\Debug\Cube.tlog\li
?????文件????????564??2015-06-17?11:37??Cube\Cube\Debug\Cube.tlog\li
?????文件????????512??2015-06-17?11:37??Cube\Cube\Debug\Cube.tlog\rc.command.1.tlog
?????文件???????2200??2015-06-17?11:37??Cube\Cube\Debug\Cube.tlog\rc.read.1.tlog
?????文件????????238??2015-06-17?11:37??Cube\Cube\Debug\Cube.tlog\rc.write.1.tlog
?????文件?????????92??2015-06-17?11:37??Cube\Cube\Debug\Resource.res
?????文件?????781312??2015-06-17?11:37??Cube\Cube\Debug\vc120.idb
?????文件?????528384??2015-06-17?11:37??Cube\Cube\Debug\vc120.pdb
?????文件?????498956??2015-06-17?11:37??Cube\Cube\Debug\wander.obj
?????文件????????406??2015-05-23?10:25??Cube\Cube\desk.mtl
?????文件??????84670??2015-05-23?10:25??Cube\Cube\desk.obj
?????文件????????406??2015-05-26?00:12??Cube\Cube\desk1.mtl
?????文件??????84048??2015-05-26?00:12??Cube\Cube\desk1.obj
?????文件????????406??2015-05-26?00:14??Cube\Cube\desk2.mtl
?????文件??????88241??2015-05-26?00:14??Cube\Cube\desk2.obj
?????文件?????786486??2015-05-26?15:40??Cube\Cube\deskmtl.bmp
............此處省略36個(gè)文件信息
評(píng)論
共有 條評(píng)論