From 4a82c67fdc353f833014347f867ac6c580bf5eda Mon Sep 17 00:00:00 2001 From: DirtPiper Date: Sat, 26 Oct 2019 15:54:48 -0400 Subject: [PATCH] Added getMass to part --- G3DTest.vcproj | 2 +- PartInstance.cpp | 12 ++++++++++++ PartInstance.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/G3DTest.vcproj b/G3DTest.vcproj index 1947667..ecebf3b 100644 --- a/G3DTest.vcproj +++ b/G3DTest.vcproj @@ -3,7 +3,7 @@ ProjectType="Visual C++" Version="8.00" Name="G3DTest" - ProjectGUID="{6C4D6EEF-B1D1-456A-B850-92CAB17124BE}" + ProjectGUID="{277D185B-AEBA-4F75-A7FC-F1EBE787C200}" RootNamespace="G3DTest" > diff --git a/PartInstance.cpp b/PartInstance.cpp index 21ddf1d..21b3962 100644 --- a/PartInstance.cpp +++ b/PartInstance.cpp @@ -149,6 +149,18 @@ CoordinateFrame PartInstance::getCFrameRenderBased() { return cFrame;//CoordinateFrame(getCFrame().rotation,Vector3(getCFrame().translation.x, getCFrame().translation.y, getCFrame().translation.z)); } + +// Start Physics stuff +float PartInstance::getMass() +{ + if(shape == Enum::Shape::Sphere || shape == Enum::Shape::Cylinder){ + return (4/3) * 3.1415926535 * pow(size.x/2, 3); + } + return size.x * size.y * size.z; +} + + + #ifdef NEW_BOX_RENDER Box PartInstance::getBox() { diff --git a/PartInstance.h b/PartInstance.h index 094e4ed..c5ace98 100644 --- a/PartInstance.h +++ b/PartInstance.h @@ -45,6 +45,7 @@ public: void debugPrintVertexIDs(RenderDevice* rd, GFontRef font, Matrix3 camRot); void makeFace(int vertex1, int vertex2, int vertex3); bool isUniqueVertex(Vector3 pos); + float getMass(); private: Vector3 position; Vector3 size;