Originally Posted by
Sychotix
Perhaps it is a rounding error for pixel location?
That was actually one of the first things I explored. Unfortunately I don't think that is the reason.
When I'm standing still things seem to be okay, including me rendering names above moving entities. As soon as I move however, everything goes jittery.
Some more info I hope helps:
- When I move and then stop, values are still updating for a little bit after I have stopped. (This is for static positions) But the changes are so insignificant it cant change position on the screen.
- I switched to different rendering engines and still seeing the issue. (which makes me believe I'm doing something wrong with memory reading/w2screen/loops)
EDIT: Here is a code sample
Code:
class Vector2(ctypes.Structure):
_fields_ = [
('x', ctypes.c_float),
('y', ctypes.c_float)
]
class Vector3(ctypes.Structure):
_fields_ = [
('x', ctypes.c_float),
('y', ctypes.c_float),
('z', ctypes.c_float)
]
class Matrix4x4(ctypes.Structure):
_fields_ = [
('matrix', (ctypes.c_float * 4) * 4)
]
def world_to_screen(world: Vector3, screen_size: Vector2, matrix: Matrix4x4) -> Vector2:
matrix = matrix.matrix # todo: avoid weird struct
x = world.x * matrix[0][0] + world.y * matrix[1][0] + world.z * matrix[2][0] + matrix[3][0]
y = world.x * matrix[0][1] + world.y * matrix[1][1] + world.z * matrix[2][1] + matrix[3][1]
w = world.x * matrix[0][3] + world.y * matrix[1][3] + world.z * matrix[2][3] + matrix[3][3]
return Vector2((1.0 + x / w) * screen_size.x / 2, (1.0 - y / w) * screen_size.y / 2)
# ...
buffer = read_bytes(render_component.address + 0x90, ctypes.sizeof(Vector3))
position = Vector3.from_buffer(bytearray(buffer))
screen_position = world_to_screen(position, screen_size, matrix)
draw_rect(screen_position.x - 10, screen_position.y - 10, 20, 20)