View Single Post
  #8  
Old 05-03-2008, 12:38 AM
k_iwan k_iwan is offline
Member
 
Join Date: May 2006
Posts: 115
Red face Action sequence code.....

Here is the module that load the objects file and set-up the movements...

Code:
import viz
import vizact

#Ant 7(normal), 8 (stilts)and 9(stumps) are for scene 2
ant7 = viz.add('duck.cfg')
ant7.setScale(0.02,0.02,0.02)
ant7.idlepose(2)
ant7.disable(viz.RENDERING)
ant7.setPosition([1.000, 0.00, 0.000])
ant7.setEuler([90,0,0])

ant8 = viz.add('duck.cfg')
ant8.setScale(0.02,0.02,0.02)
ant8.idlepose(2)
ant8.disable(viz.RENDERING)
ant8.setPosition([1, 0.0, -0.200])
ant8.setEuler([90,0,0])

ant9 = viz.add('duck.cfg')
ant9.setScale(0.02,0.02,0.02)
ant9.idlepose(2)
ant9.disable(viz.RENDERING)
ant9.setPosition([1.000, 0.0, -0.4])
ant9.setEuler([90,0,0])


#Loading .OSG files that contains movement points of the ants
movementPaths = viz.add('antMovementPoints.osg')

#Setting up foraging path of normal condition in scene 4
CP_ACTOR_CONTROL = []

CP_COUNT_ACTOR_CONTROL = 45
CONTROLPOINT_ACTOR_CONTROL_PREFEX = 'control.path.'  #name of boxes = layera1 ... layera17
CONTROLPOINT_ACTOR_CONTROL_SUFFEX = ''  #use '_Cube' for .obj and '' for.osg

for cpNumber in range( 0,CP_COUNT_ACTOR_CONTROL):	
	nodename = '%s%03d%s' % (CONTROLPOINT_ACTOR_CONTROL_PREFEX, cpNumber,CONTROLPOINT_ACTOR_CONTROL_SUFFEX)
	pointNode = movementPaths.getChild(nodename)
	nodebox = pointNode.getBoundingBox()
	cntr = [nodebox.center[0],-nodebox.center[2],nodebox.center[1]]  #this is the xyz setting ONLY for .OSG file
	print 'control.path.',cpNumber, cntr
	CP_ACTOR_CONTROL.append(cntr)

#Setting up foraging path of stilts condition in scene 4
CP_ACTOR_STILTS = []

CP_COUNT_ACTOR_STILTS = 45
CONTROLPOINT_ACTOR_STILTS_PREFEX = 'stilts.path.'  #name of boxes = layera1 ... layera17
CONTROLPOINT_ACTOR_STILTS_SUFFEX = ''  #use '_Cube' for .obj and '' for.osg

for cpNumber in range( 0,CP_COUNT_ACTOR_STILTS):	
	nodename = '%s%03d%s' % (CONTROLPOINT_ACTOR_STILTS_PREFEX, cpNumber,CONTROLPOINT_ACTOR_STILTS_SUFFEX)
	pointNode = movementPaths.getChild(nodename)
	nodebox = pointNode.getBoundingBox()
	cntr = [nodebox.center[0],-nodebox.center[2],nodebox.center[1]]  #this is the xyz setting ONLY for .OSG file
	print 'stilts.path.',cpNumber, cntr
	CP_ACTOR_STILTS.append(cntr)


#Setting up foraging path of stumps condition in scene 4
CP_ACTOR_STUMPS = []

CP_COUNT_ACTOR_STUMPS = 45
CONTROLPOINT_ACTOR_STUMPS_PREFEX = 'stumps.path.'  #name of boxes = layera1 ... layera17
CONTROLPOINT_ACTOR_STUMPS_SUFFEX = ''  #use '_Cube' for .obj and '' for.osg

for cpNumber in range( 0,CP_COUNT_ACTOR_STUMPS):	
	nodename = '%s%03d%s' % (CONTROLPOINT_ACTOR_STUMPS_PREFEX, cpNumber,CONTROLPOINT_ACTOR_STUMPS_SUFFEX)
	pointNode = movementPaths.getChild(nodename)
	nodebox = pointNode.getBoundingBox()
	cntr = [nodebox.center[0],-nodebox.center[2],nodebox.center[1]]  #this is the xyz setting ONLY for .OSG file
	print 'stumps.path.',cpNumber, cntr
	CP_ACTOR_STUMPS.append(cntr)



#Setting up homebound path of normal condition in scene 4
CP_ACTOR_CONTROL_RETURN = []

CP_COUNT_ACTOR_CONTROL_RETURN = 45
CONTROLPOINT_ACTOR_CONTROL_RETURN_PREFEX = 'control.Rpath.'  #name of boxes = layera1 ... layera17
CONTROLPOINT_ACTOR_CONTROL_RETURN_SUFFEX = ''  #use '_Cube' for .obj and '' for.osg

for cpNumber in range( 0,CP_COUNT_ACTOR_CONTROL_RETURN):	
	nodename = '%s%03d%s' % (CONTROLPOINT_ACTOR_CONTROL_RETURN_PREFEX, cpNumber,CONTROLPOINT_ACTOR_CONTROL_RETURN_SUFFEX)
	pointNode = movementPaths.getChild(nodename)
	nodebox = pointNode.getBoundingBox()
	cntr = [nodebox.center[0],-nodebox.center[2],nodebox.center[1]]  #this is the xyz setting ONLY for .OSG file
	print 'control.Rpath.',cpNumber, cntr
	CP_ACTOR_CONTROL_RETURN.append(cntr)


#Setting up homebound path of stilts condition in scene 4
CP_ACTOR_STILTS_RETURN = []

CP_COUNT_ACTOR_STILTS_RETURN = 58
CONTROLPOINT_ACTOR_STILTS_RETURN_PREFEX = 'stilts.Rpath.'  #name of boxes = layera1 ... layera17
CONTROLPOINT_ACTOR_STILTS_RETURN_SUFFEX = ''  #use '_Cube' for .obj and '' for.osg

for cpNumber in range( 0,CP_COUNT_ACTOR_STILTS_RETURN):	
	nodename = '%s%03d%s' % (CONTROLPOINT_ACTOR_STILTS_RETURN_PREFEX, cpNumber,CONTROLPOINT_ACTOR_STILTS_RETURN_SUFFEX)
	pointNode = movementPaths.getChild(nodename)
	nodebox = pointNode.getBoundingBox()
	cntr = [nodebox.center[0],-nodebox.center[2],nodebox.center[1]]  #this is the xyz setting ONLY for .OSG file
	print 'stilts.Rpath.',cpNumber, cntr
	CP_ACTOR_STILTS_RETURN.append(cntr)
	
	
#Setting up homebound path of stumps condition in scene 4
CP_ACTOR_STUMPS_RETURN = []

CP_COUNT_ACTOR_STUMPS_RETURN = 54
CONTROLPOINT_ACTOR_STUMPS_RETURN_PREFEX = 'stumps.Rpath.'  #name of boxes = layera1 ... layera17
CONTROLPOINT_ACTOR_STUMPS_RETURN_SUFFEX = ''  #use '_Cube' for .obj and '' for.osg

for cpNumber in range( 0,CP_COUNT_ACTOR_STUMPS_RETURN):	
	nodename = '%s%03d%s' % (CONTROLPOINT_ACTOR_STUMPS_RETURN_PREFEX, cpNumber,CONTROLPOINT_ACTOR_STUMPS_RETURN_SUFFEX)
	pointNode = movementPaths.getChild(nodename)
	nodebox = pointNode.getBoundingBox()
	cntr = [nodebox.center[0],-nodebox.center[2],nodebox.center[1]]  #this is the xyz setting ONLY for .OSG file
	print 'stumps.Rpath.',cpNumber, cntr
	CP_ACTOR_STUMPS_RETURN.append(cntr)

#Actors Activation####################################
def actorsScene4Enable():
	ant7.enable(viz.RENDERING)
	ant8.enable(viz.RENDERING)
	ant9.enable(viz.RENDERING)
	
def controlAction():
	for each in CP_ACTOR_CONTROL:
		print "ant7.addAction(vizact.walkto(",each,"))"
		ant7.addAction(vizact.walkto(each[0], each[1], each[2], 0.22, 720, 1))

def stiltsAction():
	for each in CP_ACTOR_STILTS:
		print "ant8.addAction(vizact.walkto(",each,"))"
		ant8.addAction(vizact.walkto(each[0], each[1], each[2], 0.226, 720, 1))

def stumpsAction():
	for each in CP_ACTOR_STUMPS:
		print "ant9.addAction(vizact.walkto(",each,"))"
		ant9.addAction(vizact.walkto(each[0], each[1], each[2], 0.225, 720, 1))

def controlReturn():
	for each in CP_ACTOR_CONTROL_RETURN:
		print "ant7.addAction(vizact.walkto(",each,"))"
		ant7.addAction(vizact.walkto(each[0], each[1], each[2], 0.22, 720, 1))

def stiltsReturn():
	count = 0
	for each in CP_ACTOR_STILTS_RETURN:
		count = count + 1
		if count < 53:
			print "ant8.addAction(vizact.walkto(",each,"))"
			ant8.addAction(vizact.walkto(each[0], each[1], each[2], 0.226, 720, 1))
		
		else:
			print "ant8.addAction(vizact.walkto(",each,"))"
			ant8.addAction(vizact.walkto(each[0], each[1], each[2], 0.10, 900, 1))

def stumpsReturn():
	count = 0
	for each in CP_ACTOR_STUMPS_RETURN:
		count = count + 1
		if count < 44:
			print "ant9.addAction(vizact.walkto(",each,"))"
			ant9.addAction(vizact.walkto(each[0], each[1], each[2], 0.224, 720, 1))
		
		else:
			print "ant9.addAction(vizact.walkto(",each,"))"
			ant9.addAction(vizact.walkto(each[0], each[1], each[2], 0.10, 900, 1))


def pickupAnts():
	ant7.addAction(vizact.move(0, 0.067,0,3))
	ant8.addAction(vizact.move(0, 0.067,0,3))
	ant9.addAction(vizact.move(0, 0.067,0,3))

def dropAnts():
	ant7.addAction(vizact.move(0,-0.067,0,3))
	ant8.addAction(vizact.move(0,-0.067,0,3))
	ant9.addAction(vizact.move(0,-0.067,0,3))


def actorsScene4Disable():
	ant7.enable(viz.RENDERING)
	ant8.enable(viz.RENDERING)
	ant9.enable(viz.RENDERING)
During action, ant 7,8 don't go to the final box, but ant 9 hit the final destination. During return sequence, ant 7, 8, 9 don't go to the final destination.

Any ideas, or insight would be appreciated. Thank you.

Kind Regards,
Iwan
Reply With Quote