現在地メニュー >> NVIDIA_SDK >> NVIDIA_SDK_02

マウス処理(マニピュレータ)


「nvGlutManipulators.h」を使うと、マウスによるトラックボール処理などが簡単にできる。

使い方

  1. 動作設定
  2. マウスコールバック関数で、メンバ関数を呼ぶ。
  3. 描画時にメンバ関数を呼ぶ


【例】
#include <nvGlutManipulators.h>
... ...
nv::GlutExamine manipulator; //マウス操作用マニピュレータ

... ...
//------- 動作設定 ---------//
	manipulator.setTrackballScale(2.0);//トラックボール(回転処理の速度)
	manipulator.setDollyActivate( GLUT_LEFT_BUTTON, GLUT_ACTIVE_CTRL);//左ドラッグ+ctl → dolly移動処理
	manipulator.setPanActivate( GLUT_LEFT_BUTTON, GLUT_ACTIVE_SHIFT);//左ドラッグ+Shfit → pan移動処理
... ...

void reshape(int w, int h)
{
	... ...
	manipulator.reshape(w, h);//ここでも呼ぶ必要がある
}
... ...
void myMouseFunc(int button,int state,int x,int y)
{
	manipulator.mouse(button, state, x, y);
}

void myMouseMotion(int x,int y)
{
	manipulator.motion(x, y);
}

... ...

void display()
{
	... ...
	manipulator.applyTransform();//移動を適用する(回転、平行、拡大縮小など)
	... 描画 ...
	glutSwapBuffers();
}

※マウス関連のコールバック関数内に、
ボタン判定処理などを書かなくて済むのは、便利かもしれない。

サンプルコード

目次

― その他 ―

Wiki内検索

計測中...(07.10.8〜)

Save The World






▲よろしければ広告のクリックもお願いします


▲ランキングに参加しました

管理人/副管理人のみ編集できます