void CPreviewDlg::display_func(){ static bool init = false; static timemeas_t tm; static double realtime = 0.; if(!init){ init = true; TimeMeasStart(&tm); } double t1 = TimeMeasLap(&tm); double rdt, dt; /* if(g_fix_dt) rdt = g_fix_dt; else*/ rdt = (t1 - realtime); realtime = t1; dt = !init ? 0. : rdt < 1. ? rdt : 1.; MotionPose *dnmv = main.dnmv; /* if(main.dnmv){ if(fmod(realtime, .2) < .1){ dnmv->target = GetSrfName(main.selectbone); } else dnmv->target = NULL; }*/ glClearColor(0,0,0,0); glClearDepth(1.); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslated(0,0,-dist); gldMultQuat(viewrot); /* grid draw */ glPushMatrix(); gldScaled(100.); glBegin(GL_LINES); for(int i = 0; i <= 16; i++){ glColor4ub(255,127,127,255); glVertex3d(-8, 0, i - 8); glVertex3d( 8, 0, i - 8); glColor4ub(127,127,255,255); glVertex3d(i - 8, 0, -8); glVertex3d(i - 8, 0, 8); } glColor4ub(255,0,0,255); glVertex3d(-100,0,0); glVertex3d( 100,0,0); glColor4ub(0,255,0,255); glVertex3d(0,-100,0); glVertex3d(0, 100,0); glColor4ub(0,0,255,255); glVertex3d(0,0,-100); glVertex3d(0,0, 100); glEnd(); glPopMatrix(); if(main.dnm){ glPushAttrib(GL_CURRENT_BIT | GL_LIGHTING_BIT | GL_POLYGON_BIT); if(wireframe) glPolygonMode(GL_FRONT, GL_LINE); else glPolygonMode(GL_FRONT, GL_FILL); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); { int i; GLfloat mat_specular[] = {0., 0., 0., 1.}; GLfloat mat_diffuse[] = { .5, .5, .5, 1.0 }; GLfloat mat_ambient_color[] = { 0.5, 0.5, 0.5, 1.0 }; GLfloat mat_shininess[] = { 50.0 }; GLfloat light_position[4] = { 1, 1, 1, 0.0 }; GLfloat light_ambient_color[] = { 0.5, 0.5, 0.5, 1.0 }; GLfloat light_diffuse[] = { 1., 1., 1., 1.0 }; glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightfv(GL_LIGHT0, GL_SPECULAR, mat_specular); glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient_color); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); } glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glEnable(GL_NORMALIZE); glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // DrawYSDNM_V(main.dnm, main.dnmv); glPopAttrib(); /* if(boneview){ if(boneview == 2) glDisable(GL_DEPTH_TEST); glPushMatrix(); BoneYSDNM_V(main.dnm, main.dnmv); glPopMatrix(); }*/ } else if(main.model){ glPushAttrib(GL_CURRENT_BIT | GL_LIGHTING_BIT | GL_POLYGON_BIT); if(wireframe) glPolygonMode(GL_FRONT, GL_LINE); else glPolygonMode(GL_FRONT, GL_FILL); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); { int i; GLfloat mat_specular[] = {0., 0., 0., 1.}; GLfloat mat_diffuse[] = { .5, .5, .5, 1.0 }; GLfloat mat_ambient_color[] = { 0.5, 0.5, 0.5, 1.0 }; GLfloat mat_shininess[] = { 50.0 }; GLfloat light_position[4] = { 1, 1, 1, 0.0 }; GLfloat light_ambient_color[] = { 0.5, 0.5, 0.5, 1.0 }; GLfloat light_diffuse[] = { 1., 1., 1., 1.0 }; glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightfv(GL_LIGHT0, GL_SPECULAR, mat_specular); glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient_color); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); } glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glEnable(GL_NORMALIZE); glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // for(int i = 0; i < nsufs; i++){ // DrawSUF(sufs[i], SUF_ATR, NULL); // } // BoneMQO_V(sufs, bones, dnmv); // DrawMQO_V(main.model, dnmv); DrawMQOPose(main.model, dnmv); glPopAttrib(); /* if(boneview){ if(boneview == 2) glDisable(GL_DEPTH_TEST); glPushMatrix(); glBegin(GL_LINES); for(int i = 0; i < nsufs; i++){ glVertex3dv(bones[i]->parent ? bones[i]->parent->joint: Vec4d(0,0,0,0)); glVertex3dv(bones[i]->joint); } glEnd(); glPopMatrix(); }*/ } if(main.dnm){ glDisable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslated(0,0,-.5); ysdnm_t *dnm = main.dnm; int selectbone = main.selectbone; Motion *&motion = main.motion; Motion *(&motions)[16] = main.motions; int nmotions = main.nmotions, curmotion = main.curmotion; double (&motion_time)[16] = main.motion_time; glScaled(2. / g_width, 2. / g_height, 1.); glColor4ub(0,255,0,255); glRasterPos2d(-g_width / 2, -g_height / 2 + 32); gldprintf("bone: %d", selectbone); if(0 <= selectbone && selectbone < dnm->ns && dnm->s[selectbone]){ glRasterPos2d(-g_width / 2, -g_height / 2 + 16); gldprintf("name: \"%s\" \"%s\"", dnm->s[selectbone]->name, dnm->s[selectbone]->pck->name); } const double (*pq)[7]; if(pq = (double (*)[7])FindBone(selectbone)){ glRasterPos2d(-g_width / 2, -g_height / 2 + 0); gldprintf("rot: (%lg,%lg,%lg,%lg),(%lg,%lg,%lg)", (*pq)[0], (*pq)[1], (*pq)[2], (*pq)[3], (*pq)[4], (*pq)[5], (*pq)[6]); } /* if(motion && motion->kfl.size()){ glRasterPos2d(-g_width / 2, -g_height * 2 / 3); gldprintf("mot: (%d)", &motion->getKeyframe(motion_time[curmotion]) - motion->kfl); }*/ for(int n = 0; n < nmotions; n++) if(motions[n] && motions[n]->kfl.size()){ Motion *mot = motions[n]; double ttime = mot->totalTime(); glColor4ub(0,n == curmotion ? 255 : 127,0,255); glBegin(GL_LINE_LOOP); glVertex2d(-g_width / 2 * .8, -g_height / 2 * (.7 + .1 * n)); glVertex2d( g_width / 2 * .8, -g_height / 2 * (.7 + .1 * n)); glVertex2d( g_width / 2 * .8, -g_height / 2 * (.6 + .1 * n)); glVertex2d(-g_width / 2 * .8, -g_height / 2 * (.6 + .1 * n)); glEnd(); glBegin(GL_LINES); double tsum = 0.; for(int i = 0; i < mot->kfl.size(); i++){ tsum += mot->kfl[i].dt; glVertex2d(-g_width / 2 * .8 + tsum * (g_width / 2 * 1.6) / ttime, -g_height / 2 * (.7 + .1 * n)); glVertex2d(-g_width / 2 * .8 + tsum * (g_width / 2 * 1.6) / ttime, -g_height / 2 * (.6 + .1 * n)); } glColor4ub(255,255,0,255); glVertex2d(-g_width / 2 * .8 + motion_time[n] * (g_width / 2 * 1.6) / ttime, -g_height / 2 * (.7 + .1 * n)); glVertex2d(-g_width / 2 * .8 + motion_time[n] * (g_width / 2 * 1.6) / ttime, -g_height / 2 * (.6 + .1 * n)); glEnd(); } glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); } }