normals... how to pass to sceGuDrawArray

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

normals... how to pass to sceGuDrawArray

Post by LuMo »

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: Select all

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
sandberg
Posts: 90
Joined: Wed Oct 05, 2005 1:25 am
Location: Denmark

Post by sandberg »

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
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

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
jsgf
Posts: 254
Joined: Tue Jul 12, 2005 11:02 am
Contact:

Post by jsgf »

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.
sandberg
Posts: 90
Joined: Wed Oct 05, 2005 1:25 am
Location: Denmark

Post by sandberg »

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
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

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
sandberg
Posts: 90
Joined: Wed Oct 05, 2005 1:25 am
Location: Denmark

Post by sandberg »

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
Post Reply