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 

How to correctly align vertices?

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



Joined: 31 Dec 2005
Posts: 288

PostPosted: Sat Sep 16, 2006 7:28 am    Post subject: How to correctly align vertices? Reply with quote

Hi folks,

I'm trying to draw an object correctly, i don't really get it correct and i guess it is because i have not aligned the vertices because i really dont know exactly how to do it. How someone can explain them a little bit.

All the vertices are stored this way:

Code:
typedef struct { float         u, v;
                unsigned int         color;
                float         x, y, z; } ObjVertexB;   // vertex to render

   typedef struct { unsigned int   iNumberOfVertices;
                ObjVertexB      *Vertices; } ObjStrip;

   typedef struct _MeshB {   unsigned int   iNumberOfStrips;
                     ObjStrip      *Strips; } MeshB;
so my mesh has strips and those strips have the vertices however this way the vertices are not aligned.

i create them using this code:
Code:
tmpObj->iNumberOfStrips = tmpStrips;
      tmpObj->Strips = (ObjStrip*)malloc(tmpStrips * sizeof(ObjStrip));
tmpObj->Strips[iStripNr].iNumberOfVertices = tmpStripsSize[iStripNr];
      tmpObj->Strips[iStripNr].Vertices = (ObjVertexB*)malloc(tmpStripsSize[iStripNr] * sizeof(ObjVertexB));


i then draw it like this:
Code:
tmpObj->Strips[iStripNr].iNumberOfVertices = tmpStripsSize[iStripNr];
      tmpObj->Strips[iStripNr].Vertices = (ObjVertexB*)malloc(tmpStripsSize[iStripNr] * sizeof(ObjVertexB));
      


Hope someone can help me implement the alignment

greets ghoti
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
zoret



Joined: 19 Mar 2006
Posts: 22

PostPosted: Tue Sep 19, 2006 5:25 am    Post subject: Reply with quote

to allocate aligned on 16b you can use the memalign function
so :

ObjVertexB * pVertices = memalign(16, nbVertices * sizeof(ObjVertexB));

maybe you can help to use psplink ! ;)
Back to top
View user's profile Send private message Send e-mail
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Tue Sep 19, 2006 5:50 am    Post subject: Reply with quote

malloc on psp is aligned to 16byte by default.

There's nothing generally wrong with the code, if the drawing messes up, its more likely to other problems than the alignment, because wrong alignment would just crash the program.
_________________
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Back to top
View user's profile Send private message Visit poster's website
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Tue Sep 19, 2006 5:54 pm    Post subject: Reply with quote

Hi thanks for the reply, however i have a question left:

i have used psplink it is very usefull for everything but there is one thing that is very annoying about psplink. for some reason psplink accepts some code while the psp on its own does not.

example:

with controls, if i use the analog pad this way:
Code:
float movement;
movement = (float)(pad.Lx) - 128.0f;
if i run this through psplink i can move around, however when i run this the normal way as a pbp i can't move around.

other annoying things that happens are code that crashes the normal way but in psplink it is accepted. Last time i was quite far with some code and then i ran it the normal way and it crashed on several occasions.

why is this? is this because i am probebly not using the newest psptoolchain anymore?

greets ghoti
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
Tinnus



Joined: 29 Jul 2006
Posts: 67

PostPosted: Wed Sep 20, 2006 2:48 am    Post subject: Reply with quote

You need that to make the analog work:

Code:
    sceCtrlSetSamplingCycle(0);
    sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);

PSPLink probably does that itself, that's why your program can use it. IRShell does the same thing :)
_________________
Let's see what the PSP reserves... well, I'd say anything is better than Palm OS.
Back to top
View user's profile Send private message
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Wed Sep 20, 2006 9:25 pm    Post subject: Reply with quote

Ah thanks that did the trick
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
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