資源簡介
讀取芭蕉樹的obj模型文件并顯示,包括紋理、光照
另一棵樹的效果更好,可是文件大小超出上傳限制了,所以只能上傳這棵點、面數小的小樹了
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Text;
using?System.Windows.Forms;
using?System.Drawing;
using?CsGL.OpenGL;
using?CsGL.Util;
namespace?OpenGL_1
{
????public?class?csglViewer?:?OpenGLControl
????{
????????drawMan?man?=?new?drawMan();
????????drawLegs?Legs?=?new?drawLegs();
????????private?loadObjFile?lOF?=?new?loadObjFile();?//保存繪圖數據
????????//定義交互性變量,用于視口的鼠標控制
????????public?float?m_xTranslation=0.0f?m_yTranslation=-0.0f?m_zTranslation=-0.0f;?????//
????????public?float?m_xRotation=0.0f?m_yRotation=0.0f?m_zRotation=0.0f;??????????????//定義旋轉量
????????public?float?m_xScaling=1.0f?m_yScaling=1.0f?m_zScaling=1.0f;?????????????????//定義放縮量
????????public?float?m_speedTranslation=1.0f/30.0f;????????????????????????????????//定義移動速度
????????public?float?m_speedRotation?=?0.1f;
????????private?uint?drawMethod=GL.GL_LINE;??????????????//定義繪圖方式
????????private?bool?lightUse=false;????????????????????????????//定義是否使用光照
????????//定義鼠標動作記錄
????????bool?lMouseButtonDown;
????????bool?rMouseButtonDown;
????????Point?lButtonDownPos;
????????Point?rButtonDownPos;
????????
????????public?csglViewer()//:?base()
????????{
????????????System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls?=?false;
????????????this.KeyDown?+=?new?KeyEventHandler(OurView_onkeydown);
????????????this.MouseDown?+=?new?MouseEventHandler(OurView_onmousedown);//鼠標按下響應事件
????????????this.MouseUp+=new?MouseEventHandler(OurView_onmouseup);//鼠標抬起響應事件
????????????this.MouseMove+=new?MouseEventHandler(OurView_onmousemove);//鼠標移動響應事件
????????????this.MouseWheel+=new?MouseEventHandler(OurView_onmousewheel);//鼠標滾輪事件
????????}
????????public?void?setObjFile(loadObjFile?l)??//將從主窗口處獲取的數據保存,用于繪圖
????????{
????????????lOF?=?l;
????????????Invalidate();
????????????Update();
????????}
????????public?void?fitParameter()????????????????//配置繪圖參數,適合模型在窗口中顯示
????????{
????????????m_xTranslation?=?-(lOF.xMaxAxes?+?lOF.xMinAxes)?/?2;
????????????m_yTranslation?=?-(lOF.yMaxAxes?+?lOF.yMinAxes)?/?2;
????????????float?maxDis;
????????????maxDis?=?lOF.xMinAxes?-?lOF.xMaxAxes;
????????????maxDis?=?(maxDis?>?(lOF.yMinAxes?-?lOF.yMaxAxes))???(lOF.yMinAxes?-?lOF.yMaxAxes)?:?maxDis;
????????????maxDis?=?(maxDis?>?(lOF.zMinAxes?-?lOF.zMaxAxes))???(lOF.zMinAxes?-?lOF.zMaxAxes)?:?maxDis;
????????????m_zTranslation?=?maxDis;
????????}
????????public?override?void?glDraw()?????//重載繪圖
????????{
????????????GL.glClear(GL.GL_COLOR_BUFFER_BIT?|?GL.GL_DEPTH_BUFFER_BIT);?//?Clear?The?Screen?And?The?Depth?Buffer?
????????????GL.glLoadIdentity();?//?Reset?The?Current?Modelview?Matrix?
????????????//?TODO:?Draw?a?box?or?something
????????????//?this.SwapBuffer();?//?swap?Buffers
????????????GL.glTranslatef(m_xTranslation?m_yTranslation?m_zTranslation);
????????????GL.glRotatef(m_xRotation?1.0f?0.0f?0.0f);
????????????GL.glRotatef(m_yRotation?0.0f?1.0f?0.0f);
????????????GL.glScaled(m_xScaling?m_yScali
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????8947??2009-03-24?14:53??單棵芭蕉樹\Backup\OpenGL_1\csglViewer.cs
?????文件???????1315??2009-03-24?14:03??單棵芭蕉樹\Backup\OpenGL_1\drawLegs.cs
?????文件???????5004??2009-03-19?13:22??單棵芭蕉樹\Backup\OpenGL_1\drawMan.cs
?????文件???????3321??2009-03-24?20:54??單棵芭蕉樹\Backup\OpenGL_1\Form1.cs
?????文件???????6538??2009-03-24?20:48??單棵芭蕉樹\Backup\OpenGL_1\Form1.Designer.cs
?????文件???????6017??2009-03-24?14:54??單棵芭蕉樹\Backup\OpenGL_1\Form1.resx
?????文件???????4168??2009-03-24?14:26??單棵芭蕉樹\Backup\OpenGL_1\loadObjFile.cs
?????文件???????3604??2009-03-21?11:46??單棵芭蕉樹\Backup\OpenGL_1\OpenGL_1.csproj
?????文件????????471??2009-03-18?21:07??單棵芭蕉樹\Backup\OpenGL_1\Program.cs
?????文件???????1170??2009-03-18?20:13??單棵芭蕉樹\Backup\OpenGL_1\Properties\AssemblyInfo.cs
?????文件???????2872??2009-03-18?20:13??單棵芭蕉樹\Backup\OpenGL_1\Properties\Resources.Designer.cs
?????文件???????5612??2009-03-18?20:13??單棵芭蕉樹\Backup\OpenGL_1\Properties\Resources.resx
?????文件???????1093??2009-03-18?20:13??單棵芭蕉樹\Backup\OpenGL_1\Properties\Settings.Designer.cs
?????文件????????249??2009-03-18?20:13??單棵芭蕉樹\Backup\OpenGL_1\Properties\Settings.settings
?????文件????????913??2009-03-18?20:13??單棵芭蕉樹\Backup\OpenGL_1.sln
?????文件??????18432??2009-03-24?20:54??單棵芭蕉樹\Backup\OpenGL_1.suo
?????文件???????8947??2009-03-24?14:53??單棵芭蕉樹\OpenGL_1\Backup\OpenGL_1\csglViewer.cs
?????文件???????1315??2009-03-24?14:03??單棵芭蕉樹\OpenGL_1\Backup\OpenGL_1\drawLegs.cs
?????文件???????5004??2009-03-19?13:22??單棵芭蕉樹\OpenGL_1\Backup\OpenGL_1\drawMan.cs
?????文件???????3321??2009-03-24?20:54??單棵芭蕉樹\OpenGL_1\Backup\OpenGL_1\Form1.cs
?????文件???????6538??2009-03-24?20:48??單棵芭蕉樹\OpenGL_1\Backup\OpenGL_1\Form1.Designer.cs
?????文件???????6017??2009-03-24?14:54??單棵芭蕉樹\OpenGL_1\Backup\OpenGL_1\Form1.resx
?????文件???????4168??2009-03-24?14:26??單棵芭蕉樹\OpenGL_1\Backup\OpenGL_1\loadObjFile.cs
?????文件???????3604??2009-03-21?11:46??單棵芭蕉樹\OpenGL_1\Backup\OpenGL_1\OpenGL_1.csproj
?????文件????????471??2009-03-18?21:07??單棵芭蕉樹\OpenGL_1\Backup\OpenGL_1\Program.cs
?????文件???????1170??2009-03-18?20:13??單棵芭蕉樹\OpenGL_1\Backup\OpenGL_1\Properties\AssemblyInfo.cs
?????文件???????2872??2009-03-18?20:13??單棵芭蕉樹\OpenGL_1\Backup\OpenGL_1\Properties\Resources.Designer.cs
?????文件???????5612??2009-03-18?20:13??單棵芭蕉樹\OpenGL_1\Backup\OpenGL_1\Properties\Resources.resx
?????文件???????1093??2009-03-18?20:13??單棵芭蕉樹\OpenGL_1\Backup\OpenGL_1\Properties\Settings.Designer.cs
?????文件????????249??2009-03-18?20:13??單棵芭蕉樹\OpenGL_1\Backup\OpenGL_1\Properties\Settings.settings
............此處省略154個文件信息
- 上一篇:啊哈,算法,啊哈算法完整版,有趣的算法書
- 下一篇:ffmpeg for Linux
評論
共有 條評論