takis March 23, 2005, 04:22 PM 

Could it be that some normals point inside the object instead of outside the object?
this is how i calculate the normals.
void Mesh::calculateNormals()
{
m_faceNormals.reserve(m_faces.size());
for(std ::vector<Vertex >::const_iterator vIt =m_vertices .begin (); vIt !=m_vertices .end(); ++vIt )
m_vertexNormals.push_back(Vector3D(0,0,0));
for(int i=0; i<m_faces.size(); ++i)
{
Vertex v0=getVertex(m_faces[i].getVertex(0)),
v1=getVertex(m_faces[i].getVertex(1)),
v2=getVertex(m_faces[i].getVertex(2));
Vector3D p0=v1.getPosition()v0.getPosition(),
p1=v2.getPosition()v0.getPosition();
Vector3D normal;
normal.crossProduct(p0, p1);
normal.normalize();
// face normal
m_faces[i].setNormal(i);
m_faceNormals.push_back(normal);
}
m_bNormalsUpTodate=true;
}

And this is how i rotate around an edge.
void Vector3D::rotateAroundAxis(const Vector3D& p, const Vector3D& axis, float a)
{
// axis is normalised
float s=sinf(a);
float c=cosf(a);
Vector3D vpar=axis*dotProduct(p,axis);
Vector3D vprp=pvpar;
Vector3D vcrs;
vcrs.crossProduct(axis,p);
m_values[0]=vpar[0]+c*vprp[0]+s*vcrs[0];
m_values[1]=vpar[1]+c*vprp[1]+s*vcrs[1];
m_values[2]=vpar[2]+c*vprp[2]+s*vcrs[2];
}
void Vector3D::rotateAroundLine(const Vector3D& p, const Vector3D& p0, const Vector3D& p1, float a)
{
Vector3D axis=p1p0;
axis.normalize();
rotateAroundAxis(pp0,axis,a);
m_values[0]+=p0[0];
m_values[1]+=p0[1];
m_values[2]+=p0[2];
}

