Cool! This will definitely be useful for people to get started with 3D shapes in openFrameworks.
A couple of suggestions:
Make lights a class - this way people can create multiple lights. You could have a base light class that has a lot of features and then have some simple light classes that inherit from that that have some default settings. Or just have 1 light class but have some #defines for different settings. ie DIRECTION_LIGHT, SOFT_LIGHT etc
ofLightsOn(); might be better outside of the drawing commands - as people might want to draw shapes without lighting.
Another thing to look into if you are doing 3D is display lists - they are good to use for complex shapes that stay the same during your app or shapes that get used a lot.
You might want to check out josh nimoy’s objLoader addon in the soon to be released 005 which lets you load 3D obj files into openFrameworks.
nice thanks theo working on it. Question about shaders. Do you know of any lib for loading and using shaders. I would love to try and compile one in OF or just start building one from scratch.
Hey guys. This might be kind of a ridiculous question, but I’m trying to throw lighting into a program i’m working on and i just cant seem to figure it out.
I tried out putting in this of3d code and using it to turn lights on and off, and apply them to vertex shapes that I’m drawing, but it doesnt seem to work. here’s what my draw func looks like:
the lighting is applied to the teapot and cube properly, but the quad shape that I draw doesnt reflect light at all. I assume this is some kind of materials problem, but i dont know how to fix it
In order to light stuff in opengl you need to calculate the normals of the polygon faces you are drawing. The library function calls such as the teapot and square already do this for you, but if you make your own shapes you have to calculate the normals yourself.