Once you have the collision tree, you can use it like any other collision object and create a body with the tree for it's collision. The only drawback is that the a body with a tree for collision cannot be dynamic - that is it will always have a mass of 0.
-hanson
Okay, so I'm pretty much doing everything right. Does the third argument of a body matter, or whatever argument of the tree collision? Like, that ID argument at the end. For example, this is my code:
// PhysXMasterAddStaticWorld(u3d_index,x,y,z)
// Locks a specified u3d_index, takes the coordinates
// and gets a physics mesh from that.
var i, i_max, current_tree_collision;
i_max = GetMeshCount();
for (i = 0; i < i_max; i += 1)
{
external_call(global.u3d_lock_mesh,0,argument0,i,0,0);
// Create the collision
current_tree_collision = GmnCreateTreeCollision(physX_master.o_world);
// Begin the tree
GmnTreeCollisionBeginBuild(current_tree_collision);
var j, j_max, x1, x2, x3, y1, y2, y3, z1, z2, z3, ct;
j_max = GetLockedMeshTriangleCount(0);
for (j = 0; j < j_max; j += 1)
{
ct = GetLockedMeshTriangle(0,j,0);
x1 = GetLockedMeshVertex(0,ct,0);
y1 = GetLockedMeshVertex(0,ct,1);
z1 = GetLockedMeshVertex(0,ct,2);
ct = GetLockedMeshTriangle(0,j,1);
x2 = GetLockedMeshVertex(0,ct,0);
y2 = GetLockedMeshVertex(0,ct,1);
z2 = GetLockedMeshVertex(0,ct,2);
ct = GetLockedMeshTriangle(0,j,2);
x3 = GetLockedMeshVertex(0,ct,0);
y3 = GetLockedMeshVertex(0,ct,1);
z3 = GetLockedMeshVertex(0,ct,2);
GmnTreeCollisionAddFace(current_tree_collision,
x1,y1,z1,
x2,y2,z2,
x3,y3,z3,
(i+1)*id
);
}
// End the tree
GmnTreeCollisionEndBuild(current_tree_collision,true);
// save the tree
ds_list_add(physX_master.list_static_mesh,current_tree_col
lision);
// Unlock the mesh
UnlockMesh(0);
// Create a colliding body
var new_body;
new_body = GmnCreateBody(physX_master.o_world,current_tree_collision,id);
GmnBodySetMass(physX_master.o_world,new_body,0);
GmnBodySetPosition(physX_master.o_world,new_body,argument1,argume
nt2,argument3);
ds_list_add(physX_master.list_static_object,new_body);
//GmnReleaseCollision(current_tree_collision);
}
return true;I usually have up to four meshes in one file, however, I can't really get any to collide. I dunno.
I know I didn't have to post the whole thing, but I don't know about any specifics, so would there be anything else I need to know about collision trees? Everything else works fine.