Fix perspective calculation in CCamera::GetScreenCoordinates.
Fixes #99. This was SVN commit r8870.
This commit is contained in:
parent
fd46b9e370
commit
63bd39d4a5
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user