Подпишитесь на наш Telegram-канал, чтобы всегда быть в курсе важных обновлений! Перейти

Дайте World To screen для апекса.

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
18 Май 2021
Сообщения
49
Реакции
0
Мне нужен world to screen для apex.

Пробовал это но не пашит:



struct view_matrix_t {
float* operator[ ](int index) {
return matrix[index];
}

float matrix[4][4];
};

struct Vector3
{
float x, y, z;
};

Vector3 WorldToScreen(const Vector3 pos, view_matrix_t matrix) {
float _x = matrix[0][0] * pos.x + matrix[0][1] * pos.y + matrix[0][2] * pos.z + matrix[0][3];
float _y = matrix[1][0] * pos.x + matrix[1][1] * pos.y + matrix[1][2] * pos.z + matrix[1][3];

float w = matrix[3][0] * pos.x + matrix[3][1] * pos.y + matrix[3][2] * pos.z + matrix[3][3];

float inv_w = 1.f / w;
_x *= inv_w;
_y *= inv_w;

float x = screenX * .5f;
float y = screenY * .5f;

x += 0.5f * _x * screenX + 0.5f;
y -= 0.5f * _y * screenY + 0.5f;

return { x,y,w };
}
 
C++:
Expand Collapse Copy
struct Vector3 WorldToScreen(struct Vector3 pos, Matrix matrix, int SWidth, int SHeight) {
    struct Vector3 out;

    float _x = matrix.matrix[0] * pos.x + matrix.matrix[1] * pos.y + matrix.matrix[2] * pos.z + matrix.matrix[3];
    float _y = matrix.matrix[4] * pos.x + matrix.matrix[5] * pos.y + matrix.matrix[6] * pos.z + matrix.matrix[7];

    out.z = matrix.matrix[12] * pos.x + matrix.matrix[13] * pos.y + matrix.matrix[14] * pos.z + matrix.matrix[15];

    _x *= 1.f / out.z;
    _y *= 1.f / out.z;

    out.x = SWidth * .5f;
    out.y = SHeight * .5f;

    out.x += 0.5f * _x * SWidth + 0.5f;
    out.y -= 0.5f * _y * SHeight + 0.5f;

    return out;
};


C++:
Expand Collapse Copy
struct Matrix {
    float matrix[16];
};

C++:
Expand Collapse Copy
uintptr_t ViewMatrix = Read<uintptr_t>(base_address + Offsets::ViewMatrix);
Matrix Matrixx = Read<Matrix>(ViewMatrix+ Offsets::VeiwRender);//обязательно ViewRender
//используешь Matrixx в качестве матрицы))
 
C++:
Expand Collapse Copy
struct Vector3 WorldToScreen(struct Vector3 pos, Matrix matrix, int SWidth, int SHeight) {
    struct Vector3 out;

    float _x = matrix.matrix[0] * pos.x + matrix.matrix[1] * pos.y + matrix.matrix[2] * pos.z + matrix.matrix[3];
    float _y = matrix.matrix[4] * pos.x + matrix.matrix[5] * pos.y + matrix.matrix[6] * pos.z + matrix.matrix[7];

    out.z = matrix.matrix[12] * pos.x + matrix.matrix[13] * pos.y + matrix.matrix[14] * pos.z + matrix.matrix[15];

    _x *= 1.f / out.z;
    _y *= 1.f / out.z;

    out.x = SWidth * .5f;
    out.y = SHeight * .5f;

    out.x += 0.5f * _x * SWidth + 0.5f;
    out.y -= 0.5f * _y * SHeight + 0.5f;

    return out;
};


C++:
Expand Collapse Copy
struct Matrix {
    float matrix[16];
};

C++:
Expand Collapse Copy
uintptr_t ViewMatrix = Read<uintptr_t>(base_address + Offsets::ViewMatrix);
Matrix Matrixx = Read<Matrix>(ViewMatrix+ Offsets::VeiwRender);//обязательно ViewRender
//используешь Matrixx в качестве матрицы))
норм..
 
C++:
Expand Collapse Copy
struct Vector3 WorldToScreen(struct Vector3 pos, Matrix matrix, int SWidth, int SHeight) {
    struct Vector3 out;

    float _x = matrix.matrix[0] * pos.x + matrix.matrix[1] * pos.y + matrix.matrix[2] * pos.z + matrix.matrix[3];
    float _y = matrix.matrix[4] * pos.x + matrix.matrix[5] * pos.y + matrix.matrix[6] * pos.z + matrix.matrix[7];

    out.z = matrix.matrix[12] * pos.x + matrix.matrix[13] * pos.y + matrix.matrix[14] * pos.z + matrix.matrix[15];

    _x *= 1.f / out.z;
    _y *= 1.f / out.z;

    out.x = SWidth * .5f;
    out.y = SHeight * .5f;

    out.x += 0.5f * _x * SWidth + 0.5f;
    out.y -= 0.5f * _y * SHeight + 0.5f;

    return out;
};


C++:
Expand Collapse Copy
struct Matrix {
    float matrix[16];
};

C++:
Expand Collapse Copy
uintptr_t ViewMatrix = Read<uintptr_t>(base_address + Offsets::ViewMatrix);
Matrix Matrixx = Read<Matrix>(ViewMatrix+ Offsets::VeiwRender);//обязательно ViewRender
//используешь Matrixx в качестве матрицы))
а нахуя ты массив матрицей назвал
 
Назад
Сверху Снизу