Recent Posts

Pages: [1] 2 3 ... 7
1
Mechanical Engineering Discussions / institut de massage lyon
« Last post by BufordTarr on May 22, 2017, 06:06:38 PM »
Depuis cette epoque jusqu'a l'invention de l'imprimerie, il faut convenir qu'au point institut de massage lyon vue de l'exactitude les chroniqueurs qui ont vecu dans l'intervalle se presentent a la posterite dans des conditions exceptionnellement defavorables. Je reconnais, disait-il, le mouvement d'opinion en France; je reconnais le chagrin, la colere qui, a l'occasion du traite du 15 juillet, se sont reveilles et ont reveille des souvenirs, des preventions, des sentiments qui semblaient endormis. A cette sous-classe la plus recente, appartient l'homme lui-meme, car il presente dans son organisation toutes les particularites qui distinguent les Placentaliens en general, des Marsupiaux et des Monotremes, plus anciens encore. Apres avoir voyage pendant quelques heures nous arrivames a une mauvaise hutte abandonnee, situee sur les bords d'un ruisseau qui descendait des montagnes environnantes pour se jeter probablement dans le Rio Salinas. Qui croirait que dans cette ville en flammes, dont une partie etait deja occupee par l'ennemi, et dont le reste devait etre saccage au point du jour, il se trouva des hommes assez aveugles pour ambitionner un trone pret a crouler, et ensanglante depuis six mois par trois empereurs?
2
Refernces Bookmarks / opengl
« Last post by admin1 on May 06, 2017, 04:04:07 PM »
8
Computer Science IT Tutorials / python opengl
« Last post by admin1 on April 12, 2017, 11:07:11 AM »
#!/usr/bin/env python2.3
# * 3-D gear wheels.  This program is in the public domain.
# * Brian Paul
# * Conversion to GLUT by Mark J. Kilgard
# conversion to Python using PyOpenGL with frame rates ala glxgears
# Peter Barth
import OpenGL
OpenGL.ERROR_ON_COPY = True
from OpenGL.GL import *
from OpenGL.GLUT import *
import sys, time
from math import sin,cos,sqrt,pi
from OpenGL.constants import GLfloat
vec4 = GLfloat_4

def gear(inner_radius, outer_radius, width, teeth, tooth_depth):
    r0 = inner_radius
    r1 = outer_radius - tooth_depth/2.0
    r2 = outer_radius + tooth_depth/2.0   
    da = 2.0*pi / teeth / 4.0
   
    glShadeModel(GL_FLAT) 
    glNormal3f(0.0, 0.0, 1.0)

    # draw front face
    glBegin(GL_QUAD_STRIP)
    for i in range(teeth + 1):
        angle = i * 2.0 * pi / teeth
        glVertex3f(r0*cos(angle), r0*sin(angle), width*0.5)
        glVertex3f(r1*cos(angle), r1*sin(angle), width*0.5)
        glVertex3f(r0*cos(angle), r0*sin(angle), width*0.5)
        glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5)
    glEnd()

    # draw front sides of teeth
    glBegin(GL_QUADS)
    da = 2.0*pi / teeth / 4.0
    for i in range(teeth):
        angle = i * 2.0*pi / teeth
        glVertex3f(r1*cos(angle),      r1*sin(angle),      width*0.5)
        glVertex3f(r2*cos(angle+da),   r2*sin(angle+da),   width*0.5)
        glVertex3f(r2*cos(angle+2*da), r2*sin(angle+2*da), width*0.5)
        glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5)
    glEnd()

    glNormal3f(0.0, 0.0, -1.0)

    # draw back face
    glBegin(GL_QUAD_STRIP)
    for i in range(teeth + 1):
        angle = i * 2.0*pi / teeth
        glVertex3f(r1*cos(angle), r1*sin(angle), -width*0.5)
        glVertex3f(r0*cos(angle), r0*sin(angle), -width*0.5)
        glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da),-width*0.5)
        glVertex3f(r0*cos(angle), r0*sin(angle), -width*0.5)
    glEnd()

    # draw back sides of teeth
    glBegin(GL_QUADS)
    da = 2.0*pi / teeth / 4.0
    for i in range(teeth):
        angle = i * 2.0*pi / teeth       
        glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da),-width*0.5)
        glVertex3f(r2*cos(angle+2*da), r2*sin(angle+2*da),-width*0.5)
        glVertex3f(r2*cos(angle+da),   r2*sin(angle+da),  -width*0.5)
        glVertex3f(r1*cos(angle),      r1*sin(angle),     -width*0.5)
    glEnd()

    # draw outward faces of teeth
    glBegin(GL_QUAD_STRIP);
    for i in range(teeth):
        angle = i * 2.0*pi / teeth       
        glVertex3f(r1*cos(angle), r1*sin(angle),  width*0.5)
        glVertex3f(r1*cos(angle), r1*sin(angle), -width*0.5)
        u = r2*cos(angle+da) - r1*cos(angle)
        v = r2*sin(angle+da) - r1*sin(angle)
        len = sqrt(u*u + v*v)
        u = u / len
        v = v / len
        glNormal3f(v, -u, 0.0)
        glVertex3f(r2*cos(angle+da),   r2*sin(angle+da),   width*0.5)
        glVertex3f(r2*cos(angle+da),   r2*sin(angle+da),  -width*0.5)
        glNormal3f(cos(angle), sin(angle), 0.0)
        glVertex3f(r2*cos(angle+2*da), r2*sin(angle+2*da), width*0.5)
        glVertex3f(r2*cos(angle+2*da), r2*sin(angle+2*da),-width*0.5)
        u = r1*cos(angle+3*da) - r2*cos(angle+2*da)
        v = r1*sin(angle+3*da) - r2*sin(angle+2*da)
        glNormal3f(v, -u, 0.0)
        glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5)
        glVertex3f(r1*cos(angle+3*da), r1*sin(angle+3*da),-width*0.5)
        glNormal3f(cos(angle), sin(angle), 0.0)

    glVertex3f(r1*cos(0), r1*sin(0), width*0.5)
    glVertex3f(r1*cos(0), r1*sin(0), -width*0.5)

    glEnd()

    glShadeModel(GL_SMOOTH)

    # draw inside radius cylinder
    glBegin(GL_QUAD_STRIP)
    for i in range(teeth + 1):
        angle = i * 2.0*pi / teeth;
        glNormal3f(-cos(angle), -sin(angle), 0.0)
        glVertex3f(r0*cos(angle), r0*sin(angle), -width*0.5)
        glVertex3f(r0*cos(angle), r0*sin(angle), width*0.5)
    glEnd()


(view_rotx,view_roty,view_rotz)=(20.0, 30.0, 0.0)
(gear1, gear2, gear3) = (0,0,0)
angle = 0.0


tStart = t0 = time.time()
frames = 0
rotationRate = 1.01

def framerate():
    global t0, frames
    t = time.time()
    frames += 1
    if t - t0 >= 5.0:
        seconds = t - t0
        fps = frames/seconds
        print "%.0f frames in %3.1f seconds = %6.3f FPS" % (frames,seconds,fps)
        t0 = t
        frames = 0


def draw():
    rotationRate = (time.time() - tStart) * 1.05
    angle = (2 * pi) * ((time.time() - tStart)*rotationRate)# * rotationRate
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

    glPushMatrix()
    glRotatef(view_rotx, 1.0, 0.0, 0.0)
    glRotatef(view_roty, 0.0, 1.0, 0.0)
    glRotatef(view_rotz, 0.0, 0.0, 1.0)

    glPushMatrix()
    glTranslatef(-3.0, -2.0, 0.0)
    glRotatef(angle, 0.0, 0.0, 1.0)
    glCallList(gear1)
    glPopMatrix()

    glPushMatrix()
    glTranslatef(3.1, -2.0, 0.0)
    glRotatef(-2.0*angle-9.0, 0.0, 0.0, 1.0)
    glCallList(gear2)
    glPopMatrix()

    glPushMatrix()
    glTranslatef(-3.1, 4.2, 0.0)
    glRotatef(-2.0*angle-25.0, 0.0, 0.0, 1.0)
    glCallList(gear3)
    glPopMatrix()

    glPopMatrix()

    glutSwapBuffers()

    framerate()
   
def idle():
    global angle
    angle += 2.0
    glutPostRedisplay()
   

# change view angle, exit upon ESC
def key(k, x, y):
    global view_rotz

    if k == 'z':
        view_rotz += 5.0
    elif k == 'Z':
        view_rotz -= 5.0
    elif ord(k) == 27: # Escape
        sys.exit(0)
    else:
        return
    glutPostRedisplay()


# change view angle
def special(k, x, y):
    global view_rotx, view_roty, view_rotz
   
    if k == GLUT_KEY_UP:
        view_rotx += 5.0
    elif k == GLUT_KEY_DOWN:
        view_rotx -= 5.0
    elif k == GLUT_KEY_LEFT:
        view_roty += 5.0
    elif k == GLUT_KEY_RIGHT:
        view_roty -= 5.0
    else:
        return
    glutPostRedisplay()


# new window size or exposure
def reshape(width, height):
    h = float(height) / float(width);
    glViewport(0, 0, width, height)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0)
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    glTranslatef(0.0, 0.0, -40.0)

def init():
    global gear1, gear2, gear3
   
   
    pos = vec4(5.0, 5.0, 10.0, 0.0)
    red = vec4(0.8, 0.1, 0.0, 1.0)
    green = vec4(0.0, 0.8, 0.2, 1.0)
    blue = vec4(0.2, 0.2, 1.0, 1.0)

    glLightfv(GL_LIGHT0, GL_POSITION, pos)
    glEnable(GL_CULL_FACE)
    glEnable(GL_LIGHTING)
    glEnable(GL_LIGHT0)
    glEnable(GL_DEPTH_TEST)

    # make the gears
    gear1 = glGenLists(1)
    glNewList(gear1, GL_COMPILE)
    glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red)
    gear(1.0, 4.0, 1.0, 20, 0.7)
    glEndList()
   
    gear2 = glGenLists(1)
    glNewList(gear2, GL_COMPILE)
    glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green)
    gear(0.5, 2.0, 2.0, 10, 0.7)
    glEndList()

    gear3 = glGenLists(1)
    glNewList(gear3, GL_COMPILE)
    glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue)
    gear(1.3, 2.0, 0.5, 10, 0.7)
    glEndList()

    glEnable(GL_NORMALIZE)

def visible(vis):
    if vis == GLUT_VISIBLE:
        glutIdleFunc(idle)
    else:
        glutIdleFunc(None)


if __name__ == '__main__':
    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH)

    glutInitWindowPosition(0, 0)
    glutInitWindowSize(300, 300)
    glutCreateWindow("pyGears")
    init()
   
    glutDisplayFunc(draw)
    glutReshapeFunc(reshape)
    glutKeyboardFunc(key)
    glutSpecialFunc(special)
    glutVisibilityFunc(visible)

    if "-info" in sys.argv:
        print "GL_RENDERER   = ", glGetString(GL_RENDERER)
        print "GL_VERSION    = ", glGetString(GL_VERSION)
        print "GL_VENDOR     = ", glGetString(GL_VENDOR)
        print "GL_EXTENSIONS = ", glGetString(GL_EXTENSIONS)

    glutMainLoop()
   
9
Computer Science IT Tutorials / python opengl trials
« Last post by admin1 on April 12, 2017, 11:05:03 AM »
import sys

from OpenGL.GLUT import *
from OpenGL.GLU import *
from OpenGL.GL import *
from math import *
from random import random, choice, randint, getrandbits

"""                       
   Copyright (c) Mark J. Kilgard, 1994.   

   This program is freely distributable without licensing fees
   and is provided without guarantee or warrantee expressed or
   implied. This program is -not- in the public domain. 
"""
M_PI   = pi
M_PI_2 = pi / 2.0

moving = False
MAX_PLANES = 15

# define plane object
#
class plane(object):
    def __init__(self, speed, red, green, blue, theta, x, y, z, angle):
        self.speed = speed
        self.red   = red
        self.green = green
        self.blue  = blue
        self.theta = theta
        self.angle = angle
        self.x = x
        self.y = y
        self.z = z

# create list of planes
#
planes = []       
for n in range(MAX_PLANES) :
    p = plane(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
    planes.append(p)


# define the GLUT display function
#
def draw():
    glClear(GL_DEPTH_BUFFER_BIT)
    # paint black to blue smooth shaded polygon for background
    glDisable(GL_DEPTH_TEST)
    glShadeModel(GL_SMOOTH)
    glBegin(GL_POLYGON);
    glColor3f(0.0, 0.0, 0.0);
    glVertex3f(-20.0, 20.0, -19.0)
    glVertex3f( 20.0, 20.0, -19.0)
    glColor3f(0.0, 0.0, 1.0)
    glVertex3f( 20.0, -20.0, -19.0)
    glVertex3f(-20.0, -20.0, -19.0)
    glEnd()
    # paint planes
    glEnable(GL_DEPTH_TEST)
    glShadeModel(GL_FLAT)
    for n in range(MAX_PLANES) :
        if (planes[n].speed != 0.0) :
            glPushMatrix()
            glTranslatef(planes[n].x, planes[n].y, planes[n].z)
            glRotatef(290.0, 1.0, 0.0, 0.0)
            glRotatef(planes[n].angle, 0.0, 0.0, 1.0)
            glScalef(1.0 / 3.0, 1.0 / 4.0, 1.0 / 4.0)
            glTranslatef(0.0, -4.0, -1.5)
            glBegin(GL_TRIANGLE_STRIP)
            # left wing
            glVertex3f(-7.0, 0.0, 2.0)
            glVertex3f(-1.0, 0.0, 3.0)
            red   = planes[n].red
            green = planes[n].green
            blue  = planes[n].blue
            glColor3f(red, green, blue)
            glVertex3f(-1.0, 7.0, 3.0)
            # left side
            glColor3f(0.6 * red, 0.6 * green, 0.6 * blue)
            glVertex3f(0.0, 0.0, 0.0)
            glVertex3f(0.0, 8.0, 0.0)
            # right side
            glVertex3f(1.0, 0.0, 3.0)
            glVertex3f(1.0, 7.0, 3.0)
            # final tip of right wing */
            glColor3f(red, green, blue)
            glVertex3f(7.0, 0.0, 2.0)
            glEnd()
            glPopMatrix()
     
    glutSwapBuffers()
    return

# define the plane position and speed incrementor
#
def tick_per_plane(i):
    planes.theta += planes.speed
    theta = planes.theta
    planes.z = -10 + 4 * cos(theta)
    planes.x = 5 * sin(2 * theta)
    planes.y = sin(theta / 3.4) * 3
    planes.angle = ((atan(2.0) + M_PI_2) * sin(theta) - M_PI_2) * 180 / M_PI
    if (planes.speed < 0.0) :
        planes.angle += 180.0
    return

#define the list of rgb tuples for setting plane colours by random choice
#
rgblist = [(1.0, 0.0, 0.0),  # red
           (1.0, 1.0, 1.0),  # white
           (0.0, 1.0, 0.0),  # green
           (1.0, 0.0, 1.0),  # magenta
           (1.0, 1.0, 0.0),  # yellow
           (0.0, 1.0, 1.0)   # cyan
          ]

# define add planes to display of planes
#
def add_plane():
    for i in range(MAX_PLANES) :
        if (planes.speed == 0.0) :
            planes.red, planes.green, planes.blue = choice(rgblist)
            planes.speed = (float(randint(0, 19)) * 0.001) + 0.02
            if (getrandbits(32) & 0x1) :
                planes.speed *= -1
            planes.theta = float(randint(0, 256)) * 0.1111
            tick_per_plane(i)
            if (not moving) :
                glutPostRedisplay()
            return
    return


# define remove a plane from display of planes
#
def remove_plane():
    for i in range(MAX_PLANES-1, -1, -1) :
      if (planes.speed != 0) :
          planes.speed = 0
          if (not moving) :
              glutPostRedisplay()
          return
    return

#define choice of planes to animate
#
def tick():
    for i in range(MAX_PLANES) :
        if (planes.speed != 0.0) :
            tick_per_plane(i)
    return

# define animator so that motion can be started
def animate():
    tick()
    glutPostRedisplay()
    return


def visible(state):
    if (state == GLUT_VISIBLE) :
        if (moving) :
            glutIdleFunc(animate)
    else :
        if (moving) :
            glutIdleFunc(None)
    return


# ARGSUSED1

def keyboard( ch,  x,  y):
    if(ch == ' ') :
        if (not moving) :
            tick()
            glutPostRedisplay()
    elif (ch == chr(27)) :
        sys.exit(0)
    return 0

VOID, ADD_PLANE, REMOVE_PLANE, MOTION_ON, MOTION_OFF, QUIT = range(6)

def domotion_on():
    moving = GL_TRUE
    glutChangeToMenuEntry(3, "Motion off", MOTION_OFF)
    glutIdleFunc(animate)
    return

def domotion_off():
    moving = GL_FALSE
    glutChangeToMenuEntry(3, "Motion", MOTION_ON)
    glutIdleFunc(None)
    return

def doquit():
    sys.exit(0)
    return

menudict ={ADD_PLANE : add_plane,
           REMOVE_PLANE : remove_plane,
           MOTION_ON : domotion_on,
           MOTION_OFF: domotion_off,
           QUIT : doquit}

def dmenu(item):
    menudict[item]()
    return 0

if __name__ == "__main__":
   glutInit(['glutplane'])
   glutInitWindowPosition(112, 84)
   glutInitWindowSize(800, 600)
   # use multisampling if available
   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE)
   wintitle = "glutplane  Copyright (c) Mark J. Kilgard, 1994. RIGHT-CLICK for menu"
   glutCreateWindow(wintitle)
   glutDisplayFunc(draw)
   glutKeyboardFunc(keyboard)
   glutVisibilityFunc(visible)
   #
   # This program fails if PyOpenGL-3.0.0b1-py2.5.egg\OpenGL\GLUT\special.py
   # is not corrected at line 158 to read :
   # callbackType = ctypes.CFUNCTYPE( None, ctypes.c_int )
   # instead of :
   # callbackType = ctypes.CFUNCTYPE( ctypes.c_int, ctypes.c_int )
   #
   # RIGHT-CLICK to display the menu
   #
   glutCreateMenu(dmenu)
   glutAddMenuEntry("Add plane", ADD_PLANE)
   glutAddMenuEntry("Remove plane", REMOVE_PLANE)
   glutAddMenuEntry("Motion", MOTION_ON)
   glutAddMenuEntry("Quit", QUIT)
   glutAttachMenu(GLUT_RIGHT_BUTTON)

   # setup OpenGL state
   glClearDepth(1.0)
   glClearColor(0.0, 0.0, 0.0, 0.0)
   glMatrixMode(GL_PROJECTION)
   glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 30)
   glMatrixMode(GL_MODELVIEW)
   # add three initial random planes
   add_plane()
   add_plane()
   add_plane()
   # start event processing */
   print 'RIGHT-CLICK to display the menu.'
   glutMainLoop()

10
Computer Science IT Tutorials / python opengL mouse application
« Last post by admin1 on April 12, 2017, 11:02:03 AM »
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *

class Point:
    def __init__(self,x,y):
        self.x=x
        self.y=y

points=[]

def initFun():
    glClearColor(1.0,1.0,1.0,0.0)
    glColor3f(0.0,0.0, 0.0)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    gluOrtho2D(0.0,640.0,0.0,480.0)
   

def displayFun():
    global points
    glClear(GL_COLOR_BUFFER_BIT)
    glBegin(GL_LINE_STRIP)
    glColor3f(0,0,0)
    for p in points:
        glVertex2i(p.x,p.y)
    glEnd()
    glFlush()

def mouseFun(button,state,x,y):
    global points
    if button==GLUT_LEFT_BUTTON and state == GLUT_DOWN:
        p = Point(x,480-y)
        points.append(p)
    if button==GLUT_RIGHT_BUTTON and state == GLUT_DOWN:
        if len(points) != 0:
            points=points[:-1]
    glutPostRedisplay()
       
if __name__ == '__main__':
    glutInit()
    glutInitWindowSize(640,480)
    glutCreateWindow("Polyline")
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
    glutDisplayFunc(displayFun)
    glutMouseFunc(mouseFun)
    initFun()
    glutMainLoop()
Pages: [1] 2 3 ... 7