5. PhysX Materials
Jump To:
main.cpp Source
Download
Main.CPP File: For our fourth PhysX tutorial, we are just going to set a couple of paramters for our SDK and our scene. These are all going to take place in our initNX function. First off we are going to set a default skin width for objects in our scene. But first I will explain what this does. Each object has it’s own skin that goes around the object at the width of the skin depth we are going to set. This skin is used for interpenetration between objects to account for inaccuracy when stacking objects on top of each other. The skin allows the objects to penetrate each other, at the width of the skin. The width of the skin that should be needed depends on the size of the objects as it can lead to visible penetration. The default skin width is set to 0.025. To set the skin width we just use the following line after we set the Physics SDK: NxMaterial* defaultMaterial = gScene->getMaterialFromIndex(0); defaultMaterial->setRestitution(0.5); There are a couple of parameters covered (there are LOTS more). Check out the next tutorial for setting materials here. If you have any questions, just email me at swiftless@gmail.com #include <stdio.h> #include <GL\glut.h> #include <Physics\include\NxPhysics.h> #define NOMINMAX #include <windows.h> #pragma comment(lib,"PhysXLoader.lib") #pragma comment(lib,"NxExtensions.lib") static NxPhysicsSDK* gPhysicsSDK = NULL; NxScene* gScene = NULL; void initNX(void){ gPhysicsSDK->setParameter(NX_SKIN_WIDTH, 0.01); NxSceneDesc sceneDesc; gScene = gPhysicsSDK->createScene(sceneDesc); NxMaterial* defaultMaterial = gScene->getMaterialFromIndex(0); } void deinitNX(void){ gPhysicsSDK->release(); } void display(void){ glutSwapBuffers(); void reshape(int w, int h){ } int main(int argc, char** argv) { glutCreateWindow("Physics"); initNX(); glutDisplayFunc(display); glutMainLoop(); deinitNX(); return 0; |
Download: |