bool check_polyhedron_collision_with_dag(SceneNode *node, const pp::Matrix& modelMatrix, const pp::Matrix& invModelMatrix, const ppogl::Polyhedron& ph) { PP_CHECK_POINTER( node ); bool hit = false; pp::Matrix newModelMatrix=modelMatrix*node->trans; pp::Matrix newInvModelMatrix=node->invtrans*invModelMatrix; if(node->isSphere == true){ ppogl::Polyhedron newph(ph); trans_polyhedron( newInvModelMatrix, newph ); hit = intersect_polyhedron( newph ); } if (hit == true) return hit; SceneNode* child = node->child; while (child != NULL) { hit = check_polyhedron_collision_with_dag( child, newModelMatrix, newInvModelMatrix, ph ); if ( hit == true ) { return hit; } child = child->next; } return false; }
bool collide(const std::string& node, const ppogl::Polyhedron& ph) { SceneNode *nodePtr; if(get_scene_node(node, &nodePtr) != true){ PP_ERROR( "draw_scene_graph: No such node: " << node ); } pp::Matrix mat, invmat; mat.makeIdentity(); invmat.makeIdentity(); return check_polyhedron_collision_with_dag( nodePtr, mat, invmat, ph ); }
bool_t collide(const char *node, polyhedron_t ph ) { scene_node_t *nodePtr; matrixgl_t mat, invmat; make_identity_matrix( mat ); make_identity_matrix( invmat ); if ( get_scene_node( node, &nodePtr ) != TCL_OK ) { handle_error( 1, "draw_scene_graph: No such node `%s'", node ); } return check_polyhedron_collision_with_dag( nodePtr, mat, invmat, ph ); }
bool_t check_polyhedron_collision_with_dag( scene_node_t *node, matrixgl_t modelMatrix, matrixgl_t invModelMatrix, polyhedron_t ph) { matrixgl_t newModelMatrix, newInvModelMatrix; scene_node_t *child; polyhedron_t newph; bool_t hit = False; check_assertion( node != NULL, "node is NULL" ); multiply_matrices( newModelMatrix, modelMatrix, node->trans ); multiply_matrices( newInvModelMatrix, node->invtrans, invModelMatrix ); if ( node->geom == Sphere ) { newph = copy_polyhedron( ph ); trans_polyhedron( newInvModelMatrix, newph ); hit = intersect_polyhedron( newph ); free_polyhedron( newph ); } if (hit == True) return hit; child = node->child; while (child != NULL) { hit = check_polyhedron_collision_with_dag( child, newModelMatrix, newInvModelMatrix, ph ); if ( hit == True ) { return hit; } child = child->next; } return False; }