Jump to content

Node 2D coordinate in image


photo

Recommended Posts

Hello everyone,

I am using Unigine to generate images. These images contain specific objects nodes (3D models imported). Each rendered image is screenshoted and saved to a file.

I would like to know the coordinates of these nodes in the images I save. Ideally I would like to have the coordinates of a bounding box around the object in the image.

From what I understood the Node class contains a method "getSpatialBoundBox" that returns a 3D bounding box around the object in world coordinates. I thought that I could use this 3D bounding box to deduce a 2D bounding box in the image.

Is there a simpler/better way to do it ? 

Link to comment

Thanks,

I think it would be very useful to add a function for this purpose (like in Unity for example where we can call "screenPos = cam.WorldToScreenPoint(targetWorldPosition)")

I came accross a bug while trying to rewrite this function. It seems like the Mat4 type is bugged (used by getIModelview for instance). The last row is always set to (0,0,0,1) and an exception is raised when trying to access last row and last column as if it was a 3x3 matrix.

A simple test would be

mat4 normalmat4 = mat4(2.);
Mat4 convertedMat4 = (Mat4) mat4(2.);
Mat4 normalMat4 = Mat4(2.);

std::cout << "normalmat4 = \n" <<  normalmat4 << '\n';
std::cout << "convertedMat4 = \n" <<  convertedMat4 << '\n';
std::cout << "normalMat4 = \n" <<  normalMat4 << '\n';

 

which returns (I wrote basics << operators that are exactly the same for mat4 and Mat4)

normalmat4 =
[    2    2    2    2    ]
[    2    2    2    2    ]
[    2    2    2    2    ]
[    2    2    2    2    ]
convertedMat4 =
[    2    2    2    2    ]
[    2    2    2    2    ]
[    2    2    2    2    ]
[    0    0    0    1    ]
normalMat4 =
[    2    2    2    2    ]
[    2    2    2    2    ]
[    2    2    2    2    ]
[    0    0    0    1    ]


 
Edited by Coppel.Damien
previously printed column as row
Link to comment
×
×
  • Create New...