Triangle entity problems

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
jens_n
Posts: 4
Joined: Tue Feb 28, 2012 6:57 am

Triangle entity problems

Post by jens_n »

Hi!

I'm having some problems with the triangle entity. I initialize the triangle with three different points but when I query the triangle vertices in world space (by getting the properties VertexA, VertexB and VertexC) the VertexB and VertexC properties return the same value.

Basically I'm trying to spawn a triangle in the place of a Sphere. In the class holding the Sphere (note the different vertices):

Code: Select all

TriangleManager.AddTriangle(new Vector3(0, 0, 0), new Vector3(1, 1, 0), new Vector3(-1, 1, 0), SphereBody.WorldTransform);
In the class TriangleManager:

Code: Select all

public void AddFragment(Vector3 v0, Vector3 v1, Vector3 v2, Matrix world) {
    TriangleBody = new Triangle(v0, v1, v2, 0.01f) {
        WorldTransform = world,
    };
    Space.Add(TriangleBody);
}
This is how I try to render the triangle:

Code: Select all

VertexBuffer.Set(index++, Semantic.Position, TriangleBody.VertexA);
VertexBuffer.Set(index++, Semantic.Position, TriangleBody.VertexB);
VertexBuffer.Set(index++, Semantic.Position, TriangleBody.VertexC);
Took me quite a while until I enabled wireframe :roll:

Code: Select all

if (fragment.VertexB == fragment.VertexC) {
    throw new Exception("degenerate triangle"); // gets thrown
}
Data in LocalVertexA/B/C is correct (as initialized). What am I missing or doing wrong?

Edit:
BEPUphysics 1.2.0, SharpDX fork (commit 87fc56cc9ed4 - latest at time of writing)
Also I *think* the triangles still behave like triangles in terms of physics and raycasts (though that is really hard to say without correct visuals ^^)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Triangle entity problems

Post by Norbo »

The Triangle.VertexC getter happens to return the transformed version of LocalVertexB, unhelpfully. It's now fixed in the development version.

Thanks for the report!
Post Reply