1
1
forked from 0ad/0ad

Fix perspective calculation in CCamera::GetScreenCoordinates.

Fixes #99.

This was SVN commit r8870.
This commit is contained in:
Ykkrosh 2011-01-28 21:51:59 +00:00
parent fd46b9e370
commit 63bd39d4a5
2 changed files with 4 additions and 4 deletions

View File

@ -28,6 +28,7 @@
#include "graphics/Terrain.h"
#include "lib/ogl.h"
#include "maths/MathUtil.h"
#include "maths/Vector4D.h"
#include "ps/Game.h"
#include "ps/World.h"
#include "renderer/Renderer.h"
@ -192,10 +193,10 @@ void CCamera::GetScreenCoordinates(const CVector3D& world, float& x, float& y) c
m_Orientation.GetInverse(transform);
transform.Concatenate(m_ProjMat);
CVector3D screenspace = transform.Transform(world);
CVector4D screenspace = transform.Transform(CVector4D(world.X, world.Y, world.Z, 1.0f));
x = screenspace.X / screenspace.Z;
y = screenspace.Y / screenspace.Z;
x = screenspace.m_X / screenspace.m_W;
y = screenspace.m_Y / screenspace.m_W;
x = (x + 1) * 0.5f * g_Renderer.GetWidth();
y = (1 - y) * 0.5f * g_Renderer.GetHeight();
}

View File

@ -416,7 +416,6 @@ QUERYHANDLER(PickObject)
// Get screen coordinates of the point on the ground underneath the
// object's model-centre, so that callers know the offset to use when
// working out the screen coordinates to move the object to.
// (TODO: http://trac.wildfiregames.com/ticket/99)
CVector3D centre = target->GetModel().GetTransform().GetTranslation();