Farseer 3 Questions

Topics: Developer Forum, Project Management Forum, User Forum
May 27, 2010 at 11:41 PM

Wow so I know I've had a lot of questions but I decided to give a jump into Farseer 3 with my project. My biggest question is where did the Mathematics namespace go? I used the Calculator class quite extensively and much raycasting. Now I know that it is directly implemented somewhere in Farseer 3 (raycasting that is) but I don't even know where Geom went yet lol. I understand that they are now the Shapes but I don't know how they are linked to the bodies? Sorry I just am a little overwhelmed trying to switch over. Finally, is FixedAngleJoint just gone or is it implemented with the Body now? I still don't understand it all just yet.

May 28, 2010 at 12:17 AM

You should read the Box2D Manual, it explains the engine really well, and study the TestBed examples.

Geoms have been replaced by Fixtures, and each Fixture has a single shape which describes how it collides.

FixedAngleJoint is gone, but you can use Body.FixedRotation. This doesn't have any give though, and I hope they can get FixedAngleJoint back.

To see how raycasting works you will need to look at the Testbed sample, and read the Box2D Manual. It uses a callback and the value you return tells the raycast operation to continue or cancel. Pretty neat I think! And you can always do manual raycasts against shapes though.

Jun 2, 2010 at 3:37 PM
Edited Jun 3, 2010 at 4:06 AM

Ok, I've always used the BodyFactory and GeomFactory in the past. I have switched most of everything in my game to use the new BodyFactory and FixtureFactory but I don't know how to attach the fixture to the body. I've seen the body.CreateFixture() method but it requires a shape, not a fixture. Would I want to do something like this:


                        //Create body and geom to associate with
                        tempFixture = FixtureFactory.CreateRectangle(Farseer.World, size.X, size.Y, mass);

                        //Load vals to fixture (what collision categories it is part of, friction, etc.

                        //Connect with tempBody


I don't see how this would be the best way to do it though because I don't see how tempFixture.Shape would take any of the collision category or friction info along with it. Should I instead not use FixtureFactory and create the shape myself and then once it is done, change the friction and collision categories based off the body? I only use temporary Fixtures because they are cloned, from what I read, when put to a body. I also saw though that you can access the body through the fixture. I just can't get my head wrapped around the how these all work together. Sorry again, jumbled mess. Just need some good help with this (or at least a point to something I over read or missed).



Looked into the internals of all of the methods I've been using, and saw that FixtureFactory creation creates a body inside the method. I have changed to using Shape objects and the PolygonTools methods now. The only thing left to ask is how to offset different shapes from the center of a body. Is the position of a shape it's relative position to the body or is there something else I can use?