badlogic a écritFor the hull, you don't need the triangle indices, you just need to iterate through the first hullLength
vertices in the computed world vertices array. The vertices limit on PolygonShape can be lifted when recompiling the box2d native code. Not for the faint of heart though :/ The alternative of creating one PolygonShape per triangle is not a good one either, as that gets heavy fast. What's the use case? Generally, having a box2d shape per attachment is not what one wants.
So, you mean that i need to create for each part of charachter polygon with no more than 8 vertices or recompile box2d. But the second way is realatively difficult, but doesn't matter. I made mistake in my pervious post because of my bad english, i want concave polygon, not convex, how i can do it? For exmaple PhysicEditor can generate forms varying degrees of complexity. I understand that it maybe not so efficiently, but sometimes it's necessary.
badlogic a écritUse Bone#getWorldRotationX()
instead of Bone#getARotation()
. The rest of the code looks OK to me, I'm unsure why mesh attachments wouldn't move at all.
Hm, it so strange because slot.getBone().getWorldX/getX/getWorldRotationX/getARotation are constant and equals 0.0 or 10.0 for each MeshAttachment slot.
Ok, i've understood that convex polygon with no more than 8 vertices will be enough for each body, but unfortunately I've a problem with realization. I tried several variants. I decided to first check it in the online figure builder.
ArrayList<Float> x = new ArrayList();
ArrayList<Float> y = new ArrayList();
for(int i = 0; i < attachment.getHullLength(); i+=2) {
x.add(attachment.getVertices()[attachment.getEdges()[i]]/GameData.PPM);
y.add(attachment.getVertices()[attachment.getEdges()[i+1]]/GameData.PPM);
}
System.out.println(x);
System.out.println(y);
image:
result:
[-0.1384375, 0.173125, 1.684375, 3.8103125, 3.8103125, 3.505625, 1.684375]
[0.173125, 3.115625, 2.741875, 3.115625, 3.505625, 2.741875, -0.1384375]
result:
[-0.1384375, 0.173125, 1.684375, 3.8103125, 3.115625, 3.505625, 2.741875]
[0.0240625, 0.5878125, -0.9578125, 0.27875, 0.8321875, -0.48875, -0.80125]