Python OpenGL.GL.glVertex3f() Examples
The following are 12
code examples of OpenGL.GL.glVertex3f().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
OpenGL.GL
, or try the search function
.
Example #1
Source File: ndwindow.py From spectral with MIT License | 7 votes |
def draw_box(self, x0, y0, x1, y1): '''Draws a selection box in the 3-D window. Coordinates are with respect to the lower left corner of the window. ''' import OpenGL.GL as gl gl.glMatrixMode(gl.GL_PROJECTION) gl.glLoadIdentity() gl.glOrtho(0.0, self.size[0], 0.0, self.size[1], -0.01, 10.0) gl.glLineStipple(1, 0xF00F) gl.glEnable(gl.GL_LINE_STIPPLE) gl.glLineWidth(1.0) gl.glColor3f(1.0, 1.0, 1.0) gl.glBegin(gl.GL_LINE_LOOP) gl.glVertex3f(x0, y0, 0.0) gl.glVertex3f(x1, y0, 0.0) gl.glVertex3f(x1, y1, 0.0) gl.glVertex3f(x0, y1, 0.0) gl.glEnd() gl.glDisable(gl.GL_LINE_STIPPLE) gl.glFlush() self.resize(*self.size)
Example #2
Source File: viewer3D.py From pyslam with GNU General Public License v3.0 | 6 votes |
def drawPlane(num_divs=200, div_size=10): # Plane parallel to x-z at origin with normal -y minx = -num_divs*div_size minz = -num_divs*div_size maxx = num_divs*div_size maxz = num_divs*div_size #gl.glLineWidth(2) #gl.glColor3f(0.7,0.7,1.0) gl.glColor3f(0.7,0.7,0.7) gl.glBegin(gl.GL_LINES) for n in range(2*num_divs): gl.glVertex3f(minx+div_size*n,0,minz) gl.glVertex3f(minx+div_size*n,0,maxz) gl.glVertex3f(minx,0,minz+div_size*n) gl.glVertex3f(maxx,0,minz+div_size*n) gl.glEnd()
Example #3
Source File: LicModel.py From lic with GNU General Public License v3.0 | 6 votes |
def drawConditionalLines(self): if self.type != GL.GL_LINES or len(self.points) != 12: return # Not a conditional line p = self.points p0 = GLU.gluProject(p[0], p[1], p[2]) p1 = GLU.gluProject(p[3], p[4], p[5]) c0 = GLU.gluProject(p[6], p[7], p[8]) c1 = GLU.gluProject(p[9], p[10], p[11]) winding1 = self.pointWinding(p0, p1, c0) winding2 = self.pointWinding(p0, p1, c1) if winding1 != winding2: return GL.glPushAttrib(GL.GL_CURRENT_BIT) GL.glColor4f(1.0, 1.0, 0.0, 1.0) GL.glBegin(self.type) GL.glVertex3f(p[0], p[1], p[2]) GL.glVertex3f(p[3], p[4], p[5]) GL.glEnd() GL.glPopAttrib()
Example #4
Source File: glutils.py From GDMC with ISC License | 5 votes |
def debugDrawPoint(point): GL.glColor(1.0, 1.0, 0.0, 1.0) GL.glPointSize(9.0) with gl.glBegin(GL.GL_POINTS): GL.glVertex3f(*point)
Example #5
Source File: brush.py From GDMC with ISC License | 5 votes |
def drawTerrainReticle(self): """ Draws the white reticle where the cursor is pointing. Called by leveleditor.render """ if self.optionBackup != self.options: self.saveBrushPreset('__temp__') self.optionBackup = copy.copy(self.options) if not hasattr(self, 'brushMode'): return if self.options[getattr(self.brushMode, 'mainBlock', 'Block')] != self.renderedBlock and not getattr(self.brushMode, 'addPasteButton', False): self.setupPreview() self.renderedBlock = self.options[getattr(self.brushMode, 'mainBlock', 'Block')] if self.pickBlockKey == 1: #Alt is pressed self.editor.drawWireCubeReticle(color=(0.2, 0.6, 0.9, 1.0)) else: pos, direction = self.editor.blockFaceUnderCursor reticlePoint = self.getReticlePoint(pos, direction) self.editor.drawWireCubeReticle(position=reticlePoint) if reticlePoint != pos: GL.glColor4f(1.0, 1.0, 0.0, 0.7) with gl.glBegin(GL.GL_LINES): GL.glVertex3f(*map(lambda a: a + 0.5, reticlePoint)) #Center of reticle block GL.glVertex3f(*map(lambda a, b: a + 0.5 + b * 0.5, pos, direction)) #Top side of surface block dirtyBox = self.getDirtyBox(reticlePoint, self) self.drawTerrainPreview(dirtyBox.origin) if self.lineToolKey and self.lastPosition and getattr(self.brushMode, 'draggableBrush', True): #If dragging mouse with Linetool pressed. GL.glColor4f(1.0, 1.0, 1.0, 0.7) with gl.glBegin(GL.GL_LINES): GL.glVertex3f(*map(lambda a: a + 0.5, self.lastPosition)) GL.glVertex3f(*map(lambda a: a + 0.5, reticlePoint))
Example #6
Source File: simpleDraw.py From pyslam with GNU General Public License v3.0 | 5 votes |
def drawPlane(ndivs=100, ndivsize=1): # Plane parallel to x-z at origin with normal -y minx = -ndivs*ndivsize minz = -ndivs*ndivsize maxx = ndivs*ndivsize maxz = ndivs*ndivsize gl.glLineWidth(1) gl.glColor3f(0.7,0.7,1.0) gl.glBegin(gl.GL_LINES) for n in range(2*ndivs): gl.glVertex3f(minx+ndivsize*n,0,minz) gl.glVertex3f(minx+ndivsize*n,0,maxz) gl.glVertex3f(minx,0,minz+ndivsize*n) gl.glVertex3f(maxx,0,minz+ndivsize*n) gl.glEnd()
Example #7
Source File: LicModel.py From lic with GNU General Public License v3.0 | 5 votes |
def drawGLBoundingBox(self): b = self.abstractPart.getBoundingBox() GL.glBegin(GL.GL_LINE_LOOP) GL.glVertex3f(b.x1, b.y1, b.z1) GL.glVertex3f(b.x2, b.y1, b.z1) GL.glVertex3f(b.x2, b.y2, b.z1) GL.glVertex3f(b.x1, b.y2, b.z1) GL.glEnd() GL.glBegin(GL.GL_LINE_LOOP) GL.glVertex3f(b.x1, b.y1, b.z2) GL.glVertex3f(b.x2, b.y1, b.z2) GL.glVertex3f(b.x2, b.y2, b.z2) GL.glVertex3f(b.x1, b.y2, b.z2) GL.glEnd() GL.glBegin(GL.GL_LINES) GL.glVertex3f(b.x1, b.y1, b.z1) GL.glVertex3f(b.x1, b.y1, b.z2) GL.glVertex3f(b.x1, b.y2, b.z1) GL.glVertex3f(b.x1, b.y2, b.z2) GL.glVertex3f(b.x2, b.y1, b.z1) GL.glVertex3f(b.x2, b.y1, b.z2) GL.glVertex3f(b.x2, b.y2, b.z1) GL.glVertex3f(b.x2, b.y2, b.z2) GL.glEnd()
Example #8
Source File: glutils.py From MCEdit-Unified with ISC License | 5 votes |
def debugDrawPoint(point): GL.glColor(1.0, 1.0, 0.0, 1.0) GL.glPointSize(9.0) with gl.glBegin(GL.GL_POINTS): GL.glVertex3f(*point)
Example #9
Source File: brush.py From MCEdit-Unified with ISC License | 5 votes |
def drawTerrainReticle(self): """ Draws the white reticle where the cursor is pointing. Called by leveleditor.render """ if self.optionBackup != self.options: self.saveBrushPreset('__temp__') self.optionBackup = copy.copy(self.options) if not hasattr(self, 'brushMode'): return if self.options[getattr(self.brushMode, 'mainBlock', 'Block')] != self.renderedBlock and not getattr(self.brushMode, 'addPasteButton', False): self.setupPreview() self.renderedBlock = self.options[getattr(self.brushMode, 'mainBlock', 'Block')] if self.pickBlockKey == 1: #Alt is pressed self.editor.drawWireCubeReticle(color=(0.2, 0.6, 0.9, 1.0)) else: pos, direction = self.editor.blockFaceUnderCursor reticlePoint = self.getReticlePoint(pos, direction) self.editor.drawWireCubeReticle(position=reticlePoint) if reticlePoint != pos: GL.glColor4f(1.0, 1.0, 0.0, 0.7) with gl.glBegin(GL.GL_LINES): GL.glVertex3f(*[a + 0.5 for a in reticlePoint]) #Center of reticle block GL.glVertex3f(*map(lambda a, b: a + 0.5 + b * 0.5, pos, direction)) #Top side of surface block dirtyBox = self.getDirtyBox(reticlePoint, self) self.drawTerrainPreview(dirtyBox.origin) if self.lineToolKey and self.lastPosition and getattr(self.brushMode, 'draggableBrush', True): #If dragging mouse with Linetool pressed. GL.glColor4f(1.0, 1.0, 1.0, 0.7) with gl.glBegin(GL.GL_LINES): GL.glVertex3f(*[a + 0.5 for a in self.lastPosition]) GL.glVertex3f(*[a + 0.5 for a in reticlePoint])
Example #10
Source File: head_model_OGL.py From simnibs with GNU General Public License v3.0 | 4 votes |
def drawAxis(self): GL.glMatrixMode(GL.GL_PROJECTION) GL.glPushMatrix() GL.glLoadIdentity() width = float(self.width()) height = float(self.height()) frustrumx = 60*width/self.sizeHint().width() frustrumy = 60*height/self.sizeHint().height() GL.glFrustum(-frustrumx, frustrumx, frustrumy, -frustrumy, 200, 500) GL.glMatrixMode(GL.GL_MODELVIEW) GL.glPushMatrix() GL.glLoadIdentity() qobj = GLU.gluNewQuadric() GL.glTranslatef(1.7*frustrumx, 1.7*frustrumy, -400) GL.glRotatef(self.xRot / 16.0, 1.0, 0.0, 0.0) GL.glRotatef(self.yRot / 16.0, 0.0, 1.0, 0.0) GL.glRotatef(self.zRot / 16.0, 0.0, 0.0, 1.0) GL.glDisable(GL.GL_LIGHTING) GL.glBegin(GL.GL_LINES) self.qglColor(RED) GL.glVertex3f(-20.0,0,0) #X is inverted GL.glVertex3f(0.,0.,0.) self.qglColor(GREEN) GL.glVertex3f(0,20,0) GL.glVertex3f(0.,0.,0.) self.qglColor(BLUE) GL.glVertex3f(0,0,20) GL.glVertex3f(0.,0.,0.) GL.glEnd() GL.glEnable(GL.GL_LIGHTING) GL.glPopMatrix() GL.glMatrixMode(GL.GL_PROJECTION) GL.glPopMatrix() GL.glMatrixMode(GL.GL_MODELVIEW) #Scale for HeatMap
Example #11
Source File: ndwindow.py From spectral with MIT License | 4 votes |
def create_axes_list(self): '''Creates display lists to render unit length x,y,z axes.''' import OpenGL.GL as gl gl.glNewList(self.gllist_id, gl.GL_COMPILE) gl.glBegin(gl.GL_LINES) gl.glColor3f(1.0, 0.0, 0.0) gl.glVertex3f(0.0, 0.0, 0.0) gl.glVertex3f(1.0, 0.0, 0.0) gl.glColor3f(0.0, 1.0, 0.0) gl.glVertex3f(0.0, 0.0, 0.0) gl.glVertex3f(0.0, 1.0, 0.0) gl.glColor3f(-.0, 0.0, 1.0) gl.glVertex3f(0.0, 0.0, 0.0) gl.glVertex3f(0.0, 0.0, 1.0) gl.glColor3f(1.0, 1.0, 1.0) gl.glVertex3f(0.0, 0.0, 0.0) gl.glVertex3f(-1.0, 0.0, 0.0) gl.glVertex3f(0.0, 0.0, 0.0) gl.glVertex3f(0.0, -1.0, 0.0) gl.glVertex3f(0.0, 0.0, 0.0) gl.glVertex3f(0.0, 0.0, -1.0) gl.glEnd() def label_axis(x, y, z, label): gl.glRasterPos3f(x, y, z) glut.glutBitmapString(glut.GLUT_BITMAP_HELVETICA_18, str(label)) def label_axis_for_feature(x, y, z, feature_ind): feature = self.octant_features[feature_ind[0]][feature_ind[1]] label_axis(x, y, z, self.labels[feature]) if self._have_glut: try: import OpenGL.GLUT as glut if bool(glut.glutBitmapString): if self.quadrant_mode == 'independent': label_axis(1.05, 0.0, 0.0, 'x') label_axis(0.0, 1.05, 0.0, 'y') label_axis(0.0, 0.0, 1.05, 'z') elif self.quadrant_mode == 'mirrored': label_axis_for_feature(1.05, 0.0, 0.0, (0, 0)) label_axis_for_feature(0.0, 1.05, 0.0, (0, 1)) label_axis_for_feature(0.0, 0.0, 1.05, (0, 2)) label_axis_for_feature(-1.05, 0.0, 0.0, (6, 0)) label_axis_for_feature(0.0, -1.05, 0.0, (6, 1)) label_axis_for_feature(0.0, 0.0, -1.05, (6, 2)) else: label_axis_for_feature(1.05, 0.0, 0.0, (0, 0)) label_axis_for_feature(0.0, 1.05, 0.0, (0, 1)) label_axis_for_feature(0.0, 0.0, 1.05, (0, 2)) except: pass gl.glEndList()
Example #12
Source File: LicModel.py From lic with GNU General Public License v3.0 | 4 votes |
def callGLDisplayList(self, paintingEdge): # must be called inside a glNewList/EndList pair p = self.points if self.type == GL.GL_LINES: if len(self.points) > 6 or not paintingEdge: # This is a conditional line or we are not painting edges return GL.glBegin(self.type) GL.glVertex3f(p[0], p[1], p[2]) GL.glVertex3f(p[3], p[4], p[5]) GL.glEnd() return if paintingEdge: return if self.color is not None: GL.glPushAttrib(GL.GL_CURRENT_BIT) GL.glColor4fv(self.color.rgba) if self.winding == GL.GL_CCW: normal = self.addNormal(p[0:3], p[3:6], p[6:9]) # GL.glBegin( GL.GL_LINES ) # GL.glVertex3f(p[3], p[4], p[5]) # GL.glVertex3f(p[3] + normal[0], p[4] + normal[1], p[5] + normal[2]) # GL.glEnd() GL.glBegin(self.type) GL.glNormal3fv(normal) GL.glVertex3f(p[0], p[1], p[2]) GL.glVertex3f(p[3], p[4], p[5]) GL.glVertex3f(p[6], p[7], p[8]) if self.type == GL.GL_QUADS: GL.glVertex3f(p[9], p[10], p[11]) GL.glEnd() elif self.winding == GL.GL_CW: normal = self.addNormal(p[0:3], p[6:9], p[3:6]) # GL.glBegin( GL.GL_LINES ) # GL.glVertex3f(p[3], p[4], p[5]) # GL.glVertex3f(p[3] + normal[0], p[4] + normal[1], p[5] + normal[2]) # GL.glEnd() GL.glBegin(self.type) GL.glNormal3fv(normal) GL.glVertex3f(p[0], p[1], p[2]) if self.type == GL.GL_QUADS: GL.glVertex3f(p[9], p[10], p[11]) GL.glVertex3f(p[6], p[7], p[8]) GL.glVertex3f(p[3], p[4], p[5]) GL.glEnd() if self.color is not None: GL.glPopAttrib()