How to program 3D graphics from scratch. Without 3D engines. (In Python)
Why Stack Overflow recommends it
Stack Overflow users link it when people are building their own 3D camera or renderer in Python and want to understand the projection and rotation math without relying on OpenGL matrices.
Recommended by 1 people across 1 different months, 2016 to 2018.
What it is
A 15-minute Python tutorial that builds a 3D renderer from scratch using only pygame for 2D drawing, with no 3D engine or matrix library. It covers perspective projection, a movable camera with rotation, and face sorting for drawing cubes, and is presented by the channel DLC ENERGY.
What people said
Recommends Puddle · 2018-02 · Stack Overflow · on “LibGDX - Camera rotation”
you should watch this video "How to program 3D graphics from scratch. Without 3D engines. (In Python) " [this video] since it doesn't use matrices, it does these translations in reverse. moving the verts to you. then rotating left/right. then up/down. matrix math (like which is built into opengl) is just a little different. it's used since it's more efficient. but yeah, moving xyz, then rotY, rotX is the plain way to visualize it.
Cites Coolq B · 2016-08 · Stack Overflow · on “Python - 3D mapping, without 3D engines”
Does anyone know how to do this? I want to be able to map a texture to a 3d cube in Python. here's my code so far, from pygame import gfxdraw import pygame, sys, math def rotate2d(pos,rad): x,y=pos; s,c = math.sin(rad),math.cos(rad); return x*c-y*s,y*c+x*s class Cam: def __init__(self,pos=(0,0,0),rot=(0,0)): self.pos=list(pos) self.rot=list(rot) def events(self,event): if event.type == pygame.MOUSEMOTION: x,y = event.rel x/=200;y/=200 self.rot[0]+=y; self.rot[1]+=x def update(self,dt,key): s=dt*10 if key[pygame.K_q]: self.pos[1]+=s if key[pygame.K_e]: self.pos[1]-=s x,y = s*math.sin(self.rot[1]),s*math.cos(self.rot[1]) if key[pygame.K_w]: self.pos[0]+=x;self.pos[2]+=y if key[pygame.K_s]: sel
Cites Brandon · 2017-07 · Stack Overflow · on “Pygame key pressed not working”
I've been trying to follow this old youtube tutorial on how to create a game in Python using pygame. I've ran into a stump where I can't get the key pressed movements to work. Tutorial I've been following: [this video] I press w, a, s, d... but nothing happens to the screen import pygame import sys # import math class Cam: def __init__(self, pos=(0, 0, 0), rot=(0, 0)): self.pos = list(pos) self.rot = list(rot) def update(self, dt, key): s = dt * 10 if key[pygame.K_q]: self.pos[1] += s if key[pygame.K_e]: self.pos[1] -= s if key[pygame.K_w]: self.pos[2] += s if key[pygame.K_s]: self.pos[2] -= s if key[pygame.K_a]: self.pos[0] -= s if key[pygame.K_d]: self.pos[0] += s pygame.init() w, h = 400, 400;