00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include "Sphere.h"
00013
#include <OpenCAL/System.h>
00014
#include <OpenCAL/Renderer.h>
00015
using namespace OpenCAL;
00016
using namespace Utils;
00017
00018
using namespace std;
00019
00020
00021
00022
00023
00024
00025 Sphere::Sphere(
System *parent,
float radius,
float mass)
00026 :
RigidBody(parent, mass), m_radius(radius)
00027 {
00028
#ifdef VERBOSE
00029
Debug::print(
"Sphere constructor", 2);
00030
#endif // VERBOSE
00031
00032 }
00033
00034 Sphere::~Sphere()
00035 {
00036 }
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
void Sphere::render()
00049 {
00050
Renderer *renderer = m_parent->
getRenderer();
00051
if(!renderer)
return;
00052
00053
00054 renderer->
pushTransformation();
00055
00056 renderer->
translate(m_position);
00057 renderer->
rotate(m_rotation);
00058 renderer->
renderSphere(m_radius);
00059
00060
00061 renderer->
popTransformation();
00062 }
00063
00064
void Sphere::calculateVolume()
00065 {
00066 m_volume = 2 * Math::pi * Math::squared(m_radius);
00067 }
00068
00069
void Sphere::calculateInversedInertia()
00070 {
00071
m_invInertia.
identity();
00072
m_invInertia *= 5.0f / (2.0f * getMass() * Math::squared(m_radius));
00073
00074 cout <<
"Inversed inertia (body space):" << endl;
00075
m_invInertia.
print();
00076 }
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103