ok, I've copied the code from that thread, also I used a Picking tutorial.
What do I want is to click on the Knight(in Horde3d Sample Knight project) and to display its bounding box. I've added such method:
Code:
void Application::pick(float dX, float dY) {
H3DNode node = h3dutPickNode(_cam, dX, dY);
//h3dSetNodeActivation(node, false);
curnode_ = node;
}
In the main loop I do the following:
Code:
void Application::mainLoop( float fps )
{
// skipped sample code...
h3dRender( _cam );
DrawBoundingBox();
}
void Application::DrawBoundingBox() {
if (curnode_) {
const float* camera = 0;
// Retrieve camera position...
h3dGetNodeTransMats(_cam, 0, &camera);
// In case of an invalid camera (e.g. pipeline not set) return
if ( !camera ) return;
// ... and projection matrix
float projMat[16];
h3dGetCameraProjMat( _cam, projMat );
// ...
// Set projection matrix
glMatrixMode( GL_PROJECTION );
glLoadMatrixf( projMat );
// apply camera transformation
glMatrixMode( GL_MODELVIEW );
Matrix4f transMat( camera );
glLoadMatrixf( transMat.inverted().x );
// then later in e.g. drawGizmo
glPushMatrix();
const float *nodeTransform = 0;
h3dGetNodeTransMats(curnode_, NULL, &nodeTransform);
glMultMatrixf(nodeTransform); // Load scene node matrix
// ... draw code
float minX, minY, minZ, maxX, maxY, maxZ;
h3dGetNodeAABB(curnode_, &minX, &minY, &minZ, &maxX, &maxY, &maxZ);
glColor3f(0.7f, 0.7f, 0.7f);
glBegin(GL_LINE_STRIP);
glVertex3f(minX, minY, minZ);
glVertex3f(maxX, minY, minZ);
glVertex3f(maxX, maxY, minZ);
glVertex3f(minX, maxY, minZ);
glVertex3f(minX, minY, minZ);
glVertex3f(minX, minY, maxZ);
glVertex3f(maxX, minY, maxZ);
glVertex3f(maxX, maxY, maxZ);
glVertex3f(minX, maxY, maxZ);
glVertex3f(minX, minY, maxZ);
glEnd();
glBegin(GL_LINES);
glVertex3f(minX, maxY, minZ);
glVertex3f(minX, maxY, maxZ);
glVertex3f(maxX, minY, minZ);
glVertex3f(maxX, minY, maxZ);
glVertex3f(maxX, maxY, minZ);
glVertex3f(maxX, maxY, maxZ);
glEnd();
glPopMatrix();
}
}
I still don't see any lines drawn..
May be it's my lack of OpenGL knowledge? Please suggest me good books here:
http://www.horde3d.org/forums/viewtopic.php?f=5&t=1032