コード例 #1
0
ファイル: glwidget.OLD.cpp プロジェクト: SeregaGomen/QFEM
void GLWidget::createTRPObject(void)
{
    if (!pObj->GetX().Size()) return;


    if (isBuild) glDeleteLists(xList, 1);
    xList = glGenLists(1);
    glNewList (xList, GL_COMPILE);

    switch (pObj->GetType())
    {
        case FE1D_2:
            draw1D();
            break;
        case FE2D_3:
        case FE2D_6:
        case FE2D_4:
            draw2D();
            break;
        case FE3D_4:
        case FE3D_10:
        case FE3D_8:
            draw3D();
            break;
        default:
            break;
    }
    glEndList();

    isBuild = true;
}
コード例 #2
0
ファイル: maze.c プロジェクト: GNOME/gcompris
static gint key_press_3D(guint keyval, gchar *commit_str, gchar *preedit_str)
{
  switch (keyval)
    {
    case GDK_Left: viewing_direction=TURN_LEFT(viewing_direction);
      gc_sound_play_ogg ("sounds/grow.wav", NULL);
      break;
    case GDK_Right: viewing_direction=TURN_RIGHT(viewing_direction);
      gc_sound_play_ogg ("sounds/grow.wav", NULL);
      break;
    case GDK_Up: one_step(viewing_direction);
      break;
    case GDK_Down:
      viewing_direction=TURN_RIGHT(viewing_direction);
      viewing_direction=TURN_RIGHT(viewing_direction);
      gc_sound_play_ogg ("sounds/grow.wav", NULL);
      break;
    case GDK_2:
    case GDK_space:
      /* Display a warning that you can't move there */
      g_object_set (warning_item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
      twoDdisplay();
      return TRUE;
    case GDK_E: case GDK_e: eye_pos_y+=0.1; if (eye_pos_y>0.9) eye_pos_y=0.9; break;
    case GDK_X: case GDK_x: eye_pos_y-=0.1; if (eye_pos_y<-0.9) eye_pos_y=-0.9; break;
    case GDK_D: case GDK_d: eye_pos_x+=0.1; if (eye_pos_x>0.9) eye_pos_x=0.9; break;
    case GDK_S: case GDK_s: eye_pos_x-=0.1; if (eye_pos_x<-0.9) eye_pos_x=-0.9; break;
    case GDK_Y: case GDK_y: case GDK_Z: case GDK_z: eye_pos_z+=0.1; break;
    case GDK_R: case GDK_r: eye_pos_z-=0.1; if (eye_pos_z<-0.9) eye_pos_z=-0.9; break;
    default: return FALSE;
    }
  update_tux(viewing_direction);
  draw3D();
  return TRUE;
}
コード例 #3
0
ファイル: asciifile.cpp プロジェクト: LibreCAD/LibreCAD
void dibPunto::procesFile(Document_Interface *doc)
{
    QString sep;
    QMessageBox::information(this, "Info", "dibpunto procesFile");
    currDoc = doc;

//Warning, can change adding or reordering "formatedit"
    QString::SplitBehavior skip = QString::KeepEmptyParts;
    switch (formatedit->currentIndex()) {
    case 0:
        sep = " ";
        break;
    case 3:
        sep = " ";
        skip = QString::SkipEmptyParts;
        break;
    case 2:
        sep = ",";
        break;
    default:
        sep = "\t";
    }
    if (!QFile::exists(fileedit->text()) ) {
        QMessageBox::critical ( this, "DibPunto", QString(tr("The file %1 not exist")).arg(fileedit->text()) );
        return;
    }
    QFile infile(fileedit->text());
    if (!infile.open(QIODevice::ReadOnly | QIODevice::Text)) {
        QMessageBox::critical ( this, "DibPunto", QString(tr("Can't open the file %1")).arg(fileedit->text()) );
         return;
    }

//Warning, can change adding or reordering "formatedit"
    if (formatedit->currentIndex() == 4)
        procesfileODB(&infile, sep);
    else
        procesfileNormal(&infile, sep, skip);
    infile.close ();
    QString currlay = currDoc->getCurrentLayer();

    if (pt2d->checkOn() == true)
        draw2D();
    if (pt3d->checkOn() == true)
        draw3D();
    if (ptelev->checkOn() == true)
        drawElev();
    if (ptnumber->checkOn() == true)
        drawNumber();
    if (ptcode->checkOn() == true)
        drawCode();

    currDoc->setLayer(currlay);
    /* draw lines in current layer */
    if ( connectPoints->isChecked() )
        drawLine();

    currDoc = NULL;

}
コード例 #4
0
ファイル: draw.c プロジェクト: te-bachi/cgr
void draw_screen( ) {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);             // Clear the screen and the depth buffer
    
    draw3D();
    countFrames();
    
    SDL_GL_SwapBuffers( );                                          // Swap the buffers
}
コード例 #5
0
/* Calls the 3d and 2d drawing functions */
void Engine::draw()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    draw3D();
    draw2D();
    
    SDL_GL_SwapBuffers();
}
コード例 #6
0
ファイル: maze.c プロジェクト: GNOME/gcompris
static void
threeDdisplay()
{
  gc_sound_play_ogg ("sounds/flip.wav", NULL);
  gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
		    "maze/maze-bg.svgz");
  g_object_set (boardRootItem, "visibility",
		GOO_CANVAS_ITEM_INVISIBLE, NULL);
  threeDactive=TRUE;
  draw3D();
}
コード例 #7
0
void XlGLDisplay::paintGL()
{
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	if (currentRenderMode == RENDER_IMAGE) {
		if ( !(this->textureGenerated))
		{
			initializeTexture();
		}
		drawImage();
	}
	else if(currentRenderMode == RENDER_3D) {
		draw3D();
	}
}
コード例 #8
0
ファイル: GFont.cpp プロジェクト: jackpoz/G3D-backup
Vector2 GFont::draw3DBillboard
   (RenderDevice*               renderDevice,
    const String&               s,
    const Vector3&              pos3D,
    float                       size,
    const Color4&               color,
    const Color4&               border,
    XAlign                      xalign,
    YAlign                      yalign,
    Spacing                     spacing) const {

    const CFrame& camera = renderDevice->cameraToWorldMatrix();
    const CFrame& object = renderDevice->objectToWorldMatrix();
    
    const CFrame cframe(camera.rotation * object.rotation.transpose(), pos3D);
    return draw3D(renderDevice, s, cframe, size, color, border, xalign, yalign, spacing);
}
コード例 #9
0
void EnsancheModelBuildingAdv::draw(int drawMode, bool bDrawWOffset)
{
	if( drawMode == MODEL_DRAW_MODE_3D ) draw3D( bDrawWOffset );
	else								 draw2D( bDrawWOffset );
}
コード例 #10
0
ファイル: testGl1.cpp プロジェクト: tmtmazum/glVeteran
void handleGameDisplay()
{
    
    if(Mouse.buttonsPressed & MouseAB::MMB) { Cam.translateXYZ( MouseDiff ); }
    else if(Mouse.buttonsPressed & MouseAB::LMB) { Cam.rotateXYZ( MouseDiff ); }
    else if(Mouse.buttonsPressed & MouseAB::RMB) { Cam.scaleXYZ( MouseDiff ); }
    else
    { // smooth effect
	if(Mouse.buttonsPressed & MouseAB::MMB) { Cam.translateXYZ( MouseDiff ); }
	if(Mouse.buttonsPressed & MouseAB::LMB) { Cam.rotateXYZ( MouseDiff ); }
	if(Mouse.buttonsPressed & MouseAB::RMB) { Cam.scaleXYZ( MouseDiff ); }
    
	if(Mouse.buttonsPressed == 0)
	{
	    // Still keep transitioning a while even after all buttons 
	    // have been released
	    switch(Mouse.lastButton)
	    {
		case MouseAB::LMB: Cam.rotateXYZ( MouseDiff ); break;
		// case 1: Cam.rotateXYZ( MouseDiff ); break;
		case MouseAB::RMB: Cam.scaleXYZ( MouseDiff ); break;
	    }
	    Util::moderateDivEq( &MouseDiff.X , 0.007 );
	    Util::moderateDivEq( &MouseDiff.Y , 0.007 );
	}
	if(Mouse.buttonsPressed==0 && Cam.Eye.theta > (PI/2))
	{
	    float nw_angle = Cam.Eye.theta - (PI/2);
	    nw_angle /= (PI/2);
	    Util::moderateDivEq( &MouseDiff.X , 0.007 );
	    // moderateDivEq( &nw_angle, 0.07*((PI/2) -nw_angle) );
	    nw_angle *= (PI/2);
	    // moderateMinusEq( &nw_angle, 0.07*nw_angle );
	    Cam.Eye.theta = (PI/2 + nw_angle);
	}
    }
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    
    if(line_selected)
    {
	glLineWidth( 2.0 );
	Colors::Orange.get();
    }
    WO line_1;
    line_1.setGeometry( GO::CUBE , 0.4 , 0.4 , 0.0 , END_F );
    line_1.set( WO::POSITION , 0.0 , 0.0 , 0.0 , END_F );
    
    glStencilOp( GL_KEEP , GL_KEEP , GL_REPLACE );
    glStencilFunc( GL_ALWAYS , 1 , -1 );
    glEnable( GL_STENCIL_TEST );
    // draw3D( line_1 );
    glDisable( GL_STENCIL_TEST );
    
    glLineWidth( 1.0 );

    Cam.update();	// --- Apply 3D transform
    
    
    Lights.setCenter( Cam.Center );
    // Lights.setMode(2);
    WO lit1;
    lit1.setGeometry( GO::LIGHT_RADIAL , 0.0  , 1.0 + chVar.Y/10, END_F );
    lit1.set( WO::POSITION , Cam.Center.X , Cam.Center.Y , Cam.Center.Z - 0.1, END_F );
    lit1.set( WO::COLOR , 1.0 , 1.0 , 1.0 , 1.0 , END_F );
    lit1.set( WO::SCALE , scale );
    draw3D( lit1 );
    /*
    glColor4f( 0.1 , 1.0 , 0.1 , 0.95 );
    glShadeModel( GL_SMOOTH );
    // glEnable( GL_NORMALIZE );
    glBegin( GL_TRIANGLE_STRIP );
	glColor4f( 0.3 , 0.3 , 0.3 , 0.9 );
	glNormal3f( 0.0 , 0.0 , 1.0 );
	    glVertex3f( 0.7 , -0.3 , 0.3 );
	glNormal3f( 0.0 , 1.0 , 0.0 );
	    glVertex3f( 0.7 , 0.3 , 0.3 );
	glColor4f( 0.0 , 0.0 , 0.0 , 0.9 );
	glNormal3f( 1.0 , 0.0 , 0.0 );
	    glVertex3f( -0.7 , -0.3 , 0.3 );
	glNormal3f( 0.0 , 0.0 , 0.0 );
	    glVertex3f( -0.7 , 0.3 , 0.3 );
    glEnd();
    */
    WO single;
    single.setGeometry( GO::FACE_BOTTOM , END_F );
    // single.setGeometry( GO::FACE_BOTTOM , 13.0 , END_F );
    single.set( WO::POSITION , translate.X , translate.Y , translate.Z , END_F );
    single.set( WO::NP_SCALE , npScale.X , npScale.Y , npScale.Z , END_F );
    single.set( WO::ROTATION , rotates.X*PI*10 , rotates.Y*PI*10 , END_F );
    // single.set( WO::ROTATION , 0.0 , PI/2 , END_F );
    single.set( WO::SCALE , scale );
    single.set( WO::COLOR , 1.0 , 1.0 , 1.0 , END_F );
    /*
	    glEnable( GL_LINE_STIPPLE );
	    unsigned short pattern = 43690;
	    glLineStipple(5 , pattern);
    */
    glPolygonMode( GL_FRONT_AND_BACK , GL_FILL );
    
    single.set( WO::TILING_FACTOR , 5.0 , 5.0 , END_F );
    TM->activate( ((int)chVar.Y) % TM->tile_count );
    //T2->enable();
    draw3D( single );
    TM->deactivate();
    
    WO wall1;
    wall1.setGeometry( GO::FACE , END_F );
    wall1.set( WO::POSITION , 0.45 , 0.5 , 0.2 , END_F );
    wall1.set( WO::SCALE , 0.5 , END_F );
    wall1.set( WO::ROTATION , 0.0 , PI/8 , END_F );
    wall1.set( WO::TILING_FACTOR , 5.0 , 5.0 , END_F );
    TM->activate(1);
    // draw3D( wall1 );
    TM->deactivate();
    
    
    WO wall2;
    wall2.setGeometry( GO::V_WALL , 0.5 ,	// height 
		       0.5 , 0.5 , 0.0 , 	// p1
		       0.5 , 0.0 , 0.0 , 	// p2
		       0.5 , -0.5 , 0.0 , 	// p3
				END_F );
    wall2.set( WO::TILING_FACTOR , 5.0 , 5.0 , END_F );
    
    TM->activate(1);
    draw3D( wall2 );
    TM->deactivate();
    
    
    
    wall1.set( WO::POSITION , 0.45 , 0.1 , 0.2 , END_F );
    TM->activate(1);
    // draw3D( wall1 );
    TM->deactivate();
    
    WO p_body;
    p_body.setGeometry( GO::CYLINDER , 10.0 , END_F );
    p_body.set( WO::POSITION , 0.0 , 0.0 , 0.2 , END_F );
    p_body.set( WO::SCALE , 0.04 , END_F );
    p_body.set( WO::NP_SCALE , 1.0 , 1.0 , 2.0 , END_F );
    p_body.set( WO::ROTATION , 0.0 , 0.1*chVar.Y, END_F );
    p_body.set( WO::TILING_FACTOR , 0.5 , 0.5, END_F );
    DEBUG("chVar.X",chVar.X);
    TM->activate(3);
    // draw3D( p_body );
    draw3D( p_body );
    
    p_body.set( WO::SCALE , 0.024 , END_F );
    p_body.set( WO::NP_SCALE , 0.5 , 0.7 , 2.0 , END_F );
    p_body.set( WO::POSITION , -0.035 , 0.0 , 0.08 , END_F );
    
    draw3D( p_body );
    
    p_body.set( WO::POSITION , 0.035 , 0.0 , 0.08 , END_F );
    draw3D( p_body );
    
    TM->deactivate();
    
    WO p_head;
    p_head.setGeometry( GO::SPHERE , 10.0 , 10.0 , END_F );
    p_head.set( WO::POSITION , 0.0 , 0.0 , 0.5 , END_F );
    p_head.set( WO::SCALE , 0.04 , END_F );
    
    TM->activate(3);
    draw3D( p_head );
    TM->deactivate();
    
    
    // T2->disable();
    
    single.setGeometry( GO::CUBE , END_F );
    single.set( WO::SCALE , 0.1 , END_F );
    static FrameEval FE;
    float y_val = 1.0;//*FE('a',1.0,FrameEval::INCR_TO_QUADRATIC,10.0,100,-500);
    single.set( WO::NP_SCALE , 1.0 , y_val , 1.0, END_F );
    single.set( WO::POSITION , 0.0 , 0.0 , 0.1 , END_F );
    single.set( WO::COLOR , 0.5 , 0.5 , 0.1 , END_F );
    /*
  
    LineManip L;
    L.state = LineManip::VISIBLE;
    if( ls ) L.state = LineManip::OVER;
    L.pos = PosXYZ( 0 , y_val*0.6 , -1.0*0.6);
    L.orientation = 0;
    
ManipManager MM;
    MM.add( &single );
    MM.draw();
*/
    /*
    setTransforms3D( single );
    draw3D_pure( single );
    
    Stencil::setMode( Stencil::SET_PICK_ID );
    Stencil::setWriteValue( 3 );
    draw3D_pure( L );
    Stencil::disable();
    
    resetTransforms3D( single );
    */
    
    // draw3D( single );
    // draw3D( single );
    // draw3D_pure( single , true );
    	//    glDisable( GL_LINE_STIPPLE );

    glutSwapBuffers();

}	// REQUIRED