cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

How to Retrieve View Matrix or Camera Position Using Creo Toolkit?

CS_11420818
4-Participant

How to Retrieve View Matrix or Camera Position Using Creo Toolkit?

I’m working on a project where I need to retrieve the view matrix or camera position from Creo using the API. Can anyone guide me on how to do this?
Specifically, I’m looking to:

1. Access the view matrix of a specific view.
2. Obtain the camera (or eye) position for a given view.

If you have any code examples, API functions, or documentation links that could help, I’d greatly appreciate it!
Thank you.

 

Creo 4.0 M150

Toolkit C++

3 REPLIES 3

Also it seems that GetCurrentViewTransform->GetMatrix() seems to give transformation from solid to screen coordinates which indicates that it might also be applying projection matrix to it as well. I Only need the view matrix or camera properties such as eye position, fov etc.

Hi, 


Below are the .NET API methods to get matrix from model & drawing views.

 

_____Get Matrix from model View____

public double[] GetMatrix(IpfcView modelView)
{
double[] viewMatrix = new double[9];

//Get View Tranformation

IpfcTransform3D ipfcTransform3D = modelView.Transform;

//Get Matrix from Transformation

CpfcMatrix3D matrix3D1 = ipfcTransform3D.Matrix;

//Normalize the matrix

IpfcMatrix3D matrix3D = Utility.NormalizeMatrix(matrix3D1);

viewMatrix[0] = matrix3D[0, 0];
viewMatrix[1] = matrix3D[0, 1];
viewMatrix[2] = matrix3D[0, 2];
viewMatrix[3] = matrix3D[1, 0];
viewMatrix[4] = matrix3D[1, 1];
viewMatrix[5] = matrix3D[1, 2];
viewMatrix[6] = matrix3D[2, 0];
viewMatrix[7] = matrix3D[2, 1];
viewMatrix[8] = matrix3D[2, 2];

return viewMatrix;
}


_____Get Matrix from drawing View____

public double[] GetMatrix(IpfcView2D inputView2D)
{
double[] viewMatrix = new double[9];

//Get View Tranformation
IpfcTransform3D ipfcTransform3D = inputView2D.GetTransform();

//Get Matrix from Transformation
CpfcMatrix3D matrix3D1 = ipfcTransform3D.Matrix;

//Normalize the matrix
IpfcMatrix3D matrix3D = Utility.NormalizeMatrix(matrix3D1);

viewMatrix[0] = matrix3D[0, 0];
viewMatrix[1] = matrix3D[0, 1];
viewMatrix[2] = matrix3D[0, 2];
viewMatrix[3] = matrix3D[1, 0];
viewMatrix[4] = matrix3D[1, 1];
viewMatrix[5] = matrix3D[1, 2];
viewMatrix[6] = matrix3D[2, 0];
viewMatrix[7] = matrix3D[2, 1];
viewMatrix[8] = matrix3D[2, 2];

return viewMatrix;
}

 

Procedure is similar for .NET API or Toolkit C++.  Get Matrix from Transformation will always return a 4x4 transformation matrix that include rotation, translation, scaling, and perspective projection.

You won't get values in screen coordinates, the thing you must do is Normalize the matrix.
In the above codes, I am returning only 3x3 matrix for a specific purpose after normalizing the matrix.

Thanks,

Gopinadh Gvs.

x

Im sorry but this didnt work for my purpose.

 

Is there any way we can get the camera properties like its position, look at, fov etc. so that I could generate my own view matrix?

Announcements


Top Tags