simple skinning

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

Moderators: cheriff, TyRaNiD

Post Reply
sturatt
Posts: 46
Joined: Thu Jul 13, 2006 4:21 pm

simple skinning

Post by sturatt »

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

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

ScePspFMatrix4 mat[8];
		for &#40;int i=0; i<8; i++&#41;
		&#123;
			gumLoadIdentity&#40;&mat&#91;i&#93;&#41;;
			sceGuBoneMatrix&#40;i, &mat&#91;i&#93;&#41;;
			sceGuMorphWeight&#40;i, 1.0f &#41;;
		&#125;
and i changed my sceGuDrawArray to have GU_WEIGHTS(8)|GU_WEIGHT_32BITF

Code: Select all

sceGumDrawArray&#40;GU_POINTS, GU_WEIGHTS&#40;8&#41;|GU_WEIGHT_32BITF|GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_NORMAL_32BITF|GU_COLOR_8888|GU_TRANSFORM_3D,
			meshes&#91;x&#93;.numVertices, 0, meshes&#91;x&#93;.vertices&#41;;
why would these things stop my model from rendering?
rapso
Posts: 140
Joined: Mon Mar 28, 2005 6:35 am

Post by rapso »

the new vertex is

Code: Select all

for each weight
  newpos += originalpos*matrix*weight
all weights to 0 accumulates to 0 as well.
the sum of all weights should be 1.
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

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
sturatt
Posts: 46
Joined: Thu Jul 13, 2006 4:21 pm

Post by sturatt »

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.
sturatt
Posts: 46
Joined: Thu Jul 13, 2006 4:21 pm

Post by sturatt »

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

typedef struct pspVertex &#123;
	float weights&#91;8&#93;;
	float u,v;
	unsigned int color;
	float nx, ny, nz;
	float x,y,z;
&#125;;
set each weight to 1.0f/8.0f

Code: Select all

for &#40;int h=0; h<8; h++&#41;
			&#123;
				meshes&#91;x&#93;.vertices&#91;y&#93;.weights&#91;h&#93; = 1.0f/8.0f;
			&#125;
Setup the matrices before each render, and added the GU_WEIGHTS and GU_WEIGHT_32BITF to the render type

Code: Select all

ScePspFMatrix4 mat&#91;8&#93;;
		for &#40;int i=0; i<8; i++&#41;
		&#123;
			gumLoadIdentity&#40;&mat&#91;i&#93;&#41;;
			sceGuBoneMatrix&#40;i, &mat&#91;i&#93;&#41;;
		&#125;

		sceGumDrawArray&#40;GU_POINTS, GU_WEIGHTS&#40;8&#41;|GU_WEIGHT_32BITF|GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_NORMAL_32BITF|GU_COLOR_8888|GU_TRANSFORM_3D,
			meshes&#91;x&#93;.numVertices, 0, meshes&#91;x&#93;.vertices&#41;;
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
sturatt
Posts: 46
Joined: Thu Jul 13, 2006 4:21 pm

Post by sturatt »

Nobody knows what im doing wrong?
Post Reply