About Store Forum Documentation Contact



Post Reply 
Custom phys object
Author Message
b1s Offline
Member

Post: #1
Custom phys object
For some reason when i create a phys object from my own mesh I wont get any physics. I mean there's no gravity or anything. The phys object is there but just wont fall when dropped.
Same object with automatic phys object works ok.
02-15-2010 11:53 PM
Find all posts by this user Quote this message in a reply
Masterxilo Offline
Member

Post: #2
RE: Custom phys object
Non convex meshes can't be dynamic in physx.

System: Windows 7 Ultimate 64 bit, Q6600 2.4 GHZ, 4GB RAM, nVidia GeForce 260 GTX 896 MB DDR3

Visit my site: hurricane-eye.webs.com
And read my blog: hurricane-eyeent.blogspot.com
02-15-2010 11:55 PM
Visit this user's website Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #3
RE: Custom phys object
omg.. thats just lame!
02-16-2010 12:17 AM
Find all posts by this user Quote this message in a reply
XeonXT Offline
Member

Post: #4
RE: Custom phys object
Agreed...so how does one do physics with convex meshes? Is this an outright limitation or are there workarounds?
02-16-2010 12:22 AM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #5
RE: Custom phys object
i saw something about attaching physics objects somewhere..
that might the workaround.

hmm.. i could swear i used mesh based physics objects in unity which is also physx.
(This post was last modified: 02-16-2010 12:26 AM by b1s.)
02-16-2010 12:25 AM
Find all posts by this user Quote this message in a reply
nero81af Offline
Member

Post: #6
RE: Custom phys object
what I have done in my project is create a physical object about the same size of the bounding box and than using actor's matrix to build up static (or animated in my case) mesh around it:
- in init create physics;
- in init create a containing actor from a capsule or something that wraps up your mesh;
- in update get sim physics (if world is not present otherwise world.update will do);
- in update use actor.matrix().pos to set up mesh pos;
this way simulations are done on a simpler object but you get the results on your mesh indirectly. Obviously if you want to move your mesh you have to move the actor (you can use controller instead of actor)
02-16-2010 11:05 AM
Find all posts by this user Quote this message in a reply
XeonXT Offline
Member

Post: #7
RE: Custom phys object
Yes, this is certainly a viable workaround, but that means we basically can't do physics with complicated shapes?
02-16-2010 07:35 PM
Find all posts by this user Quote this message in a reply
nero81af Offline
Member

Post: #8
RE: Custom phys object
yes you can.. just build with mesh editor a complex physical group, save it to file (.phys) then load it in the game using the physgroup object.. there's a really nice tutorial (actor from mesh) and nice explanation on how to build up the physical group in mesh editor in the documentation ^^
02-17-2010 09:45 AM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #9
RE: Custom phys object
this way it will have gravity and all?
02-17-2010 04:12 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #10
RE: Custom phys object
physx doesn't support dynamic Mesh based actors (its not efficient)
only convex, or shaped based (can be many shapes) can be dynamic
02-17-2010 04:25 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #11
RE: Custom phys object
i was wondering.. how to create a braking object.
if i have saved object in world with different parts.
how do i seperate the parts and create items from them? or something with physics.
Code:
    if (actor.vel().y>=0.8&&breakable)
    {
    Game::ObjParams &obj=*Game::Objs(breakable); // get barrel object parameters
    Game::World.objCreate(obj,Matrix(obj.scale(),this->pos()));    // create new object at (16,8,16) position and give objects default scaling
    for(int i = 0;i<obj.mesh()->parts();i++)
    {


    
    Game::ObjParams &obj2=*Game::Objs(breakable);
    Game::World.objCreate(obj2,Matrix(obj.scale(),this->pos()));    // create new object at (16,8,16) position and give objects default scaling
    obj2.mesh()->part(0).create(obj.mesh()->part(i));

i got about this far grin

best thing would be to create new objects from all the parts and create convex hulls from them.
(This post was last modified: 03-11-2010 05:16 AM by b1s.)
03-11-2010 05:11 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #12
RE: Custom phys object
yes, that's good idea to create separate objects

I would set a class let's say OBJ_DEBRIS (Debris : Game::Obj) just for the destroyed stuff.

I will be implementing automatic objects destroying in the future.
03-12-2010 09:52 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #13
RE: Custom phys object
the thing that got me here that i couldnt do was that i dont know how to seperate mesh parts to objects?


the assigning a part of a another mesh to a basemesh of an object thing..

could you give some example code for this?

if id have an obj class called depris.

that has some cube for a phys file. how do i assign one part of another mesh to that objects mesh..
hard to explain grin
03-13-2010 12:35 AM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #14
RE: Custom phys object
yeah i have now got this working just by creating a one fragment peace and saved that as an obj. when the object brakes it spawns few of the framents and a broken main part of the object.

not exactly what i was looking for but it will have to do now since i didn't manage to break mesh parts into objects.
03-14-2010 09:08 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #15
RE: Custom phys object
in a newly created debris objects you can store:

struct Debris
{
Mesh *mesh;
Int part_index;
03-14-2010 09:13 PM
Find all posts by this user Quote this message in a reply
Post Reply