forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

normals... how to pass to sceGuDrawArray

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Wed Jan 11, 2006 12:38 am    Post subject: normals... how to pass to sceGuDrawArray Reply with quote

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
View user's profile Send private message Visit poster's website
sandberg



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Wed Jan 11, 2006 2:57 am    Post subject: Reply with quote

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
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Wed Jan 11, 2006 4:17 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
jsgf



Joined: 12 Jul 2005
Posts: 254

PostPosted: Wed Jan 11, 2006 4:57 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
sandberg



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Wed Jan 11, 2006 5:01 am    Post subject: Reply with quote

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
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Wed Jan 11, 2006 5:38 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
sandberg



Joined: 05 Oct 2005
Posts: 90
Location: Denmark

PostPosted: Thu Jan 12, 2006 12:48 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group