資源簡介
沒有直接調用OpenGL幾何變換函數,運用齊次坐標,采用矩陣相乘的方式自己編程實現;
控制方式:鼠標左鍵拖著移動,鼠標右鍵旋轉方向,滾輪縮放
我為了完成實驗作業自己寫的
代碼片段和文件信息
#include?“stdafx.h“
//#include?“math3d.h“
#include
#include?
#include?
#include?
using?namespace?std;
#define?GLUT_WHEEL_UP?3
#define?GLUT_WHEEL_DOWN?4
////////////////////////////////////////////////////////////
////math3d////
#define?PI_DIV_180?(0.017453292519943296)//?1°=?2π/360?=?0.0174弧度
typedef?float Vector2f[2]; //?3D?points?=?3D?Vectors?but?we?need?a?
typedef?float Vector3f[3]; //?Vector?of?three?floats?(x?y?z)
typedef?float Vector4f[4]; //?Lesser?used...?Do?we?really?need?these?
typedef?float Matrix33f[9]; //?A?3?x?3?matrix?column?major?(floats)?-?OpenGL?style
typedef?float???Matrix44f[16]; //?A?4?X?4?matrix?column?major?(floats)?-?OpenGL?style
#define?DegToRad(x) ((x)*PI_DIV_180)
inline?void?LoadVector3(Vector3f?v?const?float?x?const?float?y?const?float?z)
{
v[0]?=?x;?v[1]?=?y;?v[2]?=?z;
} //?4x4?float
inline?void CopyVector3(Vector3f?dst?const?Vector3f?src)?{?memcpy(dst?src?sizeof(Vector3f));?}
inline?void?LoadVector4(Vector4f?v?const?float?x?const?float?y?const?float?z?const?float?w)
{
v[0]?=?x;?v[1]?=?y;?v[2]?=?z;?v[3]?=?w;
}
void?LoadIdentity44(Matrix44f?m)
{
//?Don‘t?be?fooled?this?is?still?column?major
static?Matrix44f identity?=?{?1.0f?0.0f?0.0f?0.0f
0.0f?1.0f?0.0f?0.0f
0.0f?0.0f?1.0f?0.0f
0.0f?0.0f?0.0f?1.0f?};
memcpy(m?identity?sizeof(Matrix44f));
}
////////////////////////////////////////////////////////////
//參數
static?float?rotatee?=?0.001;
static?float?translate?=?0.01;
static?float?PI?=?3.14159;
void?translate3D(GLfloat?tx?GLfloat?ty?GLfloat?tz);
void?scale3D();
void?Vector4Mulitply(Vector4f?vOut?const?Vector4f?v?const?Matrix44f?m);
void?comChange(float?angle?float?angle2?GLfloat?tx?GLfloat?ty?GLfloat?tz);
/////////////////////////////////鼠標左鍵/////////////////////////////////////
//鼠標按下時的坐標
int?x0?y00;
//鼠標停下時的坐標
int?x1?y11;
//鼠標是否按下
bool?LeftButtonIsDown?=?false;
/////////////////////////////////鼠標右鍵/////////////////////////////////////
//鼠標按下時的坐標
int?x2?y2;
//鼠標停下時的坐標
int?x3?y3;
//鼠標是否按下
bool?RightButtonIsDown?=?false;
//位移增量
float?tx?=?0;
float?ty?=?0;
float?tz?=?0;
//旋轉增量
float?rx?=?0;
float?ry?=?0;
float?rz?=?0;
//縮放增量
float?zoom?=?1.0;
//?將立方體的八個頂點保存到一個數組里面?原始數據
static?float?vertex_list[8][3]?=
{
-20.0f?-20.0f?-20.0f
20.0f?-20.0f?-20.0f
-20.0f?20.0f?-20.0f
20.0f20.0f?-20.0f
-20.0f?-20.0f20.0f
20.0f?-20.0f?20.0f
-20.0f?20.0f?20.0f
20.0f20.0f?20.0f
};
//畫圖數據
static?float?vertex_draw[8][3]?=
{
-20.0f?-20.0f?-20.0f
20.0f?-20.0f?-20.0f
-20.0f?20.0f?-20.0f
20.0f20.0f?-20.0f
-20.0f?-20.0f20.0f
20.0f?-20.0f?20.0f
-20.0f?20.0f?20.0f
20.0f20.0f?20.0f
};
//?將要使用的頂點的序號保存到一個數組里面?
static?const?GLint?index_list[][2]?=
{
{?0?1?}
{?2?3?}
{?4?5?}
{?6?7?}
{?0?2?}
{?1?3?}
{?4?6?}
{?5?7?}
{?0?4?}
{?1?5?}
{?7?3?}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.?????65024??2018-05-27?12:18??opengl函數實現平移旋轉縮放\.vs\3Dpick\v15\.suo
?????文件???37130240??2018-05-27?12:18??opengl函數實現平移旋轉縮放\.vs\3Dpick\v15\Browse.VC.db
?????文件????3604480??2018-05-24?11:09??opengl函數實現平移旋轉縮放\.vs\3Dpick\v15\ipch\1b7c1f9d8ba0e544.ipch
?????文件????3604480??2018-05-24?17:03??opengl函數實現平移旋轉縮放\.vs\3Dpick\v15\ipch\1cd6e519e9c42d5.ipch
?????文件????3604480??2018-05-25?14:34??opengl函數實現平移旋轉縮放\.vs\3Dpick\v15\ipch\2e87b34bc5a06ea4.ipch
?????文件????3604480??2018-05-27?12:00??opengl函數實現平移旋轉縮放\.vs\3Dpick\v15\ipch\4594dd35148ef33e.ipch
?????文件????3604480??2018-05-22?22:09??opengl函數實現平移旋轉縮放\.vs\3Dpick\v15\ipch\6d9f927b4f3e75c5.ipch
?????文件????3604480??2018-05-23?17:17??opengl函數實現平移旋轉縮放\.vs\3Dpick\v15\ipch\834d186b7889040c.ipch
?????文件???????9658??2018-05-24?12:40??opengl函數實現平移旋轉縮放\3Dpick\3Dpick.vcxproj
?????文件???????1584??2018-05-24?12:40??opengl函數實現平移旋轉縮放\3Dpick\3Dpick.vcxproj.filters
?????文件????????165??2018-05-20?11:12??opengl函數實現平移旋轉縮放\3Dpick\3Dpick.vcxproj.user
?????文件???????1020??2018-05-27?11:11??opengl函數實現平移旋轉縮放\3Dpick\Debug\3Dpick.log
?????文件???????2721??2018-05-23?17:31??opengl函數實現平移旋轉縮放\3Dpick\Debug\3Dpick.obj
?????文件????2883584??2018-05-25?14:35??opengl函數實現平移旋轉縮放\3Dpick\Debug\3Dpick.pch
?????文件????????218??2018-05-27?11:11??opengl函數實現平移旋轉縮放\3Dpick\Debug\3Dpick.tlog\3Dpick.lastbuildstate
?????文件??????23852??2018-05-27?11:11??opengl函數實現平移旋轉縮放\3Dpick\Debug\3Dpick.tlog\CL.command.1.tlog
?????文件?????114398??2018-05-27?11:11??opengl函數實現平移旋轉縮放\3Dpick\Debug\3Dpick.tlog\CL.read.1.tlog
?????文件???????5826??2018-05-27?11:11??opengl函數實現平移旋轉縮放\3Dpick\Debug\3Dpick.tlog\CL.write.1.tlog
?????文件??????11830??2018-05-27?11:11??opengl函數實現平移旋轉縮放\3Dpick\Debug\3Dpick.tlog\li
?????文件??????15628??2018-05-27?11:11??opengl函數實現平移旋轉縮放\3Dpick\Debug\3Dpick.tlog\li
?????文件???????1530??2018-05-27?11:11??opengl函數實現平移旋轉縮放\3Dpick\Debug\3Dpick.tlog\li
?????文件??????59959??2018-05-27?11:11??opengl函數實現平移旋轉縮放\3Dpick\Debug\main.obj
?????文件??????65682??2018-05-23?19:47??opengl函數實現平移旋轉縮放\3Dpick\Debug\main.obj.enc
?????文件??????74471??2018-05-25?14:35??opengl函數實現平移旋轉縮放\3Dpick\Debug\math3d.obj
?????文件??????74021??2018-05-21?12:37??opengl函數實現平移旋轉縮放\3Dpick\Debug\math3d.obj.enc
?????文件?????159389??2018-05-24?12:28??opengl函數實現平移旋轉縮放\3Dpick\Debug\Selection.obj
?????文件?????158982??2018-05-22?22:50??opengl函數實現平移旋轉縮放\3Dpick\Debug\selection.obj.enc
?????文件???????5988??2018-05-25?14:35??opengl函數實現平移旋轉縮放\3Dpick\Debug\stdafx.obj
?????文件?????535552??2018-05-27?11:11??opengl函數實現平移旋轉縮放\3Dpick\Debug\vc141.idb
?????文件?????577536??2018-05-27?11:11??opengl函數實現平移旋轉縮放\3Dpick\Debug\vc141.pdb
............此處省略82個文件信息
- 上一篇:減速器課程設計說明書及 箱體與零件全套cad圖紙
- 下一篇:SSH個人博客系統
評論
共有 條評論