Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Locked Meshes; What the crap.
Topic Started: Mar 14 2009, 10:15 PM (255 Views)
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
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);

current_tree_collision = GmnCreateTreeCollision(physX_master.o_world);
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,
1
);

}
// End the tree
GmnTreeCollisionEndBuild(current_tree_collision,true);
// save the tree
//ds_list_add(physX_master.list_static_mesh,current_tree_collision);
// Unlock the mesh
UnlockMesh(0);

// Create a colliding body
var new_collide;
new_collide = GmnCreateBody(physX_master.o_world,current_tree_collision,id);
GmnBodySetMass(physX_master.o_world,new_collide,0);
GmnBodySetPosition(physX_master.o_world,new_collide,argument1,argument2,argument3);
ds_list_add(physX_master.list_static_object,new_collide);

GmnReleaseCollision(current_tree_collision);
}

return true;


Am I doing this right? I think the problem is with generating the tree mesh, but I don't know if I'm doing the Locked Mesh calls correctly. Anybody know how? I've actually never used these functions before.
Blog|EHS
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
skarik
Mar 14 2009, 10:15 PM
Code:
 
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);
Beware that the indexes for y and z are switched around because of the internal coordinate system of U3D. So y has index 2 and z has index 1, instead of the other way around. (The same goes for the vertex normal components.)
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
Well, that's sexy. Everything works epic fine now.

MysteriXYZ, thank you for the tip about the YZ switch. I forgot about that.



Stickman now has full working physics.
Blog|EHS
Offline Profile Quote Post Goto Top
 
Naz
Member Avatar
Forum Leader
[ *  *  *  *  * ]
Well skar... blow him a kiss...
May 20th, 2016
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
Nazle
Mar 16 2009, 08:26 AM
Well skar... blow him a kiss...
I uh, am not sure if I'd want to do that. I am in debt to Myst, however.
Blog|EHS
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply