0
我在Box2D的多邊形形狀。形狀是三角形,至極我希望有3個頂點。事實上,我創建的所有形狀都會輸出8個頂點。爲什麼是這樣?如果我輸出頂點數,那總是正確的數量。我不想渲染不必要的線條,硬朗的,我想從得到的形狀的頂點數據。Box2D的頂點形狀
@Override
public void setShape(Vec2[] vector) {
// TODO Auto-generated method stub
super.setShape(vector);
//A NEW SHAPE
shape = new PolygonShape();
//THE TRIANGLES VECTORS
Vec2[] vec = new Vec2[3];
vec[0] = new Vec2(10, 0);
vec[1] = new Vec2(0, 10);
vec[2] = new Vec2(0, 0);
//SET THE VERTICES
shape.set(vec, vec.length);
}
@Override
public void render() {
// TODO Auto-generated method stub
super.render();
//GET THE VERTICES
Vec2[] vector = shape.m_vertices;
System.out.print("\n" + "Vertices: " + vector.length);
}
會一直輸出8.爲什麼?