Jump to content

  • Log In with Google      Sign In   
  • Create Account

Relationship bw graphics and collision meshes


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Krohm   Crossbones+   -  Reputation: 3249

Like
0Likes
Like

Posted 02 January 2013 - 08:57 AM

While in the process of fixing a bug with my system, I stumbled in an apparent limitation, albeit I'm not sure this limitation is real.

I cannot quite figure out whatever this problem is real or not so I figured out I'd probably ask you all.

 

Situation is as follows: my mesh format exports both a graphical mesh and a physics mesh. That is, each mesh resource exports a graphics and a physics mesh.

Each time the mesh is instantiated, if the instance is marked solid, a corresponding rigid body is spawned at graphical mesh location using the mesh exported physics model.

The transform used for the physics mesh is the same as the graphical mesh.

 

However, I am having a problem with this. It appears that under certain circumstances there might be the need to append a transform from graphical meshes to physics.

So far, this has been ignored. After all meshes are supposed to be authored "centered around the origin" and the physics mesh is assumed to match the graphics mesh.

I'm tempted to not provide this extra transform at all. I cannot quite figure out a case in which this would be needed. On the other side, I cannot really find a strong reason to not do that... besides noticing supporting this features needs some care.

 

Do I need to provide a graphics-to-physics transform? 

 

It appears to me that meshes requiring this feature would be not properly authored (at least according to my current standards). But I'm not sure. Opinions welcome.



Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 7991

Like
1Likes
Like

Posted 02 January 2013 - 09:19 AM

Do I need to provide a graphics-to-physics transform?

I don't think that you will need this at all. Rendering is more or less only a view of the physics model and the physics model should provide everything to handle game related features (hit detection, collision detection etc.).

 

I'm tempted to not provide this extra transform at all.

Don't add something without any requirement. It will only bloat the code  and most likely will be removed in a future version smile.png



#3 Krohm   Crossbones+   -  Reputation: 3249

Like
0Likes
Like

Posted 02 January 2013 - 01:46 PM

Without considering usage, I see those statements rather broad; both notions were considered prior to posting.

 

There's no requirement right now and likely will never be for some time. Shall the need arise, it will be a bug and hunted down as such. With all the consequences.

I still have to stress I do worry about being unable to support anything that is authored not origin-centered. What's worse, this works for hulls but not for boxes nor spheres. So there's quite some non-orthogonality.

 

What would happen is the follow. Consider a sphere-like object centered at (0, 1, 0) with 1 unit radius.

The spherical collision object generated instead would effectively be at (0, 0, 0).

Therefore, at runtime, the scripts would incorrectly cause the graphical mesh to float half a unit above surface.

 

I've been looking at the scripts I have here. None of them would work properly with a non-identity graphics-to-physics transform. Generic mesh manipulation would probably not work as intended and there's likely not even a way to let the script code know about such a transform.

 

Currently, the above example would be classified as incorrectly authored asset. 

I am still finding myself very uncomfortable in mandating all assets to be origin-centered. But I guess I should document this limitation with extra care, I suppose this is related with some specific usage where it makes sense.



#4 Ashaman73   Crossbones+   -  Reputation: 7991

Like
1Likes
Like

Posted 02 January 2013 - 03:42 PM

What would happen is the follow. Consider a sphere-like object centered at (0, 1, 0) with 1 unit radius.

The spherical collision object generated instead would effectively be at (0, 0, 0).

Therefore, at runtime, the scripts would incorrectly cause the graphical mesh to float half a unit above surface.

Maybe I misunderstood you at first, but I got the same issue. I solved it by keeping the physics mesh as main game object. To properly offset other entities (effects, mesh) I can add links to the physics mesh. As example I use a floor link which would be at (0,-0.5,0) in your example and connect the mesh to this link, so that the feet of a character would be always on floor level.

Additionally the render mesh can add more links for render effects, which could be statically offset-ed or connected to a bone, I'm going as far as to connect even link to link.

 

This way I can connect objects like this

physic entity <- mesh, effect or other physics entity

mesh <- other mesh or effect

 

For me it is important to keep the visual representation separated from the game world, that is, I can run only the game with physics without any rendering going on.

 

Yes, it could be useful to map a render mesh position back to the physics position, e.g. when an animated character holds a gun and you want to represent the gun by a physics object. Still I would prefer a physics only approach to keep it simple and to prevent feedback loops (physics->render mesh->physics->render mesh=mess). E.g. a simplified (ragdoll) physics representations of the character which is simulated by the physics engine, because when the gun should interact with the world, your physics engine must be able to manipulated the rendered animation (inverse kinetics), therefore the final character animation would be based on an animation driven forward physics combined with inverse kinetics.

 

But, to be honest, this could get really messy at times, think about a character which gun is locked in a closing door and the nice character animation is falling apart due to this lock.



#5 Krohm   Crossbones+   -  Reputation: 3249

Like
0Likes
Like

Posted 03 January 2013 - 08:26 AM

Maybe I misunderstood you at first, but I got the same issue. I solved it by keeping the physics mesh as main game object. To properly offset other entities (effects, mesh) I can add links to the physics mesh. As example I use a floor link which would be at (0,-0.5,0) in your example and connect the mesh to this link, so that the feet of a character would be always on floor level.
Additionally the render mesh can add more links for render effects, which could be statically offset-ed or connected to a bone, I'm going as far as to connect even link to link.

This is indeed a very useful suggestion! I have already links (I call them joints) information and I could probably use them for this purpose.

The problem is indeed compounded by the need to have kinematic rigid bodies which are looped by definition.

Nonetheless, after thinking another half a day at it, I have decided to let this go and mandate assets to be origin-centered when using box and sphere collision primitive.

Thank you very much. I've made a step forward into thinking... and I cannot make it work in my head, even supposing I can write everything needed to keep the information you suggested. My best bet is that the problem is too vague to have a decent solution so the only thing I can do is to really let everything as is... and hope this will be sufficient.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS