CompoundShapeEntry absolute position
Posted: Mon Apr 01, 2013 7:14 pm
Hi, I'm having this problem with CompoundShapeEntry positioning.
Results I'm getting are that some shapes positions within compound are not as expected - they're shifted several game units up in particular example. That's at least how it looks like when drawn using BepuModelDrawer. I'm not talking about physics not matching grapchics here, just particular shape entries being located at different positions than provided. Now, searching through posts here I learned that there's magic happening inside, related to physical center computations etc. I understand that this could change resulting position. That's ok, but is there any way I can set specific position of CompoundShapeEntries exactly where I need?
How I build CompoundBody:
1) there is a game WorldTransform for particular scene element. That scene element is complex so it's physical representation is built of several simple shapes like box, capsules and sphere
2) for each collision mesh, exported from DCC package, I create corresponding CompoundShapeEntry, i.e. BoxShape, CapsuleSphere etc., using CompoundShapeEntry ctor that takes shape, RigidTransform and mass
3) RigidTransform contains transformed by WorldTransform position and orientation I got form DCC - I checked here, my transformations are ok. Whenever I'm using my WorldTransform or just manualy provide some arbitrary vector3 position, it's drawn not where expected anyway
4) once I'm done with CompoundShapeEntries I create CompoundBody entity, supplying CompoundShapeEntry list created above
5) I don't alter CompoundBody position or any other property in any way
6) I add entity to the space
7) I add entity to BepuModelDrawer (Instanced version)
It looks like shapes are repositioned due to physical center computations - I understand lopgic behind that - but what I need here is to be able set their position in compound exactly how it was done in DCC package, or at least learn how I can control this to get the same result. What's interesting here is that after CompoundBody is created (and before added to the space - I don't know if it's of any relevance) I inspected its internals and looked at Shapes local positions - they are the same as provided during creation time.
Results I'm getting are that some shapes positions within compound are not as expected - they're shifted several game units up in particular example. That's at least how it looks like when drawn using BepuModelDrawer. I'm not talking about physics not matching grapchics here, just particular shape entries being located at different positions than provided. Now, searching through posts here I learned that there's magic happening inside, related to physical center computations etc. I understand that this could change resulting position. That's ok, but is there any way I can set specific position of CompoundShapeEntries exactly where I need?
How I build CompoundBody:
1) there is a game WorldTransform for particular scene element. That scene element is complex so it's physical representation is built of several simple shapes like box, capsules and sphere
2) for each collision mesh, exported from DCC package, I create corresponding CompoundShapeEntry, i.e. BoxShape, CapsuleSphere etc., using CompoundShapeEntry ctor that takes shape, RigidTransform and mass
3) RigidTransform contains transformed by WorldTransform position and orientation I got form DCC - I checked here, my transformations are ok. Whenever I'm using my WorldTransform or just manualy provide some arbitrary vector3 position, it's drawn not where expected anyway
4) once I'm done with CompoundShapeEntries I create CompoundBody entity, supplying CompoundShapeEntry list created above
5) I don't alter CompoundBody position or any other property in any way
6) I add entity to the space
7) I add entity to BepuModelDrawer (Instanced version)
It looks like shapes are repositioned due to physical center computations - I understand lopgic behind that - but what I need here is to be able set their position in compound exactly how it was done in DCC package, or at least learn how I can control this to get the same result. What's interesting here is that after CompoundBody is created (and before added to the space - I don't know if it's of any relevance) I inspected its internals and looked at Shapes local positions - they are the same as provided during creation time.