Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Loading Normals from obj file  (Read 436 times)
0 Members and 2 Guests are viewing this topic.
Offline PinHead

JGO n00b
*

Posts: 6



« on: 2011-11-18 08:04:08 »

Hi,
  I'm having a few issues loading th normals into jogl okay I' ve wrote my model loader and have iterated over the vertices which are loading in just fine and resembling a Cube, now I'm trying to load the normals Ive iterating over the information and have tried to load them  I do get some visual faces but in a bit of a mess rather than the shape of a cube any help would be most appreciated.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
                gl.glVertexPointer( 3, GL2.GL_FLOAT, 0,  fBuffer );
     
      gl.glNormalPointer( GL2.GL_FLOAT, 0, nBuffer );
     
      gl.glEnableClientState( GL2.GL_VERTEX_ARRAY );  
      gl.glEnableClientState( GL2.GL_NORMAL_ARRAY );  
     
      gl.glDrawArrays( GL2.GL_POINTS, 0, fVertex.length / 3 );
           
      gl.glDrawArrays( GL2.GL_POLYGON, 0, nNormals.length / 3 );
     
      gl.glDisableClientState( GL2.GL_VERTEX_ARRAY );
      gl.glDisableClientState( GL2.GL_NORMAL_ARRAY );

These are the the normal which I think are vn in the obj file ?
Normal Iterate Array: 0.000000
Normal Iterate Array: -1.000000
Normal Iterate Array: 0.000000
Normal Iterate Array: 0.000000
Normal Iterate Array: 1.000000
Normal Iterate Array: 0.000000
Normal Iterate Array: 1.000000
Normal Iterate Array: 0.000000
Normal Iterate Array: 0.000000
Normal Iterate Array: -0.000000
Normal Iterate Array: -0.000000
Normal Iterate Array: 1.000000
Normal Iterate Array: -1.000000
Normal Iterate Array: -0.000000
Normal Iterate Array: -0.000000
Normal Iterate Array: 0.000000
Normal Iterate Array: 0.000000
Normal Iterate Array: -1.000000

and these are the vertices which I think are v in the obj file?
Iterate Array: 1.000000
Iterate Array: -1.000000
Iterate Array: -1.000000
Iterate Array: 1.000000
Iterate Array: -1.000000
Iterate Array: 1.000000
Iterate Array: -1.000000
Iterate Array: -1.000000
Iterate Array: 1.000000
Iterate Array: -1.000000
Iterate Array: -1.000000
Iterate Array: -1.000000
Iterate Array: 1.000000
Iterate Array: 1.000000
Iterate Array: -0.999999
Iterate Array: 0.999999
Iterate Array: 1.000000
Iterate Array: 1.000001
Iterate Array: -1.000000
Iterate Array: 1.000000
Iterate Array: 1.000000
Iterate Array: -1.000000
Iterate Array: 1.000000
Iterate Array: -1.000000
Offline lhkbob

JGO Neuromancer
****

Posts: 1174
Medals: 35



« Reply #1 on: 2011-11-18 10:57:38 »

You shouldn't have the 2nd glDrawArrays call, you don't draw the normals a second time, OpenGL automatically uses them if you've configured everything correctly, which it looks like you have.

Also, OBJ files usually have faces that describe how to combine the normals and vertices, are you taking that into account when reading the model?

Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.095 seconds with 20 queries.