void TestCase::handleRender() { glLineWidth(2.0f); glBegin(GL_LINES); for (Test* iter = m_tests; iter; iter = iter->next) { float dir[3]; rcVsub(dir, iter->epos, iter->spos); rcVnormalize(dir); glColor4ub(128,25,0,192); glVertex3f(iter->spos[0],iter->spos[1]-0.3f,iter->spos[2]); glVertex3f(iter->spos[0],iter->spos[1]+0.3f,iter->spos[2]); glVertex3f(iter->spos[0],iter->spos[1]+0.3f,iter->spos[2]); glVertex3f(iter->spos[0]+dir[0]*0.3f,iter->spos[1]+0.3f+dir[1]*0.3f,iter->spos[2]+dir[2]*0.3f); glColor4ub(51,102,0,129); glVertex3f(iter->epos[0],iter->epos[1]-0.3f,iter->epos[2]); glVertex3f(iter->epos[0],iter->epos[1]+0.3f,iter->epos[2]); if (iter->expand) glColor4ub(255,192,0,255); else glColor4ub(0,0,0,64); for (int i = 0; i < iter->nstraight-1; ++i) { glVertex3f(iter->straight[i*3+0],iter->straight[i*3+1]+0.3f,iter->straight[i*3+2]); glVertex3f(iter->straight[(i+1)*3+0],iter->straight[(i+1)*3+1]+0.3f,iter->straight[(i+1)*3+2]); } } glEnd(); glLineWidth(1.0f); }
static void calcTriNormal(const float* v0, const float* v1, const float* v2, float* norm) { float e0[3], e1[3]; rcVsub(e0, v1, v0); rcVsub(e1, v2, v0); rcVcross(norm, e0, e1); rcVnormalize(norm); }
static void calcTriNormal(const dtCoordinates& v0, const dtCoordinates& v1, const dtCoordinates& v2, dtCoordinates& norm) { dtCoordinates e0, e1; rcVsub(e0, v1, v0); rcVsub(e1, v2, v0); rcVcross(norm, e0, e1); rcVnormalize(norm); }
bool TestCase::handleRenderOverlay(double* proj, double* model, int* view) { GLdouble x, y, z; char text[64]; int n = 0; static const float LABEL_DIST = 1.0f; for (Test* iter = m_tests; iter; iter = iter->next) { float pt[3], dir[3]; if (iter->nstraight) { rcVcopy(pt, &iter->straight[3]); if (rcVdist(pt, iter->spos) > LABEL_DIST) { rcVsub(dir, pt, iter->spos); rcVnormalize(dir); rcVmad(pt, iter->spos, dir, LABEL_DIST); } pt[1]+=0.5f; } else { rcVsub(dir, iter->epos, iter->spos); rcVnormalize(dir); rcVmad(pt, iter->spos, dir, LABEL_DIST); pt[1]+=0.5f; } if (gluProject((GLdouble)pt[0], (GLdouble)pt[1], (GLdouble)pt[2], model, proj, view, &x, &y, &z)) { snprintf(text, 64, "Path %d\n", n); unsigned int col = imguiRGBA(0,0,0,128); if (iter->expand) col = imguiRGBA(255,192,0,220); imguiDrawText((int)x, (int)(y-25), IMGUI_ALIGN_CENTER, text, col); } n++; } static int resScroll = 0; bool mouseOverMenu = imguiBeginScrollArea("Test Results", 10, view[3] - 10 - 350, 200, 350, &resScroll); // mouseOverMenu = true; n = 0; for (Test* iter = m_tests; iter; iter = iter->next) { snprintf(text, 64, "Path %d\n", n); if (imguiCollapse(text, iter->expand)) iter->expand = !iter->expand; if (iter->expand) { snprintf(text, 64, "Poly: %.4f ms\n", (float)iter->findNearestPolyTime/1000.0f); imguiValue(text); snprintf(text, 64, "Path: %.4f ms\n", (float)iter->findPathTime/1000.0f); imguiValue(text); snprintf(text, 64, "Straight: %.4f ms\n", (float)iter->findStraightPathTime/1000.0f); imguiValue(text); } rcTimeVal total = iter->findNearestPolyTime + iter->findPathTime + iter->findStraightPathTime; snprintf(text, 64, "Total: %.4f ms\n", (float)total/1000.0f); imguiValue(text); // imguiDrawText(10, 700-n*20, IMGUI_ALIGN_LEFT, text, imguiRGBA(255,255,255,220)); n++; } imguiEndScrollArea(); return mouseOverMenu; }