Game Development Community

[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
#181
09/02/2010 (10:20 pm)
Man I am so envious, I have not had time to mess with this much, well almost not at all. I hope we see some example code.

This is getting cool.
#182
09/02/2010 (10:55 pm)
@Henry...I hope we see some example code too. ;)

In all honesty, Henry, I've just been bouncing from component to component trying to get as much code in the community's hands as possible. But I myself have not even begun to use it yet. :)

Pino and Aaron have some pretty cool little mini-projects going.

@Aaron...way busy day at work today...came home late and running behind with home "stuff," so I will most likely not make it back to the keyboard today (at least not for anything substantial).

Keep at it...and keep posting your findings...hopefully you'll get some help from the folks here...otherwise, I can take a look at it this weekend.

--RB
#183
09/02/2010 (11:02 pm)
@Henry: I've planned a mini-game to put in the repository showcasing all the components' usage... I need some time ;)

@Aaron: Still not sure to understand... I might have gotten it wrong... here a video of what I guess you want to achieve... is this right?

#184
09/02/2010 (11:23 pm)
@Pino: Exactly! I was finally able to do this by attaching the spring angle and revolute joint components on the car (cart in your video) without "fixing" anything, is this how you did it?
#185
09/02/2010 (11:51 pm)
@Aaron: nope, I did that adding FSAngleJoint and FSRevoluteJoint. In the video the angle joint has a target of 0 and a softness of 0.7 and the revolute is attached to the cart by OurBottom anchor.
#186
09/03/2010 (12:29 am)
@Pino: Thanks, I will give it a try. I cant believe I missed this, I tried so many different combos doing it the way you did it, but maybe its an issue with using TheirTop instead of OurBottom.

Its a great learning experience for me, and I thank you and ron for taking your time to help me.

My way on post #184 also works, but becomes a problem if you want to attach another body using the same approach, because you can only add 1 revolute component per body.
#187
09/03/2010 (12:38 am)
@Aaron: yep, using my suggested approach you can have a lot of "passengers" on your cart :) And making some tweak differentiating a little the strenght allowances each passenger will behave a little differently from the others... kinda cool ;)
#188
09/04/2010 (1:30 am)
Ok guys,

the fluid component is now using the custom material able to render the waves. I've also changed the defaults presented in the builder to reflect a better setting. Obviously you can play with those parameters to get the best depending on the size of the fluid surface, the density you want and so on.

For the fluid you should use a plain color static sprite for now, later on I'll add the use of refractive materials as well and also some cool effect to make better the fluid rendering.

Enjoy ;)

#189
09/04/2010 (6:44 pm)
Wow, Pino! Amazing work with the water material!

That looks great. Thanks for taking the time to work that in.

--RB
#190
09/05/2010 (6:46 pm)
Hey all...I need some community help. ;)

I've been working to keep things "in line" between Torque X and the Farseer simulation. One glaring miss was that changes to the SceneObject's Size property were not being reflected in the Farseer bodies, geoms, joints, springs, or for that matter in the simulation itself.

While many of you probably do not resize objects on the fly, it is a behavior that could be reasonable and should be supported.

That being said...it's also quite a bit of code to keep things synchronized.

I've made the changes and tested them a bit in my sandbox projects...things look pretty happy so far. What I'd like from you all are some volunteers to run this code for a little while before I submit it into the repository and "make it official" so to speak.

If anyone's interested and can spare the time...please send me an email to the address listed in my profile. I can send you a patch file containing the changes. You can use TortoiseSVN or svn merge to apply the patch to your project then just rebuild and test things out.

If anyone IS resizing objects as part of their gameplay or sandbox mechanics...then your help would be GREATLY appreciated and quite valuable.

The code change was pretty extensive...and it will be a pain if I submit it and introduce any problems.

Thanks in advance for anyone's help!
--RB
#191
09/05/2010 (11:25 pm)
@Ron: I'll do some testing for you, sending an email right now.
#192
09/05/2010 (11:53 pm)
@Aaron...thanks for the help. I sent you the patch file and some details of how to apply the patch.

I assume you already know how to resize scene objects...but if not...just do this:

SceneObject.Size = new Vector2([some new X value], [some new Y value]);

Thanks!
--RB
#193
09/06/2010 (12:40 am)
www.topnotched.com/images/texturePoly.jpg
I ran into a problem with the texture polygons, as you can see in the image above. I made a circle track (4 512x512 PNG transparency images, completely separate files) and each image that makes up the circle has 4 "potholes", 2 (1 big and 1 small) on each end of the polygon curve. I have tried a few different image alterations and updated the ShapeMaterial, but so far these holes wont go away. Any ideas why this is happening, or how I can fix this? I will continue to experiment with this.
#194
09/06/2010 (12:41 am)
@Aaron...is this running WITH the resizing code patch, or without?

That would be very important to know. :)

Thanks
--RB
#195
09/06/2010 (12:43 am)
@Ron: This is without the resizing patch. Do you think it has something to do with the size of the images?
#196
09/06/2010 (12:54 am)
@Aaron...I don't think it has to do with the image sizes...it just REALLY narrows the playing field. :)

That patch I sent you includes some 20 files. If this problem occurred AFTER you applied the patch...then any of those 20 files would be a viable suspect. The fact that you haven't applied the patch limits the scope of potential suspects.

That being said...I think I might know what you're facing. Farseer subdivides alot of its geometry into grids...sharp angles can confuse the grid and make Farseer find a "hole" where there shouldn't be one.

In the FSGeomComponent of your track...try a different value for GridSize. The default value of 0.0 tells Farseer to calculate the grid for you:

Read this section of the manual

I'm not sure what a good value would be, but the manual page above tells a bit about the default method for calculating it.

Maybe a finer grid will help fill the potholes.

Try using a value of 1.0 just to see if there's a visible difference on screen.

Hope that helps...
--RB

[UPDATE]
Here's some more info.
#197
09/06/2010 (1:05 am)
@Ron: That worked like a charm! Thanks for pointing out the sections in the manual too, I will read up on it.

Thank You!
#198
09/06/2010 (1:09 am)
@Aaron...glad to be able to help. Just be careful of choosing a grid value that's too small...it will impact the amount of time it takes to construct the geometry (as indicated in the manual).

I'd seen some similar "issues" like this when I first put in the user-defined polygon code. So I'd already mucked around with some different values to fix that type of thing.

Glad it's working for you...
--RB
#199
09/06/2010 (6:11 pm)
Hey guys,

I've just committed the textured fluid's rendering. As you can see trying to use a complex texture I didn't achieve a proper rendering: the texture is rendering shifted by half size on X and Y and logarithmically expanded getting away from its origin. This means that if you can't get a suitable texture it'll be better to still use a plain color.

If any of you guys wants to have a look to the code and see what I'm clearly missing... please let me know! I've spent hours without understanding why on earth it's not rendering as it should! Maybe it's right under my nose but I can't see it... I've just given up for now :(

~Pino
#200
09/07/2010 (4:34 pm)
Wow, it looks like you guys have put in a lot of good work! I've been following the thread but haven't had a chance to try things out, yet. Can I get access to the repository? Thanks!