Beispiel #1
0
    def _markWalkableAreas(self):
        self.walkableMask = [True] * self.size * self.size
        index = 0
        for tz in xrange(self.size):
            for tx in xrange(self.size):
                v1, v2, v3, v4, v5, v6 = self.heightmap.getTrianglesAt(tx, tz)
                normal1 = MathUtil.getTriangleNormal(v1, v3, v2)
                normal2 = MathUtil.getTriangleNormal(v4, v6, v5)

                #mix the two normals to get an average
                normal = ((normal1 + normal2) / 2.0).normalize()
                height = self.heightmap.getHeight(tx, tz)
                if height < self.world.seaLevel or normal.y < 0.1:
                    self.walkableMask[index] = False
                index += 1
        self.astarMap = AStar.AStarMap(self.walkableMask, self.size, self.size)
Beispiel #2
0
    def _markWalkableAreas(self):
        self.walkableMask   = [True]*self.size*self.size
        index = 0
        for tz in xrange(self.size):
            for tx in xrange(self.size):
                v1,v2,v3,v4,v5,v6 = self.heightmap.getTrianglesAt( tx, tz )
                normal1 = MathUtil.getTriangleNormal( v1, v3, v2  )
                normal2 = MathUtil.getTriangleNormal( v4, v6, v5  )

                #mix the two normals to get an average
                normal = ((normal1 + normal2)/2.0).normalize()
                height = self.heightmap.getHeight(tx, tz)
                if height < self.world.seaLevel or normal.y < 0.1:
                    self.walkableMask[index] = False
                index += 1
        self.astarMap = AStar.AStarMap( self.walkableMask, self.size, self.size )
Beispiel #3
0
 def normalAt(self, x, y):
     t = self.getTriangleAtPosition(x, y)
     return MathUtil.getTriangleNormal(*t)
Beispiel #4
0
	def normalAt( self, x, y ):
		t = self.getTriangleAtPosition( x, y )
		return MathUtil.getTriangleNormal( *t )