コード例 #1
0
ファイル: city.py プロジェクト: johnfredcee/Generators
 def build_bounding_box(self):
     self.topleft = vec3(0.0, 0.0, 0.0)
     self.bottomright = vec3(0.0, 0.0, 0.0)
     for c in self.end_points:
         if c.x < self.topleft.x:
             self.topleft.x = c.x
         if c.y < self.topleft.y:
             self.topleft.y = c.y
         if c.x > self.bottomright.x:
             self.bottomright.x = c.x
         if c.y > self.bottomright.y:
             self.bottomright.y = c.y
コード例 #2
0
 def build_bounding_box(self):
     self.topleft = vec3(0.0,0.0,0.0)
     self.bottomright = vec3(0.0,0.0,0.0)
     for c in self.end_points:
         if (c.x < self.topleft.x):
             self.topleft.x = c.x
         if (c.y < self.topleft.y):
             self.topleft.y  = c.y
         if (c.x > self.bottomright.x):
             self.bottomright.x = c.x
         if (c.y > self.bottomright.y):
             self.bottomright.y  = c.y
コード例 #3
0
ファイル: dungeongen.py プロジェクト: johnfredcee/Generators
	def build_room_geometry(self):
		""" Given that the rooms have been identified, flesh out their geometry """
		for r in self.rooms:
			r.build_geometry(self.end_points)
			doors = []
			for point in r.points:
				line = ( r.centre_point, point )
				## now, interoplate a bit along the line in order to get the vertex of a polygon
				door_point = vec2((line[1].x - line[0].x) * 0.25 + line[0].x,
						  (line[1].y - line[0].y) * 0.25 + line[0].y)
				r.doors += [ door_point ]
				# door_line = ( door_point, geom.line_exp_perp_2d(line[0], line[1], door_point) )
				# door_line_delta = door_line[1] - door_line[0]
				# door_line_delta = door_line_delta * 1.0 / door_line_delta.length()
				# door_line = ( door_point + ( door_line_delta * 0.02 ) , door_point - ( door_line_delta * 0.02 ) )
				# r.doors = r.doors + [ door_line ]
			# print "Points: ", r.points
			for ci in r.connections:
				connection = self.connections[ci]
				# print "Room centere %s " % r.centre_point
				# print "Connection %d (%d,%d) " % (ci, self.connections[ci][0], self.connections[ci][1] )
				# print "Connection %s %s " % (self.end_points[self.connections[ci][0]], self.end_points[self.connections[ci][1]] ) 
				corridor = self.corridors[ci]
				# print "Corridor ends 0 %s 1 % s " % (corridor.end_points[0], corridor.end_points[1])
				end = connection.closest(r.centre_point, self.end_points)
				# print "end is %d " % end
				assert(corridor.end_points[end] == vec3(r.centre_point.x, r.centre_point[1], 0.0))
				corridor.shorten_corridor(0.25, end, self.corridor_width)
			r.build_floorplan(self.corridors, self.end_points)
				
		return
コード例 #4
0
ファイル: dungeongen.py プロジェクト: yazici/Generators
    def build_room_geometry(self):
        """ Given that the rooms have been identified, flesh out their geometry """
        for r in self.rooms:
            r.build_geometry(self.end_points)
            doors = []
            for point in r.points:
                line = (r.centre_point, point)
                ## now, interoplate a bit along the line in order to get the vertex of a polygon
                door_point = vec2((line[1].x - line[0].x) * 0.25 + line[0].x,
                                  (line[1].y - line[0].y) * 0.25 + line[0].y)
                r.doors += [door_point]
                # door_line = ( door_point, geom.line_exp_perp_2d(line[0], line[1], door_point) )
                # door_line_delta = door_line[1] - door_line[0]
                # door_line_delta = door_line_delta * 1.0 / door_line_delta.length()
                # door_line = ( door_point + ( door_line_delta * 0.02 ) , door_point - ( door_line_delta * 0.02 ) )
                # r.doors = r.doors + [ door_line ]
            # print "Points: ", r.points
            for ci in r.connections:
                connection = self.connections[ci]
                # print "Room centere %s " % r.centre_point
                # print "Connection %d (%d,%d) " % (ci, self.connections[ci][0], self.connections[ci][1] )
                # print "Connection %s %s " % (self.end_points[self.connections[ci][0]], self.end_points[self.connections[ci][1]] )
                corridor = self.corridors[ci]
                # print "Corridor ends 0 %s 1 % s " % (corridor.end_points[0], corridor.end_points[1])
                end = connection.closest(r.centre_point, self.end_points)
                # print "end is %d " % end
                assert (corridor.end_points[end] == vec3(
                    r.centre_point.x, r.centre_point[1], 0.0))
                corridor.shorten_corridor(0.25, end, self.corridor_width)
            r.build_floorplan(self.corridors, self.end_points)

        return
コード例 #5
0
ファイル: dungeongen.py プロジェクト: johnfredcee/Generators
	def generate_end_points(self, peturbation):
		self.end_points = []
		max_dist = math.sqrt(self.gridx * self.gridx + self.gridy * self.gridy)
		for x in range(-self.gridx,self.gridx):
			for y in range(-self.gridy, self.gridy):
				distance = math.sqrt(x * x + y * y) / max_dist
				if (random.gauss(0.0,1.0) > distance):
					x_peturbation = random.random() * peturbation
					y_peturbation = random.random() * peturbation
					self.end_points.append(vec3((x + x_peturbation) / self.gridx, (y + y_peturbation) / self.gridy, 0.0))
		return
コード例 #6
0
 def generate_end_points(self, peturbation):
     """ Generate the end points of each line in the network"""
     self.end_points = []
     max_dist = math.sqrt(self.gridx * self.gridx + self.gridy * self.gridy)
     for x in range(-self.gridx,self.gridx):
         for y in range(-self.gridy, self.gridy):
             distance = math.sqrt(x * x + y * y) / max_dist
             if (random.gauss(0.0,1.0) > distance):
                 x_peturbation = random.random() * peturbation
                 y_peturbation = random.random() * peturbation
                 self.end_points.append(vec3((x + x_peturbation) / self.gridx, (y + y_peturbation) / self.gridy, 1.0))
     return
コード例 #7
0
ファイル: city.py プロジェクト: johnfredcee/Generators
 def generate_end_points(self, peturbation):
     """ Generate the end points of each line in the network"""
     self.end_points = []
     max_dist = math.sqrt(self.gridx * self.gridx + self.gridy * self.gridy)
     for x in range(-self.gridx, self.gridx):
         for y in range(-self.gridy, self.gridy):
             distance = math.sqrt(x * x + y * y) / max_dist
             if random.gauss(0.0, 1.0) > distance:
                 x_peturbation = random.random() * peturbation
                 y_peturbation = random.random() * peturbation
                 self.end_points.append(
                     vec3((x + x_peturbation) / self.gridx, (y + y_peturbation) / self.gridy, 1.0)
                 )
     return