add rope
This commit is contained in:
@ -64,7 +64,7 @@ b3Mat44 Camera::BuildProjectionMatrix() const
|
||||
b3Transform Camera::BuildWorldTransform() const
|
||||
{
|
||||
b3Transform xf;
|
||||
xf.rotation = b3ConvertQuatToMat(m_q);
|
||||
xf.rotation = b3QuatMat33(m_q);
|
||||
xf.position = (m_zoom * xf.rotation.z) - m_center;
|
||||
return xf;
|
||||
}
|
||||
@ -78,7 +78,7 @@ b3Mat44 Camera::BuildWorldMatrix() const
|
||||
b3Transform Camera::BuildViewTransform() const
|
||||
{
|
||||
b3Transform xf;
|
||||
xf.rotation = b3ConvertQuatToMat(m_q);
|
||||
xf.rotation = b3QuatMat33(m_q);
|
||||
xf.position = (m_zoom * xf.rotation.z) - m_center;
|
||||
return b3Inverse(xf);
|
||||
}
|
||||
@ -1281,6 +1281,65 @@ void DebugDraw::DrawSolidSphere(const b3Vec3& center, float32 radius, const b3Co
|
||||
m_solid->DrawSphere(radius, color, xf);
|
||||
}
|
||||
|
||||
void DebugDraw::DrawCapsule(const b3Vec3& c1, const b3Vec3& c2, float32 radius, const b3Color& color)
|
||||
{
|
||||
float32 height = b3Length(c1 - c2);
|
||||
|
||||
{
|
||||
b3Transform xfc;
|
||||
xfc.rotation.SetIdentity();
|
||||
xfc.position = c1;
|
||||
m_wire->DrawSphere(radius, color, xfc);
|
||||
}
|
||||
|
||||
if (height > 0.0f)
|
||||
{
|
||||
DrawSegment(c1, c2, color);
|
||||
|
||||
{
|
||||
b3Transform xfc;
|
||||
xfc.rotation.SetIdentity();
|
||||
xfc.position = c2;
|
||||
m_wire->DrawSphere(radius, color, xfc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DebugDraw::DrawSolidCapsule(const b3Vec3& c1, const b3Vec3& c2, float32 radius, const b3Color& c)
|
||||
{
|
||||
float32 height = b3Length(c1 - c2);
|
||||
|
||||
{
|
||||
b3Transform xfc;
|
||||
xfc.rotation.SetIdentity();
|
||||
xfc.position = c1;
|
||||
m_solid->DrawSphere(radius, c, xfc);
|
||||
}
|
||||
|
||||
if (height > 0.0f)
|
||||
{
|
||||
{
|
||||
b3Mat33 R;
|
||||
R.y = (1.0f / height) * (c1 - c2);
|
||||
R.z = b3Perp(R.y);
|
||||
R.x = b3Cross(R.y, R.z);
|
||||
|
||||
b3Transform xfc;
|
||||
xfc.position = 0.5f * (c1 + c2);
|
||||
xfc.rotation = R;
|
||||
|
||||
m_solid->DrawCylinder(radius, height, c, xfc);
|
||||
}
|
||||
|
||||
{
|
||||
b3Transform xfc;
|
||||
xfc.rotation.SetIdentity();
|
||||
xfc.position = c2;
|
||||
m_solid->DrawSphere(radius, c, xfc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DebugDraw::DrawTransform(const b3Transform& xf)
|
||||
{
|
||||
float32 lenght = 1.0f;
|
||||
|
@ -103,6 +103,10 @@ public:
|
||||
|
||||
void DrawSolidSphere(const b3Vec3& center, float32 radius, const b3Color& color);
|
||||
|
||||
void DrawCapsule(const b3Vec3& p1, const b3Vec3& p2, float32 radius, const b3Color& color);
|
||||
|
||||
void DrawSolidCapsule(const b3Vec3& p1, const b3Vec3& p2, float32 radius, const b3Color& color);
|
||||
|
||||
void DrawAABB(const b3AABB3& aabb, const b3Color& color);
|
||||
|
||||
void DrawTransform(const b3Transform& xf);
|
||||
|
@ -64,14 +64,14 @@ static void MouseMove(GLFWwindow* w, double x, double y)
|
||||
if (g_leftDown)
|
||||
{
|
||||
// Negate angles to do positive rotations (CCW) of the world.
|
||||
float32 angleX = 0.005f * B3_PI * -nx;
|
||||
float32 angleY = 0.005f * B3_PI * -ny;
|
||||
float32 angleX = 0.005f * B3_PI * -nx;
|
||||
|
||||
b3Quat qx = b3QuatRotationX(angleY);
|
||||
b3Quat qy = b3QuatRotationY(angleX);
|
||||
|
||||
b3Quat qx(b3Vec3(1.0f, 0.0f, 0.0f), angleY);
|
||||
b3Quat qy(b3Vec3(0.0f, 1.0f, 0.0f), angleX);
|
||||
|
||||
g_camera.m_q = qy * g_camera.m_q;
|
||||
g_camera.m_q = g_camera.m_q * qx;
|
||||
g_camera.m_q = qy * g_camera.m_q;
|
||||
g_camera.m_q.Normalize();
|
||||
}
|
||||
|
||||
|
@ -55,9 +55,12 @@
|
||||
#include <testbed/tests/body_types.h>
|
||||
#include <testbed/tests/varying_friction.h>
|
||||
#include <testbed/tests/varying_restitution.h>
|
||||
#include <testbed/tests/cloth_test.h>
|
||||
#include <testbed/tests/tumbler.h>
|
||||
#include <testbed/tests/pendulum.h>
|
||||
#include <testbed/tests/single_pendulum.h>
|
||||
#include <testbed/tests/multiple_pendulum.h>
|
||||
#include <testbed/tests/cloth_test.h>
|
||||
#include <testbed/tests/rope_test.h>
|
||||
//#include <testbed/tests/tree_test.h>
|
||||
|
||||
TestEntry g_tests[] =
|
||||
{
|
||||
@ -97,9 +100,12 @@ TestEntry g_tests[] =
|
||||
{ "Body Types", &BodyTypes::Create },
|
||||
{ "Varying Friction", &VaryingFriction::Create },
|
||||
{ "Varying Restitution", &VaryingRestitution::Create },
|
||||
{ "Cloth", &Cloth::Create },
|
||||
{ "Tumbler", &Tumbler::Create },
|
||||
{ "Initial Overlap", &InitialOverlap::Create },
|
||||
{ "Pendulum", &Pendulum::Create },
|
||||
{ "Single Pendulum", &SinglePendulum::Create },
|
||||
{ "Multiple Pendulum", &MultiplePendulum::Create },
|
||||
{ "Cloth", &Cloth::Create },
|
||||
{ "Rope", &Rope::Create },
|
||||
//{ "Tree", &Tree::Create },
|
||||
{ NULL, NULL }
|
||||
};
|
Reference in New Issue
Block a user