Skip to content

Instantly share code, notes, and snippets.

@TAK-EMI
Last active December 12, 2015 01:38
Show Gist options
  • Save TAK-EMI/4692615 to your computer and use it in GitHub Desktop.
Save TAK-EMI/4692615 to your computer and use it in GitHub Desktop.
ShapeViewerのカメラをマウスで動かしたい!そんなあなたに。 fk_ShapeViewerのprivateメンバをprotectedメンバに変更する必要あり。 まだ作りかけ。 メタセコのようなロクロ操作をするには縦の回転をどうすりゃいいんじゃろね。
#ifndef __TAK_SHAPEVIEWER_H__
#define __TAK_SHAPEVIEWER_H__
#include <FK/FK.h>
class TAK_ShapeViewer : public fk_ShapeViewer
{
public:
TAK_ShapeViewer(int w = 300, int h = 300);
virtual ~TAK_ShapeViewer(void);
bool draw(void);
};
TAK_ShapeViewer::TAK_ShapeViewer(int w, int h) :
fk_ShapeViewer(w, h)
{
return;
}
TAK_ShapeViewer::~TAK_ShapeViewer(void)
{
return;
}
void TAK_ShapeViewer::init(void)
{
return;
}
bool TAK_ShapeViewer::draw(void)
{
bool result = fk_ShapeViewer::draw();
if(!result)
return false;
fk_Window *win = this->viewWin;
if(win->getMouseStatus(FK_MOUSE3))
{
int mX, mY;
this->moveFlag = true;
double oldX = this->mouseX;
double oldY = this->mouseY;
this->viewWin->getMousePosition(&mX, &mY);
double tX, tY;
tX = mX - oldX;
tY = mY - oldY;
if(tX > 0)
this->setHead(this->getHead() - 0.1);
else if(tX < 0)
this->setHead(this->getHead() + 0.1);
this->mouseX = mX;
this->mouseY = mY;
}
int delta = win->getMouseWheelStatus();
if(delta > 0)
this->setScale(this->getScale() * 1.5);
else if(delta < 0)
this->setScale(this->getScale() / 1.5);
return result;
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment