1
Support / How to rotate and move 3D object in world space by 2D mouse coordinaes?
« on: June 29, 2011, 10:11:03 am »
Hallo!
I want to solve the following problems:
1) How to rotateY() 3D object in world space by 2D mouse coordinates? // 3D object must follow mouse movements
2) How to move 3D object in world space by 2D mouse cooridnates? // 3D object must move in world by mouse click
//Solution 1
SimpleVector mouse3D = Interract2D.reproject2D3DWS(camera, xMouse, yMose).normalize();
float angel = mouse3D.calcAngel(my3Dobject);
my3Dobject.clerRotation();
my3Dobject.rotaYAxis(new SimpleVector(0,1,0), angel);
//Solution 2
SimpleVector mouse3D = Interract2D.reproject2D3DWS(camera, xMouse, yMose).normalize();
Simple direction = mouse3D.calcSub(my3Dobject.getTranslation()); // get direction of 3Dobject
my3Dobject.translate(direction.x+1, 0, direction.z+1);
Maybe similar topics already exist? (please can send the links)
Sorry for my english.
Thanks!
[attachment deleted by admin]
I want to solve the following problems:
1) How to rotateY() 3D object in world space by 2D mouse coordinates? // 3D object must follow mouse movements
2) How to move 3D object in world space by 2D mouse cooridnates? // 3D object must move in world by mouse click
//Solution 1
SimpleVector mouse3D = Interract2D.reproject2D3DWS(camera, xMouse, yMose).normalize();
float angel = mouse3D.calcAngel(my3Dobject);
my3Dobject.clerRotation();
my3Dobject.rotaYAxis(new SimpleVector(0,1,0), angel);
//Solution 2
SimpleVector mouse3D = Interract2D.reproject2D3DWS(camera, xMouse, yMose).normalize();
Simple direction = mouse3D.calcSub(my3Dobject.getTranslation()); // get direction of 3Dobject
my3Dobject.translate(direction.x+1, 0, direction.z+1);
Maybe similar topics already exist? (please can send the links)
Sorry for my english.
Thanks!
[attachment deleted by admin]