Static Mesh Trouble

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Mentex
Posts: 2
Joined: Thu Apr 26, 2012 4:31 pm

Static Mesh Trouble

Post by Mentex »

Hi,

I'm trying to load a simple static mesh (Just a simple test mesh) with the following code.. (Windows Phone SDK)

Code: Select all

Vector3[] vertices = VertexList.ToArray();
int[] indices = FaceList.ToArray();                            
staticMesh m = new StaticMesh(vertices, indices, new AffineTransform(new Vector3(0, 0, 0)));
space.Add(m);
the vertex list and face list are generated by custom exporter a built for 3DS MAX...
But any colliding object (such as a falling sphere.. ) pass right through...
I checked the bounding box to compare the volume generated by Bepu with the ones I see in MAX and everything seems to be alright..
I also changed the sidedness.. and this made no diference..

Below is the vertex and face list... in its original XML state.. .

Code: Select all

                   <FaceList>
                        <Item>
                           <FaceNumber>1</FaceNumber>
                           <Face>1 4 5</Face>
                        </Item>
                        <Item>
                           <FaceNumber>2</FaceNumber>
                           <Face>5 2 1</Face>
                        </Item>
                        <Item>
                           <FaceNumber>3</FaceNumber>
                           <Face>2 5 6</Face>
                        </Item>
                        <Item>
                           <FaceNumber>4</FaceNumber>
                           <Face>6 3 2</Face>
                        </Item>
                        <Item>
                           <FaceNumber>5</FaceNumber>
                           <Face>7 8 11</Face>
                        </Item>
                        <Item>
                           <FaceNumber>6</FaceNumber>
                           <Face>11 10 7</Face>
                        </Item>
                        <Item>
                           <FaceNumber>7</FaceNumber>
                           <Face>8 9 12</Face>
                        </Item>
                        <Item>
                           <FaceNumber>8</FaceNumber>
                           <Face>12 11 8</Face>
                        </Item>
                        <Item>
                           <FaceNumber>9</FaceNumber>
                           <Face>1 2 8</Face>
                        </Item>
                        <Item>
                           <FaceNumber>10</FaceNumber>
                           <Face>8 7 1</Face>
                        </Item>
                        <Item>
                           <FaceNumber>11</FaceNumber>
                           <Face>2 3 9</Face>
                        </Item>
                        <Item>
                           <FaceNumber>12</FaceNumber>
                           <Face>9 8 2</Face>
                        </Item>
                        <Item>
                           <FaceNumber>13</FaceNumber>
                           <Face>3 6 12</Face>
                        </Item>
                        <Item>
                           <FaceNumber>14</FaceNumber>
                           <Face>12 9 3</Face>
                        </Item>
                        <Item>
                           <FaceNumber>15</FaceNumber>
                           <Face>6 5 11</Face>
                        </Item>
                        <Item>
                           <FaceNumber>16</FaceNumber>
                           <Face>11 12 6</Face>
                        </Item>
                        <Item>
                           <FaceNumber>17</FaceNumber>
                           <Face>5 4 10</Face>
                        </Item>
                        <Item>
                           <FaceNumber>18</FaceNumber>
                           <Face>10 11 5</Face>
                        </Item>
                        <Item>
                           <FaceNumber>19</FaceNumber>
                           <Face>4 1 7</Face>
                        </Item>
                        <Item>
                           <FaceNumber>20</FaceNumber>
                           <Face>7 10 4</Face>
                        </Item>
                   </FaceList>
                   <VertexList>
                        <Item>
                           <VertexNumber>1</VertexNumber>
                           <Vertex>-2002.89 -376.19 3299.9</Vertex>
                        </Item>
                        <Item>
                           <VertexNumber>2</VertexNumber>
                           <Vertex>0.0 -376.19 3299.9</Vertex>
                        </Item>
                        <Item>
                           <VertexNumber>3</VertexNumber>
                           <Vertex>2002.89 -376.19 3299.9</Vertex>
                        </Item>
                        <Item>
                           <VertexNumber>4</VertexNumber>
                           <Vertex>-2002.89 -376.19 -3299.9</Vertex>
                        </Item>
                        <Item>
                           <VertexNumber>5</VertexNumber>
                           <Vertex>0.0 -376.19 -3299.9</Vertex>
                        </Item>
                        <Item>
                           <VertexNumber>6</VertexNumber>
                           <Vertex>2002.89 -376.19 -3299.9</Vertex>
                        </Item>
                        <Item>
                           <VertexNumber>7</VertexNumber>
                           <Vertex>-2002.89 376.19 3299.9</Vertex>
                        </Item>
                        <Item>
                           <VertexNumber>8</VertexNumber>
                           <Vertex>0.0 376.19 3299.9</Vertex>
                        </Item>
                        <Item>
                           <VertexNumber>9</VertexNumber>
                           <Vertex>2002.89 376.19 3299.9</Vertex>
                        </Item>
                        <Item>
                           <VertexNumber>10</VertexNumber>
                           <Vertex>-2002.89 376.19 -3299.9</Vertex>
                        </Item>
                        <Item>
                           <VertexNumber>11</VertexNumber>
                           <Vertex>0.0 376.19 -3299.9</Vertex>
                        </Item>
                        <Item>
                           <VertexNumber>12</VertexNumber>
                           <Vertex>2002.89 376.19 -3299.9</Vertex>
                        </Item>
                   </VertexList>
this Xml is loaded by the content loader...
And here is how filter the above into a vector3[] and a int[] for use with Bepu..

Code: Select all

public struct phyVertex
{
        public int     VertexNumber;
        public Vector3 Vertex;
}
public struct phyFace
{
        public int   FaceNumber;
        public int[] Face;
}

VertexList = new List<Vector3>();
foreach (phyVertex v in xmlVertexList)
{
        VertexList.Add(v.Vertex);
}
FaceList = new List<int>();
foreach (phyFace f in xmlFaceList)
{
       FaceList.Add(f.Face[0] - 1);
       FaceList.Add(f.Face[1] - 1);
       FaceList.Add(f.Face[2] - 1);
 }
Any suggestions to why this is happening..? Maybe a scale issue..?
I also checked the vertex and face numbering... and everything seems right...
All collision models such as Box, Sphere and ConvexHull work fine...
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Static Mesh Trouble

Post by Norbo »

If the objects truly fall through without ever generating a contact with the mesh, that most strongly implies the shape not being where it is supposed to be. Scale issues usually manifest as low quality behavior- maybe bumping around a bit as opposed to just falling through uninterrupted- but triangles, especially triangle faces, have pretty robust handling of even very large scales. Sidedness may look like it falls through without interacting, but it should still generate contacts as it goes through the other side (they just won't stop the object since it's moving away from the surface).

I would recommend grabbing the BEPUphysicsDrawer and using it to visualize what the collision shape actually looks like. That will help verify the graphic is truly where the shape is and that the shape is actually the right shape. If it's properly aligned and the visualization looks correct, I'm not sure what's wrong at a glance.

If you can create an isolated reproduction case in the BEPUphysicsDemos or something, I could take a closer look.
snoozbuster
Posts: 172
Joined: Sat Sep 24, 2011 7:31 am

Re: Static Mesh Trouble

Post by snoozbuster »

Try creating your StaticMesh with TriangleMeshSolidity.DoubleSided. I've found that resolves 9/10 collision issues.
Mentex
Posts: 2
Joined: Thu Apr 26, 2012 4:31 pm

Re: Static Mesh Trouble

Post by Mentex »

Hi,

I've inserted de Bepu Drawer in my application and found the problem, the spheres had Zero radius (and so didn't appear in the drawer).
It's a problem with my MAX exporter (generating large xml files, bound to have glitches, but its fixed now).
StaticMesh is very good and stable. Everything is working fine for the moment.

I'm building a nice puzzle game for windows phone hope to make it to the marketplace soon..

Well, thanks again for the suggestions!
And Cheers for a great physics lib! That works fine!
Post Reply