Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

132 Neutral

About aws357

  • Rank
  1. The script in question is just a thing I am doing with PhysX...   This thread on devtalk made the assumption that a GPU dispatcher was enough to do rigid body dynamics on GPU...    So that's an interesting point you are making here.    I've looked up the samples in Physx 3.3.0 SDK and only found the gpudispatch in PhysXSample.cpp but it does not provide more explanation than the thread I linked to.
  2. So, after tinkering for a while on PhysX, I have a script that build "noodles" of capsules and I am quite happy with it.    However, I would like to try using the GPUs (I have 1 Geforce and 3 tesla cards) to do the simulation instead of the CPU.   Here is what I have... //sceneDesc.cpuDispatcher = PxDefaultCpuDispatcherCreate(1); //Creates default CPU dispatcher for the scene //testing GPU dispatcher PxProfileZoneManager* profileZoneManager = &PxProfileZoneManager::createProfileZoneManager(gFoundation); PxCudaContextManagerDesc cudaContextManagerDesc; PxCudaContextManager* cudaContextManager = PxCreateCudaContextManager(*gFoundation,cudaContextManagerDesc,profileZoneManager); sceneDesc.gpuDispatcher = cudaContextManager->getGpuDispatcher(); //testing GPU dispatcher As you can see, while using the cpuDispatcher is easy, using the gpuDispatcher requires quite a number of lines of codes.   However when the script is launched I get 1 error lines...   ..\..\PhysX\src\NpPhysics.cpp (229) : invalid parameter : Physics::createScene: desc.isValid() is false! ... along with many warnings... 'phystest3.exe' : Chargé 'C:\Windows\SysWOW64\<multiple name>.dll', Cannot find or open the PDB file But these warning don't stop the script from working properly when using the CPU.   Before anyone asks, I updated Cuda to the latest available on nVidia site, and updated my graphic drivers because I had an error message from the script itself telling me the Cuda version and graphic drivers on my machine were a bit old.   Searching google for this specific error return few useful links. I am at my wit's end as to what to do now.
  3. Thanks for all the replies. It helped, even when I could not make sense of them (give hint and google search terms etc...).  Plus i was probably looking for a complicated solution when a simple one works just fine.   Here is the solution I finally settled for. A vector to store bodies. vector <PxRigidBody*> arrayofBodies; PxTransform boxPos1(initpos,PxQuat(PxHalfPi, PxVec3(0.0f, 1.0f, 0.0f))); //Position and orientation(transform) for box actor PxRigidDynamic *gBoxOri = NULL; //Instance of box actor PxCapsuleGeometry sphereGeometry(radius,height); //Defining geometry for box actor gBoxOri = PxCreateDynamic(*gPhysicsSDK, boxPos1, sphereGeometry, *material, 1.0f); //Creating rigid static actor gScene->addActor(*gBoxOri); //Adding box actor to PhysX scene arrayofBodies.push_back(gBoxOri); //vector is filled with bodies here... for (PxU32 i=1; i<numberofblocks; i++) { PxTransform boxPos1(initpos+PxVec3(0.0f, 0.0f, 2*i*height/*2.0f*/),PxQuat(PxHalfPi, PxVec3(0.0f, 1.0f, 0.0f))); //Position and orientation(transform) for box actor PxRigidDynamic *gBox = NULL; //Instance of box actor PxCapsuleGeometry sphereGeometry(radius,height); //Defining geometry for box actor gBox = PxCreateDynamic(*gPhysicsSDK, boxPos1, sphereGeometry, *material, 1.0f); //Creating rigid static actor gScene->addActor(*gBox); //Adding box actor to PhysX scene // adding some joint to the mix //PxSphericalJoint* joint = PxSphericalJointCreate(*gPhysicsSDK, gBoxOri, PxTransform(-offset), gBox, PxTransform(offset)); //PxSphericalJoint* joint = PxSphericalJointCreate(*gPhysicsSDK, gBoxOri, PxTransform(offset0), gBox, PxTransform(offset1)); //uncomment to use spherical joints PxD6Joint* joint = PxD6JointCreate(*gPhysicsSDK, gBoxOri, PxTransform(offset0), gBox, PxTransform(offset1)); //add some limits to the joint //joint->setLimitCone(PxJointLimitCone(0.00000001f,0.00000001f,0.1f)); //joint->setSphericalJointFlag(PxSphericalJointFlag::eLIMIT_ENABLED,true); joint->setSwingLimit(PxJointLimitCone(1.57f,1.57f,0.00000001f)); joint->setConstraintFlag(PxConstraintFlag::eVISUALIZATION, true); joint->setMotion(PxD6Axis::eTWIST, PxD6Motion::eLOCKED); joint->setMotion(PxD6Axis::eSWING1, PxD6Motion::eLIMITED); joint->setMotion(PxD6Axis::eSWING2, PxD6Motion::eLIMITED); //joint->setMotion(PxD6Axis::eSWING1, PxD6Motion::eFREE); //free to rotate around y axis //add the body to the array before renaming the original box... arrayofBodies.push_back(gBox); //vector is filled with bodies here... gBoxOri=gBox; I can then run through the vector of bodies with ease.  void countActor(void) { //PxU32 nbActors = gScene->getNbActors(physx::PxActorTypeSelectionFlag::eRIGID_DYNAMIC); //PxActor** actors = new PxActor*[nbActors]; //gScene->getActors(physx::PxActorTypeSelectionFlag::eRIGID_DYNAMIC,actors,nbActors); int nbActors=arrayofBodies.size(); //arrayofBodies[1]->addForce(PxVec3(0,800,0),PxForceMode::eACCELERATION); while(nbActors--) { int fx=rand()%50; int fy=rand()%50; int fz=rand()%50; //cout<<fx<<"_"<<fy<<"_"<<fz<<"\n"; //arrayofBodies[nbActors]; arrayofBodies[nbActors]->addForce(PxVec3(fx,fy,fz),PxForceMode::eIMPULSE); arrayofBodies[nbActors]->getLinearVelocity } } Again, kudo to all.
  4. The thing is, I am not sure how to access the bodies in the simulation (C++ && Physx noob alert, bear with me please).   There is a PxScene::getActors but no PxScene::getBodies. So it is not really clear for me where the bodies are stored in physx and how they can be accessed if i wish to loop through them.   Here is a code I glued together to loop through actors e.g.   I guess actors are linked to bodies but I don't really know how to access the bodies so I can use PxRigidBody::addForce on them...   Hope it makes the question clearer. void countActor(void) { PxU32 nbActors = gScene->getNbActors(physx::PxActorTypeSelectionFlag::eRIGID_DYNAMIC); PxActor** actors = new PxActor*[nbActors]; gScene->getActors(physx::PxActorTypeSelectionFlag::eRIGID_DYNAMIC,actors,nbActors); while(nbActors--) { cout<<"nb"<<nbActors<<"_"<<"actor"<<actors<<"\n"; } }
  5. In physx you create a body and add it as an actor to a scene.    The thing I am trying to do is to go through the rigid bodies in the scene to apply a random force impulse on each rigid bodies.    So I am looking for the most efficient way to loop through all the bodies in a scene.   Thanks for any hints.
  6. Success...   In the end the filter shader seems ridiculous simple (I was looking for something much more complicated...). If it helps anyone trying to do the same thing.... PxFilterFlags customFilterShader(PxFilterObjectAttributes attributes0, PxFilterData filterData0, PxFilterObjectAttributes attributes1, PxFilterData filterData1, PxPairFlags& pairFlags, const void* constantBlock, PxU32 constantBlockSize) { pairFlags = PxPairFlag::eCONTACT_DEFAULT; return PxFilterFlag::eDEFAULT; }
  7. Ok. Reporting on my progress so far, I found this link that finally gave me the filter flag I was looking for... eKILL.   No I just have to find how to tell the filter to do that only for object that are joined together by joints (non contact joints) 
  8. Sorry, I missed the answer because I was offline waiting for some Ikea furniture (that never arrived...).   If there is a page or a link to the feature I would be interested and grateful (google returns nothing useful with chains+physx).   Custom filter could work, but the main problem is to find a practical simple working example of the filter attributes...   If I can't tell physx to ignore collisions between adjacent joined bodies, the chain is going to explode on launch or be extremely jittery.    This code gives me an idea of how I should do it...  // let triggers through if(PxFilterObjectIsTrigger(attributes0) || PxFilterObjectIsTrigger(attributes1)) { pairFlags = PxPairFlag::eTRIGGER_DEFAULT; return PxFilterFlag::eDEFAULT; } This page makes me think I should use the eSOLVE_CONTACT which is used in the default contact resolution according to pxfiltering.h.    Still digging.
  9. //create custom filter PxFilterFlags customFilterShader(PxFilterObjectAttributes attributes0, PxFilterData filterData0, PxFilterObjectAttributes attributes1, PxFilterData filterData1, PxPairFlags& pairFlags, const void* constantBlock, PxU32 constantBlockSize) { // all initial and persisting reports for everything, with per-point data pairFlags = PxPairFlag::eCONTACT_DEFAULT | PxPairFlag::eTRIGGER_DEFAULT | PxPairFlag::eNOTIFY_CONTACT_POINTS | PxPairFlag::eCCD_LINEAR; //Set flag to enable CCD (Continuous Collision Detection) return PxFilterFlag::eDEFAULT; //more ugly test code if(PxFilterObjectIsTrigger(attributes0) || PxFilterObjectIsTrigger(attributes1)) // <---- this is where you define the custom attribute if I understand... { pairFlags = PxPairFlag::eTRIGGER_DEFAULT; return PxFilterFlag::eDEFAULT; } //end more ugly test code } //end of custom filter Here is a textbook example from a very helpful book I bought (Learning Physics Modeling with PhysX) but I have a hard time finding example for the case I developped in the OP (attribute that indicate two objects are joined... )   So I am stuck looking for the right thing to put between the "ugly test code" comment lines.
  10. Hello there, new to gamedev forum. I am a C++ newbie and PhysX virgin. I hope I won't waste people time...   That being said. I managed to do a script to generate a scene with a loop to generate a series of neatly aligned capsules.    I would like to do something similar to this ().   Capsules are being used for that. The n+1 capsule does not collide with the n capsule if n+1 because the collision filter is set to ignore objects collisions if objects are joined.   I would like to reproduce this kind of collision filtering in PhysX, to tell physx not to detect collisions between objects that are joined together.   I tried looking into official Physx documentation, but there is nothing about this specific case.    Has anybody tried this could it be done at all?
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!