GLam Collection version 0.4 - | ACCUEIL - CLASSES - HIERARCHIE - MEMBRES - EXEMPLES |
delta
dans l'intervalle -6 ... +6.
// attributs GLamCylinder* axe20x80 ; GLamCylinder* axe30x80 ; GLamRevolution* axe40x80 ; GLamTesselation* br10 ; GLamTesselation* br11 ; GLamPolygon* br12 ; GLamGroup* bras1 ; GLamTesselation* br20 ; GLamGroup* bras2 ; GLamTesselation* dg1 ; GLamCube* dg2 ; GLamGroup* doigt ; GLamTesselation* ca1 ; GLamCube* ca2 ; GLamGroup* carter ; GLamTesselation* pi1 ; GLamCube* pi2 ; GLamCylinder* pi3 ; GLamGroup* piston ; GLamTesselation* co1 ; GLamRevolution* co2 ; GLamCircularHole* co3 ; GLamGroup* corps ; double delta ; // construction delta = 0 ; // axe 2.0 x 8.0 axe20x80 = new GLamCylinder(2, 8 ) ; axe20x80->setSimpleColor( false ) ; // axe 3.0 x 8.0 axe30x80 = new GLamCylinder(3, 8 ) ; axe30x80->setSimpleColor( false ) ; // axe 4.0 x 8.0 double ptsax1[] = { 0,-4, 1.75,-4, 2,-3.75, 2,3.75, 1.75,4, 0,4 } ; axe40x80 = new GLamRevolution( ptsax1, 6, 90 ) ; axe40x80->setSimpleColor( false ) ;
// bras 1 double ptsbr10[] = { 4,-7, 8,-3, 51,-3, 53,-1, 53,1, 51,3, -1,3, -4,0, -4,-7 } ; br10 = new GLamTesselation( ptsbr10, 9, 4 ) ; br10->addCircularHole( 0, 0, 1.5 ) ; br10->addCircularHole( 50, 0, 1.5 ) ; double ptsbr11[] = { -4,-7, -4,-23, -3,-24, -2,-24, -2,-18, 0,-16, 2,-18, 2,-24, 3,-24, 4,-23, 4,-7 } ; br11 = new GLamTesselation( ptsbr11, 11, 2 ) ; double ptsbr12[] = { 0,-11, 0,-7, -2,-7, 0,-11 } ; br12 = new GLamPolygon( ptsbr12, 4, 8 ) ; bras1 = new GLamGroup ; int ibr10 = bras1->addObject( br10 ) ; int ibr11 = bras1->addObject( br11 ) ; int ibr12 = bras1->addObject( br12 ) ; bras1->addObjectTranslate( ibr10, 0, 0, -2 ) ; bras1->addObjectTranslate( ibr11, 0, 0, -2 ) ; bras1->addObjectRotate( ibr12, 0, 90, 0 ) ; bras1->addObjectTranslate( ibr12, 0, 0, -4 ) ; bras1->setColor(0.8, 0.1, 0.1 ) ;
// bras 2 double ptsbr20[] = { -1,-3, 51,-3, 53,-1, 53,1, 51,3, -1,3, -3,1, -3,-1 } ; br20 = new GLamTesselation( ptsbr20, 8, 4 ) ; br20->addCircularHole( 0, 0, 1.5 ) ; br20->addCircularHole( 50, 0, 1.5 ) ; br20->setColor(0.1, 0.1, 0.8 ) ; bras2 = new GLamGroup ; int ibr20 = bras2->addObject( br20 ) ; bras2->addObjectTranslate(ibr20, 0, 0, -2 ) ;
//doigt double ptsdg1[] = { 0,-3.5, 10,-3.5, 10,0, 2,11, -1,11, -3,9, -3,-1 } ; dg1 = new GLamTesselation( ptsdg1, 7, 1 ) ; dg1->addCircularHole( 0, 0, 1.5 ) ; dg1->addCircularHole( 0, 8, 1.5 ) ; dg2 = new GLamCube( 10, 2, 7 ) ; doigt = new GLamGroup ; int idg10 = doigt->addObject( dg1 ) ; int idg11 = doigt->addObject( dg1 ) ; int idg2 = doigt->addObject( dg2 ) ; doigt->addObjectTranslate( idg10, 0, 0, -3.5 ) ; doigt->addObjectTranslate( idg11, 0, 0, 2.5 ) ; doigt->addObjectTranslate( idg2, 5, -4.5, -3.5 ) ; doigt->setColor(0.1, 0.6, 0.1 ) ; int idg30 = doigt->addObject( axe30x80 ) ; int idg31 = doigt->addObject( axe30x80 ) ; doigt->addObjectTranslate( idg30, 0, 0, -4 ) ; doigt->addObjectTranslate( idg31, 0, 8, -4 ) ;
// carter double ptsca1[] = { -3,4, 27,4, 29,2, 29,0, 31,0, 31,17, 21,31, 16.5,31, 3,12, -3,12 } ; ca1 = new GLamTesselation( ptsca1, 10, 1 ) ; ca1->addCircularHole( 19, 20, 1.5 ) ; ca1->addCircularHole( 19, 28, 1.5 ) ; ca1->addCircularHole( 0, 6, 1 ) ; ca1->addCircularHole( 0, 10, 1 ) ; ca1->setColor(0.7, 0.1, 0.8, true ) ; ca2 = new GLamCube(1, 24, 5 ) ; ca2->setColor(0.7, 0.1, 0.8, true ) ; carter = new GLamGroup ; int ica10 = carter->addObject( ca1 ) ; carter->addObjectTranslate( ica10, 0, 0, -3.5 ) ; int ica11 = carter->addObject( ca1 ) ; carter->addObjectRotate( ica11, 180, 0, 0 ) ; carter->addObjectTranslate( ica11, 0, 0, 2.5 ) ; // partie à commenter pour voir l'articulation... int ica12 = carter->addObject( ca1 ) ; carter->addObjectTranslate( ica12, 0, 0, 2.5 ) ; int ica13 = carter->addObject( ca1 ) ; carter->addObjectRotate( ica13, 180, 0, 0 ) ; carter->addObjectTranslate( ica13, 0, 0, -3.5 ) ; // int ica20 = carter->addObject( ca2 ) ; carter->addObjectTranslate( ica20, 30.5, 0, -2.5 ) ; int ica30 = carter->addObject( axe30x80 ) ; carter->addObjectTranslate( ica30, 19, 20, -4 ) ; int ica31 = carter->addObject( axe30x80 ) ; carter->addObjectTranslate( ica31, 19, 28, -4 ) ; int ica32 = carter->addObject( axe30x80 ) ; carter->addObjectTranslate( ica32, 19, -20, -4 ) ; int ica33 = carter->addObject( axe30x80 ) ; carter->addObjectTranslate( ica33, 19, -28, -4 ) ; int ica40 = carter->addObject( axe20x80 ) ; carter->addObjectTranslate( ica40, 0, 6, -4 ) ; int ica41 = carter->addObject( axe20x80 ) ; carter->addObjectTranslate( ica41, 0, 10, -4 ) ; int ica42 = carter->addObject( axe20x80 ) ; carter->addObjectTranslate( ica42, 0, -6, -4 ) ; int ica43 = carter->addObject( axe20x80 ) ; carter->addObjectTranslate( ica43, 0, -10, -4 ) ;
// piston double ptspi1[] = { -6,-3.5, 1.5,-3.5, 3,-2, 3,2, 1.5,3.5, -6,3.5 } ; pi1 = new GLamTesselation( ptspi1, 6, 1 ) ; pi1->addCircularHole( 0, 0, 2.0 ) ; pi2 = new GLamCube( 3, 7, 7 ) ; pi3 = new GLamCylinder( 4, 32 ) ; piston = new GLamGroup ; int ipi10 = piston->addObject( pi1 ) ; int ipi11 = piston->addObject( pi1 ) ; int ipi2 = piston->addObject( pi2 ) ; int ipi3 = piston->addObject( pi3 ) ; piston->addObjectTranslate( ipi10, 0, 0, -3.5 ) ; piston->addObjectTranslate( ipi11, 0, 0, 2.5 ) ; piston->addObjectTranslate( ipi2, -7.5, 0, -3.5 ) ; piston->addObjectRotate( ipi3, 0, -90, 0 ) ; piston->addObjectTranslate( ipi3, 0, 0, 9 ) ; piston->setColor(1.0, 0.6, 0.4, true ) ; piston->addObject( axe40x80 ) ; axe40x80->setSimpleColor( false ) ;
// corps co1 = new GLamTesselation( GLamCube(6, 8, 5 ) ) ; co1->addCircularHole( 0, -2, 1 ) ; co1->addCircularHole( 0, 2, 1 ) ; double ptsco2[] = { 2,0, 14,0, 14,26, 2,26 } ; co2 = new GLamRevolution( ptsco2, 4, 12 ) ; co3 = new GLamCircularHole( 4, 26, 90 ) ; corps = new GLamGroup ; int ico10 = corps->addObject( co1 ) ; int ico11 = corps->addObject( co1 ) ; int ico2 = corps->addObject( co2 ) ; int ico3 = corps->addObject( co3 ) ; corps->addObjectTranslate( ico10, 0, 8, -2.5 ) ; corps->addObjectTranslate( ico11, 0, -8, -2.5 ) ; corps->addObjectRotate( ico2, 0, -90, 0 ) ; corps->addObjectTranslate( ico2, 0, 0, 3 ) ; corps->addObjectRotate( ico3, 0, -90, 0 ) ; corps->addObjectTranslate( ico3, 0, 0, 3 ) ; corps->setShiny() ;
// projection sur la scène glPushMatrix() ; glScaled(0.1, 0.1, 0.1 ) ; glPushMatrix() ; glTranslated(-19, 0, 0 ) ; corps->draw() ; carter->draw() ; glPopMatrix() ; glPushMatrix() ; glTranslated( delta, 0, 0 ) ; piston->draw() ; glPopMatrix() ; double alpha = atan( delta / 20 ) ; double x = 50.0 * cos( alpha ) ; double y = 50.0 * sin( alpha ) + 20 ; alpha = alpha * 180.0 / Pi ; glPushMatrix() ; glTranslated( 0, 20, 0 ) ; glRotated(alpha, 0, 0, 1 ) ; bras1->draw() ; glPopMatrix() ; glPushMatrix() ; glTranslated( 0, -20, 0 ) ; glRotated(180, 1, 0, 0 ) ; glRotated(alpha, 0, 0, 1 ) ; bras1->draw() ; glPopMatrix() ; glPushMatrix() ; glTranslated( 0, 28, 0 ) ; glRotated(alpha, 0, 0, 1 ) ; bras2->draw() ; glPopMatrix() ; glPushMatrix() ; glTranslated( 0, -28, 0 ) ; glRotated(180, 1, 0, 0 ) ; glRotated(alpha, 0, 0, 1 ) ; bras2->draw() ; glPopMatrix() ; glPushMatrix() ; glTranslated( x, y, 0 ) ; doigt->draw() ; glPopMatrix() ; glPushMatrix() ; glTranslated( x, -y, 0 ) ; glRotated(180, 1, 0, 0 ) ; doigt->draw() ; glPopMatrix() ; glPopMatrix() ; |