Page 1 of 4 1234 LastLast
Results 1 to 10 of 34

Thread: Normal question (well, kinda weird actualy)

  1. #1
    Member Contributor
    Join Date
    May 2003
    Posts
    50

    Normal question (well, kinda weird actualy)

    I wrote a program that can load and render .obj files with textures, but the .obj file does not have normals data, is there a way to calculate normals?

    how can i draw an .obj with lighting?

    thanks!

  2. #2
    Member Contributor
    Join Date
    Jul 2003
    Location
    Rhode Island
    Posts
    55

    Re: Normal question (well, kinda weird actualy)

    The normals is an equation to calculate it for each verticy, i don't know it. I use DirectX calls to calculate all my normals for me.

  3. #3
    Member Contributor
    Join Date
    May 2003
    Posts
    50

    Re: Normal question (well, kinda weird actualy)

    im trying to stick with opengl, is there a way to calculate normals in opengl?

  4. #4
    Member Newbie
    Join Date
    Aug 2003
    Location
    asda
    Posts
    47

    Re: Normal question (well, kinda weird actualy)

    See appendix E from the red book, also recommended to zix99 so he does not have to depend on some helper functions.
    If you really do not want to make the effort is low level libraries like OpenGL and Direct3D not what you want.

    You probably need to calculate the cross product. Here is two libraries with that function and others. http://plib.sourceforge.net/sg/ http://www-2.cs.cmu.edu/~ajw/doc/svl.html

    Once you have the normals can you use the standard OpenGL lights.
    asd

  5. #5
    Senior Member Regular Contributor
    Join Date
    Apr 2003
    Location
    Toulouse, France
    Posts
    133

    Re: Normal question (well, kinda weird actualy)

    the normal of a vertex is the normalized sum of the normal of the triangles that share the vertex.

    for each triangle
    normal[triangle.vertex[0]] += triangle.normal
    normal[triangle.vertex[1]] += triangle.normal
    normal[triangle.vertex[2]] += triangle.normal
    end for

  6. #6
    Member Contributor
    Join Date
    Feb 2003
    Location
    Mitishy
    Posts
    59

    Re: Normal question (well, kinda weird actualy)

    it's strange that there is not normals in obj file! i using maya's exported obj models and they contain normals data!
    like this: vn 1 0 0

  7. #7
    Member Contributor
    Join Date
    Jul 2003
    Location
    Rhode Island
    Posts
    55

    Re: Normal question (well, kinda weird actualy)

    thanks some guy, i'll try not to use DX this time. Its a pain to use DX for just ONE call in my whole program.

  8. #8
    Member Contributor
    Join Date
    May 2003
    Posts
    50

    Re: Normal question (well, kinda weird actualy)

    simple math question, it says that the normal = [v1 - v2] [v2 - v3].

    How do you subtract 2 vectors? is it: (x1+y1+z1 - x2+y2+z2) or: (x1-x2 y1-y2 z1-z2)
    i think its (x1-x2 y1-y2 z1-z2) because its the only one resulting in a vector, but imnot sure... and also, how do you muliply?

  9. #9
    Guest

    Re: Normal question (well, kinda weird actualy)

    The cross product of 2 given vectors v1 and v2 is as follows:
    v1 x v2 = ( v1.x*v1.z - v1.z*v2.y , v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x )

    I think it would be better for you if you get a math book and take a look at vector math, so you can understand where this formula comes from.

  10. #10
    Member Newbie
    Join Date
    Aug 2003
    Location
    asda
    Posts
    47

    Re: Normal question (well, kinda weird actualy)

    Here is a description on how to calculate the cross product, its really very simple. http://www.lighthouse3d.com/opengl/m...3?crossproduct
    Note that the x means cross pruduct and not multiplication.

    If you need some reference material about matrices could perhaps the matrix FAQ be used. http://www.j3d.org/matrix_faq/
    asd

Page 1 of 4 1234 LastLast

Similar Threads

  1. Alpha to coverage: how does it actualy work?
    By Ed Daenar in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 11-06-2011, 06:19 PM
  2. Terrain Textures... Kinda
    By zix99 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-13-2003, 10:50 AM
  3. Rotation quirks, etc... need help kinda quick
    By Doublearon in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 10-02-2002, 06:32 AM
  4. Kinda difficult to rotate
    By in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 04-15-2002, 05:30 AM
  5. OT kinda.. Normal code
    By in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 02-08-2002, 06:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean