Don't know if it's a bug or just me with some wrong code, so I made the thread here.
I use the function 'getScreenCoordinatesFrom3DPosition' to calculate the 2D screen coordinates of each corner of a bounding box. Here's an eplanation of what I'm doing in PSEUDO-code:
Code: Select all
V_3DVECTOR corner[8]; // Corners of the bounding box, trust me that they're in their.
irr::core::position2d<irr::s32> screen[8]; // 2D screen coordinates of the bounding box.
irr::core::aabbox3d<irr::f32> box = node->getTransformedBoundingBox(); // Used for corner calculation.
// Now I fill the 'screen' array variable (for explanation just the first element).
screen[0] = collision->getScreenCoordinatesFrom3DPosition(corner[0]);
As you can see, the X element of each corner is the same; that's not the problem. However, the same goes for the screen coordinates.Corner:
[0] {X=0.30330077 Y=19.511070 Z=5.3033009 }
[1] {X=0.30330077 Y=4.5110703 Z=5.3033009 }
[2] {X=0.30330077 Y=19.511070 Z=-15.909903 }
[3] {X=0.30330077 Y=4.5110703 Z=-15.909903 }
[4] {X=0.30330071 Y=19.511070 Z=5.3033009 }
[5] {X=0.30330071 Y=4.5110703 Z=5.3033009 }
[6] {X=0.30330071 Y=19.511070 Z=-15.909903 }
[7] {X=0.30330071 Y=4.5110703 Z=-15.909903 }
Screen:
[0] {X=402 Y=124 }
[1] {X=403 Y=368 }
[2] {X=402 Y=236 }
[3] {X=403 Y=253 }
[4] {X=403 Y=253 }
[5] {X=402 Y=236 }
[6] {X=403 Y=368 }
[7] {X=402 Y=124 }
That's kinda weird, how can all the corners of a cube (with each side of equal length) have the same X-coordinate? This happens when I start rotating the cube, in my case along the Y-axis. Sometimes the X screen coordinates are the same, and sometimes the Y.
Does anyone know what I'm doing wrong?