lime & bullet

Post your questions, suggestions and experiences regarding to Image manipulation, 3d modeling and level editing for the Irrlicht engine here.
Post Reply
WaxyChicken
Posts: 95
Joined: Sat Jun 25, 2011 6:15 am

lime & bullet

Post by WaxyChicken »

if anyone knows where I can find examples of using
irrlicht Lime with Bullet Sharp then drop me a line.
_______________________________________________________
You could argue with me all day long about which language is best.
But what it comes down to is:
which language is best for YOU and which language is best for ME.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Re: lime & bullet

Post by sudi »

Really i don't get it. Why do people ask on tutorials two totally seperate things work together.
Bullet in itself can run on its own its a physics library which is able to represent a physical world and simulate it. Now only thing you have to do is allign the visual representation (scenenodes for example) to those physical bodies....really there is no magic at all going on...
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
WaxyChicken
Posts: 95
Joined: Sat Jun 25, 2011 6:15 am

Re: lime & bullet

Post by WaxyChicken »

Ok, sudi - since this is the 2nd time you posted to one of my threads just to criticize rather than contribute:

How do you load a .BSP Q3 level into the Bullet Sharp engine
How do you load a Maya .OBJ mesh into the Bullet Sharp Engine
How do you synchronize between the automated collision of the bullet sharp wrapper and the automated animation of the Irrlicht Lime wrapper?

Common, it's so easy, just spit it out.
Image
_______________________________________________________
You could argue with me all day long about which language is best.
But what it comes down to is:
which language is best for YOU and which language is best for ME.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Re: lime & bullet

Post by sudi »

Seriously lame shot....but here you go...

(hope cobra doesn't mind)
copied from irrbullet to create a btTriangle mesh from a IMesh

Code: Select all

btTriangleMesh * createTriangleMesh(IMesh* const mesh)
 
{
 
    btVector3 vertices[3];
 
        u32 i, j, k;
 
        s32 index, numVertices;
 
        u16* mb_indices;
 
        const vector3df &scale = node->getScale();
 
 
 
        btTriangleMesh *pTriMesh = new btTriangleMesh();
 
 
 
        for(i = 0; i < mesh->getMeshBufferCount(); i++)
 
        {
 
                irr::scene::IMeshBuffer* mb=mesh->getMeshBuffer(i);
 
 
 
        //////////////////////////////////////////////////////////////////////////
 
                // Extract vertex data                                                  //
 
                // Because the vertices are stored as structs with no common base class,//
 
                // We need to handle each type separately                               //
 
                //////////////////////////////////////////////////////////////////////////
 
                if(mb->getVertexType() == irr::video::EVT_STANDARD)
 
                {
 
                        irr::video::S3DVertex* mb_vertices=(irr::video::S3DVertex*)mb->getVertices();
 
                        mb_indices = mb->getIndices();
 
                        numVertices = mb->getVertexCount();
 
                        for(j=0;j<mb->getIndexCount();j+=3)
 
                        { //get index into vertex list
 
                                for (k=0;k<3;k++)
 
                                {
 
                                    //three verts per triangle
 
                                        index = mb_indices[j+k];
 
                                        if (index > numVertices) continue;
 
                                        //convert to btVector3
 
                                        vertices[k] = irrlichtToBulletVector(mb_vertices[index].Pos * scale); // 1100
 
                                }
 
                                pTriMesh->addTriangle(vertices[0], vertices[1], vertices[2]);
 
                        }
 
 
 
                }
 
                else
 
                if(mb->getVertexType()==irr::video::EVT_2TCOORDS)
 
                {
 
                        // Same but for S3DVertex2TCoords data
 
                        irr::video::S3DVertex2TCoords* mb_vertices=(irr::video::S3DVertex2TCoords*)mb->getVertices();
 
                        u16* mb_indices = mb->getIndices();
 
                        s32 numVertices = mb->getVertexCount();
 
                        for(j=0;j<mb->getIndexCount();j+=3)
 
                        { //index into irrlicht data
 
                                for (k=0;k<3;k++)
 
                                {
 
                                        s32 index = mb_indices[j+k];
 
                                        if (index > numVertices) continue;
 
                                        vertices[k] = irrlichtToBulletVector(mb_vertices[index].Pos * scale);
 
                                }
 
                                pTriMesh->addTriangle(vertices[0], vertices[1], vertices[2]);
 
                        }
 
                }
 
 
 
                // Does not handle the EVT_TANGENTS type
 
        }
 
 
 
        if(pTriMesh)
 
        {
 
            return pTriMesh;
 
        }
 
 
 
        return 0;
 
}
then just create a collision object out of it. Works for both the bsp and the obj obviously....but you might wanna use the btBvhTriangleMeshShape later for the bsp to make it faster.
then synchronize...why would you combine static animators of irricht with a physics engine? write an animator that holds a btRigidBody and then get its transform and apply it to your scenenode...done
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
WaxyChicken
Posts: 95
Joined: Sat Jun 25, 2011 6:15 am

Re: lime & bullet

Post by WaxyChicken »

*bows*
you have no idea how hard that Greek is for me to find.
the sad thing is i think i found it before but didn't understand what it was.
in a few hours I'll have it translated and be able to apply that to the existing framework i already have for the game.

Thanks for not being all talk.
why would you combine static animators of irricht with a physics engine? write an animator that holds a btRigidBody and then get its transform and apply it to your scenenode...done
dude, you're cool. :D

(And thanks to Cobra)
_______________________________________________________
You could argue with me all day long about which language is best.
But what it comes down to is:
which language is best for YOU and which language is best for ME.
WaxyChicken
Posts: 95
Joined: Sat Jun 25, 2011 6:15 am

Re: lime & bullet

Post by WaxyChicken »

And for anyone else that may need it in the future:

vb.net 2010

Code: Select all

 
    Private Function createTriangleMesh(ByVal mesh As Mesh) As TriangleMesh
        ' Original code by Cobra - see irrBullet: http://sourceforge.net/projects/irrbullet
        ' Conversion by WaxyChicken
 
        Dim vertices(2) As BulletSharp.Vector3
 
        Dim i As UInteger
        Dim j As UInteger
        Dim k As UInteger
 
        Dim index As New Integer
        Dim numVertices As New Integer
 
        Dim mb_indices() As UShort
 
        Dim scale As Vector3Df = MasterDevice.SceneManager.RootNode.Scale  'node.scale
  
        Dim pTriMesh As New TriangleMesh()
  
        For i = 0 To mesh.MeshBufferCount - 1
 
            Dim mb As Scene.MeshBuffer = mesh.GetMeshBuffer(i)
 
            '////////////////////////////////////////////////////////////////////////
 
            ' Extract vertex data                                                  //
 
            ' Because the vertices are stored as structs with no common base class,//
 
            ' We need to handle each type separately                               //
 
            '////////////////////////////////////////////////////////////////////////
 
            If mb.VertexType() = IrrlichtLime.Video.VertexType.Standard Then
 
                '/ Original line is:
                '                irr::video::S3DVertex* mb_vertices=(irr::video::S3DVertex*)mb->getVertices();
                ' i may be misinterperting this. this code is untested.
                ' next 2 lines is my attempt
                Dim mb_vertices(UBound(mb.Vertices) + 1) As Vertex3D '= CType(mb.Vertices(), Vertex3D)
                System.Array.Copy(mb.Vertices, mb_vertices, mb_vertices.Length)
 
                mb_indices = mb.Indices()
 
                numVertices = mb.VertexCount()
 
                For j = 0 To mb.IndexCount() - 1 Step 3
 
 
                    For k = 0 To 2
 
 
                        'three verts per triangle
 
                        index = mb_indices(j + k)
 
                        If index > numVertices Then
                            Continue For
                        End If
 
                        'convert to btVector3
 
                        vertices(k) = irrlichtToBulletVector(mb_vertices(index).Position * scale) ' 1100
 
                    Next k
 
                    pTriMesh.AddTriangle(vertices(0), vertices(1), vertices(2))
 
                Next j
 
            Else
 
                If mb.VertexType() = IrrlichtLime.Video.VertexType.TTCoords Then
 
                    ' Same but for S3DVertex2TCoords data
 
                ' Original line is:
                '                irr::video::S3DVertex2TCoords* mb_vertices=(irr::video::S3DVertex2TCoords*)mb->getVertices();
                ' i may be misinterperting this. this code is untested.
                ' next 2 lines is my attempt:
                    Dim mb_vertices(UBound(mb.Vertices) + 1) As IrrlichtLime.Video.Vertex3DTTCoords
                    System.Array.Copy(mb.Vertices, mb_vertices, UBound(mb.Vertices))
 
                    mb_indices = mb.Indices
 
                    numVertices = mb.VertexCount
 
                    For j = 0 To mb.IndexCount - 1 Step 3
 
 
                        For k = 0 To 2
 
 
                            index = mb_indices(j + k)
 
                            If index > numVertices Then
                                Continue For
                            End If
 
                            vertices(k) = irrlichtToBulletVector(mb_vertices(index).Position * scale)
 
                        Next k
 
                        pTriMesh.AddTriangle(vertices(0), vertices(1), vertices(2))
 
                    Next j
 
                End If
            End If
 
            ' Does not handle the EVT_TANGENTS type
 
        Next i
 
        Return pTriMesh
 
        'Return 0
 
    End Function
 
    Private Function irrlichtToBulletVector(ByVal vec As Vector3Df) As BulletSharp.Vector3
        Return New Vector3(vec.X, vec.Y, vec.Z)
    End Function
_______________________________________________________
You could argue with me all day long about which language is best.
But what it comes down to is:
which language is best for YOU and which language is best for ME.
Post Reply