00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <PVLE/Physics/Utility.h>
00028 #include <PVLE/Physics/GeometryHandlers.h>
00029 #include <PVLE/Physics/Geom.h>
00030 #include <PVLE/Physics/World.h>
00031 #include <PVLE/Physics/Body.h>
00032
00033
00034 namespace Physics {
00035
00036 Geom * createCanonicalBoxGeom(const osg::Vec3 & size, const SurfaceParams & surfaceParam) {
00037 return new Geom(new BoxHandler(size), surfaceParam);
00038 }
00039
00040 Geom * createCanonicalBox(World * pPhyWorld, const osg::Vec3 & size, const float mass, const SurfaceParams & surfaceParam) {
00041 Geom * pGeom = new Geom(new BoxHandler(size), surfaceParam);
00042 Body * pBody = new Body(pPhyWorld);
00043 pGeom->setBody(pBody);
00044 pBody->getMassData().setBoxTotal(mass, size);
00045 return pGeom;
00046 }
00047
00048
00049 Geom * createCanonicalSphereGeom(const float radius, const SurfaceParams & surfaceParam) {
00050 return new Geom(new SphereHandler(radius), surfaceParam);
00051 }
00052
00053 Geom * createCanonicalSphere(World * pPhyWorld, const float radius, const float mass, const SurfaceParams & surfaceParam) {
00054 Geom * pGeom = new Geom(new SphereHandler(radius), surfaceParam);
00055 Body * pBody = new Body(pPhyWorld);
00056 pGeom->setBody(pBody);
00057 pBody->getMassData().setSphereTotal(mass, radius);
00058 return pGeom;
00059 }
00060
00061
00062 Geom * createCanonicalCapsuleGeom(const float radius, const float length, const SurfaceParams & surfaceParam) {
00063 return new Geom(new CapsuleHandler(radius, length), surfaceParam);
00064 }
00065
00066 Geom * createCanonicalCapsule(World * pPhyWorld, const float radius, const float length, const float mass, const SurfaceParams & surfaceParam) {
00067 Geom * pGeom = new Geom(new CapsuleHandler(radius, length), surfaceParam);
00068 Body * pBody = new Body(pPhyWorld);
00069 pGeom->setBody(pBody);
00070 pBody->getMassData().setCapsuleTotal(mass, Mass::Z_AXIS, radius, length);
00071 return pGeom;
00072 }
00073
00074
00075 Geom * createCanonicalCylinderGeom(const float radius, const float length, const SurfaceParams & surfaceParam) {
00076 return new Geom(new CylinderHandler(radius, length), surfaceParam);
00077 }
00078
00079 Geom * createCanonicalCylinder(World * pPhyWorld, const float radius, const float length, const float mass, const SurfaceParams & surfaceParam) {
00080 Geom * pGeom = new Geom(new CylinderHandler(radius, length), surfaceParam);
00081 Body * pBody = new Body(pPhyWorld);
00082 pGeom->setBody(pBody);
00083 pBody->getMassData().setCylinderTotal(mass, Mass::Z_AXIS, radius, length);
00084 return pGeom;
00085 }
00086
00087 }