API: Control current view with 3D Mouse
Grrzzz
✭
in RobotStudio
Hi,
I am trying to control the current view with a 3D mouse. But atm I am missing some parameters from the camera.
Here are the things that I do know:
[code]
Station station = Project.ActiveProject as Station;
Vector3 lookAt = GraphicControl.ActiveGraphicControl.LookAt;
Vector3 lookFrom = GraphicControl.ActiveGraphicControl.LookFrom;
Camera myCam = new Camera();
station.Cameras.Add(myCam);
myCam.LookAt = lookAt; //change values here
myCam.LookFrom = lookFrom; //and here
GraphicControl.ActiveGraphicControl.SyncCamera(myCam, true, 0);
GraphicControl.ActiveGraphicControl.Camera = myCam;
[/code]
So, theroretically I can move around in space changing the lookAt and lookFrom vectors. But where do I get the current ROTATION of the camera from?
I need this, because I want the following: e.g.
- Push 3D mouse in x-direction
-> current view moves right / left (which is not neccesarily x direction in world coordinates)
Which means: Depending on the current orientation of the camera I have to do a matrix transformation. How can I do this?
I hope you understand my problem.
I am trying to control the current view with a 3D mouse. But atm I am missing some parameters from the camera.
Here are the things that I do know:
[code]
Station station = Project.ActiveProject as Station;
Vector3 lookAt = GraphicControl.ActiveGraphicControl.LookAt;
Vector3 lookFrom = GraphicControl.ActiveGraphicControl.LookFrom;
Camera myCam = new Camera();
station.Cameras.Add(myCam);
myCam.LookAt = lookAt; //change values here
myCam.LookFrom = lookFrom; //and here
GraphicControl.ActiveGraphicControl.SyncCamera(myCam, true, 0);
GraphicControl.ActiveGraphicControl.Camera = myCam;
[/code]
So, theroretically I can move around in space changing the lookAt and lookFrom vectors. But where do I get the current ROTATION of the camera from?
I need this, because I want the following: e.g.
- Push 3D mouse in x-direction
-> current view moves right / left (which is not neccesarily x direction in world coordinates)
Which means: Depending on the current orientation of the camera I have to do a matrix transformation. How can I do this?
I hope you understand my problem.
0
Comments
-
Since the "up" direction of the camera is locked (to the positive z direction), the rotation of the camera is actually well specified by the LookAt and LookFrom properties.
This code calculates the directions (in world coordinates) that represent right (x) and up (y) on the screen:
[code]
Vector3 lookVec = lookAt - lookFrom;
lookVec.Normalize();
Vector3 xVec = lookVec.Cross(new Vector3(0,0,1));
Vector3 yVec = xVec.Cross(lookVec);
[/code]
So to pan the camera right, for example, you would translate lookAt and lookFrom in the xVec direction.
Also, what kind of 3D mouse are you using? RS already supports 3Dconnexion devices.
regards,
Johannes
Johannes Weiman2007-12-13 8:42:46Johannes Weiman
Software Engineer
ABB Robotics0 -
Thank you for the code. This is exactly what I was looking for.
And yes, the 3D mouse already worked with the ABB driver, but I want to enhance the functionality of it, e.g. adding the possibility of moving the TCP with the mouse.
0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 786 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings