A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://pyopengl.sourceforge.net/context/tutorials/nurbsobject.html below:

Scenegraph Nodes: RedBook NURBS Trim

Scenegraph Nodes: RedBook NURBS Trim

#! /usr/bin/env python

from OpenGLContext import testingcontext BaseContext = testingcontext.getInteractive() from OpenGL.GL import * from OpenGLContext.arrays import * import string, time from OpenGLContext.scenegraph.basenodes import * from OpenGLContext.scenegraph import nurbs class TestContext( BaseContext ): """RedBook Trimmed Nurbs Demo"""

initialPosition = (0,0,3) def buildControlPoints( self ): """Build control points for the main surface"""

ctlpoints = zeros( (4,4,3), 'd') for u in range( 4 ): for v in range( 4): ctlpoints[u][v][0] = 2.0*(u - 1.5) ctlpoints[u][v][1] = 2.0*(v - 1.5); if (u == 1 or u ==2) and (v == 1 or v == 2): ctlpoints[u][v][2] = 3.0; else: ctlpoints[u][v][2] = -3.0; return ctlpoints def OnInit( self ): """Create the scenegraph""" print """You should see a multi-coloured Nurbs surface with an ice-cream-cone-shaped trimming curve (a hole cut out of it)."""

trimmingContour = [ Contour2D( children = [ Polyline2D( # outside edge point = array( [ [0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0], [0.0, 0.0], ], 'd') ), ], ), Contour2D( children = [ Polyline2D( # inside edge point = array([ [0.75, 0.5], [0.5, 0.25], [0.25, 0.5], ],'d') ), NurbsCurve2D( knot = array( [0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0], 'd'), controlPoint = array( [ [0.25, 0.5], [0.25, 0.75], [0.75, 0.75], [0.75, 0.5], ],'d') ) ] ), ] knots = [0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]

color = zeros( (4,4,3), 'd' ) color[0,:,:] = (1.,0,0) color[1,:,:] = (.66,.33,0) color[2,:,:] = (.33,.66,0) color[3,:,:] = (0,1.,0) self.shape = Shape( appearance = Appearance( material = Material(), ), geometry = TrimmedSurface( surface = NurbsSurface( controlPoint = self.buildControlPoints(), color = color, vDimension = 4, uDimension = 4, uKnot = knots, vKnot = knots, ), trimmingContour = trimmingContour, ), ) self.sg = sceneGraph( children = [ Transform( scale = [.5,.5,.5], rotation = [1,0,0,-.5], children = [self.shape], ), ], ) if __name__ == "__main__": TestContext.ContextMainLoop()


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4