Coppel.Damien Posted June 3, 2020 Share Posted June 3, 2020 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
morbid Posted June 4, 2020 Share Posted June 4, 2020 Hello Damien, The approach you've described is fine and probably the best way to do this. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Coppel.Damien Posted June 9, 2020 Author Share Posted June 9, 2020 (edited) 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 June 9, 2020 by Coppel.Damien previously printed column as row Link to comment
morbid Posted June 10, 2020 Share Posted June 10, 2020 Hi Damien, Mat4 is a 3 x 4 matrix, it stores 12 doubles and has no projection. So it's not a bug. Thanks. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts