Vertex normal not updated properly in soft bodies.

winspear
Posts: 77
Joined: Thu Nov 26, 2009 6:32 pm

Vertex normal not updated properly in soft bodies.

Post by winspear »

I made a simple soft body simulation with 3 soft spheres and tried stepping the physics at a high rate.
When the soft bodies are rendered with flat face normals,everything looks fine but when I render them with vertex normals, I see some weird artifacts in the rendering.

Here is my render function..

Code: Select all

void renderSoftbodyMeshes(btSoftBody* sBody)
{
	btTransform meshTransform = sBody->getWorldTransform();

	GLfloat tempForm[16];
	meshTransform.getOpenGLMatrix(tempForm);
	
	glPushMatrix();
	glMultMatrixf(tempForm);
	glBegin(GL_TRIANGLES);
	int numFaces = sBody->m_faces.size();
	for (int i=0; i< numFaces; i++)
	{
//		glNormal3fv(sBody->m_faces[i].m_normal); // face normal
		glNormal3fv(sBody->m_faces[i].m_n[0]->m_n);
		glVertex3fv(sBody->m_faces[i].m_n[0]->m_q);
		glNormal3fv(sBody->m_faces[i].m_n[1]->m_n);
		glVertex3fv(sBody->m_faces[i].m_n[1]->m_q);
		glNormal3fv(sBody->m_faces[i].m_n[2]->m_n);
		glVertex3fv(sBody->m_faces[i].m_n[2]->m_q);
	}
	glEnd();
	glPopMatrix(); 
}
Can anyone please tell me what is going on ? This has been very frustrating since softbody works great but I am not able to render them properly.

Please see attached video for clarification.


Thanks
W
You do not have the required permissions to view the files attached to this post.