Answer the question
In order to leave comments, you need to log in
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 - here 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))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question