|
-
Aug 6th, 2002, 06:57 PM
#1
Thread Starter
Lively Member
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 .
-
Aug 6th, 2002, 07:24 PM
#2
Thread Starter
Lively Member
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?
-
Aug 6th, 2002, 07:44 PM
#3
Frenzied Member
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.
-
Aug 6th, 2002, 08:19 PM
#4
Thread Starter
Lively Member
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
-
Aug 6th, 2002, 08:21 PM
#5
Thread Starter
Lively Member
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
-
Aug 6th, 2002, 11:27 PM
#6
Frenzied Member
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.
-
Aug 7th, 2002, 12:01 AM
#7
Thread Starter
Lively Member
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
-
Aug 7th, 2002, 12:28 AM
#8
Frenzied Member
-
Aug 7th, 2002, 12:36 AM
#9
Frenzied Member
-
Aug 7th, 2002, 12:38 AM
#10
Thread Starter
Lively Member
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
-
Aug 7th, 2002, 12:40 AM
#11
Thread Starter
Lively Member
Z
lol ignore that last post i hadnt seen the second pic
Thanks 
Dan
-
Aug 7th, 2002, 12:44 AM
#12
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|