This project has moved and is read-only. For the latest updates, please go here.

Defining vertices on sprite sheet

Topics: Developer Forum, User Forum
Jul 27, 2010 at 5:06 AM
Edited Jul 27, 2010 at 5:46 AM

Hey guys, currently I'm working on a game with Farseer Physics Engine.

I'm struggling with the vertices on sprite sheet. 

How'd you guys defining/know the vertices? where the coordinates should be? Is there any free tools out there which can serve this purpose? 

Vertices vertices = new Vertices(new Vector2[] { 
new Vector2(27f, 20f),
new Vector2(27f, 6f),
new Vector2(19f, -10f),
new Vector2(-5f, -10f),
new Vector2(-8f, -20f),
new Vector2(-16f, -20f),
new Vector2(-19f, -11f),
new Vector2(-25f, -11f),
new Vector2(-28f, -6f),
new Vector2(-28f, 20f)
These vertices is purely done by defining each of it by yourself? Or is there any tools where you click on the certain point then it will generate the vertex point?

1 more problem is, how you guys know whether your sprite sheet offset is correct or not?

+ [0] {X:29.20031 Y:15.93663} FarseerGames.FarseerPhysics.Mathematics.Vector2
+ [1] {X:29.20031 Y:1.936629} FarseerGames.FarseerPhysics.Mathematics.Vector2
+ [2] {X:21.20031 Y:-14.06337} FarseerGames.FarseerPhysics.Mathematics.Vector2
+ [3] {X:-2.799686 Y:-14.06337} FarseerGames.FarseerPhysics.Mathematics.Vector2
+ [4] {X:-5.799686 Y:-24.06337} FarseerGames.FarseerPhysics.Mathematics.Vector2
+ [5] {X:-13.79969 Y:-24.06337} FarseerGames.FarseerPhysics.Mathematics.Vector2
+ [6] {X:-16.79969 Y:-15.06337} FarseerGames.FarseerPhysics.Mathematics.Vector2
+ [7] {X:-22.79969 Y:-15.06337} FarseerGames.FarseerPhysics.Mathematics.Vector2
+ [8] {X:-25.79969 Y:-10.06337} FarseerGames.FarseerPhysics.Mathematics.Vector2
+ [9] {X:-25.79969 Y:15.93663} FarseerGames.FarseerPhysics.Mathematics.Vector2

There is roughly (+2.2, -4.1) off center.... how to get this ??

Hope someone can help me out on this :(

PS: all the vertices and offset data are taken from this post :

Jul 27, 2010 at 5:07 AM
Edited Jul 27, 2010 at 5:46 AM

Why I cant put empty line ?!

why all have been screwed up together?

I have re-post it to

Hope you guys can click on the link below and look for it:

Thank You.

Jul 27, 2010 at 5:43 AM

What broswer are you using?  the WYSIWYG editor acts differently in different browsers (thanks to javascript).

Jul 27, 2010 at 5:47 AM

Thanks alot Jerky, previously I'm using Chrome but now I change to IE and edit the post again and it works :D

Jul 27, 2010 at 7:33 AM

For Farseer 2 there is the textureToVertices function: I don't know if this is already implemented in F3...
If you want, you can store a geom of every frame of your animation in say an array, and while the animation is running, switch between these geom's. HOWEVER, I would not go that way, as your character will get easily stuck in other objects.

About your origin question; I can't remember exactly. Farseer 2 calculates the origin based on the shape of the texture. So you can either store that origin and use it as offset when drawing your sprite, or try to change that origin to be the same as the sprite (but that will affect how the body rotates).

Jul 27, 2010 at 7:41 AM
Hi Jordos, if you say that you would not go that way (storing geom in array) then what is the better way ?
Jul 27, 2010 at 10:24 AM

What I mean with not going that way, is changing the body's geom in respect to the texture of the animationframe. In other words; having a different geom for every frame of the animation.

I don't know what the situation is, but I would probably have one geom that approximately covers the size of the whatever-it-is-in-the-animation and just have the animation run, but keep the geom the same.

Jul 27, 2010 at 10:27 AM
Edited Jul 27, 2010 at 12:35 PM
Hi, that depends heavily on what you are trying to do. Switching a bodys geometry from one frame to another is basically a bad idea, if you are using it for collision response. If you are just using it for collision detection it is no big deal though. For example i am using a bounding box for my main character in a platformer. This does not change and is used to check for collisions against the environment or other characters and objects, like crates or stuff like that. For detecting if the main character got hit by a shot however, i use geometries generated from the sprites texture. As the switchable geometries are always inside the bounding box though, i prevent them from accidentally getting stuck within the environment. Maybe this kind of mixed approach might be applicable in your scenario too.