Collection of Useful Theatre Activities and Games - Nussdorfer
Useful Tools for Making Video Games - Newton (2008)
-
Upload
korhan-bircan -
Category
Engineering
-
view
8 -
download
3
Transcript of Useful Tools for Making Video Games - Newton (2008)
![Page 1: Useful Tools for Making Video Games - Newton (2008)](https://reader036.fdocuments.in/reader036/viewer/2022080422/587254d81a28ab852f8b8075/html5/thumbnails/1.jpg)
1
Useful Tools for Making Video Games
Part IIIAn overview of
![Page 2: Useful Tools for Making Video Games - Newton (2008)](https://reader036.fdocuments.in/reader036/viewer/2022080422/587254d81a28ab852f8b8075/html5/thumbnails/2.jpg)
2
Featureseasy to use C-API available for windows, osx, linuxplethora of convex collision shapes compound collision shapes continuous collision mode hinge, ball, slider, corkscrew,... and custom joints special vehicle container special ragdoll container
![Page 3: Useful Tools for Making Video Games - Newton (2008)](https://reader036.fdocuments.in/reader036/viewer/2022080422/587254d81a28ab852f8b8075/html5/thumbnails/3.jpg)
3
Startup sequence (simplified)// create the newton worldNewtonWorld* nWorld = NewtonCreate(…);
// Create the collision shapeNewtonCollision*collision = NewtonCreateBox (…);
// Create the rigid bodyNewtonBody* rigidBodyBox = NewtonCreateBody (nWorld, collision);
// set the body mass and inertiaNewtonBodySetMassMatrix (rigidBodyBox, …);
// Set the transformation matrixNewtonBodySetMatrix (rigidBodyBox, …);
// Animate the body eg. By setting angular velocityNewtonBodySetOmega (rigidBodyBox, …);
// in game loop update timer, get new transformation matrixNewtonUpdate (nWorld, timeStep); NewtonBodyGetMatrix(rigidBodyBox, …); // use this matrix to render a box
![Page 4: Useful Tools for Making Video Games - Newton (2008)](https://reader036.fdocuments.in/reader036/viewer/2022080422/587254d81a28ab852f8b8075/html5/thumbnails/4.jpg)
4
Using Callbacks
At each update apply force and update transformation of rendering primitive
// at body creationNewtonBodySetTransformCallback (boxBody, transCallback);NewtonBodySetForceAndTorqueCallback (boxBody, forceCallback);
Where
void transCallback (const NewtonBody* body, const dFloat* matrix) {…}void forceCallback(const NewtonBody* body) {…}
![Page 5: Useful Tools for Making Video Games - Newton (2008)](https://reader036.fdocuments.in/reader036/viewer/2022080422/587254d81a28ab852f8b8075/html5/thumbnails/5.jpg)
5
MaterialsAssign physical properties to Newton bodies such as friction, softness, elasticity etc.You need to set the material interactions for every combination of any two materials in your scene!
// create materialInt materialId = NewtonMaterialCreateGroupID(nWorld);NewtonMaterialSetDefaultSoftness (nWorld, defaultID, …);NewtonMaterialSetDefaultElasticity (nWorld, defaultID, …);NewtonMaterialSetDefaultCollidable (nWorld, defaultID, …);NewtonMaterialSetDefaultFriction (nWorld, defaultID, …);NewtonMaterialSetCollisionCallback (nWorld, defaultID, …);
// set material to bodyNewtonBodySetMaterialGroupID (boxBody, materialId);
![Page 6: Useful Tools for Making Video Games - Newton (2008)](https://reader036.fdocuments.in/reader036/viewer/2022080422/587254d81a28ab852f8b8075/html5/thumbnails/6.jpg)
6
Joints and Constraints
Ball and Socket
Hinge
![Page 7: Useful Tools for Making Video Games - Newton (2008)](https://reader036.fdocuments.in/reader036/viewer/2022080422/587254d81a28ab852f8b8075/html5/thumbnails/7.jpg)
7
Joints and ConstraintsSlider
Corkscrew Universal
![Page 8: Useful Tools for Making Video Games - Newton (2008)](https://reader036.fdocuments.in/reader036/viewer/2022080422/587254d81a28ab852f8b8075/html5/thumbnails/8.jpg)
8
Joints and ConstraintsNewtonJoint* joint =
NewtonConstraintCreate[Ball/Hinge/Slider/Corkscrew/Universal] (…, body1, body2);
Newton[Ball/Hinge/Slider/Universal]SetUserCallback (joint, callbackFunc);
Also need to set limits, pivot, stiffness, friction depending on the type of jointfor details look at
samples\tutorial_05_UsingJointsDon’t forget to check out NewtonRaceCar(samples\tutorial_09_SimpleVehicle)
![Page 9: Useful Tools for Making Video Games - Newton (2008)](https://reader036.fdocuments.in/reader036/viewer/2022080422/587254d81a28ab852f8b8075/html5/thumbnails/9.jpg)
9
Rendering Engine Integration
Already done!OgreNewtIrrNewt
Takes care of most of setting up, updating, allocation/deallocationand other details
![Page 10: Useful Tools for Making Video Games - Newton (2008)](https://reader036.fdocuments.in/reader036/viewer/2022080422/587254d81a28ab852f8b8075/html5/thumbnails/10.jpg)
10
Referenceshttp://www.newtondynamics.com/http://www.newtondynamics.com/forumhttp://aresfps.sourceforge.net/irrnewt.htmhttp://walaber.com/index.php?action=showitem&id=9