OK I made a simple example to better understand the problem.
Here is an arrow with bb perfectly aligned.
Loading Image
When i set flipX every thing is ok except the bb
Loading Image
Here is the code of create metod
public void create() {
kartka = new SpriteBatch();
shapeRenderer = new ShapeRenderer();
swiat = new World(new Vector2(0, -9.81f), true );
debugRenderer = new Box2DDebugRenderer();
camera = new OrthographicCamera(Gdx.graphics.getWidth() /20, Gdx.graphics.getHeight() /20);
renderer = new SkeletonRenderer();
debugRenderer2 = new SkeletonRendererDebug();
atlas = new TextureAtlas(Gdx.files.internal("spineboy/skeleton.atlas"));
SkeletonJson json = new SkeletonJson(atlas);
json.setScale(0.09f); // scale
debugRenderer2.setScale(json.getScale());
SkeletonData skeletonData = json.readSkeletonData(Gdx.files.internal("spineboy/skeleton.json"));
skeleton = new Skeleton(skeletonData);
skeleton.setFlipX(true);
AnimationStateData stateData = new AnimationStateData(skeletonData);
state = new AnimationState(stateData);
state.apply(skeleton); // Poses skeleton using current animations. This sets the bone's local SRT.
skeleton.updateWorldTransform();
bounds = new SkeletonBounds();
bounds.update(skeleton, true);
PolygonShape boxPoly1;
for (Slot slot : skeleton.getSlots()) {
if (slot.getAttachment() != null){
String s = slot.getAttachment().getName();
if ( slot.getAttachment() instanceof BoundingBoxAttachment ){
Gdx.app.log(slot.getAttachment().getName(), " nazwa ");
Box2dAttachment box2 = new Box2dAttachment(slot.getAttachment().getName());
box2.att = (BoundingBoxAttachment)slot.getAttachment();
//s.equals(a.nazwa
boxPoly1 = new PolygonShape();
boxPoly1.set(box2.att.getVertices());
float a[] = box2.att.getVertices();
System.out.println(Arrays.toString(a));
float x = skeleton.getX() + slot.getBone().getWorldX() ;
float y = skeleton.getY() + slot.getBone().getWorldY();
float rotation = slot.getBone().getWorldRotation() ;
BodyDef cos = new BodyDef();
FixtureDef fizyka = new FixtureDef();
cos.type = BodyType.StaticBody;
cos.angularDamping = 1.8f;
fizyka.density = 2.5f;
fizyka.friction = 0.4f;
fizyka.restitution = 0.6f;
fizyka.shape = boxPoly1;
fizyka.filter.groupIndex = -1;
box2.body =swiat.createBody(cos);
box2.body.createFixture(fizyka);
box2.body.setTransform(x , y , rotation * MathUtils.degRad);
boxPoly1.dispose();
}}}}
Vertices are the same before and after flip:
bb: nazwa
[-0.3073149, -1.0631596, 3.3688884, -1.034258, 3.3532636, 0.9528781, -0.29007906, 0.9573554]
bb2: nazwa
[3.344621, -2.160562, 6.67297, -0.014652501, 3.3444107, 2.0789216]
The debug renderer works ok and flips the bb.
Does any one use flip X and BB? I'm alone with this problem or what?
Nate where are you? 😉