Exemple #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
Exemple #2
0
 def createShape(self):
     "Create the shape."
     halfHeight = 0.5 * self.height
     polygonBottom = []
     polygonTop = []
     imaginaryRadius = self.radiusZ
     if self.radiusZ == None:
         imaginaryRadius = self.radiusY
     sides = max(int(evaluate.getSides(max(imaginaryRadius, self.radiusX), self.xmlElement)), 3)
     sideAngle = 2.0 * math.pi / float(sides)
     for side in xrange(sides):
         angle = float(side) * sideAngle
         unitComplex = euclidean.getWiddershinsUnitPolar(angle)
         pointBottom = complex(unitComplex.real * self.radiusX, unitComplex.imag * imaginaryRadius)
         polygonBottom.append(pointBottom)
         if self.topOverBottom > 0.0:
             polygonTop.append(pointBottom * self.topOverBottom)
     if self.topOverBottom <= 0.0:
         polygonTop.append(complex())
     bottomTopPolygon = [
         trianglemesh.getAddIndexedLoop(polygonBottom, self.vertices, -halfHeight),
         trianglemesh.getAddIndexedLoop(polygonTop, self.vertices, halfHeight),
     ]
     trianglemesh.addPillarFromConvexLoops(self.faces, bottomTopPolygon)
     if self.radiusZ != None:
         for vertex in self.vertices:
             oldY = vertex.y
             vertex.y = vertex.z
             vertex.z = oldY
Exemple #3
0
	def createShape( self ):
		"Create the shape."
		halfHeight = 0.5 * self.height
		polygonBottom = []
		polygonTop = []
		imaginaryRadius = self.radiusZ
		if self.radiusZ == None:
			imaginaryRadius = self.radiusY
		sides = max( int( evaluate.getSides( max( imaginaryRadius, self.radiusX ), self.xmlElement ) ), 3 )
		sideAngle = 2.0 * math.pi / float( sides )
		for side in xrange( sides ):
			angle = float( side ) * sideAngle
			unitComplex = euclidean.getWiddershinsUnitPolar( angle )
			pointBottom = complex( unitComplex.real * self.radiusX, unitComplex.imag * imaginaryRadius )
			polygonBottom.append( pointBottom )
			if self.topOverBottom > 0.0:
				polygonTop.append( pointBottom * self.topOverBottom )
		if self.topOverBottom <= 0.0:
			polygonTop.append( complex() )
		bottomTopPolygon = [ trianglemesh.getAddIndexedLoop( polygonBottom, self.vertices, - halfHeight ), trianglemesh.getAddIndexedLoop( polygonTop, self.vertices, halfHeight ) ]
		trianglemesh.addPillarFromConvexLoops( self.faces, bottomTopPolygon )
		if self.radiusZ != None:
			for vertex in self.vertices:
				oldY = vertex.y
				vertex.y = vertex.z
				vertex.z = oldY
Exemple #4
0
def getRoundLoop( close, loop, sideLength, xmlElement ):
	"Get round loop."
	radius = getRadiusByPrefix( 'round', sideLength, xmlElement )
	if radius == 0.0:
		return loop
	roundLoop = []
	sidesPerRadian = 0.5 / math.pi * evaluate.getSides( sideLength, xmlElement )
	for pointIndex in xrange( len( loop ) ):
		begin = loop[ ( pointIndex + len( loop ) - 1 ) % len( loop ) ]
		center = loop[ pointIndex ]
		end = loop[ ( pointIndex + 1 ) % len( loop ) ]
		roundLoop += getRoundPath( begin, center, close, end, radius, sidesPerRadian )
	return euclidean.getLoopWithoutCloseSequentialPoints( close, roundLoop )
 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