void UReporterGraph::Draw(UCanvas* Canvas) { if(!bVisible) { return; } DrawBackground(Canvas); switch(DataStyle) { case EGraphDataStyle::Lines: { // order doesn't *really* matter, as they're lines DrawAxes(Canvas); DrawData(Canvas); } break; case EGraphDataStyle::Filled: { // draw data first and overlay axes DrawData(Canvas); DrawAxes(Canvas); } break; } DrawLegend(Canvas); DrawThresholds(Canvas); }
//OpenGL Display Routine void Display(void){ int k; glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glTranslatef(FaceTx,FaceTy,FaceTz); glRotatef(FaceRoll,0,0,1); glRotatef(FacePitch,0,1,0); glRotatef(FaceYaw,1,0,0); Anthropometric3DModel(3); DrawAxes(5,0.1); glPopMatrix(); glutSwapBuffers(); //Read From FrameBuffer //glReadPixels(0,0,Image->width,Image->height,GL_BGR,GL_UNSIGNED_BYTE,Image->imageData); glReadPixels(0,0,Image->width,Image->height,GL_RGB,GL_UNSIGNED_BYTE,Image->imageData); }
void PostDisplay() { // Count frame rate : static int fpsCounter = -1; // Don't count first frame static int fpsCurrent = -1; // -1 if framerate has not been set yet static double accumTime = 0.0; // Update counters : fpsCounter++; accumTime += timeElapsedSincePrevIteration; if (accumTime > 1.0) { fpsCurrent = (int)(((double)fpsCounter) / accumTime); accumTime = 0.0; fpsCounter = 0; } // GLfloat a=0.2; DrawAxes(-a,a,-a,a,-a,a); // Draw infos on the screen : char tText[255]; if (fpsCurrent >= 0) { sprintf((char*)tText, "FPS : %d", fpsCurrent); DrawText(10, 50, (char*)tText); } sprintf((char*)tText, "Current iteration: [Compute(s): %d] [Visu: %d] [Capture: %d]", iterationCounterComputes, iterationCounterVisu, iterationCounterCapture); DrawText(10, 35, (char*)tText); sprintf((char*)tText, "Prime numbers computed: %d", primeNumbersCount); DrawText(10, 20, (char*)tText); if (lastIterationComputeTime >= 0) sprintf((char*)tText, "Prime compution Time (last iteration): %d.%.03d milliseconds", lastIterationComputeTime/1000, lastIterationComputeTime%1000); else sprintf((char*)tText, "Prime compution Time (last iteration): Error"); DrawText(10, 5, (char*)tText); // Display keys received. int offset = 100; sprintf((char*)tText, "Key Pressed:");DrawText(offset, 50, (char*)tText); offset += 100; for (unsigned int ikey=0; ikey<keysPressedCount; ikey++) switch(pKeysPressed[ikey]) { case FLOWVR_KEY_UP: sprintf((char*)tText, "Up");DrawText(offset,50, (char*)tText); break; case FLOWVR_KEY_DOWN: sprintf((char*)tText, "Down");DrawText(offset+40, 50, (char*)tText);break; case FLOWVR_KEY_LEFT: sprintf((char*)tText, "Left");DrawText(offset+80, 50, (char*)tText);break; case FLOWVR_KEY_RIGHT: sprintf((char*)tText, "Right");DrawText(offset+120, 50, (char*)tText); break; } // Swap Opengl buffers : glutSwapBuffers(); }
/* draw the helix shape */ void DrawStuff (void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f (0.8, 0.3, 0.6); glPushMatrix (); /* set up some matrices so that the object spins with the mouse */ glTranslatef (20.0,20.0,-120.0); glRotatef (rotate_frame[1], 1.0, 0.0, 0.0); glRotatef (rotate_frame[0], 0.0, 0.0, 1.0); //change thread, if necessary if (move_end[0] != 0.0 || move_end[1] != 0.0 || tangent_end[0] != 0.0 || tangent_end[1] != 0.0 || tangent_rotation_end[0] != 0 || tangent_rotation_end[1] != 0) { glThreads[curThread]->ApplyUserInput(move_end, tangent_end, tangent_rotation_end); } //Draw Axes DrawAxes(); //addThreadDebugInfo(); glThreads[startThread]->updateThreadPoints(); Vector3d display_start_pos = glThreads[startThread]->getStartPosition(); for(int i = 0; i < totalThreads; i++) { //Draw Thread if (!show_threads[i]) continue; std::cout << i << " " << show_threads[i] << std::endl; if (i==startThread) { glColor4f (0.8, 0.5, 0.0, 0.9); } else if (i==just_vis_error_thread) { glColor4f (0.8, 0.0, 0.0, 0.9); } else if (i==optimize_thread) { glColor4f (0.0, 0.0, 0.8, 0.9); } else { glColor4f (0.5, 0.5, 0.5, 0.9); } glThreads[i]->display_start_pos = display_start_pos; glThreads[i]->DrawThread(); if (i != just_vis_error_thread) { //glThreads[i]->DrawAxes(); } } if (thread_vision_searched) { thread_vision.display(); save_opengl_image(); } glPopMatrix (); glutSwapBuffers (); }
void CHostageImprov::__MAKE_VHOOK(TrackPath)(const Vector &pathGoal, float deltaT) { FaceTowards(pathGoal, deltaT); MoveTowards(pathGoal, deltaT); m_jumpTarget = pathGoal; DrawAxes(pathGoal, 255, 0, 255); }
void RenderingWidget::Render() { DrawAxes(is_draw_axes_); DrawPoints(is_draw_point_); DrawEdge(is_draw_edge_); DrawHeat(is_draw_heat_); DrawBulk(is_draw_bulk_); DrawOrder(is_draw_order_); }
void DrawScene(void) { DrawAxes(); DrawSphereAt (0, 0, 0); DrawSphereAt (0.5, 0, 0); DrawSphereAt (-0.5, 0, 0); DrawSphereAt (0, 0.5, 0); DrawSphereAt (0, -0.5, 0); DrawSphereAt (0, 0, -0.5); DrawSphereAt (0, 0, 0.5); }
static void MyDisplay( void ) { static int starttime, stoptime; starttime = glutGet( GLUT_ELAPSED_TIME ); glViewport( 0, 0, winWidth, winHeight ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 45.0, (double)winWidth/winHeight, model.radius, 10.0 * model.radius ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glTranslated( 0.0, 0.0, -2.5 * model.radius ); glPushMatrix(); tb.applyTransform(); glTranslatef( -model.center[0], -model.center[1], -model.center[2] ); glDepthRange( DEPTH_OFFSET, 1.0 ); // This is for outlined fill. // Draw axes. if ( drawAxes ) DrawAxes( 2.0 * model.radius ); if ( drawStyle == 0 || drawStyle == 2 ) glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); // Filled or outlined fill. else glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); // Wireframe. glCallList( gathererQuadsDList ); // Draw gatherer quads. if ( drawStyle == 2 ) // Draw the outlines of the outlined fill style. { glPushAttrib( GL_ALL_ATTRIB_BITS ); glDisable( GL_LIGHTING ); glDepthFunc( GL_LEQUAL ); glDepthRange( 0.0, 1.0 - DEPTH_OFFSET ); glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); // Wireframe. glLineWidth( 1.0 ); glColor3f( 0.0f, 0.0f, 0.0f ); glCallList( gathererQuadsNoColorDList ); // Draw gatherer quads. glPopAttrib(); } glPopMatrix(); glutSwapBuffers(); stoptime = glutGet( GLUT_ELAPSED_TIME ); double fps = 1.0 / ((stoptime - starttime) / 1000.0); static char s[256]; sprintf( s, "Radiosity Viewer (%.1f FPS)", fps ); glutSetWindowTitle( s ); }
/* draw the helix shape */ void DrawStuff (void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f (0.8, 0.3, 0.6); glPushMatrix (); /* set up some matrices so that the object spins with the mouse */ glTranslatef (0.0,0.0,-120.0); glRotatef (rotate_frame[1], 1.0, 0.0, 0.0); glRotatef (rotate_frame[0], 0.0, 0.0, 1.0); //change thread, if necessary if (move_end[0] != 0.0 || move_end[1] != 0.0 || tangent_end[0] != 0.0 || tangent_end[1] != 0.0 || tangent_rotation_end[0] != 0 || tangent_rotation_end[1] != 0) { glThreads[truthThread]->ApplyUserInput(move_end, tangent_end, tangent_rotation_end); } //Draw Axes DrawAxes(); addThreadDebugInfo(); if (thread_vision_searched) { glThreads[optimizedThread]->updateThreadPoints(); } Vector3d display_start_pos = glThreads[optimizedThread]->getStartPosition(); for(int i = 0; i < NUM_THREADS_DISPLAY; i++) { //Draw Thread if (!show_threads[i]) continue; if (i==optimizedThread) { glColor4f (0.8, 0.5, 0.0, 1.0); } else if (i==truthThread) { glColor4f (0.8, 0.0, 0.0, 1.0); } else { glColor4f (0.5, 0.5, 0.5, 1.0); } glThreads[i]->display_start_pos = display_start_pos; glThreads[i]->DrawThread(); } if (thread_vision_searched) { thread_vision.display(); } glPopMatrix (); glutSwapBuffers (); }
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0,0,2, 0,0,0, 0,1,0); glLineWidth(4); DrawAxes(); DrawTriangle(); glutSolidSphere(0.5,20,20); glutSwapBuffers(); }
void OVariousObjects::DrawHorizontalObject(GLfloat size_x, GLfloat size_y, GLfloat size_z, GLfloat dist, GLfloat angle) { glEnableClientState(GL_VERTEX_ARRAY); glPushMatrix(); glTranslatef(dist*cos(angle), 0.0f, dist*sin(angle)); glRotatef(angle, 0.0f, 1.0f, 0.0f); glScalef(size_x, size_y, size_z); DrawCube(); glScalef(1.f/size_x, 1.f/size_y, 1.f/size_z); DrawAxes( ((size_x<size_z)?size_z:size_x) + size_x / 10.0f, 1.0f); glPopMatrix(); glDisableClientState(GL_VERTEX_ARRAY); }
void AxisPlot::DrawData(wxDC &dc, wxRect rc) { wxRect rcData; wxRect rcLegend; CalcDataArea(dc, rc, rcData, rcLegend); m_dataBackground->Draw(dc, rcData); DrawAxes(dc, rc, rcData); DrawDataArea(dc, rcData); DrawLegend(dc, rcLegend); }
QSGNode* Graph::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) { QSGNode* rootNode = QQuickItem::updatePaintNode(oldNode, data); if (rootNode == NULL) { rootNode = new QSGNode(); rootNode->setFlag(QSGNode::OwnedByParent, true); } else { rootNode->removeAllChildNodes(); } DrawAxes(rootNode); return rootNode; }
// main render function called by glut void OnRender() { //Calculate fps totalFrames++; int current = glutGet(GLUT_ELAPSED_TIME); float elapsedTime = float(current - startTime); static float lastfpsTime = 0.0f; if ((current - lastfpsTime) > 1000.0f) { fps = ((totalFrames * 1000.0f) / ((current - lastfpsTime))); totalFrames = 0; lastfpsTime = float(current); } startTime = current; sprintf_s(buffer, "FPS: %3.2f", fps); //Update PhysX if (gScene) { stepPhysics(elapsedTime / 1000.0f); } // start render glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0, 0, dist); glRotatef(rX, 1, 0, 0); glRotatef(rY, 0, 1, 0); //Draw the grid and axes DrawAxes(); DrawGrid(100); // draw physics objects glEnable(GL_LIGHTING); RenderPhysXScene(); glDisable(GL_LIGHTING); //Show the fps SetOrthoForFont(WINDOW_WIDTH, WINDOW_HEIGHT); glColor3f(1, 1, 1); RenderSpacedBitmapString(20, 20, 0, GLUT_BITMAP_HELVETICA_12, buffer); ResetPerspectiveProjection(); // finish render glutSwapBuffers(); }
/* draw the helix shape */ void DrawStuff (void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f (0.8, 0.3, 0.6); glPushMatrix (); /* set up some matrices so that the object spins with the mouse */ glTranslatef (0.0,0.0,-150.0); glRotatef (rotate_frame[1], 1.0, 0.0, 0.0); glRotatef (rotate_frame[0], 0.0, 0.0, 1.0); //change thread, if necessary if (move_end[0] != 0.0 || move_end[1] != 0.0 || tangent_end[0] != 0.0 || tangent_end[1] != 0.0 || tangent_rotation_end[0] != 0 || tangent_rotation_end[1] != 0) { glThreads[curThread]->ApplyUserInput(move_end, tangent_end, tangent_rotation_end); } //Draw Axes DrawAxes(); for(int i = 0; i < totalThreads; i++) { //Draw Thread if (i==0) { glColor4f (1.0, 0.0, 0.0, 0.5); } else if (i==1) { glColor4f (0.0, 1.0, 0.0, 0.5); } else if (i==2) { glColor4f (0.0, 0.0, 1.0, 0.5); } else { glColor4f (0.5, 0.5, 0.1, 0.5); } glThreads[i]->DrawThread(); if (i != just_vis_error_thread) { glThreads[i]->DrawAxes(); } } glPopMatrix (); glutSwapBuffers (); }
void QGraph::DrawGraph(QPainter &painter) { static QColor color; painter.save(); // Paint background // QBrush bg(m_BkColor); // painter.setBackground(bg); // Draw Border if(m_bBorder) color = m_BorderColor; else color = m_BkColor; QPen BorderPen(color); BorderPen.setStyle(GetStyle(m_BorderStyle)); BorderPen.setWidth(m_BorderWidth); painter.setPen(BorderPen); painter.fillRect(m_rCltRect, m_BkColor); painter.drawRect(m_rCltRect); Init(); painter.setClipRect(m_rCltRect); painter.setBackgroundMode(Qt::TransparentMode); if(m_bXMinGrid) DrawXMinGrid(painter); if(m_bYMinGrid) DrawYMinGrid(painter); if(m_bXMajGrid) DrawXMajGrid(painter); if(m_bYMajGrid) DrawYMajGrid(painter); DrawAxes(painter); DrawXTicks(painter); DrawYTicks(painter); for (int nc=0; nc < m_oaCurves.size(); nc++) DrawCurve(nc,painter); DrawTitles(painter); painter.setClipping(false); painter.restore(); }
void display(void) { int i; glClear (GL_COLOR_BUFFER_BIT); glColor3f (0.0, 0.0, 0.0); DrawAxes(); // draw grid // draw scale glColor3f (1.0, 0.0, 0.0); glBegin (drawmode); glVertex2f (x[0], y[0]); for (i = 1; i < ndata; i++) glVertex2f (x[i], y[i]); glEnd(); glFlush (); }
// Affichage de la scène void SceneSimple::Render() { ResourceManager& res = ResourceManager::getInstance(); VarManager& var = VarManager::getInstance(); DrawAxes(); glColor3f(1.0f, 0.0f, 0.0f); // DrawTraj(); glPushMatrix(); // glRotatef(m_fAngle, 0.0f, 1.0f, 0.0f); vec4 white(1.0f, 1.0f, 1.0f, 1.0f); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); vec4 pos(0.0, 0.0, 1.0, 0.0); glLightfv(GL_LIGHT0, GL_POSITION, pos); glLightfv(GL_LIGHT0, GL_AMBIENT, white); glLightfv(GL_LIGHT0, GL_DIFFUSE, white); glLightfv(GL_LIGHT0, GL_SPECULAR, white); // Ici on va activer notre texture // On pourrait accéder à notre texture via : // Texture2D* pTex = res.getTexture2D("rocks_diffuse.jpg"); // et cela éviterait d'avoir une variable de classe pour accéder à la ressource // On bind la texture en slot 0 m_pMyTex->Bind(0); // On dessine un objet glColor3f(1.0f, 0.0f, 0.0f); glutSolidTeapot(5.0); // res.getMesh("simpsons_table.obj")->Draw(); // la teapot est dessinée dans le mauvais sens, mais c'est un bug de glut, // les autres primitives sont, elles, dessinées dans le bon sens. // On la débind en slot 0 aussi m_pMyTex->Unbind(0); glPopMatrix(); }
void OTestCArm::Draw() { OQuaternion q(quat_.X(), quat_.Y(), quat_.Z(), quat_.W()); clone_avatar->matrix() = q.ToMatrix(); clone_avatar->draw(); return; glPushMatrix(); outer_ring_->DrawMesh(OSpecialMesh::THORUS); //glRotatef(angulation_, 0.0f, 1.0f, 0.0f); //glRotatef(rotation_, 1.0f, 0.0f, 0.0f); //glRotatef(dra_, 0, 0, 1); ////ComputeQuat(); OMatrix4 orient = quat_.ToMatrix(); glMultMatrixf(orient.GetSafeM()); DrawAxes(2.4f * inner_ray_); glPopMatrix(); glPushMatrix(); float temp_dra = dra_; dra_ = 0.0f; ComputeQuat(); orient = quat_.ToMatrix(); glMultMatrixf(orient.GetSafeM()); // glRotatef(angulation_, 0, 1, 0); // glRotatef(rotation_, 1, 0, 0); // glRotatef(dra_, 0, 0, 1); inner_ring_->DrawMesh(OSpecialMesh::THORUS); glTranslatef(-inner_ray_, 0.0f, 0.0f); rod_->DrawMesh(OSpecialMesh::CYLINDER); dra_ = temp_dra; glPopMatrix(); }
void MyGraph::DrawGraph(CDC& dc) { VALIDATE; ASSERT_VALID(&dc); if (GetMaxSeriesSize()) { dc.SetBkMode(TRANSPARENT); // Populate the colors as a group of evenly spaced colors of maximum // saturation. int nColorsDelta(240 / GetMaxSeriesSize()); int baseColorL = 120; int diffColorL = 60; DWORD backgroundColor = ::GetSysColor(COLOR_WINDOW); // If graph is a non-stacked line graph, use darker colors if system window color is light. #if 0 if (m_eGraphType == MyGraph::Line && !m_bStackedGraph) { int backgroundLuma = (GetRValue(backgroundColor) + GetGValue(backgroundColor) + GetBValue(backgroundColor)) / 3; if (backgroundLuma > 128) { baseColorL = 70; diffColorL = 50; } } #endif for (WORD nGroup = 0; nGroup < GetMaxSeriesSize(); ++nGroup) { WORD colorH = (WORD)(nColorsDelta * nGroup); WORD colorL = (WORD)(baseColorL+(diffColorL*(nGroup%2))); WORD colorS = (WORD)(180)+(30*((1-nGroup%2)*(nGroup%3))); COLORREF cr(MyGraph::HLStoRGB(colorH, colorL, colorS)); // Populate colors cleverly m_dwaColors.SetAtGrow(nGroup, cr); } // Reduce the graphable area by the frame window and status bar. We will // leave GAP_PIXELS pixels blank on all sides of the graph. So top-left // side of graph is at GAP_PIXELS,GAP_PIXELS and the bottom-right side // of graph is at (m_rcGraph.Height() - GAP_PIXELS), (m_rcGraph.Width() - // GAP_PIXELS). These settings are altered by axis labels and legends. CRect rcWnd; GetClientRect(&rcWnd); m_rcGraph.left = GAP_PIXELS; m_rcGraph.top = GAP_PIXELS; m_rcGraph.right = rcWnd.Width() - GAP_PIXELS; m_rcGraph.bottom = rcWnd.Height() - GAP_PIXELS; CBrush br; VERIFY(br.CreateSolidBrush(backgroundColor)); dc.FillRect(rcWnd, &br); br.DeleteObject(); // Draw graph title. DrawTitle(dc); // Set the axes and origin values. SetupAxes(dc); // Draw legend if there is one and there's enough space. if (m_saLegendLabels.GetSize() && m_rcGraph.right-m_rcGraph.left > LEGEND_VISIBILITY_THRESHOLD) { DrawLegend(dc); } else{ m_rcLegend.SetRectEmpty(); } // Draw axes unless it's a pie. if (m_eGraphType != MyGraph::PieChart) { DrawAxes(dc); } // Draw series data and labels. switch (m_eGraphType) { case MyGraph::Bar: DrawSeriesBar(dc); break; case MyGraph::Line: if (m_bStackedGraph) DrawSeriesLineStacked(dc); else DrawSeriesLine(dc); break; case MyGraph::PieChart: DrawSeriesPie(dc); break; default: _ASSERTE(! "Bad default case"); break; } } }
static void Draw_WireframeSweptBox( OverlaySweptBox_t* pBox ) { // Build a rotation matrix from angles matrix3x4_t fRotateMatrix; AngleMatrix(pBox->angles, fRotateMatrix); materialSystemInterface->Bind( g_materialWireframe ); g_materialWireframe->ColorModulate( pBox->r*(1.0f/255.0f), pBox->g*(1.0f/255.0f), pBox->b*(1.0f/255.0f) ); if (pBox->a > 0) g_materialWireframe->AlphaModulate( pBox->a*(1.0f/255.0f) ); g_materialWireframe->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, 0 ); IMesh *pMesh = materialSystemInterface->GetDynamicMesh( ); CMeshBuilder meshBuilder; meshBuilder.Begin( pMesh, MATERIAL_LINES, 30 ); Vector delta; VectorSubtract( pBox->end, pBox->start, delta ); // Compute the box points, rotated but without the origin added Vector temp; Vector pts[8]; float dot[8]; int minidx = 0; for ( int i = 0; i < 8; ++i ) { temp.x = (i & 0x1) ? pBox->maxs[0] : pBox->mins[0]; temp.y = (i & 0x2) ? pBox->maxs[1] : pBox->mins[1]; temp.z = (i & 0x4) ? pBox->maxs[2] : pBox->mins[2]; // Rotate the corner point VectorRotate( temp, fRotateMatrix, pts[i]); // Find the dot product with dir dot[i] = DotProduct( pts[i], delta ); if (dot[i] < dot[minidx]) minidx = i; } // Choose opposite corner int maxidx = minidx ^ 0x7; // Draw the start + end axes... DrawAxes( pBox->start, pts, minidx, meshBuilder ); DrawAxes( pBox->end, pts, maxidx, meshBuilder ); // Draw the extrusion faces for (int j = 0; j < 3; ++j ) { int dirflag1 = ( 1 << ((j+1)%3) ); int dirflag2 = ( 1 << ((j+2)%3) ); int idx1, idx2, idx3; idx1 = (minidx & dirflag1) ? minidx - dirflag1 : minidx + dirflag1; idx2 = (minidx & dirflag2) ? minidx - dirflag2 : minidx + dirflag2; idx3 = (minidx & dirflag2) ? idx1 - dirflag2 : idx1 + dirflag2; DrawExtrusionFace( pBox->start, pBox->end, pts, idx1, idx3, meshBuilder ); DrawExtrusionFace( pBox->start, pBox->end, pts, idx2, idx3, meshBuilder ); } meshBuilder.End(); pMesh->Draw(); }
/* draw the helix shape */ void DrawStuff (void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f (0.8, 0.3, 0.6); glPushMatrix (); /* set up some matrices so that the object spins with the mouse */ glTranslatef (0.0,0.0,-150.0); glRotatef (rotate_frame[1], 1.0, 0.0, 0.0); glRotatef (rotate_frame[0], 0.0, 0.0, 1.0); if (move_end[0] != 0.0 || move_end[1] != 0.0 || tangent_end[0] != 0.0 || tangent_end[1] != 0.0 || tangent_rotation_end[0] != 0 || tangent_rotation_end[1] != 0 || move_start[0] != 0.0 || move_start[1] != 0.0 || tangent_start[0] != 0.0 || tangent_start[1] != 0.0 || tangent_rotation_start[0] != 0 || tangent_rotation_start[1] != 0) { glThreads[curThread]->ApplyUserInput(move_end, tangent_end, tangent_rotation_end, move_start, tangent_start, tangent_rotation_start); } // draw planner end points if(drawTree) { DrawRRT(); } //Draw Axes DrawAxes(); for(int i = 0; i < totalThreads; i++) { if ( !initialized && i != planThread && i != endThread ) continue; if ( initialized && i!=startThread && i != planThread && i != endThread && i != 4 && i != 5 && i != 6 && i != 7 ) continue; glThreads[i]->DrawAxes(); //Draw Thread if (i==curThread) { glColor3f (0.8, 0.4, 0.0); } else if (i==planThread) { glColor3f (0.2, 0.8, 0.2); } else if (i==startThread) { glColor3f (0.25, 0.55, 1.0); } else if (i==endThread) { glColor3f (0.8, 0.2, 0.2); } else if (i==newRRTNodeThread) { glColor3f (0.2, 0.2, 0.8); } else if (i==7) { glColor3f (0.4, 0.4, 0.7); } else { glColor3f (0.5, 0.5, 0.1); } glThreads[i]->DrawThread(); } for(int i = 0; i < numApprox; i++) { if ( !initialized && !threadSet ) continue; apprxThreads[i]->DrawAxes(); //Draw Thread if (i % 7 == 0) { glColor3f (0.8, 0.4, 0.0); } else if (i % 7 ==1) { glColor3f (0.2, 0.8, 0.2); } else if (i % 7 ==2) { glColor3f (0.25, 0.55, 1.0); } else if (i % 7 ==3) { glColor3f (0.8, 0.2, 0.2); } else if (i % 7==4) { glColor3f (0.2, 0.2, 0.8); } else if (i % 7==5) { glColor3f (0.4, 0.4, 0.7); } else { glColor3f (0.5, 0.5, 0.1); } apprxThreads[i]->DrawThread(); } glPopMatrix (); glutSwapBuffers (); }
// main render function called by glut void OnRender() { //Calculate fps totalFrames++; int current = glutGet(GLUT_ELAPSED_TIME); float elapsedTime = float(current - startTime); static float lastfpsTime = 0.0f; if ((current - lastfpsTime) > 1000.0f) { fps = ((totalFrames * 1000.0f) / ((current - lastfpsTime))); totalFrames = 0; lastfpsTime = float(current); } startTime = current; sprintf_s(buffer, "FPS: %3.2f", fps); //Update PhysX if (gScene) { stepPhysics(elapsedTime / 1000.0f); } // start render glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0, 0, dist); glRotatef(rX, 1, 0, 0); glRotatef(rY, 0, 1, 0); // shoot if (shoot) { GLdouble matModelView[16], matProjection[16]; GLdouble camera_pos[3]; int viewport[4]; // get matrixs and viewport: glGetDoublev(GL_MODELVIEW_MATRIX, matModelView); glGetDoublev(GL_PROJECTION_MATRIX, matProjection); glGetIntegerv(GL_VIEWPORT, viewport); gluUnProject((viewport[2] - viewport[0]) / 2, (viewport[3] - viewport[1]) / 2, 0.0, matModelView, matProjection, viewport, &camera_pos[0], &camera_pos[1], &camera_pos[2]); //PxVec3 p(camera_pos[0], camera_pos[1], camera_pos[2]); //AddBullet(p, -p.getNormalized() * 10.0f); shoot = false; // //GLdouble mpos[3]; //gluUnProject(oldX, oldY, 0, // matModelView, // matProjection, viewport, &mpos[0], &mpos[1], &mpos[2]); GLfloat winX, winY, winZ; //variables to hold screen x,y,z coordinates GLdouble worldX, worldY, worldZ; //variables to hold world x,y,z coordinates winX = (float)(viewport[2] - viewport[0]) / 2; winY = (float)(viewport[3] - viewport[1]) / 2; glReadPixels(winX, winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ); //get the world coordinates from the screen coordinates gluUnProject(winX, winY, 0.0, matModelView, matProjection , viewport, &worldX, &worldY, &worldZ); GLdouble fx, fy, fz; gluUnProject(winX, winY, 1.0, matModelView, matProjection , viewport, &fx, &fy, &fz); PxVec3 pp(worldX, worldY, worldZ); PxVec3 vv(fx - worldX, fy - worldY, fz - worldZ); AddBullet(pp, vv.getNormalized() * 10.0f); } //Draw the grid and axes DrawAxes(); DrawGrid(100); // draw physics objects glEnable(GL_LIGHTING); RenderPhysXScene(); glDisable(GL_LIGHTING); //Show the fps SetOrthoForFont(WINDOW_WIDTH, WINDOW_HEIGHT); glColor3f(1, 1, 1); RenderSpacedBitmapString(20, 20, 0, GLUT_BITMAP_HELVETICA_12, buffer); ResetPerspectiveProjection(); // finish render glutSwapBuffers(); }
void CHostageImprov::UpdatePosition(float deltaT) { CNavArea *area = TheNavAreaGrid.GetNavArea(&m_hostage->pev->origin); if (area != NULL) { m_lastKnownArea = area; } DrawAxes(m_moveGoal, 255, 255, 0); if (IsJumping()) { Vector dir; const float pushSpeed = 100.0f; if (!m_hasJumped) { m_hasJumped = true; m_hasJumpedIntoAir = false; m_hostage->pev->velocity.z += 300.0f; } else ResetJump(); dir = m_jumpTarget - GetFeet(); dir.z = 0; #ifndef PLAY_GAMEDLL // TODO: fix test demo dir.NormalizeInPlace(); m_hostage->pev->velocity.x = dir.x * pushSpeed; m_hostage->pev->velocity.y = dir.y * pushSpeed; #else Vector vecRet = NormalizeMulScalar<float_precision, float_precision, float_precision, float>(dir, pushSpeed); m_hostage->pev->velocity.x = vecRet.x; m_hostage->pev->velocity.y = vecRet.y; #endif m_hostage->SetBoneController(0); m_hostage->SetBoneController(1); FaceTowards(m_jumpTarget, deltaT); return; } if (m_isLookingAt) { Vector angles = UTIL_VecToAngles(m_viewGoal - GetEyes()); float_precision pitch = angles.x - m_hostage->pev->angles.x; float_precision yaw = angles.y - m_hostage->pev->angles.y; while (yaw > 180.0f) yaw -= 360.0f; while (yaw < -180.0f) yaw += 360.0f; while (pitch > 180.0f) pitch -= 360.0f; while (pitch < -180.0f) pitch += 360.0f; m_hostage->SetBoneController(0, yaw); m_hostage->SetBoneController(1, -pitch); if (IsAtMoveGoal() && !HasFaceTo()) { if (yaw < -45.0f || yaw > 45.0f) { FaceTowards(m_viewGoal, deltaT); } } } else { m_hostage->SetBoneController(0); m_hostage->SetBoneController(1); } if (HasFaceTo() && FaceTowards(m_faceGoal, deltaT)) ClearFaceTo(); if (!IsAtMoveGoal() || m_path.GetSegmentCount() > 0) { if (m_path.GetSegmentCount() <= 0) { HostagePathCost pathCost; if (m_path.Compute(&GetFeet(), &m_moveGoal, pathCost)) { m_follower.SetPath(&m_path); m_follower.SetImprov(this); m_follower.Reset(); m_follower.Debug(cv_hostage_debug.value > 0.0); } } m_follower.Update(deltaT, m_inhibitObstacleAvoidance.IsElapsed()); if (m_moveType == Stopped) { m_follower.ResetStuck(); } if (m_follower.IsStuck()) { Wiggle(); } } const float friction = 3.0f; m_vel.x += m_vel.x * -friction * deltaT; m_vel.y += m_vel.y * -friction * deltaT; float_precision speed = m_vel.NormalizeInPlace(); const float maxSpeed = 285.0f; if (speed > maxSpeed) { speed = maxSpeed; } m_vel.x = m_vel.x * speed; m_vel.y = m_vel.y * speed; KeepPersonalSpace spacer(this); ForEachPlayer(spacer); if (g_pHostages != NULL) { g_pHostages->ForEachHostage(spacer); } m_hostage->pev->velocity.x = m_vel.x; m_hostage->pev->velocity.y = m_vel.y; m_moveFlags = 0; }
void AxesDrawable::draw() { DrawAxes(); }