What is the best way to use this 2D physics engine with 3D objects?

Feb 8, 2009 at 9:11 AM
What is the best way to use this 2D physics engine with 3D objects?  I only intend on moving the 3d objects on the X and Y axis so the  Farseer Engine still suits my needs.  Would the best way to do this be to generate a bitmap mask for every 3D object everytime the animation is updated and use that mask as a 2D collision object?  Seems to be.  I just have to figure out how to generate a black and white mask for every 3D object on the fly and compare it to others in the scene each time the animation is drawn...
Feb 8, 2009 at 9:25 AM
Welcome chancet! about your question: uh, probably not... Then you would be creating new geometries every frame of the animation and that would be a huge waste of resources. Your best bet is either to use simple collision geometries (ellipses or circles or rectangles) for collision that cover your entire models (and probably then some) during the animation or to make a bunch of generalized ones (like the previous method) but swap them in and out during the animation. Other people here will probably have better ideas though, so don't take mine too seriously.
Feb 8, 2009 at 10:47 AM
Thanks for the welcome and the quick reply RogueCommanderIX.  Hmm, I was thinkin maybe there wouldn't be too much computation involved.  All I need is some code to examine a 3d polygonal object in a bounding box in the viewport, and take any colour that is not white and make it black... and there you have a collision mask.  save that mask (in my case.. one for the characters and one for the swords they're holding) and use the masks for physics calculations.  can farseer do physics calculations on non geometrical objects  (random-shaped sprites)?.  it's been a long time since i checked farseer documentation so i don't know -- sorry.
Feb 8, 2009 at 10:51 AM
Edited Feb 8, 2009 at 11:31 AM
in the end, i really hope to be able to use 3d graphics without having to work with the extra "z" co-ordinate!  Anything to avoid that!  Even the map editor I want to do in 2D (tile based), and simply have the 3D objects placed in the 2D editor.

I thought since all the physics and collision detections are being done in 2D, any computer nowadays could do them... even at very high resolutions.  If my idea is feasible, can someone with good knowledge of the method please let me know if there is a max resolution I should stay under please? 

Will converting each 3D object to a black and white mask be processor intensive?  Or is this nothing compared to physics calculations of random-shaped pixel-perfect masks coliding with one another?  Should I aim to keep the resolution of my game no higher than 1024x768?

Oh, and sorry I forgot to mention that the game has a fixed overhead, isometric view.  Without this, collision detection would be wrong when characters fight in vertical positions from one another.
Developer
Feb 8, 2009 at 10:07 PM
@chancet - Do you plan on rotating the 3D objects on their X or Y axis? I actually had a little demo of using Farseer with 3D shapes but I'm not sure if I could find it. Making a mask every frame would be totally unacceptable with Farseer's current collision detection. I was planning on using a lower polygon count for collision detection and projecting the mesh to the physics plane. You should be able to do this by simply dropping the depth value of the vertices and using those polygons for collision. However, Farseer still can't do this in real time because it uses a grid based collision detection that takes to long to calculate. Once I get the new collision detection in place all this should be possible and I will probably make a demo. Until then all I can recommend is trying to use BulletX or Bepu physics libraries. Both are outstanding, but Bepu has a license you have to abide by. Personally I've only messed with Bepu and I found it quite simply to use and the latest version is really fast and stable. Rendering would be your biggest issue but since your doing 3D anyway you should be able to figure it out.
Feb 8, 2009 at 11:42 PM
thanks for the reply matt.  just rotating 3d objects on their x (horizontal) axis is fine with me.  i look forward to seeing your demo!  hmm, i will not use this method if it is too processor intensive like you say.  i may opt to just use simple 2D shapes that follow the path of the 3d object's animation.  hopefully, i can use the xna animation library on codeplex to create a second object flat 2D object that mimicks the underlying 3D objects' animation.  has anyone here implemented xna animation library successfully with a physics engine and do they have any tips, or code examples they can share?  Thanks again!
Developer
Feb 9, 2009 at 12:09 AM
@chancet - Your welcome. If you don't need to rotate the objects in any other axis than x then you could just render the model once from the side and then use the texture to polygon utility to create a collision polygon. To use this technique with animated 3D models you would need to render the 3D model for each frame and create a different Geom for each frame. This sounds good in theory but I'm not sure how Farseer would handle switching Geoms every frame. You may want to do some experimenting with some different techniques until you get something working well. I wish you the best of luck.
Feb 9, 2009 at 2:07 AM
thanks mat!  ok.  time for me to stop asking questions.  i have some reading to do.
Feb 9, 2009 at 4:24 PM
I actually tried this out a while back in WPF 3D and it worked just fine.  Farseer is just a 2D library and you can absolutely map two of your 3D axes to the 2D library.  If I get a spare minute I'll try and post the code/app and a link.