Sign in to follow this  
CadeF

[.net] [Resolved[Problems with ODE.NET and TriMeshes

Recommended Posts

CadeF    421
Hey everyone, In ODE.NET, I have made a simulation of various boxes (ODE.Geoms.Box) falling and stacking on a plane (ODE.Geoms.Plane). This works nicely, so now Im trying to modify it to use actual triangles instead of predefined primitives. Swapping this code, Space.Add(New Geoms.Plane(New Vector3(0, 1, 0), -2)) with
        Dim v(4 - 1) As Vector3
        v(0) = New Vector3(-20, -2, -20)
        v(1) = New Vector3(20, -2, -20)
        v(2) = New Vector3(20, -2, 20)
        v(3) = New Vector3(-20, -2, 20)
        Dim iv(6 - 1) As Integer
        iv(0) = 0
        iv(1) = 1
        iv(2) = 2
        iv(3) = 2
        iv(4) = 3
        iv(5) = 0
        Space.Add(New Geoms.TriMesh(v, iv))


Some boxes fall and stack correctly or land correctly, some land correctly then "roll into" the ground and out under the flat surface and some go right through. If I use my own collision callback, or the default collider, I still get the same problem. Using Quickstep with 100 iterations or Timestep, gives me the same problem. Manually creating a new vertex list with the index buffer, and only specifying the vertices, makes no difference. ODE setup code
    Public Shared World As ODE.World
    Public Shared Space As ODE.Space
    Dim ContactJoints As Joints.JointGroup


        World = New World
        Space = New Space

        World.Gravity = New Vector3(0, -1, 0)
        Space.Collider = New CollisionDelegate(AddressOf CollisionCallback)

        Dim v(4 - 1) As Vector3
        v(0) = New Vector3(-20, -2, -20)
        v(1) = New Vector3(20, -2, -20)
        v(2) = New Vector3(20, -2, 20)
        v(3) = New Vector3(-20, -2, 20)
        Dim iv(6 - 1) As Short
        iv(0) = 0
        iv(1) = 1
        iv(2) = 2
        iv(3) = 1
        iv(4) = 3
        iv(5) = 2
        Space.Add(New Geoms.TriMesh(v, iv))
        'Space.Add(New Geoms.Plane(New Vector3(0, 1, 0), -2))


Collision callback
    Private Sub CollisionCallback(ByVal Contacts() As Joints.ContactInfo, ByVal GeomA As Geoms.Geom, ByVal GeomB As Geoms.Geom)
        Dim I As Integer = 0
        For I = 0 To Contacts.Length - 1
            With Contacts(I).SurfaceParams
                .Mode = Joints.ContactMode.Bounce Or Joints.ContactMode.FrictionApprox1
                .Bounce = 0.05
                .BounceVel = 0.03
                .Mu = 0.5
            End With

            Dim Joint As Joints.Contact = New Joints.Contact(World, Contacts(I), ContactJoints)
            Joint.Attach(GeomA.RigidBody, GeomB.RigidBody)
        Next
    End Sub


Physics tick
[source="vb"]
    Private Sub Tick()
        Space.Collide()
        'World.QuickStep(TimeElapse / 200, 100)
        World.TimeStep(TimeElapse / 200)
        ContactJoints.Clear()
    End Sub


The only objects in the world, are a few boxes (ODE.Geoms.Box) and the trimesh I'm trying to use as the ground. Thanks :) [Edited by - CadeF on April 17, 2006 3:03:09 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this