Render #207
Replies: 3 comments
-
You need to do a surface reconstruction of the water phase to get a triangle mesh which represents the surface of the fluid. My PhD student has an open-source project for surface recontruction which could be used: https://github.com/w1th0utnam3/splashsurf And then you can import the resulting mesh in Blender to get such renderings. |
Beta Was this translation helpful? Give feedback.
-
Thanks for answering. Can I ask you one more question? How can I change "density" of rigid body while scene is working. Like in you're video (https://www.youtube.com/watch?v=P82qmTAahg0): In the SceneLoader.cpp file "density" is not reading and I cannot understand how to change it in the program. Part of the SceneLoader.cpp file: //////////////////////////////////////////////////////////////////////////
// read boundary models
//////////////////////////////////////////////////////////////////////////
if (m_jsonData.find("RigidBodies") != m_jsonData.end())
{
nlohmann::json boundaryModels = m_jsonData["RigidBodies"];
for (auto& boundaryModel : boundaryModels)
{
std::string particleFile = "";
std::string meshFile = "";
std::string mapFile = "";
const bool bMesh = readValue<std::string>(boundaryModel["geometryFile"], meshFile);
const bool bSamples = readValue<std::string>(boundaryModel["particleFile"], particleFile);
const bool bMap = readValue<std::string>(boundaryModel["mapFile"], mapFile);
if (bMesh || bSamples)
{
BoundaryData *data = new BoundaryData();
data->meshFile = meshFile;
data->samplesFile = particleFile;
data->mapFile = mapFile;
// translation
data->translation = Vector3r::Zero();
readVector(boundaryModel["translation"], data->translation);
// rotation axis
Vector3r axis = Vector3r::Zero();
Real angle = 0.0;
data->rotation = Matrix3r::Identity();
if (readVector(boundaryModel["rotationAxis"], axis) &&
readValue<Real>(boundaryModel["rotationAngle"], angle))
data->rotation = AngleAxisr(angle, axis);
// scale
data->scale = Vector3r::Ones();
readVector(boundaryModel["scale"], data->scale);
data->dynamic = false;
readValue<bool>(boundaryModel["isDynamic"], data->dynamic);
data->isWall = false;
readValue<bool>(boundaryModel["isWall"], data->isWall);
data->color = Eigen::Vector4f(1.0f, 0.0f, 0.0f, 0.0f);
readVector(boundaryModel["color"], data->color);
data->samplingMode = 0;
readValue<unsigned int>(boundaryModel["samplingMode"], data->samplingMode);
data->isAnimated = false;
readValue<bool>(boundaryModel["isAnimated"], data->isAnimated);
// Maps
data->mapInvert = false;
readValue(boundaryModel["mapInvert"], data->mapInvert);
data->mapThickness = 0.0;
readValue(boundaryModel["mapThickness"], data->mapThickness);
data->mapResolution = Eigen::Matrix<unsigned int, 3, 1>(20, 20, 20);
readVector(boundaryModel["mapResolution"], data->mapResolution);
scene.boundaryModels.push_back(data);
}
}
} I used to try this code in the Simulator_GUI_imgui.cpp: MiniGL::addKeyFunc('q', myOunFunc);
void myOunFunc() {
const Utilities::SceneLoader::Scene& scene = SceneConfiguration::getCurrent()->getScene();
//sdsad.density;
for (const auto& i : scene.boundaryModels)
{
//i->scale[0] *= 3;
//std::cout << i->scale[0] << std::endl;
//i->isWall = false;
//std::cout << i->isWall << std::endl;
i->density = 400;
std::cout << i->density << std::endl;
}
} |
Beta Was this translation helpful? Give feedback.
-
SPlisHSPlasH uses our project PositionBasedDynamics for simulating the rigid bodies. After the SceneLoader of SPlisHSPlasH read the file, the SceneLoader of PositionBasedDynamics will also read it. Here the field "density" is imported. So in the scene file you can write:
Then the density of the rigid body is set to 200 and the body will swim on top of a water phase with density 1000. To change the density during runtim, there is no function. However, this should be pretty simple to implement. I think the function should look like this (not tested):
Probably you have to wrap the functions setMass, setInertiaTensor and updateInverseInertiaW in the class PBDRigidBody. Just analogously to the other functions in the class (e.g. getMass). Hope that helps. |
Beta Was this translation helpful? Give feedback.
-
I know how to render scene like this using https://github.com/InteractiveComputerGraphics/BlenderPartioTools:
But how can I render scene with realistic water?:
Beta Was this translation helpful? Give feedback.
All reactions