 |
 |
|
 |
02-02-2010, 12:17 AM
|
#1 (permalink)
|
|
Registered Member
Join Date: Jan 2010
Posts: 214
|
OpenGL | ES Question
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.
|
|
|
02-02-2010, 12:29 AM
|
#2 (permalink)
|
|
Registered Member
Join Date: Nov 2008
Posts: 195
|
Quote:
Originally Posted by flamingliquid
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.
Calculate the normal of a triangle with three vertices - XNA Community Forums
|
|
|
02-02-2010, 12:38 AM
|
#3 (permalink)
|
|
Registered Member
Join Date: Jan 2010
Posts: 214
|
That helps, thanks!
|
|
|
02-02-2010, 08:04 PM
|
#4 (permalink)
|
|
Registered Member
Join Date: Jan 2010
Posts: 214
|
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'.
Im such a noob, haha
|
|
|
02-02-2010, 08:06 PM
|
#5 (permalink)
|
|
Registered Member
Join Date: Jan 2010
Posts: 214
|
|
|
|
02-02-2010, 09:02 PM
|
#6 (permalink)
|
|
Registered Member
Join Date: Jul 2009
Posts: 13
|
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.
|
|
|
02-02-2010, 10:42 PM
|
#7 (permalink)
|
|
Registered Member
Join Date: Jan 2010
Posts: 214
|
Export Blender > Perl Script (Creates header file) > import Header into OpenGL
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?
|
|
|
02-03-2010, 12:32 PM
|
#8 (permalink)
|
|
Registered Member
Join Date: Nov 2008
Posts: 195
|
Quote:
Originally Posted by flamingliquid
Export Blender > Perl Script (Creates header file) > import Header into OpenGL
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:
iPhone Development: Improved Blender Export
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 418 |
| 36 members and 382 guests |
| AdamSubach, aderrington, benoitr007, bensj, BrianSlick, Danneman, dev123, ErichGS, futurevilla216, GreatWizard, gustavo7sexton, gw1921, HemiMG, HowEver, iSDK, Jeremy1026, joelhull, lifeCoder45, mattiahalter, melodizzzy, mriphoneman, newchucky, Ovidius, Piequanna, pofak, qilin, Racker, rendezvouscp, riq, Sega dude, socals, timle8n1, Whitehk, ZunePod |
| Most users ever online was 965, 06-30-2010 at 04:26 AM. |
» Stats |
Members: 41,862
Threads: 49,770
Posts: 213,057
Top Poster: BrianSlick (3,139)
|
| Welcome to our newest member, futurevilla216 |
|