Learning C, Day 23 (Camera Clipping)

Today I spent an hour on preliminary setup for clipping planes. The idea here is to not render triangles outside the camera view and to clip triangles which extend outside the view. To do that, I need planes defining the bounds of the camera view and a way to check whether points are inside the camera view. I was trying to find a point and a normal to define a plane for each side of the view, but I wasn’t really sure how to approach it. So I hit it with the trig, but I was headed in the opposite direction:

Don’t quote me on this one: I have almost no idea what I’m doing.

It ended up being really simple:

That small triangle should connect to the large one, but I drew the first line wrong.

I have an idea for checking whether points are inside the camera view: I could subtract the point to compare from the plane’s point to get a vector pointing from the plane to the point (that’s a lot of points and pointing xD). Then to determine if it’s outside or not, take the dot product of the plane’s normal and the new vector. If it’s positive, it’s inside, otherwise it’s outside. I haven’t tried it yet, but maybe it will work. Anyway, I’ll see you tomorrow!

Leave a comment

Your email address will not be published. Required fields are marked *

Your data is processed in accordance with my privacy policy. Comments are manually approved and may take a while to appear.