Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualHodgman

Posted 07 July 2012 - 11:11 PM

I'm trying to render a number of vertices (dots) in order to ensure that my skeleton is setup correctly. But I can't figure out how to do the equivalent of:

static void DrawBonesSkeleton(Bone_t& Bone)
{
	glPointSize(5.0);
	glTranslatef(Bone.Translation.x, Bone.Translation.y, Bone.Translation.z);
	float RotationMatrix[16];
	FindQuaternionMatrix(RotationMatrix, &Bone.Rotation);
	glMultMatrixf(RotationMatrix);

	if(!strcmp(Bone.Name, "ROOT"))
		glColor3f(1.0, 0.0, 0.0);
	else if(!strcmp(Bone.Name, "HEAD"))
		glColor3f(1.0, 1.0, 0.0);
	else
		glColor3f(0.0, 1.0, 0.0);
	glBegin(GL_POINTS); glVertex3f(0, 0, 0); glEnd();

	if(Bone.ChildrenCount == 1){
		DrawBonesSkeleton(*Bone.Children[0]);
	}else if(Bone.ChildrenCount > 1){
		for(unsigned i=0; i<Bone.ChildrenCount; i++){
			glPushMatrix();
			DrawBonesSkeleton(*Bone.Children[i]);
			glPopMatrix();
		}
	}
}

static void DrawSkeleton()
{
	glPushMatrix();
	DrawBonesSkeleton(Skeleton.Bones[0]);
	glPopMatrix();
}

in XNA - my current attempt involves one call to DrawUserPrimitives() when rendering, but the output obviously isn't correct because DrawBonesSkeleton is a recursive function. Please, if you have any ideas - reply!

Edit: Why isn't the entire code displayed?
Edit2 by Hodgman: We seem to be having some bugs with the source tag at the moment, the code tag still seems to work though...

#3MatsK

Posted 07 July 2012 - 08:43 PM

I'm trying to render a number of vertices (dots) in order to ensure that my skeleton is setup correctly. But I can't figure out how to do the equivalent of:


[source lang="cpp"]static void DrawBonesSkeleton(Bone_t& Bone){ glPointSize(5.0); glTranslatef(Bone.Translation.x, Bone.Translation.y, Bone.Translation.z); float RotationMatrix[16]; FindQuaternionMatrix(RotationMatrix, &Bone.Rotation); glMultMatrixf(RotationMatrix); if(!strcmp(Bone.Name, "ROOT")) glColor3f(1.0, 0.0, 0.0); else if(!strcmp(Bone.Name, "HEAD")) glColor3f(1.0, 1.0, 0.0); else glColor3f(0.0, 1.0, 0.0); glBegin(GL_POINTS); glVertex3f(0, 0, 0); glEnd(); if(Bone.ChildrenCount == 1){ DrawBonesSkeleton(*Bone.Children[0]); }else if(Bone.ChildrenCount > 1){ for(unsigned i=0; i<Bone.ChildrenCount; i++){ glPushMatrix(); DrawBonesSkeleton(*Bone.Children[i]); glPopMatrix(); } }}static void DrawSkeleton(){ glPushMatrix(); DrawBonesSkeleton(Skeleton.Bones[0]); glPopMatrix();}[/source]

in XNA - my current attempt involves one call to DrawUserPrimitives() when rendering, but the output obviously isn't correct because DrawBonesSkeleton is a recursive function. Please, if you have any ideas - reply!

Edit: Why isn't the entire code displayed?

#2MatsK

Posted 07 July 2012 - 08:42 PM

I'm trying to render a number of vertices (dots) in order to ensure that my skeleton is setup correctly. But I can't figure out how to do the equivalent of:


[source lang="cpp"]static void DrawBonesSkeleton(Bone_t& Bone){ glPointSize(5.0); glTranslatef(Bone.Translation.x, Bone.Translation.y, Bone.Translation.z); float RotationMatrix[16]; FindQuaternionMatrix(RotationMatrix, &Bone.Rotation); glMultMatrixf(RotationMatrix); if(!strcmp(Bone.Name, "ROOT")) glColor3f(1.0, 0.0, 0.0); else if(!strcmp(Bone.Name, "HEAD")) glColor3f(1.0, 1.0, 0.0); else glColor3f(0.0, 1.0, 0.0); glBegin(GL_POINTS); glVertex3f(0, 0, 0); glEnd(); if(Bone.ChildrenCount == 1){ DrawBonesSkeleton(*Bone.Children[0]); }else if(Bone.ChildrenCount > 1){ for(unsigned i=0; i<Bone.ChildrenCount; i++){ glPushMatrix(); DrawBonesSkeleton(*Bone.Children[i]); glPopMatrix(); } }}static void DrawSkeleton(){ glPushMatrix(); DrawBonesSkeleton(Skeleton.Bones[0]); glPopMatrix();}[/source]

in XNA - my current attempt involves one call to DrawUserPrimitives() when rendering, but the output obviously isn't correct because DrawBonesSkeleton is a recursive function. Please, if you have any ideas - reply!

#1MatsK

Posted 07 July 2012 - 08:39 PM

I'm trying to render a number of vertices (dots) in order to ensure that my skeleton is setup correctly. But I can't figure out how to do the equivalent of:


[source lang="cpp"]static void DrawBonesSkeleton(Bone_t& Bone){ glPointSize(5.0); glTranslatef(Bone.Translation.x, Bone.Translation.y, Bone.Translation.z); float RotationMatrix[16]; FindQuaternionMatrix(RotationMatrix, &Bone.Rotation); glMultMatrixf(RotationMatrix); if(!strcmp(Bone.Name, "ROOT")) glColor3f(1.0, 0.0, 0.0); else if(!strcmp(Bone.Name, "HEAD")) glColor3f(1.0, 1.0, 0.0); else glColor3f(0.0, 1.0, 0.0); glBegin(GL_POINTS); glVertex3f(0, 0, 0); glEnd(); if(Bone.ChildrenCount == 1){ DrawBonesSkeleton(*Bone.Children[0]); }else if(Bone.ChildrenCount > 1){ for(unsigned i=0; i<Bone.ChildrenCount; i++){ glPushMatrix(); DrawBonesSkeleton(*Bone.Children[i]); glPopMatrix(); } }}static void DrawSkeleton(){ glPushMatrix(); DrawBonesSkeleton(Skeleton.Bones[0]); glPopMatrix();}[/source]
in XNA - my current attempt involves one call to DrawUserPrimitives() when rendering, but the output obviously isn't correct because DrawBonesSkeleton is a recursive function. Please, if you have any ideas - reply!

PARTNERS