|
|
PyOde uses faces and vertices of meshes to detect collisions. Not sure how compatible that is with our code though
myspace = ode.Space() #space to put collision objects
meshdata = ode.TriMeshData() #create the data buffer
meshdata.build(verts,faces) #Put vertex and face data into the buffer
mesh = ode.GeomTriMesh(meshdata,myspace) #create collide mesh
from elementtree import ElementTree
def get_verts_faces_from_xml(path):
"""Returns vert,face data from the xml model file"""
#print dir(ElementTree)
tree = ElementTree.parse(path)
root = tree.getroot()
submeshes = root.find("submeshes").getchildren()
facedata = []
vertdata = []
for submesh in submeshes:
faces = submesh.find("faces").getchildren()
vertexbuffers = submesh.find("geometry").getchildren()
for face in faces:
indices = [int(face.get(x)) for x in ["v1","v2","v3"]]
facedata.append(tuple(indices))
for vb in vertexbuffers:
if "positions" in vb.keys():
verts = vb.getchildren()
for v in verts:
pos = v.find("position")
xyz = [eval(pos.get(x)) for x in "xyz"]
vertdata.append(tuple(xyz))
return vertdata,facedata
Categories: None
The words you entered did not match the given text. Please try again.
Oops!
Oops, you forgot something.