| View previous topic :: View next topic |
| Author |
Message |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Wed Jan 11, 2006 12:38 am Post subject: normals... how to pass to sceGuDrawArray |
|
|
i found a thread here which tells me that i have to add normals to my model information.. actually thats not the problem...
the main problem is...
if you have 1 vertex which is used by eg. four faces
you do not only have one nv (x,y,z)
further you have 4...
as its used in the samples:
| Code: | struct Vertex
{
float nx,ny,nz;
float x,y,z;
}; |
you can only pass one normal vector, and you do not even know which face depends to it...
how can i come along this prob?
greets
lumo
PS: i read that lightning does not work without normal vectors... _________________ "Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com |
|
| Back to top |
|
 |
sandberg
Joined: 05 Oct 2005 Posts: 90 Location: Denmark
|
Posted: Wed Jan 11, 2006 2:57 am Post subject: |
|
|
You shouldn't use indexed vertices, i.e. specify all the vertices in your object and pass that to sceGuDrawArray and pass NULL as the index pointer. But this is ofcause slower than merging all the vertices shared on all you faces. _________________ Br, Sandberg |
|
| Back to top |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Wed Jan 11, 2006 4:17 am Post subject: |
|
|
i do not exactly get what you mean;
i could create 3 vertex per face to get optimal normals and viewing results
(is it what you mean?)
for i could sum up the normals and normalize em -> data loss but faster
greets
lumo _________________ "Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com |
|
| Back to top |
|
 |
jsgf
Joined: 12 Jul 2005 Posts: 254
|
Posted: Wed Jan 11, 2006 4:57 am Post subject: |
|
|
Just because two vertices have the same x,y,z coords doesn't mean they're the same vertex. If the have other differing attributes, like normal, texcoord or colour, then they're different vertices. Just give each face its own vertex with the appropriate attributes.
Of course, if all the vertex attributes are really identical, you should share them, either with indexing, and/or by using strips/fans. |
|
| Back to top |
|
 |
sandberg
Joined: 05 Oct 2005 Posts: 90 Location: Denmark
|
Posted: Wed Jan 11, 2006 5:01 am Post subject: |
|
|
Yes. I wrote code to do this. Basically it iterates through the object.
* For each vertex it loops through all the faces, to see if the current vertex is used in that face. If it is it stores a reference to the face.
* After all faces for the vertex has been checked it finds the average of the facenormals which uses this vertex. This averaged normal is used as the vertex normal.
You can get my code for this if you want to see how I do it. _________________ Br, Sandberg |
|
| Back to top |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Wed Jan 11, 2006 5:38 am Post subject: |
|
|
| sandberg wrote: | | You can get my code for this if you want to see how I do it. |
sure, i am curious, due: this point is still in front of me
the stuff done now, works smooth
Thanks
lumo _________________ "Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com |
|
| Back to top |
|
 |
sandberg
Joined: 05 Oct 2005 Posts: 90 Location: Denmark
|
Posted: Thu Jan 12, 2006 12:48 am Post subject: |
|
|
| LuMo wrote: | | sandberg wrote: | | You can get my code for this if you want to see how I do it. |
sure, i am curious, due: this point is still in front of me
the stuff done now, works smooth
Thanks
lumo |
ok. If you can't get the normal stuff to work when you need it, just PM me and I can send you the code that I use. _________________ Br, Sandberg |
|
| Back to top |
|
 |
|