diff --git a/Examples/CollisionDetection/ManualCDWithOctree/ManualCDWithOctreeExample.cpp b/Examples/CollisionDetection/ManualCDWithOctree/ManualCDWithOctreeExample.cpp index ffc5d0842bf94da3402aaa14d9e1bdbb3db1e77c..1e27dfc2ebb6bd7d121e98654ef881a67b4a8b28 100644 --- a/Examples/CollisionDetection/ManualCDWithOctree/ManualCDWithOctreeExample.cpp +++ b/Examples/CollisionDetection/ManualCDWithOctree/ManualCDWithOctreeExample.cpp @@ -80,7 +80,7 @@ createMeshObject(const std::shared_ptr<imstk::Scene>& scene, // Create a visiual model auto visualModel = std::make_shared<VisualModel>(meshObj); auto material = std::make_shared<RenderMaterial>(); - material->setDebugColor(color); // Wireframe color + material->setEdgeColor(color); // Wireframe color material->setLineWidth(2); if (meshObj->getNumTriangles() > 100) { @@ -111,7 +111,7 @@ addPointsDebugRendering(const std::shared_ptr<Scene>& scene) auto debugPoints = std::make_shared<DebugRenderPoints>("Debug Points"); auto material = std::make_shared<RenderMaterial>(); material->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface); - material->setDebugColor(Color::Yellow); + material->setVertexColor(Color::Yellow); material->setPointSize(8.); auto dbgViz = std::make_shared<VisualModel>(debugPoints, material); @@ -129,7 +129,7 @@ addVTConnectingLinesDebugRendering(const std::shared_ptr<Scene>& scene) auto debugLines = std::make_shared<DebugRenderLines>("Debug Connecting VT Lines"); auto material = std::make_shared<RenderMaterial>(); material->setBackFaceCulling(false); - material->setDebugColor(Color::Green); + material->setEdgeColor(Color::Green); material->setLineWidth(4.0); auto dbgViz = std::make_shared<VisualModel>(debugLines, material); @@ -147,7 +147,7 @@ addEEConnectingLinesDebugRendering(const std::shared_ptr<Scene>& scene) auto debugLines = std::make_shared<DebugRenderLines>("Debug Connecting EE Lines"); auto material = std::make_shared<RenderMaterial>(); material->setBackFaceCulling(false); - material->setDebugColor(Color::Red); + material->setEdgeColor(Color::Red); material->setLineWidth(4.0); auto dbgViz = std::make_shared<VisualModel>(debugLines, material); @@ -165,7 +165,7 @@ addHighlightedLinesDebugRendering(const std::shared_ptr<Scene>& scene) auto debugLines = std::make_shared<DebugRenderLines>("Debug Highlighted Lines"); auto material = std::make_shared<RenderMaterial>(); material->setBackFaceCulling(false); - material->setDebugColor(Color::Orange); + material->setEdgeColor(Color::Orange); material->setLineWidth(8.0); auto dbgViz = std::make_shared<VisualModel>(debugLines, material); @@ -280,7 +280,7 @@ main() const auto matDbgViz = std::make_shared<RenderMaterial>(); matDbgViz->setDisplayMode(RenderMaterial::DisplayMode::Wireframe); - matDbgViz->setDebugColor(Color::Green); + matDbgViz->setEdgeColor(Color::Green); matDbgViz->setLineWidth(1.0); auto octreeVizDbgModel = std::make_shared<VisualModel>(debugOctree, matDbgViz); scene->addDebugVisualModel(octreeVizDbgModel); diff --git a/Examples/DebugRendering/DebugRenderingExample.cpp b/Examples/DebugRendering/DebugRenderingExample.cpp index fa36764c3ae1f19ccdac4a000a4ce4d588aae98c..db5a9b8531f971f55b4dbda584bda7e06fde3d7f 100644 --- a/Examples/DebugRendering/DebugRenderingExample.cpp +++ b/Examples/DebugRendering/DebugRenderingExample.cpp @@ -42,7 +42,8 @@ addPointsDebugRendering(const std::shared_ptr<Scene>& scene) { auto debugPoints = std::make_shared<DebugRenderPoints>("Debug Points"); auto material = std::make_shared<RenderMaterial>(); - material->setDebugColor(Color::Blue); + material->setDisplayMode(RenderMaterial::DisplayMode::Points); + material->setPointSize(6.); auto vizModel = std::make_shared<VisualModel>(debugPoints, material); scene->addDebugVisualModel(vizModel); @@ -54,9 +55,10 @@ addLinesDebugRendering(const std::shared_ptr<Scene>& scene) { auto debugLines = std::make_shared<DebugRenderLines>("Debug Lines"); auto material = std::make_shared<RenderMaterial>(); - material->setBackFaceCulling(false); - material->setDebugColor(Color::Green); - material->setLineWidth(2.0); + material->setDisplayMode(RenderMaterial::DisplayMode::Wireframe); + //material->setBackFaceCulling(false); + material->setEdgeColor(Color::Green); + material->setLineWidth(4.0); auto vizModel = std::make_shared<VisualModel>(debugLines, material); scene->addDebugVisualModel(vizModel); @@ -68,10 +70,11 @@ addTrianglesDebugRendering(const std::shared_ptr<Scene>& scene) { auto debugTriangles = std::make_shared<DebugRenderTriangles>("Debug Triangles"); auto material = std::make_shared<RenderMaterial>(); - material->setBackFaceCulling(false); - material->setDebugColor(Color::Red); material->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface); + material->setBackFaceCulling(false); + material->setColor(Color::Red); auto vizModel = std::make_shared<VisualModel>(debugTriangles, material); + scene->addDebugVisualModel(vizModel); return debugTriangles; } diff --git a/Examples/DeformableBody/DeformableBodyExample.cpp b/Examples/DeformableBody/DeformableBodyExample.cpp index 4daad033968e520fb040ef611a9bbce31c92a372..3093eee8e20e670afea6d73b4e375470f0fe595c 100644 --- a/Examples/DeformableBody/DeformableBodyExample.cpp +++ b/Examples/DeformableBody/DeformableBodyExample.cpp @@ -90,8 +90,9 @@ main() dynaModel->setTimeIntegrator(timeIntegrator); auto material = std::make_shared<RenderMaterial>(); - material->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface); + material->setDisplayMode(RenderMaterial::DisplayMode::Wireframe); material->setPointSize(6.); + material->setEdgeColor(Color::LightGray); material->setLineWidth(4.); auto surfMeshModel = std::make_shared<VisualModel>(surfMesh); surfMeshModel->setRenderMaterial(material); diff --git a/Examples/Octree/OctreeExample.cpp b/Examples/Octree/OctreeExample.cpp index 9ff62067da2278f00b9ce22949782ade897de520..bcd1e62d2668f43c8f53cd34b19b43e3d3051a86 100644 --- a/Examples/Octree/OctreeExample.cpp +++ b/Examples/Octree/OctreeExample.cpp @@ -54,7 +54,7 @@ static std::pair<StdVectorOfVec3d, std::vector<std::array<size_t, 3>>> g_BunnyDa std::shared_ptr<VisualObject> createMeshObject(const std::shared_ptr<imstk::Scene>& scene, const std::string& objectName, - Color color) + const Color& color) { // Create a surface mesh for the bunny auto meshObj = std::make_shared<SurfaceMesh>(); @@ -63,9 +63,9 @@ createMeshObject(const std::shared_ptr<imstk::Scene>& scene, // Create a visiual model auto visualModel = std::make_shared<VisualModel>(meshObj); auto material = std::make_shared<RenderMaterial>(); + material->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface); material->setColor(color); // Wireframe color material->setLineWidth(1); - material->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface); visualModel->setRenderMaterial(material); auto visualObject = std::make_shared<VisualObject>(objectName); @@ -168,7 +168,7 @@ main() const auto matDbgViz = std::make_shared<RenderMaterial>(); matDbgViz->setDisplayMode(RenderMaterial::DisplayMode::Wireframe); - matDbgViz->setDebugColor(Color::Green); + matDbgViz->setEdgeColor(Color::Green); matDbgViz->setLineWidth(1.0); auto octreeVizDbgModel = std::make_shared<VisualModel>(debugOctree, matDbgViz); scene->addDebugVisualModel(octreeVizDbgModel); diff --git a/Examples/PBD/PBDCloth/pbdClothExample.cpp b/Examples/PBD/PBDCloth/pbdClothExample.cpp index baef1bba4f7f9ab3598ffef60475e7101065e54b..b1f99326c073190d53920319e6c88bbed074af63 100644 --- a/Examples/PBD/PBDCloth/pbdClothExample.cpp +++ b/Examples/PBD/PBDCloth/pbdClothExample.cpp @@ -122,11 +122,9 @@ main() auto material = std::make_shared<RenderMaterial>(); material->setBackFaceCulling(false); - material->setColor(Color::DarkGray); material->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface); material->setPointSize(6.); material->setLineWidth(4.); - material->setEdgeColor(Color::Color::Orange); auto surfMeshModel = std::make_shared<VisualModel>(surfMesh); surfMeshModel->setRenderMaterial(material); deformableObj->addVisualModel(surfMeshModel); @@ -134,7 +132,7 @@ main() // Light (white) auto whiteLight = std::make_shared<DirectionalLight>("whiteLight"); whiteLight->setFocalPoint(Vec3d(5, -8, -5)); - whiteLight->setIntensity(7); + whiteLight->setIntensity(1.); // Light (red) auto colorLight = std::make_shared<SpotLight>("colorLight"); diff --git a/Examples/Rendering/RenderingExample.cpp b/Examples/Rendering/RenderingExample.cpp index d784bcd0472e427afe53419e8f8285b15a410a46..ea8f289069d436a7b4e263cd4baa54072c838605 100644 --- a/Examples/Rendering/RenderingExample.cpp +++ b/Examples/Rendering/RenderingExample.cpp @@ -25,6 +25,7 @@ #include "imstkCollisionGraph.h" #include "imstkIBLProbe.h" #include "imstkCamera.h" +#include "imstkMeshIO.h" #include "imstkLight.h" #include "imstkScene.h" @@ -54,15 +55,27 @@ main() "head", iMSTK_DATA_ROOT "/head/head_revised.obj", iMSTK_DATA_ROOT "/head/", 1, Vec3d(0, 0, 0), "dds"); #else - auto headObject = VisualObjectImporter::importVisualObject( + /*auto headObject = VisualObjectImporter::importVisualObject( "head", iMSTK_DATA_ROOT "/head/head_revised.obj", - iMSTK_DATA_ROOT "/head/"); + iMSTK_DATA_ROOT "/head/");*/ - /*auto headObject = VisualObjectImporter::importVisualObject( - "head", - iMSTK_DATA_ROOT "/cloth/gauze21.obj", - iMSTK_DATA_ROOT "/cloth/");*/ + auto surfaceMesh = MeshIO::read(iMSTK_DATA_ROOT "/head/head_revised.obj"); + + auto material = std::make_shared<RenderMaterial>(); + material->setDisplayMode(RenderMaterial::DisplayMode::Surface); + material->setShadingModel(RenderMaterial::ShadingModel::PBR); + auto headDiffuseTexture = std::make_shared<Texture>(iMSTK_DATA_ROOT "head/HeadTexture_BaseColor.png", Texture::Type::Diffuse); + auto headNormalTexture = std::make_shared<Texture>(iMSTK_DATA_ROOT "head/HeadTexture_Normal.jpg", Texture::Type::Normal); + + /*material->addTexture(headDiffuseTexture); + material->addTexture(headNormalTexture);*/ + + auto surfMeshModel = std::make_shared<VisualModel>(surfaceMesh); + surfMeshModel->setRenderMaterial(material); + + auto headObject = std::make_shared<VisualObject>("head"); + headObject->addVisualModel(surfMeshModel); // Head material with textures /* auto headNormalTexture = std::make_shared<Texture>(iMSTK_DATA_ROOT "head/HeadTexture_Normal.jpg", Texture::Type::Normal); @@ -72,9 +85,7 @@ main() headMaterial->addTexture(headNormalTexture); headMaterial->addTexture(headDiffuseTexture);*/ - auto headDiffuseTexture = std::make_shared<Texture>(iMSTK_DATA_ROOT "cloth/gauze_diffuse.jpg", Texture::Type::Diffuse); - auto headMaterial = headObject->getVisualModel()->getRenderMaterial(); - headMaterial->setShadingModel(RenderMaterial::ShadingModel::PBR); + //headMaterial->addTexture(headDiffuseTexture); #endif @@ -93,10 +104,10 @@ main() directionalLight->setShadowRange(1.5); scene->addLight(directionalLight); - auto pointLight = std::make_shared<PointLight>("PointLight"); + /* auto pointLight = std::make_shared<PointLight>("PointLight"); pointLight->setIntensity(0.1); pointLight->setPosition(0.1, 0.2, 0.5); - scene->addLight(pointLight); + scene->addLight(pointLight);*/ // Sphere auto sphereObj = apiutils::createVisualAnalyticalSceneObject(Geometry::Type::Sphere, scene, "VisualSphere", 0.025); diff --git a/Source/Rendering/Materials/imstkRenderMaterial.cpp b/Source/Rendering/Materials/imstkRenderMaterial.cpp index 2983f5ed8594d9deed07d62797e38d181b676639..87afca98e3b0e5b94391bd6048553e3dac27806a 100644 --- a/Source/Rendering/Materials/imstkRenderMaterial.cpp +++ b/Source/Rendering/Materials/imstkRenderMaterial.cpp @@ -148,19 +148,6 @@ RenderMaterial::setColor(const Color& color) m_modified = true; } -const Color& -RenderMaterial::getDebugColor() const -{ - return m_debugColor; -} - -void -RenderMaterial::setDebugColor(const Color& color) -{ - m_debugColor = color; - m_modified = true; -} - const float& RenderMaterial::getMetalness() const { diff --git a/Source/Rendering/Materials/imstkRenderMaterial.h b/Source/Rendering/Materials/imstkRenderMaterial.h index 9785f806a8afbcd856df408c271121ca80ae7164..717e919d1cc55de6ac3024a38f956d733c89ba26 100644 --- a/Source/Rendering/Materials/imstkRenderMaterial.h +++ b/Source/Rendering/Materials/imstkRenderMaterial.h @@ -220,7 +220,6 @@ protected: ///-------------------Common properties--------------------- Color m_color = Color::LightGray; - Color m_debugColor = Color::Black;// remove? float m_opacity = 1.0; diff --git a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKFluidRenderDelegate.cpp b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKFluidRenderDelegate.cpp index d501608831d7e501e413a1e0e16eef232068c8fc..f5f1d96ff6a96b183ca549479252555b2bff4889 100644 --- a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKFluidRenderDelegate.cpp +++ b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKFluidRenderDelegate.cpp @@ -64,7 +64,7 @@ m_mappedVertexArray(vtkSmartPointer<vtkDoubleArray>::New()) fluidMapper->SetParticleRadius(0.03f * 6.0f); fluidMapper->SetSurfaceFilterIterations(3); fluidMapper->SetSurfaceFilterRadius(5); - fluidMapper->SetSurfaceFilterMethod(vtkOpenGLFluidMapper::FluidSurfaceFilterMethod::BilateralGaussian); + fluidMapper->SetSurfaceFilterMethod(vtkOpenGLFluidMapper::FluidSurfaceFilterMethod::NarrowRange); fluidMapper->SetDisplayMode(vtkOpenGLFluidMapper::FluidDisplayMode::TransparentFluidVolume); fluidMapper->SetAttenuationColor(0.8f, 0.2f, 0.15f); fluidMapper->SetAttenuationScale(1.0f); diff --git a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKRenderDelegate.cpp b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKRenderDelegate.cpp index 4532c69facc5c3e62479c9ffb8f160e4990847bc..5aeeefea1049e8d550f4e27384933506efd56031 100644 --- a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKRenderDelegate.cpp +++ b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKRenderDelegate.cpp @@ -388,7 +388,6 @@ VTKRenderDelegate::updateActorPropertiesMesh() break; case RenderMaterial::DisplayMode::Points: actorProperty->SetRepresentationToPoints(); - actorProperty->SetColor(vertexColor.r, vertexColor.g, vertexColor.b); break; default: actorProperty->SetRepresentationToSurface();//wireframeSurface @@ -400,18 +399,22 @@ VTKRenderDelegate::updateActorPropertiesMesh() actorProperty->SetRenderPointsAsSpheres(true); actorProperty->SetVertexVisibility(true); actorProperty->SetVertexColor(vertexColor.r, vertexColor.g, vertexColor.b); + + if (material->getDisplayMode() != RenderMaterial::DisplayMode::Points) { // enable edge visibility and set edge properties actorProperty->SetEdgeVisibility(true); - actorProperty->SetEdgeColor(edgeColor.r, edgeColor.g, edgeColor.b); - actorProperty->SetLineWidth(material->getLineWidth()); actorProperty->SetRenderLinesAsTubes(true); + //actorProperty->SetEdgeColor(edgeColor.r, edgeColor.g, edgeColor.b); // doesn't work if edges are rendered as tubes + actorProperty->SetLineWidth(material->getLineWidth()); } if (material->getDisplayMode() == RenderMaterial::DisplayMode::WireframeSurface) { + actorProperty->SetEdgeColor(edgeColor.r, edgeColor.g, edgeColor.b); + actorProperty->SetColor(surfaceColor.r, surfaceColor.g, surfaceColor.b); switch (material->getShadingModel()) { case RenderMaterial::ShadingModel::Flat: @@ -424,6 +427,16 @@ VTKRenderDelegate::updateActorPropertiesMesh() actorProperty->SetInterpolationToPhong(); } } + + if (material->getDisplayMode() == RenderMaterial::DisplayMode::Points) + { + actorProperty->SetColor(vertexColor.r, vertexColor.g, vertexColor.b); + } + + if (material->getDisplayMode() == RenderMaterial::DisplayMode::Wireframe) + { + actorProperty->SetColor(edgeColor.r, edgeColor.g, edgeColor.b); + } } else // surface diff --git a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugLinesRenderDelegate.cpp b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugLinesRenderDelegate.cpp index 96c9945a6183c298723f186a7236af48306e48d7..56c2f3206eb07982b147f8ba464fc91cede4f589 100644 --- a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugLinesRenderDelegate.cpp +++ b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugLinesRenderDelegate.cpp @@ -67,7 +67,7 @@ VTKdbgLinesRenderDelegate::VTKdbgLinesRenderDelegate(std::shared_ptr<VisualModel updateActorProperties(); setUpMapper(source->GetOutputPort(), visualModel); - //updateDataSource(); + updateDataSource(); } void diff --git a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugTrianglesRenderDelegate.cpp b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugTrianglesRenderDelegate.cpp index f7c39c11d86e2e144ccacfb21f976e2a38cf7ed7..144aba82292715187138a139c2b4964130e20d85 100644 --- a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugTrianglesRenderDelegate.cpp +++ b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugTrianglesRenderDelegate.cpp @@ -57,8 +57,8 @@ VTKdbgTrianglesRenderDelegate::VTKdbgTrianglesRenderDelegate(std::shared_ptr<Vis source->SetOutput(m_polyData); // Update Transform, Render Properties - //updateDataSource(); - //updateActorProperties(); + updateDataSource(); + updateActorProperties(); setUpMapper(source->GetOutputPort(), visualModel); }