void CartWheel3D::addBall(const string& name, const Vector3d& scale, double mass, const Vector3d& color) { string mesh = _path + "data/models/sphere10x.obj"; Vector3d offset = Vector3d(0, 0, 0); #if 1 RigidBody* body = new ArticulatedRigidBody(); #else RigidBody* body = new RigidBody(); #endif body->setName(name.c_str()); body->setScale(scale); body->addMeshObj(mesh.c_str(), offset, scale); body->setColour(color.x, color.y, color.z, 1); // body->setColour(0.1, 0, 0.8, 1); body->setMass(mass); body->setMOI(Vector3d(0.2, 0.2, 0.2)); Point3d center = Point3d(0, 0, 0); SphereCDP* sphereCDP = new SphereCDP(center, scale.getX(), body); body->addCollisionDetectionPrimitive(sphereCDP); body->setFrictionCoefficient(1.8); body->setRestitutionCoefficient(0.35); ArticulatedRigidBody* arb = dynamic_cast<ArticulatedRigidBody*> (body); if (NULL != arb) { arb->setAFParent(NULL); arb->setParentJoint(NULL); _world->addArticulatedRigidBody(arb); } else { _world->addRigidBody(body); } }