Exemplo n.º 1
0
	def createShape( self ):
		"Create the shape."
		maximumRadius = max( self.radius.x, self.radius.y, self.radius.z )
		numberOfInBetweens = max( int( 0.25 * evaluate.getSides( maximumRadius, self.xmlElement ) ), 1 )
		numberOfDivisions = numberOfInBetweens + 1
		bottomLeft = complex( - 1.0, - 1.0 )
		topRight = complex( 1.0, 1.0 )
		extent = topRight - bottomLeft
		elementExtent = extent / numberOfDivisions
		grid = []
		for rowIndex in xrange( numberOfDivisions + 1 ):
			row = []
			grid.append( row )
			for columnIndex in xrange( numberOfDivisions + 1 ):
				point = complex( elementExtent.real * float( columnIndex ), elementExtent.real * float( rowIndex ) ) + bottomLeft
				row.append( point )
		indexedGridBottom = trianglemesh.getAddIndexedGrid( grid, self.vertices, - 1.0 )
		indexedGridBottomLoop = trianglemesh.getIndexedLoopFromIndexedGrid( indexedGridBottom )
		indexedLoops = [ indexedGridBottomLoop ]
		zList = []
		for zIndex in xrange( 1, numberOfDivisions ):
			z = elementExtent.real * float( zIndex ) + bottomLeft.real
			zList.append( z )
		gridLoop = []
		for vertex in indexedGridBottomLoop:
			gridLoop.append( vertex.dropAxis( 2 ) )
		indexedLoops += trianglemesh.getAddIndexedLoops( gridLoop, self.vertices, zList )
		indexedGridTop = trianglemesh.getAddIndexedGrid( grid, self.vertices, 1.0 )
		indexedLoops.append( trianglemesh.getIndexedLoopFromIndexedGrid( indexedGridTop ) )
		trianglemesh.addPillarFromConvexLoopsGrids( self.faces, [ indexedGridBottom, indexedGridTop ], indexedLoops )
		for vertex in self.vertices:
			vertex.normalize()
			vertex.x *= self.radius.x
			vertex.y *= self.radius.y
			vertex.z *= self.radius.z
Exemplo n.º 2
0
def addSphereByRadius(faces, radius, vertexes, xmlElement):
	'Add sphere by radius.'
	maximumRadius = max(radius.x, radius.y, radius.z)
	numberOfInBetweens = max(int(0.25 * evaluate.getSidesBasedOnPrecision(maximumRadius, xmlElement)), 1)
	numberOfDivisions = numberOfInBetweens + 1
	bottomLeft = complex(-1.0, -1.0)
	topRight = complex(1.0, 1.0)
	extent = topRight - bottomLeft
	elementExtent = extent / numberOfDivisions
	grid = []
	for rowIndex in xrange(numberOfDivisions + 1):
		row = []
		grid.append(row)
		for columnIndex in xrange(numberOfDivisions + 1):
			point = complex(elementExtent.real * float(columnIndex), elementExtent.real * float(rowIndex)) + bottomLeft
			row.append(point)
	indexedGridBottom = trianglemesh.getAddIndexedGrid(grid, vertexes, -1.0)
	indexedGridBottomLoop = trianglemesh.getIndexedLoopFromIndexedGrid(indexedGridBottom)
	indexedLoops = [indexedGridBottomLoop]
	zList = []
	for zIndex in xrange(1, numberOfDivisions):
		z = elementExtent.real * float(zIndex) + bottomLeft.real
		zList.append(z)
	gridLoop = []
	for vertex in indexedGridBottomLoop:
		gridLoop.append( vertex.dropAxis() )
	indexedLoops += trianglemesh.getAddIndexedLoops(gridLoop, vertexes, zList)
	indexedGridTop = trianglemesh.getAddIndexedGrid(grid, vertexes, 1.0)
	indexedLoops.append(trianglemesh.getIndexedLoopFromIndexedGrid(indexedGridTop))
	trianglemesh.addPillarFromConvexLoopsGrids(faces, [indexedGridBottom, indexedGridTop], indexedLoops)
	for vertex in vertexes:
		vertex.normalize()
		vertex.x *= radius.x
		vertex.y *= radius.y
		vertex.z *= radius.z
Exemplo n.º 3
0
	def createShape(self):
		"Create the shape."
		square = [
			complex( - self.inradius.x, - self.inradius.y ),
			complex( self.inradius.x, - self.inradius.y ),
			complex( self.inradius.x, self.inradius.y ),
			complex( - self.inradius.x, self.inradius.y ) ]
		bottomTopSquare = trianglemesh.getAddIndexedLoops( square, self.vertexes, [ - self.inradius.z, self.inradius.z ] )
		trianglemesh.addPillarFromConvexLoops( self.faces, bottomTopSquare )
Exemplo n.º 4
0
	def createShape(self):
		"Create the shape."
		square = [
			complex( - self.inradius.x, - self.inradius.y ),
			complex( self.inradius.x, - self.inradius.y ),
			complex( self.inradius.x, self.inradius.y ),
			complex( - self.inradius.x, self.inradius.y ) ]
		bottomTopSquare = trianglemesh.getAddIndexedLoops( square, self.vertexes, [ - self.inradius.z, self.inradius.z ] )
		trianglemesh.addPillarByLoops( self.faces, bottomTopSquare )
Exemplo n.º 5
0
 def createShape(self):
     "Create the shape."
     square = [
         complex(-self.half.x, -self.half.y),
         complex(self.half.x, -self.half.y),
         complex(self.half.x, self.half.y),
         complex(-self.half.x, self.half.y)
     ]
     bottomTopSquare = trianglemesh.getAddIndexedLoops(
         square, self.vertices, [-self.half.z, self.half.z])
     trianglemesh.addPillarFromConvexLoops(self.faces, bottomTopSquare)
Exemplo n.º 6
0
 def createShape(self):
     "Create the shape."
     maximumRadius = max(self.radius.x, self.radius.y, self.radius.z)
     numberOfInBetweens = max(
         int(0.25 * evaluate.getSidesBasedOnPrecision(
             maximumRadius, self.xmlElement)), 1)
     numberOfDivisions = numberOfInBetweens + 1
     bottomLeft = complex(-1.0, -1.0)
     topRight = complex(1.0, 1.0)
     extent = topRight - bottomLeft
     elementExtent = extent / numberOfDivisions
     grid = []
     for rowIndex in xrange(numberOfDivisions + 1):
         row = []
         grid.append(row)
         for columnIndex in xrange(numberOfDivisions + 1):
             point = complex(
                 elementExtent.real * float(columnIndex),
                 elementExtent.real * float(rowIndex)) + bottomLeft
             row.append(point)
     indexedGridBottom = trianglemesh.getAddIndexedGrid(
         grid, self.vertexes, -1.0)
     indexedGridBottomLoop = trianglemesh.getIndexedLoopFromIndexedGrid(
         indexedGridBottom)
     indexedLoops = [indexedGridBottomLoop]
     zList = []
     for zIndex in xrange(1, numberOfDivisions):
         z = elementExtent.real * float(zIndex) + bottomLeft.real
         zList.append(z)
     gridLoop = []
     for vertex in indexedGridBottomLoop:
         gridLoop.append(vertex.dropAxis(2))
     indexedLoops += trianglemesh.getAddIndexedLoops(
         gridLoop, self.vertexes, zList)
     indexedGridTop = trianglemesh.getAddIndexedGrid(
         grid, self.vertexes, 1.0)
     indexedLoops.append(
         trianglemesh.getIndexedLoopFromIndexedGrid(indexedGridTop))
     trianglemesh.addPillarFromConvexLoopsGrids(
         self.faces, [indexedGridBottom, indexedGridTop], indexedLoops)
     for vertex in self.vertexes:
         vertex.normalize()
         vertex.x *= self.radius.x
         vertex.y *= self.radius.y
         vertex.z *= self.radius.z