It is no going to be call automatically you have to mak eteh explicit call to the collsion shape with a class of teh type class ndShapeDebugCallback : public dClassAlloc that implements
function virtual void DrawPolygon
then you have to iterate over the body list to what ever collsion shape you have and calling
collision->DebugShape(...)
there are many example in file ...\newton-4.00\applications\ndSandbox\ndDemoDebugMesh.cpp
like this
- Code: Select all
ndFlatShadedDebugMesh::ndFlatShadedDebugMesh(const ndShaderPrograms& shaderCache, const ndShapeInstance* const collision)
:ndDemoMeshInterface()
,m_indexCount(0)
,m_shadeColorLocation(0)
,m_normalMatrixLocation(0)
,m_projectMatrixLocation(0)
,m_viewModelMatrixLocation(0)
,m_shader(0)
,m_vertexBuffer(0)
,m_vertextArrayBuffer(0)
,m_triangleIndexBuffer(0)
{
class ndDrawShape : public ndShapeDebugCallback
{
public:
ndDrawShape()
:ndShapeDebugCallback()
,m_triangles(1024)
{
}
virtual void DrawPolygon(dInt32 vertexCount, const dVector* const faceVertex, const ndEdgeType* const)
{
dVector p0(faceVertex[0]);
dVector p1(faceVertex[1]);
dVector p2(faceVertex[2]);
dVector normal((p1 - p0).CrossProduct(p2 - p0));
normal = normal.Normalize();
for (dInt32 i = 2; i < vertexCount; i++)
{
glPositionNormal point;
point.m_posit.m_x = GLfloat(faceVertex[0].m_x);
point.m_posit.m_y = GLfloat(faceVertex[0].m_y);
point.m_posit.m_z = GLfloat(faceVertex[0].m_z);
point.m_normal.m_x = GLfloat(normal.m_x);
point.m_normal.m_y = GLfloat(normal.m_y);
point.m_normal.m_z = GLfloat(normal.m_z);
m_triangles.PushBack(point);
point.m_posit.m_x = GLfloat(faceVertex[i - 1].m_x);
point.m_posit.m_y = GLfloat(faceVertex[i - 1].m_y);
point.m_posit.m_z = GLfloat(faceVertex[i - 1].m_z);
point.m_normal.m_x = GLfloat(normal.m_x);
point.m_normal.m_y = GLfloat(normal.m_y);
point.m_normal.m_z = GLfloat(normal.m_z);
m_triangles.PushBack(point);
point.m_posit.m_x = GLfloat(faceVertex[i].m_x);
point.m_posit.m_y = GLfloat(faceVertex[i].m_y);
point.m_posit.m_z = GLfloat(faceVertex[i].m_z);
point.m_normal.m_x = GLfloat(normal.m_x);
point.m_normal.m_y = GLfloat(normal.m_y);
point.m_normal.m_z = GLfloat(normal.m_z);
m_triangles.PushBack(point);
}
}
dArray<glPositionNormal> m_triangles;
};
ndDrawShape drawShapes;
collision->DebugShape(dGetIdentityMatrix(), drawShapes);
the funtion take a pointe to a collsion shape, and them make and notification object to get the call back to DrawPolygon.
This is similar to what lambdas function is is newton C++ but I like it far better, more readable, and more flexible , and more practical too.
to what class did you add
virtual void DrawPolygon(dInt32 vertexCount, const dVector* const faceVertex, const ndEdgeType* const)