示例#1
0
	def new_goal(self):
		self.m_goal[0]=random.randint(0,14)
		self.m_goal[2]=random.randint(0,14)
		
		pos = self.get_rounded_pos()
		
		while(pathfinding.point_on_obstacle(self.m_goal) or pathfinding.point_at_pos(self.m_goal,pos)):
			self.m_goal[0]=random.randint(0,14)
			self.m_goal[2]=random.randint(0,14)
		
		pathfinding.pathfind(pos,self.m_goal,self.m_path)
		
		self.m_step = 0
示例#2
0
def run(frame_number):
    # get the frame rate by using an internal MEL script
    frame_rate = mel.eval("currentTimeUnitToFPS")

    # calculate the amount of time in seconds between each frame
    frame_time = 1.0 / frame_rate

    # special case if we are on the first frame then initialise the simulation
    global initialized
    global last_frame_number
    if initialized == False:
        if frame_number == 1:
            initialized = True
            pathfinding.initialise()
            init()
            trink = cmds.polySphere()
            cmds.xform(trink, t=(trinket[0], 0, trinket[2]))
            cmds.scale(50, 50, 50, trink)
            cmds.rename('trinket')
    elif initialized == True:
        if frame_number == 1:
            last_frame_number = 1

    # check to see if we have an event to process this frame
    if (frame_number - last_frame_number) == 1:
        for agent in Agents:
            #print agent
            if (pathfinding.point_at_pos(trinket,
                                         agent.get_rounded_pos()) == False):
                do_flocking_behaviour(agent)
                agent.agent_move(frame_time)

        print "Custom simulation run successfully at frame: " + str(
            frame_number)

        # we have successfully completed a run of the simulation
        # update the last frame number
        last_frame_number = frame_number
示例#3
0
def run(frame_number):
	# get the frame rate by using an internal MEL script
	frame_rate = mel.eval("currentTimeUnitToFPS")
	
	# calculate the amount of time in seconds between each frame
	frame_time = 1.0 / frame_rate
	
	# special case if we are on the first frame then initialise the simulation
	global initialized
	global last_frame_number
	if initialized == False:
		if frame_number == 1:
			initialized = True
			pathfinding.initialise()
			init()
			trink = cmds.polySphere()
			cmds.xform(trink,t=(trinket[0],0,trinket[2]))
			cmds.scale(50,50,50, trink)
			cmds.rename( 'trinket' )
	elif initialized == True:
		if frame_number == 1:
			last_frame_number = 1
	
	# check to see if we have an event to process this frame
	if (frame_number - last_frame_number) == 1:
		for agent in Agents:
			#print agent
			if (pathfinding.point_at_pos(trinket,agent.get_rounded_pos())==False):
				do_flocking_behaviour(agent)
				agent.agent_move(frame_time)
		
		print "Custom simulation run successfully at frame: "+str(frame_number)
		
		# we have successfully completed a run of the simulation
		# update the last frame number
		last_frame_number = frame_number
示例#4
0
	def check_step(self):
		pos = self.get_rounded_pos()
		
		if(pathfinding.point_at_pos(pos,self.m_path[self.m_step])):
			self.m_step += 1