Triangle/TriangleShape location issue
Posted: Sat Jan 09, 2016 1:44 pm
Hi and happy new year,
I play with Triangle(Shape)s and I get a big issue: despite giving the three vertices that define the triangle, and so it's location in space, triangle are not located in the expected place (which may have been to be defined more precisely).
Knowing the specificity of the triangle, which is designed by its three vertices for both size AND position, whereas other convex shapes are by design "position-less", ie: sphere or radius r, box of size w x l x h, etc.
TriangleShape constructor does:
which is bad. Because: "computing" ourselves triangle's center is very hard and uncommon, especially when working with primitives, which assemble triangle WHERE they're defined.
So building compound entity as we do with primitives just failed, because all triangles are stacked in a big mess located on origin of the compound entity.
Here is an example of two triangles defined as:
in a compound entity located in (0, 20, 0)
That should be defined a quad, instead, we've got a star !
It is too far complicated to additionally get the right center coordinates and to either use AfineTransform in CompoundShapeEntry or, if possible, add it to the TriangleShape constructor.
What do you think about this ?
Is it possible to change that to handle the specific nature of triangle in constructor of TriangleShape ?
I play with Triangle(Shape)s and I get a big issue: despite giving the three vertices that define the triangle, and so it's location in space, triangle are not located in the expected place (which may have been to be defined more precisely).
Knowing the specificity of the triangle, which is designed by its three vertices for both size AND position, whereas other convex shapes are by design "position-less", ie: sphere or radius r, box of size w x l x h, etc.
TriangleShape constructor does:
Code: Select all
Vector3 center;
var shape = new TriangleShape(v1, v2, v3, out center);
Initialize(new ConvexCollidable<TriangleShape>(shape));
Position = center;
So building compound entity as we do with primitives just failed, because all triangles are stacked in a big mess located on origin of the compound entity.
Here is an example of two triangles defined as:
Code: Select all
Triangles.Add(new CompoundShapeEntry(new TriangleShape(new Vector3(-5, 0, 0), new Vector3(0, 0, 0), new Vector3(0, 0, 5))));
Triangles.Add(new CompoundShapeEntry(new TriangleShape(new Vector3(-5, 0, 0), new Vector3(-5, 0, 5), new Vector3(0, 0, 5))));
That should be defined a quad, instead, we've got a star !
It is too far complicated to additionally get the right center coordinates and to either use AfineTransform in CompoundShapeEntry or, if possible, add it to the TriangleShape constructor.
What do you think about this ?
Is it possible to change that to handle the specific nature of triangle in constructor of TriangleShape ?