A
A
Arseniy Khusainov2021-08-29 16:47:33
pygame
Arseniy Khusainov, 2021-08-29 16:47:33

How can this bug be solved?

I am making a 3d engine, everything seems to be drawn normally, but at a certain angle or position, such a bug appears - 612b8f2950a80154261432.pnghere is a piece of code for rotations and increments from 3d to 2d -

x,y,z=p

#OBJECT ROTATION
x,z=rotate2d((x,z),(math.sin(model.rot[1]),math.cos(model.rot[1])))
y,z=rotate2d((y,z),(math.sin(model.rot[0]),math.cos(model.rot[0])))
x,y=rotate2d((x,y),(math.sin(model.rot[2]),math.cos(model.rot[2])))

#CAMERA POS
x-=camera.pos[0]-model.x
y+=camera.pos[1]-model.y
z-=camera.pos[2]-model.z
                
#CAMERA ROTATION    
x,z=rotate2d((x,z),camera.rotY)
y,z=rotate2d((y,z),camera.rotX)
x,y=rotate2d((x,y),camera.rotZ)

verts.append((x,y,z))
    
f=fov/z if z else fov; x=x*f; y=y*f

if z>0 and x>0 and x<w and y>0 and y<h: on_screen=True
pns.append((x,y))

Can this be fixed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question