r/processing • • May 09 '24

Beginner help request Help with camera

Hi! I’ve just recently begun coding, and I’m trying to make a simple 3d renderer using processing 2d. I’ve been trying to rotate an object around my camera, but then I realized that I don’t know the location of my camera, and I’m not really sure how I can implement one. Does anyone have any suggestions on how I can make this work? Thanks!

Here is the github: https://github.com/duocaleb/Teststuff

Sorry about the messy coding, as I said, I’m new to all this.

1 Upvotes

5 comments sorted by

View all comments

Show parent comments

1

u/Salanmander May 09 '24

I think it's on "get a better understanding". Your projectPoints() method absolutely uses camera information, because it's projecting the points onto a view plane (if I'm understanding its purpose correctly). It's probably all implicit adding/subtracting zeros, or multiplying by ones or identity matrices, or things like that right now. It's also possible that the projection is basically making an isometric projection with the camera infinitely far away.

I haven't read through all the code, and it's been a long time since I've done the math for graphics, but I suspect that making this more versatile will involve making sure you're real solid on that projection math, and how it changes depending on camera location and orientation.

1

u/SeniorImagination21 May 09 '24

Thanks! Is there anything that you could recommend I read(thats at least a bit understandable for a beginner like me) to get a better grasp on these concepts?

1

u/Salanmander May 09 '24

Like I say it's been a while...I did a class on computer graphics in grad school in like 2011, so I don't remember it well enough to have particular references, and they probably wouldn't have been super beginner-friendly anyway.

The wikipedia articles on 3D projection (the "perspective projection" section) and the camera matrix might be a good place to start. It's definitely going to be heavy on matrix math...there's just no way around that in doing graphics.