Results 1 to 12 of 12

Thread: DIRECTX8 : D3DVERTEX - nx, ny, nz?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    118

    DIRECTX8 : D3DVERTEX - nx, ny, nz?

    Here is some DirectX code. The values x y and z are your bog standard 3d coordinates. The values tu and tv determine the part of the bitmap that is drawn but what do nx, ny and nz mean?

    Please some1 help me!

    Function MakeVertex(x As Single, y As Single, z As Single, nx As Single, ny As Single, nz As Single, tu As Single, tv As Single) As D3DVERTEX

    With MakeVertex
    .x = x
    .y = y
    .z = z
    .nx = nx
    .ny = ny
    .nz = nz
    .tu = tu
    .tv = tv
    End With
    End Function

    Thanks in advance Dan

    PS Please could you make any explanations as simple as possible and give examples as well please. Thankyou .

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    118
    mmmmmm

    I have just found out nx, ny and nz mean normal x, normal y and normal z and that they have something to do with direction can anyone enlarge on my understanding please?

  3. #3
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Normals are used for lighting. A face normal is the direction a face is pointing. Imagine a triangle laying flat on the ground. Its normal would be (0, 1, 0), where the y axis is up. Simple. Now, a vertex normal is the average of all the normals of all of the faces that share that vertex. Simple enough. A normal should also have a magnitude(length) of 1. The process of taking a vector of arbitrary magnitude and make it a magnitude of 1, while pointing in the same direction is called "Normalization".

    Z.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    118
    Now Im getting somewhere. Thanks Z. Wen u say a triangle laying flat on the ground do u mean a 2d traingle or a 3d traingle.

    I am imagining a 2d traingle like so :


    1
    /\
    / \
    / \
    0 ------- 0

    Is it (0,1,0) because the centre point is higher?

    How would u use this for lighting? I have some source code from Simon Price (a guy who gives out code on this site), I have played with his code but playing with the nx,ny and nz coordinaes seems to make no difference at all. Could u perhaps give me a way so that these cooridantes actually make changes to what is shwing on the screen or maybe point me to some source code?

    Thanks very much

    Dan

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    118
    mmmmm the triangle messed up wen i posted it it is meant t look like this (ignore the 's)

    '''''''' /\ 1
    ''''''' / '\
    '''''' / ' ' \
    ''''0 ------ 0

    well u get the idea

  6. #6
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    I meant a 3D triangle. Each triangle makes a single face, and the normal is the direction that that face is facing. Try this. Take a pencil and stick it between your middle and ring fingers, so that it sticks straight out from your hand. That is your hand's face normal. Whichever way you rotate your hand, the normal is always the direction the palm of your hand is facing.

    The way this works for lighting is that light can also be a vector between the vertex and the light source. You can find the angle between these vectors, and use that angle to determine how much light from the light source hits that vertex, and thus, what color it should be.

    Z.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    118
    Cheers Z

    I think Im understandingthis now. Imagine a 3d triangle. It has 4 four sides. 3 sides use the normal (1,0,0) (X FACES UP) whereas the side flat on the floor (using your example earlier) has a normal (0,0,0). Correct?

    Maybe I am going into too much depth but how does this work for squares?

    Also i would love to see some DX8 code that uses normal values for this purpose do u know of any such code?

    Sorry for being thick but I am just getting into this stuff, Ill get there in the end, hey i can use 2 UV coords I cant be too bad .

    I guess wiv this stuff getting it is hard but wen u have got it it so simple its unreal.

    Thanks again

    Dan

  8. #8
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Im not explaining this very well =). Let me draw a diagram =).

    Take a look at this. It should explain it =).



    Z.
    Attached Images Attached Images  

  9. #9
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Here is a diagram of how vertex normals work with adjoining faces.



    Z.
    Attached Images Attached Images  

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    118
    Z

    lol now i got it, like they say a pic says 1000 words .

    so does a 3d triangle (or any 3d shape) have 1 normal face only?

    I have a few more questions but I think they are too indepth. If i can get the general idea for now it will at least quench some thirst for knoweldge .

    Thanks for all your explanations Z and for your time it has been grealty appreciated.

    Dan

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    118
    Z

    lol ignore that last post i hadnt seen the second pic

    Thanks

    Dan

  12. #12
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    And third in this diagram series =). This is how normals are used in lighting.



    And post any questions you have =). Its what Im here for =).

    Z.
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width