# SolvedC# Assault Cube World To Screen Help

Status
Not open for further replies.

#### zix3r

Full Member
Game Name
Assault Cube
Anticheat
N/A
How long you been coding/hacking?
Recently started getting into game hacking.
Coding Language
C#
Hey guys.
I'm currently trying to make an esp hack for assault cube.
I have the view matrix and enemy player coordinates.
I also have a W2S function, but I don't really know how to use it:
C#:
``````using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpCube.ac
{
class worldtoscreen
{
public static float[] WorldToScreen(byte[] matrix, PlayerEntity entity, int width, int height, POINTS gameWindow, bool foot = true)
{

float m11 = BitConverter.ToSingle(matrix, 0), m12 = BitConverter.ToSingle(matrix, 4), m13 = BitConverter.ToSingle(matrix, 8), m14 = BitConverter.ToSingle(matrix, 12);
float m21 = BitConverter.ToSingle(matrix, 16), m22 = BitConverter.ToSingle(matrix, 20), m23 = BitConverter.ToSingle(matrix, 24), m24 = BitConverter.ToSingle(matrix, 28);
float m31 = BitConverter.ToSingle(matrix, 32), m32 = BitConverter.ToSingle(matrix, 36), m33 = BitConverter.ToSingle(matrix, 40), m34 = BitConverter.ToSingle(matrix, 44);
float m41 = BitConverter.ToSingle(matrix, 48), m42 = BitConverter.ToSingle(matrix, 52), m43 = BitConverter.ToSingle(matrix, 56), m44 = BitConverter.ToSingle(matrix, 60);

float zPos = entity.getZPos(foot);

//multiply vector against matrix
float screenX = (m11 * entity.xPos) + (m21 * entity.yPos) + (m31 * zPos) + m41;
float screenY = (m12 * entity.xPos) + (m22 * entity.yPos) + (m32 * zPos) + m42;
float screenW = (m14 * entity.xPos) + (m24 * entity.yPos) + (m34 * zPos) + m44;

//camera position (eye level/middle of screen)
float camX = width / 2f;
float camY = height / 2f;

//convert to homogeneous position
float x = camX + (camX * screenX / screenW);
float y = camY - (camY * screenY / screenW);
float[] screenPos = { x, y };

//check it is in the bounds to draw
if (screenW > 0.001f  //not behind us
&& gameWindow.Left + x > gameWindow.Left && gameWindow.Left + x < gameWindow.Right //not off the left or right of the window
&& gameWindow.Top + y > gameWindow.Top && gameWindow.Top + y < gameWindow.Bottom) //not off the top of bottom of the window
{
return screenPos;
}
return null;
}
}
}``````
I also dont really know what the PlayerEntity stands for, I mean I know, but how do I define it?

Same for POINTS near the gameWindow.

If anyone could point me out on how to use it I'd really appreciated it.

#### Rake

Guide - GHB0 - Game Hacking Bible Introduction
Guide - How to get started with learning ViewMatrix
Source Code - World2Screen - DIrect3D and OpenGL WorldToScreen Functions

Using a World To Screen function is a the 48th tutorial in the GHB because you need the experience from 47 other tutorials before you can use one successfully without pasting. So do your homework.

Entity is a struct that contains the information you read from memory, most importantly the player's position.

POINTS is a struct which contains the size of the game window, includes these member variables: left, top, right bottom

#### zix3r

Full Member
Thanks, I'll check that out.

Status
Not open for further replies.
Attention! Before you post:

99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

• Fill out the form correctly
• Tell us the game name & coding language