- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey everyone!
I've been trying my best to get familiar with the Autodesk Inventor COM API for the purpose of integrating a new 3D input device (the Keyglove) for intuitive control. I have worked through the "My first plugin" example, and I have basic COM integration working using VB.NET in Visual Studio 2010. I've been able to rotate the camera's view around a single axis by applying a rotation matrix transform to the camera's UpVector property:
Dim Pi As Double = 3.14159265358979
Dim appInventor As Inventor.Application
Dim oCamera As Inventor.Camera
Dim oRotAxis As Inventor.Vector
Dim oRotMatrix As Inventor.Matrix
Dim oUpVector As Inventor.UnitVector
Try
appInventor = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
oCamera = appInventor.ActiveView.Camera
oRotMatrix = appInventor.TransientGeometry.CreateMatrix
Catch ex As Exception
appInventor = Nothing
MsgBox("Unable to locate running Autodesk Inventor instance: " & ex.Message)
End Try
If Not appInventor Is Nothing Then
' apply rotation around camera's Z axis
oUpVector = oCamera.UpVector
oRotAxis = appInventor.TransientGeometry.CreateVector(oCamera.Target.X - oCamera.Eye.X, oCamera.Target.Y - oCamera.Eye.Y, oCamera.Target.Z - oCamera.Eye.Z)
Call oRotMatrix.SetToRotation(Pi / 4, oRotAxis, oCamera.Eye)
Call oUpVector.TransformBy(oRotMatrix)
oCamera.UpVector = oUpVector
oCamera.ApplyWithoutTransition()
End If
...and I've been able to rotate around the other two axes by using the Camera.ComputeWIthMouseInput() method:
' apply rotation around camera's X and Y axes
oCamera.ComputeWithMouseInput(appInventor.TransientGeometry.CreatePoint2d(0, 0), appInventor.TransientGeometry.CreatePoint2d(5, 5), 0, Inventor.ViewOperationTypeEnum.kRotateViewOperation)
But I cannot for the life of me figure out how to achieve what I'm really after: a programmatic equivalent to the "Orbit" action that is done on all three rotational axes at once. I would ultimately like to reproduce all aspects of the Full Navigation Wheel through the COM API, but right now I'll settle for 3D orbiting. The pan and zoom operations seem to be doable through the ComputeWithMouseInput() method, though I'd imagine there's a better, more direct way to do that with raw camera eye/target transformation as well.
When using the Orbit tool on the Full Navigation Wheel, the mouse X/Y axes control orientation about the Y and X axes respectively, centered around the pivot point. If you hold down shift to enable "roll" mode, the mouse Y axis is ignored, and the mouse X axis controls orientation about the Z axis. The Keyglove provides angular rotation data on all three axes at once, so there is no need to toggle between X/Y control and Z control; it should be easily possible to do them all at the same time. I can't figure out how though.
Has anyone done this kind of thing before, or can you provide any pointers? I feel like I'm really close, but lacking in familiarity with the COM API and/or the ability to visualize and code the correct spatial geometry calculations.
Solved! Go to Solution.