This project has moved. For the latest updates, please go here.

Texture Rope

Feb 2, 2011 at 5:41 PM

Hey Guys,


I had this code working in Farseer 2.3 but no that i've come to 3.2 i cant seem to get my code to work with the new farseer. Im tryin to texture my rope. Last time i did this by Texturing Each body on the chain. However things have slightly changed with this one. My code looks like this

    class Bridge
        private const int Count = 30;

        private Bridge()
            Body ground;
                ground = new Body(;

                PolygonShape shape = new PolygonShape(0);
                shape.SetAsEdge(new Vector2(-40.0f, 0.0f), new Vector2(40.0f, 0.0f));
                Vertices box = PolygonTools.CreateRectangle(0.5f, 0.125f);
                PolygonShape shape = new PolygonShape(box, 20);

                Body prevBody = ground;
                for (int i = 0; i < Count; ++i)
                    Body body = BodyFactory.CreateBody(;
                    body.BodyType = BodyType.Dynamic;
                    body.Position = new Vector2(-14.5f + 1.0f*i, 5.0f);

                    Fixture fixture = body.CreateFixture(shape);
                    fixture.Friction = 0.2f;

                    Vector2 anchor = new Vector2(-0.5f, 0.0f);
                    RevoluteJoint jd = new RevoluteJoint(prevBody, body,
                                                         prevBody.GetLocalPoint(body.GetWorldPoint(anchor)), anchor);

                    prevBody = body;

                Vector2 anchor2 = new Vector2(0.5f, 0.0f);
                RevoluteJoint jd2 = new RevoluteJoint(ground, prevBody,
                                                      ground.GetLocalPoint(prevBody.GetWorldPoint(anchor2)), anchor2);


        public virtual void Draw(GameTime gT, SpriteBatch SB)
            foreach (Body body in ground.bodies)
                SB.Draw(ropetexture, new Rectangle((int)body.Position.X, (int)body.Position.Y, (int)Width, (int)Height), null, Color.White, body.Rotation, origin, SpriteEffects.None, 0.15f);
                //ropetexture, body.Position, Color.White, body.Rotation, body.Rotation,origin,SpriteEffects.None,0.1f);

        public static Bridge Create()
            return new Bridge();


Can anyone help please :)


Thank You


Feb 3, 2011 at 12:37 PM
Lucyisinthesky wrote:

I had this code working in Farseer 2.3 but no that i've come to 3.2 i cant seem to get my code to work with the new farseer.

That is a pretty vague description. Could you please be more specific as to what your actual problem is?

From looking at your code I have no idea where parameters like Width and Height come from... but since you obviously scale your physics objects to MKS system... do you scale their coordinates back to pixels before you draw?

Your code is missing the SpriteBatch.Begin(...) part, so it impossible to tell, whether you provide the right transformation matrix there (or any transformation matrix at all for that matter).