7 #include "imstkCamera.h" 8 #include "imstkCylinder.h" 9 #include "imstkDirectionalLight.h" 10 #include "imstkKeyboardDeviceClient.h" 11 #include "imstkKeyboardSceneControl.h" 12 #include "imstkLogger.h" 13 #include "imstkMeshIO.h" 14 #include "imstkMouseDeviceClient.h" 15 #include "imstkMouseSceneControl.h" 17 #include "imstkOrientedBox.h" 18 #include "imstkPlane.h" 19 #include "imstkRenderMaterial.h" 20 #include "imstkScene.h" 21 #include "imstkSceneManager.h" 22 #include "imstkSceneObject.h" 23 #include "imstkSimulationManager.h" 24 #include "imstkSimulationUtils.h" 25 #include "imstkSurfaceMesh.h" 26 #include "imstkVisualModel.h" 27 #include "imstkVTKViewer.h" 29 using namespace imstk;
44 auto sceneObj = std::make_shared<SceneObject>(
"Dragon");
46 scene->addSceneObject(sceneObj);
48 auto surfaceMesh = sceneObj->getVisualGeometry();
49 surfaceMesh->
scale(5.0, Geometry::TransformType::ConcatenateToTransform);
53 planeGeom->
scale(80.0, Geometry::TransformType::ConcatenateToTransform);
54 planeGeom->
translate(0.0, -20.0, 0.0, Geometry::TransformType::ConcatenateToTransform);
55 planeGeom->
rotate(Vec3d(0.0, 1.0, 0.0), PI_4, Geometry::TransformType::ConcatenateToTransform);
58 planeMaterial->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface);
59 planeMaterial->setPointSize(6.0);
60 planeMaterial->setLineWidth(4.0);
62 planeVisualModel->setGeometry(planeGeom);
66 planeObj->addVisualModel(planeVisualModel);
67 scene->addSceneObject(planeObj);
72 cubeGeom->
scale(0.5, Geometry::TransformType::ConcatenateToTransform);
73 cubeGeom->
rotate(Vec3d(1.0, 1.0, 0.0), PI_4, Geometry::TransformType::ApplyToData);
74 cubeGeom->
translate(Vec3d(0.0, 0.0, 10.0));
76 auto materialCube = std::make_shared<RenderMaterial>();
78 redMaterial->setColor(Color::Red);
79 redMaterial->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface);
80 redMaterial->setPointSize(6.0);
81 redMaterial->setLineWidth(4.0);
83 cubeVisualModel->setGeometry(cubeGeom);
87 cubeObj->addVisualModel(cubeVisualModel);
88 scene->addSceneObject(cubeObj);
92 cylinderGeom->setRadius(4.0);
93 cylinderGeom->setLength(12.0);
94 cylinderGeom->
scale(0.4, Geometry::TransformType::ConcatenateToTransform);
95 cylinderGeom->
rotate(Vec3d(1.0, 1.0, 0), PI_2, Geometry::TransformType::ApplyToData);
96 cylinderGeom->
translate(Vec3d(0.0, 0.0, -10.0));
99 cylVisualModel->setGeometry(cylinderGeom);
103 cylObj->addVisualModel(cylVisualModel);
104 scene->addSceneObject(cylObj);
107 scene->getActiveCamera()->setPosition(Vec3d(0.0, 30.0, 30.0));
113 scene->addLight(
"light", light);
130 connect<Event>(sceneManager, &SceneManager::postUpdate,
133 surfaceMesh->rotate(Vec3d(1.0, 0.0, 0.0), PI * sceneManager->getDt());
134 surfaceMesh->postModified();
138 std::shared_ptr<Entity> mouseAndKeyControls =
139 SimulationUtils::createDefaultSceneControl(driver);
140 scene->addSceneObject(mouseAndKeyControls);
void setActiveScene(std::shared_ptr< Scene > scene) override
Set scene to be rendered.
Base class for events which contain a type, priority, and data priority defaults to 0 and uses a grea...
void rotate(const Quatd &q, TransformType type=TransformType::ConcatenateToTransform)
Rotate the geometry in Cartesian space.
void setExtents(const Vec3d extents)
Sets the extents of the cube (half dimensions)
void addModule(std::shared_ptr< Module > module) override
Add a module to run.
void setIntensity(const double intensity)
Set the light intensity. This value is unbounded.
void scale(const Vec3d &scaling, TransformType type=TransformType::ConcatenateToTransform)
Scale in Cartesian directions.
std::shared_ptr<T> obj = std::make_shared<T>(); equivalent, convenience class for STL shared allocati...
Represents a set of triangles & vertices via an array of Vec3d double vertices & Vec3i integer indice...
void setRenderMaterial(std::shared_ptr< RenderMaterial > renderMaterial)
Set/Get render material.
void setDirection(const Vec3d &dir)
Set the direction of the light.
static std::shared_ptr< PointSet > read(const std::string &filePath)
Read external file.
void translate(const Vec3d &t, TransformType type=TransformType::ConcatenateToTransform)
Translate the geometry in Cartesian space.
void setActiveScene(std::string newSceneName)
Sets the currently updating scene.
static LoggerG3 & startLogger()
Starts logger with default sinks, use getInstance to create a logger with no sinks.