Springs Tissue by Zhiping, Qi and Shenyuan

From KokkugiaWiki

project development

Image:springsTissue-1_800.jpg Image:springsTissue-2_800.jpg Image:springsTissue-3_800.jpg

Main Function:

Sub Main()
	
	Dim contextPts, programPts, minLength, maxLength, i, ptPos, count
	Dim arrCPts(), arrPPts()
	Dim springC(), springP()
	
	minLength = 10
	maxLength = 200
	
	count = 0
	
	' contextPts
	contextPts = Rhino.GetObjects("select the context points", 1)
	For i = 0 To UBound(contextPts)
		ptPos = Rhino.PointCoordinates(contextPts(i))
		ReDim Preserve arrCPts(i)
		arrCPts(i) = ptPos
	Next
	' programPts
	programPts = Rhino.GetObjects("select the program points", 1)
	For i = 0 To UBound(programPts)
		ptPos = Rhino.PointCoordinates(programPts(i))
		ReDim Preserve arrPPts(i)
		arrPPts(i) = ptPos
	Next
	' springs
	Call addSprings(springC, springP, arrPPts, arrCPts, minLength, maxLength)
	
	
	' agent1
	Dim startAgents, iterations, pos, endPt, vel, maxVel, maxForce, arrAgents() ' ()-DYNAMIC
	Dim arrAgentPos(), ptCloud 
	
	' user input - start vectors of the agents
	startAgents = Rhino.GetObjects("select the starting agent vectors", 4)
	iterations = Rhino.GetInteger("how many steps/iterations", 200)
	
	maxVel = 10 ' FIRST SET THE VALUES
	maxForce = 2
	
	' compile an array of all the agents
	' agents(pos, vel, maxVel, maxForce)
	' arrAgents(agent1, ...)
	' arrAgents((pos, vel, maxVel, maxForce),(pos, vel, maxVel, maxForce),...)
	For i = 0 To UBound(startAgents)
		pos = Rhino.CurveStartPoint(startAgents(i))
		endPt = Rhino.CurveEndPoint(startAgents(i))
		vel = Rhino.VectorCreate(endPt, pos)
		ReDim Preserve arrAgents(i) ' BECAUSE DIM BEFORE ' Preserve NOT TO ERASE
		arrAgents(i) = Array(pos, vel, maxVel, maxForce) ' MAKE AN ARRAY
		
	Next
	
	For i = 0 To iterations-1
	
		Dim acc, vecAli, vecSep, vecCoh, vecAttC, vecAttP, j, springParam', srfCrv
		' loop through for each agents
		For j = 0 To UBound(arrAgents)
			
			' reset acc to 0 ' IN EACH STEP
			acc = Array(0,0,0)
			
			' get some spring infomation
			'springParam = Rhino.CurveClosestPoint(spring, arrAgents(j)(0))
						
			' call the behavior functions - aligh etc
			vecAli = align(arrAgents(j), arrAgents, 10) ' inte-
			vecSep = separate(arrAgents(j), arrAgents, 10)
			vecCoh = cohesion(arrAgents(j), arrAgents, 20)
			vecAttC = attSpringC(arrAgents(j), springC, 50)
			vecAttP = attSpringP(arrAgents(j), springP, 50)
			
			' weight - priority ' TO MODIFY
			vecAli = Rhino.VectorScale(vecAli, 5)
			vecSep = Rhino.VectorScale(vecSep, 1)
			vecCoh = Rhino.VectorScale(vecCoh, 1)
			vecAttC = Rhino.VectorScale(vecAttC, -1)
			vecAttP = Rhino.VectorScale(vecAttP, -1)
	
			' update the agents position
			'acc = Rhino.VectorAdd(acc, vecAli)
			'acc = Rhino.VectorAdd(acc, VecSep)
			'acc = Rhino.VectorAdd(acc, VecCoh)
			'acc = Rhino.VectorAdd(acc, VecAttC)
			acc = Rhino.VectorAdd(acc, VecAttP)
			
			' add acc to vel
			vel = Rhino.VectorAdd(arrAgents(j)(1), acc) ' IMPARTANT GET DATA FROM ARRAY
			' limit vel to maxVel
			vel = vectorLimit(vel,arrAgents(j)(2))
			' update the array
			arrAgents(j)(0) = Rhino.VectorAdd(arrAgents(j)(0), vel) ' MOVE
			arrAgents(j)(1) = vel	' NEW VEL
		Next
		' end j loop -arrAgents
		
		''''' arrSpringAgents
		'Dim vecSpringImpact
		'For j = 0 To UBound(arrSrfAgents)
		'	' srfAgent - call function
		'	vecSpringImpact = springImpact(arrSrfAgents(j), arrAgents, 3)
		'	' weight the vector
		'	vecSpringImpact = Rhino.VectorScale(vecSrfImpact, 0.5)
		'	' update the array
		'	' pos = pos + vecSrfImpact
		'	arrSrfAgents(j) = Rhino.VectorAdd(arrSrfAgents(j),vecSrfImpact)
		'Next
	
	
		' loop to make an array of positions
		count = count + 1
		For j = 0 To UBound(arrAgents)
			ReDim Preserve arrAgentPos(j) ' ALWAYS HAVE A DYNAMIC ARRAY
			arrAgentPos(j) = arrAgents(j)(0)
		Next
		
		
		Rhino.EnableRedraw False
		' delete the previous pointcloud
		'If i > 0 And count > 30 Then
	'	count = count +
		'End If
		
		If i > 0 And count = 30 Then ' FOR FIRST STEP
			'Rhino.DeleteObject ptCloud
			' count = 0
		End If
		' update the point cloud
		ptCloud = Rhino.AddPointCloud(arrAgentPos)
		
		' update the spring - move the programPts
		'Call Rhino.ObjectGripLocations(surface, arrSrfAgents)
		
		Rhino.EnableRedraw True
	
	Next

End Sub


COMMENTS NOV 5
the recent work is a little hard to understand as the images are very low res and the notes not clear. however the most evident issue at this stage is the lack of relationship between the swarming agents and the spring system. the spring system is a useful device for organising a network and seeking equilibrium. however this seems at odds with the swarm system, which appears to be operating at a very different scale and speed. it is important that the swarm agents exhibit a similar level of control to the spring agents and that they begin to form a coherent emergent whole. currently the swarm system appears to have little control and isn't responding to the small scale detail of the other systems, also their current trajectories appear very hard to reconcile into coherent geometry. you will need to adjust the maxVel and gain a higher level of control over these.

Views