parent
ef8ef0187a
commit
aaa795e34f
13 changed files with 1416 additions and 300 deletions
|
|
@ -590,7 +590,7 @@ public:
|
|||
{
|
||||
b3BodyDef bodyDef = b3DefaultBodyDef();
|
||||
bodyDef.type = b3_dynamicBody;
|
||||
bodyDef.position = { -m_walkRange, m_bodyHalfHeight + 0.1f, 0.0f };
|
||||
bodyDef.position = { -m_walkRangeX, m_bodyHalfHeight + 0.1f, 0.0f };
|
||||
bodyDef.motionLocks.angularX = true;
|
||||
bodyDef.motionLocks.angularY = true;
|
||||
bodyDef.motionLocks.angularZ = true;
|
||||
|
|
@ -613,8 +613,10 @@ public:
|
|||
b3CreateHullShape( m_characterId, &shapeDef, &box.base );
|
||||
}
|
||||
|
||||
m_walkDirection = 1.0f;
|
||||
m_walkSpeed = 350.0f * SRC; // s&box run speed
|
||||
m_walkDirectionX = 1.0f;
|
||||
m_walkDirectionZ = 1.0f;
|
||||
m_walkSpeedX = 350.0f * SRC; // s&box run speed
|
||||
m_walkSpeedZ = 20.0f * SRC;
|
||||
m_launchCount = 0;
|
||||
m_maxLaunchSpeed = 0.0f;
|
||||
m_launchMarkerCount = 0;
|
||||
|
|
@ -850,18 +852,27 @@ public:
|
|||
// Drive the character with pure velocity control: keep the solver's vertical velocity,
|
||||
// set the horizontal velocity. This is how the s&box player controller moves.
|
||||
b3Pos position = b3Body_GetPosition( m_characterId );
|
||||
if ( position.x > m_walkRange )
|
||||
if ( position.x > m_walkRangeX )
|
||||
{
|
||||
m_walkDirection = -1.0f;
|
||||
m_walkDirectionX = -1.0f;
|
||||
}
|
||||
else if ( position.x < -m_walkRange )
|
||||
else if ( position.x < -m_walkRangeX )
|
||||
{
|
||||
m_walkDirection = 1.0f;
|
||||
m_walkDirectionX = 1.0f;
|
||||
}
|
||||
|
||||
if ( position.z > m_walkRangeZ )
|
||||
{
|
||||
m_walkDirectionZ = -1.0f;
|
||||
}
|
||||
else if ( position.z < -m_walkRangeZ )
|
||||
{
|
||||
m_walkDirectionZ= 1.0f;
|
||||
}
|
||||
|
||||
b3Vec3 velocity = b3Body_GetLinearVelocity( m_characterId );
|
||||
velocity.x = m_walkDirection * m_walkSpeed;
|
||||
velocity.z = 0.0f;
|
||||
velocity.x = m_walkDirectionX * m_walkSpeedX;
|
||||
velocity.z = m_walkDirectionZ * m_walkSpeedZ;
|
||||
b3Body_SetLinearVelocity( m_characterId, velocity );
|
||||
|
||||
Sample::Step();
|
||||
|
|
@ -905,10 +916,16 @@ public:
|
|||
|
||||
bool DrawControls() override
|
||||
{
|
||||
float speedU = m_walkSpeed / SRC;
|
||||
if ( ImGui::SliderFloat( "Walk Speed (inch/s)", &speedU, 100.0f, 400.0f, "%.0f" ) )
|
||||
float speedUX = m_walkSpeedX / SRC;
|
||||
if ( ImGui::SliderFloat( "Walk Speed X (inch/s)", &speedUX, 100.0f, 400.0f, "%.0f" ) )
|
||||
{
|
||||
m_walkSpeed = speedU * SRC;
|
||||
m_walkSpeedX = speedUX * SRC;
|
||||
}
|
||||
|
||||
float speedUZ = m_walkSpeedZ / SRC;
|
||||
if ( ImGui::SliderFloat( "Walk Speed Z (inch/s)", &speedUZ, 10.0f, 100.0f, "%.0f" ) )
|
||||
{
|
||||
m_walkSpeedZ = speedUZ * SRC;
|
||||
}
|
||||
|
||||
if ( ImGui::Button( "Reset Counters" ) )
|
||||
|
|
@ -927,14 +944,17 @@ public:
|
|||
return new SBoxGhostCollisions( context );
|
||||
}
|
||||
|
||||
static constexpr float m_walkRange = 3.5f; // turn around beyond +/- this x (meters)
|
||||
static constexpr float m_walkRangeX = 3.5f; // turn around beyond +/- this x (meters)
|
||||
static constexpr float m_walkRangeZ = 0.5f; // turn around beyond +/- this x (meters)
|
||||
static constexpr float m_launchThreshold = 0.5f; // upward m/s counted as a ghost launch (~20 inch/s)
|
||||
static constexpr int m_markerCapacity = 64;
|
||||
|
||||
b3MeshData* m_chunkMesh[2] = {};
|
||||
b3BodyId m_characterId;
|
||||
float m_walkDirection;
|
||||
float m_walkSpeed;
|
||||
float m_walkDirectionX;
|
||||
float m_walkDirectionZ;
|
||||
float m_walkSpeedX;
|
||||
float m_walkSpeedZ;
|
||||
int m_launchCount;
|
||||
float m_maxLaunchSpeed;
|
||||
bool m_wasLaunched;
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ public:
|
|||
DrawPoint( point, 10.0f, MakeColor( b3_colorYellow ) );
|
||||
}
|
||||
|
||||
DrawString3D( point, MakeColor( b3_colorWhite ), " %.2f", 100.0f * manifoldPoint.separation );
|
||||
DrawString3D( point, MakeColor( b3_colorWhite ), " %.2f", 100.0f * manifoldPoint.separation );
|
||||
|
||||
b3FeaturePair pair = manifoldPoint.pair;
|
||||
DrawString3D( point + 0.025f * normal, MakeColor( b3_colorPapayaWhip ), " %X:%X %X:%X", pair.owner1, pair.index1,
|
||||
|
|
@ -572,7 +572,7 @@ public:
|
|||
m_camera->SetView( 0.0f, 30.0f, 5.0f, b3Pos_zero );
|
||||
}
|
||||
|
||||
m_capsule = { { -1.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f }, 0.5f };
|
||||
m_capsule = { { -1.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f }, 0.15f };
|
||||
m_hull = b3MakeBoxHull( 1.0f, 0.5f, 0.5f );
|
||||
|
||||
m_transformA = { { 0.0f, 0.0f, 0.0f }, b3Quat_identity };
|
||||
|
|
@ -636,17 +636,13 @@ public:
|
|||
m_camera->SetView( 0.0f, 30.0f, 10.0f, b3Pos_zero );
|
||||
}
|
||||
|
||||
m_capsule = { { 0.0f, -0.2f, 0.0f }, { 0.0f, 0.2f, 0.0f }, 0.05f };
|
||||
m_capsule = { { -0.5f, 0.0f, 0.0f }, { 0.5f, 0.0f, 0.0f }, 0.05f };
|
||||
m_triangle[0] = { -4.0f, 0.0f, -4.0f };
|
||||
m_triangle[1] = { -4.0f, 0.0f, 0.0f };
|
||||
m_triangle[2] = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
m_transformA = b3WorldTransform_identity;
|
||||
m_transformB = { { 0.0f, 0.5f, 0.0f }, b3Quat_identity };
|
||||
m_transformB.q = b3MakeQuatFromAxisAngle( { 0.0f, 0.0f, 1.0f }, 0.5f * B3_PI );
|
||||
|
||||
m_transformB = { { -0.500000000, 0.123778239, -0.500000000 },
|
||||
{ { -0.157559350, 0.294042289, 0.821513653 }, -0.462417006 } };
|
||||
m_transformB = { { -1.0f, 0.0f, -1.0f }, b3Quat_identity };
|
||||
}
|
||||
|
||||
void Render() override
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc --input shapes/capsule.glsl --output generated/capsule.glsl.h --slang hlsl5:metal_macos:glsl430
|
||||
sokol-shdc --input E:/box/box3d/samples/shaders/shapes/capsule.glsl --output E:/box/box3d/samples/shaders/generated/capsule.glsl.h --slang hlsl5:metal_macos:glsl430
|
||||
|
||||
Overview:
|
||||
=========
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc --input shapes/cube.glsl --output generated/cube.glsl.h --slang hlsl5:metal_macos:glsl430
|
||||
sokol-shdc --input E:/box/box3d/samples/shaders/shapes/cube.glsl --output E:/box/box3d/samples/shaders/generated/cube.glsl.h --slang hlsl5:metal_macos:glsl430
|
||||
|
||||
Overview:
|
||||
=========
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc --input shapes/geom.glsl --output generated/geom.glsl.h --slang hlsl5:metal_macos:glsl430
|
||||
sokol-shdc --input E:/box/box3d/samples/shaders/shapes/geom.glsl --output E:/box/box3d/samples/shaders/generated/geom.glsl.h --slang hlsl5:metal_macos:glsl430
|
||||
|
||||
Overview:
|
||||
=========
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||
|
||||
Cmdline:
|
||||
sokol-shdc --input shapes/sphere.glsl --output generated/sphere.glsl.h --slang hlsl5:metal_macos:glsl430
|
||||
sokol-shdc --input E:/box/box3d/samples/shaders/shapes/sphere.glsl --output E:/box/box3d/samples/shaders/generated/sphere.glsl.h --slang hlsl5:metal_macos:glsl430
|
||||
|
||||
Overview:
|
||||
=========
|
||||
|
|
|
|||
Loading…
Reference in a new issue