Ok, so I am just trying to teach myself OpenGL ES, and have a couple of roadblocks. They seem so simple, yet so difficult at the same time. One of which has to do with Normals.
I have a GLfloat array of vertices created from an OBJ file. In order for the lighting to work, I need normals.
How can I calculate normals based on the array of GLfloats?
Ok, so I am just trying to teach myself OpenGL ES, and have a couple of roadblocks. They seem so simple, yet so difficult at the same time. One of which has to do with Normals.
I have a GLfloat array of vertices created from an OBJ file. In order for the lighting to work, I need normals.
How can I calculate normals based on the array of GLfloats?
Thanks.
You can't.
You can only calculate normals for triangles which means you will have to know which of these floats are connected together to form triangles ( normally you would get that from indices)
Once you have your triangle data you can just simple look it up on the net.
Gahh this doesn't make sense. I exported (from Blender) an OBJ file. I then used a Perl script to create an array of vertices from this OBJ file. How can I calculate the triangles / normals from this vertex array / original OBJ file?
NOTE: I feel like I might be doing something wrong with the actual export into OBJ or the conversion because it appears that the perl script is able to make a normals array.
I've included all of the files, of the random shape that I created and called a 'flamethrower'.
Hey, calculating normals on the iphone would be a waste time, the normals are already pre-calculated and sitting in the .obj file you exported. The only thing I am confused about is.. Why are you using the perl script to further parse the data? What is your setup right now, do you export from blender and then use the perl script to put the data into a format you can understand? Anyways, I read through the perl script and basically it prints the vertex data, then the normal data and then the texture coords. So you should already have all the data you need. Let me know what your setup is so I can help more with this.
Thats what I thought about the normals, but in the header file I don't see any sort of normal array, only indications that one should be there. Am I exporting it incorrectly into OBJ from Blender?
Thats what I thought about the normals, but in the header file I don't see any sort of normal array, only indications that one should be there. Am I exporting it incorrectly into OBJ from Blender?
You should be exporting your models as indexed arrays suitable for using glDrawElements.
I am not familiar with Blender so I don't really know what Header/OpenGL exporting does but here is a script which is iPhone specific: