91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

用OpenTK做的OpenGL拾取。代碼注釋中包含了拾取的原理及過程。用的是C#語言。

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.Drawing;
using?System.Windows.Forms;
using?OpenTK;
using?OpenTK.Graphics;
using?OpenTK.Graphics.OpenGL;
using?OpenTK.Platform;
using?OpenTK.Input;


///更多內(nèi)容
///?http://download.csdn.net/user/llimite
///關(guān)注我吧
namespace?Picking
{
????class?Pick:?GameWindow?
????{
????????//判斷鼠標(biāo)是否按下
????????private?bool?isRButtonDown;
????????private?bool?isLButtonDown;
????????//選擇緩存
????????private?int[]?selectBuf=new?int[1024];
????????//鼠標(biāo)位置
????????private?Point?mousepos;
????????//點(diǎn)擊的數(shù)量,與拾取視口相交的物體的數(shù)量
????????private?int?intersetion;
????????//視口
????????private?int[]?view=new?int[4];

????????//創(chuàng)建一個(gè)800*600的窗口,32位真彩色,8位深度,8位模板緩存,8倍多重采樣
????????//多重采樣需要顯卡支持
????????public?Pick():base(800600new?GraphicsMode(32888)“OpenTK?Picking“GameWindowFlags.FixedWindow)
????????{
????????????//添加兩個(gè)事件處理
????????????MouseDown?+=?Pick_MouseDown;
????????????MouseUp?+=?Pick_MouseUp;
????????}

????????//鼠標(biāo)按鍵釋放
????????void?Pick_MouseUp(object?sender?OpenTK.Input.MouseButtonEventArgs?e)
????????{
????????????if?(e.Mouse.IsButtonUp(MouseButton.Left))
????????????{
????????????????isLButtonDown?=?false;
????????????}
????????????if?(e.Mouse.IsButtonUp(MouseButton.Right))
????????????{
????????????????isRButtonDown?=?false;
????????????}
????????????mousepos?=?e.Position;
????????}

????????//鼠標(biāo)按鍵按下
????????void?Pick_MouseDown(object?sender?OpenTK.Input.MouseButtonEventArgs?e)
????????{
????????????if(e.Mouse.IsButtonDown(MouseButton.Left))
????????????{
????????????????isLButtonDown=true;
????????????}
????????????if?(e.Mouse.IsButtonDown(MouseButton.Right))
????????????{
????????????????isRButtonDown?=?true;
????????????}
????????????mousepos?=?e.Position;
????????}


????????protected?override?void?onload(EventArgs?e)
????????{
????????????base.onload(e);
????????????GL.ClearColor(0.5f?0.5f?0.5f?1.0f);
????????}

????????//改變窗口時(shí),更新視口
????????protected?override?void?onresize(EventArgs?e)
????????{
????????????base.onresize(e);
????????????GL.Viewport(0?0?Width?Height);
????????????GL.MatrixMode(MatrixMode.Projection);
????????????GL.LoadIdentity();
????????}

????????protected?override?void?OnUpdateframe(frameEventArgs?e)
????????{
????????????base.OnUpdateframe(e);
????????}
????????
????????//重寫繪圖函數(shù)
????????protected?override?void?OnRenderframe(frameEventArgs?e)
????????{
????????????base.OnRenderframe(e);
????????????GL.Clear(ClearBufferMask.ColorBufferBit|ClearBufferMask.DepthBufferBit?);
????????????GL.ClearColor(0.5f?0.5f?0.5f?1.0f);
????????????//啟用混合
????????????GL.Enable(EnableCap.Blend);
????????????GL.BlendFunc(BlendingFactorSrc.SrcAlpha?BlendingFactorDest.OneMinusSrcAlpha);
????????????//啟用深度測試
????????????GL.Enable(EnableCap.DepthTest);

????????????GL.MatrixMode(MatrixMode.Projection);
????????????GL.LoadIdentity();
????????????//相當(dāng)于gluPerspective
????????????Matrix4?perspective??=?Matrix4

評論

共有 條評論

相關(guān)資源