~ fix image positioning when the camera center was not 0, 0, 0

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2021-06-16 18:38:37 +02:00
parent 4a1f91d548
commit 89f956e796

View File

@ -46,14 +46,16 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
); );
} }
irr::core::vector3df cameraCenter = this->getScene ()->getCamera ()->getCenter ();
// take the orthogonal projection into account // take the orthogonal projection into account
irr::f32 scene_width = this->getScene ()->getScene ()->getOrthogonalProjection ()->getWidth (); irr::f32 scene_width = this->getScene ()->getScene ()->getOrthogonalProjection ()->getWidth ();
irr::f32 scene_height = this->getScene ()->getScene ()->getOrthogonalProjection ()->getHeight (); irr::f32 scene_height = this->getScene ()->getScene ()->getOrthogonalProjection ()->getHeight ();
irr::f32 xright = -scene_width / 2.0f + this->m_image->getOrigin ().X + xsize * xscale / 2.0f; irr::f32 xright = (-scene_width / 2.0f + this->m_image->getOrigin ().X + xsize * xscale / 2.0f) + cameraCenter.X;
irr::f32 xleft = -scene_width / 2.0f + this->m_image->getOrigin ().X - xsize * xscale / 2.0f; irr::f32 xleft = (-scene_width / 2.0f + this->m_image->getOrigin ().X - xsize * xscale / 2.0f) + cameraCenter.X;
irr::f32 ytop = -scene_height / 2.0f + this->m_image->getOrigin ().Y + ysize * yscale / 2.0f; irr::f32 ytop = (-scene_height / 2.0f + this->m_image->getOrigin ().Y + ysize * yscale / 2.0f) + cameraCenter.Y;
irr::f32 ybottom = -scene_height / 2.0f + this->m_image->getOrigin ().Y - ysize * yscale / 2.0f; irr::f32 ybottom = (-scene_height / 2.0f + this->m_image->getOrigin ().Y - ysize * yscale / 2.0f) + cameraCenter.Y;
irr::f32 z = this->m_image->getOrigin ().Z; irr::f32 z = this->m_image->getOrigin ().Z;
// top left // top left
@ -65,10 +67,10 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
// bottom left // bottom left
this->m_vertex [3].Pos = irr::core::vector3df (xleft, ybottom, z); this->m_vertex [3].Pos = irr::core::vector3df (xleft, ybottom, z);
this->m_vertex [0].TCoords = irr::core::vector2df (0.0f, 0.0f); this->m_vertex [0].TCoords = irr::core::vector2df (1.0f, 0.0f);
this->m_vertex [1].TCoords = irr::core::vector2df (1.0f, 0.0f); this->m_vertex [1].TCoords = irr::core::vector2df (0.0f, 0.0f);
this->m_vertex [2].TCoords = irr::core::vector2df (1.0f, 1.0f); this->m_vertex [2].TCoords = irr::core::vector2df (0.0f, 1.0f);
this->m_vertex [3].TCoords = irr::core::vector2df (0.0f, 1.0f); this->m_vertex [3].TCoords = irr::core::vector2df (1.0f, 1.0f);
this->m_vertex [0].Color = irr::video::SColor (255, 255, 255, 255); this->m_vertex [0].Color = irr::video::SColor (255, 255, 255, 255);
this->m_vertex [1].Color = irr::video::SColor (255, 255, 255, 255); this->m_vertex [1].Color = irr::video::SColor (255, 255, 255, 255);