updates
This commit is contained in:
+29
-1
@@ -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));
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
wiWindow* meshWindow;
|
||||
wiLabel* meshInfoLabel;
|
||||
wiCheckBox* doubleSidedCheckBox;
|
||||
wiCheckBox* softbodyCheckBox;
|
||||
wiSlider* massSlider;
|
||||
wiSlider* frictionSlider;
|
||||
wiButton* impostorCreateButton;
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user