Page 1 of 1

Irrlicht, Bullet and Quake 3 maps.... The bane of my existen

Posted: Sat Mar 22, 2014 10:58 pm
by Metalhead33
I use Irrlicht 1.8.1 and Bullet Physics 2.82...
So what is the problem? I can't get them them to work with a Quake 3 map.
Getting it to work with Irrlicht works fine and dandy. But Bullett?
Nope.
I can't even compile Bullet's BspDemo, since I don't have GLUT. I tried to add BspConverter as a header, but it complains how " 'm_dynamicsWorld' was not declared in this scope|", and how many other stuff were not declared. It's driving me crazy.
This happens when I simply copy everything from the .cpp files into the .h files.
But when I try to use the original, unedited files, it just complains about undefined references - which is funny, since I compiled the Bullet library, and linked it to my program.

Isn't there a way to get Bullet Physics to work with BSP files? A way where I can just include the header into my main.cpp, and it'll work like Irrlicht?
Every demo that Bullet has relies on something called GLUT which I don't even know what is.
By the way, I use CodeBlocks 12.11, Windows XP, MinGW compiler.

Why is using Bullet so freaking difficult? Why can't I have something compiles without complaining, and does what it's supposed to at a magical "Physics->InitPhysics("20kdm2.bsp")", like Irrlicht?
I'm starting to lose my faith in Bullet Physics.

Maybe I should post this to the Bullet Forums though.
I found this before, but all links on it seem dead.

Re: Irrlicht, Bullet and Quake 3 maps.... The bane of my exi

Posted: Sat Mar 22, 2014 11:44 pm
by Seven
I have written wrappers for multiple physics engines and keep coming back to PhysX (3.## now). Easy to use and very powerful. In addition, it is one I can help you with when you have questions :)

Let me look around for an old bullet wrapper to see if it had the quake world written for it.......

Re: Irrlicht, Bullet and Quake 3 maps.... The bane of my exi

Posted: Sat Mar 22, 2014 11:55 pm
by Seven
found one and copying it from the network (15 minutes) so i think that I will blabber for a minute.

in my wrappers, I create a base object class CSObject that can contain nodes, AI, attributes etc.... including a physics object. during the movement phase, the CSObject instance polls the CSPhysXObject for position and rotation.

I create physics objects by filling out a physics description and then using it to create the object (which is stored in the CSObject);
something like this.......

Code: Select all

 
// include this file only once
#pragma once
 
// include the needed header files
#include "CSO_Generic.h"
#include "CSObject.h"
#include "CSLevel.h"
 
namespace CS
{
    // This class is exported from the dll
    class CSO_Cube : public CSObject
    {
    public:
        // all objects must define this so that the normal CSObject::Frame()
        // call can update the position of the node based on the physicsobject
        virtual ISceneNode* getPrimarySceneNode() { return m_Node; }
 
        // the primarys cenenode for this object
        ADD_PUBLIC_VARIABLE_SETGET(ISceneNode*, Node);
 
        virtual bool cleanup()
        {
            // log this event
            CS_LOG("CSO_Cube::cleanup()");
 
            // safely remove the scenenode
            CS_SAFE_REMOVE(m_Node);
 
            // let the base class cleanup too
            return CSObject::cleanup();
        }
 
        virtual void initialize()
        {
            // log this event
            CS_LOG("CSO_Cube::Initialize()");
 
            // initialize the base class
            CSObject::initialize();
 
            // set variables to a known value
            CS_INIT(m_Node);
            CS_INIT_VECTOR3DF(m_Scale, 20, 20, 20);
            CS_INIT_FLOAT(m_Mass, 10.0f);
            CS_INIT_STRING(m_TextureFileName, "wall.jpg");
        }
 
        virtual bool create(CSLevel* level, int id)
        {
            // log this event
            CS_LOG("CSO_Cube::create()");
 
            // create the base class
            CSObject::create(level, id);
 
            // create the information structure for this object
            getInfo()->create(1, "CSO_Cube", "a box with physics attached", 1.00, "Seven");
 
            // everything went fine
            return true;
        }
 
        virtual bool reCreate()
        {
            // log this event
            CS_LOG("CSO_Cube::ReCreate()");
 
            // remove the node if it exists
            CS_SAFE_REMOVE(m_Node);
 
            // create the base class
            CS_CHECK_BOOL(CSObject::reCreate(), "CSO_Cube::ReCreate() -- base class create failed");
 
            // create the scenenode
            CS_CHECK_BOOL(createNode(),"Warning! node creation failed");
 
            // create the physx object
            createPhysXObject();
 
            // set the object's id after the node is created
            // this allows the editor to select the node properly
            setId(getId());
 
            // set the object type for the editors
            setObjectType(OBJECT_TYPE::CS_TYPE_OBJECT);
 
            // everything went fine
            return true;
        }
 
        virtual bool createNode()
        {
            // safely remove the node if it already exists
            CS_SAFE_REMOVE(m_Node);
 
            // create the node
            m_Node = getSmgr()->addCubeSceneNode(1, 0, -1, getPosition(), getRotation(), getScale());
 
            // make sure we have a vlid node
            CS_CHECK_BOOL(m_Node, "Warning! node creation failed!");
 
            // set the node variables
            m_Node->setMaterialTexture(0, getDriver()->getTexture(MEDIAPATH(getTextureFileName())));
 
            // everything went fine
            return true;
        }
 
        virtual void createPhysXObject()
        {
            CS_LOG("CSO_Cube::CreatePhysXObject()");
 
            // make sure the object is available
            CSObject::createPhysXObject();
 
            // make sure the node is valid
            CS_CHECK_RETURN(m_Node, "-- no node to create physics object from");
 
            // create a physics object to represent this node
            IPhysicsObjectData data;
            data.type       = POT_PRIMITIVE_BOX;
            data.node       = m_Node;
            data.position   = getPosition();
            data.rotation   = getRotation();
            data.scale      = getScale();
            data.mass       = getMass();
            data.gravity    = true;
            data.bboffset   = getBBOffset();
            data.userdata   = getId();
            data.dynamic    = true;
            setPhysXObject(getLevel()->getPhysXWorld()->createPhysXObject(data));
        }
    };
 
} // end namespace
 
 
When the createPhysXObject(data) call is resolved, it creates a physx object that relates to the data parameters that are passed in. In this case, a rectangular physx representation using position, rotation, scale, mass, and it is dynamic ( a plane would not be for example).

I tell you this so that you can understand the code I will post in a moment...........

Re: Irrlicht, Bullet and Quake 3 maps.... The bane of my exi

Posted: Sun Mar 23, 2014 12:15 am
by Seven
sigh, the old code i found doesnt have the bsp laoder in it sorry........

it did have this at the header......

// Bullet/irrlicht demo by Alan Witkowski
// http://www.cs.utah.edu/~witkowsk
// http://code.google.com/p/irrlamb/

if I remember, irrlamb was pretty good and should have the examples you need.

if you change your mind and decide to use physX I can be of more help.

Re: Irrlicht, Bullet and Quake 3 maps.... The bane of my exi

Posted: Sun Mar 23, 2014 8:14 am
by hendu
There's no need to open-code BSP loading. Load it in irr, pass the triangles to bullet as a bullet triangle mesh. If you can't code that conversion, there are several examples here on the forum.

Re: Irrlicht, Bullet and Quake 3 maps.... The bane of my exi

Posted: Sun Mar 23, 2014 2:16 pm
by Seven
if you are looking to change over to PhysX, let me know. I have quite a code base that I can share and I can answer questions better.

Re: Irrlicht, Bullet and Quake 3 maps.... The bane of my exi

Posted: Sun Mar 23, 2014 4:42 pm
by Metalhead33
I think I'll give Bullet a last chance and look for ways to pass the triangles to bullet as a bullet triangle meshes.
If I fail, I'll convert to PhysX.

Re: Irrlicht, Bullet and Quake 3 maps.... The bane of my exi

Posted: Sun Mar 23, 2014 5:17 pm
by Seven
sounds good and good luck with your project!

Re: Irrlicht, Bullet and Quake 3 maps.... The bane of my exi

Posted: Sat Mar 29, 2014 1:11 pm
by Metalhead33
Aaaand, thanks to this, I managed to do this!
Finally, working collision....

Re: Irrlicht, Bullet and Quake 3 maps.... The bane of my exi

Posted: Wed Apr 16, 2014 8:17 am
by Granyte
LOL when inis mona started I was like why is my music player on

anyway this is a nice start