[CLOSED] - Farseer Phsyics Integration - Any pointers?
by Ron Barbosa · in Torque X 2D · 07/29/2010 (12:51 pm) · 234 replies
Hey all...I've just recently started looking at some demos and videos for Farseer Physics.
I was curious if anyone here had done or is considering a Farseer integration with TorqueX. If so, how's it going for you?
I am admittedly ignorant in the use of the physics engine, so I have no idea where to begin...but I'm just curious if folks are even trying this and whether or not it integrates fairly simply or if it will detract too much attention from my game build.
I don't want to take a 2-month detour from my game project just to integrate the physics. My game project is going to be a value proposition. I want to sell it cheap and see if I can push volume...so if it doesn't have a proper physics implementation, or uses only the TX physics...that's ok. But if I can spend a couple of weeks or a month on the Farseer integration...that might help push sales volume.
Thanks!
--RB
I was curious if anyone here had done or is considering a Farseer integration with TorqueX. If so, how's it going for you?
I am admittedly ignorant in the use of the physics engine, so I have no idea where to begin...but I'm just curious if folks are even trying this and whether or not it integrates fairly simply or if it will detract too much attention from my game build.
I don't want to take a 2-month detour from my game project just to integrate the physics. My game project is going to be a value proposition. I want to sell it cheap and see if I can push volume...so if it doesn't have a proper physics implementation, or uses only the TX physics...that's ok. But if I can spend a couple of weeks or a month on the Farseer integration...that might help push sales volume.
Thanks!
--RB
#62
If anyone needs help setting it up, send me an email.
08/19/2010 (3:54 am)
@Pino/Ron you guys are GREAT! Everything is up and running, time to start experimenting! If anyone needs help setting it up, send me an email.
#63
I'm about to make another submission tonight that will expose some more configurable properties in the Body and Geom components (things like friction and drag) as well as some properties for the physics simulation itself that can help in performance tuning.
Pino did a code review for these changes last night and made some change recommendations...we're discussing those now, and I should have them into the repo by 8PM or 9PM East Coast US time.
This new set of changes I'm making will intercept the functionality of T2DPhysicsComponent if you use it in conjunction with FSBodyComponent on the same SceneObject. This change will let you add the stock MoveComponent that comes with TorqueX (which requires a T2DPhysicsComponent) and then you can actually move the bodies around and influence the simulation.
Modifying MoveComponent to route directly through the FSBodyComponent would have been just as easy, but it's best not to have T2DPhysicsComponent processing physics and then Farseer doing the same thing...you'll end up double dipping on your calculations and nothing will work right.
SO TO BE CLEAR if you have a T2DPhysicsComponent and an FSBodyComponent on the same scene object, T2DPhysicsComponent will NOT process ticks, and all changes to the T2DPhysicsComponent's Velocity and AngularVelocity will be routed through to the FSBodyComponent equivalents.
ONE MORE TIME if you don't want the Farseer functionality, DON'T use the FSBodyComponent on your scene objects. =)
Enjoy!
--RB
08/19/2010 (11:59 am)
@Aaron...glad you got this stuff working last night. It's pretty fun to play around with it once you get the sandbox working.I'm about to make another submission tonight that will expose some more configurable properties in the Body and Geom components (things like friction and drag) as well as some properties for the physics simulation itself that can help in performance tuning.
Pino did a code review for these changes last night and made some change recommendations...we're discussing those now, and I should have them into the repo by 8PM or 9PM East Coast US time.
This new set of changes I'm making will intercept the functionality of T2DPhysicsComponent if you use it in conjunction with FSBodyComponent on the same SceneObject. This change will let you add the stock MoveComponent that comes with TorqueX (which requires a T2DPhysicsComponent) and then you can actually move the bodies around and influence the simulation.
Modifying MoveComponent to route directly through the FSBodyComponent would have been just as easy, but it's best not to have T2DPhysicsComponent processing physics and then Farseer doing the same thing...you'll end up double dipping on your calculations and nothing will work right.
SO TO BE CLEAR if you have a T2DPhysicsComponent and an FSBodyComponent on the same scene object, T2DPhysicsComponent will NOT process ticks, and all changes to the T2DPhysicsComponent's Velocity and AngularVelocity will be routed through to the FSBodyComponent equivalents.
ONE MORE TIME if you don't want the Farseer functionality, DON'T use the FSBodyComponent on your scene objects. =)
Enjoy!
--RB
#64
I have tested out the physics and they look pretty good. I didn't experience any problems with a standard deployment.
However, I couldn't get the components to show up in the TX builder when I was using the platformer kit. I know this probably isn't a big deal. But Im sure other people are wanting to do the same thing (Farseer with the Platformer kit). So maybe it might be best to take care of that now. :)
Thanks again for your time on this. :)
08/19/2010 (5:27 pm)
Hi Ron,I have tested out the physics and they look pretty good. I didn't experience any problems with a standard deployment.
However, I couldn't get the components to show up in the TX builder when I was using the platformer kit. I know this probably isn't a big deal. But Im sure other people are wanting to do the same thing (Farseer with the Platformer kit). So maybe it might be best to take care of that now. :)
Thanks again for your time on this. :)
#66
08/19/2010 (5:47 pm)
I have not would I have to add references to the Farseer project or th Platformer framework?
#67
I don't own the PSK, so I'm not quite sure how it interacts with a standard implementation, but I'd assume when you create a PSK project, you probably end up with:
The game and PSK projects would most likely have references to the TorqueX Core and TorqueX 2D projects.
You would need to unlink the references from those projects, and point them to the TorqueX Core and TorqueX 2D projects from the downloaded repo.
This is why (in the instructions I emailed you last night) I advised you to dump the repo under your VS2008 projects folder, and then just leave it there. That way all of your game projects (with a little bit of work on your part) can be relinked to point to the repo which will include the Farseer Integration.
Unfortunately, there's nothing I or any other community contributor can do to "fix" this problem. You as the developer, need to set your references appropriately. This is just the nature of the beast when using outside contributions to your projects.
Hope this helps...
--RB
08/19/2010 (5:55 pm)
@John...basically you'd want to follow the steps I sent you in the email last night for your game project that uses the PSK.I don't own the PSK, so I'm not quite sure how it interacts with a standard implementation, but I'd assume when you create a PSK project, you probably end up with:
- A TorqueX Core project
- A TorqueX 2D project
- A Game project
- A PSK project
The game and PSK projects would most likely have references to the TorqueX Core and TorqueX 2D projects.
You would need to unlink the references from those projects, and point them to the TorqueX Core and TorqueX 2D projects from the downloaded repo.
This is why (in the instructions I emailed you last night) I advised you to dump the repo under your VS2008 projects folder, and then just leave it there. That way all of your game projects (with a little bit of work on your part) can be relinked to point to the repo which will include the Farseer Integration.
Unfortunately, there's nothing I or any other community contributor can do to "fix" this problem. You as the developer, need to set your references appropriately. This is just the nature of the beast when using outside contributions to your projects.
Hope this helps...
--RB
#68
GarageGames.TorqueX.Framework, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side.
I think it might be a version issue. But im going to keep pluging away at it. :)
08/19/2010 (6:32 pm)
Ron the steps you gave me worked out perfectly. Although Im having some problems with he PSK. I know you don't need to solve it. Im going to try :)GarageGames.TorqueX.Framework, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side.
I think it might be a version issue. But im going to keep pluging away at it. :)
#69
If your PSK project previously had a DLL reference to Torque X and/or Torque X Core, and then you added a Project reference to the repo projects. Then everything that's defined in the DLL will already exist when the repo projects try to do their part.
In the solution explorer, there's a "References" node. Expand that node and see if you have references to any "GarageGames" DLLs. If so, remove them, and try to recompile.
Keep plugging and posting...either you'll figure it out or someone here will be help you find a solution.
--RB
08/19/2010 (6:41 pm)
@John...maybe what this is referring to (and this is just me thinking out loud) is that you might have "double" references somewhere.If your PSK project previously had a DLL reference to Torque X and/or Torque X Core, and then you added a Project reference to the repo projects. Then everything that's defined in the DLL will already exist when the repo projects try to do their part.
In the solution explorer, there's a "References" node. Expand that node and see if you have references to any "GarageGames" DLLs. If so, remove them, and try to recompile.
Keep plugging and posting...either you'll figure it out or someone here will be help you find a solution.
--RB
#70
@Ron: I have been recreating the farseer Demo's from The Manual and so far everything is working great in TXB. I just have the Angle Spring to figure out, and while reading I noticed there is a missing component -> FSFixedAngleSpringComponent
Aaron
08/19/2010 (6:49 pm)
@John: I have the PSK, I will try to set it up right now and let you know my outcome.@Ron: I have been recreating the farseer Demo's from The Manual and so far everything is working great in TXB. I just have the Angle Spring to figure out, and while reading I noticed there is a missing component -> FSFixedAngleSpringComponent
Aaron
#71
Aaron
08/19/2010 (7:06 pm)
@John: I got it to work. You need to add the Torque2D and TorqueCore reference to the PlatformerFramework project, just like you did for the Game project. This is because the references are removed when you remove the old Torque2D and TorqueCore projects.Aaron
#72
The only situation where I couldn't combine the fixed and dynamic versions into one component was in the case of linear springs. While both the fixed and dynamic version of linear spring use the same type of arguments, their names and the way they are interpreted by Farseer are so different, that I couldn't elegantly combine them into one class. I tried...but it made me feel dirty. ;)
So I decided it was best to give that spring type 2 separate classes and name the properties according to the proper type.
Hope that makes sense...
What you WILL find, no doubt, is that there are many more properties in the Farseer native classes than I have exposed publicly to TXB. This is the work I'm actively doing now. Reading the manual, and the code, and exposing more and more of the properties so that the line between interacting with native Farseer and using the TX integration components becomes very blurred. Ultimately, I would like a Farseer expert to be able to look at TXB and know EXACTLY how every piece functions and what every property in TXB relates to in Farseer.
But this will take some time...
;)
--RB
08/19/2010 (7:10 pm)
@Aaron...actually FSAngleSpringComponent has an "IsFixed" flag. Both the fixed and dynamic functionality of that spring is built into a single component.The only situation where I couldn't combine the fixed and dynamic versions into one component was in the case of linear springs. While both the fixed and dynamic version of linear spring use the same type of arguments, their names and the way they are interpreted by Farseer are so different, that I couldn't elegantly combine them into one class. I tried...but it made me feel dirty. ;)
So I decided it was best to give that spring type 2 separate classes and name the properties according to the proper type.
Hope that makes sense...
What you WILL find, no doubt, is that there are many more properties in the Farseer native classes than I have exposed publicly to TXB. This is the work I'm actively doing now. Reading the manual, and the code, and exposing more and more of the properties so that the line between interacting with native Farseer and using the TX integration components becomes very blurred. Ultimately, I would like a Farseer expert to be able to look at TXB and know EXACTLY how every piece functions and what every property in TXB relates to in Farseer.
But this will take some time...
;)
--RB
#73
Did you manage to get the PSK's components up in the Components layout in TX builder? :)
08/19/2010 (7:16 pm)
@ Aaron Did you manage to get the PSK's components up in the Components layout in TX builder? :)
#74
I see what's being done in the manual, but it's an oversimplification. For a fixed angle spring to do what's shown in the manual, you actually need 2 bodies, a revolute joint, and a fixed angle spring.
I looked through the C# code that comes with the full Farseer package, and it's a bit hairy. It goes through 4 or 5 different helper classes just to create that fixed angle spring behavior.
I was starting to lose focus on the integration, so I decided to step back and just implement the spring and let the developers (you guys) decide how to make it useful. ;)
I'm still dying to replicate that example for myself, though. When I figure it out...I'll share.
--RB
08/19/2010 (7:34 pm)
@Aaron...by the way. When I first shared the code with Pino to integrate into the repository...I mentioned to him that the only component I couldn't find a way to meaningfully test was the FSAngleSpringComponent. ;)I see what's being done in the manual, but it's an oversimplification. For a fixed angle spring to do what's shown in the manual, you actually need 2 bodies, a revolute joint, and a fixed angle spring.
I looked through the C# code that comes with the full Farseer package, and it's a bit hairy. It goes through 4 or 5 different helper classes just to create that fixed angle spring behavior.
I was starting to lose focus on the integration, so I decided to step back and just implement the spring and let the developers (you guys) decide how to make it useful. ;)
I'm still dying to replicate that example for myself, though. When I figure it out...I'll share.
--RB
#75
@Ron: I will keep testing the AngleSpringComponent myself and let you know if i get success with it.
08/19/2010 (8:15 pm)
@John: Yes, the PSK components are all showing up in TXB. Send me and email and I will reply with step by step instructions.@Ron: I will keep testing the AngleSpringComponent myself and let you know if i get success with it.
#76
If you want the latest updates, either run update on your checkout (if you have a checkout) or get a new export from the HEAD revision of the repo.
I most likely won't work on this integration again until the weekend. Hopefully you guys have enough to chew on for a few days.
--RB
08/19/2010 (11:27 pm)
Hey all...I submitted some additional updates today that should be useful. The ties into T2DSceneObject and T2DPhysicsComponent (see comment #63 in this thread), and some more public properties exposed to TXB.If you want the latest updates, either run update on your checkout (if you have a checkout) or get a new export from the HEAD revision of the repo.
I most likely won't work on this integration again until the weekend. Hopefully you guys have enough to chew on for a few days.
--RB
#77
08/20/2010 (4:28 am)
Excellent work Ron!! I just have to think something, and you have it already made! :-)
#78
@Ron: when building The Xbox360FarseerPhysicsXNA it gives a warning. Warning: The referenced component 'System.Data' could not be found. Not sure how important this is, everything worked great on the xbox.
08/20/2010 (7:04 am)
After setting up the movement component I had to test it on the big screen with the xbox :-) It was so fun just to use momentum and spin things into other objects. @Ron: when building The Xbox360FarseerPhysicsXNA it gives a warning. Warning: The referenced component 'System.Data' could not be found. Not sure how important this is, everything worked great on the xbox.
#79
I've just corrected that and committed the change (Commit revision 28) so update to the last version to have it. Thanks for pointing that out :)
08/20/2010 (9:08 am)
@Aaron: that System.Data reference is created by Visual Studio when it generates the Xbox 360 copy of a Windows project having that reference. I forgot to delete it when I created the project :)I've just corrected that and committed the change (Commit revision 28) so update to the last version to have it. Thanks for pointing that out :)
#80
@Ron: I dont believe the FSAngleSpringComponent "isFixed" is working. The manual (referring to the documentation/demo using a FixedAngleSpring) says "The fixed versions mean that the spring is anchored to the world and not to another body as their non-fixed versions". This could possibly be what is preventing the spring to build tension from the Revolute Joint?
08/20/2010 (9:33 am)
No Problem :-)@Ron: I dont believe the FSAngleSpringComponent "isFixed" is working. The manual (referring to the documentation/demo using a FixedAngleSpring) says "The fixed versions mean that the spring is anchored to the world and not to another body as their non-fixed versions". This could possibly be what is preventing the spring to build tension from the Revolute Joint?
Torque Owner Ron Barbosa
Disposable Fun
It will mature over time, but the base that's in place should allow folks to get things started.
--RB