Really got stuck when trying to integrating physx with irr

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
MasterM
Posts: 128
Joined: Sat Oct 20, 2007 2:38 am
Location: netherlands antilles, Curacao

Really got stuck when trying to integrating physx with irr

Post by MasterM »

Hey guys...for these past days i have been trying hard to integrate Physx into Irrlicht but i haven't fully understand the integration process yet so i came here to get help from the professionals.
basically what i wanna accomplish is for a ball to start in the air and fall on a plane(and bounce).
here is a picture on what i want to accomplish : Image

Ok as i started on my quest to integrate Physx i did the following steps :
1.initialize the Irrlicht device
2.load a plane and sphere mesh into 2 Scene_Mesh_Nodes
3.initialize PhysxSDK
4.make a Physx scene
5.i got stuck here, i don't know what to do next

At 5 i get stuck and don't know what to do...
the thing is that i don't know the basic concept of integrating Physx into Irrlicht or like i say "attach physic to scene nodes"...
So i hope someone can point me in the right direction or tell me what i need to do to understand how to integrate Physx into Irrlicht.
If more information is needed to help me just tell me and ill give the information.
Thanks in advance.
C++ is not the Magdalena...it takes patience...shes like the well aged prostitute, it takes years to learn her tricks! she is cruel...laughs at you when you are naked...
Life of a programmer == Const abuse
Mel
Competition winner
Posts: 2293
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

You need to understand how the physics engines use to work. Esentially, you have to initialize a "world" within the physics system to colide with, and provide a description of the objects of the scene. Then, make the simulation run, and the physics engine will return you transformation matrices you have to aply to the objects of the scene you want to simulate, and that way, it will work. This applies more or less the same to all the physics engine, i don't know the exact details withing Physx, but it follows a similar pattern. Read the documentation regarding how to get the mesh definitions of the objects, and how to pass it to the physics engine, and that is all you have to do.

This thread should be moved to the Game programming forum! :)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

You could take a look at IrrPhysX. Either you could use it because it already integrates physx into irrlicht or you can look on how it handles stuff.
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
MasterM
Posts: 128
Joined: Sat Oct 20, 2007 2:38 am
Location: netherlands antilles, Curacao

Post by MasterM »

I had a look at Irrphysx but its very very very hard to find out how things work from it(...
I tried everything i can think of but nothing helped.
really if you know how to do this then can i see a example code or how its done(in code)...
I am sure there is more Physx users in this forum but do all of them use Irrphysx?
C++ is not the Magdalena...it takes patience...shes like the well aged prostitute, it takes years to learn her tricks! she is cruel...laughs at you when you are naked...
Life of a programmer == Const abuse
MasterM
Posts: 128
Joined: Sat Oct 20, 2007 2:38 am
Location: netherlands antilles, Curacao

Post by MasterM »

Can someone pleas help me?, i really like to learn how to do this but i really don't know how...i looked at irrphysics countless times and i googled countless times...i got some directions but they were no help to me...

btw here is the code i am working with atm(the one i puted together with no results yet)

Code: Select all

// Physics SDK globals
NxPhysicsSDK*     gPhysicsSDK = NULL;
NxUserAllocator*	myAllocator =0 ;
NxSDKCreateError *  Error=0;
NxUserOutputStream* output =0;
NxScene*			gScene =0;

int main()
{	//create irrlicht device
 IrrlichtDevice *device =
        createDevice(EDT_OPENGL, dimension2d<s32>(640, 480), 16,
            false, false, false, 0);

	//create physx device
 gPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION,myAllocator,output,NxPhysicsSDKDesc(),Error);
	if(!gPhysicsSDK)
	{
		cout<<"Wrong SDK DLL version"<<endl;
		gPhysicsSDK->release();
	}
	//setting skin width
	gPhysicsSDK->setParameter(NX_SKIN_WIDTH, 0.01); 

	//physics scene
	NxSceneDesc myscene;
	myscene.gravity = NxVec3(0.0f, -9.81f, 0.0f);
	gScene=gPhysicsSDK->createScene(myscene);

	//running in software mode
	myscene.simType = NX_SIMULATION_SW;

	//setting physx materials...
	NxMaterial* defaultMaterial = myScene->getMaterialFromIndex(0);
	defaultMaterial->setRestitution(0.0f);
	defaultMaterial->setStaticFriction(0.5f);
	defaultMaterial->setDynamicFriction(0.5f);

	NxActorDesc actorDesc;
    NxBodyDesc bodyDesc;
    bodyDesc.angularDamping = 0.5f;

    NxSphereShapeDesc sphereDesc;
    sphereDesc.radius = radius; // should be 0.5
    actorDesc.shapes.pushBack(&sphereDesc);

    actorDesc.body = &bodyDesc;
    actorDesc.density = 1.0f;
    actorDesc.globalPose.t = NxVec3(pos.X,pos.Y,pos.Z);
    myScene->createActor(actorDesc);    




    device->setWindowCaption(L"Physic test 1");
    IVideoDriver* driver = device->getVideoDriver();
    ISceneManager* smgr = device->getSceneManager();
    IGUIEnvironment* guienv = device->getGUIEnvironment();


	scene::IMesh *plane=smgr->getMesh("plane.3DS");
	scene::ISceneNode *planen= smgr->addMeshSceneNode(plane);

      scene::IMesh *ball=smgr->getMesh("bsll.3DS");
    scene::ISceneNode *balln= smgr->addMeshSceneNode(ball);

   
    smgr->addCameraSceneNodeFPS();
     
     if (balln)
     {
         balln->setPosition(vector3df(0,50,0));
         balln->setMaterialFlag(EMF_LIGHTING,false);
     }



 while(device->run())
    {

        driver->beginScene(true, true, SColor(0,200,200,200));

        smgr->drawAll();
        guienv->drawAll();

        driver->endScene();
    }


    device->drop();
	gPhysicsSDK->releaseScene(*gScene);
	gScene = 0; 
	gPhysicsSDK->release();

    return 0;
}
and i am aware that the physics isnt attached to any scene nodes but the problem is that i dont know how to do it...
thanks in advanced.
C++ is not the Magdalena...it takes patience...shes like the well aged prostitute, it takes years to learn her tricks! she is cruel...laughs at you when you are naked...
Life of a programmer == Const abuse
Post Reply