ESP Drawing

Posts 18 of 8 · Page 1 of 1
ESP Drawing
I've been working on this external ESP for MW3 (Written in C#) for some time and I've got a problem.

While my player is standing the ESP draws correctly and it's all good, but when I crouch the ESP gets drawn lower in stead of keeping the same position.

Say I look directly at a player in front of me and we are both standing. In that case the ESP draws like it should, but if i crouch or go prone the whole ESP get drawn "lower" proportionally to the height at where the player camera is.

When I compare my source code to the source of other ESP's there is practically no difference as far as I can see.

What could be the issue?
While standing, does it draw correctly when you are above/below the other players? Like if you climb up a ladder, and look forward at the horizon, do all the boxes still draw correctly? The only error is while crouched/prone?
Quote Originally Posted by abuckau907 View Post
While standing, does it draw correctly when you are above/below the other players? Like if you climb up a ladder, and look forward at the horizon, do all the boxes still draw correctly? The only error is while crouched/prone?
Yes, as long as I am standing it draws correctly. Doesn't matter if I'm above or below the horizon. The problem only occurs when I'm crouched/prone.

If I draw the player name at head height and I crouch the text will appear at waist level instead of remaining at head height like it should. And if I prone it gets drawn even lower.
idk mw3, but maybe you know: does the game store 2 variables, 1 for player position (x,y,z) and one for "camera offset", about, 5 ft above player pos?
so when you crouch/lay, it's actually decresing "camera offset", not player pos?

In you code, somehow it's using camer position and/or player position to calculate the location of the boxes. Show some of this code?

1 way to fix it is something like..

If (LocalPlayer->IsCrouching)
cameraHeight = 2 ft;
else if (LocalPlayer->IsLaying)
cameraHeight = 6 in.;
else
cameraHeight = 60in.;

but I don't like that. Post the code related to camera / player height.
-----

I think you need to replace [LocalPlayer.WorldPos.Z + CameraHeightOffset] with [LocalPlayer.WorldPos.Z + LocalPlayer.Height] somewhere in the code that calculates the box x,y screen coords.

which will make it always use player.z + 60inches instead of player.z + camera.heightOffset

maybe (?)
I have sort of figured out where the problem lies.

In my WorldToScreen method:
Code:
public static bool WorldToScreen(Vector location, out Point<float> point)
{
    point = new Point<float>();

    Vector transform, local;

    local = location - MW3.viewmatrix.Origin;

    transform.x = local.DotProduct(MW3.refdef.ViewAxis2);
    transform.y = local.DotProduct(MW3.refdef.ViewAxis3);
    transform.z = local.DotProduct(MW3.refdef.ViewAxis1);

    if (transform.z < 0.1)
        return false;

    Point<float> screenCenter = new Point<float>();
    screenCenter.X = (float)(MW3.refdef.Width) / 2.0f;
    screenCenter.Y = (float)(MW3.refdef.Height) / 2.0f;

    point.X = screenCenter.X * (1.0f - (transform.x / MW3.refdef.FovX / transform.z));
    point.Y = screenCenter.Y * (1.0f - (transform.y / MW3.refdef.FovY / transform.z));

    return true;
}
If I use MW3.viewmatrix.Origin then it all gets drawn smoothly, but everything gets rendered incorrectly if I crouch or prone.
But if I use MW3.refdef.ViewOrigin it draws everything at the correct height even if I crouch or prone. There is one problem however.
It doesn't draw smoothly at all. When I draw something it bounces around while I'm moving instead of staying fixed at the players.

Code:
public static bool WorldToScreen(Vector location, out Point<float> point)
{
    point = new Point<float>();

    Vector transform, local;

    local = location - MW3.refdef.ViewOrigin;

    transform.x = local.DotProduct(MW3.refdef.ViewAxis2);
    transform.y = local.DotProduct(MW3.refdef.ViewAxis3);
    transform.z = local.DotProduct(MW3.refdef.ViewAxis1);

    if (transform.z < 0.1)
        return false;

    Point<float> screenCenter = new Point<float>();
    screenCenter.X = (float)(MW3.refdef.Width) / 2.0f;
    screenCenter.Y = (float)(MW3.refdef.Height) / 2.0f;

    point.X = screenCenter.X * (1.0f - (transform.x / MW3.refdef.FovX / transform.z));
    point.Y = screenCenter.Y * (1.0f - (transform.y / MW3.refdef.FovY / transform.z));

    return true;
}
How are you setting ViewMatrix.Origin ? I dislike 3d because it always depends on the coord system they used. but if it's really close, good.

Um..I'm not 100% sure, but if the first method works perfectly, and only fails when your height changes..I'd still go with that one.
How are you setting MW3.refdef.ViewOrigin? MemRead or constructing it yourself?


Code:
public static bool WorldToScreen(Vector location, out Point<float> point)
{
    point = new Point<float>();

    Vector transform, local;

    local = location - MW3.refdef.Origin;

    transform.x = local.DotProduct(MW3.refdef.ViewAxis2);
    transform.y = local.DotProduct(MW3.refdef.ViewAxis3);
    transform.z = local.DotProduct(MW3.refdef.ViewAxis1); // vertical

    if (transform.z < 0.1)
        return false;

    Point<float> screenCenter = new Point<float>();
    screenCenter.X = (float)(MW3.refdef.Width) / 2.0f;
    screenCenter.Y = (float)(MW3.refdef.Height) / 2.0f; // vertical

    point.X = screenCenter.X * (1.0f - (transform.x / MW3.refdef.FovX / transform.z));
    point.Y = screenCenter.Y * (1.0f - (transform.y / MW3.refdef.FovY / transform.z)); // vertical

    return true;
}
When you crouch, only the z component is off? The x,y/width are still correct for the boxes?

Apparently Origin = Your feet position, and OriginView = your head position. (?)

Hard to tell w/o more code. I'm not great at 3d math, maybe I'm not the person to help. Sounds like you're 99% there though.
I FOUND A SOLUTION THAT WORKS! The refdef ViewOrigin Vector is the one I should be using, but since it was behaving unstable I decided to use Cheat Engine to find a different place in memory where I could find the same vector. I found like 20 identical vectors in memory all static so I picked the one that updated most accurately and now my ESP works flawlessly.
or that makes sense too. Right on.

"I think you need to replace [LocalPlayer.WorldPos.Z + CameraHeightOffset] with [LocalPlayer.WorldPos.Z + LocalPlayer.Height]"
was actually [Origin] vs [ViewOrigin], same thing, de nada.
Posts 18 of 8 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?