View Single Post
  #1  
Old 08-24-2010, 12:58 PM
mkmatlock mkmatlock is offline
Member
 
Join Date: Jun 2010
Posts: 6
chain mesh collisions

Hi!

I have a chain link ( a plane, with transparent texturing ). I am trying to make a complete chain out of links programatically.

This works fine, however, when I try to simulate the chain hanging and swaying (by attaching one end to a joint, and setting "Collide Mesh"), vizard locks up completely.

I don't want the chain to bend at each link, just at the point from which it is hanging (the chain is supposed to be under high load, so lots of flopping around would be unrealistic).

I assume vizard locks up because the chainlink meshes technically intersect one another. Is there a way to apply gravity to an object WITHOUT giving it a collide<Type>() command?

Code follows:

Code:
import viz
import math
# distance is meters
# mass is in kilograms
# gravity is 9.81 m/s

viz.go()


viz.phys.enable()
viz.phys.setGravity([0, -9.81, 0])

viz.startlayer(viz.LINE_STRIP)
viz.vertexcolor([1,1,1])
viz.vertex([0,0,0])
viz.vertex([0,0,4])
viz.endlayer()

def create_axes(length, parent):
	viz.startlayer(viz.LINE_STRIP)
	viz.vertexcolor([0,0,1])
	viz.vertex([0,0,0])
	viz.vertex([0,0,length])
	viz.vertexcolor([0,1,0])
	viz.vertex([0,0,0])
	viz.vertex([0,length,0])
	viz.vertexcolor([1,0,0])
	viz.vertex([0,0,0])
	viz.vertex([length,0,0])
	object = viz.endlayer()
	if(parent != 0):
		object.parent(parent)
	return object

def create_chain(length):
	link_count = length / 0.1 + 1
	a = 0
	head = 0
	plink = 0
	while(a < link_count):
		if(head == 0):
			head = viz.add('data\\chainlinks.IVE')
			head.setScale([0.0142,0.0142,0.0142])
			head.collideMesh()
			plink = head
			
		else:
			link = viz.add('data\\chainlinks.IVE')
			link.collideMesh()
			link.parent(plink)
			link.setPosition([0,0,7])
			link.setEuler([0,0,90])
			plink = link
			
		a=a+1
	
	return head
	
	
chain = create_chain(4.0)
#chain.setEuler([0,90,0])
chain.setPosition([0,4,0])

joint = viz.phys.addBallJoint(chain, None, pos = [0,4,0])

create_axes(100, chain)
create_axes(1, 0)

viz.MainView.setPosition([5,2,5])
viz.MainView.lookat([0,2,0])
Reply With Quote