 # 3D ESP source code PUBG

Administrator

#### DREDD

##### Administrator
Administrator
A simple box helps to estimate the enemy's distance. This option learn you box size change, understand how the 3d method works.

Create a function, initialize the size of a standing player and being in a vehicle

Code:
``````public void Draw3DBox(FMinimalViewInfo POV, AActor actor)
{
float l, w, h, o;
l = 60f; w = 60f; h = 160f; o = 50f; //box size for standing player

float zOffset = -100f;

if (actor.Type == ActorTypes.Vehicle) //vehicles have a bigger box
{
zOffset = 50;
l = 200f; w = 160f; h = 80f; o = 0f;
}``````

Build box

Code:
``````Vector3 p00 = new Vector3(o, -w / 2,0f);
Vector3 p01 = new Vector3(o, w / 2, 0f);
Vector3 p02 = new Vector3(o - l, w / 2, 0f);
Vector3 p03 = new Vector3(o - l, -w / 2, 0f);``````

Set the rotation

Code:
``````float theta1 = 2.0f * (float)Math.PI * (actor****tation.Y) / 180.0f;
Matrix rotM = Matrix****tationZ((float)(theta1 / 2)); // rotate around Z-axis``````

Set curPos

Code:
``````Vector3 curPos = new Vector3(actor.Location.X, actor.Location.Y, actor.Location.Z + zOffset);
p00 = Vector3.TransformCoordinate(p00, rotM) + curPos;
p01 = Vector3.TransformCoordinate(p01, rotM) + curPos;
p02 = Vector3.TransformCoordinate(p02, rotM) + curPos;
p03 = Vector3.TransformCoordinate(p03, rotM) + curPos;``````

We initialize the last and do the display

Code:
`````` RawVector2 s00 = W2S(p00, POV);
RawVector2 s01 = W2S(p01, POV);
RawVector2 s02 = W2S(p02, POV);
RawVector2 s03 = W2S(p03, POV);
RawVector2[] square0 = { s00, s01, s02, s03, s00 };

DrawLines(square0);

// top rectangle
p00.Z += h; s00 = W2S(p00, POV);
p01.Z += h; s01 = W2S(p01, POV);
p02.Z += h; s02 = W2S(p02, POV);
p03.Z += h; s03 = W2S(p03, POV);

RawVector2[] square1 = { s00, s01, s02, s03, s00 };
DrawLines(square1);

// upper/lower rectangles get connected
DrawLine(new RawVector2(square0.X, square0.Y), new RawVector2(square1.X, square1.Y));
DrawLine(new RawVector2(square0.X, square0.Y), new RawVector2(square1.X, square1.Y));
DrawLine(new RawVector2(square0.X, square0.Y), new RawVector2(square1.X, square1.Y));
DrawLine(new RawVector2(square0.X, square0.Y), new RawVector2(square1.X, square1.Y));
}``````

Full Code:

Code:
``````public void Draw3DBox(FMinimalViewInfo POV, AActor actor)
{
float l, w, h, o;
l = 60f; w = 60f; h = 160f; o = 50f; //box size for standing player

float zOffset = -100f;

if (actor.Type == ActorTypes.Vehicle) //vehicles have a bigger box
{
zOffset = 50;
l = 200f; w = 160f; h = 80f; o = 0f;
}

//build box
Vector3 p00 = new Vector3(o, -w / 2,0f);
Vector3 p01 = new Vector3(o, w / 2, 0f);
Vector3 p02 = new Vector3(o - l, w / 2, 0f);
Vector3 p03 = new Vector3(o - l, -w / 2, 0f);

//rotate rectangle to match actor rotation
float theta1 = 2.0f * (float)Math.PI * (actor****tation.Y) / 180.0f;
Matrix rotM = Matrix****tationZ((float)(theta1 / 2)); // rotate around Z-axis

Vector3 curPos = new Vector3(actor.Location.X, actor.Location.Y, actor.Location.Z + zOffset);
p00 = Vector3.TransformCoordinate(p00, rotM) + curPos;
p01 = Vector3.TransformCoordinate(p01, rotM) + curPos;
p02 = Vector3.TransformCoordinate(p02, rotM) + curPos;
p03 = Vector3.TransformCoordinate(p03, rotM) + curPos;

RawVector2 s00 = W2S(p00, POV);
RawVector2 s01 = W2S(p01, POV);
RawVector2 s02 = W2S(p02, POV);
RawVector2 s03 = W2S(p03, POV);
RawVector2[] square0 = { s00, s01, s02, s03, s00 };

DrawLines(square0);

// top rectangle
p00.Z += h; s00 = W2S(p00, POV);
p01.Z += h; s01 = W2S(p01, POV);
p02.Z += h; s02 = W2S(p02, POV);
p03.Z += h; s03 = W2S(p03, POV);

RawVector2[] square1 = { s00, s01, s02, s03, s00 };
DrawLines(square1);

// upper/lower rectangles get connected
DrawLine(new RawVector2(square0.X, square0.Y), new RawVector2(square1.X, square1.Y));
DrawLine(new RawVector2(square0.X, square0.Y), new RawVector2(square1.X, square1.Y));
DrawLine(new RawVector2(square0.X, square0.Y), new RawVector2(square1.X, square1.Y));
DrawLine(new RawVector2(square0.X, square0.Y), new RawVector2(square1.X, square1.Y));
}``````