A RetroSearch Logo

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

Search Query:

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

Scenegraph Nodes: Molehill NURBS Introduction

Scenegraph Nodes: Molehill NURBS Introduction

#! /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 ): def buildControlPoints( self ): """Build control points for NURBS mole hills"""

pts1 = [] pts2 = [] pts3 = [] pts4 = [] for u in range(4): pts1.append([]) pts2.append([]) pts3.append([]) pts4.append([]) for v in range(4):

pts1[u].append([2.0*u, 2.0*v, 0.0]) if (u == 1 or u == 2) and (v == 1 or v == 2): pts1[u][v][2] = 6.0

pts2[u].append([2.0*u - 6.0, 2.0*v - 6.0, 0.0]) if (u == 1 or u == 2) and (v == 1 or v == 2): if u == 1 and v == 1:

pts2[u][v][2] = 15.0 else:

pts2[u][v][2] = -2.0

pts3[u].append([2.0*u - 6.0, 2.0*v, 0.0]) if (u == 1 or u == 2) and (v == 1 or v == 2): if u == 1 and v == 2:

pts3[u][v][2] = 11.0 else:

pts3[u][v][2] = 2.0

pts4[u].append([2.0*u, 2.0*v - 6.0, 0.0]) if u != 0 and (v == 1 or v == 2): if v == 1:

pts4[u][v][2] = -2.0 else:

pts4[u][v][2] = 5.0

pts1[3][3][2] = 6.0

pts2[0][0][2] = -2.0

pts1[0][0][2] = 1.0 pts2[3][3][2] = 1.0 pts3[3][0][2] = 1.0 pts4[0][3][2] = 1.0 return pts1,pts2,pts3,pts4 def OnInit( self ): """Create the scenegraph for rendering""" print """You should see a 4-colour "molehill" composed of four different NurbsSurface nodes.""" knots = array( (0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0),'f' ) pts1,pts2,pts3,pts4 = self.buildControlPoints() colors = [[1,0,0],[0,1,0],[0,0,1],[1,1,0],]

self.shapes = [] for pts,color in zip((pts1,pts2,pts3,pts4),colors): appearance = Appearance( material = Material( diffuseColor = color, ), )

self.shapes.append( Shape( appearance = appearance, geometry = NurbsSurface( controlPoint = pts, vDimension = 4, uDimension = 4, uKnot = knots, vKnot = knots, ), ) )

self.shapes.append( Shape( geometry = PointSet( coord = Coordinate( point = pts, ), ), ) )

self.sg = sceneGraph( children = [ Transform( scale = [.5,.5,.5], rotation = [1,0,0,-.5], children = self.shapes, ), ], ) 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