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 

simple skinning

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



Joined: 13 Jul 2006
Posts: 46

PostPosted: Wed Apr 18, 2007 9:05 am    Post subject: simple skinning Reply with quote

Im trying to learn about skinning, so i am modifying a smiple program that i have that just draws colored triangles.

I've added all the parts that i thought i needed to get it to render, but when i compile with all this stuff, i get a black screen.

Here is the stuff ive added:

i changed my vertex to have the weights:
Code:

typedef struct pspVertex {
   float weights[8];
   float u,v;
   unsigned int color;
   float nx, ny, nz;
   float x,y,z;
};


when i read in the vertex data, i set all of weights to 0.

I added this small section right before i call sceGuDrawArray to setup the bones
Code:
ScePspFMatrix4 mat[8];
      for (int i=0; i<8; i++)
      {
         gumLoadIdentity(&mat[i]);
         sceGuBoneMatrix(i, &mat[i]);
         sceGuMorphWeight(i, 1.0f );
      }


and i changed my sceGuDrawArray to have GU_WEIGHTS(8)|GU_WEIGHT_32BITF
Code:
sceGumDrawArray(GU_POINTS, GU_WEIGHTS(8)|GU_WEIGHT_32BITF|GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_NORMAL_32BITF|GU_COLOR_8888|GU_TRANSFORM_3D,
         meshes[x].numVertices, 0, meshes[x].vertices);


why would these things stop my model from rendering?
Back to top
View user's profile Send private message
rapso



Joined: 28 Mar 2005
Posts: 147

PostPosted: Wed Apr 18, 2007 5:22 pm    Post subject: Reply with quote

the new vertex is
Code:

for each weight
  newpos += originalpos*matrix*weight


all weights to 0 accumulates to 0 as well.
the sum of all weights should be 1.
Back to top
View user's profile Send private message
Raphael



Joined: 17 Jan 2006
Posts: 646
Location: Germany

PostPosted: Wed Apr 18, 2007 10:13 pm    Post subject: Reply with quote

Also, morphweight != skinweight.
_________________
<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
sturatt



Joined: 13 Jul 2006
Posts: 46

PostPosted: Thu Apr 19, 2007 2:41 am    Post subject: Reply with quote

Thanks for the replys :)

After reading what you said, i went back and changed it so that the first weight on each vertex is 1.0f. With the first bone matrix being an identity matrix, shouldn't my geometry show up unchanged?

@Raphael
Yeah, i thought so, but i was just throwing stuff in there to try and get some trianges =D. I was a little confused though, morphing is when you give several vertices to interpolate between right? The reason i wasnt so sure is because randomly in the skinning sample in the sdk, he throws a guMorphWeight in there.
Back to top
View user's profile Send private message
sturatt



Joined: 13 Jul 2006
Posts: 46

PostPosted: Thu Apr 19, 2007 3:33 pm    Post subject: Reply with quote

I still dont know what im doing wrong. It seems like my model should show up just as it did before, but adding these things seem to stop it from showing up at all...


I added hte weights to the vertex structure:
Code:
typedef struct pspVertex {
   float weights[8];
   float u,v;
   unsigned int color;
   float nx, ny, nz;
   float x,y,z;
};


set each weight to 1.0f/8.0f

Code:
for (int h=0; h<8; h++)
         {
            meshes[x].vertices[y].weights[h] = 1.0f/8.0f;
         }


Setup the matrices before each render, and added the GU_WEIGHTS and GU_WEIGHT_32BITF to the render type
Code:
ScePspFMatrix4 mat[8];
      for (int i=0; i<8; i++)
      {
         gumLoadIdentity(&mat[i]);
         sceGuBoneMatrix(i, &mat[i]);
      }

      sceGumDrawArray(GU_POINTS, GU_WEIGHTS(8)|GU_WEIGHT_32BITF|GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_NORMAL_32BITF|GU_COLOR_8888|GU_TRANSFORM_3D,
         meshes[x].numVertices, 0, meshes[x].vertices);


should just those things stop my geometry from rendering? when i commend all the new stuff above out, it draws just fine. I also tried setting weight[0] to 1.0f and the rest to 0, but still nothing.

Thanks,
Stu
Back to top
View user's profile Send private message
sturatt



Joined: 13 Jul 2006
Posts: 46

PostPosted: Sat Apr 21, 2007 2:04 am    Post subject: Reply with quote

Nobody knows what im doing wrong?
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