This commit is contained in:
turanszkij
2018-09-23 20:43:36 +01:00
parent c9767425be
commit 30e71881ff
4 changed files with 38 additions and 4 deletions
+29 -1
View File
@@ -16,7 +16,7 @@ MeshWindow::MeshWindow(wiGUI* gui) : GUI(gui)
meshWindow = new wiWindow(GUI, "Mesh Window");
meshWindow->SetSize(XMFLOAT2(800, 600));
meshWindow->SetSize(XMFLOAT2(800, 640));
meshWindow->SetEnabled(false);
GUI->AddWidget(meshWindow);
@@ -43,6 +43,34 @@ MeshWindow::MeshWindow(wiGUI* gui) : GUI(gui)
});
meshWindow->AddWidget(doubleSidedCheckBox);
softbodyCheckBox = new wiCheckBox("Soft body: ");
softbodyCheckBox->SetTooltip("Enable soft body simulation.");
softbodyCheckBox->SetPos(XMFLOAT2(x, y += step));
softbodyCheckBox->OnClick([&](wiEventArgs args) {
Scene& scene = wiRenderer::GetScene();
SoftBodyPhysicsComponent* physicscomponent = scene.softbodies.GetComponent(entity);
if (args.bValue)
{
if (physicscomponent == nullptr)
{
SoftBodyPhysicsComponent& softbody = scene.softbodies.Create(entity);
softbody.friction = frictionSlider->GetValue();
softbody.mass = massSlider->GetValue();
}
}
else
{
if (physicscomponent != nullptr)
{
scene.softbodies.Remove(entity);
}
}
});
meshWindow->AddWidget(softbodyCheckBox);
massSlider = new wiSlider(0, 5000, 0, 100000, "Mass: ");
massSlider->SetTooltip("Set the mass amount for the physics engine.");
massSlider->SetSize(XMFLOAT2(100, 30));
+1
View File
@@ -21,6 +21,7 @@ public:
wiWindow* meshWindow;
wiLabel* meshInfoLabel;
wiCheckBox* doubleSidedCheckBox;
wiCheckBox* softbodyCheckBox;
wiSlider* massSlider;
wiSlider* frictionSlider;
wiButton* impostorCreateButton;
+1 -3
View File
@@ -121,9 +121,7 @@ void ImportModel_OBJ(const std::string& fileName)
for (auto& index : reordered_indices)
{
XMFLOAT3 pos;
pos = XMFLOAT3(
XMFLOAT3 pos = XMFLOAT3(
obj_attrib.vertices[index.vertex_index * 3 + 0],
obj_attrib.vertices[index.vertex_index * 3 + 1],
obj_attrib.vertices[index.vertex_index * 3 + 2]
+7
View File
@@ -440,6 +440,13 @@ namespace wiPhysics
}
assert(id >= 0 && id <= dynamicsWorld->getCollisionObjectArray().size());
btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[id];
btSoftBody* body = btSoftBody::upcast(obj);
if (body != nullptr)
{
body->setWindVelocity(wind);
}
}
// Tidy: