diff --git a/examples/AlphaMap/AlphaMappingExample.cpp b/examples/AlphaMap/AlphaMappingExample.cpp index fb60013021114919937e69539d18c502749e698f..898390782b622fb4877ddcd3fd246b319afd701d 100644 --- a/examples/AlphaMap/AlphaMappingExample.cpp +++ b/examples/AlphaMap/AlphaMappingExample.cpp @@ -65,18 +65,18 @@ AlphaMapExample::AlphaMapExample() - smTextureManager::init(SDK::getErrorLog()); - smTextureManager::loadTexture("../../resources/textures/4351-diffuse.jpg", "groundImage"); - smTextureManager::loadTexture("../../resources/textures/4351-normal.jpg", "groundBumpImage"); - smTextureManager::loadTexture("../../resources/textures/brick.jpg", "wallImage"); - smTextureManager::loadTexture("../../resources/textures/brick-normal.jpg", "wallBumpImage"); - smTextureManager::loadTexture("../../resources/textures/Tissue.jpg", "diffuse"); - smTextureManager::loadTexture("../../resources/textures/Tissue_Alpha.jpg", "alpha"); - smTextureManager::loadTexture("../../resources/textures/Tissue_NORM.jpg", "norm"); - smTextureManager::loadTexture("../../resources/textures/Tissue_SPEC.jpg", "spec"); - smTextureManager::loadTexture("../../resources/textures/band.bmp", "noOCC"); - - object1->mesh->loadMeshLegacy("../../resources/models/gall_tissue.3DS", SM_FILETYPE_3DS); + TextureManager::init(SDK::getErrorLog()); + TextureManager::loadTexture("../../resources/textures/4351-diffuse.jpg", "groundImage"); + TextureManager::loadTexture("../../resources/textures/4351-normal.jpg", "groundBumpImage"); + TextureManager::loadTexture("../../resources/textures/brick.jpg", "wallImage"); + TextureManager::loadTexture("../../resources/textures/brick-normal.jpg", "wallBumpImage"); + TextureManager::loadTexture("../../resources/textures/Tissue.jpg", "diffuse"); + TextureManager::loadTexture("../../resources/textures/Tissue_Alpha.jpg", "alpha"); + TextureManager::loadTexture("../../resources/textures/Tissue_NORM.jpg", "norm"); + TextureManager::loadTexture("../../resources/textures/Tissue_SPEC.jpg", "spec"); + TextureManager::loadTexture("../../resources/textures/band.bmp", "noOCC"); + + object1->mesh->loadMeshLegacy("../../resources/models/gall_tissue.3DS", BaseMesh::MeshFileType::ThreeDS); metalShader->attachTexture(object1->mesh->getUniqueId(), "norm", "BumpTex"); metalShader->attachTexture(object1->mesh->getUniqueId(), "diffuse", "DecalTex"); diff --git a/examples/AlphaMap/AlphaMappingExample.h b/examples/AlphaMap/AlphaMappingExample.h index 488c2620173672f62abdaa878f457da97198c7ee..a1dbc6527dfd60bcbd619bc5f4fb6fb13d3eaf80 100644 --- a/examples/AlphaMap/AlphaMappingExample.h +++ b/examples/AlphaMap/AlphaMappingExample.h @@ -43,7 +43,7 @@ public: StaticSceneObject *object1; SDK* simmedtkSDK; Scene *scene1; - smViewer *viewer; + Viewer *viewer; PhantomInterface* hapticInterface; smHapticCameraTrans *motionTrans; diff --git a/examples/AudioExample/AudioExample.cpp b/examples/AudioExample/AudioExample.cpp index 87311edf51d37ae2fb8f1cc0557d2cc2d3a08878..0fe50450f358d0081d0fb27a9765241d16e759c9 100644 --- a/examples/AudioExample/AudioExample.cpp +++ b/examples/AudioExample/AudioExample.cpp @@ -43,37 +43,37 @@ void AudioKeyboardController::setSound(std::shared_ptr<Audio> a) sound = a; } -void AudioKeyboardController::handleEvent(std::shared_ptr<mstk::Event::Event> event) +void AudioKeyboardController::handleEvent(std::shared_ptr<core::Event> event) { assert(sound); - auto keyboardEvent = std::static_pointer_cast<mstk::Event::smKeyboardEvent>(event); + auto keyboardEvent = std::static_pointer_cast<event::KeyboardEvent>(event); if(keyboardEvent->getPressed()) { switch(keyboardEvent->getKeyPressed()) { - case mstk::Event::smKey::S: + case event::Key::S: sound->play(); break; - case mstk::Event::smKey::P: + case event::Key::P: sound->pause(); break; - case mstk::Event::smKey::H: + case event::Key::H: sound->stop(); break; - case mstk::Event::smKey::L: + case event::Key::L: loopSound = !loopSound; sound->setLoop(loopSound); break; - case mstk::Event::smKey::I: + case event::Key::I: if (1.0 > soundVolume) { soundVolume += 0.1; sound->setVolume(soundVolume); } break; - case mstk::Event::smKey::D: + case event::Key::D: if (0.0 <= soundVolume) { soundVolume -= 0.1; @@ -89,7 +89,7 @@ void AudioKeyboardController::handleEvent(std::shared_ptr<mstk::Event::Event> ev void runAudioExample() { std::shared_ptr<SDK> sdk; - std::shared_ptr<smViewer> viewer; + std::shared_ptr<Viewer> viewer; std::shared_ptr<Audio> sound; std::shared_ptr<AudioKeyboardController> audioCtl; @@ -97,7 +97,7 @@ void runAudioExample() sdk = SDK::getInstance(); //Create a viewer to see the scene through - viewer = std::make_shared<smViewer>(); + viewer = std::make_shared<Viewer>(); sdk->addViewer(viewer); //Create the audio controller @@ -118,7 +118,7 @@ void runAudioExample() //viewer->viewerRenderDetail |= SIMMEDTK_VIEWERRENDER_FULLSCREEN; //Link up the event system between this the audio controller and the viewer - viewer->attachEvent(mstk::Event::EventType::Keyboard, audioCtl); + viewer->attachEvent(core::EventType::Keyboard, audioCtl); sdk->run(); diff --git a/examples/AudioExample/AudioExample.h b/examples/AudioExample/AudioExample.h index 621c631fe32031cab170129c119f0503fd45ffa8..b8662c3fce50e66e156c241361ff49918d26168a 100644 --- a/examples/AudioExample/AudioExample.h +++ b/examples/AudioExample/AudioExample.h @@ -42,7 +42,7 @@ public: /// \brief Event handling function from CoreClass /// /// \param event Event to handle from the main event system - void handleEvent(std::shared_ptr<mstk::Event::Event> event) override; + void handleEvent(std::shared_ptr<core::Event> event) override; /// \brief Set the sound to be controlled /// @@ -50,9 +50,9 @@ public: void setSound(std::shared_ptr<Audio> a); private: - std::shared_ptr<Audio> sound; ///< Pointer to sound being controlled bool loopSound; ///< Flag to loop the sound or not float soundVolume; + std::shared_ptr<Audio> sound; ///< Pointer to sound being controlled }; void runAudioExample(); diff --git a/examples/CollisionDetectionBVH/CollisionDetectionBVH.cpp b/examples/CollisionDetectionBVH/CollisionDetectionBVH.cpp index 5642537e9f568eabc75dfb0436ba549ebd2d8db8..9110ef45cd8803581e808fc97b2659fddfbcec71 100644 --- a/examples/CollisionDetectionBVH/CollisionDetectionBVH.cpp +++ b/examples/CollisionDetectionBVH/CollisionDetectionBVH.cpp @@ -43,7 +43,7 @@ CollisionDetectionBVH::CollisionDetectionBVH() scene = sdk->createScene(); // Create viewer - viewer = std::make_shared<smViewer>(); + viewer = std::make_shared<Viewer>(); // Add our viewer to the SDK sdk->addViewer(viewer); @@ -57,18 +57,18 @@ CollisionDetectionBVH::CollisionDetectionBVH() sdk->registerObjectSim(defaultSimulator); // Init texture manager and specify the textures needed for the current application - smTextureManager::init(sdk->getErrorLog()); - smTextureManager::loadTexture("textures/fat9.bmp", "livertexture1"); - smTextureManager::loadTexture("textures/blood.jpg", "livertexture2"); + TextureManager::init(sdk->getErrorLog()); + TextureManager::loadTexture("textures/fat9.bmp", "livertexture1"); + TextureManager::loadTexture("textures/blood.jpg", "livertexture2"); - smTextureManager::loadTexture("textures/4351-diffuse.jpg", "groundImage"); - smTextureManager::loadTexture("textures/4351-normal.jpg", "groundBumpImage"); - smTextureManager::loadTexture("textures/brick.jpg", "wallImage"); - smTextureManager::loadTexture("textures/brick-normal.jpg", "wallBumpImage"); + TextureManager::loadTexture("textures/4351-diffuse.jpg", "groundImage"); + TextureManager::loadTexture("textures/4351-normal.jpg", "groundBumpImage"); + TextureManager::loadTexture("textures/brick.jpg", "wallImage"); + TextureManager::loadTexture("textures/brick-normal.jpg", "wallBumpImage"); // Create collision models std::shared_ptr<MeshCollisionModel> collisionModelA = std::make_shared<MeshCollisionModel>(); - collisionModelA->loadTriangleMesh("models/liverNormalized_SB2.3DS", SM_FILETYPE_3DS); + collisionModelA->loadTriangleMesh("models/liverNormalized_SB2.3DS", BaseMesh::MeshFileType::ThreeDS); collisionModelA->getMesh()->assignTexture("livertexture1"); collisionModelA->getMesh()->getRenderDetail()->renderType = (SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_WIREFRAME); collisionModelA->getMesh()->translate(7, 3, 0); @@ -76,7 +76,7 @@ CollisionDetectionBVH::CollisionDetectionBVH() collisionModelA->getMesh()->getRenderDetail()->pointSize = 5; std::shared_ptr<MeshCollisionModel> collisionModelB = std::make_shared<MeshCollisionModel>(); - collisionModelB->loadTriangleMesh("models/liverNormalized_SB2.3DS", SM_FILETYPE_3DS); + collisionModelB->loadTriangleMesh("models/liverNormalized_SB2.3DS", BaseMesh::MeshFileType::ThreeDS); collisionModelB->getMesh()->assignTexture("livertexture2"); collisionModelB->getMesh()->translate(core::Vec3d(2, 0, 0)); collisionModelB->getMesh()->assignTexture("livertexture2"); @@ -115,7 +115,7 @@ CollisionDetectionBVH::CollisionDetectionBVH() scene->addLight(light); // Camera setup - std::shared_ptr<smCamera> sceneCamera = smCamera::getDefaultCamera(); + std::shared_ptr<Camera> sceneCamera = Camera::getDefaultCamera(); assert(sceneCamera); scene->addCamera(sceneCamera); camCtl->setCamera(sceneCamera); @@ -134,8 +134,8 @@ CollisionDetectionBVH::CollisionDetectionBVH() viewer->addObject(collisionModelB->getAABBTree()); //Link up the event system between this the camera controller and the viewer - viewer->attachEvent(mstk::Event::EventType::Keyboard, camCtl); - viewer->attachEvent(mstk::Event::EventType::Keyboard, keyShutdown); + viewer->attachEvent(core::EventType::Keyboard, camCtl); + viewer->attachEvent(core::EventType::Keyboard, keyShutdown); } void CollisionDetectionBVH::simulateMain(const SimulationMainParam &/*p_param*/) diff --git a/examples/CollisionDetectionBVH/CollisionDetectionBVH.h b/examples/CollisionDetectionBVH/CollisionDetectionBVH.h index 4231c247d24be713fbfe39b191da658a8e7921fe..ff1993ca9c9e10cde6e867c639d8320830cd1c99 100644 --- a/examples/CollisionDetectionBVH/CollisionDetectionBVH.h +++ b/examples/CollisionDetectionBVH/CollisionDetectionBVH.h @@ -56,7 +56,7 @@ public: std::shared_ptr<StaticSceneObject> modelA; std::shared_ptr<StaticSceneObject> modelB; std::shared_ptr<Scene> scene; - std::shared_ptr<smViewer> viewer; + std::shared_ptr<Viewer> viewer; std::shared_ptr<smDummySimulator> defaultSimulator; std::shared_ptr<Simulator> simulator; std::shared_ptr<MeshToMeshCollision> collisionDetection; diff --git a/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.cpp b/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.cpp index 4e0f97665180b161afc45394f71094671eb39f0a..de10a8d7806261e395e2893fd180232e9f992e74 100644 --- a/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.cpp +++ b/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.cpp @@ -42,7 +42,7 @@ CollisionDetectionSpatialHashing::CollisionDetectionSpatialHashing() scene = sdk->createScene(); // Create viewer - viewer = std::make_shared<smViewer>(); + viewer = std::make_shared<Viewer>(); // Add our viewer to the SDK sdk->addViewer(viewer); @@ -59,18 +59,18 @@ CollisionDetectionSpatialHashing::CollisionDetectionSpatialHashing() sdk->registerObjectSim(defaultSimulator); // Init texture manager and specify the textures needed for the current application - smTextureManager::init(sdk->getErrorLog()); - smTextureManager::loadTexture("textures/fat9.bmp", "livertexture1"); - smTextureManager::loadTexture("textures/blood.jpg", "livertexture2"); + TextureManager::init(sdk->getErrorLog()); + TextureManager::loadTexture("textures/fat9.bmp", "livertexture1"); + TextureManager::loadTexture("textures/blood.jpg", "livertexture2"); - smTextureManager::loadTexture("textures/4351-diffuse.jpg", "groundImage"); - smTextureManager::loadTexture("textures/4351-normal.jpg", "groundBumpImage"); - smTextureManager::loadTexture("textures/brick.jpg", "wallImage"); - smTextureManager::loadTexture("textures/brick-normal.jpg", "wallBumpImage"); + TextureManager::loadTexture("textures/4351-diffuse.jpg", "groundImage"); + TextureManager::loadTexture("textures/4351-normal.jpg", "groundBumpImage"); + TextureManager::loadTexture("textures/brick.jpg", "wallImage"); + TextureManager::loadTexture("textures/brick-normal.jpg", "wallBumpImage"); // Create collision models std::shared_ptr<MeshCollisionModel> collisionModelA = std::make_shared<MeshCollisionModel>(); - collisionModelA->loadTriangleMesh("models/liverNormalized_SB2.3DS", SM_FILETYPE_3DS); + collisionModelA->loadTriangleMesh("models/liverNormalized_SB2.3DS", BaseMesh::MeshFileType::ThreeDS); collisionModelA->getMesh()->assignTexture("livertexture1"); collisionModelA->getMesh()->getRenderDetail()->renderType = (SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_WIREFRAME); collisionModelA->getMesh()->translate(7, 3, 0); @@ -78,7 +78,7 @@ CollisionDetectionSpatialHashing::CollisionDetectionSpatialHashing() collisionModelA->getMesh()->getRenderDetail()->pointSize = 5; std::shared_ptr<MeshCollisionModel> collisionModelB = std::make_shared<MeshCollisionModel>(); - collisionModelB->loadTriangleMesh("models/liverNormalized_SB2.3DS", SM_FILETYPE_3DS); + collisionModelB->loadTriangleMesh("models/liverNormalized_SB2.3DS", BaseMesh::MeshFileType::ThreeDS); collisionModelB->getMesh()->assignTexture("livertexture2"); collisionModelB->getMesh()->translate(core::Vec3d(2, 0, 0)); collisionModelB->getMesh()->assignTexture("livertexture2"); @@ -112,7 +112,7 @@ CollisionDetectionSpatialHashing::CollisionDetectionSpatialHashing() scene->addLight(light); // Camera setup - std::shared_ptr<smCamera> sceneCamera = smCamera::getDefaultCamera(); + std::shared_ptr<Camera> sceneCamera = Camera::getDefaultCamera(); assert(sceneCamera); scene->addCamera(sceneCamera); camCtl->setCamera(sceneCamera); @@ -133,8 +133,8 @@ CollisionDetectionSpatialHashing::CollisionDetectionSpatialHashing() viewer->registerScene(scene, SMRENDERTARGET_SCREEN, ""); //Link up the event system between this the camera controller and the viewer - viewer->attachEvent(mstk::Event::EventType::Keyboard, camCtl); - viewer->attachEvent(mstk::Event::EventType::Keyboard, keyShutdown); + viewer->attachEvent(core::EventType::Keyboard, camCtl); + viewer->attachEvent(core::EventType::Keyboard, keyShutdown); } void CollisionDetectionSpatialHashing::simulateMain(const SimulationMainParam &/*p_param*/) diff --git a/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.h b/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.h index 457e23c5daa669eb00febacf656f4f941a97294b..23e7f24d5b746697c3790617e75d9f259d091847 100644 --- a/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.h +++ b/examples/CollisionDetectionSpatialHashing/CollisionDetectionSpatialHashing.h @@ -56,7 +56,7 @@ public: std::shared_ptr<StaticSceneObject> modelA; std::shared_ptr<StaticSceneObject> modelB; std::shared_ptr<Scene> scene; - std::shared_ptr<smViewer> viewer; + std::shared_ptr<Viewer> viewer; std::shared_ptr<smDummySimulator> defaultSimulator; std::shared_ptr<Simulator> simulator; std::shared_ptr<SpatialHashCollision> spatialHashing; diff --git a/examples/CollisionGrid/CollisionDetectionExample.cpp b/examples/CollisionGrid/CollisionDetectionExample.cpp deleted file mode 100644 index aa14e984f00b54f2d15a4c2552d696e815b17190..0000000000000000000000000000000000000000 --- a/examples/CollisionGrid/CollisionDetectionExample.cpp +++ /dev/null @@ -1,203 +0,0 @@ -// This file is part of the SimMedTK project. -// Copyright (c) Center for Modeling, Simulation, and Imaging in Medicine, -// Rensselaer Polytechnic Institute -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//--------------------------------------------------------------------------- -// -// Authors: -// -// Contact: -//--------------------------------------------------------------------------- - -#include "CollisionDetectionExample.h" -#include "Core/SDK.h" -#include "Rendering/TextureManager.h" -#include "Mesh/Lattice.h" -#include "Mesh/LatticeTypes.h" -#include "Core/EventData.h" - -void CollisionDetectionExample::initHapticCamMotion() -{ - - hapticInterface = new PhantomInterface(); - hapticInterface->forceEnabled = false; //disable forces right now for all devices - hapticInterface->startDevice(); - hapticInterface->setEventDispatcher(simmedtkSDK->getEventDispatcher()); - motionTrans = new smHapticCameraTrans(0); - motionTrans->setMotionScale(0.1); - simmedtkSDK->getEventDispatcher()->registerEventHandler(viewer, SIMMEDTK_EVENTTYPE_CAMERA_UPDATE); - viewer->enableCameraMotion = true; -} - -CollisionDetectionExample::CollisionDetectionExample() -{ - - motionTrans = NULL; - hapticInterface = NULL; - - //initializes the spatial grid - spatGrid = new smSpatialGrid(); - - ///create the sdk - simmedtkSDK = SDK::createSDK(); - ///create scene objects - object1 = new StaticSceneObject(); - object2 = new StaticSceneObject(); - - ///create a 3D lattice for each object - lat = new smLattice(); - lat2 = new smLattice(); - - ///create a scene - scene1 = simmedtkSDK->createScene(); - - ///dummy simulator. it translates the object - dummySim = new smDummySimulator(SDK::getErrorLog()); - simmedtkSDK->getEventDispatcher()->registerEventHandler(dummySim, SIMMEDTK_EVENTTYPE_KEYBOARD); - - ///init texture manager and give the texture file names to be loaded - smTextureManager::init(SDK::getErrorLog()); - smTextureManager::loadTexture("../../resources/textures/fat9.bmp", "livertexture1"); - smTextureManager::loadTexture("../../resources/textures/blood.jpg", "livertexture2"); - - ///For rendering the ground - smTextureManager::loadTexture("../../resources/textures/4351-diffuse.jpg", "groundImage"); //ground decal image - smTextureManager::loadTexture("../../resources/textures/4351-normal.jpg", "groundBumpImage"); //gorund bum map image - smTextureManager::loadTexture("../../resources/textures/brick.jpg", "wallImage"); //ground wall image - smTextureManager::loadTexture("../../resources/textures/brick-normal.jpg", "wallBumpImage"); //ground wall bump image - - ///load a mesh - object1->mesh->loadMeshLegacy("../../resources/models/liverNormalized_SB2.3DS", SM_FILETYPE_3DS); - - ///texture attachment needed for fixed opengl rendering if texture is needed - object1->mesh->assignTexture("livertexture1"); - object1getRenderDetail()->renderType = (SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE | SIMMEDTK_RENDER_MATERIALCOLOR); - object1->mesh->translate(7, 0, 0); - object1getRenderDetail()->lineSize = 2; - object1getRenderDetail()->pointSize = 5; - - ///add object1 to lattice - lat->addObject(object1); - - ///add lattice to the grid - spatGrid->addLattice(lat); - - ///the similiar routines for object2 - object2 = new StaticSceneObject(); - object2->mesh->loadMeshLegacy("../../resources/models/liverNormalized_SB2.3DS", SM_FILETYPE_3DS); - object2->mesh->translate(core::Vec3d(2, 0, 0)); - - object2->mesh->assignTexture("livertexture2"); - object2getRenderDetail()->shadowColor.rgba[0] = 1.0; - object2getRenderDetail()->renderType = (SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE | SIMMEDTK_RENDER_MATERIALCOLOR); - - lat2->addObject(object2); - spatGrid->addLattice(lat2); - spatGrid->pipe->registerListener(&this->myCollInformation); - this->myCollInformation.listenerObject = &*this; - this->myCollInformation.regType = SIMMEDTK_PIPE_BYREF; - - ///register the module for spatial grid - simmedtkSDK->registerModule(spatGrid); - - //add object to the scene - scene1->addSceneObject(object1); - scene1->addSceneObject(object2); - - ///create the simulator - simulator = simmedtkSDK->createSimulator(); - ///attach the dummy simulator - simulator->registerObjectSimulator(dummySim); - - ///create a viewer - viewer = simmedtkSDK->createViewer(); - - //specify the viewer global settings - viewer->viewerRenderDetail = viewer->viewerRenderDetail | SIMMEDTK_VIEWERRENDER_GROUND; - viewer->camera()->setFieldOfView(0.0174532925199433*(60)); - viewer->camera()->setZClippingCoefficient(1000); - viewer->camera()->setZNearCoefficient(0.001); - viewer->list(); - viewer->setWindowTitle("SimMedTK TEST"); - - ///assign dispatcher - viewer->setEventDispatcher(simmedtkSDK->getEventDispatcher()); - - ///You can either add object to the viewer or add object to the scene. Draw function will be called - viewer->addObject(spatGrid); - viewer->addObject(this); - - ///run the simulation - simmedtkSDK->run(); -} - -CollisionDetectionExample::~CollisionDetectionExample() -{ - - delete object1; - delete object2; - delete scene1; - delete dummySim; - delete lat; - delete lat2; - delete spatGrid; - - if (motionTrans != NULL) - { - delete motionTrans; - } - - if (hapticInterface != NULL) - { - delete hapticInterface; - } -} - -///Draw collided triangles -void CollisionDetectionExample::draw() -{ - - smCollidedTriangles *tris; - - if (myCollInformation.data.dataReady) - { - if (myCollInformation.data.nbrElements > 0) - { - tris = (smCollidedTriangles *)myCollInformation.data.dataLocation; - glBegin(GL_TRIANGLES); - - for (int i = 0; i < myCollInformation.data.nbrElements; i++) - { - glVertex3dv((GLfloat*)&tris[i].tri1.vert[0]); - glVertex3dv((GLfloat*)&tris[i].tri1.vert[1]); - glVertex3dv((GLfloat*)&tris[i].tri1.vert[2]); - - glVertex3dv((GLfloat*)&tris[i].tri2.vert[0]); - glVertex3dv((GLfloat*)&tris[i].tri2.vert[1]); - glVertex3dv((GLfloat*)&tris[i].tri2.vert[2]); - } - - glEnd(); - } - } - -} - -//extern function -void main() -{ - CollisionDetectionExample *ex = new CollisionDetectionExample(); - delete ex; -} diff --git a/examples/CollisionGrid/CollisionDetectionExample.h b/examples/CollisionGrid/CollisionDetectionExample.h deleted file mode 100644 index 331d7aca018b866f257371a7c662d80a1e9ac1cb..0000000000000000000000000000000000000000 --- a/examples/CollisionGrid/CollisionDetectionExample.h +++ /dev/null @@ -1,69 +0,0 @@ -// This file is part of the SimMedTK project. -// Copyright (c) Center for Modeling, Simulation, and Imaging in Medicine, -// Rensselaer Polytechnic Institute -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//--------------------------------------------------------------------------- -// -// Authors: -// -// Contact: -//--------------------------------------------------------------------------- - -#ifndef COLLISIONDETECTIONEXAMPLE_H -#define COLLISIONDETECTIONEXAMPLE_H - -#include "Core/Config.h" -#include "Core/ErrorLog.h" -#include "Core/CoreClass.h" -#include "Core/Simulator.h" -#include "Core/StaticSceneObject.h" -#include "Core/SceneObject.h" -#include "Simulators/DummySimulator.h" -#include "ExternalDevices/PhantomInterface.h" -#include "Core/MotionTransformer.h" -#include "Collision/SpatialGrid.h" - - -class CollisionDetectionExample: public SimulationMain, public CoreClass -{ - -public: - StaticSceneObject *object1; - StaticSceneObject *object2; - SDK* simmedtkSDK; - Scene *scene1; - smDummySimulator *dummySim; - smViewer *viewer; - Simulator *simulator; - PhantomInterface* hapticInterface; - smHapticCameraTrans *motionTrans; - smSpatialGrid *spatGrid; - smLattice *lat; - smLattice *lat2; - - CollisionDetectionExample(); - void initHapticCamMotion(); - - virtual void simulateMain(SimulationMainParam p_param) - { - } - - void CollisionDetectionExample::draw(); - ~CollisionDetectionExample(); -}; - -void collisionDetectionExample(); - -#endif diff --git a/examples/ExampleTool/exampleTool.cpp b/examples/ExampleTool/exampleTool.cpp index 8e32d9ba9977c08ba9a51d7252cefc21d635b9b0..fb96e953addce770af5db802ab530f990f20e5e5 100644 --- a/examples/ExampleTool/exampleTool.cpp +++ b/examples/ExampleTool/exampleTool.cpp @@ -57,7 +57,7 @@ public: { } - void handleEvent(std::shared_ptr<mstk::Event::Event> event) + void handleEvent(std::shared_ptr<core::Event> event) { s MyStylus::handleEvent(p_event); @@ -84,7 +84,7 @@ void main() PhantomInterface * hapticInterface; SDK* simmedtkSDK; Scene *scene1; - smViewer *viewer; + Viewer *viewer; Simulator *simulator; smToolSimulator *toolSim; @@ -114,11 +114,11 @@ void main() light2.castShadow = true; ///init texture manager and load the textures - smTextureManager::init(simmedtkSDK->getErrorLog()); - smTextureManager::loadTexture("../../resources/textures/metal.bmp", "metal", true); - smTextureManager::loadTexture("../../resources/textures/hook_cautery3.bmp", "hookCautery"); - smTextureManager::loadTexture("../../resources/textures/metalbump.bmp", "bump"); - smTextureManager::loadTexture("../../resources/textures/burn1024.bmp", "specTex"); ///for OCC I'll use the same texture + TextureManager::init(simmedtkSDK->getErrorLog()); + TextureManager::loadTexture("../../resources/textures/metal.bmp", "metal", true); + TextureManager::loadTexture("../../resources/textures/hook_cautery3.bmp", "hookCautery"); + TextureManager::loadTexture("../../resources/textures/metalbump.bmp", "bump"); + TextureManager::loadTexture("../../resources/textures/burn1024.bmp", "specTex"); ///for OCC I'll use the same texture ///create a grasper hapticStylus = new myTool(); diff --git a/examples/ExampleTool2/exampleTool2.cpp b/examples/ExampleTool2/exampleTool2.cpp index a66eb23c8e5c4423f107c162fded3a7b675cd83b..25b010fd6cc7a96b1248cf8c76e25dede4cf7f87 100644 --- a/examples/ExampleTool2/exampleTool2.cpp +++ b/examples/ExampleTool2/exampleTool2.cpp @@ -49,7 +49,7 @@ void main() PhantomInterface * hapticInterface; SDK* simmedtkSDK; Scene *scene1; - smViewer *viewer; + Viewer *viewer; Simulator *simulator; ///create lights @@ -82,12 +82,12 @@ void main() scene1->setName("Scene1"); ///init texture manager and load the textures - smTextureManager::init(simmedtkSDK->getErrorLog()); - smTextureManager::loadTexture("../../resources/textures/metal.bmp", "metal"); - smTextureManager::loadTexture("../../resources/textures/hook_cautery3.bmp", "hookCautery"); - smTextureManager::loadTexture("../../resources/textures/metalbump.bmp", "bump"); - smTextureManager::loadTexture("../../resources/textures/sword_bump.bmp", "nobump"); - smTextureManager::loadTexture("../../resources/textures/burn1024.bmp", "specTex"); ///for OCC I'll use the same texture + TextureManager::init(simmedtkSDK->getErrorLog()); + TextureManager::loadTexture("../../resources/textures/metal.bmp", "metal"); + TextureManager::loadTexture("../../resources/textures/hook_cautery3.bmp", "hookCautery"); + TextureManager::loadTexture("../../resources/textures/metalbump.bmp", "bump"); + TextureManager::loadTexture("../../resources/textures/sword_bump.bmp", "nobump"); + TextureManager::loadTexture("../../resources/textures/burn1024.bmp", "specTex"); ///for OCC I'll use the same texture ///initialize the vertex and fragment shader MetalShaderShadow *metalShader = new MetalShaderShadow( diff --git a/examples/MultipleObjects/MultipleObjects.cpp b/examples/MultipleObjects/MultipleObjects.cpp index 92562f8a12d158bf5d207315a625d1852ff9ba2e..cbcee07a1e2716d9c7b7874d02daeb629a09f956 100644 --- a/examples/MultipleObjects/MultipleObjects.cpp +++ b/examples/MultipleObjects/MultipleObjects.cpp @@ -38,7 +38,7 @@ void createPBDandFEM() smPBDObjectSimulator * pbd; Matrix33d mat; Simulator *simulator; - smViewer *viewer; + Viewer *viewer; Scene *scene1; ///create rotation matrix @@ -48,14 +48,14 @@ void createPBDandFEM() simmedtkSDK = SDK::getInstance(); ///init texture manager and load the textures - smTextureManager::init(simmedtkSDK->getErrorLog()); - smTextureManager::loadTexture("../../resources/textures/4351-diffuse.jpg", "groundImage"); - smTextureManager::loadTexture("../../resources/textures/4351-normal.jpg", "groundBumpImage"); - smTextureManager::loadTexture("../../resources/textures/brick.jpg", "wallImage"); - smTextureManager::loadTexture("../../resources/textures/brick-normal.jpg", "wallBumpImage"); + TextureManager::init(simmedtkSDK->getErrorLog()); + TextureManager::loadTexture("../../resources/textures/4351-diffuse.jpg", "groundImage"); + TextureManager::loadTexture("../../resources/textures/4351-normal.jpg", "groundBumpImage"); + TextureManager::loadTexture("../../resources/textures/brick.jpg", "wallImage"); + TextureManager::loadTexture("../../resources/textures/brick-normal.jpg", "wallBumpImage"); //for cloth texture - smTextureManager::loadTexture("../../resources/textures/cloth.jpg", "clothtexture"); + TextureManager::loadTexture("../../resources/textures/cloth.jpg", "clothtexture"); ///create a FEM simulator femSim = new smFemSimulator(simmedtkSDK->getErrorLog()); @@ -90,7 +90,7 @@ void createPBDandFEM() pbdObject = new smPBDSurfaceSceneObject(); pbdObjectgetRenderDetail()->colorDiffuse = Color::colorWhite; pbdObjectgetRenderDetail()->colorAmbient = Color::colorWhite; - pbdObject->mesh->loadMeshLegacy("../../resources/models/clothtextured.3ds", SM_FILETYPE_3DS); + pbdObject->mesh->loadMeshLegacy("../../resources/models/clothtextured.3ds", BaseMesh::MeshFileType::ThreeDS); //pbdObject->mesh->rotate(mat); pbdObject->mesh->scale(core::Vec3d(2.3, 0.5, 2)); diff --git a/examples/common/KeyPressSDKShutdown.cpp b/examples/common/KeyPressSDKShutdown.cpp index 6216d7053d361d305f726e2993ef4671d1ed41fd..edef002a03fd590d7842ff890e3172ed580eeae2 100644 --- a/examples/common/KeyPressSDKShutdown.cpp +++ b/examples/common/KeyPressSDKShutdown.cpp @@ -30,13 +30,13 @@ namespace mstk { namespace Examples { namespace Common { -KeyPressSDKShutdown::KeyPressSDKShutdown() : key(mstk::Event::smKey::Escape) +KeyPressSDKShutdown::KeyPressSDKShutdown() : key(event::Key::Escape) { } -void KeyPressSDKShutdown::handleEvent(std::shared_ptr<mstk::Event::Event> event) +void KeyPressSDKShutdown::handleEvent(std::shared_ptr<core::Event> event) { - auto keyboardEvent = std::static_pointer_cast<mstk::Event::smKeyboardEvent>(event); + auto keyboardEvent = std::static_pointer_cast<event::KeyboardEvent>(event); if(keyboardEvent->getPressed()) { if (keyboardEvent->getKeyPressed() == this->key) @@ -46,7 +46,7 @@ void KeyPressSDKShutdown::handleEvent(std::shared_ptr<mstk::Event::Event> event) } } -void KeyPressSDKShutdown::setKey(mstk::Event::smKey key) +void KeyPressSDKShutdown::setKey(event::Key key) { this->key = key; } diff --git a/examples/common/KeyPressSDKShutdown.h b/examples/common/KeyPressSDKShutdown.h index b477b21a925ade51b4cbf4547d38954f71a1d255..456de5e9ce8668c438d1ef3376496907649b6cb2 100644 --- a/examples/common/KeyPressSDKShutdown.h +++ b/examples/common/KeyPressSDKShutdown.h @@ -43,15 +43,15 @@ public: /// \brief Event handling function from CoreClass /// /// \param event Event to handle from the main event system - void handleEvent(std::shared_ptr<mstk::Event::Event> event) override; + void handleEvent(std::shared_ptr<core::Event> event) override; /// \brief Set the keyboard key to listen for /// /// \param key The keyboard key to listen for - void setKey(mstk::Event::smKey key); + void setKey(event::Key key); private: - mstk::Event::smKey key; ///< When this key is pressed, shutdown the framework + event::Key key; ///< When this key is pressed, shutdown the framework }; }//Common diff --git a/examples/common/hapticController.cpp b/examples/common/hapticController.cpp index 410b2eb255edf30cb6927998e59ccbf1dc62591b..b774692fa3e85670898028226d0eb7cfadb95f38 100644 --- a/examples/common/hapticController.cpp +++ b/examples/common/hapticController.cpp @@ -24,13 +24,13 @@ #include "hapticController.h" #include "Core/SDK.h" -#include "Event/KeyboardEvent.h" +#include "Event/HapticEvent.h" using namespace mstk::Examples::Common; -void hapticController::handleEvent(std::shared_ptr<mstk::Event::Event> event) +void hapticController::handleEvent(std::shared_ptr<core::Event> event) { - auto hapticEvent = std::static_pointer_cast<mstk::Event::smHapticEvent>(event); + auto hapticEvent = std::static_pointer_cast<event::HapticEvent>(event); if(hapticEvent != nullptr && hapticEvent->getButtonState(0)) { femSceneObject->setPulledVertex(hapticEvent->getPosition()); diff --git a/examples/common/hapticController.h b/examples/common/hapticController.h index 6b36bc8820f0c9b5211448d06be9c932da051c60..bce1e613801d7f9d65e9b390b29fcd7caba55d6e 100644 --- a/examples/common/hapticController.h +++ b/examples/common/hapticController.h @@ -44,7 +44,7 @@ public: /// \brief Event handling function from CoreClass /// /// \param event Event to handle from the main event system - void handleEvent(std::shared_ptr<mstk::Event::Event> event) override; + void handleEvent(std::shared_ptr<core::Event> event) override; /// \brief Set the scene objects which gets affected by this haptic event /// diff --git a/examples/common/pzrMouseCameraController.cpp b/examples/common/pzrMouseCameraController.cpp index 915c5f6155a88ea47df7f546a947d39633d379db..57dc001a65c03c32c6bb2e9cb8e65ed4eaf5880f 100644 --- a/examples/common/pzrMouseCameraController.cpp +++ b/examples/common/pzrMouseCameraController.cpp @@ -35,15 +35,15 @@ pzrMouseCameraController::pzrMouseCameraController() { } -pzrMouseCameraController::pzrMouseCameraController(std::shared_ptr<smCamera> cam) +pzrMouseCameraController::pzrMouseCameraController(std::shared_ptr<Camera> cam) : moveDistance{1}, - camera(cam), lmbPressed{false}, - rmbPressed{false} + rmbPressed{false}, + camera(cam) { } -void pzrMouseCameraController::setCamera(std::shared_ptr<smCamera> cam) +void pzrMouseCameraController::setCamera(std::shared_ptr<Camera> cam) { camera = cam; } @@ -53,21 +53,21 @@ void pzrMouseCameraController::setStepSize(float size) moveDistance = size; } -void pzrMouseCameraController::handleEvent(std::shared_ptr<mstk::Event::Event> event) +void pzrMouseCameraController::handleEvent(std::shared_ptr<core::Event> event) { assert(nullptr != event); assert(nullptr != camera); - auto mouseButtonEvent = std::dynamic_pointer_cast<Event::smMouseButtonEvent>(event); + auto mouseButtonEvent = std::dynamic_pointer_cast<event::MouseButtonEvent>(event); if(mouseButtonEvent != nullptr) { - if(Event::smMouseButton::Left == + if(event::MouseButton::Left == mouseButtonEvent->getMouseButton()) { lmbPressed = mouseButtonEvent->getPressed(); coords = mouseButtonEvent->getWindowCoord().cast<float>(); } - else if(Event::smMouseButton::Right == + else if(event::MouseButton::Right == mouseButtonEvent->getMouseButton()) { rmbPressed = mouseButtonEvent->getPressed(); @@ -79,7 +79,7 @@ void pzrMouseCameraController::handleEvent(std::shared_ptr<mstk::Event::Event> e } } - auto mouseMoveEvent = std::dynamic_pointer_cast<Event::smMouseMoveEvent>(event); + auto mouseMoveEvent = std::dynamic_pointer_cast<event::MouseMoveEvent>(event); if(mouseMoveEvent != nullptr) { core::Vec2f diff; diff --git a/examples/common/pzrMouseCameraController.h b/examples/common/pzrMouseCameraController.h index 7ccae54e03c3efd395d3bf32cc87862cb4779c81..0ed42b90a74e854acacf0d35ffc08648f3d59a8e 100644 --- a/examples/common/pzrMouseCameraController.h +++ b/examples/common/pzrMouseCameraController.h @@ -48,17 +48,17 @@ public: /// \brief Default constructor /// /// \param cam Pointer to camera to be controlled - pzrMouseCameraController(std::shared_ptr<smCamera> cam); + pzrMouseCameraController(std::shared_ptr<Camera> cam); /// \brief Event handling function from CoreClass /// /// \param event Event to handle from the main event system - void handleEvent(std::shared_ptr<mstk::Event::Event> event) override; + void handleEvent(std::shared_ptr<core::Event> event) override; /// \brief Set the camera to be controlled /// /// \param cam Pointer to camera to be controlled - void setCamera(std::shared_ptr<smCamera> cam); + void setCamera(std::shared_ptr<Camera> cam); /// \brief Set the step size that the camera moves with each key press /// @@ -66,10 +66,10 @@ public: void setStepSize(float size); private: - std::shared_ptr<smCamera> camera; ///< Pointer to camera being controlled float moveDistance; ///< Modifier to the movement distance for operations bool lmbPressed; ///< Left mouse button (un)pressed bool rmbPressed; ///< Right mouse button (un)pressed + std::shared_ptr<Camera> camera; ///< Pointer to camera being controlled core::Vec2f coords; ///< Record of last window coords manipulated }; diff --git a/examples/common/wasdCameraController.cpp b/examples/common/wasdCameraController.cpp index 67e3fa2a5a831e3157d18323598045bcdbd522c6..d2158870cdce5dc15d7bb4dd67cb23dc844931a9 100644 --- a/examples/common/wasdCameraController.cpp +++ b/examples/common/wasdCameraController.cpp @@ -34,13 +34,13 @@ wasdCameraController::wasdCameraController() { } -wasdCameraController::wasdCameraController(std::shared_ptr<smCamera> cam) +wasdCameraController::wasdCameraController(std::shared_ptr<Camera> cam) : moveDistance{1.0}, camera(cam) { } -void wasdCameraController::setCamera(std::shared_ptr<smCamera> cam) +void wasdCameraController::setCamera(std::shared_ptr<Camera> cam) { camera = cam; } @@ -50,20 +50,20 @@ void wasdCameraController::setStepSize(float size) moveDistance = size; } -void wasdCameraController::handleEvent(std::shared_ptr<mstk::Event::Event> event) +void wasdCameraController::handleEvent(std::shared_ptr<core::Event> e) { - assert(nullptr != event); + assert(nullptr != e); assert(nullptr != camera); - auto keyboardEvent = std::static_pointer_cast<mstk::Event::smKeyboardEvent>(event); + auto keyboardEvent = std::static_pointer_cast<event::KeyboardEvent>(e); if(keyboardEvent->getPressed()) { core::Vec3f dispVec = core::Vec3f::Zero(); //Vector to store displacement of camera switch(keyboardEvent->getKeyPressed()) { - case mstk::Event::smKey::W: + case event::Key::W: { - if(mstk::Event::smModKey::shift == (keyboardEvent->getModifierKey() & mstk::Event::smModKey::shift)) + if(event::ModKey::shift == (keyboardEvent->getModifierKey() & event::ModKey::shift)) { //Move the camera up dispVec(1) = moveDistance; @@ -75,15 +75,15 @@ void wasdCameraController::handleEvent(std::shared_ptr<mstk::Event::Event> event } break; } - case mstk::Event::smKey::A: + case event::Key::A: { //Move the camera to the left dispVec(0) = -moveDistance; break; } - case mstk::Event::smKey::S: + case event::Key::S: { - if(mstk::Event::smModKey::shift == (keyboardEvent->getModifierKey() & mstk::Event::smModKey::shift)) + if(event::ModKey::shift == (keyboardEvent->getModifierKey() & event::ModKey::shift)) { //Move the camera down dispVec(1) = -moveDistance; @@ -95,7 +95,7 @@ void wasdCameraController::handleEvent(std::shared_ptr<mstk::Event::Event> event } break; } - case mstk::Event::smKey::D: + case event::Key::D: { //Move the camera to the right dispVec(0) = moveDistance; diff --git a/examples/common/wasdCameraController.h b/examples/common/wasdCameraController.h index 06e35a68a6eea1a60cd3e513047dc70551e2d4ba..caf25f8e3da0739d18af5d626cc2048edaf95be5 100644 --- a/examples/common/wasdCameraController.h +++ b/examples/common/wasdCameraController.h @@ -48,17 +48,17 @@ public: /// \brief Default constructor /// /// \param cam Pointer to camera to be controlled - wasdCameraController(std::shared_ptr<smCamera> cam); + wasdCameraController(std::shared_ptr<Camera> cam); /// \brief Event handling function from CoreClass /// /// \param event Event to handle from the main event system - void handleEvent(std::shared_ptr<mstk::Event::Event> event) override; + void handleEvent(std::shared_ptr<core::Event> event) override; /// \brief Set the camera to be controlled /// /// \param cam Pointer to camera to be controlled - void setCamera(std::shared_ptr<smCamera> cam); + void setCamera(std::shared_ptr<Camera> cam); /// \brief Set the step size that the camera moves with each key press /// @@ -66,8 +66,8 @@ public: void setStepSize(float size); private: - std::shared_ptr<smCamera> camera; ///< Pointer to camera being controlled float moveDistance; + std::shared_ptr<Camera> camera; ///< Pointer to camera being controlled }; }//Common diff --git a/examples/renderCube/main.cpp b/examples/renderCube/main.cpp index 9d0ab129cf5bd7977d5b6f1c1c1dd0a9526f22ca..5720501e04db6bc4819687c189d1a768f87f9ecc 100644 --- a/examples/renderCube/main.cpp +++ b/examples/renderCube/main.cpp @@ -36,10 +36,10 @@ int main() { SIMMEDTK_REGISTER_RENDER_DELEGATES(); std::shared_ptr<SDK> sdk; - std::shared_ptr<smViewer> viewer; + std::shared_ptr<Viewer> viewer; std::shared_ptr<Scene> scene1; std::shared_ptr<Light> light; - std::shared_ptr<smCamera> sceneCamera; + std::shared_ptr<Camera> sceneCamera; std::shared_ptr<StaticSceneObject> cube; std::shared_ptr<mstk::Examples::Common::wasdCameraController> camCtl; std::shared_ptr<mstk::Examples::Common::KeyPressSDKShutdown> keyShutdown; @@ -51,7 +51,7 @@ int main() scene1 = sdk->createScene(); //Create a viewer to see the scene through - viewer = std::make_shared<smViewer>(); + viewer = std::make_shared<Viewer>(); sdk->addViewer(viewer); //Create the camera controller @@ -59,7 +59,7 @@ int main() keyShutdown = std::make_shared<mstk::Examples::Common::KeyPressSDKShutdown>(); pzrCamCtl = std::make_shared<mstk::Examples::Common::pzrMouseCameraController>(); - auto cubeModel = std::make_shared<smMeshModel>(); + auto cubeModel = std::make_shared<MeshModel>(); cubeModel->load("models/cube.obj", "textures/cube.png", "cubetex"); auto renderDetail = std::make_shared<RenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); @@ -89,7 +89,7 @@ int main() scene1->addLight(light); // Camera setup - sceneCamera = smCamera::getDefaultCamera(); + sceneCamera = Camera::getDefaultCamera(); assert(sceneCamera); sceneCamera->setPos(3, 3, 5); sceneCamera->setFocus(0, 0, -1); @@ -100,10 +100,10 @@ int main() pzrCamCtl->setCamera(sceneCamera); //Link up the event system between this the camera controller and the viewer - viewer->attachEvent(mstk::Event::EventType::Keyboard, camCtl); - viewer->attachEvent(mstk::Event::EventType::Keyboard, keyShutdown); - viewer->attachEvent(mstk::Event::EventType::MouseMove, pzrCamCtl); - viewer->attachEvent(mstk::Event::EventType::MouseButton, pzrCamCtl); + viewer->attachEvent(core::EventType::Keyboard, camCtl); + viewer->attachEvent(core::EventType::Keyboard, keyShutdown); + viewer->attachEvent(core::EventType::MouseMove, pzrCamCtl); + viewer->attachEvent(core::EventType::MouseButton, pzrCamCtl); //run the framework sdk->run(); diff --git a/examples/renderCubeOculus/main.cpp b/examples/renderCubeOculus/main.cpp index 69eb6a785dc17d95aefdf22e4b6cf00787485664..36468930a51a2a1ea6d542ee505625f5bd0cdd87 100644 --- a/examples/renderCubeOculus/main.cpp +++ b/examples/renderCubeOculus/main.cpp @@ -37,7 +37,7 @@ int main() std::shared_ptr<smOculusViewer> viewer; std::shared_ptr<Scene> scene1; std::shared_ptr<Light> light; - std::shared_ptr<smCamera> sceneCamera; + std::shared_ptr<Camera> sceneCamera; std::shared_ptr<StaticSceneObject> cube; std::shared_ptr<mstk::Examples::Common::wasdCameraController> camCtl; std::shared_ptr<mstk::Examples::Common::KeyPressSDKShutdown> keyShutdown; @@ -56,7 +56,7 @@ int main() camCtl = std::make_shared<mstk::Examples::Common::wasdCameraController>(); keyShutdown = std::make_shared<mstk::Examples::Common::KeyPressSDKShutdown>(); - auto cubeModel = std::make_shared<smMeshModel>(); + auto cubeModel = std::make_shared<MeshModel>(); cubeModel->load("models/cube.obj", "textures/cube.png", "cubetex"); auto renderDetail = std::make_shared<RenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); @@ -86,7 +86,7 @@ int main() scene1->addLight(light); // Camera setup - sceneCamera = smCamera::getDefaultCamera(); + sceneCamera = Camera::getDefaultCamera(); assert(sceneCamera); sceneCamera->setPos(3, 3, 5); sceneCamera->setFocus(0, 0, -1); @@ -94,8 +94,8 @@ int main() camCtl->setCamera(sceneCamera); //Link up the event system between this the camera controller and the viewer - viewer->attachEvent(mstk::Event::EventType::Keyboard, camCtl); - viewer->attachEvent(mstk::Event::EventType::Keyboard, keyShutdown); + viewer->attachEvent(core::EventType::Keyboard, camCtl); + viewer->attachEvent(core::EventType::Keyboard, keyShutdown); //run the framework sdk->run(); diff --git a/examples/renderCubeToTexture/main.cpp b/examples/renderCubeToTexture/main.cpp index d206d7132eb93d36f4114bb8e2d14326c212c29f..c8938c5c0417c287911fe42aa4f73ac1c79e770e 100644 --- a/examples/renderCubeToTexture/main.cpp +++ b/examples/renderCubeToTexture/main.cpp @@ -33,10 +33,10 @@ int main() { std::shared_ptr<SDK> sdk; - std::shared_ptr<smViewer> viewer; + std::shared_ptr<Viewer> viewer; std::shared_ptr<Scene> scene1, scene2; std::shared_ptr<Light> light1, light2; - std::shared_ptr<smCamera> sceneCamera1, sceneCamera2; + std::shared_ptr<Camera> sceneCamera1, sceneCamera2; std::shared_ptr<StaticSceneObject> cube, square; std::shared_ptr<mstk::Examples::Common::wasdCameraController> camCtl; std::shared_ptr<mstk::Examples::Common::KeyPressSDKShutdown> keyShutdown; @@ -49,14 +49,14 @@ int main() scene2 = sdk->createScene(); //external scene containing square with scene1 mapped to it //Create a viewer to see the scene through - viewer = std::make_shared<smViewer>(); + viewer = std::make_shared<Viewer>(); sdk->addViewer(viewer); //Create the camera controller camCtl = std::make_shared<mstk::Examples::Common::wasdCameraController>(); keyShutdown = std::make_shared<mstk::Examples::Common::KeyPressSDKShutdown>(); - auto cubeModel = std::make_shared<smMeshModel>(); + auto cubeModel = std::make_shared<MeshModel>(); cubeModel->load("models/cube.obj", "textures/cube.png", "cubetex"); auto renderDetail = std::make_shared<RenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); @@ -70,11 +70,11 @@ int main() //setup scene2 //Create a color and depth texture for the FBO - smTextureManager::createColorTexture("colorTex1", 64, 64); - smTextureManager::createDepthTexture("depthTex1", 64, 64); + TextureManager::createColorTexture("colorTex1", 64, 64); + TextureManager::createDepthTexture("depthTex1", 64, 64); - std::shared_ptr<smMeshModel> squareModel = std::make_shared<smMeshModel>(); - squareModel->load("models/square.obj", SM_FILETYPE_OBJ); + std::shared_ptr<MeshModel> squareModel = std::make_shared<MeshModel>(); + squareModel->load("models/square.obj", BaseMesh::MeshFileType::Obj); squareModel->getMesh()->assignTexture("colorTex1"); renderDetail= std::make_shared<RenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); squareModel->setRenderDetail(renderDetail); @@ -85,8 +85,8 @@ int main() //Setup an FBO for rendering in the viewer. //Add the FBO and textures to the viewer viewer->addFBO("fbo1", - smTextureManager::getTexture("colorTex1"), - smTextureManager::getTexture("depthTex1"), + TextureManager::getTexture("colorTex1"), + TextureManager::getTexture("depthTex1"), 64, 64); //Add the square to the scene @@ -116,7 +116,7 @@ int main() scene2->addLight(light2); // Camera setup - sceneCamera1 = smCamera::getDefaultCamera(); + sceneCamera1 = Camera::getDefaultCamera(); assert(sceneCamera1); sceneCamera1->setPos(3, 3, 5); sceneCamera1->setFocus(0, 0, -1); @@ -125,7 +125,7 @@ int main() scene1->addCamera(sceneCamera1); camCtl->setCamera(sceneCamera1); - sceneCamera2 = smCamera::getDefaultCamera(); + sceneCamera2 = Camera::getDefaultCamera(); assert(sceneCamera2); sceneCamera2->setPos(0, 0, 5); sceneCamera2->setFocus(0, 0, -1); @@ -134,8 +134,8 @@ int main() scene2->addCamera(sceneCamera2); //Link up the event system between this the camera controller and the viewer - viewer->attachEvent(mstk::Event::EventType::Keyboard, camCtl); - viewer->attachEvent(mstk::Event::EventType::Keyboard, keyShutdown); + viewer->attachEvent(core::EventType::Keyboard, camCtl); + viewer->attachEvent(core::EventType::Keyboard, keyShutdown); //run the framework sdk->run(); diff --git a/examples/renderCubeToTextureOculus/main.cpp b/examples/renderCubeToTextureOculus/main.cpp index 6d1036039d887cac1a7f4e273e3e998d7d2f5885..a93cfe6c149db8b9bb84ae6eca6030ac55672a67 100644 --- a/examples/renderCubeToTextureOculus/main.cpp +++ b/examples/renderCubeToTextureOculus/main.cpp @@ -37,7 +37,7 @@ int main() std::shared_ptr<smOculusViewer> viewer; std::shared_ptr<Scene> scene1, scene2; std::shared_ptr<Light> light1, light2; - std::shared_ptr<smCamera> sceneCamera1, sceneCamera2; + std::shared_ptr<Camera> sceneCamera1, sceneCamera2; std::shared_ptr<StaticSceneObject> cube, square; std::shared_ptr<mstk::Examples::Common::wasdCameraController> camCtl; std::shared_ptr<mstk::Examples::Common::KeyPressSDKShutdown> keyShutdown; @@ -57,7 +57,7 @@ int main() camCtl = std::make_shared<mstk::Examples::Common::wasdCameraController>(); keyShutdown = std::make_shared<mstk::Examples::Common::KeyPressSDKShutdown>(); - auto cubeModel = std::make_shared<smMeshModel>(); + auto cubeModel = std::make_shared<MeshModel>(); cubeModel->load("models/cube.obj", "textures/cube.png", "cubetex"); auto renderDetail = std::make_shared<RenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); @@ -71,11 +71,11 @@ int main() //setup scene2 //Create a color and depth texture for the FBO - smTextureManager::createColorTexture("colorTex1", 64, 64); - smTextureManager::createDepthTexture("depthTex1", 64, 64); + TextureManager::createColorTexture("colorTex1", 64, 64); + TextureManager::createDepthTexture("depthTex1", 64, 64); - std::shared_ptr<smMeshModel> squareModel = std::make_shared<smMeshModel>(); - squareModel->load("models/square.obj", SM_FILETYPE_OBJ); + std::shared_ptr<MeshModel> squareModel = std::make_shared<MeshModel>(); + squareModel->load("models/square.obj", BaseMesh::MeshFileType::Obj); squareModel->getMesh()->assignTexture("colorTex1"); renderDetail= std::make_shared<RenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_TEXTURE); squareModel->setRenderDetail(renderDetail); @@ -86,8 +86,8 @@ int main() //Setup an FBO for rendering in the viewer. //Add the FBO and textures to the viewer viewer->addFBO("fbo1", - smTextureManager::getTexture("colorTex1"), - smTextureManager::getTexture("depthTex1"), + TextureManager::getTexture("colorTex1"), + TextureManager::getTexture("depthTex1"), 64, 64); //Add the square to the scene @@ -117,22 +117,22 @@ int main() scene2->addLight(light2); // Camera setup - sceneCamera1 = smCamera::getDefaultCamera(); + sceneCamera1 = Camera::getDefaultCamera(); assert(sceneCamera1); sceneCamera1->setPos(3, 3, 5); sceneCamera1->setFocus(0, 0, -1); scene1->addCamera(sceneCamera1); camCtl->setCamera(sceneCamera1); - sceneCamera2 = smCamera::getDefaultCamera(); + sceneCamera2 = Camera::getDefaultCamera(); assert(sceneCamera2); sceneCamera2->setPos(0, 0, 5); sceneCamera2->setFocus(0, 0, -1); scene2->addCamera(sceneCamera2); //Link up the event system between this the camera controller and the viewer - viewer->attachEvent(mstk::Event::EventType::Keyboard, camCtl); - viewer->attachEvent(mstk::Event::EventType::Keyboard, keyShutdown); + viewer->attachEvent(core::EventType::Keyboard, camCtl); + viewer->attachEvent(core::EventType::Keyboard, keyShutdown); //run the framework sdk->run(); diff --git a/examples/vegaFem/main.cpp b/examples/vegaFem/main.cpp index ac5213821caf25b89f4f65f9f7b1658089a0493e..2bbfccf46b41c576f93c58857b52f83303ad3bbd 100644 --- a/examples/vegaFem/main.cpp +++ b/examples/vegaFem/main.cpp @@ -60,10 +60,10 @@ int main() std::shared_ptr<smVegaFemSimulator> femSimulator; std::shared_ptr<smDummySimulator> staticSimulator; std::shared_ptr<PlaneCollisionModel> plane; - std::shared_ptr<smViewer> viewer; + std::shared_ptr<Viewer> viewer; std::shared_ptr<Scene> scene; std::shared_ptr<Light> light; - std::shared_ptr<smCamera> sceneCamera; + std::shared_ptr<Camera> sceneCamera; std::shared_ptr<mstk::Examples::Common::wasdCameraController> camCtl; std::shared_ptr<mstk::Examples::Common::KeyPressSDKShutdown> keyShutdown; std::shared_ptr<mstk::Examples::Common::pzrMouseCameraController> pzrCamCtl; @@ -103,7 +103,7 @@ int main() /*hapticCtl = std::make_shared<mstk::Examples::Common::hapticController>(); hapticCtl->setVegaFemSceneObject(femObject); - femSimulator->attachEvent(mstk::Event::EventType::Haptic, hapticCtl);*/ + femSimulator->attachEvent(core::Haptic, hapticCtl);*/ sdk->addSceneActor(femObject, femSimulator); @@ -161,7 +161,7 @@ int main() //------------------------------------------------------- // Customize the viewer //------------------------------------------------------- - viewer = std::dynamic_pointer_cast<smViewer>(sdk->getViewerInstance()); + viewer = std::dynamic_pointer_cast<Viewer>(sdk->getViewerInstance()); viewer->viewerRenderDetail = viewer->viewerRenderDetail | SIMMEDTK_VIEWERRENDER_FADEBACKGROUND | @@ -178,7 +178,7 @@ int main() scene->addLight(light); // Camera setup - sceneCamera = smCamera::getDefaultCamera(); + sceneCamera = Camera::getDefaultCamera(); sceneCamera->setPos(12, 12, 24); sceneCamera->setFocus(0, 0, 0); scene->addCamera(sceneCamera); @@ -193,10 +193,10 @@ int main() pzrCamCtl->setCamera(sceneCamera); // Link up the event system between this the camera controller and the viewer - viewer->attachEvent(mstk::Event::EventType::Keyboard, camCtl); - viewer->attachEvent(mstk::Event::EventType::Keyboard, keyShutdown); - viewer->attachEvent(mstk::Event::EventType::MouseMove, pzrCamCtl); - viewer->attachEvent(mstk::Event::EventType::MouseButton, pzrCamCtl); + viewer->attachEvent(core::EventType::Keyboard, camCtl); + viewer->attachEvent(core::EventType::Keyboard, keyShutdown); + viewer->attachEvent(core::EventType::MouseMove, pzrCamCtl); + viewer->attachEvent(core::EventType::MouseButton, pzrCamCtl); //------------------------------------------------------- // Run the SDK diff --git a/src/Collision/MeshCollisionModel.cpp b/src/Collision/MeshCollisionModel.cpp index bc9264122374c623ca70fb4685c6875a1ca934b1..08692880bcb0484d6c40ff73e2b26b6ce3b22e9b 100644 --- a/src/Collision/MeshCollisionModel.cpp +++ b/src/Collision/MeshCollisionModel.cpp @@ -32,13 +32,13 @@ MeshCollisionModel::~MeshCollisionModel() { } -void MeshCollisionModel::setMesh(std::shared_ptr<smMesh> modelMesh) +void MeshCollisionModel::setMesh(std::shared_ptr<Mesh> modelMesh) { this->setModelMesh(modelMesh); this->aabbTree.reset(); this->initAABBTree(1); } -void MeshCollisionModel::loadTriangleMesh(const std::string& meshName, const smMeshFileType &type) +void MeshCollisionModel::loadTriangleMesh(const std::string& meshName, const BaseMesh::MeshFileType &type) { this->load(meshName,type); @@ -56,6 +56,6 @@ void MeshCollisionModel::setAABBTree(std::shared_ptr<MeshCollisionModel::AABBTre } void MeshCollisionModel::initAABBTree(const int& numLevels) { - this->aabbTree = std::make_shared<AABBTreeType>(std::static_pointer_cast<smSurfaceMesh>(this->mesh), numLevels); + this->aabbTree = std::make_shared<AABBTreeType>(std::static_pointer_cast<SurfaceMesh>(this->mesh), numLevels); this->aabbTree->initStructure(); } diff --git a/src/Collision/MeshCollisionModel.h b/src/Collision/MeshCollisionModel.h index bc7e4b529b866d5ea42dbd86884b2d34e070e677..99384e47d94ad7fb3a2207f81bc54bd3b8435768 100644 --- a/src/Collision/MeshCollisionModel.h +++ b/src/Collision/MeshCollisionModel.h @@ -44,7 +44,7 @@ /// /// @see MeshToMeshCollision /// -class MeshCollisionModel : public smMeshModel +class MeshCollisionModel : public MeshModel { public: using AABBNodeType = OctreeCell; @@ -58,7 +58,7 @@ public: /// /// @brief Set internal mesh data structure /// - void setMesh(std::shared_ptr<smMesh> modelMesh); + void setMesh(std::shared_ptr<Mesh> modelMesh); /// /// @brief Returns pointer to axis aligned bounding box hierarchy @@ -68,7 +68,7 @@ public: /// /// @brief Loads a triangular mesh and stores it. /// - void loadTriangleMesh(const std::string &meshName, const smMeshFileType &type); + void loadTriangleMesh(const std::string &meshName, const BaseMesh::MeshFileType &type); /// /// @brief Set internal AABB tree diff --git a/src/Collision/PlaneCollisionModel.cpp b/src/Collision/PlaneCollisionModel.cpp index 84b74b58364c86272b47715c334fee753acacad4..0b9a22e4058a292545b1e8b6c548801c87b40a66 100644 --- a/src/Collision/PlaneCollisionModel.cpp +++ b/src/Collision/PlaneCollisionModel.cpp @@ -25,7 +25,7 @@ #include "PlaneCollisionModel.h" PlaneCollisionModel::PlaneCollisionModel(const core::Vec3d& p, const core::Vec3d& n) - : smPlaneModel(p, n) + : PlaneModel(p, n) { } diff --git a/src/Collision/PlaneCollisionModel.h b/src/Collision/PlaneCollisionModel.h index 1494bc87391ea197fead35bea971841a4921deda..d922332f6bc74e8e0bbcb513718ab4f92952952a 100644 --- a/src/Collision/PlaneCollisionModel.h +++ b/src/Collision/PlaneCollisionModel.h @@ -26,7 +26,7 @@ #include "Geometry/PlaneModel.h" -class PlaneCollisionModel : public smPlaneModel +class PlaneCollisionModel : public PlaneModel { public: PlaneCollisionModel(const core::Vec3d &p, const core::Vec3d &n); diff --git a/src/Collision/PlaneToMeshCollision.cpp b/src/Collision/PlaneToMeshCollision.cpp index b6068fc93cde513b09ba9e371a886b36243e41d4..0b13d3f049174296af10a127962ef5d338d2b993 100644 --- a/src/Collision/PlaneToMeshCollision.cpp +++ b/src/Collision/PlaneToMeshCollision.cpp @@ -48,7 +48,7 @@ void PlaneToMeshCollision::doComputeCollision(std::shared_ptr<CollisionPair> pai core::Vec3d vert; pair->clearContacts(); - for (int i = 0; i < mesh->getVertices().size(); i++)//const auto& vertex : mesh->getVertices() + for (size_t i = 0; i < mesh->getVertices().size(); i++)//const auto& vertex : mesh->getVertices() { vert = mesh->getVertices()[i]; d = planeNormal.dot(vert - planePos); diff --git a/src/Collision/SpatialHashCollision.cpp b/src/Collision/SpatialHashCollision.cpp index 035015dbcde586ed7099aa83f94215eec41b9646..7a3421d0717aafdf964ea4921c2feb4f91015899 100644 --- a/src/Collision/SpatialHashCollision.cpp +++ b/src/Collision/SpatialHashCollision.cpp @@ -75,25 +75,25 @@ void SpatialHashCollision::addCollisionModel(std::shared_ptr<SurfaceTreeType> Co colModel.push_back(CollMode); } -void SpatialHashCollision::addMesh(std::shared_ptr<smMesh> mesh) +void SpatialHashCollision::addMesh(std::shared_ptr<Mesh> mesh) { meshes.push_back(mesh); mesh->allocateAABBTris(); } -void SpatialHashCollision::addMesh(std::shared_ptr<smLineMesh> mesh) +void SpatialHashCollision::addMesh(std::shared_ptr<LineMesh> mesh) { lineMeshes.push_back(mesh); } -void SpatialHashCollision::removeMesh(std::shared_ptr<smMesh> mesh) +void SpatialHashCollision::removeMesh(std::shared_ptr<Mesh> mesh) { auto it = std::find(meshes.begin(),meshes.end(),mesh); if(it != meshes.end()) meshes.erase(it); } -bool SpatialHashCollision::findCandidatePoints(std::shared_ptr<smMesh> mesh, +bool SpatialHashCollision::findCandidatePoints(std::shared_ptr<Mesh> mesh, std::shared_ptr<SpatialHashCollision::SurfaceTreeType> colModel) { AABB tempAABB; @@ -112,7 +112,7 @@ bool SpatialHashCollision::findCandidatePoints(std::shared_ptr<smMesh> mesh, return found; } -bool SpatialHashCollision::findCandidateTris(std::shared_ptr<smMesh> meshA, std::shared_ptr<smMesh> meshB) +bool SpatialHashCollision::findCandidateTris(std::shared_ptr<Mesh> meshA, std::shared_ptr<Mesh> meshB) { AABB aabboverlap; @@ -134,7 +134,7 @@ bool SpatialHashCollision::findCandidateTris(std::shared_ptr<smMesh> meshA, std: return true; } -bool SpatialHashCollision::findCandidateTrisLines(std::shared_ptr<smMesh> meshA, std::shared_ptr<smLineMesh> meshB) +bool SpatialHashCollision::findCandidateTrisLines(std::shared_ptr<Mesh> meshA, std::shared_ptr<LineMesh> meshB) { AABB aabboverlap; @@ -285,7 +285,7 @@ void SpatialHashCollision::computeCollisionModel2Points() } } -void SpatialHashCollision::computeHash(std::shared_ptr<smMesh> mesh, const std::vector<int> &triangleIndexes) +void SpatialHashCollision::computeHash(std::shared_ptr<Mesh> mesh, const std::vector<int> &triangleIndexes) { for(auto&& i : triangleIndexes) { @@ -306,7 +306,7 @@ void SpatialHashCollision::computeHash(std::shared_ptr<smMesh> mesh, const std:: } } -void SpatialHashCollision::addTriangle(std::shared_ptr<smMesh> mesh, int triangleId, smHash<CellTriangle> &cells) +void SpatialHashCollision::addTriangle(std::shared_ptr<Mesh> mesh, int triangleId, smHash<CellTriangle> &cells) { CellTriangle triangle; triangle.meshID = mesh->getUniqueId(); @@ -332,7 +332,7 @@ void SpatialHashCollision::addTriangle(std::shared_ptr<smMesh> mesh, int triangl } } -void SpatialHashCollision::addLine(std::shared_ptr<smLineMesh> mesh, +void SpatialHashCollision::addLine(std::shared_ptr<LineMesh> mesh, int edgeId, smHash<smCellLine> &cells) { smCellLine line; @@ -357,7 +357,7 @@ void SpatialHashCollision::addLine(std::shared_ptr<smLineMesh> mesh, } } -void SpatialHashCollision::addPoint(std::shared_ptr<smMesh> mesh, int vertId, smHash<smCellPoint> &cells) +void SpatialHashCollision::addPoint(std::shared_ptr<Mesh> mesh, int vertId, smHash<smCellPoint> &cells) { smCellPoint cellPoint; cellPoint.meshID = mesh->getUniqueId(); diff --git a/src/Collision/SpatialHashCollision.h b/src/Collision/SpatialHashCollision.h index 31e4b57290ac4b1f277461dda6c8481f19fc7305..8ece0c5dd43699121a2847f3c85f78593a0f00a2 100644 --- a/src/Collision/SpatialHashCollision.h +++ b/src/Collision/SpatialHashCollision.h @@ -39,8 +39,8 @@ class CellTriangle; class smCollidedLineTris; class smCollidedModelPoints; class smCollidedTriangles; -class smLineMesh; -class smMesh; +class LineMesh; +class Mesh; class OctreeCell; template<typename CellType> @@ -75,25 +75,25 @@ public: void addCollisionModel(std::shared_ptr<SurfaceTreeType> CollModel); /// \brief !! - void addMesh(std::shared_ptr<smMesh> mesh); + void addMesh(std::shared_ptr<Mesh> mesh); /// \brief !! - void addMesh(std::shared_ptr<smLineMesh> mesh); + void addMesh(std::shared_ptr<LineMesh> mesh); /// \brief !! - void removeMesh(std::shared_ptr<smMesh> mesh); + void removeMesh(std::shared_ptr<Mesh> mesh); /// \brief !! - bool findCandidates(/*std::shared_ptr<smMesh> meshA, std::shared_ptr<smMesh> meshB*/); + bool findCandidates(/*std::shared_ptr<Mesh> meshA, std::shared_ptr<Mesh> meshB*/); /// \brief !! - bool findCandidatePoints(std::shared_ptr<smMesh> mesh, std::shared_ptr<SurfaceTreeType> colModel); + bool findCandidatePoints(std::shared_ptr<Mesh> mesh, std::shared_ptr<SurfaceTreeType> colModel); /// \brief find the candidate triangle pairs for collision (broad phase collision) - bool findCandidateTris(std::shared_ptr<smMesh> meshA, std::shared_ptr<smMesh> meshB); + bool findCandidateTris(std::shared_ptr<Mesh> meshA, std::shared_ptr<Mesh> meshB); /// \brief find the candidate line-triangle pairs for collision (broad phase collision) - bool findCandidateTrisLines(std::shared_ptr<smMesh> meshA, std::shared_ptr<smLineMesh> meshB); + bool findCandidateTrisLines(std::shared_ptr<Mesh> meshA, std::shared_ptr<LineMesh> meshB); /// \brief compute the collision between two triangles (narrow phase collision) void computeCollisionTri2Tri(); @@ -105,7 +105,7 @@ public: void computeCollisionModel2Points(); /// \brief !! compute the hash - void computeHash(std::shared_ptr<smMesh> mesh, const std::vector<int> &tris); + void computeHash(std::shared_ptr<Mesh> mesh, const std::vector<int> &tris); const std::vector<std::shared_ptr<smCollidedTriangles>> &getCollidedTriangles() const; @@ -113,13 +113,13 @@ public: protected: /// \brief adds triangle to hash - void addTriangle(std::shared_ptr<smMesh> mesh, int triangleId, smHash<CellTriangle> &cells); + void addTriangle(std::shared_ptr<Mesh> mesh, int triangleId, smHash<CellTriangle> &cells); /// \brief adds line to hash - void addLine(std::shared_ptr<smLineMesh> mesh, int edgeId, smHash<smCellLine> &cells); + void addLine(std::shared_ptr<LineMesh> mesh, int edgeId, smHash<smCellLine> &cells); /// \brief adds point to hash - void addPoint(std::shared_ptr<smMesh> mesh, int vertId, smHash<smCellPoint> &cells); + void addPoint(std::shared_ptr<Mesh> mesh, int vertId, smHash<smCellPoint> &cells); /// \brief adds octree cell to hash void addOctreeCell(std::shared_ptr<SurfaceTreeType> colModel, smHash<smCellModel> &cells); @@ -150,8 +150,8 @@ private: smHash<CellTriangle> cellsForTri2Line; // Candidate triangles in the scene. smHash<smCellModel> cellsForModel; // Candidate cells for collision model smHash<smCellPoint> cellsForModelPoints; // Candidate for Collision model to point - std::vector<std::shared_ptr<smMesh>> meshes; // Mesh models - std::vector<std::shared_ptr<smLineMesh>> lineMeshes; // Line mehs models + std::vector<std::shared_ptr<Mesh>> meshes; // Mesh models + std::vector<std::shared_ptr<LineMesh>> lineMeshes; // Line mehs models std::vector<std::shared_ptr<smCollidedTriangles>> collidedTriangles; // List of collision pairs triangles std::vector<std::shared_ptr<smCollidedLineTris>> collidedLineTris; // List of collision pairs triangles-lines std::vector<std::shared_ptr<smCollidedModelPoints>> collidedModelPoints; // List of collision pairs models-points diff --git a/src/Collision/SurfaceTree.h b/src/Collision/SurfaceTree.h index 153833f98ed7b8cc881c1eb85332bc914ad73e3a..063f7c25c65fa6004197954414272ebba4b0b7b4 100644 --- a/src/Collision/SurfaceTree.h +++ b/src/Collision/SurfaceTree.h @@ -42,7 +42,7 @@ protected: typedef Matrix44d MatrixType; protected: - std::shared_ptr<smSurfaceMesh> mesh; ///< surface mesh + std::shared_ptr<SurfaceMesh> mesh; ///< surface mesh int minTreeRenderLevel; ///< !! bool renderSurface; ///< !! bool enableShiftPos; ///< !! @@ -54,7 +54,7 @@ protected: public: /// \brief constructor - SurfaceTree(std::shared_ptr<smSurfaceMesh> surfaceMesh, int maxLevels = 6); + SurfaceTree(std::shared_ptr<SurfaceMesh> surfaceMesh, int maxLevels = 6); /// \brief destructor ~SurfaceTree(); @@ -90,7 +90,7 @@ public: } /// \brief !! - void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; + void handleEvent(std::shared_ptr<core::Event> p_event) override; /// \brief !! SurfaceTree structure void updateStructure(); diff --git a/src/Collision/SurfaceTree.hpp b/src/Collision/SurfaceTree.hpp index d9438bcbf77948c2694e5c6633e2e2a133ac9630..70c2a653b8132a59e524afc0eca3141afe2dfe85 100644 --- a/src/Collision/SurfaceTree.hpp +++ b/src/Collision/SurfaceTree.hpp @@ -65,7 +65,7 @@ SurfaceTree<CellType>::~SurfaceTree() /// \brief template<typename CellType> -SurfaceTree<CellType>::SurfaceTree(std::shared_ptr<smSurfaceMesh> surfaceMesh, int maxLevels) +SurfaceTree<CellType>::SurfaceTree(std::shared_ptr<SurfaceMesh> surfaceMesh, int maxLevels) { mesh = surfaceMesh; totalCells = 0; @@ -109,19 +109,19 @@ SurfaceTree<CellType>::SurfaceTree(std::shared_ptr<smSurfaceMesh> surfaceMesh, i /// \brief handle key press events template<typename CellType> -void SurfaceTree<CellType>::handleEvent(std::shared_ptr<mstk::Event::Event> event) +void SurfaceTree<CellType>::handleEvent(std::shared_ptr<core::Event> event) { if(!this->isListening()) { return; } - auto keyBoardEvent = std::static_pointer_cast<mstk::Event::smKeyboardEvent>(event); + auto keyBoardEvent = std::static_pointer_cast<event::KeyboardEvent>(event); if(keyBoardEvent != nullptr) { - mstk::Event::smKey keyPressed = keyBoardEvent->getKeyPressed(); + event::Key keyPressed = keyBoardEvent->getKeyPressed(); switch(keyPressed) { - case mstk::Event::smKey::Add: + case event::Key::Add: { minTreeRenderLevel++; @@ -138,7 +138,7 @@ void SurfaceTree<CellType>::handleEvent(std::shared_ptr<mstk::Event::Event> even currentLevel = minTreeRenderLevel; } - case mstk::Event::smKey::Subtract: + case event::Key::Subtract: { minTreeRenderLevel--; @@ -155,22 +155,22 @@ void SurfaceTree<CellType>::handleEvent(std::shared_ptr<mstk::Event::Event> even currentLevel = minTreeRenderLevel; } - case mstk::Event::smKey::R: + case event::Key::R: { this->renderSurface = !this->renderSurface; } - case mstk::Event::smKey::P: + case event::Key::P: { this->enableShiftPos = !this->enableShiftPos; } - case mstk::Event::smKey::K: + case event::Key::K: { this->renderOnlySurface = !this->renderOnlySurface; } - case mstk::Event::smKey::T: + case event::Key::T: { updateStructure(); } diff --git a/src/Collision/UnitTests/CMakeLists.txt b/src/Collision/UnitTests/CMakeLists.txt index 0e4b451f2aec7c59d1404df5fef3f2c0b718e8ee..8895e8df389c830a3aa152122f09b7269fca07b8 100644 --- a/src/Collision/UnitTests/CMakeLists.txt +++ b/src/Collision/UnitTests/CMakeLists.txt @@ -9,7 +9,7 @@ add_executable(${Module}UnitTestRunner MeshCollisionModelSpec.cpp ) -target_compile_options(${Module}UnitTestRunner PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast>) +target_compile_options(${Module}UnitTestRunner PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast -Wno-multichar -Wno-type-limits>) target_link_libraries(${Module}UnitTestRunner Geometry Collision Core Rendering Mesh Event) diff --git a/src/Collision/UnitTests/MeshCollisionModelSpec.cpp b/src/Collision/UnitTests/MeshCollisionModelSpec.cpp index c2f1c63e3a8a4b2c6114c0da32397dd7a65311e7..5624647d8c8c01716ccb1f61c09b8b3155d57ff0 100644 --- a/src/Collision/UnitTests/MeshCollisionModelSpec.cpp +++ b/src/Collision/UnitTests/MeshCollisionModelSpec.cpp @@ -37,7 +37,7 @@ go_bandit([](){ it("loads mesh ", []() { std::unique_ptr<MeshCollisionModel> meshCollisionModel = make_unique<MeshCollisionModel>(); - std::shared_ptr<smMesh> mesh = std::make_shared<smSurfaceMesh>(); + std::shared_ptr<Mesh> mesh = std::make_shared<SurfaceMesh>(); meshCollisionModel->setMesh(mesh); @@ -47,7 +47,7 @@ go_bandit([](){ it("can access positions ", []() { std::unique_ptr<MeshCollisionModel> meshCollisionModel = make_unique<MeshCollisionModel>(); - std::shared_ptr<smMesh> mesh = std::make_shared<smSurfaceMesh>(); + std::shared_ptr<Mesh> mesh = std::make_shared<SurfaceMesh>(); meshCollisionModel->setMesh(mesh); // Add two triangles to the data structure @@ -94,7 +94,7 @@ go_bandit([](){ it("can access normals ", []() { std::unique_ptr<MeshCollisionModel> meshCollisionModel = make_unique<MeshCollisionModel>(); - std::shared_ptr<smMesh> mesh = std::make_shared<smSurfaceMesh>(); + std::shared_ptr<Mesh> mesh = std::make_shared<SurfaceMesh>(); meshCollisionModel->setMesh(mesh); // Add two triangles to the data structure @@ -140,7 +140,7 @@ go_bandit([](){ it("create BVH ", []() { std::unique_ptr<MeshCollisionModel> meshCollisionModel = make_unique<MeshCollisionModel>(); - std::shared_ptr<smMesh> mesh = std::make_shared<smSurfaceMesh>(); + std::shared_ptr<Mesh> mesh = std::make_shared<SurfaceMesh>(); meshCollisionModel->setMesh(mesh); // Add two triangles to the data structure @@ -178,7 +178,7 @@ go_bandit([](){ std::shared_ptr<MeshCollisionModel::AABBTreeType> modelAabbTree = std::make_shared<MeshCollisionModel::AABBTreeType>( - std::static_pointer_cast<smSurfaceMesh>(mesh),6); + std::static_pointer_cast<SurfaceMesh>(mesh),6); modelAabbTree->initStructure(); meshCollisionModel->setAABBTree(modelAabbTree); diff --git a/src/Collision/UnitTests/MeshToMeshCollisionSpec.cpp b/src/Collision/UnitTests/MeshToMeshCollisionSpec.cpp index d33d3d2b340056bf125e82a7058cf4550830538e..2337f28fff1728d84fae230c89e62de3300ed947 100644 --- a/src/Collision/UnitTests/MeshToMeshCollisionSpec.cpp +++ b/src/Collision/UnitTests/MeshToMeshCollisionSpec.cpp @@ -34,7 +34,7 @@ using namespace bandit; std::shared_ptr<MeshCollisionModel> getModel(const core::StdVector3d &vertices) { std::shared_ptr<MeshCollisionModel> model = std::make_shared<MeshCollisionModel>(); - std::shared_ptr<smMesh> mesh = std::make_shared<smSurfaceMesh>(); + std::shared_ptr<Mesh> mesh = std::make_shared<SurfaceMesh>(); // Add two triangles to the data structure mesh->initVertexArrays(3); diff --git a/src/ContactHandling/PenaltyContactFemToStatic.cpp b/src/ContactHandling/PenaltyContactFemToStatic.cpp index 841d8076fe80c77764a4493700082e54323c198c..b7d1f1db66a6a665498782f4ec61ee41b9698cc1 100644 --- a/src/ContactHandling/PenaltyContactFemToStatic.cpp +++ b/src/ContactHandling/PenaltyContactFemToStatic.cpp @@ -45,7 +45,7 @@ PenaltyContactFemToStatic::~PenaltyContactFemToStatic() void PenaltyContactFemToStatic::computeUnilateralContactForces() { - int penetratedNode, nodeDofID; + int nodeDofID; const double stiffness = 1.0e4, damping = 1.0e5; core::Vec3d velocityProjection; @@ -58,7 +58,7 @@ void PenaltyContactFemToStatic::computeUnilateralContactForces() femSceneObject->setContactForcesToZero(); core::Vec3d force; - for (int i = 0; i < contactInfo.size(); i++) + for (size_t i = 0; i < contactInfo.size(); i++) { nodeDofID = 3 * contactInfo[i]->index; velocityProjection = femSceneObject->getVelocityOfNodeWithDofID(nodeDofID); diff --git a/src/ContactHandling/UnitTests/CMakeLists.txt b/src/ContactHandling/UnitTests/CMakeLists.txt index f2090752c1988b612e38dbf9385c211339a5fd86..3890eb716c65c64a2a07e28edf8539e96436f136 100644 --- a/src/ContactHandling/UnitTests/CMakeLists.txt +++ b/src/ContactHandling/UnitTests/CMakeLists.txt @@ -5,7 +5,7 @@ add_executable(${Module}UnitTestRunner PenaltyContactHandlingSpec.cpp ) -target_compile_options(${Module}UnitTestRunner PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast>) +target_compile_options(${Module}UnitTestRunner PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast -Wno-multichar -Wno-type-limits>) target_link_libraries(${Module}UnitTestRunner Collision diff --git a/src/Core/CollisionDetection.h b/src/Core/CollisionDetection.h index 1a75e8b116e2c333ab675b16929c948ca285d40c..ba3251a675362d9d7c789f27e7e8ddede5b2e69d 100644 --- a/src/Core/CollisionDetection.h +++ b/src/Core/CollisionDetection.h @@ -30,7 +30,7 @@ // SimMedTK includes #include "CoreClass.h" -class smMesh; +class Mesh; class CollisionPair; /// \brief Base class to calculate contact information between two meshes diff --git a/src/Core/CollisionPair.h b/src/Core/CollisionPair.h index 7351b2a09f959c40be112fcc41a771f9b4e9d643..53921fa2979af8a66d298b4d800418224ec22878 100644 --- a/src/Core/CollisionPair.h +++ b/src/Core/CollisionPair.h @@ -45,7 +45,8 @@ public: const core::Vec3d& p, const int ind, const core::Vec3d& contactNornmal - ) : depth(penetrationDepth), point(p), index(ind), normal(contactNornmal){} + ) : + depth(penetrationDepth), point(p), normal(contactNornmal), index(ind){} void printInfo() { diff --git a/src/Core/ContactHandling.h b/src/Core/ContactHandling.h index f8aab6aeceb5e4862a3eae5a456a6faae610a1f5..06fe333426f7fe9d09eca9be1bbd3e0b39ee6748 100644 --- a/src/Core/ContactHandling.h +++ b/src/Core/ContactHandling.h @@ -31,7 +31,7 @@ // STL includes #include <memory> -class smMesh; +class Mesh; class CollisionPair; enum class ContactHandlingType diff --git a/src/Core/CoreClass.cpp b/src/Core/CoreClass.cpp index 7f0d761550b8bf83022fd35d33c44b55b9820ce9..76b2b09a431be3517269c041616c45b50b17beee 100644 --- a/src/Core/CoreClass.cpp +++ b/src/Core/CoreClass.cpp @@ -26,8 +26,8 @@ #include "EventHandler.h" #include "RenderDelegate.h" -std::shared_ptr<mstk::Event::smEventHandler> -CoreClass::eventHandler = std::make_shared<mstk::Event::smEventHandler>(); +std::shared_ptr<core::EventHandler> +CoreClass::eventHandler = std::make_shared<core::EventHandler>(); CoreClass::CoreClass() : name(""), listening(false) @@ -70,12 +70,12 @@ void CoreClass::print() const std::cout << "Default print" << std::endl; } -void CoreClass::handleEvent(std::shared_ptr< mstk::Event::Event > event) +void CoreClass::handleEvent(std::shared_ptr< core::Event > event) { std::cout << "Default handleEvent" << std::endl; std::cout << "Sender " << int(event->getSender()) << std::endl; std::cout << "Priority " << int(event->getPriority()) << std::endl; - std::cout << "Type " << int(mstk::Event::Event::EventName) << std::endl; + std::cout << "Type " << int(core::Event::EventName) << std::endl; } void CoreClass::setName( const std::string &p_objectName ) diff --git a/src/Core/CoreClass.h b/src/Core/CoreClass.h index 655b970cd4a368a67489a9e46e92a749020446aa..c5cf3365d6fe0af3ddae874fdd23231f9c65b5c5 100644 --- a/src/Core/CoreClass.h +++ b/src/Core/CoreClass.h @@ -40,7 +40,7 @@ class SDK; class CoreClass; class RenderDelegate; class ObjectSimulator; -class smViewer; +class Viewer; /// \brief simulator calls object and sends this structure struct smSimulationParam @@ -75,7 +75,7 @@ class CoreClass : public std::enable_shared_from_this<CoreClass> public: using Pointer = std::shared_ptr<CoreClass>; - static std::shared_ptr<mstk::Event::smEventHandler> eventHandler; + static std::shared_ptr<core::EventHandler> eventHandler; public: /// @@ -128,7 +128,7 @@ public: /// This function is called by the event handler after observing /// events. /// - virtual void handleEvent(std::shared_ptr<mstk::Event::Event>); + virtual void handleEvent(std::shared_ptr<core::Event>); /// /// \brief set the name of object @@ -178,20 +178,20 @@ public: /// \brief Event index used by the event handler to unregister event observers /// \return eventIndex /// - const mstk::Event::smEventHandler::FunctionContainerType::iterator - &getEventIndex(const mstk::Event::EventType &eventType) const + const core::EventHandler::FunctionContainerType::iterator + &getEventIndex(const core::EventType &eventType) const { return eventIndexMap.at(eventType); } /// /// \brief Set event index used by the event handler to unregister event observers /// - void setEventIndex(const mstk::Event::EventType &eventType, mstk::Event::smEventHandler::FunctionContainerType::iterator index) + void setEventIndex(const core::EventType &eventType, core::EventHandler::FunctionContainerType::iterator index) { eventIndexMap[eventType] = index; } /// /// \brief Set event index used by the event handler to unregister event observers /// - void removeEventIndex(const mstk::Event::EventType &eventType) + void removeEventIndex(const core::EventType &eventType) { eventIndexMap.erase(eventType); } /// @@ -215,7 +215,7 @@ public: std::shared_ptr<RenderDelegate> getRenderDelegate() const; void setRenderDelegate(std::shared_ptr<RenderDelegate> delegate); - void attachEvent(const mstk::Event::EventType &eventType, std::shared_ptr<CoreClass> component) + void attachEvent(const core::EventType &eventType, std::shared_ptr<CoreClass> component) { eventHandler->attachEvent(eventType,component); } @@ -236,8 +236,8 @@ protected: std::string name; ///< name of the class bool listening; ///< parameter to determine if this object is listening for events std::map< - mstk::Event::EventType, - mstk::Event::smEventHandler::FunctionContainerType::iterator> eventIndexMap; + core::EventType, + core::EventHandler::FunctionContainerType::iterator> eventIndexMap; std::shared_ptr<RenderDelegate> renderDelegate; ///!< Class that can render this class private: diff --git a/src/Core/Event.cpp b/src/Core/Event.cpp index c9dd4e7230e39e9dbcb9c0094b2a04b78e589c2c..465b4730a4800c9a2def402ec1e1612023cde8e6 100644 --- a/src/Core/Event.cpp +++ b/src/Core/Event.cpp @@ -23,8 +23,7 @@ #include "Event.h" -namespace mstk { -namespace Event { +namespace core { EventType Event::EventName = EventType::None; @@ -57,6 +56,5 @@ const bool& Event::getEnabled() return this->enabled; } -} // Event namespace -} // mstk namespace +} // core namespace diff --git a/src/Core/Event.h b/src/Core/Event.h index 6406b717662ec66515fc5d9eb87c4f5f1248de6c..7e264561af119e99edacf72bcc249d38a63da9c1 100644 --- a/src/Core/Event.h +++ b/src/Core/Event.h @@ -27,8 +27,7 @@ // STL includes #include <memory> -namespace mstk { -namespace Event { +namespace core { enum class EventType { @@ -101,7 +100,6 @@ private: bool enabled; // allows to disable this event }; -} // Event namespace -} // mstk namespace +} // core namespace #endif // SMEVENT_H diff --git a/src/Core/EventHandler.cpp b/src/Core/EventHandler.cpp index 085ec254493cc6134115d00c262800a109f646be..0775c3490b55e53e23a3f0bcc0ef5742cae533f0 100644 --- a/src/Core/EventHandler.cpp +++ b/src/Core/EventHandler.cpp @@ -24,10 +24,9 @@ #include "EventHandler.h" #include "CoreClass.h" -namespace mstk { -namespace Event { +namespace core { -void smEventHandler::attachEvent(const EventType& eventType, std::shared_ptr<CoreClass> component) +void EventHandler::attachEvent(const EventType& eventType, std::shared_ptr<CoreClass> component) { // Bind handleEvent to a void(std::shared_ptr<Event>) function std::function<void(std::shared_ptr<Event>)> @@ -39,20 +38,20 @@ void smEventHandler::attachEvent(const EventType& eventType, std::shared_ptr<Cor // Add index to the component observer component->setEventIndex(eventType,index); } -void smEventHandler::detachEvent(const EventType& eventType, std::shared_ptr<CoreClass> component) +void EventHandler::detachEvent(const EventType& eventType, std::shared_ptr<CoreClass> component) { auto index = component->getEventIndex(eventType); this->unregisterEvent(eventType,index); component->removeEventIndex(eventType); } -bool smEventHandler::isAttached(const EventType& eventType, std::shared_ptr<CoreClass> component) +bool EventHandler::isAttached(const EventType& eventType, std::shared_ptr<CoreClass> component) { auto index = component->getEventIndex(eventType); return this->isAttached(eventType,index); } -bool smEventHandler::isAttached(const EventType& eventType, - smEventHandler::FunctionContainerType::iterator index) +bool EventHandler::isAttached(const EventType& eventType, + EventHandler::FunctionContainerType::iterator index) { auto i = observers.find(eventType); @@ -72,5 +71,4 @@ bool smEventHandler::isAttached(const EventType& eventType, return false; } -} // Event namespace -} // mstk namespace +} // core namespace diff --git a/src/Core/EventHandler.h b/src/Core/EventHandler.h index 65666f2107562e12503f759a7b910ec4877ae07c..df278eca0199c76471259e4c1dc27b9f026b1a00 100644 --- a/src/Core/EventHandler.h +++ b/src/Core/EventHandler.h @@ -37,8 +37,7 @@ class CoreClass; -namespace mstk { -namespace Event { +namespace core { /// /// @brief Event handler. This class implement a generic observer design @@ -47,11 +46,11 @@ namespace Event { /// https://juanchopanzacpp.wordpress.com/2013/02/24/simple-observer-pattern-implementation-c11/ /// /// The only requirement is that the observer function to bind has -/// the following signature: void handleEvent(std::shared_ptr<mstk::Event::Event> e) +/// the following signature: void handleEvent(std::shared_ptr<core::Event> e) /// This means that anything inheriting from the CoreClass can be /// binded to an event. /// -class smEventHandler +class EventHandler { public: using FunctionType = std::function<void ( std::shared_ptr<Event> )>; @@ -61,7 +60,7 @@ public: /// /// @brief Construct and initilize map /// - smEventHandler() : observers() {} + EventHandler() : observers() {} /// /// @brief Register event and function eventhandler @@ -145,7 +144,6 @@ private: // to be triggered }; -} // Event namespace -} // mstk namespace +} // core namespace #endif // SMEVENTHANDLER_H diff --git a/src/Core/Factory.h b/src/Core/Factory.h index 82e14e76c57d37d73b2e72cafc625bcafd010e28..20774872c2e0a705bcae51bda74019a0674a90bb 100644 --- a/src/Core/Factory.h +++ b/src/Core/Factory.h @@ -32,11 +32,11 @@ * before the first registration call is made. * * A more specific example is the way the smRendering library - * registers the smViewer class as a concrete child of ViewerBase: + * registers the Viewer class as a concrete child of ViewerBase: * <pre> * SIMMEDTK_BEGIN_DYNAMIC_LOADER() * SIMMEDTK_BEGIN_ONLOAD(register_viewer_children) - * SIMMEDTK_REGISTER_CLASS(CoreClass,ViewerBase,smViewer,0); + * SIMMEDTK_REGISTER_CLASS(CoreClass,ViewerBase,Viewer,0); * SIMMEDTK_FINISH_ONLOAD() * SIMMEDTK_FINISH_DYNAMIC_LOADER() * </pre> diff --git a/src/Core/Geometry.h b/src/Core/Geometry.h index d40c07ec335e50b880c8ed815bfc60d0cd1fac20..b4dc99d7d0cb613d606986b47bef3782fb32fcf6 100644 --- a/src/Core/Geometry.h +++ b/src/Core/Geometry.h @@ -240,7 +240,7 @@ public: center += t; } - void rotate(const Matrix33d &rot) + void rotate(const Matrix33d &/*rot*/) { //Its a sphere! nothing to be done. } diff --git a/src/Core/IOStream.cpp b/src/Core/IOStream.cpp index a36abef6d1e2abdd0bef23140fec91fec973aaf9..03f10a12919408640c421d77a44d66490867dc85 100644 --- a/src/Core/IOStream.cpp +++ b/src/Core/IOStream.cpp @@ -174,7 +174,7 @@ smWindowConsole::smWindowConsole(int p_totalTexts) { init(p_totalTexts); backGroundColor.setValue(1.0, 1.0, 1.0, 0.15); - this->eventHanlder->attachEvent(mstk::Event::EventType::Keyboard,shared_from_this()); + this->eventHanlder->attachEvent(core::EventType::Keyboard,shared_from_this()); left = 0.0; bottom = 0.0; right = 1.0; diff --git a/src/Core/IOStream.h b/src/Core/IOStream.h index c813376b615ca3ea96b6c7ae8b3b2a2793908ac4..45d4eb5e2f035a416db35f22bd9e4a0df8860105 100644 --- a/src/Core/IOStream.h +++ b/src/Core/IOStream.h @@ -37,12 +37,10 @@ #define SM_WINDOW_MAXSTRINGSIZE 255 #define SM_WINDOW_TOTALSTRINGS_ONWINDOW 100 -namespace mstk { -namespace Event { +namespace core { class Event; - class smEventHandler; - class smCameraEvent; - } + class EventHandler; + class CameraEvent; } /// \brief I/O stream @@ -52,7 +50,7 @@ public: virtual IOStream& operator >>(std::string &p_string) = 0; virtual IOStream& operator <<(std::string p_string) = 0; protected: - std::shared_ptr<mstk::Event::smEventHandler> eventHanlder; + std::shared_ptr<core::EventHandler> eventHanlder; }; /// \brief console stream; for printing text on the console @@ -134,7 +132,7 @@ public: bool removeText(std::string p_tag); /// \brief handle events - virtual void handleEvent(std::shared_ptr<mstk::Event::Event> /*p_event*/) override {} + virtual void handleEvent(std::shared_ptr<core::Event> /*p_event*/) override {} protected: /// \brief fonts diff --git a/src/Core/Matrix.h b/src/Core/Matrix.h index d9c313a05f1fae236227032fc434a31bce6faf94..ee3e491fda07bc1623c5b51ec4bb3d8a1f12a8f2 100644 --- a/src/Core/Matrix.h +++ b/src/Core/Matrix.h @@ -97,21 +97,21 @@ using Matrixf = Matrix<float>; /// A dynamic size matrix of doubles using Matrixd = Matrix<double>; -// template<typename T, int StorageType> -// void fillSparseMatrix(const std::vector<Eigen::Triplet<T>> &triplets, Eigen::SparseMatrix<T,StorageType> &A) -// { -// A.setFromTriplets(triplets.begin(),triplets.end()); -// } -// -// template<typename T, int StorageType, int opt> -// void solveSparseSystemCholesky(const Eigen::SparseMatrix<T,StorageType> &A, -// const Eigen::Matrix<T, Eigen::Dynamic, 1, opt> &b, -// Eigen::Matrix<T, Eigen::Dynamic, 1, opt> &x) -// { -// // Solving: -// Eigen::SimplicialCholesky<Eigen::SparseMatrix<T,StorageType>> solver(A); // performs a Cholesky factorization of A -// x = solver.solve(b); // use the factorization to solve for the given right hand side -// } +template<typename T, int StorageType> +void fillSparseMatrix(const std::vector<Eigen::Triplet<T>> &triplets, Eigen::SparseMatrix<T,StorageType> &A) +{ + A.setFromTriplets(triplets.begin(),triplets.end()); +} + +template<typename T, int StorageType, int opt> +void solveSparseSystemCholesky(const Eigen::SparseMatrix<T,StorageType> &A, + const Eigen::Matrix<T, Eigen::Dynamic, 1, opt> &b, + Eigen::Matrix<T, Eigen::Dynamic, 1, opt> &x) +{ + // Solving: + Eigen::SimplicialCholesky<Eigen::SparseMatrix<T,StorageType>> solver(A); // performs a Cholesky factorization of A + x = solver.solve(b); // use the factorization to solve for the given right hand side +} // WARNING: The input matrix A should be in a compressed and column-major form. Otherwise an expensive copy will be made. // template<typename T, int StorageType, int opt> diff --git a/src/Core/ModelRepresentation.h b/src/Core/ModelRepresentation.h index 41d822db686852d5aa5ee4e5831a3702588ec6c1..f5a370ec66b69a8df69b5bfc675df4fb7e3748e5 100644 --- a/src/Core/ModelRepresentation.h +++ b/src/Core/ModelRepresentation.h @@ -31,7 +31,7 @@ #include "CoreClass.h" #include "Mesh/Mesh.h" -class smMesh; +class Mesh; class ModelRepresentation { @@ -39,7 +39,7 @@ public: ModelRepresentation(){} ~ModelRepresentation(){} - virtual std::shared_ptr<smMesh> getMesh(){ std::shared_ptr<smMesh> s; return s; } + virtual std::shared_ptr<Mesh> getMesh(){ std::shared_ptr<Mesh> s; return s; } virtual std::shared_ptr<CoreClass> getObject(){ std::shared_ptr<CoreClass> s; return s; } virtual void draw(){} }; diff --git a/src/Core/SDK.cpp b/src/Core/SDK.cpp index 2e98a24c4e0098502ad2e7a644817580bcf71621..8f58005ce179b184f5eb9e5dbc3a14d68c9334ad 100644 --- a/src/Core/SDK.cpp +++ b/src/Core/SDK.cpp @@ -270,7 +270,7 @@ void SDK::terminateAll() } /// \brief register functions -int SDK::registerMesh(std::shared_ptr<smBaseMesh> p_mesh) +int SDK::registerMesh(std::shared_ptr<BaseMesh> p_mesh) { MeshHolder mh; mh.mesh = p_mesh; diff --git a/src/Core/SDK.h b/src/Core/SDK.h index 1067899565bfac560eeff75ccf905b5989342252..403b922da47fda0c7eb806dba408c9ea122ec0c4 100644 --- a/src/Core/SDK.h +++ b/src/Core/SDK.h @@ -62,7 +62,7 @@ struct MeshHolder mesh = NULL; } - std::shared_ptr<smBaseMesh> mesh; + std::shared_ptr<BaseMesh> mesh; inline bool operator ==(MeshHolder &p_param) { @@ -232,7 +232,7 @@ public: void removeRef(std::shared_ptr<CoreClass> p_coreClass); /// \brief register functions - int registerMesh(std::shared_ptr<smBaseMesh> p_mesh); + int registerMesh(std::shared_ptr<BaseMesh> p_mesh); int registerModule(std::shared_ptr<Module> p_mod); diff --git a/src/Core/Scene.h b/src/Core/Scene.h index 4c38f131914060b09cf27ce0b1e563796ed5469c..545418f2c79b83ba9c51efac3e48426e1b0f09c2 100644 --- a/src/Core/Scene.h +++ b/src/Core/Scene.h @@ -130,12 +130,12 @@ public: void setLightPos(int p_lightId, smLightPos p_pos, core::Vec3d p_direction); - std::shared_ptr<smCamera> getCamera() + std::shared_ptr<Camera> getCamera() { return camera; } - void addCamera(std::shared_ptr<smCamera> sceneCamera) + void addCamera(std::shared_ptr<Camera> sceneCamera) { camera = sceneCamera; } @@ -144,7 +144,7 @@ public: void copySceneToLocal(SceneLocal &p_local); private: - std::shared_ptr<smCamera> camera; //Camera for the scene + std::shared_ptr<Camera> camera; //Camera for the scene std::vector<std::shared_ptr<Light> > lights; //Lights in the scene std::vector<std::shared_ptr<SceneObject>> sceneObjects; // scene objects storage std::shared_ptr<ErrorLog> log; // error logging diff --git a/src/Core/SceneObject.h b/src/Core/SceneObject.h index 8099fd8b37619baf08bf829068bae16dfa97105d..f252a0897719ec33c68bb217a756bda9ece7b635 100644 --- a/src/Core/SceneObject.h +++ b/src/Core/SceneObject.h @@ -53,7 +53,7 @@ class SceneObject : public CoreClass { friend class SDK; friend class ViewerBase; - friend class smViewer; + friend class Viewer; friend class Scene; friend class ObjectSimulator; diff --git a/src/Core/StaticSceneObject.cpp b/src/Core/StaticSceneObject.cpp index fc63f05ed8253809a36b1d0dee3a1ea8bc0da153..2cb9eadab2517c447cbf6e7de1d51cf9bc7c90b3 100644 --- a/src/Core/StaticSceneObject.cpp +++ b/src/Core/StaticSceneObject.cpp @@ -24,7 +24,7 @@ #include "StaticSceneObject.h" #include "Factory.h" -StaticSceneObject::StaticSceneObject(std::shared_ptr<ErrorLog> p_log) : SceneObject() +StaticSceneObject::StaticSceneObject(std::shared_ptr<ErrorLog> /*p_log*/) : SceneObject() { type = core::ClassType::StaticSceneObject; @@ -55,7 +55,7 @@ void StaticSceneObject::loadInitialStates() { } -bool StaticSceneObject::configure(const std::string ConfigFile) +bool StaticSceneObject::configure(const std::string /*ConfigFile*/) { return false; } diff --git a/src/Core/StaticSceneObject.h b/src/Core/StaticSceneObject.h index e80d9fa0fc43e188e801eff8fba1cad38a394930..037e321ab6087aa51b477265bfaafb51baaf2d4e 100644 --- a/src/Core/StaticSceneObject.h +++ b/src/Core/StaticSceneObject.h @@ -32,11 +32,9 @@ #include "CoreClass.h" #include "ModelRepresentation.h" -namespace mstk{ -namespace Event{ +namespace core { class Event; } -} /// \brief static scene object class StaticSceneObject: public SceneObject @@ -69,7 +67,7 @@ public: void printInfo() const override; - virtual void handleEvent(std::shared_ptr<mstk::Event::Event>) override {} + virtual void handleEvent(std::shared_ptr<core::Event>) override {} void setModel(std::shared_ptr<ModelRepresentation> model); diff --git a/src/Core/UnitTests/CMakeLists.txt b/src/Core/UnitTests/CMakeLists.txt index d364e495c5b35c643beb0fe412d90a833242eee3..24cb8c0134c730a43e2c021d5c771879a6c88338 100644 --- a/src/Core/UnitTests/CMakeLists.txt +++ b/src/Core/UnitTests/CMakeLists.txt @@ -5,6 +5,6 @@ add_executable(${Module}UnitTestRunner Factory.cpp ) -target_compile_options(${Module}UnitTestRunner PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast>) +target_compile_options(${Module}UnitTestRunner PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast -Wno-multichar -Wno-type-limits>) target_link_libraries(${Module}UnitTestRunner Core) simple_test(${Module} --reporter=spec) diff --git a/src/Core/Utils.h b/src/Core/Utils.h index ac17d605ec409c8823ff533e45d1579e96430f3f..4872673bd8674639931724c5db620039ab539f9e 100644 --- a/src/Core/Utils.h +++ b/src/Core/Utils.h @@ -25,11 +25,11 @@ #define SMUTILS_H /// \brief query, logs and diplays opengl error -#define SM_CHECKGLERROR_DISPLAY(log,error) smGLUtils::queryGLError(error);\ +#define SM_CHECKGLERROR_DISPLAY(log,error) GLUtils::queryGLError(error);\ log->addError(error);\ log->printLastErrUnsafe();\ /// \brief query, logs opengl error -#define SM_CHECKERROR(log,error) smGLUtils::queryGLError(error);\ +#define SM_CHECKERROR(log,error) GLUtils::queryGLError(error);\ log->addError(error);\ #endif diff --git a/src/Core/ViewerBase.h b/src/Core/ViewerBase.h index d7a465ced9125478b5f13130b0a7aba64e108d76..af94e408c27fe084adb2a4dcc4647bcb4444b7a8 100644 --- a/src/Core/ViewerBase.h +++ b/src/Core/ViewerBase.h @@ -35,9 +35,9 @@ // Forward declaration class SDK; class smOpenGLWindowStream; -class smMetalShader; -class smSceneTextureShader; -class smFrameBuffer; +class MetalShader; +class SceneTextureShader; +class FrameBuffer; class Texture; enum smRenderingStageType @@ -59,7 +59,7 @@ struct RenderOperation { RenderOperation(); std::shared_ptr<Scene> scene; ///< The scene full of objects to render - smFrameBuffer *fbo; ///< Only required if rendering to FBO, specifies the FBO to render to + FrameBuffer *fbo; ///< Only required if rendering to FBO, specifies the FBO to render to std::string fboName; ///< Only required if rendering to FBO, named reference to look up the FBO pointer smRenderTargetType target; ///< Specifies where the rendered result should be placed see smRenderTargetType }; @@ -67,7 +67,7 @@ struct RenderOperation struct FboListItem { std::string fboName; ///< String identification - smFrameBuffer* fbo; ///< The FBO pointer + FrameBuffer* fbo; ///< The FBO pointer Texture *depthTex; ///< The FBO depth texture pointer Texture *colorTex; ///< The FBO color texture pointer unsigned int width; ///< The width of the FBO diff --git a/src/Devices/ADUInterface.h b/src/Devices/ADUInterface.h index b6238d8c608d3d32c381435bb8d8d103b9d60240..cd753779ec6c1755e6096c38a102126c5cdb76a8 100644 --- a/src/Devices/ADUInterface.h +++ b/src/Devices/ADUInterface.h @@ -104,7 +104,7 @@ public: void run() override; /// \brief - void handleEvent(std::shared_ptr<mstk::Event::Event> event) override{}; + void handleEvent(std::shared_ptr<core::Event> event) override{}; public: // smPipe *ADUpipe; ///< !! diff --git a/src/Devices/Audio.h b/src/Devices/Audio.h index 4d1f1aa47e121e7e41f88dcd527291c9f824f948..bc05ff814512f4eeeee295652ff8f60cf837f617 100644 --- a/src/Devices/Audio.h +++ b/src/Devices/Audio.h @@ -41,8 +41,8 @@ private: std::shared_ptr<ErrorLog> log; ///< log for errors std::string referenceName; ///< A human readable string to refer to the object - mstk::Event::AudioState state; ///< state of audio - mstk::Event::AudioState prevState; ///< state of audio in previous cycle + event::AudioEvent::AudioState state; ///< state of audio + event::AudioEvent::AudioState prevState; ///< state of audio in previous cycle float prevVolume; ///< state of audio volume in previous cycle float volume; ///< volume (max volume is 1.0) bool loop; ///< play the song in a loop @@ -50,10 +50,10 @@ private: public: Audio() : referenceName(""), - state{mstk::Event::AudioState::Unknown }, - prevState{mstk::Event::AudioState::Unknown }, - volume{1.0}, + state{event::AudioEvent::AudioState::Unknown }, + prevState{event::AudioEvent::AudioState::Unknown }, prevVolume{1.0}, + volume{1.0}, loop{false} { } @@ -61,7 +61,7 @@ public: /// \brief constructor initialize various states Audio(const std::string& fileName, const std::string& p_referenceName, - ErrorLog *p_log = nullptr, + ErrorLog */*p_log*/, bool p_loop = false) : referenceName(p_referenceName), loop(p_loop) @@ -71,7 +71,7 @@ public: assert(false); } - prevState = state = mstk::Event::AudioState::Stop; + prevState = state = event::AudioEvent::AudioState::Stop; volume = prevVolume = 1.0f; } @@ -120,16 +120,16 @@ public: } /// \brief set the state of audio and continue playing - void setState(mstk::Event::AudioState p_state) + void setState(event::AudioEvent::AudioState p_state) { assert("" != referenceName); switch (state) { - case mstk::Event::AudioState::Play: + case event::AudioEvent::AudioState::Play: this->play(); break; - case mstk::Event::AudioState::Stop: + case event::AudioEvent::AudioState::Stop: this->stop(); break; default: diff --git a/src/Devices/NIUSB6008Interface.h b/src/Devices/NIUSB6008Interface.h index 64d6e8b4e10a0e026650df718c2a7778e70645dd..1fe9162b6fea39fd0060bdb337f3096a91e1673f 100644 --- a/src/Devices/NIUSB6008Interface.h +++ b/src/Devices/NIUSB6008Interface.h @@ -97,7 +97,7 @@ public: void run(); /// \brief handle event related to NIUSB6008 device - void handleEvent(std::shared_ptr<mstk::Event::Event> event) override + void handleEvent(std::shared_ptr<core::Event> event) override { }; diff --git a/src/Devices/PhantomInterface.cpp b/src/Devices/PhantomInterface.cpp index f407fa7c94355f539994e055ff5c75b149ea89b3..0cabf9ff33f017307f29bb25c8afd28feb0d4c26 100644 --- a/src/Devices/PhantomInterface.cpp +++ b/src/Devices/PhantomInterface.cpp @@ -282,7 +282,7 @@ HDCallbackCode HDCALLBACK hapticCallback(void *pData) } /// \brief -void PhantomInterface::handleEvent(std::shared_ptr<mstk::Event::Event> event) +void PhantomInterface::handleEvent(std::shared_ptr<core::Event> event) { smHapticInEventData *hapticEventData; diff --git a/src/Devices/PhantomInterface.h b/src/Devices/PhantomInterface.h index c6c4af4390814d12cca7abd00a587e8f34337f39..470835aefe3a2239769bcdadcfe1eb1ba416d26a 100644 --- a/src/Devices/PhantomInterface.h +++ b/src/Devices/PhantomInterface.h @@ -99,7 +99,7 @@ public: friend HDCallbackCode HDCALLBACK hapticCallback(void *pData); ///< !! /// \brief handle events related to phantom omni - void handleEvent(std::shared_ptr<mstk::Event::Event> event) override; + void handleEvent(std::shared_ptr<core::Event> event) override; /// \brief initialize (nothing happens) void init() override; diff --git a/src/Event/AudioEvent.cpp b/src/Event/AudioEvent.cpp index eceefc5ac056d9411071fefc11118b2eca0867c5..3adccd52d318add6c2c4d52d3a980085cb2557bd 100644 --- a/src/Event/AudioEvent.cpp +++ b/src/Event/AudioEvent.cpp @@ -23,40 +23,38 @@ #include "AudioEvent.h" -namespace mstk -{ -namespace Event + +namespace event { -EventType smAudioEvent::EventName = EventType::Audio; +core::EventType AudioEvent::EventName = core::EventType::Audio; -smAudioEvent::smAudioEvent(): state(AudioState::Stop), sound(""), volume(-1.0) +AudioEvent::AudioEvent(): state(AudioState::Stop), sound(""), volume(-1.0) { } -void smAudioEvent::setState(const mstk::Event::AudioState& audioState) +void AudioEvent::setState(const AudioState& audioState) { this->state = audioState; } -const mstk::Event::AudioState& smAudioEvent::getState() +const AudioEvent::AudioState& AudioEvent::getState() { return this->state; } -void smAudioEvent::setSound(const std::string& soundStream) +void AudioEvent::setSound(const std::string& soundStream) { this->sound = soundStream; } -const std::string& smAudioEvent::getSound() +const std::string& AudioEvent::getSound() { return this->sound; } -void smAudioEvent::setVolume(const float& volumeScale) +void AudioEvent::setVolume(const float& volumeScale) { this->volume = volumeScale; } -const float& smAudioEvent::getVolume() +const float& AudioEvent::getVolume() { return this->volume; } } -} diff --git a/src/Event/AudioEvent.h b/src/Event/AudioEvent.h index 3fef6f40fe37545e64ac73d4ff9b6106ef197ec5..1d291f0dea82bd44ce44d67ebbe9146aa2b5db7d 100644 --- a/src/Event/AudioEvent.h +++ b/src/Event/AudioEvent.h @@ -30,24 +30,22 @@ // SimMedTK includes #include "Core/Event.h" -namespace mstk { -namespace Event { +namespace event { -/// \brief contains state of the audio driver -enum class AudioState -{ - Unknown = -1, - Play = 0, - Stop, -}; - -class smAudioEvent: public Event +class AudioEvent: public core::Event { public: - static EventType EventName; + /// \brief contains state of the audio driver + enum class AudioState + { + Unknown = -1, + Play = 0, + Stop, + }; + static core::EventType EventName; public: - smAudioEvent(); + AudioEvent(); void setState(const AudioState &audioState); @@ -67,7 +65,6 @@ private: float volume; }; -} // Event namespace -} // mstk namespace +} // event namespace #endif // SMAUDIOEVENT_H diff --git a/src/Event/CMakeLists.txt b/src/Event/CMakeLists.txt index 2d90529ea402bb36d3d1b21bb285d37793af30bd..1d6a92bd330e6c55273f7c148235c71cfd2bab90 100644 --- a/src/Event/CMakeLists.txt +++ b/src/Event/CMakeLists.txt @@ -20,7 +20,7 @@ simmedtk_add_library(Event target_compile_options(Event PRIVATE - $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast>) + $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast -Wno-multichar -Wno-type-limits>) target_link_libraries(Event PRIVATE diff --git a/src/Event/CameraEvent.cpp b/src/Event/CameraEvent.cpp index ed42edebe1875e54cb21a4d1f4f69f8dacf2008f..513179936821da6a0bb0fb2dc02a802bca4859a4 100644 --- a/src/Event/CameraEvent.cpp +++ b/src/Event/CameraEvent.cpp @@ -23,41 +23,39 @@ #include "CameraEvent.h" -namespace mstk { -namespace Event { +namespace event { -EventType smCameraEvent::EventName = EventType::CameraUpdate; +core::EventType CameraEvent::EventName = core::EventType::CameraUpdate; -smCameraEvent::smCameraEvent() +CameraEvent::CameraEvent() { position = core::Vec3d::Zero(); direction = core::Vec3d::Zero(); upDirection = core::Vec3d::Zero(); } -void smCameraEvent::setPosition(const core::Vec3d& cameraPosition) +void CameraEvent::setPosition(const core::Vec3d& cameraPosition) { this->position = cameraPosition; } -const core::Vec3d& smCameraEvent::getPosition() +const core::Vec3d& CameraEvent::getPosition() { return this->position; } -void smCameraEvent::setDirection(const core::Vec3d& cameraDirection) +void CameraEvent::setDirection(const core::Vec3d& cameraDirection) { this->direction = cameraDirection; } -const core::Vec3d& smCameraEvent::getDirection() +const core::Vec3d& CameraEvent::getDirection() { return this->direction; } -void smCameraEvent::setUpDirection(const core::Vec3d& cameraUpDirection) +void CameraEvent::setUpDirection(const core::Vec3d& cameraUpDirection) { this->upDirection = cameraUpDirection; } -const core::Vec3d& smCameraEvent::getUpDirection() +const core::Vec3d& CameraEvent::getUpDirection() { return this->upDirection; } -} // Event namespace -} // mstk namespace +} // event namespace diff --git a/src/Event/CameraEvent.h b/src/Event/CameraEvent.h index 951fb6f65a95d852f1335da5b9546a4e594e2a4d..212d61c9b9f0a3490b7b5d08a219aed31ede5556 100644 --- a/src/Event/CameraEvent.h +++ b/src/Event/CameraEvent.h @@ -29,16 +29,15 @@ #include "Core/Vector.h" #include "Core/Quaternion.h" -namespace mstk { -namespace Event { +namespace event { -class smCameraEvent : public Event +class CameraEvent : public core::Event { public: - static EventType EventName; + static core::EventType EventName; public: - smCameraEvent(); + CameraEvent(); void setPosition(const core::Vec3d &cameraPosition); @@ -64,7 +63,6 @@ private: core::Vec3d upDirection; // upward direction }; -} // Event namespace -} // mstk namespace +} // event namespace #endif // SMCAMERAEVENT_H diff --git a/src/Event/HapticEvent.cpp b/src/Event/HapticEvent.cpp index a3e9513dfd91b2691ed918a3081ff0a32dcf1af6..daa897935f8507ecbb7901a46a5b025ae739af17 100644 --- a/src/Event/HapticEvent.cpp +++ b/src/Event/HapticEvent.cpp @@ -23,63 +23,61 @@ #include "HapticEvent.h" -namespace mstk { -namespace Event { +namespace event { -EventType smHapticEvent::EventName = EventType::Haptic; +core::EventType HapticEvent::EventName = core::EventType::Haptic; -smHapticEvent::smHapticEvent(const size_t& deviceId, const std::string& deviceName): id(deviceId), name(deviceName) +HapticEvent::HapticEvent(const size_t& deviceId, const std::string& deviceName): id(deviceId), name(deviceName) {} -void smHapticEvent::setPosition(const core::Vec3d& coordinates) +void HapticEvent::setPosition(const core::Vec3d& coordinates) { this->position = coordinates; } -const core::Vec3d& smHapticEvent::getPosition() +const core::Vec3d& HapticEvent::getPosition() { return this->position; } -void smHapticEvent::setVelocity(const core::Vec3d& deviceVelocity) +void HapticEvent::setVelocity(const core::Vec3d& deviceVelocity) { this->velocity = deviceVelocity; } -const core::Vec3d& smHapticEvent::getVelocity() +const core::Vec3d& HapticEvent::getVelocity() { return this->velocity; } -void smHapticEvent::setAngles(const core::Vec3d& deviceAngles) +void HapticEvent::setAngles(const core::Vec3d& deviceAngles) { this->angles = deviceAngles; } -const core::Vec3d& smHapticEvent::getAngles() +const core::Vec3d& HapticEvent::getAngles() { return this->angles; } -const Matrix44d& smHapticEvent::getTransform() +const Matrix44d& HapticEvent::getTransform() { return this->transform; } -void smHapticEvent::setTransform(const Matrix44d& deviceTransform) +void HapticEvent::setTransform(const Matrix44d& deviceTransform) { this->transform = deviceTransform; } -const core::Vec3d& smHapticEvent::getForce() +const core::Vec3d& HapticEvent::getForce() { return this->force; } -void smHapticEvent::setForce(const core::Vec3d& deviceForce) +void HapticEvent::setForce(const core::Vec3d& deviceForce) { this->force = deviceForce; } -const core::Vec3d& smHapticEvent::getTorque() +const core::Vec3d& HapticEvent::getTorque() { return this->torque; } -void smHapticEvent::setTorque(const core::Vec3d& deviceTorque) +void HapticEvent::setTorque(const core::Vec3d& deviceTorque) { this->torque = deviceTorque; } -} // Event namespace -} // mstk namespace +} // event namespace diff --git a/src/Event/HapticEvent.h b/src/Event/HapticEvent.h index d8da483b2c8a76336edd6a5dfd31e5830e7fa3cb..532bccaba2807c61308394f909660302398aed24 100644 --- a/src/Event/HapticEvent.h +++ b/src/Event/HapticEvent.h @@ -33,16 +33,15 @@ #include <Core/Vector.h> #include <Core/Matrix.h> -namespace mstk { -namespace Event { +namespace event { -class smHapticEvent : public Event +class HapticEvent : public core::Event { public: - static EventType EventName; + static core::EventType EventName; public: - smHapticEvent(const size_t &deviceId, const std::string &deviceName); + HapticEvent(const size_t &deviceId, const std::string &deviceName); void setPosition(const core::Vec3d &coordinates); @@ -95,7 +94,6 @@ private: std::array<bool,4> buttonState;//will be chnage later on }; -} // Event namespace -} // mstk namespace +} // event namespace #endif // SMHAPTICEVENT_H diff --git a/src/Event/Key.h b/src/Event/Key.h index ac407e59ea5ed440538c6f5153f36b62c5080753..4bebd07f6dfc5c2c0be1b7721773b3bbeac5a6a7 100755 --- a/src/Event/Key.h +++ b/src/Event/Key.h @@ -26,10 +26,9 @@ #include "Core/Config.h" -namespace mstk { -namespace Event { +namespace event { -enum class smModKey : unsigned int +enum class ModKey : unsigned int { none = 0, control = 1, @@ -38,27 +37,27 @@ enum class smModKey : unsigned int shift = 8 }; -inline smModKey operator|(smModKey a, smModKey b) +inline ModKey operator|(ModKey a, ModKey b) { - return static_cast<smModKey>(static_cast<unsigned int>(a) | static_cast<unsigned int>(b)); + return static_cast<ModKey>(static_cast<unsigned int>(a) | static_cast<unsigned int>(b)); } -inline smModKey operator&(smModKey a, smModKey b) +inline ModKey operator&(ModKey a, ModKey b) { - return static_cast<smModKey>(static_cast<unsigned int>(a) & static_cast<unsigned int>(b)); + return static_cast<ModKey>(static_cast<unsigned int>(a) & static_cast<unsigned int>(b)); } -inline smModKey& operator |=(smModKey& a, smModKey b) +inline ModKey& operator |=(ModKey& a, ModKey b) { return a = a | b; } -inline smModKey& operator &=(smModKey& a, smModKey b) +inline ModKey& operator &=(ModKey& a, ModKey b) { return a = a & b; } -enum class smKey +enum class Key { Unknown = -1, ///< Unhandled key A = 0, ///< The A key @@ -166,7 +165,6 @@ enum class smKey KeyCount ///< Keep last -- the total number of keyboard keys }; -} // Event namespace -} // mstk namespace +} // event namespace #endif diff --git a/src/Event/KeySFMLInterface.h b/src/Event/KeySFMLInterface.h index 3a972508fb439b630f0d929ce0662d0daeacbc32..f9df7b0b4028d26c0673cb8a56265029fc631972 100644 --- a/src/Event/KeySFMLInterface.h +++ b/src/Event/KeySFMLInterface.h @@ -29,120 +29,119 @@ #include <SFML/Window/Keyboard.hpp> #include <map> -namespace mstk { -namespace Event { +namespace event { -static const std::map<int, smKey> sfmlToSmKeyMap = { - {sf::Keyboard::A, smKey::A}, - {sf::Keyboard::B, smKey::B}, - {sf::Keyboard::C, smKey::C}, - {sf::Keyboard::D, smKey::D}, - {sf::Keyboard::E, smKey::E}, - {sf::Keyboard::F, smKey::F}, - {sf::Keyboard::G, smKey::G}, - {sf::Keyboard::H, smKey::H}, - {sf::Keyboard::I, smKey::I}, - {sf::Keyboard::J, smKey::J}, - {sf::Keyboard::K, smKey::K}, - {sf::Keyboard::L, smKey::L}, - {sf::Keyboard::M, smKey::M}, - {sf::Keyboard::N, smKey::N}, - {sf::Keyboard::O, smKey::O}, - {sf::Keyboard::P, smKey::P}, - {sf::Keyboard::Q, smKey::Q}, - {sf::Keyboard::R, smKey::R}, - {sf::Keyboard::S, smKey::S}, - {sf::Keyboard::T, smKey::T}, - {sf::Keyboard::U, smKey::U}, - {sf::Keyboard::V, smKey::V}, - {sf::Keyboard::W, smKey::W}, - {sf::Keyboard::X, smKey::X}, - {sf::Keyboard::Y, smKey::Y}, - {sf::Keyboard::Z, smKey::Z}, - {sf::Keyboard::Num0, smKey::Num0}, - {sf::Keyboard::Num1, smKey::Num1}, - {sf::Keyboard::Num2, smKey::Num2}, - {sf::Keyboard::Num3, smKey::Num3}, - {sf::Keyboard::Num4, smKey::Num4}, - {sf::Keyboard::Num5, smKey::Num5}, - {sf::Keyboard::Num6, smKey::Num6}, - {sf::Keyboard::Num7, smKey::Num7}, - {sf::Keyboard::Num8, smKey::Num8}, - {sf::Keyboard::Num9, smKey::Num9}, - {sf::Keyboard::Escape, smKey::Escape}, - {sf::Keyboard::LControl, smKey::LControl}, - {sf::Keyboard::LShift, smKey::LShift}, - {sf::Keyboard::LAlt, smKey::LAlt}, - {sf::Keyboard::LSystem, smKey::LSystem}, - {sf::Keyboard::RControl, smKey::RControl}, - {sf::Keyboard::RShift, smKey::RShift}, - {sf::Keyboard::RAlt, smKey::RAlt}, - {sf::Keyboard::RSystem, smKey::RSystem}, - {sf::Keyboard::Menu, smKey::Menu}, - {sf::Keyboard::LBracket, smKey::LBracket}, - {sf::Keyboard::RBracket, smKey::RBracket}, - {sf::Keyboard::SemiColon, smKey::SemiColon}, - {sf::Keyboard::Comma, smKey::Comma}, - {sf::Keyboard::Period, smKey::Period}, - {sf::Keyboard::Quote, smKey::Quote}, - {sf::Keyboard::Slash, smKey::Slash}, - {sf::Keyboard::BackSlash, smKey::BackSlash}, - {sf::Keyboard::Tilde, smKey::Tilde}, - {sf::Keyboard::Equal, smKey::Equal}, - {sf::Keyboard::Dash, smKey::Dash}, - {sf::Keyboard::Space, smKey::Space}, - {sf::Keyboard::Return, smKey::Return}, - {sf::Keyboard::BackSpace, smKey::BackSpace}, - {sf::Keyboard::Tab, smKey::Tab}, - {sf::Keyboard::PageUp, smKey::PageUp}, - {sf::Keyboard::PageDown, smKey::PageDown}, - {sf::Keyboard::End, smKey::End}, - {sf::Keyboard::Home, smKey::Home}, - {sf::Keyboard::Insert, smKey::Insert}, - {sf::Keyboard::Delete, smKey::Delete}, - {sf::Keyboard::Add, smKey::Add}, - {sf::Keyboard::Subtract, smKey::Subtract}, - {sf::Keyboard::Multiply, smKey::Multiply}, - {sf::Keyboard::Divide, smKey::Divide}, - {sf::Keyboard::Left, smKey::Left}, - {sf::Keyboard::Right, smKey::Right}, - {sf::Keyboard::Up, smKey::Up}, - {sf::Keyboard::Down, smKey::Down}, - {sf::Keyboard::Numpad0, smKey::Numpad0}, - {sf::Keyboard::Numpad1, smKey::Numpad1}, - {sf::Keyboard::Numpad2, smKey::Numpad2}, - {sf::Keyboard::Numpad3, smKey::Numpad3}, - {sf::Keyboard::Numpad4, smKey::Numpad4}, - {sf::Keyboard::Numpad5, smKey::Numpad5}, - {sf::Keyboard::Numpad6, smKey::Numpad6}, - {sf::Keyboard::Numpad7, smKey::Numpad7}, - {sf::Keyboard::Numpad8, smKey::Numpad8}, - {sf::Keyboard::Numpad9, smKey::Numpad9}, - {sf::Keyboard::F1, smKey::F1}, - {sf::Keyboard::F2, smKey::F2}, - {sf::Keyboard::F3, smKey::F3}, - {sf::Keyboard::F4, smKey::F4}, - {sf::Keyboard::F5, smKey::F5}, - {sf::Keyboard::F6, smKey::F6}, - {sf::Keyboard::F7, smKey::F7}, - {sf::Keyboard::F8, smKey::F8}, - {sf::Keyboard::F9, smKey::F9}, - {sf::Keyboard::F10, smKey::F10}, - {sf::Keyboard::F11, smKey::F11}, - {sf::Keyboard::F12, smKey::F12}, - {sf::Keyboard::F13, smKey::F13}, - {sf::Keyboard::F14, smKey::F14}, - {sf::Keyboard::F15, smKey::F15}, - {sf::Keyboard::Pause, smKey::Pause}, - {sf::Keyboard::Unknown, smKey::Unknown}, +static const std::map<int, Key> sfmlToSmKeyMap = { + {sf::Keyboard::A, Key::A}, + {sf::Keyboard::B, Key::B}, + {sf::Keyboard::C, Key::C}, + {sf::Keyboard::D, Key::D}, + {sf::Keyboard::E, Key::E}, + {sf::Keyboard::F, Key::F}, + {sf::Keyboard::G, Key::G}, + {sf::Keyboard::H, Key::H}, + {sf::Keyboard::I, Key::I}, + {sf::Keyboard::J, Key::J}, + {sf::Keyboard::K, Key::K}, + {sf::Keyboard::L, Key::L}, + {sf::Keyboard::M, Key::M}, + {sf::Keyboard::N, Key::N}, + {sf::Keyboard::O, Key::O}, + {sf::Keyboard::P, Key::P}, + {sf::Keyboard::Q, Key::Q}, + {sf::Keyboard::R, Key::R}, + {sf::Keyboard::S, Key::S}, + {sf::Keyboard::T, Key::T}, + {sf::Keyboard::U, Key::U}, + {sf::Keyboard::V, Key::V}, + {sf::Keyboard::W, Key::W}, + {sf::Keyboard::X, Key::X}, + {sf::Keyboard::Y, Key::Y}, + {sf::Keyboard::Z, Key::Z}, + {sf::Keyboard::Num0, Key::Num0}, + {sf::Keyboard::Num1, Key::Num1}, + {sf::Keyboard::Num2, Key::Num2}, + {sf::Keyboard::Num3, Key::Num3}, + {sf::Keyboard::Num4, Key::Num4}, + {sf::Keyboard::Num5, Key::Num5}, + {sf::Keyboard::Num6, Key::Num6}, + {sf::Keyboard::Num7, Key::Num7}, + {sf::Keyboard::Num8, Key::Num8}, + {sf::Keyboard::Num9, Key::Num9}, + {sf::Keyboard::Escape, Key::Escape}, + {sf::Keyboard::LControl, Key::LControl}, + {sf::Keyboard::LShift, Key::LShift}, + {sf::Keyboard::LAlt, Key::LAlt}, + {sf::Keyboard::LSystem, Key::LSystem}, + {sf::Keyboard::RControl, Key::RControl}, + {sf::Keyboard::RShift, Key::RShift}, + {sf::Keyboard::RAlt, Key::RAlt}, + {sf::Keyboard::RSystem, Key::RSystem}, + {sf::Keyboard::Menu, Key::Menu}, + {sf::Keyboard::LBracket, Key::LBracket}, + {sf::Keyboard::RBracket, Key::RBracket}, + {sf::Keyboard::SemiColon, Key::SemiColon}, + {sf::Keyboard::Comma, Key::Comma}, + {sf::Keyboard::Period, Key::Period}, + {sf::Keyboard::Quote, Key::Quote}, + {sf::Keyboard::Slash, Key::Slash}, + {sf::Keyboard::BackSlash, Key::BackSlash}, + {sf::Keyboard::Tilde, Key::Tilde}, + {sf::Keyboard::Equal, Key::Equal}, + {sf::Keyboard::Dash, Key::Dash}, + {sf::Keyboard::Space, Key::Space}, + {sf::Keyboard::Return, Key::Return}, + {sf::Keyboard::BackSpace, Key::BackSpace}, + {sf::Keyboard::Tab, Key::Tab}, + {sf::Keyboard::PageUp, Key::PageUp}, + {sf::Keyboard::PageDown, Key::PageDown}, + {sf::Keyboard::End, Key::End}, + {sf::Keyboard::Home, Key::Home}, + {sf::Keyboard::Insert, Key::Insert}, + {sf::Keyboard::Delete, Key::Delete}, + {sf::Keyboard::Add, Key::Add}, + {sf::Keyboard::Subtract, Key::Subtract}, + {sf::Keyboard::Multiply, Key::Multiply}, + {sf::Keyboard::Divide, Key::Divide}, + {sf::Keyboard::Left, Key::Left}, + {sf::Keyboard::Right, Key::Right}, + {sf::Keyboard::Up, Key::Up}, + {sf::Keyboard::Down, Key::Down}, + {sf::Keyboard::Numpad0, Key::Numpad0}, + {sf::Keyboard::Numpad1, Key::Numpad1}, + {sf::Keyboard::Numpad2, Key::Numpad2}, + {sf::Keyboard::Numpad3, Key::Numpad3}, + {sf::Keyboard::Numpad4, Key::Numpad4}, + {sf::Keyboard::Numpad5, Key::Numpad5}, + {sf::Keyboard::Numpad6, Key::Numpad6}, + {sf::Keyboard::Numpad7, Key::Numpad7}, + {sf::Keyboard::Numpad8, Key::Numpad8}, + {sf::Keyboard::Numpad9, Key::Numpad9}, + {sf::Keyboard::F1, Key::F1}, + {sf::Keyboard::F2, Key::F2}, + {sf::Keyboard::F3, Key::F3}, + {sf::Keyboard::F4, Key::F4}, + {sf::Keyboard::F5, Key::F5}, + {sf::Keyboard::F6, Key::F6}, + {sf::Keyboard::F7, Key::F7}, + {sf::Keyboard::F8, Key::F8}, + {sf::Keyboard::F9, Key::F9}, + {sf::Keyboard::F10, Key::F10}, + {sf::Keyboard::F11, Key::F11}, + {sf::Keyboard::F12, Key::F12}, + {sf::Keyboard::F13, Key::F13}, + {sf::Keyboard::F14, Key::F14}, + {sf::Keyboard::F15, Key::F15}, + {sf::Keyboard::Pause, Key::Pause}, + {sf::Keyboard::Unknown, Key::Unknown}, }; -inline const smKey& SFMLKeyToSmKey(const int key) +inline const Key& SFMLKeyToSmKey(const int key) { try { - const smKey & out = sfmlToSmKeyMap.at(key) -; return out; + const Key & out = sfmlToSmKeyMap.at(key); + return out; } catch (std::out_of_range &e) { @@ -152,7 +151,6 @@ inline const smKey& SFMLKeyToSmKey(const int key) return sfmlToSmKeyMap.at(sf::Keyboard::Unknown); } -} // Event namespace -} // mstk namespace +} // event namespace #endif diff --git a/src/Event/KeyboardEvent.cpp b/src/Event/KeyboardEvent.cpp index 70868b535df44d9d066f8220ef63d9928db90759..74b24b7edc14ac5315dc040d0f5eaddf6c59013c 100644 --- a/src/Event/KeyboardEvent.cpp +++ b/src/Event/KeyboardEvent.cpp @@ -23,40 +23,38 @@ #include "KeyboardEvent.h" -namespace mstk { -namespace Event { +namespace event { -EventType smKeyboardEvent::EventName = EventType::Keyboard; +core::EventType KeyboardEvent::EventName = core::EventType::Keyboard; -smKeyboardEvent::smKeyboardEvent(const smKey& button) - : pressed(false), key(button), modKey(smModKey::none) +KeyboardEvent::KeyboardEvent(const Key& button) + : pressed(false), key(button), modKey(ModKey::none) { } -const smKey& smKeyboardEvent::getKeyPressed() +const Key& KeyboardEvent::getKeyPressed() { return key; } -void smKeyboardEvent::setPressed(const bool& press) +void KeyboardEvent::setPressed(const bool& press) { this->pressed = press; } -const bool& smKeyboardEvent::getPressed() +const bool& KeyboardEvent::getPressed() { return this->pressed; } -const bool& smKeyboardEvent::togglePressed() +const bool& KeyboardEvent::togglePressed() { return this->pressed = !this->pressed; } -void smKeyboardEvent::setModifierKey(const smModKey& modKey) +void KeyboardEvent::setModifierKey(const ModKey& modKey) { this->modKey = modKey; } -const smModKey& smKeyboardEvent::getModifierKey() +const ModKey& KeyboardEvent::getModifierKey() { return this->modKey; } -} // Event namespace -} // mstk namespace +} // event namespace diff --git a/src/Event/KeyboardEvent.h b/src/Event/KeyboardEvent.h index 5413ddffc33a831cbd373cae70ebb770546448cf..4abc3bc8f7a3f398dc6be9bb240a8d80c3ab3d08 100644 --- a/src/Event/KeyboardEvent.h +++ b/src/Event/KeyboardEvent.h @@ -28,18 +28,17 @@ #include "Core/Event.h" #include "Key.h" -namespace mstk { -namespace Event { +namespace event { -class smKeyboardEvent : public Event +class KeyboardEvent : public core::Event { public: - static EventType EventName; + static core::EventType EventName; public: - smKeyboardEvent(const smKey &button); + KeyboardEvent(const Key &button); - const smKey &getKeyPressed(); + const Key &getKeyPressed(); void setPressed(const bool &press); @@ -47,17 +46,16 @@ public: const bool &togglePressed(); - void setModifierKey(const smModKey &modKey); + void setModifierKey(const ModKey &modKey); - const smModKey &getModifierKey(); + const ModKey &getModifierKey(); private: bool pressed; ///< If the key was pressed or released in this event - smKey key; ///< Key that was pressed - smModKey modKey; ///< Modifier keys. See smModKey for values + Key key; ///< Key that was pressed + ModKey modKey; ///< Modifier keys. See ModKey for values }; -} // Event namespace -} // mstk namespace +} // event namespace #endif // SMKEYBOARDEVENT_H diff --git a/src/Event/LightMotionEvent.cpp b/src/Event/LightMotionEvent.cpp index 1f50718932ad7ce3a30910c982a9c9ab89902792..9d5f58c5f2b5fcf56be27381c97cc8ff420fdca6 100644 --- a/src/Event/LightMotionEvent.cpp +++ b/src/Event/LightMotionEvent.cpp @@ -23,40 +23,38 @@ #include "LightMotionEvent.h" -namespace mstk { -namespace Event { +namespace event { -EventType smLightMotionEvent::EventName = EventType::LightMotion; +core::EventType LightMotionEvent::EventName = core::EventType::LightMotion; -smLightMotionEvent::smLightMotionEvent(const int& lightIndex): index(lightIndex) +LightMotionEvent::LightMotionEvent(const int& lightIndex): index(lightIndex) { position = core::Vec3d::Zero(); direction = core::Vec3d::Zero(); } -void smLightMotionEvent::setPosition(const core::Vec3d& lightPosition) +void LightMotionEvent::setPosition(const core::Vec3d& lightPosition) { this->position = lightPosition; } -const core::Vec3d& smLightMotionEvent::getPosition() +const core::Vec3d& LightMotionEvent::getPosition() { return this->position; } -void smLightMotionEvent::setDirection(const core::Vec3d& lightDirection) +void LightMotionEvent::setDirection(const core::Vec3d& lightDirection) { this->direction = lightDirection; } -const core::Vec3d& smLightMotionEvent::getDirection() +const core::Vec3d& LightMotionEvent::getDirection() { return this->direction; } -void smLightMotionEvent::setLightIndex(const int& lightIndex) +void LightMotionEvent::setLightIndex(const int& lightIndex) { this->index = lightIndex; } -const int& smLightMotionEvent::getLightIndex() +const int& LightMotionEvent::getLightIndex() { return this->index; } -} // Event namespace -} // mstk namespace +} // event namespace diff --git a/src/Event/LightMotionEvent.h b/src/Event/LightMotionEvent.h index a8f265b192905ad364cbff11006066f278a14972..e2fae4ff91fabadd4fd76847570788969ca53f9a 100644 --- a/src/Event/LightMotionEvent.h +++ b/src/Event/LightMotionEvent.h @@ -28,16 +28,15 @@ #include "Core/Event.h" #include <Core/Vector.h> -namespace mstk { -namespace Event { +namespace event { -class smLightMotionEvent : public Event + class LightMotionEvent : public core::Event { public: - static EventType EventName; + static core::EventType EventName; public: - smLightMotionEvent(const int &lightIndex); + LightMotionEvent(const int &lightIndex); void setPosition(const core::Vec3d &lightPosition); @@ -57,7 +56,6 @@ private: core::Vec3d direction; // direction }; -} // Event namespace -} // mstk namespace +} // event namespace #endif // SMLIGHTMOTIONEVENT_H diff --git a/src/Event/MouseButtonEvent.cpp b/src/Event/MouseButtonEvent.cpp index d0ac3c029257237bf2afd0bbd826b809f5ffeda9..ca5f9d477319b2456aa51180c953da325d8e0522 100644 --- a/src/Event/MouseButtonEvent.cpp +++ b/src/Event/MouseButtonEvent.cpp @@ -23,37 +23,35 @@ #include "MouseButtonEvent.h" -namespace mstk { -namespace Event { +namespace event { -EventType smMouseButtonEvent::EventName = EventType::MouseButton; +core::EventType MouseButtonEvent::EventName = core::EventType::MouseButton; -smMouseButtonEvent::smMouseButtonEvent(const smMouseButton& button): pressed(false), mouseButton(button) +MouseButtonEvent::MouseButtonEvent(const MouseButton& button): pressed(false), mouseButton(button) {} -const smMouseButton& smMouseButtonEvent::getMouseButton() +const MouseButton& MouseButtonEvent::getMouseButton() { return mouseButton; } -void smMouseButtonEvent::setPresed(const bool& press) +void MouseButtonEvent::setPresed(const bool& press) { this->pressed = press; } -const bool& smMouseButtonEvent::getPressed() +const bool& MouseButtonEvent::getPressed() { return this->pressed; } -const bool& smMouseButtonEvent::togglePressed() +const bool& MouseButtonEvent::togglePressed() { return this->pressed = !this->pressed; } -void smMouseButtonEvent::setWindowCoord(const core::Vec2d& coordinates) +void MouseButtonEvent::setWindowCoord(const core::Vec2d& coordinates) { this->coord = coordinates; } -const core::Vec2d& smMouseButtonEvent::getWindowCoord() +const core::Vec2d& MouseButtonEvent::getWindowCoord() { return this->coord; } -} // Event namespace -} // mstk namespace +} // event namespace diff --git a/src/Event/MouseButtonEvent.h b/src/Event/MouseButtonEvent.h index 231514766a02caf6fe445705ddfd970927decf84..1aa16cbc25525b7cd7ee956c8acf5b8f24f2087e 100644 --- a/src/Event/MouseButtonEvent.h +++ b/src/Event/MouseButtonEvent.h @@ -28,10 +28,9 @@ #include "Core/Event.h" #include "Core/Vector.h" -namespace mstk { -namespace Event { +namespace event { -enum class smMouseButton +enum class MouseButton { Unknown = -1, Left = 0, @@ -42,15 +41,15 @@ enum class smMouseButton Reset }; -class smMouseButtonEvent : public Event +class MouseButtonEvent : public core::Event { public: - static EventType EventName; + static core::EventType EventName; public: - smMouseButtonEvent(const smMouseButton &button); + MouseButtonEvent(const MouseButton &button); - const smMouseButton &getMouseButton(); + const MouseButton &getMouseButton(); void setPresed(const bool &press); @@ -64,11 +63,10 @@ public: private: bool pressed; // If the button was pressed or released in this event - smMouseButton mouseButton; // Which mouse button was pressed + MouseButton mouseButton; // Which mouse button was pressed core::Vec2d coord; // X,Y coorindate relative to left edge }; -} // Event namespace -} // mstk namespace +} // event namespace #endif // SMMOUSEBUTTONEVENT_H diff --git a/src/Event/MouseMoveEvent.cpp b/src/Event/MouseMoveEvent.cpp index 9bd258c143af03001653edfa92ee38412d9505b7..5b040eb01940406dab7ec2f24adfd44ac44e587a 100644 --- a/src/Event/MouseMoveEvent.cpp +++ b/src/Event/MouseMoveEvent.cpp @@ -23,19 +23,17 @@ #include "MouseMoveEvent.h" -namespace mstk { -namespace Event { +namespace event { -EventType smMouseMoveEvent::EventName = EventType::MouseMove; +core::EventType MouseMoveEvent::EventName = core::EventType::MouseMove; -void smMouseMoveEvent::setWindowCoord(const core::Vec2d& coordinates) +void MouseMoveEvent::setWindowCoord(const core::Vec2d& coordinates) { this->coord = coordinates; } -const core::Vec2d& smMouseMoveEvent::getWindowCoord() +const core::Vec2d& MouseMoveEvent::getWindowCoord() { return this->coord; } -} // Event namespace -} // mstk namespace +} // event namespace diff --git a/src/Event/MouseMoveEvent.h b/src/Event/MouseMoveEvent.h index c20a9599e88dfccf1b59bc56230f677cd1825685..16d27a0d0dc0229fe98d2985ce9de067149708c7 100644 --- a/src/Event/MouseMoveEvent.h +++ b/src/Event/MouseMoveEvent.h @@ -28,13 +28,12 @@ #include "Core/Event.h" #include "Core/Vector.h" -namespace mstk { -namespace Event { +namespace event { -class smMouseMoveEvent : public Event +class MouseMoveEvent : public core::Event { public: - static EventType EventName; + static core::EventType EventName; public: void setWindowCoord(const core::Vec2d &coordinates); @@ -45,7 +44,6 @@ private: core::Vec2d coord; // X,Y coorindate relative to left edge }; -} // Event namespace -} // mstk namespace +} // event namespace #endif // SMMOUSEMOVEEVENT_H diff --git a/src/Event/ObjectClickedEvent.cpp b/src/Event/ObjectClickedEvent.cpp index bc253b521a9d0af94fa9628809e470e47afd6205..2a296fc3c76f18b712151d5814d6592c50d3499f 100644 --- a/src/Event/ObjectClickedEvent.cpp +++ b/src/Event/ObjectClickedEvent.cpp @@ -23,21 +23,19 @@ #include "ObjectClickedEvent.h" -namespace mstk { -namespace Event { +namespace event { -EventType smObjectClickedEvent::EventName = EventType::ObjectClicked; +core::EventType ObjectClickedEvent::EventName = core::EventType::ObjectClicked; -smObjectClickedEvent::smObjectClickedEvent(const size_t& objectId): id(objectId) +ObjectClickedEvent::ObjectClickedEvent(const size_t& objectId): id(objectId) {} -void smObjectClickedEvent::setWindowCoord(const core::Vec3d& coordinates) +void ObjectClickedEvent::setWindowCoord(const core::Vec3d& coordinates) { this->coord = coordinates; } -const core::Vec3d& smObjectClickedEvent::getWindowCoord() +const core::Vec3d& ObjectClickedEvent::getWindowCoord() { return this->coord; } -} // Event namespace -} // mstk namespace +} // event namespace diff --git a/src/Event/ObjectClickedEvent.h b/src/Event/ObjectClickedEvent.h index d9f8a5eefcea4af6c6e7e5bb2c2e91318ccb91ce..de978a77b14a484dc9286ff8fce772b8f78015e0 100644 --- a/src/Event/ObjectClickedEvent.h +++ b/src/Event/ObjectClickedEvent.h @@ -29,16 +29,15 @@ #include "Core/Event.h" #include <Core/Vector.h> -namespace mstk { -namespace Event { +namespace event { -class smObjectClickedEvent : public Event +class ObjectClickedEvent : public core::Event { public: - static EventType EventName; + static core::EventType EventName; public: - smObjectClickedEvent(const size_t &objectId); + ObjectClickedEvent(const size_t &objectId); void setWindowCoord(const core::Vec3d &coordinates); @@ -49,7 +48,6 @@ private: core::Vec3d coord; // position }; -} // Event namespace -} // mstk namespace +} // event namespace #endif // SMOBJECTCLICKEDEVENT_H diff --git a/src/Event/UnitTests/CMakeLists.txt b/src/Event/UnitTests/CMakeLists.txt index c6db2707f31b303bf11e374120ea6afb363135b7..768ef6cbaa0adfba6fe9df4a4bea3cf4406e5e6d 100644 --- a/src/Event/UnitTests/CMakeLists.txt +++ b/src/Event/UnitTests/CMakeLists.txt @@ -5,7 +5,7 @@ add_executable(${Module}UnitTestRunner EventHandlerSpec.cpp ) -target_compile_options(${Module}UnitTestRunner PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast>) +target_compile_options(${Module}UnitTestRunner PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast -Wno-multichar -Wno-type-limits>) target_link_libraries(${Module}UnitTestRunner Collision Core Rendering Mesh Event) diff --git a/src/Event/UnitTests/EventHandlerSpec.cpp b/src/Event/UnitTests/EventHandlerSpec.cpp index df9af8c3041308c8c4d5465d31003c08be1f10de..16ffd2feef45887abe420f8cbf3844bfb4c3df1a 100644 --- a/src/Event/UnitTests/EventHandlerSpec.cpp +++ b/src/Event/UnitTests/EventHandlerSpec.cpp @@ -37,58 +37,59 @@ #include "Event/ObjectClickedEvent.h" using namespace bandit; -using namespace mstk::Event; +using namespace core; +using namespace event; struct MyObserver : public CoreClass { - MyObserver(mstk::Event::EventType _eventType) : success(false), eventType(_eventType) {} + MyObserver(core::EventType _eventType) : success(false), eventType(_eventType) {} void handleEvent(std::shared_ptr<Event> event) override { - std::shared_ptr<smKeyboardEvent> keyboardEvent = std::static_pointer_cast<smKeyboardEvent>(event); - if(keyboardEvent != nullptr && smKeyboardEvent::EventName == eventType) + std::shared_ptr<KeyboardEvent> keyboardEvent = std::static_pointer_cast<KeyboardEvent>(event); + if(keyboardEvent != nullptr && KeyboardEvent::EventName == eventType) { success = true; std::cout << "its a keyboard event..." << std::endl; } - std::shared_ptr<smAudioEvent> audioEvent = std::static_pointer_cast<smAudioEvent>(event); - if(audioEvent != nullptr && smAudioEvent::EventName == eventType) + std::shared_ptr<AudioEvent> audioEvent = std::static_pointer_cast<AudioEvent>(event); + if(audioEvent != nullptr && AudioEvent::EventName == eventType) { success = true; std::cout << "its an audio event..." << std::endl; } - std::shared_ptr<smCameraEvent> cameraEvent = std::static_pointer_cast<smCameraEvent>(event); - if(cameraEvent != nullptr && smCameraEvent::EventName == eventType) + std::shared_ptr<CameraEvent> cameraEvent = std::static_pointer_cast<CameraEvent>(event); + if(cameraEvent != nullptr && CameraEvent::EventName == eventType) { success = true; std::cout << "its a camera event..." << std::endl; } - std::shared_ptr<smHapticEvent> hapticEvent = std::static_pointer_cast<smHapticEvent>(event); - if(hapticEvent != nullptr && smHapticEvent::EventName == eventType) + std::shared_ptr<HapticEvent> hapticEvent = std::static_pointer_cast<HapticEvent>(event); + if(hapticEvent != nullptr && HapticEvent::EventName == eventType) { success = true; std::cout << "its a haptic event..." << std::endl; } - std::shared_ptr<smLightMotionEvent> lightEvent = std::static_pointer_cast<smLightMotionEvent>(event); - if(lightEvent != nullptr && smLightMotionEvent::EventName == eventType) + std::shared_ptr<LightMotionEvent> lightEvent = std::static_pointer_cast<LightMotionEvent>(event); + if(lightEvent != nullptr && LightMotionEvent::EventName == eventType) { success = true; std::cout << "its a light event..." << std::endl; } - std::shared_ptr<smMouseButtonEvent> mouseButtonEvent = std::static_pointer_cast<smMouseButtonEvent>(event); - if(mouseButtonEvent != nullptr && smMouseButtonEvent::EventName == eventType) + std::shared_ptr<MouseButtonEvent> mouseButtonEvent = std::static_pointer_cast<MouseButtonEvent>(event); + if(mouseButtonEvent != nullptr && MouseButtonEvent::EventName == eventType) { success = true; std::cout << "its a mouse button event..." << std::endl; } - std::shared_ptr<smMouseMoveEvent> mouseMoveEvent = std::static_pointer_cast<smMouseMoveEvent>(event); - if(mouseMoveEvent != nullptr && smMouseMoveEvent::EventName == eventType) + std::shared_ptr<MouseMoveEvent> mouseMoveEvent = std::static_pointer_cast<MouseMoveEvent>(event); + if(mouseMoveEvent != nullptr && MouseMoveEvent::EventName == eventType) { success = true; std::cout << "its a mouse button event..." << std::endl; } - std::shared_ptr<smObjectClickedEvent> objectClickedEvent = std::static_pointer_cast<smObjectClickedEvent>(event); - if(objectClickedEvent != nullptr && smObjectClickedEvent::EventName == eventType) + std::shared_ptr<ObjectClickedEvent> objectClickedEvent = std::static_pointer_cast<ObjectClickedEvent>(event); + if(objectClickedEvent != nullptr && ObjectClickedEvent::EventName == eventType) { success = true; std::cout << "its an object clicked event..." << std::endl; @@ -96,91 +97,91 @@ struct MyObserver : public CoreClass } bool success; - mstk::Event::EventType eventType; + core::EventType eventType; }; go_bandit([](){ describe("Event handler", []() { it("constructs ", []() { - std::shared_ptr<smEventHandler> eventHandler = std::make_shared<smEventHandler>(); + std::shared_ptr<EventHandler> eventHandler = std::make_shared<EventHandler>(); AssertThat(eventHandler != nullptr, IsTrue()); }); it("attaches events ", []() { - std::shared_ptr<smEventHandler> eventHandler = std::make_shared<smEventHandler>(); + std::shared_ptr<EventHandler> eventHandler = std::make_shared<EventHandler>(); Event::Pointer event = std::make_shared<Event>(); CoreClass::Pointer observer = std::make_shared<CoreClass>(); - eventHandler->attachEvent(mstk::Event::EventType::Audio,observer); + eventHandler->attachEvent(core::EventType::Audio,observer); - AssertThat(eventHandler->isAttached(mstk::Event::EventType::Audio,observer), IsTrue()); + AssertThat(eventHandler->isAttached(core::EventType::Audio,observer), IsTrue()); }); it("detaches events ", []() { - std::shared_ptr<smEventHandler> eventHandler = std::make_shared<smEventHandler>(); + std::shared_ptr<EventHandler> eventHandler = std::make_shared<EventHandler>(); Event::Pointer event = std::make_shared<Event>(); CoreClass::Pointer observer = std::make_shared<CoreClass>(); - eventHandler->attachEvent(mstk::Event::EventType::Audio,observer); + eventHandler->attachEvent(core::EventType::Audio,observer); - AssertThat(eventHandler->isAttached(mstk::Event::EventType::Audio,observer), IsTrue()); - auto index = observer->getEventIndex(mstk::Event::EventType::Audio); + AssertThat(eventHandler->isAttached(core::EventType::Audio,observer), IsTrue()); + auto index = observer->getEventIndex(core::EventType::Audio); - eventHandler->detachEvent(mstk::Event::EventType::Audio,observer); + eventHandler->detachEvent(core::EventType::Audio,observer); - AssertThat(eventHandler->isAttached(mstk::Event::EventType::Audio,index), IsFalse()); + AssertThat(eventHandler->isAttached(core::EventType::Audio,index), IsFalse()); }); it("dispatches events ", []() { - std::shared_ptr<smEventHandler> eventHandler = std::make_shared<smEventHandler>(); + std::shared_ptr<EventHandler> eventHandler = std::make_shared<EventHandler>(); Event::Pointer event = std::make_shared<Event>(); std::shared_ptr<MyObserver> observer; - observer = std::make_shared<MyObserver>(mstk::Event::EventType::None); - eventHandler->attachEvent(mstk::Event::EventType::None,observer); + observer = std::make_shared<MyObserver>(core::EventType::None); + eventHandler->attachEvent(core::EventType::None,observer); eventHandler->triggerEvent(std::make_shared<Event>()); AssertThat(observer->success, IsFalse()); - observer = std::make_shared<MyObserver>(mstk::Event::EventType::Audio); - eventHandler->attachEvent(mstk::Event::EventType::Audio,observer); - eventHandler->triggerEvent(std::make_shared<smAudioEvent>()); + observer = std::make_shared<MyObserver>(core::EventType::Audio); + eventHandler->attachEvent(core::EventType::Audio,observer); + eventHandler->triggerEvent(std::make_shared<AudioEvent>()); AssertThat(observer->success, IsTrue()); - observer = std::make_shared<MyObserver>(mstk::Event::EventType::Keyboard); - eventHandler->attachEvent(mstk::Event::EventType::Keyboard,observer); - eventHandler->triggerEvent(std::make_shared<smKeyboardEvent>(smKey::A)); + observer = std::make_shared<MyObserver>(core::EventType::Keyboard); + eventHandler->attachEvent(core::EventType::Keyboard,observer); + eventHandler->triggerEvent(std::make_shared<KeyboardEvent>(Key::A)); AssertThat(observer->success, IsTrue()); - observer = std::make_shared<MyObserver>(mstk::Event::EventType::CameraUpdate); - eventHandler->attachEvent(mstk::Event::EventType::CameraUpdate,observer); - eventHandler->triggerEvent(std::make_shared<smCameraEvent>()); + observer = std::make_shared<MyObserver>(core::EventType::CameraUpdate); + eventHandler->attachEvent(core::EventType::CameraUpdate,observer); + eventHandler->triggerEvent(std::make_shared<CameraEvent>()); AssertThat(observer->success, IsTrue()); - observer = std::make_shared<MyObserver>(mstk::Event::EventType::Haptic); - eventHandler->attachEvent(mstk::Event::EventType::Haptic,observer); - eventHandler->triggerEvent(std::make_shared<smHapticEvent>(0,"HapticDevice")); + observer = std::make_shared<MyObserver>(core::EventType::Haptic); + eventHandler->attachEvent(core::EventType::Haptic,observer); + eventHandler->triggerEvent(std::make_shared<HapticEvent>(0,"HapticDevice")); AssertThat(observer->success, IsTrue()); - observer = std::make_shared<MyObserver>(mstk::Event::EventType::LightMotion); - eventHandler->attachEvent(mstk::Event::EventType::LightMotion,observer); - eventHandler->triggerEvent(std::make_shared<smLightMotionEvent>(0)); + observer = std::make_shared<MyObserver>(core::EventType::LightMotion); + eventHandler->attachEvent(core::EventType::LightMotion,observer); + eventHandler->triggerEvent(std::make_shared<LightMotionEvent>(0)); AssertThat(observer->success, IsTrue()); - observer = std::make_shared<MyObserver>(mstk::Event::EventType::MouseButton); - eventHandler->attachEvent(mstk::Event::EventType::MouseButton,observer); - eventHandler->triggerEvent(std::make_shared<smMouseButtonEvent>(smMouseButton::Button0)); + observer = std::make_shared<MyObserver>(core::EventType::MouseButton); + eventHandler->attachEvent(core::EventType::MouseButton,observer); + eventHandler->triggerEvent(std::make_shared<MouseButtonEvent>(MouseButton::Button0)); AssertThat(observer->success, IsTrue()); - observer = std::make_shared<MyObserver>(mstk::Event::EventType::MouseMove); - eventHandler->attachEvent(mstk::Event::EventType::MouseMove,observer); - eventHandler->triggerEvent(std::make_shared<smMouseMoveEvent>()); + observer = std::make_shared<MyObserver>(core::EventType::MouseMove); + eventHandler->attachEvent(core::EventType::MouseMove,observer); + eventHandler->triggerEvent(std::make_shared<MouseMoveEvent>()); AssertThat(observer->success, IsTrue()); - observer = std::make_shared<MyObserver>(mstk::Event::EventType::ObjectClicked); - eventHandler->attachEvent(mstk::Event::EventType::ObjectClicked,observer); - eventHandler->triggerEvent(std::make_shared<smObjectClickedEvent>(0)); + observer = std::make_shared<MyObserver>(core::EventType::ObjectClicked); + eventHandler->attachEvent(core::EventType::ObjectClicked,observer); + eventHandler->triggerEvent(std::make_shared<ObjectClickedEvent>(0)); AssertThat(observer->success, IsTrue()); }); diff --git a/src/External/CMakeLists.txt b/src/External/CMakeLists.txt index c9450848f625365e0ba4b4130cff6e20fd53bbfb..f06007c6786c6db27d345e37a090eea331c00534 100644 --- a/src/External/CMakeLists.txt +++ b/src/External/CMakeLists.txt @@ -1,16 +1,16 @@ simmedtk_add_library(External SOURCES - framebufferObject.cpp - renderbuffer.cpp + FrameBufferObject.cpp + RenderBuffer.cpp PUBLIC_HEADERS - framebufferObject.h - renderbuffer.h + FrameBufferObject.h + RenderBuffer.h ) target_compile_options(External PRIVATE - $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast>) + $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast -Wno-multichar -Wno-type-limits>) target_link_libraries(External PRIVATE diff --git a/src/External/framebufferObject.cpp b/src/External/FrameBufferObject.cpp similarity index 99% rename from src/External/framebufferObject.cpp rename to src/External/FrameBufferObject.cpp index 93ebfea94de959419538bcc33ce6db9d7f2f7029..8eb645b6cc071dde2123fc5473106288220e6e0f 100644 --- a/src/External/framebufferObject.cpp +++ b/src/External/FrameBufferObject.cpp @@ -40,7 +40,7 @@ */ #include <iostream> -#include "External/framebufferObject.h" +#include "FrameBufferObject.h" using namespace std; diff --git a/src/External/framebufferObject.h b/src/External/FrameBufferObject.h similarity index 100% rename from src/External/framebufferObject.h rename to src/External/FrameBufferObject.h diff --git a/src/External/renderbuffer.cpp b/src/External/RenderBuffer.cpp similarity index 98% rename from src/External/renderbuffer.cpp rename to src/External/RenderBuffer.cpp index 47c3c2c4809c066eac12825af713013dcaded1ab..8b47b3cc4b411c69892857071782ef1e29d72fa8 100644 --- a/src/External/renderbuffer.cpp +++ b/src/External/RenderBuffer.cpp @@ -39,7 +39,7 @@ */ #include <iostream> -#include "External/renderbuffer.h" +#include "External/RenderBuffer.h" using namespace std; diff --git a/src/External/renderbuffer.h b/src/External/RenderBuffer.h similarity index 99% rename from src/External/renderbuffer.h rename to src/External/RenderBuffer.h index 552270ed7fd184f6cdd9c38572455d53808e26fb..df118f13efbd2309b3c3c17a0391701fafe22181 100644 --- a/src/External/renderbuffer.h +++ b/src/External/RenderBuffer.h @@ -42,7 +42,7 @@ #define UCDAVIS_RENDER_BUFFER_H #include "Core/Config.h" -#include "framebufferObject.h" +#include "FrameBufferObject.h" /*! Renderbuffer Class. This class encapsulates the Renderbuffer OpenGL diff --git a/src/External/tree.hh b/src/External/tree.hh index 797dd3edda5ced9e220d80c20137c1c1d79bf38a..6258f0d485338271ceefe7413f58605ca2df455e 100644 --- a/src/External/tree.hh +++ b/src/External/tree.hh @@ -1,3 +1,5 @@ +/// WARNING: This file is distributed under the GPL +/// TODO: Removed from the source tree. // STL-like templated tree class. // diff --git a/src/Geometry/MeshModel.cpp b/src/Geometry/MeshModel.cpp index 05008ff084ebea961a5dda4e62dd93104cf769f0..fc17147eac5e9b2f607e352cd4474743148406fa 100644 --- a/src/Geometry/MeshModel.cpp +++ b/src/Geometry/MeshModel.cpp @@ -24,29 +24,29 @@ #include "MeshModel.h" #include "Rendering/TextureManager.h" -smMeshModel::smMeshModel() {} -smMeshModel::~smMeshModel() {} -void smMeshModel::load(const std::string& meshName, const smMeshFileType& type) +MeshModel::MeshModel() {} +MeshModel::~MeshModel() {} +void MeshModel::load(const std::string& meshName, const BaseMesh::MeshFileType& type) { this->mesh.reset(); switch(type) { - case SM_FILETYPE_OBJ: + case BaseMesh::MeshFileType::Obj: { - this->mesh = std::make_shared<smSurfaceMesh>(); + this->mesh = std::make_shared<SurfaceMesh>(); break; } - case SM_FILETYPE_3DS: // TODO: Is this a surface or volume mesh? + case BaseMesh::MeshFileType::ThreeDS: // TODO: Is this a surface or volume mesh? { - this->mesh = std::make_shared<smSurfaceMesh>(); + this->mesh = std::make_shared<SurfaceMesh>(); break; } - case SM_FILETYPE_VOLUME: + case BaseMesh::MeshFileType::Volume: { - this->mesh = std::make_shared<smVolumeMesh>(); + this->mesh = std::make_shared<VolumeMesh>(); break; } @@ -58,11 +58,11 @@ void smMeshModel::load(const std::string& meshName, const smMeshFileType& type) this->mesh->loadMesh(meshName, type); } -const core::Vec3d& smMeshModel::getNormal(size_t i) const +const core::Vec3d& MeshModel::getNormal(size_t i) const { return this->mesh->triNormals[i]; } -std::array<core::Vec3d,3> smMeshModel::getTrianglePositions(size_t i) const +std::array<core::Vec3d,3> MeshModel::getTrianglePositions(size_t i) const { std::array<core::Vec3d, 3> vertices; vertices[0] = this->mesh->vertices[this->mesh->triangles[i].vert[0]]; @@ -71,40 +71,40 @@ std::array<core::Vec3d,3> smMeshModel::getTrianglePositions(size_t i) const return vertices; } -const core::StdVector3d& smMeshModel::getVertices() const +const core::StdVector3d& MeshModel::getVertices() const { return mesh->getVertices(); } -void smMeshModel::draw() +void MeshModel::draw() { RenderDelegate::Ptr delegate = this->mesh->getRenderDelegate(); if (delegate) delegate->draw(); } -void smMeshModel::setModelMesh(std::shared_ptr< smMesh > modelMesh) +void MeshModel::setModelMesh(std::shared_ptr< Mesh > modelMesh) { this->mesh.reset(); this->mesh = modelMesh; } -std::shared_ptr< smMesh > smMeshModel::getMesh() +std::shared_ptr< Mesh > MeshModel::getMesh() { return this->mesh; } -void smMeshModel::load(const std::string& meshFileName, const std::string& textureFileName, const std::string& textureName) +void MeshModel::load(const std::string& meshFileName, const std::string& textureFileName, const std::string& textureName) { - this->load(meshFileName, SM_FILETYPE_OBJ); + this->load(meshFileName, BaseMesh::MeshFileType::Obj); if(nullptr != this->mesh) { //Initialize the texture manager - smTextureManager::init(); + TextureManager::init(); //Load in the texture for the model - smTextureManager::loadTexture(textureFileName, textureName); + TextureManager::loadTexture(textureFileName, textureName); this->mesh->assignTexture(textureName); } } -void smMeshModel::setRenderDetail(std::shared_ptr< RenderDetail > renderDetail) +void MeshModel::setRenderDetail(std::shared_ptr< RenderDetail > renderDetail) { this->mesh->setRenderDetail(renderDetail); } diff --git a/src/Geometry/MeshModel.h b/src/Geometry/MeshModel.h index 8def4d5ceaa3e38107f2efd898e88dc87ae374e3..a3f6e80899bf0b560c46067718a8275c1c525177 100644 --- a/src/Geometry/MeshModel.h +++ b/src/Geometry/MeshModel.h @@ -39,23 +39,23 @@ /// /// @see smMeshCollisionModel /// -class smMeshModel : public ModelRepresentation +class MeshModel : public ModelRepresentation { public: /// /// @brief Constructor /// - smMeshModel(); + MeshModel(); /// /// @brief Destructor /// - virtual ~smMeshModel(); + virtual ~MeshModel(); /// /// @brief Loads the mesh and stores it. /// - void load(const std::string& meshName, const smMeshFileType &type); + void load(const std::string& meshName, const BaseMesh::MeshFileType &type); /// /// @brief Loads the mesh with texture and stores it. Only surface meshes allowed. @@ -90,15 +90,15 @@ public: /// /// @brief Set internal mesh data structure /// - void setModelMesh(std::shared_ptr<smMesh> modelMesh); + void setModelMesh(std::shared_ptr<Mesh> modelMesh); /// /// @brief Returns pointer to undelying mesh object. /// - std::shared_ptr<smMesh> getMesh() override; + std::shared_ptr<Mesh> getMesh() override; protected: - std::shared_ptr<smMesh> mesh; // Underlying mesh + std::shared_ptr<Mesh> mesh; // Underlying mesh }; #endif // SMMESHMODEL_H diff --git a/src/Geometry/PlaneModel.cpp b/src/Geometry/PlaneModel.cpp index 3da792313522dd34e07eadf540e098bf41677b97..3c3630c3ce022b1a22ebf734659099e6f1d67ae2 100644 --- a/src/Geometry/PlaneModel.cpp +++ b/src/Geometry/PlaneModel.cpp @@ -23,46 +23,46 @@ #include "PlaneModel.h" -smPlaneModel::smPlaneModel(const core::Vec3d& p, const core::Vec3d& n) +PlaneModel::PlaneModel(const core::Vec3d& p, const core::Vec3d& n) { this->plane = std::make_shared<Plane>(p, n); this->transform = RigidTransformType::Identity(); } -smPlaneModel::~smPlaneModel() {} -void smPlaneModel::draw() +PlaneModel::~PlaneModel() {} +void PlaneModel::draw() { this->plane->draw(); } -const core::Vec3d& smPlaneModel::getNormal() const +const core::Vec3d& PlaneModel::getNormal() const { return this->transform.linear() * this->plane->getUnitNormal(); } -void smPlaneModel::setNormal(const core::Vec3d& normal) +void PlaneModel::setNormal(const core::Vec3d& normal) { this->plane->setUnitNormal(normal); } -const core::Vec3d& smPlaneModel::getPosition() const +const core::Vec3d& PlaneModel::getPosition() const { // NB: This static variable makes the function thread-unsafe. static core::Vec3d result; result = this->transform * this->plane->getPoint(); return result; } -const smPlaneModel::RigidTransformType& smPlaneModel::getTransform() const +const PlaneModel::RigidTransformType& PlaneModel::getTransform() const { return this->transform; } -void smPlaneModel::setTransform(const smPlaneModel::RigidTransformType& t) +void PlaneModel::setTransform(const PlaneModel::RigidTransformType& t) { this->transform = t; } -void smPlaneModel::setPlaneModel(const std::shared_ptr<Plane> &p) +void PlaneModel::setPlaneModel(const std::shared_ptr<Plane> &p) { this->plane = p; } -std::shared_ptr<Plane> smPlaneModel::getPlaneModel() const +std::shared_ptr<Plane> PlaneModel::getPlaneModel() const { return plane; } diff --git a/src/Geometry/PlaneModel.h b/src/Geometry/PlaneModel.h index ffa2415ce2f17f7b584efc3540611fd95fd892d1..d8af9a27c9e987af895f1f87eb39098673135148 100644 --- a/src/Geometry/PlaneModel.h +++ b/src/Geometry/PlaneModel.h @@ -41,7 +41,7 @@ /// /// @see smPlaneCollisionModel /// -class smPlaneModel : public ModelRepresentation +class PlaneModel : public ModelRepresentation { public: using RigidTransformType = Eigen::Transform<double, 3, Eigen::Isometry>; @@ -50,12 +50,12 @@ public: /// /// @brief Constructor /// - smPlaneModel(const core::Vec3d& p, const core::Vec3d& n); + PlaneModel(const core::Vec3d& p, const core::Vec3d& n); /// /// @brief Destructor /// - virtual ~smPlaneModel(); + virtual ~PlaneModel(); /// /// @brief Draw this mesh diff --git a/src/Geometry/UnitTests/CMakeLists.txt b/src/Geometry/UnitTests/CMakeLists.txt index 25656750c5c54fb7a2cb0787773e27bc910af4ad..3dcb9d77b6f57d66e1967d39bfa669b1ebf1f07f 100644 --- a/src/Geometry/UnitTests/CMakeLists.txt +++ b/src/Geometry/UnitTests/CMakeLists.txt @@ -5,7 +5,7 @@ add_executable(${Module}UnitTestRunner MeshModelSpec.cpp ) -target_compile_options(${Module}UnitTestRunner PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast>) +target_compile_options(${Module}UnitTestRunner PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast -Wno-multichar -Wno-type-limits>) target_link_libraries(${Module}UnitTestRunner Geometry Core Mesh) diff --git a/src/Geometry/UnitTests/MeshModelSpec.cpp b/src/Geometry/UnitTests/MeshModelSpec.cpp index 0855b49930b6b72fae13ad1b7998a417b221b514..0a358c4194f23f340ebb4e6410c694a820c8463d 100644 --- a/src/Geometry/UnitTests/MeshModelSpec.cpp +++ b/src/Geometry/UnitTests/MeshModelSpec.cpp @@ -28,10 +28,10 @@ using namespace bandit; -std::shared_ptr<smMeshModel> getModel(const core::StdVector3d &vertices) +std::shared_ptr<MeshModel> getModel(const core::StdVector3d &vertices) { - std::shared_ptr<smMeshModel> model = std::make_shared<smMeshModel>(); - std::shared_ptr<smMesh> mesh = std::make_shared<smSurfaceMesh>(); + std::shared_ptr<MeshModel> model = std::make_shared<MeshModel>(); + std::shared_ptr<Mesh> mesh = std::make_shared<SurfaceMesh>(); model->setModelMesh(mesh); // Add one triangle to the data structure @@ -56,7 +56,7 @@ std::shared_ptr<smMeshModel> getModel(const core::StdVector3d &vertices) go_bandit([](){ describe("Mesh model", []() { it("constructs", []() { - auto model = make_unique<smMeshModel>(); + auto model = make_unique<MeshModel>(); AssertThat(model != nullptr, IsTrue()); }); it("can access mesh vertices", []() { diff --git a/src/Mesh/CMakeLists.txt b/src/Mesh/CMakeLists.txt index 7cc92277895cb0cd14887b53c8f19975c0aa7dae..c5f7b0d5fc7889d067bee25d8821fc6249562d0d 100644 --- a/src/Mesh/CMakeLists.txt +++ b/src/Mesh/CMakeLists.txt @@ -1,22 +1,17 @@ simmedtk_add_library(Mesh SOURCES - ImportExport.cpp Mesh.cpp SurfaceMesh.cpp VolumeMesh.cpp - Lattice.cpp VegaSceneObject.cpp VegaSceneObjectDeformable.cpp VegaSceneObjectWithRestPosition.cpp VegaVolumetricMesh.cpp PUBLIC_HEADERS - ImportExport.h Mesh.h SurfaceMesh.h VolumeMesh.h - Lattice.h - LatticeTypes.h VegaSceneObject.h VegaSceneObjectDeformable.h VegaSceneObjectWithRestPosition.h diff --git a/src/Mesh/ImportExport.cpp b/src/Mesh/ImportExport.cpp deleted file mode 100644 index e660e6631d8056745ca2bbc0f09ca038d718f1d0..0000000000000000000000000000000000000000 --- a/src/Mesh/ImportExport.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// This file is part of the SimMedTK project. -// Copyright (c) Center for Modeling, Simulation, and Imaging in Medicine, -// Rensselaer Polytechnic Institute -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//--------------------------------------------------------------------------- -// -// Authors: -// -// Contact: -//--------------------------------------------------------------------------- - -#include "ImportExport.h" -#include "Mesh.h" -#include "Core/SDK.h" - -/// \brief -bool smImportExport::convertToJSON(smMesh *p_mesh, const std::string& p_outputFileName, - smExportOptions /*p_export*/) -{ - - FILE *file; - file = fopen(p_outputFileName.c_str(), "w"); - fprintf(file, "{ \n"); - - if (file == NULL) - { - return false; - } - - fprintf(file, "\t\"vertexPositions\" : \n["); - - for (int i = 0; i < p_mesh->nbrVertices - 1; i++) - { - fprintf(file, "%f,%f,%f,", p_mesh->vertices[i][0], p_mesh->vertices[i][1], p_mesh->vertices[i][2]); - } - - fprintf(file, "%f,%f,%f", p_mesh->vertices[p_mesh->nbrVertices - 1][0], p_mesh->vertices[p_mesh->nbrVertices - 1][1], p_mesh->vertices[p_mesh->nbrVertices - 1][2]); - fprintf(file, "],\n"); - - fprintf(file, "\t\"vertexNormals\" : \n["); - - for (int i = 0; i < p_mesh->nbrVertices - 1; i++) - { - fprintf(file, "%f,%f,%f,", p_mesh->vertNormals[i][0], p_mesh->vertNormals[i][1], p_mesh->vertNormals[i][2]); - } - - fprintf(file, "%f,%f,%f", p_mesh->vertNormals[p_mesh->nbrVertices - 1][0], p_mesh->vertNormals[p_mesh->nbrVertices - 1][1], p_mesh->vertNormals[p_mesh->nbrVertices - 1][2]); - fprintf(file, "],\n"); - - fprintf(file, "\t\"vertexTextureCoords\" : ["); - - for (int i = 0; i < p_mesh->nbrVertices - 1; i++) - { - fprintf(file, "%f,%f,", p_mesh->texCoord[i].u, p_mesh->texCoord[i].v); - } - - fprintf(file, "%f,%f", p_mesh->texCoord[p_mesh->nbrVertices - 1].u, p_mesh->texCoord[p_mesh->nbrVertices - 1].v); - fprintf(file, "],\n"); - - fprintf(file, "\t\"tangents\" : \n["); - - for (int i = 0; i < p_mesh->nbrVertices - 1; i++) - { - fprintf(file, "%f,%f,%f,", p_mesh->vertTangents[i][0], p_mesh->vertTangents[i][1], p_mesh->vertTangents[i][2]); - } - - fprintf(file, "%f,%f,%f", p_mesh->vertTangents[p_mesh->nbrVertices - 1][0], p_mesh->vertTangents[p_mesh->nbrVertices - 1][1], p_mesh->vertTangents[p_mesh->nbrVertices - 1][2]); - fprintf(file, "],\n"); - - fprintf(file, "\t\"indices\" : \n["); - - for (int i = 0; i < p_mesh->nbrTriangles; i++) - { - fprintf(file, "%d,%d,%d,", p_mesh->triangles[i].vert[0], p_mesh->triangles[i].vert[1], p_mesh->triangles[i].vert[2]); - } - - fprintf(file, "%d,%d,%d", p_mesh->triangles[p_mesh->nbrTriangles - 1].vert[0], p_mesh->triangles[p_mesh->nbrTriangles - 1].vert[1], p_mesh->triangles[p_mesh->nbrTriangles - 1].vert[2]); - fprintf(file, "]\n"); - - fprintf(file, "}"); - - fclose(file); - return true; -} diff --git a/src/Mesh/ImportExport.h b/src/Mesh/ImportExport.h deleted file mode 100644 index 1d13f730e4e6a072b81154a972b7ce85b2e03f30..0000000000000000000000000000000000000000 --- a/src/Mesh/ImportExport.h +++ /dev/null @@ -1,47 +0,0 @@ -// This file is part of the SimMedTK project. -// Copyright (c) Center for Modeling, Simulation, and Imaging in Medicine, -// Rensselaer Polytechnic Institute -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//--------------------------------------------------------------------------- -// -// Authors: -// -// Contact: -//--------------------------------------------------------------------------- - -#ifndef SMIMPORTEXPORT_H -#define SMIMPORTEXPORT_H - -// SimMedTK includes -#include "Core/Config.h" -#include "Core/CoreClass.h" -#include "Mesh.h" - -/// \brief -enum smExportOptions -{ - SIMMEDTK_EXPORT_ALL -}; - -/// \brief class for importing and exporting meshes -class smImportExport: public CoreClass -{ - -public: - static bool convertToJSON(smMesh *mesh, const std::string& outputFileName, - smExportOptions p_export = SIMMEDTK_EXPORT_ALL); -}; - -#endif diff --git a/src/Mesh/Lattice.cpp b/src/Mesh/Lattice.cpp deleted file mode 100644 index 9cfb7ceec226a1a996aaa565124b0bcfa0f01de1..0000000000000000000000000000000000000000 --- a/src/Mesh/Lattice.cpp +++ /dev/null @@ -1,257 +0,0 @@ -// This file is part of the SimMedTK project. -// Copyright (c) Center for Modeling, Simulation, and Imaging in Medicine, -// Rensselaer Polytechnic Institute -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//--------------------------------------------------------------------------- -// -// Authors: -// -// Contact: -//--------------------------------------------------------------------------- - -#include "Lattice.h" -#include "Core/Factory.h" - -smLattice::smLattice() -{ - this->cells = NULL; - this->totalCells = 0; - this->xStep = 0; - this->yStep = 0; - this->zStep = 0; - this->xSeperation = 0; - this->ySeperation = 0; - this->zSeperation = 0; - this->setRenderDelegate( - Factory<RenderDelegate>::createSubclass( - "RenderDelegate", "LatticeRenderDelegate")); -} -float smLattice::getXStep() -{ - return xStep; -} -float smLattice::getYStep() -{ - return yStep; -} -float smLattice::getZStep() -{ - return zStep; -} -core::Vec3d smLattice::getLatticeCenter() -{ - return latticeCenter; -} -core::Vec3d smLattice::getLeftMinCorner() -{ - return cells[0].cellLeftCorner; -} -core::Vec3d smLattice::getRightMaxCorner() -{ - return cells[totalCells - 1].cellRightCorner; -} -smLattice::~smLattice() -{ - delete[] cells; - delete[] aabb; -} -smLatticeReturnType smLattice::init( core::Vec3d p_leftCorner, core::Vec3d p_rightCorner, int p_xSeperation, int p_ySeperation, int p_zSeperation ) -{ - - int x, y, z; - int index; - - xSeperation = p_xSeperation; - ySeperation = p_ySeperation; - zSeperation = p_zSeperation; - - boundingBoxInit(); - cells = new smCell[xSeperation * ySeperation * zSeperation]; - zStep = ( p_rightCorner[2] - p_leftCorner[2] ) / zSeperation; - yStep = ( p_rightCorner[1] - p_leftCorner[1] ) / ySeperation; - xStep = ( p_rightCorner[0] - p_leftCorner[0] ) / xSeperation; - int counter = 0; - - for ( y = 0; y < ySeperation; y++ ) - for ( z = 0; z < zSeperation; z++ ) - for ( x = 0; x < xSeperation; x++ ) - { - index = x + z * xSeperation + y * xSeperation * zSeperation; - - if ( (x < 0 || y < 0) | (z < 0 || x >= xSeperation || y >= ySeperation || z >= zSeperation) ) - { - printf( "Error index is out of bounds in createllatice function" ); - return SIMMEDTK_LATTICE_INVALIDBOUNDS; - } - - cells[index].id = index; - cells[index].cellLeftCorner[0] = p_leftCorner[0] + x * xStep; - cells[index].cellLeftCorner[1] = p_leftCorner[1] + y * yStep; - cells[index].cellLeftCorner[2] = p_leftCorner[2] + z * zStep; - - cells[index].cellRightCorner[0] = cells[index].cellLeftCorner[0] + xStep; - cells[index].cellRightCorner[1] = cells[index].cellLeftCorner[1] + yStep; - cells[index].cellRightCorner[2] = cells[index].cellLeftCorner[2] + zStep; - - - cells[index].cellCenter[0] = ( cells[index].cellLeftCorner[0] + cells[index].cellRightCorner[0] ) / 2; - cells[index].cellCenter[1] = ( cells[index].cellLeftCorner[1] + cells[index].cellRightCorner[1] ) / 2; - cells[index].cellCenter[2] = ( cells[index].cellLeftCorner[2] + cells[index].cellRightCorner[2] ) / 2; - cells[index].isActive = false; - cells[index].lastPrimitiveIndex = 0; - - for ( int j = 0; j < SIMMEDTK_SPATIALGRID_MAXPRIMITIVES; j++ ) - { - cells[index].cellPrimitives[j].index = 0; - } - - counter++; - } - - this->totalCells = counter; - this->latticeCenter[0] = ( p_leftCorner[0] + p_rightCorner[0] ) / 2.0; - this->latticeCenter[1] = ( p_leftCorner[1] + p_rightCorner[1] ) / 2.0; - this->latticeCenter[2] = ( p_leftCorner[2] + p_rightCorner[2] ) / 2.0; - - return SIMMEDTK_LATTICE_OK; -} -void smLattice::indexReset() -{ - - int traverseIndex = 0; - - for ( int y = 0; y < ySeperation; y++ ) - for ( int z = 0; z < zSeperation; z++ ) - for ( int x = 0; x < xSeperation; x++ ) - { - traverseIndex = x + z * xSeperation + y * xSeperation * zSeperation; - cells[traverseIndex].lastPrimitiveIndex = 0; - } -} -void smLattice::isCellEmpty( int /*p_cellIndex*/ ) -{ -} -void smLattice::linkPrimitivetoCell( int p_primitiveIndex ) -{ - - int minX; - int minY; - int minZ; - int maxX; - int maxY; - int maxZ; - int index; - core::Vec3d leftCorner = getLeftMinCorner(); - - minX = ( aabb[p_primitiveIndex].aabbMin[0] - leftCorner[0] ) / xStep; - minY = ( aabb[p_primitiveIndex].aabbMin[1] - leftCorner[1] ) / yStep; - minZ = ( aabb[p_primitiveIndex].aabbMin[2] - leftCorner[2] ) / zStep; - - maxX = ( aabb[p_primitiveIndex].aabbMax[0] - leftCorner[0] ) / xStep; - maxY = ( aabb[p_primitiveIndex].aabbMax[1] - leftCorner[1] ) / yStep; - maxZ = ( aabb[p_primitiveIndex].aabbMax[2] - leftCorner[2] ) / zStep; - - for ( int yIndex = minY; yIndex <= maxY; yIndex++ ) - for ( int xIndex = minX; xIndex <= maxX; xIndex++ ) - for ( int zIndex = minZ; zIndex <= maxZ; zIndex++ ) - { - index = xIndex + zIndex * xSeperation + yIndex * xSeperation * zSeperation; - - if ( ((xIndex < 0 || yIndex < 0)) || ((zIndex < 0 || xIndex >= xSeperation || yIndex >= ySeperation || zIndex >= zSeperation)) ) - { - continue; - } - - if ( cells[index].lastPrimitiveIndex >= SIMMEDTK_SPATIALGRID_MAXPRIMITIVES ) - { - return; - } - - cells[index].cellPrimitives[cells[index].lastPrimitiveIndex].index = p_primitiveIndex; - cells[index].lastPrimitiveIndex++; - } -} -void smLattice::updateBounds( std::shared_ptr<smSurfaceMesh> p_mesh, int p_index ) -{ - - //min - aabb[p_index].aabbMin[0] = std::min( p_mesh->vertices[p_mesh->triangles[p_index].vert[0]][0], - p_mesh->vertices[p_mesh->triangles[p_index].vert[1]][0] ); - aabb[p_index].aabbMin[0] = std::min( aabb[p_index].aabbMin[0], - p_mesh->vertices[p_mesh->triangles[p_index].vert[2]][0] ); - - aabb[p_index].aabbMin[1] = std::min( p_mesh->vertices[p_mesh->triangles[p_index].vert[0]][1], - p_mesh->vertices[p_mesh->triangles[p_index].vert[1]][1] ); - aabb[p_index].aabbMin[1] = std::min( aabb[p_index].aabbMin[1], - p_mesh->vertices[p_mesh->triangles[p_index].vert[2]][1] ); - - aabb[p_index].aabbMin[2] = std::min( p_mesh->vertices[p_mesh->triangles[p_index].vert[0]][2], - p_mesh->vertices[p_mesh->triangles[p_index].vert[1]][2] ); - aabb[p_index].aabbMin[2] = std::min( aabb[p_index].aabbMin[2], - p_mesh->vertices[p_mesh->triangles[p_index].vert[2]][2] ); - - //max - aabb[p_index].aabbMax[0] = std::max( p_mesh->vertices[p_mesh->triangles[p_index].vert[0]][0], - p_mesh->vertices[p_mesh->triangles[p_index].vert[1]][0] ); - aabb[p_index].aabbMax[0] = std::max( aabb[p_index].aabbMax[0], - p_mesh->vertices[p_mesh->triangles[p_index].vert[2]][0] ); - - aabb[p_index].aabbMax[1] = std::max( p_mesh->vertices[p_mesh->triangles[p_index].vert[0]][1], - p_mesh->vertices[p_mesh->triangles[p_index].vert[1]][1] ); - aabb[p_index].aabbMax[1] = std::max( aabb[p_index].aabbMax[1], - p_mesh->vertices[p_mesh->triangles[p_index].vert[2]][1] ); - - aabb[p_index].aabbMax[2] = std::max( p_mesh->vertices[p_mesh->triangles[p_index].vert[0]][2], - p_mesh->vertices[p_mesh->triangles[p_index].vert[1]][2] ); - aabb[p_index].aabbMax[2] = std::max( aabb[p_index].aabbMax[2], - p_mesh->vertices[p_mesh->triangles[p_index].vert[2]][2] ); -} -void smLattice::updateBounds() -{ - for ( int i = 0; i < mesh->nbrTriangles; i++ ) - { - updateBounds( mesh, i ); - } -} -void smLattice::linkPrims() -{ - for ( int i = 0; i < mesh->nbrTriangles; i++ ) - { - linkPrimitivetoCell( i ); - } -} -void smLattice::addObject( SceneObject *obj ) -{ - core::ClassType objectType; - linkedObject = obj->getObjectUnifiedID(); - objectType = obj->getType(); - - switch ( objectType ) - { - case core::ClassType::StaticSceneObject: - { - auto staticSceneObject = static_cast<StaticSceneObject*>(obj); - auto model = staticSceneObject->getModel(); - if(nullptr == model) - { - break; - } - std::shared_ptr<smMesh> mesh = model->getMesh(); - break; - } - default: - std::cerr << "Unknown class type." << std::endl; - } -} diff --git a/src/Mesh/Lattice.h b/src/Mesh/Lattice.h deleted file mode 100644 index edcb202ffc5923eaa6d84a4e4c755eaedf0f1619..0000000000000000000000000000000000000000 --- a/src/Mesh/Lattice.h +++ /dev/null @@ -1,173 +0,0 @@ -// This file is part of the SimMedTK project. -// Copyright (c) Center for Modeling, Simulation, and Imaging in Medicine, -// Rensselaer Polytechnic Institute -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//--------------------------------------------------------------------------- -// -// Authors: -// -// Contact: -//--------------------------------------------------------------------------- - -#ifndef SMLATTICE_H -#define SMLATTICE_H - -// SimMedTK includes -#include "Core/Config.h" -#include "Core/CoreClass.h" -#include "Rendering/CustomRenderer.h" -#include "SurfaceMesh.h" -#include "Core/SceneObject.h" -#include "Core/StaticSceneObject.h" -#include "Core/Geometry.h" - -#define SIMMEDTK_SPATIALGRID_MAXPRIMITIVES 500 -#define SIMMEDTK_SPATIALGRID_MAXCELLS 1000 -#define SIMMEDTK_SMLATTICE_NONE (0) -#define SIMMEDTK_SMLATTICE_ALL (1<<1) -#define SIMMEDTK_SMLATTICE_MINMAXPOINTS (1<<2) -#define SIMMEDTK_SMLATTICE_SEPERATIONLINES (1<<3) -#define SIMMEDTK_SMLATTICE_CELLS (1<<4) -#define SIMMEDTK_SMLATTICE_CELLCENTERS (1<<5) -#define SIMMEDTK_SMLATTICE_CELLPOINTS (1<<6) -#define SIMMEDTK_SMLATTICE_CELLPOINTSLINKS (1<<7) -#define SIMMEDTK_SMLATTICE_CENTER (1<<8) -#define SIMMEDTK_SMLATTICE_CELLVERTICES (1<<9) -#define SIMMEDTK_SMLATTICE_CELLACTIVEVERTICES (1<<10) -#define SIMMEDTK_SMLATTICE_CELLTRIANGLES (1<<11) - -/// \brief !! -enum smLatticeReturnType -{ - SIMMEDTK_LATTICE_OK, - SIMMEDTK_LATTICE_INVALIDPARAMS, - SIMMEDTK_LATTICE_INVALIDBOUNDS -}; - -/// \brief !! holds the collision primitive pairs -struct smCollisionPairs -{ - std::shared_ptr<UnifiedId> objectIndex; - std::shared_ptr<UnifiedId> objectIndex2; - int primIndex; - int primIndex2; -}; - -/// \brief cell primitive -struct smCellPrim -{ - int index; - int objectId; -}; - -/// \brief contains everything related to a cell -class smCell -{ - -public: - int id; - int cellId[3]; - core::Vec3d cellCenter; - core::Vec3d cellLeftCorner; - core::Vec3d cellRightCorner; - smCellPrim cellPrimitives[SIMMEDTK_SPATIALGRID_MAXPRIMITIVES]; - int lastPrimitiveIndex; - int timeStamp; - bool isActive; - - smCell() - { - } -}; - -/// \brief !! -class smLattice: public CoreClass -{ -public: - /// \brief !! - void boundingBoxInit() - { - aabb = new AABB[mesh->nbrTriangles]; - } - - /// \brief constructor - smLattice(); - - /// \brief get the size of the lattice cell side in x-direction - float getXStep(); - - /// \brief get the size of the lattice cell side in y-direction - float getYStep(); - - /// \brief get the size of the lattice cell side in z-direction - float getZStep(); - - /// \brief get the center of the lattice - core::Vec3d getLatticeCenter(); - - /// \brief !! get the left corner of cell 0 - core::Vec3d getLeftMinCorner(); - - /// \brief !! get the right corner of cell 0 - core::Vec3d getRightMaxCorner(); - - /// \brief destructor - ~smLattice(); - - /// \brief Initialize the lattice - smLatticeReturnType init(core::Vec3d p_leftCorner, core::Vec3d p_rightCorner, - int p_xSeperation, int p_ySeperation, int p_zSeperation); - - /// \brief !! - void indexReset(); - - /// \brief !! - void isCellEmpty(int p_cellIndex); - - /// \brief !! - virtual void linkPrimitivetoCell(int p_primitiveIndex); - - /// \brief update the bounds of the lattice - void updateBounds(std::shared_ptr<smSurfaceMesh> p_mesh, int p_index); - - /// \brief update the bounds of the lattice - void updateBounds(); - - /// \brief !! - void linkPrims(); - - /// \brief !! - void addObject(SceneObject *obj); - -public: - friend class smLatticeRenderDelegate; - - //these should be templated..Current design is based on the triangle - AABB *aabb; - std::shared_ptr<smSurfaceMesh> mesh; - smCell *cells; - int totalCells; - int xSeperation; - int ySeperation; - int zSeperation; - float xStep; - float yStep; - float zStep; - core::Vec3d latticeCenter; - int time; - std::shared_ptr<UnifiedId> linkedObject; -}; - -#endif diff --git a/src/Mesh/Mesh.cpp b/src/Mesh/Mesh.cpp index 4a994c87cbe7b375ddedff3be71d297a024bbae8..1520ac63e6d4d39c56a089ee43b5f24b11a8be75 100644 --- a/src/Mesh/Mesh.cpp +++ b/src/Mesh/Mesh.cpp @@ -25,23 +25,26 @@ #include <limits> +// VEgaFEM include +#include "objMesh.h" + // SimMedTK includes #include "Rendering/GLRenderer.h" #include "Rendering/Viewer.h" #include "Core/Factory.h" -smBaseMesh::smBaseMesh() +BaseMesh::BaseMesh() { -// SDK::getInstance()->registerMesh(safeDownCast<smBaseMesh>()); +// SDK::getInstance()->registerMesh(safeDownCast<BaseMesh>()); } -void smBaseMesh::updateOriginalVertsWithCurrent() +void BaseMesh::updateOriginalVertsWithCurrent() { origVerts = vertices; } /// \brief constructor -smMesh::smMesh() +Mesh::Mesh() { triangles = 0; texCoord = 0; @@ -60,7 +63,7 @@ smMesh::smMesh() } /// \brief destructor -smMesh::~smMesh() +Mesh::~Mesh() { delete [] triangles; delete [] texCoord; @@ -72,7 +75,7 @@ smMesh::~smMesh() } /// \brief -void smMesh::allocateAABBTris() +void Mesh::allocateAABBTris() { this->triAABBs.resize(nbrTriangles); this->updateTriangleAABB(); @@ -80,8 +83,8 @@ void smMesh::allocateAABBTris() /// \brief void CalculateTangentArray(int vertexCount, const core::Vec3d *vertex, - const core::Vec3d *normal, const smTexCoord *texcoord, - long triangleCount, const smTriangle *triangle, + const core::Vec3d *normal, const TexCoord *texcoord, + long triangleCount, const Triangle *triangle, core::Vec3d *tangent) { @@ -99,9 +102,9 @@ void CalculateTangentArray(int vertexCount, const core::Vec3d *vertex, const core::Vec3d& v2 = vertex[i2]; const core::Vec3d& v3 = vertex[i3]; - const smTexCoord& w1 = texcoord[i1]; - const smTexCoord& w2 = texcoord[i2]; - const smTexCoord& w3 = texcoord[i3]; + const TexCoord& w1 = texcoord[i1]; + const TexCoord& w2 = texcoord[i2]; + const TexCoord& w3 = texcoord[i3]; float x1 = v2[0] - v1[0]; float x2 = v3[0] - v1[0]; @@ -144,7 +147,7 @@ void CalculateTangentArray(int vertexCount, const core::Vec3d *vertex, } /// \brief calucate the triangle tangents -void smMesh::calcTriangleTangents() +void Mesh::calcTriangleTangents() { int t; @@ -152,26 +155,26 @@ void smMesh::calcTriangleTangents() // First calculate the triangle tangents for (t = 0; t < nbrTriangles; t++) { - smTriangle *tmpTri = &triangles[t]; + Triangle *tmpTri = &triangles[t]; core::Vec3d *v0 = &vertices[tmpTri->vert[0]]; core::Vec3d *v1 = &vertices[tmpTri->vert[1]]; core::Vec3d *v2 = &vertices[tmpTri->vert[2]]; - smTexCoord *t0 = &texCoord[tmpTri->vert[0]]; - smTexCoord *t1 = &texCoord[tmpTri->vert[1]]; - smTexCoord *t2 = &texCoord[tmpTri->vert[2]]; + TexCoord *t0 = &texCoord[tmpTri->vert[0]]; + TexCoord *t1 = &texCoord[tmpTri->vert[1]]; + TexCoord *t2 = &texCoord[tmpTri->vert[2]]; - if (this->meshFileType == SM_FILETYPE_3DS) + if (this->meshFileType == BaseMesh::MeshFileType::ThreeDS) { calculateTangent(*v2, *v1, *v0, *t2, *t1, *t0, triTangents[t]); } - else if (this->meshFileType == SM_FILETYPE_OBJ) + else if (this->meshFileType == BaseMesh::MeshFileType::Obj) { calculateTangent_test(*v0, *v1, *v2, *t0, *t1, *t2, triTangents[t]); } } //calculate the vertex normals - if (this->meshFileType == SM_FILETYPE_3DS || this->meshFileType == SM_FILETYPE_OBJ) + if (this->meshFileType == BaseMesh::MeshFileType::ThreeDS || this->meshFileType == BaseMesh::MeshFileType::Obj) { for (int v = 0; v < nbrVertices; v++) { @@ -182,15 +185,15 @@ void smMesh::calcTriangleTangents() vertTangents[v] += triTangents[vertTriNeighbors[v][i]]; } - vertTangents[v].normalized(); + vertTangents[v].normalize(); vertTangents[v] = (vertTangents[v] - vertNormals[v] * vertNormals[v].dot(vertTangents[v])); - vertTangents[v].normalized(); + vertTangents[v].normalize(); } } } /// \brief calucate the triangle tangent for rendering purposes -void smMesh::calculateTangent(core::Vec3d& p1, core::Vec3d& p2, core::Vec3d& p3, smTexCoord& t1, smTexCoord& t2, smTexCoord& t3, core::Vec3d& t) +void Mesh::calculateTangent(core::Vec3d& p1, core::Vec3d& p2, core::Vec3d& p3, TexCoord& t1, TexCoord& t2, TexCoord& t3, core::Vec3d& t) { core::Vec3d v1; @@ -215,7 +218,7 @@ void smMesh::calculateTangent(core::Vec3d& p1, core::Vec3d& p2, core::Vec3d& p3, } /// \brief -void smMesh::calculateTangent_test(core::Vec3d& p1, core::Vec3d& p2, core::Vec3d& p3, smTexCoord& t1, smTexCoord& t2, smTexCoord& t3, core::Vec3d& t) +void Mesh::calculateTangent_test(core::Vec3d& p1, core::Vec3d& p2, core::Vec3d& p3, TexCoord& t1, TexCoord& t2, TexCoord& t3, core::Vec3d& t) { core::Vec3d v1; @@ -241,7 +244,7 @@ void smMesh::calculateTangent_test(core::Vec3d& p1, core::Vec3d& p2, core::Vec3d } /// \brief calculates the normal of the vertex -void smMesh::updateVertexNormals() +void Mesh::updateVertexNormals() { core::Vec3d temp = core::Vec3d::Zero(); @@ -253,13 +256,13 @@ void smMesh::updateVertexNormals() } vertNormals[i] = temp; - vertNormals[i].normalized(); + vertNormals[i].normalize(); temp = core::Vec3d::Zero(); } } /// \brief updates the normal of all the triangle -void smMesh::updateTriangleNormals() +void Mesh::updateTriangleNormals() { for (int i = 0; i < nbrTriangles; i++) @@ -269,11 +272,11 @@ void smMesh::updateTriangleNormals() } /// \brief calculates the normal of a triangle -core::Vec3d smMesh::calculateTriangleNormal(int triNbr) +core::Vec3d Mesh::calculateTriangleNormal(int triNbr) { core::Vec3d v[3]; - smTriangle temp = this->triangles[triNbr]; + Triangle temp = this->triangles[triNbr]; v[0] = this->vertices[temp.vert[0]]; v[1] = this->vertices[temp.vert[1]]; @@ -283,7 +286,7 @@ core::Vec3d smMesh::calculateTriangleNormal(int triNbr) } /// \brief allocates vertices and related array -bool smMesh::initVertexArrays(int nbr) +bool Mesh::initVertexArrays(int nbr) { if (nbr < 0) @@ -296,12 +299,12 @@ bool smMesh::initVertexArrays(int nbr) this->origVerts.resize(nbr); this->vertNormals = new core::Vec3d[nbr]; this->vertTangents = new core::Vec3d[nbr]; - this->texCoord = new smTexCoord[nbr]; + this->texCoord = new TexCoord[nbr]; return true; } /// \brief allocates triangle and related array -bool smMesh::initTriangleArrays(int nbr) +bool Mesh::initTriangleArrays(int nbr) { if (nbr < 0) @@ -311,14 +314,14 @@ bool smMesh::initTriangleArrays(int nbr) this->nbrTriangles = nbr; - this->triangles = new smTriangle[nbr]; + this->triangles = new Triangle[nbr]; this->triNormals = new core::Vec3d[nbr]; this->triTangents = new core::Vec3d[nbr]; return true; } /// \brief initializes the vertex neighbors -void smMesh::initVertexNeighbors() +void Mesh::initVertexNeighbors() { int i; @@ -333,7 +336,7 @@ void smMesh::initVertexNeighbors() } /// \brief initializes the vertex neighbors -void smMesh::calcNeighborsVertices() +void Mesh::calcNeighborsVertices() { int i; @@ -404,7 +407,7 @@ void smMesh::calcNeighborsVertices() } /// \brief -void smMesh::upadateAABB() +void Mesh::upadateAABB() { double minx = std::numeric_limits<double>::max(); double miny = std::numeric_limits<double>::max(); @@ -434,9 +437,9 @@ void smMesh::upadateAABB() } /// \brief -void smMesh::calcEdges() +void Mesh::calcEdges() { - smEdge edge; + Edge edge; edges.reserve(SIMMEDTK_MESH_RESERVEDMAXEDGES); for (int i = 0; i < nbrVertices; i++) @@ -454,7 +457,7 @@ void smMesh::calcEdges() } /// \brief -void smMesh::translate(float p_offsetX, float p_offsetY, float p_offsetZ) +void Mesh::translate(float p_offsetX, float p_offsetY, float p_offsetZ) { for (int i = 0; i < nbrVertices; i++) @@ -472,7 +475,7 @@ void smMesh::translate(float p_offsetX, float p_offsetY, float p_offsetZ) } /// \brief -void smMesh::translate(core::Vec3d p_offset) +void Mesh::translate(core::Vec3d p_offset) { for (int i = 0; i < nbrVertices; i++) @@ -485,7 +488,7 @@ void smMesh::translate(core::Vec3d p_offset) } /// \brief -void smMesh::scale(core::Vec3d p_scaleFactors) +void Mesh::scale(core::Vec3d p_scaleFactors) { for (int i = 0; i < nbrVertices; i++) @@ -503,7 +506,7 @@ void smMesh::scale(core::Vec3d p_scaleFactors) } /// \brief -void smMesh::rotate(const Matrix33d &p_rot) +void Mesh::rotate(const Matrix33d &p_rot) { for (int i = 0; i < nbrVertices; i++) @@ -523,7 +526,7 @@ void smMesh::rotate(const Matrix33d &p_rot) } /// \brief -void smMesh::updateTriangleAABB() +void Mesh::updateTriangleAABB() { for (int i = 0; i < nbrTriangles; i++) { @@ -549,7 +552,7 @@ void smMesh::updateTriangleAABB() } /// \brief -void smMesh::checkCorrectWinding() +void Mesh::checkCorrectWinding() { int x[3]; int p[3]; @@ -619,18 +622,18 @@ void smMesh::checkCorrectWinding() } } -smTextureAttachment::smTextureAttachment() +TextureAttachment::TextureAttachment() { } -bool smBaseMesh::isMeshTextured() +bool BaseMesh::isMeshTextured() { return isTextureCoordAvailable; } -void smBaseMesh::assignTexture( int p_textureId ) +void BaseMesh::assignTexture( int p_textureId ) { - smTextureAttachment attachment; + TextureAttachment attachment; attachment.textureId = p_textureId; if ( p_textureId > 0 ) @@ -638,35 +641,35 @@ void smBaseMesh::assignTexture( int p_textureId ) this->textureIds.push_back( attachment ); } } -void smBaseMesh::assignTexture(const std::string& p_referenceName) +void BaseMesh::assignTexture(const std::string& p_referenceName) { int textureId; - smTextureAttachment attachment; + TextureAttachment attachment; - if (smTextureManager::findTextureId(p_referenceName, textureId) == SIMMEDTK_TEXTURE_OK) + if (TextureManager::findTextureId(p_referenceName, textureId) == SIMMEDTK_TEXTURE_OK) { attachment.textureId = textureId; this->textureIds.push_back(attachment); } } -smLineMesh::smLineMesh( int p_nbrVertices ) : smBaseMesh() +LineMesh::LineMesh( int p_nbrVertices ) : BaseMesh() { nbrVertices = p_nbrVertices; vertices.reserve( nbrVertices ); origVerts.reserve( nbrVertices ); edgeAABBs = new AABB[nbrVertices - 1]; - texCoord = new smTexCoord[nbrVertices]; - edges = new smEdge[nbrVertices - 1]; + texCoord = new TexCoord[nbrVertices]; + edges = new Edge[nbrVertices - 1]; nbrEdges = nbrVertices - 1; isTextureCoordAvailable = false; createAutoEdges(); } -smLineMesh::smLineMesh( int p_nbrVertices, bool autoEdge ) : smBaseMesh() +LineMesh::LineMesh( int p_nbrVertices, bool autoEdge ) : BaseMesh() { nbrVertices = p_nbrVertices; vertices.reserve( nbrVertices ); origVerts.reserve( nbrVertices ); - texCoord = new smTexCoord[nbrVertices]; + texCoord = new TexCoord[nbrVertices]; /// Edge AABB should be assigned by the instance edgeAABBs = NULL; @@ -684,7 +687,7 @@ smLineMesh::smLineMesh( int p_nbrVertices, bool autoEdge ) : smBaseMesh() createAutoEdges(); } } -void smLineMesh::createAutoEdges() +void LineMesh::createAutoEdges() { for ( int i = 0; i < nbrEdges; i++ ) { @@ -692,7 +695,7 @@ void smLineMesh::createAutoEdges() edges[i].vert[1] = i + 1; } } -void smLineMesh::updateAABB() +void LineMesh::updateAABB() { AABB tempAABB; core::Vec3d minOffset( -2.0, -2.0, -2.0 ); @@ -733,7 +736,7 @@ void smLineMesh::updateAABB() tempAABB.aabbMax += maxOffset; aabb = tempAABB; } -void smLineMesh::translate( float p_offsetX, float p_offsetY, float p_offsetZ ) +void LineMesh::translate( float p_offsetX, float p_offsetY, float p_offsetZ ) { for ( int i = 0; i < nbrVertices; i++ ) @@ -745,7 +748,7 @@ void smLineMesh::translate( float p_offsetX, float p_offsetY, float p_offsetZ ) updateAABB(); } -void smLineMesh::translate( core::Vec3d p_offset ) +void LineMesh::translate( core::Vec3d p_offset ) { for ( int i = 0; i < nbrVertices; i++ ) @@ -756,7 +759,7 @@ void smLineMesh::translate( core::Vec3d p_offset ) updateAABB(); } -void smLineMesh::rotate( Matrix33d p_rot ) +void LineMesh::rotate( Matrix33d p_rot ) { for ( int i = 0; i < nbrVertices; i++ ) @@ -767,7 +770,7 @@ void smLineMesh::rotate( Matrix33d p_rot ) updateAABB(); } -void smLineMesh::scale( core::Vec3d p_scaleFactors ) +void LineMesh::scale( core::Vec3d p_scaleFactors ) { for ( int i = 0; i < nbrVertices; i++ ) @@ -784,22 +787,22 @@ void smLineMesh::scale( core::Vec3d p_scaleFactors ) updateAABB(); } -bool smLineMesh::isMeshTextured() +bool LineMesh::isMeshTextured() { return isTextureCoordAvailable; } -int smMesh::getNumTriangles() const +int Mesh::getNumTriangles() const { return this->nbrTriangles; } -int smMesh::getNumEdges() const +int Mesh::getNumEdges() const { return this->edges.size(); } -void smMesh::updateSurfaceMeshFromVegaFormat(std::shared_ptr<ObjMesh> vegaSurfaceMesh) +void Mesh::updateSurfaceMeshFromVegaFormat(std::shared_ptr<ObjMesh> vegaSurfaceMesh) { Vec3d p; //copy the vertex co-ordinates @@ -812,7 +815,7 @@ void smMesh::updateSurfaceMeshFromVegaFormat(std::shared_ptr<ObjMesh> vegaSurfac } } -bool smMesh::importSurfaceMeshFromVegaFormat(std::shared_ptr<ObjMesh> vegaSurfaceMesh, const bool perProcessingStage) +bool Mesh::importSurfaceMeshFromVegaFormat(std::shared_ptr<ObjMesh> vegaSurfaceMesh, const bool perProcessingStage) { if (!vegaSurfaceMesh) return false; @@ -847,7 +850,7 @@ bool smMesh::importSurfaceMeshFromVegaFormat(std::shared_ptr<ObjMesh> vegaSurfac initTriangleArrays(numTriangles); /*delete this->triangles; - this->triangles = new smTriangle[this->nbrTriangles];*/ + this->triangles = new Triangle[this->nbrTriangles];*/ //copy the triangle connectivity information for(i=0; i<this->nbrTriangles ; i++) diff --git a/src/Mesh/Mesh.h b/src/Mesh/Mesh.h index 4365a3af24e44cb700ed8c62667bee76e54c3b03..1a1e9c8e5c658964396af2dcb144a293318615ae 100644 --- a/src/Mesh/Mesh.h +++ b/src/Mesh/Mesh.h @@ -36,50 +36,52 @@ #include "Core/CollisionConfig.h" #include "Core/Geometry.h" -//VEGA includes -#include "objMesh.h" - #define SIMMEDTK_MESH_AABBSKINFACTOR 0.1 ///Bounding box skin value #define SIMMEDTK_MESH_RESERVEDMAXEDGES 6000 ///this value is initially allocated buffer size for thge edges -struct smTexCoord; -struct smTriangle; -struct smTetrahedra; -struct smEdge; +// VegaFEM class +class ObjMesh; + +struct TexCoord; +struct Triangle; +struct Tetrahedra; +struct Edge; -/// \brief designates what purpose/scenario the mesh is used for -enum smMeshType -{ - SMMESH_DEFORMABLE, - SMMESH_DEFORMABLECUTABLE, - SMMESH_RIGIDCUTABLE, - SMMESH_RIGID -}; -/// \brief designates input mesh file type -enum smMeshFileType -{ - SM_FILETYPE_NONE, - SM_FILETYPE_OBJ, - SM_FILETYPE_3DS, - SM_FILETYPE_VOLUME, -}; -class smShader; +class Shader; /// \brief !! -struct smTextureAttachment +struct TextureAttachment { - smTextureAttachment(); + TextureAttachment(); int textureId; }; /// \brief base class for the mesh -class smBaseMesh: public CoreClass +class BaseMesh: public CoreClass { public: + /// \brief designates what purpose/scenario the mesh is used for + enum class MeshType + { + Deformable, + DeformableCutable, + RigidCutable, + Rigid + }; + + /// \brief designates input mesh file type + enum class MeshFileType + { + None, + Obj, + ThreeDS, + Volume, + }; + /// \brief constructor - smBaseMesh(); + BaseMesh(); /// \brief query if the mesh has textures available for rendering bool isMeshTextured(); @@ -112,20 +114,20 @@ public: int nbrVertices; ///< number of vertices AABB aabb; ///< Axis aligned bounding box bool isTextureCoordAvailable; ///< true if the texture co-ordinate is available - smTexCoord *texCoord; ///< texture co-ordinates - std::vector<smTextureAttachment> textureIds; ///< !! + TexCoord *texCoord; ///< texture co-ordinates + std::vector<TextureAttachment> textureIds; ///< !! }; /// \brief: this is a generic Mesh class from which surface and volume meshes are inherited /// Note: this class cannot exist on its own -class smMesh: public smBaseMesh +class Mesh: public BaseMesh { public: /// \brief constructor - smMesh(); + Mesh(); /// \brief destructor - virtual ~smMesh(); + virtual ~Mesh(); /// \brief compute the neighbors of the vertex void getVertexNeighbors(); @@ -164,10 +166,10 @@ public: void calcTriangleTangents(); /// \brief compute the tangent give the three vertices - void calculateTangent(core::Vec3d& p1, core::Vec3d& p2, core::Vec3d& p3, smTexCoord& t1, smTexCoord& t2, smTexCoord& t3, core::Vec3d& t); + void calculateTangent(core::Vec3d& p1, core::Vec3d& p2, core::Vec3d& p3, TexCoord& t1, TexCoord& t2, TexCoord& t3, core::Vec3d& t); /// \brief !! - void calculateTangent_test(core::Vec3d& p1, core::Vec3d& p2, core::Vec3d& p3, smTexCoord& t1, smTexCoord& t2, smTexCoord& t3, core::Vec3d& t); + void calculateTangent_test(core::Vec3d& p1, core::Vec3d& p2, core::Vec3d& p3, TexCoord& t1, TexCoord& t2, TexCoord& t3, core::Vec3d& t); /// \brief find the neighbors of all vertices of mesh void calcNeighborsVertices(); @@ -192,13 +194,13 @@ public: void checkCorrectWinding(); /// \brief get the type fo mesh - smMeshType getMeshType() + MeshType getMeshType() { return meshType; }; /// \brief load the mesh - virtual bool loadMesh(const std::string& fileName, const smMeshFileType &fileType) = 0; + virtual bool loadMesh(const std::string& fileName, const MeshFileType &fileType) = 0; /// \brief load the mesh bool importSurfaceMeshFromVegaFormat(std::shared_ptr<ObjMesh> vegaSurfaceMesh, const bool perProcessingStage); @@ -214,8 +216,8 @@ public: public: int nbrTriangles; ///< number of triangles - smTriangle *triangles; ///< list of triangles - smTexCoord *texCoordForTrianglesOBJ; ///< !! tansel for OBJ + Triangle *triangles; ///< list of triangles + TexCoord *texCoordForTrianglesOBJ; ///< !! tansel for OBJ int nbrTexCoordForTrainglesOBJ; ///< !! tansel for OBJ core::Vec3d *triNormals; ///< triangle normals core::Vec3d *vertNormals; ///< vertex normals @@ -224,47 +226,47 @@ public: bool tangentChannel; ///< !! std::vector< std::vector<int> > vertTriNeighbors; ///< list of neighbors for a triangle std::vector< std::vector<int> > vertVertNeighbors; ///< list of neighbors for a vertex - std::vector<smEdge> edges; ///< list of edges + std::vector<Edge> edges; ///< list of edges ///AABBB of the mesh. ///This value is allocated and computed by only collision detection module ///Therefore it is initially NULL std::vector<AABB> triAABBs; - smMeshType meshType; ///< type of mesh (rigid, deformable etc.) - smMeshFileType meshFileType; ///< type of input mesh + MeshType meshType; ///< type of mesh (rigid, deformable etc.) + MeshFileType meshFileType; ///< type of input mesh }; /// \brief holds the texture co-ordinates -struct smTexCoord +struct TexCoord { float u, v; }; /// \brief holds the vertex indices of triangle -struct smTriangle +struct Triangle { unsigned int vert[3]; }; /// \brief holds the vertex indices of tetrahedron -struct smTetrahedra +struct Tetrahedra { int vert[4]; }; /// \brief holds the vertex indices of edge -struct smEdge +struct Edge { unsigned int vert[2]; }; /// \brief !! -class smLineMesh: public smBaseMesh +class LineMesh: public BaseMesh { public: /// \brief destructor - ~smLineMesh() + ~LineMesh() { delete[]edgeAABBs; delete[]texCoord; @@ -272,10 +274,10 @@ public: } /// \brief constructor - smLineMesh(int p_nbrVertices); + LineMesh(int p_nbrVertices); /// \brief constructor - smLineMesh(int p_nbrVertices, bool autoEdge); + LineMesh(int p_nbrVertices, bool autoEdge); /// \brief !! void createAutoEdges(); @@ -303,7 +305,7 @@ public: public: AABB *edgeAABBs;///< AABBs for the edges in the mesh - smEdge *edges;///< edges of the line mesh + Edge *edges;///< edges of the line mesh int nbrEdges;///< number of edges of the line mesh }; diff --git a/src/Mesh/SurfaceMesh.cpp b/src/Mesh/SurfaceMesh.cpp index 72e925f7f25f85b60c2c534320cae510b8a699a1..e7c1dc247c7fca2eeccda05b45ea7f93f7db573e 100644 --- a/src/Mesh/SurfaceMesh.cpp +++ b/src/Mesh/SurfaceMesh.cpp @@ -50,30 +50,30 @@ size_t Filelength(const char * filename, int) #endif /// \brief constructor -smSurfaceMesh::smSurfaceMesh(const smMeshType &p_meshtype, std::shared_ptr<ErrorLog> log) +SurfaceMesh::SurfaceMesh(const MeshType &p_meshtype, std::shared_ptr<ErrorLog> log) { this->log_SF = log; meshType = p_meshtype; - meshFileType = SM_FILETYPE_NONE; + meshFileType = BaseMesh::MeshFileType::None; } /// \brief destructor -smSurfaceMesh::~smSurfaceMesh() +SurfaceMesh::~SurfaceMesh() { } /// \brief loads the mesh based on the file type and initializes the normals -bool smSurfaceMesh::loadMesh(const std::string& fileName, const smMeshFileType &fileType) +bool SurfaceMesh::loadMesh(const std::string& fileName, const MeshFileType &fileType) { bool ret = true; switch (fileType) { - case SM_FILETYPE_3DS: - case SM_FILETYPE_OBJ: + case BaseMesh::MeshFileType::ThreeDS: + case BaseMesh::MeshFileType::Obj: meshFileType = fileType; ret = LoadMeshAssimp(fileName); break; @@ -114,18 +114,18 @@ bool smSurfaceMesh::loadMesh(const std::string& fileName, const smMeshFileType & /// \brief --Deprecated, use loadMesh() for new simulators-- /// Loads the mesh based on the file type and initializes the normals -bool smSurfaceMesh::loadMeshLegacy(const std::string& fileName, const smMeshFileType &fileType) +bool SurfaceMesh::loadMeshLegacy(const std::string& fileName, const MeshFileType &fileType) { bool ret = true; switch (fileType) { - case SM_FILETYPE_3DS: + case BaseMesh::MeshFileType::ThreeDS: Load3dsMesh(fileName); break; - case SM_FILETYPE_OBJ: + case BaseMesh::MeshFileType::Obj: ret = LoadMeshAssimp(fileName); break; @@ -165,7 +165,7 @@ bool smSurfaceMesh::loadMeshLegacy(const std::string& fileName, const smMeshFile } /// \brief -bool smSurfaceMesh::LoadMeshAssimp(const std::string& fileName) +bool SurfaceMesh::LoadMeshAssimp(const std::string& fileName) { //Tell Assimp to not import any of the following from the mesh it loads @@ -264,7 +264,7 @@ bool smSurfaceMesh::LoadMeshAssimp(const std::string& fileName) } /// \brief reads the mesh file in .3ds format -bool smSurfaceMesh::Load3dsMesh(const std::string& fileName) +bool SurfaceMesh::Load3dsMesh(const std::string& fileName) { int i; //Index variable @@ -344,7 +344,7 @@ bool smSurfaceMesh::Load3dsMesh(const std::string& fileName) this->origVerts.reserve(l_qty); this->vertNormals = new core::Vec3d[l_qty]; this->vertTangents = new core::Vec3d[l_qty]; - this->texCoord = new smTexCoord[l_qty]; + this->texCoord = new TexCoord[l_qty]; for (int fpt = 0; fpt < this->nbrVertices; fpt++) { @@ -365,7 +365,7 @@ bool smSurfaceMesh::Load3dsMesh(const std::string& fileName) case 0x4120: fread(&l_qty, sizeof(unsigned short), 1, l_file); this->nbrTriangles = l_qty; - this->triangles = new smTriangle[l_qty]; + this->triangles = new Triangle[l_qty]; this->triNormals = new core::Vec3d[l_qty]; this->triTangents = new core::Vec3d[l_qty]; @@ -420,14 +420,14 @@ bool smSurfaceMesh::Load3dsMesh(const std::string& fileName) return 1; // Returns ok } -smSurfaceMesh::smSurfaceMesh() +SurfaceMesh::SurfaceMesh() { this->log_SF = std::shared_ptr<ErrorLog>(); - meshType = SMMESH_DEFORMABLE; - meshFileType = SM_FILETYPE_NONE; + meshType = MeshType::Deformable; + meshFileType = BaseMesh::MeshFileType::None; } -void smSurfaceMesh::printPrimitiveDetails() +void SurfaceMesh::printPrimitiveDetails() { std::cout << "----------------------------\n"; std::cout << "Mesh Info for : " << this->getName() <<"\n\t"; diff --git a/src/Mesh/SurfaceMesh.h b/src/Mesh/SurfaceMesh.h index 161147dd197ff33c7c806cd380669da0c9275193..8d86b3435f3b2ab0059331eae6b706e5510905d9 100644 --- a/src/Mesh/SurfaceMesh.h +++ b/src/Mesh/SurfaceMesh.h @@ -28,27 +28,27 @@ #include "Mesh.h" /// \brief this is the Surface Mesh class derived from generic Mesh class. -class smSurfaceMesh: public smMesh +class SurfaceMesh: public Mesh { public: - /// \brief push smMesh class specific errors here + /// \brief push Mesh class specific errors here std::shared_ptr<ErrorLog> log_SF; /// \brief constructor - smSurfaceMesh(); + SurfaceMesh(); /// \brief constructor - smSurfaceMesh(const smMeshType &meshtype, std::shared_ptr<ErrorLog> log); + SurfaceMesh(const MeshType &meshtype, std::shared_ptr<ErrorLog> log); /// \brief destructor - virtual ~smSurfaceMesh(); + virtual ~SurfaceMesh(); /// \brief load the surface mesh - bool loadMesh(const std::string& fileName, const smMeshFileType &fileType); + bool loadMesh(const std::string& fileName, const MeshFileType &fileType); /// \brief load the surface mesh using in-house code - bool loadMeshLegacy(const std::string& fileName, const smMeshFileType &fileType); + bool loadMeshLegacy(const std::string& fileName, const MeshFileType &fileType); /// \brief load the surface mesh from 3ds format bool Load3dsMesh(const std::string& fileName); diff --git a/src/Mesh/UnitTests/CMakeLists.txt b/src/Mesh/UnitTests/CMakeLists.txt index de9ebd13ead9e8e0c66bb2ff7c512c9e3808cf0f..2fa01c08621ebdac0719307df1f62001da2ec225 100644 --- a/src/Mesh/UnitTests/CMakeLists.txt +++ b/src/Mesh/UnitTests/CMakeLists.txt @@ -7,7 +7,7 @@ add_executable(${Module}UnitTestRunner ${CMAKE_CURRENT_BINARY_DIR}/VegaVolumetricMeshSpec.cpp ) -target_compile_options(${Module}UnitTestRunner PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast>) +target_compile_options(${Module}UnitTestRunner PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wno-old-style-cast -Wno-multichar -Wno-type-limits>) target_link_libraries(${Module}UnitTestRunner Core Mesh) simple_test(${Module} --reporter=xunit) diff --git a/src/Mesh/UnitTests/VegaVolumetricMeshSpec.cpp.in b/src/Mesh/UnitTests/VegaVolumetricMeshSpec.cpp.in index 0ec206a9a0b7850418ad66f398e517d1f9ee3ccf..996765010ba43cd2d89e90efee69c2ff02b3bb8b 100644 --- a/src/Mesh/UnitTests/VegaVolumetricMeshSpec.cpp.in +++ b/src/Mesh/UnitTests/VegaVolumetricMeshSpec.cpp.in @@ -36,30 +36,30 @@ go_bandit([](){ describe("Vega Volumetric Mesh", []() { it("constructs", []() { - std::shared_ptr<smVegaVolumetricMesh> vegaMesh = std::make_shared<smVegaVolumetricMesh>(); + std::shared_ptr<VegaVolumetricMesh> vegaMesh = std::make_shared<VegaVolumetricMesh>(); AssertThat(vegaMesh != nullptr, IsTrue()); }); it("loads mesh", []() { int verbose = 1; bool generateGraph = false; - std::shared_ptr<smVegaVolumetricMesh> vegaMesh = std::make_shared<smVegaVolumetricMesh>(generateGraph); + std::shared_ptr<VegaVolumetricMesh> vegaMesh = std::make_shared<VegaVolumetricMesh>(generateGraph); vegaMesh->loadMesh(vegaMeshFileName,verbose); AssertThat(vegaMesh->getVegaMesh() != nullptr, IsTrue()); }); it("generates graph", []() { int verbose = 1; bool generateGraph = true; - std::shared_ptr<smVegaVolumetricMesh> vegaMesh = std::make_shared<smVegaVolumetricMesh>(generateGraph); + std::shared_ptr<VegaVolumetricMesh> vegaMesh = std::make_shared<VegaVolumetricMesh>(generateGraph); vegaMesh->loadMesh(vegaMeshFileName,verbose); AssertThat(vegaMesh->getMeshGraph() != nullptr, IsTrue()); }); it("attaches surface mesh", []() { int verbose = 1; bool generateGraph = false; - std::shared_ptr<smVegaVolumetricMesh> vegaMesh = std::make_shared<smVegaVolumetricMesh>(generateGraph); + std::shared_ptr<VegaVolumetricMesh> vegaMesh = std::make_shared<VegaVolumetricMesh>(generateGraph); vegaMesh->loadMesh(vegaMeshFileName,verbose); - std::shared_ptr<smSurfaceMesh> surfaceMesh = std::make_shared<smSurfaceMesh>(); + std::shared_ptr<SurfaceMesh> surfaceMesh = std::make_shared<SurfaceMesh>(); // These vertices coincide with vertices on the volume mesh. So the weights take a special form. surfaceMesh->vertices.emplace_back(-2.44627, -0.903874999999999, -1.711465); @@ -69,8 +69,6 @@ go_bandit([](){ vegaMesh->attachSurfaceMesh(surfaceMesh,2.0); auto &weights = vegaMesh->getAttachedWeights(0); - auto &vertices = vegaMesh->getAttachedVertices(0); - AssertThat(weights[0] == 1 && weights[5] == 1 && weights[10] == 1, IsTrue()); }); }); diff --git a/src/Mesh/VegaSceneObject.cpp b/src/Mesh/VegaSceneObject.cpp index 13de1865da811c08b7e454cd28c95c741896a54d..5cbb279c04911018ed50aabefdd0f84016d15a7d 100644 --- a/src/Mesh/VegaSceneObject.cpp +++ b/src/Mesh/VegaSceneObject.cpp @@ -6,7 +6,7 @@ #include "VegaSceneObject.h" #include "objMeshEncode.h" -smVegaSceneObject::smVegaSceneObject(char * filename): +VegaSceneObject::VegaSceneObject(char * filename): mesh(NULL) { int verbose = 0; @@ -33,66 +33,66 @@ smVegaSceneObject::smVegaSceneObject(char * filename): } } -smVegaSceneObject::~smVegaSceneObject() +VegaSceneObject::~VegaSceneObject() { } // assumes pre-existing face normals // second parameter is treshold angle for hard edges -void smVegaSceneObject::BuildVertexNormals(double thresholdAngle) +void VegaSceneObject::BuildVertexNormals(double thresholdAngle) { //do stuff with structure mesh->buildVertexNormals(thresholdAngle); } -void smVegaSceneObject::BuildFaceNormals() +void VegaSceneObject::BuildFaceNormals() { mesh->buildFaceNormals(); } -void smVegaSceneObject::BuildNormals(double thresholdAngle) +void VegaSceneObject::BuildNormals(double thresholdAngle) { BuildFaceNormals(); BuildVertexNormals(thresholdAngle); } -void smVegaSceneObject::SetNormalsToFaceNormals() +void VegaSceneObject::SetNormalsToFaceNormals() { mesh->setNormalsToFaceNormals(); } -void smVegaSceneObject::BuildNormalsFancy(double thresholdAngle) +void VegaSceneObject::BuildNormalsFancy(double thresholdAngle) { BuildFaceNormals(); mesh->buildVertexNormalsFancy(thresholdAngle); } -int smVegaSceneObject::GetClosestVertex(Vec3d & queryPos, double * distance, double * auxVertexBuffer) +int VegaSceneObject::GetClosestVertex(Vec3d & queryPos, double * distance, double * /*auxVertexBuffer*/) { return mesh->getClosestVertex(queryPos, distance); } -void smVegaSceneObject::BuildNeighboringStructure() +void VegaSceneObject::BuildNeighboringStructure() { mesh->buildVertexFaceNeighbors(); } -void smVegaSceneObject::ComputeMeshGeometricParameters(Vec3d * centroid, double * radius) +void VegaSceneObject::ComputeMeshGeometricParameters(Vec3d * centroid, double * radius) { mesh->getMeshGeometricParameters(centroid, radius); } -void smVegaSceneObject::ComputeMeshRadius(Vec3d & centroid, double * radius) +void VegaSceneObject::ComputeMeshRadius(Vec3d & centroid, double * radius) { mesh->getMeshRadius(centroid, radius); } -void smVegaSceneObject::ExportMeshGeometry(int * numVertices, double ** vertices, int * numTriangles, int ** triangles) +void VegaSceneObject::ExportMeshGeometry(int * numVertices, double ** vertices, int * numTriangles, int ** triangles) { mesh->exportGeometry(numVertices, vertices, numTriangles, triangles, NULL, NULL); } -void smVegaSceneObject::TransformRigidly(double * centerOfMass, double * R) +void VegaSceneObject::TransformRigidly(double * centerOfMass, double * R) { Vec3d cv(centerOfMass); Mat3d Rv(R); diff --git a/src/Mesh/VegaSceneObject.h b/src/Mesh/VegaSceneObject.h index b3b1999d7eb2767bb13ace11730e80bd81ccce95..34068945185cfc331fddf11030bc0efc27f9959a 100644 --- a/src/Mesh/VegaSceneObject.h +++ b/src/Mesh/VegaSceneObject.h @@ -18,12 +18,12 @@ #include "vec3d.h" #include "objMesh.h" -class smVegaSceneObject +class VegaSceneObject { public: // create a static scene object, by loading it from an Alias Wavefront OBJ file - smVegaSceneObject(char * filename); - virtual ~smVegaSceneObject(); + VegaSceneObject(char * filename); + virtual ~VegaSceneObject(); // ==== mesh info and geometric queries ==== diff --git a/src/Mesh/VegaSceneObjectDeformable.cpp b/src/Mesh/VegaSceneObjectDeformable.cpp index 54aa1d4f0df07a0045fdf4d9ec540dd845cda530..67d42bc13337bb8b2ef7e4f60cfbffe2320b7012 100644 --- a/src/Mesh/VegaSceneObjectDeformable.cpp +++ b/src/Mesh/VegaSceneObjectDeformable.cpp @@ -4,22 +4,22 @@ #include <string.h> #include "VegaSceneObjectDeformable.h" -smVegaSceneObjectDeformable::smVegaSceneObjectDeformable(char * filenameOBJ): - smVegaSceneObjectWithRestPosition(filenameOBJ) +VegaSceneObjectDeformable::VegaSceneObjectDeformable(char * filenameOBJ): + VegaSceneObjectWithRestPosition(filenameOBJ) { } -smVegaSceneObjectDeformable::~smVegaSceneObjectDeformable() +VegaSceneObjectDeformable::~VegaSceneObjectDeformable() { } -void smVegaSceneObjectDeformable::ResetDeformationToRest() +void VegaSceneObjectDeformable::ResetDeformationToRest() { for(int i = 0; i < n; i++) mesh->setPosition(i, Vec3d(restPosition[3 * i + 0], restPosition[3 * i + 1], restPosition[3 * i + 2])); } -void smVegaSceneObjectDeformable::AddVertexDeformations(double * u) +void VegaSceneObjectDeformable::AddVertexDeformations(double * u) { for(int i = 0; i < n; i++) { @@ -27,7 +27,7 @@ void smVegaSceneObjectDeformable::AddVertexDeformations(double * u) } } -void smVegaSceneObjectDeformable::SetVertexDeformations(double * u) +void VegaSceneObjectDeformable::SetVertexDeformations(double * u) { for(int i = 0; i < n; i++) { @@ -35,7 +35,7 @@ void smVegaSceneObjectDeformable::SetVertexDeformations(double * u) } } -void smVegaSceneObjectDeformable::SetVertexDeformations(float * u) +void VegaSceneObjectDeformable::SetVertexDeformations(float * u) { // set the deformations for(int i = 0; i < n; i++) diff --git a/src/Mesh/VegaSceneObjectDeformable.h b/src/Mesh/VegaSceneObjectDeformable.h index 86386f4bf43c4763131e5b73334ae2d5b83cceb1..43c1e887ea078571e922b75044955fd6d724e600 100644 --- a/src/Mesh/VegaSceneObjectDeformable.h +++ b/src/Mesh/VegaSceneObjectDeformable.h @@ -8,11 +8,11 @@ #include "VegaSceneObjectWithRestPosition.h" -class smVegaSceneObjectDeformable : public virtual smVegaSceneObjectWithRestPosition +class VegaSceneObjectDeformable : public virtual VegaSceneObjectWithRestPosition { public: - smVegaSceneObjectDeformable(char * filenameOBJ); - virtual ~smVegaSceneObjectDeformable(); + VegaSceneObjectDeformable(char * filenameOBJ); + virtual ~VegaSceneObjectDeformable(); // sets the current dynamic vertex positions to the rest position + specified deformation void SetVertexDeformations(double * u); @@ -28,21 +28,21 @@ public: inline void GetSingleVertexPositionFromBuffer(int vertex, double * x, double * y, double * z); }; -inline void smVegaSceneObjectDeformable::GetSingleVertexRestPosition(int vertex, double * x, double * y, double * z) +inline void VegaSceneObjectDeformable::GetSingleVertexRestPosition(int vertex, double * x, double * y, double * z) { *x = restPosition[3*vertex+0]; *y = restPosition[3 * vertex + 1]; *z = restPosition[3 * vertex + 2]; } -inline void smVegaSceneObjectDeformable::SetSingleVertexRestPosition(int vertex, double x, double y, double z) +inline void VegaSceneObjectDeformable::SetSingleVertexRestPosition(int vertex, double x, double y, double z) { restPosition[3 * vertex + 0] = x; restPosition[3 * vertex + 1] = y; restPosition[3 * vertex + 2] = z; } -inline void smVegaSceneObjectDeformable::GetSingleVertexPositionFromBuffer(int vertex, double * x, double * y, double * z) +inline void VegaSceneObjectDeformable::GetSingleVertexPositionFromBuffer(int vertex, double * x, double * y, double * z) { Vec3d pos = mesh->getPosition(vertex); *x = pos[0]; diff --git a/src/Mesh/VegaSceneObjectWithRestPosition.cpp b/src/Mesh/VegaSceneObjectWithRestPosition.cpp index 2d193db738ac559ea84eeb375edb0ed046e6f222..820e3d7d01eca1252f1d74e2d3ddae15be6104a8 100644 --- a/src/Mesh/VegaSceneObjectWithRestPosition.cpp +++ b/src/Mesh/VegaSceneObjectWithRestPosition.cpp @@ -2,7 +2,7 @@ #include <stdlib.h> #include "VegaSceneObjectWithRestPosition.h" -smVegaSceneObjectWithRestPosition::smVegaSceneObjectWithRestPosition(char * filename): smVegaSceneObject(filename) +VegaSceneObjectWithRestPosition::VegaSceneObjectWithRestPosition(char * filename): VegaSceneObject(filename) { restPosition.resize(3 * n); for(int i = 0; i < n; i++) @@ -14,13 +14,13 @@ smVegaSceneObjectWithRestPosition::smVegaSceneObjectWithRestPosition(char * file } } -smVegaSceneObjectWithRestPosition::~smVegaSceneObjectWithRestPosition() +VegaSceneObjectWithRestPosition::~VegaSceneObjectWithRestPosition() { } -void smVegaSceneObjectWithRestPosition::TransformRigidly(double * centerOfMass, double * R) +void VegaSceneObjectWithRestPosition::TransformRigidly(double * centerOfMass, double * R) { - smVegaSceneObject::TransformRigidly(centerOfMass, R); + VegaSceneObject::TransformRigidly(centerOfMass, R); for(int i=0; i<n; i++) { diff --git a/src/Mesh/VegaSceneObjectWithRestPosition.h b/src/Mesh/VegaSceneObjectWithRestPosition.h index fc771a4ca19dba0ccf17d7e8be265998e856c588..3d8c142d02aadcacc4a93e51698a7d4be766424d 100644 --- a/src/Mesh/VegaSceneObjectWithRestPosition.h +++ b/src/Mesh/VegaSceneObjectWithRestPosition.h @@ -3,11 +3,11 @@ #include "VegaSceneObject.h" -class smVegaSceneObjectWithRestPosition: public smVegaSceneObject +class VegaSceneObjectWithRestPosition: public VegaSceneObject { public: - smVegaSceneObjectWithRestPosition(char * filename); - virtual ~smVegaSceneObjectWithRestPosition(); + VegaSceneObjectWithRestPosition(char * filename); + virtual ~VegaSceneObjectWithRestPosition(); virtual void TransformRigidly(double * centerOfMass, double * R); diff --git a/src/Mesh/VegaVolumetricMesh.cpp b/src/Mesh/VegaVolumetricMesh.cpp index b0286ce8f0389cfeb32fd05c32cbbe646f08fad1..4c9299ad136c69bb2a16d5f4debe505569237e0e 100644 --- a/src/Mesh/VegaVolumetricMesh.cpp +++ b/src/Mesh/VegaVolumetricMesh.cpp @@ -23,9 +23,9 @@ #include "VegaVolumetricMesh.h" -smVegaVolumetricMesh::smVegaVolumetricMesh(bool generateMeshGraph) : generateGraph(generateMeshGraph) {} -smVegaVolumetricMesh::~smVegaVolumetricMesh() {} -void smVegaVolumetricMesh::loadMesh(const std::string &fileName, const int &verbose) +VegaVolumetricMesh::VegaVolumetricMesh(bool generateMeshGraph) : generateGraph(generateMeshGraph) {} +VegaVolumetricMesh::~VegaVolumetricMesh() {} +void VegaVolumetricMesh::loadMesh(const std::string &fileName, const int &verbose) { char * name = const_cast<char*>(fileName.c_str()); VolumetricMesh::elementType elementType = VolumetricMesh::getElementType(name); @@ -53,24 +53,24 @@ void smVegaVolumetricMesh::loadMesh(const std::string &fileName, const int &verb meshGraph = std::make_shared<Graph>(*GenerateMeshGraph::Generate(mesh.get())); } } -std::shared_ptr<Graph> smVegaVolumetricMesh::getMeshGraph() +std::shared_ptr<Graph> VegaVolumetricMesh::getMeshGraph() { return this->meshGraph; } -size_t smVegaVolumetricMesh::getNumberOfVertices() const +size_t VegaVolumetricMesh::getNumberOfVertices() const { return this->mesh->getNumVertices(); } -size_t smVegaVolumetricMesh::getNumberOfElements() const +size_t VegaVolumetricMesh::getNumberOfElements() const { return this->mesh->getNumElements(); } -void smVegaVolumetricMesh::attachSurfaceMesh(std::shared_ptr<smSurfaceMesh> surfaceMesh, const double &radius) +void VegaVolumetricMesh::attachSurfaceMesh(std::shared_ptr<SurfaceMesh> surfaceMesh, const double &radius) { const core::StdVector3d &meshVertices = surfaceMesh->getVertices(); int numElementVertices = this->mesh->getNumElementVertices(); - int surfaceMeshSize = meshVertices.size(); + size_t surfaceMeshSize = meshVertices.size(); // Allocate arrays this->attachedMeshes.push_back(surfaceMesh); @@ -123,15 +123,15 @@ void smVegaVolumetricMesh::attachSurfaceMesh(std::shared_ptr<smSurfaceMesh> surf } } } -const std::vector<double> &smVegaVolumetricMesh::getAttachedWeights(const size_t &i) const +const std::vector<double> &VegaVolumetricMesh::getAttachedWeights(const size_t &i) const { return this->attachedWeights.at(attachedMeshes[i]); } -const std::vector<int> &smVegaVolumetricMesh::getAttachedVertices(const size_t &i) const +const std::vector<int> &VegaVolumetricMesh::getAttachedVertices(const size_t &i) const { return this->attachedVertices.at(attachedMeshes[i]); } -std::shared_ptr< VolumetricMesh > smVegaVolumetricMesh::getVegaMesh() +std::shared_ptr< VolumetricMesh > VegaVolumetricMesh::getVegaMesh() { return this->mesh; } diff --git a/src/Mesh/VegaVolumetricMesh.h b/src/Mesh/VegaVolumetricMesh.h index 122179c9df12df30a6e8153e9f11356a5394fc02..14caaf317c1306b0e6c4998a54d49cea46d8a793 100644 --- a/src/Mesh/VegaVolumetricMesh.h +++ b/src/Mesh/VegaVolumetricMesh.h @@ -42,18 +42,18 @@ // // Interface to VegaFEM's volumetric mesh class // -class smVegaVolumetricMesh +class VegaVolumetricMesh { public: /// /// @brief Constructor /// - smVegaVolumetricMesh(bool generateMeshGraph = true); + VegaVolumetricMesh(bool generateMeshGraph = true); /// /// @brief Destructor /// - ~smVegaVolumetricMesh(); + ~VegaVolumetricMesh(); /// /// @brief Loads vega volume mesh and stores it locally @@ -79,7 +79,7 @@ public: /// /// @brief Attach surface mesh to the volume mesh and stores interpolation weights /// - void attachSurfaceMesh(std::shared_ptr<smSurfaceMesh> surfaceMesh, const double &radius = -1.0); + void attachSurfaceMesh(std::shared_ptr<SurfaceMesh> surfaceMesh, const double &radius = -1.0); /// /// @brief Returns weigths associated with attached ith surface mesh @@ -107,13 +107,13 @@ private: bool generateGraph; // Store pointer to the surface meshes - std::vector<std::shared_ptr<smSurfaceMesh>> attachedMeshes; + std::vector<std::shared_ptr<SurfaceMesh>> attachedMeshes; // Store map of vertices - std::map<std::shared_ptr<smSurfaceMesh>,std::vector<int>> attachedVertices; + std::map<std::shared_ptr<SurfaceMesh>,std::vector<int>> attachedVertices; // Store map of weigths - std::map<std::shared_ptr<smSurfaceMesh>,std::vector<double>> attachedWeights; + std::map<std::shared_ptr<SurfaceMesh>,std::vector<double>> attachedWeights; }; diff --git a/src/Mesh/VolumeMesh.cpp b/src/Mesh/VolumeMesh.cpp index 7d9d3c6e0624403660e03b7f86a7ad48db33402b..113894f08409b3e5c4256384b6ca47612d6fe82e 100644 --- a/src/Mesh/VolumeMesh.cpp +++ b/src/Mesh/VolumeMesh.cpp @@ -25,7 +25,7 @@ /// \brief constructor -smVolumeMesh::smVolumeMesh(const smMeshType &p_meshtype, std::shared_ptr<ErrorLog> log) +VolumeMesh::VolumeMesh(const MeshType &p_meshtype, std::shared_ptr<ErrorLog> log) { this->log_VM = log; @@ -34,12 +34,12 @@ smVolumeMesh::smVolumeMesh(const smMeshType &p_meshtype, std::shared_ptr<ErrorLo } /// \brief loads the specified volume mesh -bool smVolumeMesh::loadMesh(const std::string& fileName, const smMeshFileType &fileType) +bool VolumeMesh::loadMesh(const std::string& fileName, const MeshFileType &fileType) { bool ret; - if (fileType == SM_FILETYPE_VOLUME) + if (fileType == BaseMesh::MeshFileType::Volume) { ret = LoadTetra(fileName); @@ -63,7 +63,7 @@ bool smVolumeMesh::loadMesh(const std::string& fileName, const smMeshFileType &f } /// \brief -void smVolumeMesh::translateVolumeMesh(const core::Vec3d &p_offset) +void VolumeMesh::translateVolumeMesh(const core::Vec3d &p_offset) { this->translate(p_offset); @@ -75,7 +75,7 @@ void smVolumeMesh::translateVolumeMesh(const core::Vec3d &p_offset) } /// \brief -void smVolumeMesh::scaleVolumeMesh(const core::Vec3d &p_offset) +void VolumeMesh::scaleVolumeMesh(const core::Vec3d &p_offset) { scale(p_offset); @@ -87,7 +87,7 @@ void smVolumeMesh::scaleVolumeMesh(const core::Vec3d &p_offset) } /// \brief -void smVolumeMesh::rotVolumeMesh(const Matrix33d &p_rot) +void VolumeMesh::rotVolumeMesh(const Matrix33d &p_rot) { rotate(p_rot); @@ -100,7 +100,7 @@ void smVolumeMesh::rotVolumeMesh(const Matrix33d &p_rot) /// \brief loads the tetra mesh from abacus ///Extensions to support other formats will come soon... -bool smVolumeMesh::LoadTetra(const std::string& fileName) +bool VolumeMesh::LoadTetra(const std::string& fileName) { float number; @@ -153,8 +153,8 @@ bool smVolumeMesh::LoadTetra(const std::string& fileName) for (i = 0; i < nbrTetra; i++) { - tetra.emplace_back(smTetrahedra()); - smTetrahedra &tetrahedra = tetra.back(); + tetra.emplace_back(Tetrahedra()); + Tetrahedra &tetrahedra = tetra.back(); fscanf(fp, "%f", &number); fscanf(fp, "%c", &comma); fscanf(fp, "%f", &number); @@ -176,7 +176,7 @@ bool smVolumeMesh::LoadTetra(const std::string& fileName) } /// \brief loads the surface vertices and triangles -bool smVolumeMesh::getSurface(const std::string& fileName) +bool VolumeMesh::getSurface(const std::string& fileName) { float number; @@ -197,7 +197,7 @@ bool smVolumeMesh::getSurface(const std::string& fileName) char stri[19]; fscanf(fp, "%s\n", stri); - std::vector<smTriangle> triangles; + std::vector<Triangle> triangles; for (i = 0; i < nbrTriangles; i++) { fscanf(fp, "%f", &number); @@ -275,7 +275,7 @@ bool smVolumeMesh::getSurface(const std::string& fileName) /// \brief loads the tetra mesh from abacus ///Extensions to support other formats will come soon... -bool smVolumeMesh::readBC(const std::string& fileName) +bool VolumeMesh::readBC(const std::string& fileName) { int number; char comma; @@ -302,7 +302,7 @@ bool smVolumeMesh::readBC(const std::string& fileName) } /// \brief copies the updated co-ordinates of the surface vertices only -void smVolumeMesh::copySurface() +void VolumeMesh::copySurface() { int i; @@ -319,7 +319,7 @@ void smVolumeMesh::copySurface() } /// \brief copies the updated co-ordinates of the surface vertices only -void smVolumeMesh::initSurface() +void VolumeMesh::initSurface() { int i; @@ -339,21 +339,21 @@ void smVolumeMesh::initSurface() updateVertexNormals(); } // WIP -void smVolumeMesh::updateVolumeMeshFromVegaFormat(const std::shared_ptr<const VolumetricMesh> vega3dMesh) +void VolumeMesh::updateVolumeMeshFromVegaFormat(const std::shared_ptr<const VolumetricMesh> /*vega3dMesh*/) { - int i, threeI; +// int i, threeI; //copy the nodal co-ordinates - for(i=0; i<this->nbrVertices ; i++) - { - threeI = 3*i; +// for(i=0; i<this->nbrVertices ; i++) +// { +// threeI = 3*i; /*this->nodes[i][0] = (*nodes)[threeI]; this->nodes[i][1] = (*nodes)[threeI+1]; this->nodes[i][2] = (*nodes)[threeI+2];*/ - } +// } } -void smVolumeMesh::importVolumeMeshFromVegaFormat(const std::shared_ptr<const VolumetricMesh> vega3dMesh, const bool preProcessingStage) +void VolumeMesh::importVolumeMeshFromVegaFormat(const std::shared_ptr<const VolumetricMesh> vega3dMesh, const bool preProcessingStage) { int i, threeI, j; @@ -403,12 +403,12 @@ void smVolumeMesh::importVolumeMeshFromVegaFormat(const std::shared_ptr<const Vo } /// \brief destructor -smVolumeMesh::~smVolumeMesh() +VolumeMesh::~VolumeMesh() { } -smVolumeMesh::smVolumeMesh() +VolumeMesh::VolumeMesh() { nbrNodes = 0; nbrTetra = 0; diff --git a/src/Mesh/VolumeMesh.h b/src/Mesh/VolumeMesh.h index 26155c693ab4510478cd4997a33b26461125eb1a..dce21b47389aa3828289a1cdd6cc89d7772f370a 100644 --- a/src/Mesh/VolumeMesh.h +++ b/src/Mesh/VolumeMesh.h @@ -33,17 +33,17 @@ /// \brief this class is derived from generic Mesh class. Tetrahedron are building blocks of this volume mesh. /// It also retains the surface triangle structure for rendering and collision detection purposes. /// This surface triangle structure might be extracted from the volume mesh while loading -class smVolumeMesh: public smMesh +class VolumeMesh: public Mesh { public: /// \brief constructor - smVolumeMesh(); + VolumeMesh(); /// \brief constructor - smVolumeMesh(const smMeshType &meshtype, std::shared_ptr<ErrorLog> log); + VolumeMesh(const MeshType &meshtype, std::shared_ptr<ErrorLog> log); /// \brief destructor - ~smVolumeMesh(); + ~VolumeMesh(); /// \brief constructor void GenerateTetra(const std::string& fileName); @@ -73,7 +73,7 @@ public: void rotVolumeMesh(const Matrix33d &p_rot); /// \brief load the mesh - bool loadMesh(const std::string& fileName, const smMeshFileType &fileType); + bool loadMesh(const std::string& fileName, const MeshFileType &fileType); /// \brief populate the mesh data from the vega volumetric mesh file format void importVolumeMeshFromVegaFormat(const std::shared_ptr<const VolumetricMesh> vega3dMesh, const bool preProcessingStage); @@ -82,12 +82,12 @@ public: void updateVolumeMeshFromVegaFormat(const std::shared_ptr<const VolumetricMesh> vega3dMesh); public: - /// push smMesh class specific errors here + /// push Mesh class specific errors here int nbrTetra; ///< number of tetrahedra int nbrNodes; ///< total number of nodes of the volume mesh std::shared_ptr<ErrorLog> log_VM; ///< log the errors with volume mesh class core::StdVector3d nodes; ///< data of nodal co-ordinates - std::vector<smTetrahedra> tetra; ///< tetrahedra data + std::vector<Tetrahedra> tetra; ///< tetrahedra data std::vector<int> surfaceNodeIndex; ///< std::vector<bool> fixed; ///< indicates if the node is fixed or not }; diff --git a/src/RenderDelegates/AABBRenderDelegate.cpp b/src/RenderDelegates/AABBRenderDelegate.cpp index 9f062310245000efbd3a54365e30a8e41e049bfb..7efee98029d61afbefb6780df7fc78a5b4d12a26 100644 --- a/src/RenderDelegates/AABBRenderDelegate.cpp +++ b/src/RenderDelegates/AABBRenderDelegate.cpp @@ -2,13 +2,13 @@ #include "Core/RenderDelegate.h" #include "Core/Factory.h" -class smAABBRenderDelegate : public RenderDelegate +class AABBRenderDelegate : public RenderDelegate { public: virtual void draw() const override; }; -void smAABBRenderDelegate::draw() const +void AABBRenderDelegate::draw() const { AABB* geom = this->getSourceGeometryAs<AABB>(); if (!geom) @@ -48,6 +48,6 @@ void smAABBRenderDelegate::draw() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_aabb_render_delegate) - SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smAABBRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,AABBRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/CMakeLists.txt b/src/RenderDelegates/CMakeLists.txt index bdb79b8c1f84c8ec232d58ff2b83ea6040f3f57f..f4e943e0db6691624ac389fb02f0c85c55251014 100644 --- a/src/RenderDelegates/CMakeLists.txt +++ b/src/RenderDelegates/CMakeLists.txt @@ -1,7 +1,6 @@ simmedtk_add_library(RenderDelegates SOURCES AABBRenderDelegate.cpp - LatticeRenderDelegate.cpp MeshRenderDelegate.cpp PlaneRenderDelegate.cpp SceneObjectDeformableRenderDelegate.cpp diff --git a/src/RenderDelegates/Config.h b/src/RenderDelegates/Config.h index 308256f399d944f0cefe184c5c3c9a72b88ee578..5703ab6b3c543ff4b06daf07bd1ca757177fec6d 100644 --- a/src/RenderDelegates/Config.h +++ b/src/RenderDelegates/Config.h @@ -13,8 +13,8 @@ SIMMEDTK_RUN_LOADER(register_static_scene_object_render_delegate); \ SIMMEDTK_RUN_LOADER(register_stylus_render_delegate); \ SIMMEDTK_RUN_LOADER(register_surface_tree_render_delegate) - //SIMMEDTK_RUN_LOADER(register_fem_scene_render_delegate); \ - //SIMMEDTK_RUN_LOADER(register_pbd_surface_render_delegate); \ - //SIMMEDTK_RUN_LOADER(register_physx_volume_mesh_render_delegate); \ + //SIMMEDTK_RUN_LOADER(register_fem_scene_render_delegate); + //SIMMEDTK_RUN_LOADER(register_pbd_surface_render_delegate); + //SIMMEDTK_RUN_LOADER(register_physx_volume_mesh_render_delegate); #endif // SMRENDERDELEGATES_CONFIG_H diff --git a/src/RenderDelegates/FemSceneRenderDelegate.cpp b/src/RenderDelegates/FemSceneRenderDelegate.cpp index 4efb7b862d12fc7e33bb7d9da35f4d8497d98284..a14edd66e7e1ad527fb5df5d9a1081ebb9e11db2 100644 --- a/src/RenderDelegates/FemSceneRenderDelegate.cpp +++ b/src/RenderDelegates/FemSceneRenderDelegate.cpp @@ -3,15 +3,15 @@ #include "Core/Factory.h" #include "Mesh/VolumeMesh.h" -class smFemSceneRenderDelegate : public RenderDelegate +class FemSceneRenderDelegate : public RenderDelegate { public: virtual void draw() const override; }; -void smFemSceneRenderDelegate::draw() const +void FemSceneRenderDelegate::draw() const { - smVolumeMesh* v_mesh = this->getSourceGeometryAs<smFemSceneObject>()->v_mesh; + VolumeMesh* v_mesh = this->getSourceGeometryAs<smFemSceneObject>()->v_mesh; RenderDelegate::Ptr delegate = v_mesh->getRenderDelegate(); if (delegate) delegate->draw(); @@ -19,6 +19,6 @@ void smFemSceneRenderDelegate::draw() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_fem_scene_render_delegate) - SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smFemSceneRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,FemSceneRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/LatticeRenderDelegate.cpp b/src/RenderDelegates/LatticeRenderDelegate.cpp deleted file mode 100644 index e70575c3a5ab94379176434c3df987db9675743c..0000000000000000000000000000000000000000 --- a/src/RenderDelegates/LatticeRenderDelegate.cpp +++ /dev/null @@ -1,175 +0,0 @@ -#include "Mesh/Lattice.h" -#include "Core/RenderDelegate.h" -#include "Core/Factory.h" - -class smLatticeRenderDelegate : public RenderDelegate -{ -public: - virtual void draw() const override; -}; - -void smLatticeRenderDelegate::draw() const -{ - smLattice* geom = this->getSourceGeometryAs<smLattice>(); - if (!geom) - return; - - int index = 0; - int index2 = 0; - int latticeMode; - latticeMode = SIMMEDTK_SMLATTICE_CELLPOINTSLINKS; - - if ( geom->cells == NULL || latticeMode == SIMMEDTK_SMLATTICE_NONE ) - { - return; - } - - glMatrixMode( GL_MODELVIEW ); - glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, reinterpret_cast<GLfloat*>(&Color::colorYellow)); - - if ( latticeMode & SIMMEDTK_SMLATTICE_SEPERATIONLINES ) - { - for ( int j = 0; j < geom->ySeperation; j++ ) - { - glDisable( GL_LIGHTING ); - glColor3fv(reinterpret_cast<GLfloat*>(&Color::colorWhite)); - - glBegin( GL_LINES ); - - for ( int i = 0; i < geom->xSeperation; i++ ) - { - index = i + j * geom->xSeperation * geom->zSeperation; - index2 = index + geom->xSeperation * ( geom->zSeperation - 1 ); - glVertex3d( geom->cells[index].cellLeftCorner[0], - geom->cells[index].cellLeftCorner[1], - geom->cells[index].cellLeftCorner[2] - 4 * geom->zStep ); - glVertex3d( geom->cells[index2].cellLeftCorner[0], - geom->cells[index2].cellLeftCorner[1], - geom->cells[index2].cellLeftCorner[2] + 4 * geom->zStep ); - } - - for ( int i = 0; i < geom->zSeperation; i++ ) - { - index = i * geom->xSeperation + j * geom->xSeperation * geom->zSeperation; - index2 = index + ( geom->xSeperation - 1 ); - glVertex3d( geom->cells[index].cellLeftCorner[0] - 4 * geom->xStep, - geom->cells[index].cellLeftCorner[1], - geom->cells[index].cellLeftCorner[2] ); - glVertex3d( geom->cells[index2].cellLeftCorner[0] + 4 * geom->xStep, - geom->cells[index2].cellLeftCorner[1], - geom->cells[index2].cellLeftCorner[2] ); - } - - glEnd(); - } - - glEnable( GL_LIGHTING ); - glPopMatrix(); - } - - if ( latticeMode & (SIMMEDTK_SMLATTICE_CELLPOINTS | SIMMEDTK_SMLATTICE_CELLPOINTSLINKS) ) - { - for ( int y = 0; y < geom->ySeperation; y++ ) - for ( int z = 0; z < geom->zSeperation; z++ ) - for ( int x = 0; x < geom->xSeperation; x++ ) - { - - index = x + z * geom->xSeperation + y * geom->xSeperation * geom->zSeperation; - - if ( latticeMode & SIMMEDTK_SMLATTICE_CELLPOINTSLINKS ) - { - glDisable( GL_LIGHTING ); - glDisable( GL_TEXTURE_2D ); - - glEnable( GL_COLOR_MATERIAL ); - - glBegin( GL_LINE_STRIP ); - glColor3fv( reinterpret_cast<GLfloat*>(&Color::colorWhite)); - glVertex3dv( geom->cells[index].cellLeftCorner.data() ); - glVertex3d( geom->cells[index].cellLeftCorner[0] + geom->xStep, - geom->cells[index].cellLeftCorner[1], - geom->cells[index].cellLeftCorner[2] ); - glVertex3d( geom->cells[index].cellLeftCorner[0] + geom->xStep, - geom->cells[index].cellLeftCorner[1], - geom->cells[index].cellLeftCorner[2] + geom->zStep ); - glVertex3d( geom->cells[index].cellLeftCorner[0], - geom->cells[index].cellLeftCorner[1], - geom->cells[index].cellLeftCorner[2] + geom->zStep ); - glVertex3dv( geom->cells[index].cellLeftCorner.data()); - - glVertex3d( geom->cells[index].cellLeftCorner[0], - geom->cells[index].cellLeftCorner[1] + geom->yStep, - geom->cells[index].cellLeftCorner[2] ); - glVertex3d( geom->cells[index].cellLeftCorner[0] + geom->xStep, - geom->cells[index].cellLeftCorner[1] + geom->yStep, - geom->cells[index].cellLeftCorner[2] ); - glVertex3d( geom->cells[index].cellLeftCorner[0] + geom->xStep, - geom->cells[index].cellLeftCorner[1] + geom->yStep, - geom->cells[index].cellLeftCorner[2] + geom->zStep ); - glVertex3d( geom->cells[index].cellLeftCorner[0], - geom->cells[index].cellLeftCorner[1] + geom->yStep, - geom->cells[index].cellLeftCorner[2] + geom->zStep ); - glVertex3d( geom->cells[index].cellLeftCorner[0], - geom->cells[index].cellLeftCorner[1] + geom->yStep, - geom->cells[index].cellLeftCorner[2] ); - glEnd(); - - glBegin( GL_LINES ); - glColor3fv( reinterpret_cast<GLfloat*>(&Color::colorWhite)); - glVertex3dv( geom->cells[index].cellLeftCorner.data() ); - glVertex3d( geom->cells[index].cellLeftCorner[0], - geom->cells[index].cellLeftCorner[1] + geom->yStep, - geom->cells[index].cellLeftCorner[2] ); - - glVertex3d( geom->cells[index].cellLeftCorner[0] + geom->xStep, - geom->cells[index].cellLeftCorner[1], - geom->cells[index].cellLeftCorner[2] ); - glVertex3d( geom->cells[index].cellLeftCorner[0] + geom->xStep, - geom->cells[index].cellLeftCorner[1] + geom->yStep, - geom->cells[index].cellLeftCorner[2] ); - - glVertex3d( geom->cells[index].cellLeftCorner[0] + geom->xStep, - geom->cells[index].cellLeftCorner[1], - geom->cells[index].cellLeftCorner[2] + geom->zStep ); - glVertex3d( geom->cells[index].cellLeftCorner[0] + geom->xStep, - geom->cells[index].cellLeftCorner[1] + geom->yStep, - geom->cells[index].cellLeftCorner[2] + geom->zStep ); - - glVertex3d( geom->cells[index].cellLeftCorner[0], - geom->cells[index].cellLeftCorner[1], - geom->cells[index].cellLeftCorner[2] + geom->zStep ); - glVertex3d( geom->cells[index].cellLeftCorner[0], - geom->cells[index].cellLeftCorner[1] + geom->yStep, - geom->cells[index].cellLeftCorner[2] + geom->zStep ); - glEnd(); - - glEnable( GL_LIGHTING ); - } - } - } - - if ( latticeMode & SIMMEDTK_SMLATTICE_MINMAXPOINTS ) - { - glPushMatrix(); - glPushMatrix(); - glTranslatef( geom->cells[0].cellLeftCorner[0], geom->cells[0].cellLeftCorner[1], geom->cells[0].cellLeftCorner[2] ); - glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, reinterpret_cast<GLfloat*>(&Color::colorYellow)); - // glutSolidSphere( 2, 20, 20 ); - glPopMatrix(); - - glPushMatrix(); - glTranslatef( geom->cells[geom->totalCells - 1].cellRightCorner[0], - geom->cells[geom->totalCells - 1].cellRightCorner[1], - geom->cells[geom->totalCells - 1].cellRightCorner[2] ); - glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, reinterpret_cast<GLfloat*>(&Color::colorRed)); - // glutSolidSphere( 2, 20, 20 ); - glPopMatrix(); - glPopMatrix(); - } -} - -SIMMEDTK_BEGIN_DYNAMIC_LOADER() - SIMMEDTK_BEGIN_ONLOAD(register_lattice_render_delegate) - SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smLatticeRenderDelegate,2000); - SIMMEDTK_FINISH_ONLOAD() -SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/MeshRenderDelegate.cpp b/src/RenderDelegates/MeshRenderDelegate.cpp index b0d74104c13d5214ea4b598a7a48626ea2d97e67..1d1cac27f69f2b6e5af068cbb24a9c6ce7bd24f7 100644 --- a/src/RenderDelegates/MeshRenderDelegate.cpp +++ b/src/RenderDelegates/MeshRenderDelegate.cpp @@ -3,33 +3,33 @@ #include "Core/Factory.h" #include "Mesh/Mesh.h" -class smMeshRenderDelegate : public RenderDelegate +class MeshRenderDelegate : public RenderDelegate { public: virtual void draw() const override; virtual bool isTargetTextured() const override; }; -void smMeshRenderDelegate::draw() const +void MeshRenderDelegate::draw() const { - auto geom = this->getSourceGeometryAs<smMesh>(); + auto geom = this->getSourceGeometryAs<Mesh>(); if (!geom) return; - auto mesh = std::dynamic_pointer_cast<smMesh>(geom->shared_from_this()); - smGLRenderer::drawSurfaceMeshTriangles(mesh, geom->getRenderDetail()); + auto mesh = std::dynamic_pointer_cast<Mesh>(geom->shared_from_this()); + GLRenderer::drawSurfaceMeshTriangles(mesh, geom->getRenderDetail()); if (geom->getRenderDetail()->renderType & SIMMEDTK_RENDER_NORMALS) { - smGLRenderer::drawNormals(mesh, + GLRenderer::drawNormals(mesh, geom->getRenderDetail()->normalColor, geom->getRenderDetail()->normalLength); } } -bool smMeshRenderDelegate::isTargetTextured() const +bool MeshRenderDelegate::isTargetTextured() const { - auto geom = this->getSourceGeometryAs<smMesh>(); + auto geom = this->getSourceGeometryAs<Mesh>(); if (!geom) return false; @@ -38,6 +38,6 @@ bool smMeshRenderDelegate::isTargetTextured() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_mesh_render_delegate) - SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smMeshRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,MeshRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/PBDSurfaceRenderDelegate.cpp b/src/RenderDelegates/PBDSurfaceRenderDelegate.cpp index b2b86073f62ceaeccd47da8888b37f4050c86986..b12756031202abac5b8f37228c8b997f4957d702 100644 --- a/src/RenderDelegates/PBDSurfaceRenderDelegate.cpp +++ b/src/RenderDelegates/PBDSurfaceRenderDelegate.cpp @@ -2,20 +2,20 @@ #include "Core/RenderDelegate.h" #include "Simulators/PBDSceneObject.h" -class smPBDSurfaceRenderDelegate : public RenderDelegate +class PBDSurfaceRenderDelegate : public RenderDelegate { public: virtual void draw() const override; }; -void smPBDSurfaceRenderDelegate::draw() const +void PBDSurfaceRenderDelegate::draw() const { - smSurfaceMesh* mesh = this->getSourceGeometryAs<smPBDSurfaceSceneObject>()->mesh; + SurfaceMesh* mesh = this->getSourceGeometryAs<smPBDSurfaceSceneObject>()->mesh; mesh->draw(); } SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_pbd_surface_render_delegate) - SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smPBDSurfaceRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,PBDSurfaceRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/PlaneRenderDelegate.cpp b/src/RenderDelegates/PlaneRenderDelegate.cpp index 3ea795ad1589117d2468ff494409c179269585f4..27ed142e4a5238317a5fde056243e218e0573494 100644 --- a/src/RenderDelegates/PlaneRenderDelegate.cpp +++ b/src/RenderDelegates/PlaneRenderDelegate.cpp @@ -2,15 +2,15 @@ #include "Core/RenderDelegate.h" #include "Core/Factory.h" -class smPlaneRenderDelegate : public RenderDelegate +class PlaneRenderDelegate : public RenderDelegate { public: virtual void draw() const override; }; -void smPlaneRenderDelegate::draw() const +void PlaneRenderDelegate::draw() const { - smGLRenderer::draw(*this->getSourceGeometryAs<Plane>()); + GLRenderer::draw(*this->getSourceGeometryAs<Plane>()); // if (this->movedOrRotated) // { // updateDrawPoints(); @@ -41,6 +41,6 @@ void smPlaneRenderDelegate::draw() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_plane_render_delegate) - SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smPlaneRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,PlaneRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/SceneObjectDeformableRenderDelegate.cpp b/src/RenderDelegates/SceneObjectDeformableRenderDelegate.cpp index 0c909ffd912246b1379e118c81e010b5563aea7e..2b15503414a8628031a3c650371cbed0638de9dc 100644 --- a/src/RenderDelegates/SceneObjectDeformableRenderDelegate.cpp +++ b/src/RenderDelegates/SceneObjectDeformableRenderDelegate.cpp @@ -4,13 +4,13 @@ /// \brief Displays the fem object with primary or secondary mesh, fixed vertices, /// vertices interacted with, ground plane etc. -class smSceneObjectDeformableRenderDelegate : public RenderDelegate +class SceneObjectDeformableRenderDelegate : public RenderDelegate { public: virtual void draw() const override; }; -void smSceneObjectDeformableRenderDelegate::draw() const +void SceneObjectDeformableRenderDelegate::draw() const { auto geom = this->getSourceGeometryAs<smSceneObjectDeformable>(); if (!geom) @@ -28,6 +28,6 @@ void smSceneObjectDeformableRenderDelegate::draw() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_scene_object_deformable_render_delegate) - SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smSceneObjectDeformableRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,SceneObjectDeformableRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/StaticSceneObjectRenderDelegate.cpp b/src/RenderDelegates/StaticSceneObjectRenderDelegate.cpp index 78ac3c645cd6e1840b5e981fce6746f04b72f45f..dcd4826c5f797f3bbdaac46b388f4a6c125f7208 100644 --- a/src/RenderDelegates/StaticSceneObjectRenderDelegate.cpp +++ b/src/RenderDelegates/StaticSceneObjectRenderDelegate.cpp @@ -2,13 +2,13 @@ #include "Core/RenderDelegate.h" #include "Core/Factory.h" -class smStaticSceneObjectRenderDelegate : public RenderDelegate +class StaticSceneObjectRenderDelegate : public RenderDelegate { public: virtual void draw() const override; }; -void smStaticSceneObjectRenderDelegate::draw() const +void StaticSceneObjectRenderDelegate::draw() const { StaticSceneObject* geom = this->getSourceGeometryAs<StaticSceneObject>(); if (!geom) @@ -19,6 +19,6 @@ void smStaticSceneObjectRenderDelegate::draw() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_static_scene_object_render_delegate) - SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smStaticSceneObjectRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,StaticSceneObjectRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/StylusRenderDelegate.cpp b/src/RenderDelegates/StylusRenderDelegate.cpp index 5ab106aa84f5174be80d946f0190be6d9690679c..4912be21b3eba18a13520587cb3f83ff8f68ffcf 100644 --- a/src/RenderDelegates/StylusRenderDelegate.cpp +++ b/src/RenderDelegates/StylusRenderDelegate.cpp @@ -1,23 +1,24 @@ + #include "Core/Geometry.h" #include "Core/RenderDelegate.h" #include "Core/Factory.h" #include "Rendering/GLUtils.h" #include "Simulators/StylusObject.h" -class smStylusRenderDelegate : public RenderDelegate +class StylusRenderDelegate : public RenderDelegate { public: virtual void initDraw() const override; virtual void draw() const override; }; -void smStylusRenderDelegate::initDraw() const +void StylusRenderDelegate::initDraw() const { smStylusRigidSceneObject* geom = this->getSourceGeometryAs<smStylusRigidSceneObject>(); std::string errorText; tree<smMeshContainer*>::pre_order_iterator iter = geom->meshes.begin(); GLint newList = glGenLists(geom->meshes.size()); - smGLUtils::queryGLError(errorText); + GLUtils::queryGLError(errorText); int listCounter = 0; @@ -32,13 +33,11 @@ void smStylusRenderDelegate::initDraw() const } } -void smStylusRenderDelegate::draw() const +void StylusRenderDelegate::draw() const { smStylusRigidSceneObject* geom = this->getSourceGeometryAs<smStylusRigidSceneObject>(); Matrix44d viewMatrix; -#pragma unroll - for (int i = 0; i < 2; i++) { glMatrixMode(GL_MODELVIEW); @@ -85,6 +84,6 @@ void smStylusRenderDelegate::draw() const SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_stylus_render_delegate) - SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,smStylusRenderDelegate,2000); + SIMMEDTK_REGISTER_CLASS(RenderDelegate,RenderDelegate,StylusRenderDelegate,2000); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/RenderDelegates/SurfaceTreeRenderDelegate.cpp b/src/RenderDelegates/SurfaceTreeRenderDelegate.cpp index 4c9e2eba48974352e168d8a0b30288db80d1e60d..745bd501f60b0dfc4c0e5b0ff8a589d4dcca2234 100644 --- a/src/RenderDelegates/SurfaceTreeRenderDelegate.cpp +++ b/src/RenderDelegates/SurfaceTreeRenderDelegate.cpp @@ -29,7 +29,6 @@ bool SurfaceTreeRenderDelegate::drawTree() const return false; core::Vec3d center; - double length; glColor3fv(Color::colorGreen.toGLColor()); glEnable(GL_LIGHTING); diff --git a/src/Rendering/CMakeLists.txt b/src/Rendering/CMakeLists.txt index 7d3ccf4a8ca022e68b40ef211847a4909de11eef..477dfde0902d49e96b37789c4ae9f4e4307f7c24 100644 --- a/src/Rendering/CMakeLists.txt +++ b/src/Rendering/CMakeLists.txt @@ -5,7 +5,7 @@ simmedtk_add_library(Rendering FrameBuffer.cpp GLUtils.cpp MetalShader.cpp - Renderer.cpp + GLRenderer.cpp Shader.cpp SceneTextureShader.cpp TextureManager.cpp diff --git a/src/Rendering/Camera.cpp b/src/Rendering/Camera.cpp index 4644ae5a2a04e2e09f7a2d338968cce0a99ab718..39672b1f9f9a1d32d6e1a4aafcc31714fde20b47 100644 --- a/src/Rendering/Camera.cpp +++ b/src/Rendering/Camera.cpp @@ -25,32 +25,31 @@ #include "Core/Vector.h" #include "Camera.h" -smCamera::smCamera() - : ar(4.0 / 3.0), +Camera::Camera() + : pos(0, 0, 0), + fp(0, 0, -1), + ar(4.0 / 3.0), angle(M_PI_4), nearClip(0.1), - farClip(100.0), - pos(0, 0, 0), - fp(0, 0, -1), - orientation() + farClip(100.0) { viewDirty.store(true); - projDirty.store(true); orientDirty.store(false); + projDirty.store(true); } -core::Vec3f smCamera::getPos() +core::Vec3f Camera::getPos() { std::lock_guard<std::mutex> lock(posLock); return this->pos; } -void smCamera::setPos(const float x, const float y, const float z) +void Camera::setPos(const float x, const float y, const float z) { this->setPos(core::Vec3f(x, y, z)); } -void smCamera::setPos(const core::Vec3f& v) +void Camera::setPos(const core::Vec3f& v) { {//scoped for mutex release std::lock_guard<std::mutex> lock(posLock); @@ -60,18 +59,18 @@ void smCamera::setPos(const core::Vec3f& v) this->orientDirty.store(true); } -core::Vec3f smCamera::getFocus() +core::Vec3f Camera::getFocus() { std::lock_guard<std::mutex> lock(fpLock); return this->fp; } -void smCamera::setFocus(const float x, const float y, const float z) +void Camera::setFocus(const float x, const float y, const float z) { this->setFocus(core::Vec3f(x, y, z)); } -void smCamera::setFocus(const core::Vec3f& v) +void Camera::setFocus(const core::Vec3f& v) { { //scoped for mutex release std::lock_guard<std::mutex> lock(fpLock); @@ -81,73 +80,73 @@ void smCamera::setFocus(const core::Vec3f& v) this->orientDirty.store(true); } -core::Vec3f smCamera::getUpVec() +core::Vec3f Camera::getUpVec() { return getOrientation() * core::Vec3f::UnitY(); } -core::Vec3f smCamera::getDirection() +core::Vec3f Camera::getDirection() { return -(getOrientation() * core::Vec3f::UnitZ()); } -float smCamera::getAspectRatio() +float Camera::getAspectRatio() { return this->ar.load(); } -void smCamera::setAspectRatio(const float ar) +void Camera::setAspectRatio(const float ar) { this->ar.store(ar); this->projDirty.store(true); } -float smCamera::getViewAngle() +float Camera::getViewAngle() { return this->angle.load(); } -void smCamera::setViewAngle(const float a) +void Camera::setViewAngle(const float a) { this->angle.store(a); this->projDirty.store(true); } -float smCamera::getViewAngleDeg() +float Camera::getViewAngleDeg() { // Return degrees return 57.2957795130823*getViewAngle(); } -void smCamera::setViewAngleDeg(const float a) +void Camera::setViewAngleDeg(const float a) { // Use radians setViewAngle(0.0174532925199433*a); } -float smCamera::getNearClipDist() +float Camera::getNearClipDist() { return this->nearClip.load(); } -void smCamera::setNearClipDist(const float d) +void Camera::setNearClipDist(const float d) { this->nearClip.store(d); this->projDirty.store(true); } -float smCamera::getFarClipDist() +float Camera::getFarClipDist() { return this->farClip.load(); } -void smCamera::setFarClipDist(const float d) +void Camera::setFarClipDist(const float d) { this->farClip.store(d); this->projDirty.store(true); } -void smCamera::setOrientation(const Quaternionf q) +void Camera::setOrientation(const Quaternionf q) { { //scoped for mutex release std::lock_guard<std::mutex> lock(orientationLock); @@ -156,7 +155,7 @@ void smCamera::setOrientation(const Quaternionf q) this->orientDirty.store(false); } -void smCamera::setOrientFromDir(const core::Vec3f d) +void Camera::setOrientFromDir(const core::Vec3f d) { Matrix33f camAxes; core::Vec3f tempUp; @@ -171,7 +170,7 @@ void smCamera::setOrientFromDir(const core::Vec3f d) setOrientation(Quaternionf(camAxes)); } -Quaternionf smCamera::getOrientation() +Quaternionf Camera::getOrientation() { if (true == this->orientDirty.load()) { @@ -181,7 +180,7 @@ Quaternionf smCamera::getOrientation() return this->orientation; } -Matrix44f smCamera::getViewMat() +Matrix44f Camera::getViewMat() { if (true == this->viewDirty.load()) { @@ -191,7 +190,7 @@ Matrix44f smCamera::getViewMat() return this->view; } -void smCamera::setViewMat(const Matrix44f &m) +void Camera::setViewMat(const Matrix44f &m) { { //scoped for mutex release std::lock_guard<std::mutex> lock(viewLock); @@ -200,7 +199,7 @@ void smCamera::setViewMat(const Matrix44f &m) this->viewDirty.store(false); } -Matrix44f smCamera::getProjMat() +Matrix44f Camera::getProjMat() { if (true == this->projDirty.load()) { @@ -210,7 +209,7 @@ Matrix44f smCamera::getProjMat() return this->proj; } -void smCamera::setProjMat(const Matrix44f &m) +void Camera::setProjMat(const Matrix44f &m) { { //scoped for mutex release std::lock_guard<std::mutex> lock(projLock); @@ -219,14 +218,14 @@ void smCamera::setProjMat(const Matrix44f &m) this->projDirty.store(false); } -void smCamera::pan(core::Vec3f v) +void Camera::pan(core::Vec3f v) { v = getOrientation() * v; setPos(getPos() + v); setFocus(getFocus() + v); } -void smCamera::zoom(const float d) +void Camera::zoom(const float d) { float dist = (getPos() - getFocus()).norm(); if (dist > d) @@ -235,7 +234,7 @@ void smCamera::zoom(const float d) } } -void smCamera::rotateLocal(const float angle, const core::Vec3f axis) +void Camera::rotateLocal(const float angle, const core::Vec3f axis) { float dist = (getPos() - getFocus()).norm(); Quaternionf q; @@ -245,7 +244,7 @@ void smCamera::rotateLocal(const float angle, const core::Vec3f axis) setFocus(getPos() + dist * getDirection()); } -void smCamera::rotateFocus(const float angle, const core::Vec3f axis) +void Camera::rotateFocus(const float angle, const core::Vec3f axis) { float dist = (getFocus() - getPos()).norm(); Quaternionf q; @@ -255,32 +254,32 @@ void smCamera::rotateFocus(const float angle, const core::Vec3f axis) setPos(getFocus() + dist * getDirection()); } -void smCamera::rotateLocalX(const float angle) +void Camera::rotateLocalX(const float angle) { rotateLocal(angle, core::Vec3f::UnitX()); } -void smCamera::rotateLocalY(const float angle) +void Camera::rotateLocalY(const float angle) { rotateLocal(angle, core::Vec3f::UnitY()); } -void smCamera::rotateLocalZ(const float angle) +void Camera::rotateLocalZ(const float angle) { rotateLocal(angle, core::Vec3f::UnitZ()); } -void smCamera::rotateFocusX(const float angle) +void Camera::rotateFocusX(const float angle) { rotateFocus(angle, core::Vec3f::UnitX()); } -void smCamera::rotateFocusY(const float angle) +void Camera::rotateFocusY(const float angle) { rotateFocus(angle, core::Vec3f::UnitY()); } -void smCamera::rotateFocusZ(const float angle) +void Camera::rotateFocusZ(const float angle) { rotateFocus(angle, core::Vec3f::UnitZ()); } @@ -288,7 +287,7 @@ void smCamera::rotateFocusZ(const float angle) // Implementation adapted from Sylvain Pointeau's Blog: // http://spointeau.blogspot.com/2013/12/hello-i-am-looking-at-opengl-3.html -Matrix44f smCamera::lookAt(const core::Vec3f pos, +Matrix44f Camera::lookAt(const core::Vec3f pos, const core::Vec3f fp, const core::Vec3f up) { @@ -306,14 +305,14 @@ Matrix44f smCamera::lookAt(const core::Vec3f pos, return res; } -void smCamera::genViewMat() +void Camera::genViewMat() { - setViewMat(smCamera::lookAt(getPos(), getFocus(), getUpVec())); + setViewMat(Camera::lookAt(getPos(), getFocus(), getUpVec())); } // Implementation adapted from Sylvain Pointeau's Blog: // http://spointeau.blogspot.com/2013/12/hello-i-am-looking-at-opengl-3.html -Matrix44f smCamera::perspective(const float fovy, const float ar, +Matrix44f Camera::perspective(const float fovy, const float ar, const float zNear, const float zFar) { assert(ar > 0); @@ -330,8 +329,8 @@ Matrix44f smCamera::perspective(const float fovy, const float ar, return res; } -void smCamera::genProjMat() +void Camera::genProjMat() { - setProjMat(smCamera::perspective(getViewAngle(), getAspectRatio(), + setProjMat(Camera::perspective(getViewAngle(), getAspectRatio(), getNearClipDist(), getFarClipDist())); } diff --git a/src/Rendering/Camera.h b/src/Rendering/Camera.h index 4557053be82b06b8d105ef396f4f5f1dad62c936..ca3b77a1a103160800bae642ba80fbfb37bd3237 100644 --- a/src/Rendering/Camera.h +++ b/src/Rendering/Camera.h @@ -37,11 +37,11 @@ /// /// \detail The camera will be oriented facing down the -Z axis with an +Y axis /// up vector -class smCamera +class Camera { public: //Construction/Destruction - smCamera(); + Camera(); //View settings /// \brief Set the position of the camera @@ -277,9 +277,9 @@ public: /// position 10 units +Z away from origin(0, 0, 10) /// /// \return The shared_ptr containing the address of the allocated camera - static std::shared_ptr<smCamera> getDefaultCamera() + static std::shared_ptr<Camera> getDefaultCamera() { - std::shared_ptr<smCamera> defaultCamera = std::make_shared<smCamera>(); + std::shared_ptr<Camera> defaultCamera = std::make_shared<Camera>(); defaultCamera->setAspectRatio(800.0 / 640.0); //Doesn't have to match screen resolution defaultCamera->setFarClipDist(1000); defaultCamera->setNearClipDist(0.001); diff --git a/src/Rendering/ConfigRendering.h b/src/Rendering/ConfigRendering.h index c9110f4d3391e914a151413c10b60f908064880c..acce80dc95af3f386d7e5b3d5468747627f38a69 100644 --- a/src/Rendering/ConfigRendering.h +++ b/src/Rendering/ConfigRendering.h @@ -35,7 +35,7 @@ #include "Core/RenderDetail.h" -class smShader; +class Shader; /// \brief this shows the Vertex Buffer Object Size ///It should be bigger than the total data of vertices and indices of the scene objects. @@ -48,7 +48,7 @@ class smShader; #define SIMMEDTK_MAX_VBOBUFFERS 10 /// \brief The configuration for VBO -enum smVBOType +enum VBOType { SIMMEDTK_VBO_STATIC, SIMMEDTK_VBO_NOINDICESCHANGE, @@ -56,7 +56,7 @@ enum smVBOType }; /// \brief Vertex Buffer Objects Return Types -enum smVBOResult +enum VBOResult { SIMMEDTK_VBO_OK, SIMMEDTK_VBO_NODATAMEMORY, @@ -86,7 +86,7 @@ enum smVBOResult #define SIMMEDTK_RENDER_NORMALS (1<<17) #define SIMMEDTK_RENDER_NONE (1<<31) -/// \brief type definitions for variable viewerRenderDetail in smViewer +/// \brief type definitions for variable viewerRenderDetail in Viewer #define SIMMEDTK_VIEWERRENDER_GLOBALAXIS (1<<1) #define SIMMEDTK_VIEWERRENDER_TEXT (1<<2) #define SIMMEDTK_VIEWERRENDER_FADEBACKGROUND (1<<3) @@ -100,12 +100,4 @@ enum smVBOResult #define SIMMEDTK_VIEWERRENDER_DYNAMICREFLECTION (1<<12) #define SIMMEDTK_VIEWERRENDER_GLOBAL_AXIS (1<<13) - -/// \brief viewer detail. legacy code -struct smViewerDetail -{ - unsigned int environment; - Color backGroundColor; -}; - #endif // SMCONFIGRENDERING_H diff --git a/src/Rendering/CustomRenderer.h b/src/Rendering/CustomRenderer.h index 7e0e50f05174576eaadc93c29af41b947b1fea74..5d736100c2eaf50ce2ec0c623c584f6558b4a0a7 100644 --- a/src/Rendering/CustomRenderer.h +++ b/src/Rendering/CustomRenderer.h @@ -43,10 +43,10 @@ public: /// \briefthis function should be implemented based on objects //virtual void init(); /// \brief draw pre, default and post draw routines - virtual void preDraw(const SceneObject &p_object); - virtual void draw(); - virtual void draw(const SceneObject &p_object); - virtual void postDraw(const SceneObject &p_object); + virtual void preDrawObject(const SceneObject &p_object); + virtual void drawObject(const SceneObject &p_object); + virtual void postDrawObject(const SceneObject &p_object); + virtual void draw() const; }; /// \briefderive this class if you want to render a class in the viewer. diff --git a/src/Rendering/FrameBuffer.cpp b/src/Rendering/FrameBuffer.cpp index 3c3f3c57c5dc708d14f6d98b15dad70e484f8493..975674f252fa3fa9e1878d29fea508307f17f691 100644 --- a/src/Rendering/FrameBuffer.cpp +++ b/src/Rendering/FrameBuffer.cpp @@ -27,7 +27,7 @@ #include "TextureManager.h" #include "GLRenderer.h" -bool smFrameBuffer::checkStatus() +bool FrameBuffer::checkStatus() { GLenum ret = glCheckFramebufferStatus(GL_FRAMEBUFFER); @@ -99,7 +99,7 @@ void test() glPopAttrib(); } -void smFrameBuffer::draw() const +void FrameBuffer::draw() const { glPushAttrib(GL_TEXTURE_BIT | GL_VIEWPORT_BIT | GL_LIGHTING_BIT); @@ -124,53 +124,53 @@ void smFrameBuffer::draw() const glEnd(); glPopAttrib(); } -GLenum smRenderBuffer::getGLAttachmentId() +GLenum RenderBuffer::getGLAttachmentId() { - if ( type == SIMMEDTK_RENDERBUFFER_DEPTH ) + if ( type == Type::Depth ) { return GL_DEPTH_ATTACHMENT_EXT; } - if ( type == SIMMEDTK_RENDERBUFFER_STENCIL ) + if ( type == Type::Stencil ) { return GL_STENCIL_ATTACHMENT; } - if ( type == SIMMEDTK_RENDERBUFFER_COLOR_RGBA || type == SIMMEDTK_RENDERBUFFER_COLOR_RGB ) + if ( type == Type::ColorRGBA || type == Type::ColorRGB ) { return GL_COLOR_ATTACHMENT0_EXT + attachmentOrder; } return GLenum(0); } -int smRenderBuffer::getHeight() +int RenderBuffer::getHeight() { return height; } -int smRenderBuffer::getWidth() +int RenderBuffer::getWidth() { return width; } -void smRenderBuffer::setAttachmentOrder( int p_attachmentOrder ) +void RenderBuffer::setAttachmentOrder( int p_attachmentOrder ) { attachmentOrder = p_attachmentOrder; } -int smRenderBuffer::getAttachmentOrder( int /*p_attachmentOrder*/ ) +int RenderBuffer::getAttachmentOrder( int /*p_attachmentOrder*/ ) { return attachmentOrder; } -smRenderBufferType smRenderBuffer::getRenderBufType() +RenderBuffer::Type RenderBuffer::getRenderBufType() { return type; } -GLuint smRenderBuffer::getRenderBufId() +GLuint RenderBuffer::getRenderBufId() { return _rb.GetId(); } -smRenderBuffer::smRenderBuffer() +RenderBuffer::RenderBuffer() { isAllocated = false; } -smRenderBuffer::smRenderBuffer( smRenderBufferType p_type, int p_width, int p_height ) +RenderBuffer::RenderBuffer( Type p_type, int p_width, int p_height ) { width = p_width; height = p_height; @@ -178,7 +178,7 @@ smRenderBuffer::smRenderBuffer( smRenderBufferType p_type, int p_width, int p_he isAllocated = true; type = p_type; } -bool smRenderBuffer::createDepthBuffer( int width, int height ) +bool RenderBuffer::createDepthBuffer( int width, int height ) { if ( !isAllocated ) { @@ -188,25 +188,25 @@ bool smRenderBuffer::createDepthBuffer( int width, int height ) return false; } -bool smRenderBuffer::createColorBuffer() +bool RenderBuffer::createColorBuffer() { if ( !isAllocated ) { - _rb.Set( SIMMEDTK_RENDERBUFFER_COLOR_RGBA, width, height ); + _rb.Set( Type::ColorRGBA, width, height ); } return false; } -bool smRenderBuffer::createStencilBuffer() +bool RenderBuffer::createStencilBuffer() { if ( !isAllocated ) { - _rb.Set( SIMMEDTK_RENDERBUFFER_STENCIL, width, height ); + _rb.Set( Type::Stencil, width, height ); } return false; } -smFrameBuffer::smFrameBuffer() +FrameBuffer::FrameBuffer() { width = 0; height = 0; @@ -216,27 +216,27 @@ smFrameBuffer::smFrameBuffer() renderColorBuff = false; renderBuffer = NULL; } -void smFrameBuffer::setDim( int p_width, int p_height ) +void FrameBuffer::setDim( int p_width, int p_height ) { width = p_width; height = p_height; } -int smFrameBuffer::getHeight() +int FrameBuffer::getHeight() { return height; } -int smFrameBuffer::getWidth() +int FrameBuffer::getWidth() { return width; } -void smFrameBuffer::attachRenderBuffer( smRenderBuffer *p_renderBuf ) +void FrameBuffer::attachRenderBuffer( RenderBuffer *p_renderBuf ) { if ( p_renderBuf->getWidth() != width || p_renderBuf->getHeight() != height ) { _fbo.AttachRenderBuffer( p_renderBuf->getRenderBufId(), p_renderBuf->getGLAttachmentId() ); } } -void smFrameBuffer::attachDepthTexture( Texture *p_texture ) +void FrameBuffer::attachDepthTexture( Texture *p_texture ) { if ( p_texture == NULL ) { @@ -246,17 +246,17 @@ void smFrameBuffer::attachDepthTexture( Texture *p_texture ) _fbo.AttachTexture( p_texture->GLtype, p_texture->textureGLId, GL_DEPTH_ATTACHMENT_EXT ); isDepthTexAttached = true; } -void smFrameBuffer::attachColorTexture( Texture *p_texture, int p_attachmentOrder ) +void FrameBuffer::attachColorTexture( Texture *p_texture, int p_attachmentOrder ) { defaultColorAttachment = p_attachmentOrder; _fbo.AttachTexture( p_texture->GLtype, p_texture->textureGLId, GL_COLOR_ATTACHMENT0_EXT + p_attachmentOrder ); isColorBufAttached = true; } -void smFrameBuffer::activeColorBuf( int p_order ) +void FrameBuffer::activeColorBuf( int p_order ) { glDrawBuffer( GL_COLOR_ATTACHMENT0_EXT + p_order ); } -void smFrameBuffer::enable() +void FrameBuffer::enable() { _fbo.Bind(); @@ -266,8 +266,8 @@ void smFrameBuffer::enable() glReadBuffer( GL_NONE ); } } -void smFrameBuffer::disable() +void FrameBuffer::disable() { _fbo.Disable(); } -smFrameBuffer::~smFrameBuffer() {} +FrameBuffer::~FrameBuffer() {} diff --git a/src/Rendering/FrameBuffer.h b/src/Rendering/FrameBuffer.h index d640fa2d9d16da4f91375699e3d3dc9c40193da6..e1c723a45fec4cba0888a29327ed0bac7d8475e1 100644 --- a/src/Rendering/FrameBuffer.h +++ b/src/Rendering/FrameBuffer.h @@ -31,28 +31,23 @@ #include "Core/Config.h" #include "Core/CoreClass.h" #include "Core/ErrorLog.h" -#include "External/framebufferObject.h" -#include "External/renderbuffer.h" +#include "External/FrameBufferObject.h" +#include "External/RenderBuffer.h" #include "TextureManager.h" -/// \brief frame buffer attachment type; color, depth, stencil -enum smFBOImageAttachmentType -{ - SIMMEDTK_FBOIMAGE_COLOR, - SIMMEDTK_FBOIMAGE_DEPTH, - SIMMEDTK_FBOIMAGE_STENCIL -}; -/// \brief render buffer type -enum smRenderBufferType -{ - SIMMEDTK_RENDERBUFFER_DEPTH = GL_DEPTH_COMPONENT, - SIMMEDTK_RENDERBUFFER_STENCIL = GL_STENCIL_INDEX, - SIMMEDTK_RENDERBUFFER_COLOR_RGBA = GL_RGBA, - SIMMEDTK_RENDERBUFFER_COLOR_RGB = GL_RGB -}; /// \brief render buffer type used for frame buffer attachment -class smRenderBuffer: public CoreClass +class RenderBuffer: public CoreClass { +public: + /// \brief render buffer type + enum Type + { + Depth = GL_DEPTH_COMPONENT, + Stencil = GL_STENCIL_INDEX, + ColorRGBA = GL_RGBA, + ColorRGB = GL_RGB + }; + protected: /// \brief renderbuffer Renderbuffer _rb; @@ -63,7 +58,7 @@ protected: /// \brief allocation is done or not bool isAllocated; /// \brief type of renderbuffer - smRenderBufferType type; + Type type; /// \brief attachment order in the frame buffer int attachmentOrder; @@ -79,13 +74,13 @@ public: /// \brief get attacnment id. returns GL binding GLenum getGLAttachmentId(); /// \brief returns buffer type - smRenderBufferType getRenderBufType(); + Type getRenderBufType(); /// \brief return GL buffer id GLuint getRenderBufId(); /// \brief defaul constructor. - smRenderBuffer(); + RenderBuffer(); /// \brief set the type - smRenderBuffer(smRenderBufferType p_type, int p_width, int p_height); + RenderBuffer(Type p_type, int p_width, int p_height); /// \brief create a depth buffer bool createDepthBuffer(int width, int height); /// \brief create a color buffer @@ -95,7 +90,7 @@ public: }; /// \brief GL frame buffer class -class smFrameBuffer: public CoreClass +class FrameBuffer: public CoreClass { public: /// \brief GL frame buffer @@ -107,7 +102,7 @@ public: /// \brief default color buffer attachment int defaultColorAttachment; /// \brief render buffer pointer - smRenderBuffer *renderBuffer; + RenderBuffer *renderBuffer; /// \brief it is enabled when the renderbuffer exists bool renderDepthBuff; /// \brief it is enabled when the color buffer exists @@ -118,8 +113,8 @@ public: int height; /// \brief framebuffer default constructor - smFrameBuffer(); - virtual ~smFrameBuffer(); + FrameBuffer(); + virtual ~FrameBuffer(); /// \brief set dimension of the renderbuffer void setDim(int p_width, int p_height); /// \brief get height of the framebuffer @@ -129,7 +124,7 @@ public: /// \brief attach texture void attachTexture(); /// \brief attach render buffer to te frame buffer - void attachRenderBuffer(smRenderBuffer *p_renderBuf); + void attachRenderBuffer(RenderBuffer *p_renderBuf); /// \brief attach depth texture void attachDepthTexture(Texture *p_texture); /// \brief attach a color texture diff --git a/src/Rendering/Renderer.cpp b/src/Rendering/GLRenderer.cpp similarity index 91% rename from src/Rendering/Renderer.cpp rename to src/Rendering/GLRenderer.cpp index ac0ed8fc251e853b7eb8597d6287fb63e6601f1a..ed5e65f991ec7fdf0466a0f60e89381bb1f73b29 100644 --- a/src/Rendering/Renderer.cpp +++ b/src/Rendering/GLRenderer.cpp @@ -32,13 +32,13 @@ # pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif -smGLRenderer::smGLRenderer() +GLRenderer::GLRenderer() { } #if 0 -void smGLRenderer::drawLineMesh(std::shared_ptr<smLineMesh> p_lineMesh, std::shared_ptr<RenderDetail> renderDetail) +void GLRenderer::drawLineMesh(std::shared_ptr<LineMesh> p_lineMesh, std::shared_ptr<RenderDetail> renderDetail) { static core::Vec3d origin(0, 0, 0); static core::Vec3d xAxis(1, 0, 0); @@ -82,7 +82,7 @@ void smGLRenderer::drawLineMesh(std::shared_ptr<smLineMesh> p_lineMesh, std::sha for (size_t t = 0; t < p_lineMesh->textureIds.size(); t++) { glActiveTexture(GL_TEXTURE0 + t); - smTextureManager::activateTexture(p_lineMesh->textureIds[t].textureId); + TextureManager::activateTexture(p_lineMesh->textureIds[t].textureId); } } } @@ -157,7 +157,7 @@ void smGLRenderer::drawLineMesh(std::shared_ptr<smLineMesh> p_lineMesh, std::sha for (size_t t = 0; t < p_lineMesh->textureIds.size(); t++) { glActiveTexture(GL_TEXTURE0 + t); - smTextureManager::disableTexture(p_lineMesh->textureIds[t].textureId); + TextureManager::disableTexture(p_lineMesh->textureIds[t].textureId); } } } @@ -173,8 +173,8 @@ void smGLRenderer::drawLineMesh(std::shared_ptr<smLineMesh> p_lineMesh, std::sha } #endif // 0 -void smGLRenderer::drawSurfaceMeshTriangles( - std::shared_ptr<smMesh> p_surfaceMesh, +void GLRenderer::drawSurfaceMeshTriangles( + std::shared_ptr<Mesh> p_surfaceMesh, std::shared_ptr<RenderDetail> renderDetail) { if (p_surfaceMesh->getRenderDetail()->getRenderType() & SIMMEDTK_RENDER_NONE) @@ -216,7 +216,7 @@ void smGLRenderer::drawSurfaceMeshTriangles( for (size_t t = 0; t < p_surfaceMesh->textureIds.size(); t++) { glActiveTexture(GL_TEXTURE0 + t); - smTextureManager::activateTexture(p_surfaceMesh->textureIds[t].textureId); + TextureManager::activateTexture(p_surfaceMesh->textureIds[t].textureId); } } } @@ -286,7 +286,7 @@ void smGLRenderer::drawSurfaceMeshTriangles( for (size_t t = 0; t < p_surfaceMesh->textureIds.size(); t++) { glActiveTexture(GL_TEXTURE0 + t); - smTextureManager::disableTexture(p_surfaceMesh->textureIds[t].textureId); + TextureManager::disableTexture(p_surfaceMesh->textureIds[t].textureId); } } } @@ -301,7 +301,7 @@ void smGLRenderer::drawSurfaceMeshTriangles( glLineWidth(1.0); } -void smGLRenderer::drawNormals(std::shared_ptr<smMesh> p_mesh, Color p_color, float length) +void GLRenderer::drawNormals(std::shared_ptr<Mesh> p_mesh, Color p_color, float length) { glDisable(GL_LIGHTING); @@ -332,13 +332,13 @@ void smGLRenderer::drawNormals(std::shared_ptr<smMesh> p_mesh, Color p_color, fl glEnable(GL_LIGHTING); } -void smGLRenderer::beginTriangles() +void GLRenderer::beginTriangles() { glBegin(GL_TRIANGLES); } -void smGLRenderer::drawTriangle(core::Vec3d &p_1, core::Vec3d &p_2, core::Vec3d &p_3) +void GLRenderer::drawTriangle(core::Vec3d &p_1, core::Vec3d &p_2, core::Vec3d &p_3) { glVertex3dv(p_1.data()); @@ -346,13 +346,13 @@ void smGLRenderer::drawTriangle(core::Vec3d &p_1, core::Vec3d &p_2, core::Vec3d glVertex3dv(p_3.data()); } -void smGLRenderer::endTriangles() +void GLRenderer::endTriangles() { glEnd(); } -void smGLRenderer::draw(AABB &aabb, Color p_color) +void GLRenderer::draw(AABB &aabb, Color p_color) { glPushAttrib(GL_LIGHTING_BIT); @@ -404,7 +404,7 @@ void smGLRenderer::draw(AABB &aabb, Color p_color) glPopAttrib(); } -void smGLRenderer::drawArrow(const core::Vec3f &start, const core::Vec3f &end, const float D) +void GLRenderer::drawArrow(const core::Vec3f &start, const core::Vec3f &end, const float D) { float x = end[0] - start[0]; float y = end[1] - start[1]; @@ -457,7 +457,7 @@ void smGLRenderer::drawArrow(const core::Vec3f &start, const core::Vec3f &end, c } -void smGLRenderer::drawAxes(const float length) +void GLRenderer::drawAxes(const float length) { glDisable(GL_LIGHTING); @@ -483,7 +483,7 @@ void smGLRenderer::drawAxes(const float length) glEnable(GL_LIGHTING); } -void smGLRenderer::drawAxes(const Matrix33f &rotMat, const core::Vec3f &pos, const float length) +void GLRenderer::drawAxes(const Matrix33f &rotMat, const core::Vec3f &pos, const float length) { glDisable(GL_LIGHTING); @@ -513,7 +513,7 @@ void smGLRenderer::drawAxes(const Matrix33f &rotMat, const core::Vec3f &pos, con glEnable(GL_LIGHTING); } -void smGLRenderer::draw(Plane &p_plane, float p_scale, Color p_color) +void GLRenderer::draw(Plane &p_plane, float p_scale, Color p_color) { double angle; @@ -530,7 +530,7 @@ void smGLRenderer::draw(Plane &p_plane, float p_scale, Color p_color) core::Vec3d point = p_plane.getPoint(); angle = std::acos(defaultDir.dot(normal)); axisOfRot = normal.cross(defaultDir); - axisOfRot.normalized(); + axisOfRot.normalize(); Quaterniond rot = getRotationQuaternion(-angle,axisOfRot); @@ -549,7 +549,7 @@ void smGLRenderer::draw(Plane &p_plane, float p_scale, Color p_color) glEnable(GL_LIGHTING); } -void smGLRenderer::renderScene(std::shared_ptr<Scene> p_scene) +void GLRenderer::renderScene(std::shared_ptr<Scene> p_scene) { assert(p_scene); @@ -559,7 +559,7 @@ void smGLRenderer::renderScene(std::shared_ptr<Scene> p_scene) renderScene(p_scene, proj, view); } -void smGLRenderer::renderScene(std::shared_ptr<Scene> p_scene, +void GLRenderer::renderScene(std::shared_ptr<Scene> p_scene, const Matrix44f &p_proj, const Matrix44f &p_view) { @@ -595,7 +595,7 @@ void smGLRenderer::renderScene(std::shared_ptr<Scene> p_scene, glPopMatrix(); } -void smGLRenderer::renderSceneObject(std::shared_ptr<SceneObject> p_sceneObject) +void GLRenderer::renderSceneObject(std::shared_ptr<SceneObject> p_sceneObject) { RenderDetail::Ptr detail = p_sceneObject->getRenderDetail(); if (!detail || detail->getRenderType() & SIMMEDTK_RENDER_NONE) @@ -610,9 +610,9 @@ void smGLRenderer::renderSceneObject(std::shared_ptr<SceneObject> p_sceneObject) { if (renderer != nullptr) { - renderer->preDraw(*p_sceneObject); - renderer->draw(*p_sceneObject); - renderer->postDraw(*p_sceneObject); + renderer->preDrawObject(*p_sceneObject); + renderer->drawObject(*p_sceneObject); + renderer->postDrawObject(*p_sceneObject); } } else if (delegate) @@ -621,7 +621,7 @@ void smGLRenderer::renderSceneObject(std::shared_ptr<SceneObject> p_sceneObject) //rendering before the default renderer takes place if (renderer != nullptr) { - renderer->preDraw(*p_sceneObject); + renderer->preDrawObject(*p_sceneObject); } delegate->draw(); @@ -630,7 +630,7 @@ void smGLRenderer::renderSceneObject(std::shared_ptr<SceneObject> p_sceneObject) //rendering after the default renderer takes place if (renderer != nullptr) { - renderer->postDraw(*p_sceneObject); + renderer->postDrawObject(*p_sceneObject); } } } diff --git a/src/Rendering/GLRenderer.h b/src/Rendering/GLRenderer.h index d10a49badabf1c011e0d5dd71e780ac2f180ecb0..307466be302946d5158e786a36bdc1335b1e7d82 100644 --- a/src/Rendering/GLRenderer.h +++ b/src/Rendering/GLRenderer.h @@ -33,32 +33,32 @@ #include "Core/SceneObject.h" #include "Core/Matrix.h" -class smMesh; +class Mesh; class AABB; -class smLineMesh; -class smViewer; +class LineMesh; +class Viewer; class Plane; class Scene; struct RenderDetail; /// \brief gl rendering utilities -class smGLRenderer: public CoreClass +class GLRenderer: public CoreClass { public: /// \brief constructor - smGLRenderer(); + GLRenderer(); /// \brief draws surface mesh with given rendertdail and draw paramters - static void drawSurfaceMeshTriangles(std::shared_ptr<smMesh> p_surfaceMesh, std::shared_ptr<RenderDetail> renderDetail); + static void drawSurfaceMeshTriangles(std::shared_ptr<Mesh> p_surfaceMesh, std::shared_ptr<RenderDetail> renderDetail); /// \brief draw normals - static void drawNormals(std::shared_ptr<smMesh> p_mesh, Color p_color = Color::colorBlue, float length=1.0); + static void drawNormals(std::shared_ptr<Mesh> p_mesh, Color p_color = Color::colorBlue, float length=1.0); /// \brief draw line mesh - static void drawLineMesh(std::shared_ptr<smLineMesh> p_lineMesh, std::shared_ptr<RenderDetail> renderDetail); + static void drawLineMesh(std::shared_ptr<LineMesh> p_lineMesh, std::shared_ptr<RenderDetail> renderDetail); /// \brief draw coordinate system - static void drawCoordSystem(std::shared_ptr<smViewer> viewer, std::string p_name, core::Vec3d p_pos, core::Vec3d dirX, core::Vec3d dirY, core::Vec3d dirZ); + static void drawCoordSystem(std::shared_ptr<Viewer> viewer, std::string p_name, core::Vec3d p_pos, core::Vec3d dirX, core::Vec3d dirY, core::Vec3d dirZ); /// \brief begin rendering triangle static void beginTriangles(); @@ -85,7 +85,7 @@ public: static void drawArrow(const core::Vec3f &start, const core::Vec3f &end, const float D); /// \brief draw function is called for visualization the object - virtual void draw(){} + virtual void draw() const {} /// \brief switch to default rendering static void enableDefaultGLRendering(); diff --git a/src/Rendering/GLUtils.cpp b/src/Rendering/GLUtils.cpp index c98b70962a5b946baaabb12a0771165ee6c1ba13..219c13167fba1c5d4cd68f1b8b66ec5464d9b380 100644 --- a/src/Rendering/GLUtils.cpp +++ b/src/Rendering/GLUtils.cpp @@ -30,7 +30,7 @@ ///checks the openGL error. if there is an error then it returns ///the error text otherwise it returns NULL -bool smGLUtils::queryGLError(std::string& err) +bool GLUtils::queryGLError(std::string& err) { GLenum errCode; const GLubyte *errString; @@ -50,7 +50,7 @@ bool smGLUtils::queryGLError(std::string& err) } ///taken from glProgramming.com. Checks the extension. -bool smGLUtils::QueryExtension(const std::string& extName) +bool GLUtils::QueryExtension(const std::string& extName) { auto it = std::find( openGLExtensions.begin(),openGLExtensions.end(),extName); @@ -59,7 +59,7 @@ bool smGLUtils::QueryExtension(const std::string& extName) } ///fade background draw -void smGLUtils::fadeBackgroundDraw() +void GLUtils::fadeBackgroundDraw() { glPushAttrib(GL_ALL_ATTRIB_BITS); glDisable(GL_DEPTH_TEST); @@ -91,7 +91,7 @@ void smGLUtils::fadeBackgroundDraw() glPopAttrib(); } -void smGLUtils::drawQuadOnScreen(Color p_color, float p_left, +void GLUtils::drawQuadOnScreen(Color p_color, float p_left, float p_bottom, float p_right, float p_top) { @@ -125,7 +125,7 @@ void smGLUtils::drawQuadOnScreen(Color p_color, float p_left, glPopMatrix(); glPopAttrib(); } -void smGLUtils::drawUnitQuadOnScreen() +void GLUtils::drawUnitQuadOnScreen() { glBegin(GL_QUADS); glNormal3f(0, 0, 1); @@ -139,11 +139,11 @@ void smGLUtils::drawUnitQuadOnScreen() glVertex3d(-1, 1.0, -1); glEnd(); } -void smGLUtils::queryProjectionMatrix(Matrix44f& p_matrix) +void GLUtils::queryProjectionMatrix(Matrix44f& p_matrix) { glGetFloatv(GL_PROJECTION_MATRIX, p_matrix.data()); } -void smGLUtils::queryModelViewMatrix(Matrix44f& p_matrix) +void GLUtils::queryModelViewMatrix(Matrix44f& p_matrix) { glGetFloatv(GL_MODELVIEW_MATRIX, p_matrix.data()); } diff --git a/src/Rendering/GLUtils.h b/src/Rendering/GLUtils.h index 9c618a6d8467ec485fe6cb7510bfcf6e33b67142..0e7bd1708220cfa8562b86e66b58eef7e01e79f8 100644 --- a/src/Rendering/GLUtils.h +++ b/src/Rendering/GLUtils.h @@ -34,13 +34,13 @@ struct smGroundRenderInfo; /// \brief opengl rendering utilities are here. -class smGLUtils : public CoreClass +class GLUtils : public CoreClass { public: // OpenGL 3.0 adds the concept of indexed strings and // deprecates calls to glGetString( GL_EXTENSIONS ), which // will now generate GL_INVALID_ENUM. - smGLUtils() + GLUtils() { int numExt; glGetIntegerv( GL_NUM_EXTENSIONS, &numExt ); @@ -50,7 +50,7 @@ public: reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS,i))); } } - ~smGLUtils(); + ~GLUtils(); public: /// \brief checks the openGL error. if there is an error then it returns diff --git a/src/Rendering/MetalShader.cpp b/src/Rendering/MetalShader.cpp index b72f52f7ce1f5e17f0b3a972d989f5380af495cb..f90ca0c34033bf005128d809ea49d7e381dc2496 100644 --- a/src/Rendering/MetalShader.cpp +++ b/src/Rendering/MetalShader.cpp @@ -27,9 +27,9 @@ #include "Event/KeyboardEvent.h" #include "Core/SDK.h" -smMetalShader::smMetalShader( const std::string &p_verteShaderFileName, +MetalShader::MetalShader( const std::string &p_verteShaderFileName, const std::string &p_fragmentFileName ) : - smShader(SDK::getInstance()->getErrorLog()) + Shader(SDK::getInstance()->getErrorLog()) { this->log = SDK::getInstance()->getErrorLog(); this->log->isOutputtoConsoleEnabled = false; @@ -55,7 +55,7 @@ smMetalShader::smMetalShader( const std::string &p_verteShaderFileName, log->isOutputtoConsoleEnabled = true; } -void smMetalShader::attachMesh( std::shared_ptr<smMesh> p_mesh, char *p_bump, char *p_decal, char *p_specular, char *p_OCC, char *p_disp ) +void MetalShader::attachMesh( std::shared_ptr<Mesh> p_mesh, char *p_bump, char *p_decal, char *p_specular, char *p_OCC, char *p_disp ) { if ( !attachTexture( p_mesh->getUniqueId(), p_bump, "BumpTex" ) ) { @@ -69,7 +69,7 @@ void smMetalShader::attachMesh( std::shared_ptr<smMesh> p_mesh, char *p_bump, ch attachTexture( id, p_disp, "DispTex" ); } -void smMetalShader::attachMesh( std::shared_ptr<smMesh> p_mesh, char *p_bump, char *p_decal, char *p_specular, char *p_OCC, char *p_disp, char *p_alphaMap ) +void MetalShader::attachMesh( std::shared_ptr<Mesh> p_mesh, char *p_bump, char *p_decal, char *p_specular, char *p_OCC, char *p_disp, char *p_alphaMap ) { auto id = p_mesh->getUniqueId(); attachTexture( id, p_bump, "BumpTex" ); @@ -80,21 +80,21 @@ void smMetalShader::attachMesh( std::shared_ptr<smMesh> p_mesh, char *p_bump, ch attachTexture( id, p_alphaMap, "AlphaTex" ); } -void smMetalShader::draw() const +void MetalShader::draw() const { //placeholder } -void smMetalShader::initDraw() +void MetalShader::initDraw() { - smShader::initDraw(); + Shader::initDraw(); specularPower = this->getFragmentShaderParam( "specularPower" ); alphaMapGain = this->getFragmentShaderParam( "alphaMapGain" ); this->tangentAttrib = this->getShaderAtrribParam( "tangent" ); canGetShadowUniform = getFragmentShaderParam( "canGetShadow" ); } -void smMetalShader::predraw(std::shared_ptr<smMesh> mesh ) +void MetalShader::predraw(std::shared_ptr<Mesh> mesh ) { specularPowerValue = mesh->getRenderDetail()->shininess; glUniform1fARB( specularPower, specularPowerValue ); @@ -110,21 +110,21 @@ void smMetalShader::predraw(std::shared_ptr<smMesh> mesh ) } } -void smMetalShader::handleEvent(std::shared_ptr<mstk::Event::Event> p_event) +void MetalShader::handleEvent(std::shared_ptr<core::Event> p_event) { - auto keyboardEvent = std::static_pointer_cast<mstk::Event::smKeyboardEvent>(p_event); + auto keyboardEvent = std::static_pointer_cast<event::KeyboardEvent>(p_event); if(keyboardEvent) { switch(keyboardEvent->getKeyPressed()) { - case mstk::Event::smKey::Add: + case event::Key::Add: { specularPowerValue += 5; std::cout << specularPowerValue << std::endl; break; } - case mstk::Event::smKey::Subtract: + case event::Key::Subtract: { specularPowerValue -= 5; std::cout << specularPowerValue << std::endl; @@ -136,19 +136,19 @@ void smMetalShader::handleEvent(std::shared_ptr<mstk::Event::Event> p_event) } } -void smMetalShader::switchEnable() +void MetalShader::switchEnable() { // } -void smMetalShader::switchDisable() +void MetalShader::switchDisable() { // } MetalShaderShadow::MetalShaderShadow( const std::string &p_vertexShaderFileName, const std::string &p_fragmentShaderFileName ) : - smMetalShader( p_vertexShaderFileName, p_fragmentShaderFileName ) + MetalShader( p_vertexShaderFileName, p_fragmentShaderFileName ) { createParam( "ShadowMapTEST" ); createParam( "canGetShadow" ); @@ -156,15 +156,15 @@ MetalShaderShadow::MetalShaderShadow( const std::string &p_vertexShaderFileName, void MetalShaderShadow::initDraw() { - smMetalShader::initDraw(); + MetalShader::initDraw(); this->print(); shadowMapUniform = getFragmentShaderParam( "ShadowMapTEST" ); canGetShadowUniform = getFragmentShaderParam( "canGetShadow" ); } -void MetalShaderShadow::predraw( std::shared_ptr<smMesh> p_mesh ) +void MetalShaderShadow::predraw( std::shared_ptr<Mesh> p_mesh ) { - smMetalShader::predraw( p_mesh ); + MetalShader::predraw( p_mesh ); if ( p_mesh->getRenderDetail()->canGetShadow ) { @@ -175,11 +175,11 @@ void MetalShaderShadow::predraw( std::shared_ptr<smMesh> p_mesh ) glUniform1fARB( canGetShadowUniform, 0 ); } - smTextureManager::activateTexture( "depth", 30, shadowMapUniform ); + TextureManager::activateTexture( "depth", 30, shadowMapUniform ); } MetalShaderSoftShadow::MetalShaderSoftShadow() : - smMetalShader( "shaders/SingleShadowVertexBumpMap2.cg", + MetalShader( "shaders/SingleShadowVertexBumpMap2.cg", "shaders/SingleShadowFragmentBumpMap2.cg" ) { createParam( "ShadowMapTEST" ); @@ -187,17 +187,17 @@ MetalShaderSoftShadow::MetalShaderSoftShadow() : void MetalShaderSoftShadow::initDraw() { - smMetalShader::initDraw(); + MetalShader::initDraw(); this->print(); shadowMapUniform = getFragmentShaderParam( "ShadowMapTEST" ); } -void MetalShaderSoftShadow::predraw( std::shared_ptr<smMesh> p_mesh ) +void MetalShaderSoftShadow::predraw( std::shared_ptr<Mesh> p_mesh ) { - smMetalShader::predraw( p_mesh ); - smTextureManager::activateTexture( "depth", 30, shadowMapUniform ); + MetalShader::predraw( p_mesh ); + TextureManager::activateTexture( "depth", 30, shadowMapUniform ); } -void smMetalShader::predraw ( std::shared_ptr<smSurfaceMesh> ) {} -void MetalShaderSoftShadow::predraw ( std::shared_ptr<smSurfaceMesh> ) {} -void MetalShaderShadow::predraw ( std::shared_ptr<smSurfaceMesh> ) {} +void MetalShader::predraw ( std::shared_ptr<SurfaceMesh> ) {} +void MetalShaderSoftShadow::predraw ( std::shared_ptr<SurfaceMesh> ) {} +void MetalShaderShadow::predraw ( std::shared_ptr<SurfaceMesh> ) {} diff --git a/src/Rendering/MetalShader.h b/src/Rendering/MetalShader.h index d3f653f2b160364c684902e6c66e5b605c2598d5..2e158fed9c406e2c36f22bfda09213203e9b4f17 100644 --- a/src/Rendering/MetalShader.h +++ b/src/Rendering/MetalShader.h @@ -35,19 +35,19 @@ namespace Event{ } /// \brief metal shader look. It is mainly used for tool rendering but utilized for high specularity rendering for tissues. -class smMetalShader: public smShader +class MetalShader: public Shader { public: /// \brief constructor that get vertex and fragment shader file name. - smMetalShader(const std::string &p_verteShaderFileName = "shaders/VertexBumpMap1.cg", + MetalShader(const std::string &p_verteShaderFileName = "shaders/VertexBumpMap1.cg", const std::string &p_fragmentFileName = "shaders/FragmentBumpMap1.cg"); /// \brief attach mesh to the shader - void attachMesh(std::shared_ptr<smMesh> p_mesh, char *p_bump, + void attachMesh(std::shared_ptr<Mesh> p_mesh, char *p_bump, char *p_decal, char *p_specular, char *p_OCC, char *p_disp); - void attachMesh(std::shared_ptr<smMesh> p_mesh, char *p_bump, char *p_decal, char *p_specular, char *p_OCC, char *p_disp, char *p_alphaMap); + void attachMesh(std::shared_ptr<Mesh> p_mesh, char *p_bump, char *p_decal, char *p_specular, char *p_OCC, char *p_disp, char *p_alphaMap); /// \brief emtpy implementation of draw routine. needs to overwritten to enable real-time code changes void draw() const override; @@ -56,12 +56,12 @@ public: virtual void initDraw() override; /// \brief uniforms are set in the predraw - virtual void predraw(std::shared_ptr<smMesh> mesh) override; + virtual void predraw(std::shared_ptr<Mesh> mesh) override; - virtual void predraw(std::shared_ptr<smSurfaceMesh> mesh) override; + virtual void predraw(std::shared_ptr<SurfaceMesh> mesh) override; /// \brief handle keyboard event - void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; + void handleEvent(std::shared_ptr<core::Event> p_event) override; /// \brief any disable and enable shader options need to be here virtual void switchEnable(); @@ -81,7 +81,7 @@ public: }; /// \brief MetalShader variantion with shadow feature -class MetalShaderShadow: public smMetalShader +class MetalShaderShadow: public MetalShader { public: /// \brief MetalShader v @@ -91,9 +91,9 @@ public: virtual void initDraw() override; /// \brief unifom binding called before object is rendered - virtual void predraw(std::shared_ptr<smMesh> mesh) override; + virtual void predraw(std::shared_ptr<Mesh> mesh) override; - virtual void predraw(std::shared_ptr<smSurfaceMesh> mesh) override; + virtual void predraw(std::shared_ptr<SurfaceMesh> mesh) override; private: /// \brief for debugging purposes @@ -102,7 +102,7 @@ private: }; /// \brief another variation of metalshader with differen shadow mapping technique -class MetalShaderSoftShadow: public smMetalShader +class MetalShaderSoftShadow: public MetalShader { public: /// \brief constrcutore with vertex and fragment shader @@ -112,9 +112,9 @@ public: virtual void initDraw() override; /// \brief pre rendering routine before attached object is rendered - virtual void predraw(std::shared_ptr<smMesh> p_mesh) override; + virtual void predraw(std::shared_ptr<Mesh> p_mesh) override; - virtual void predraw(std::shared_ptr<smSurfaceMesh> mesh) override; + virtual void predraw(std::shared_ptr<SurfaceMesh> mesh) override; private: GLint shadowMapUniform; diff --git a/src/Rendering/OculusViewer.cpp b/src/Rendering/OculusViewer.cpp index 5196f82eaa66911d3c761c2bed982cf7bebfa7c8..23c3afe4e8a9e57411c27320a482df58fed47147 100644 --- a/src/Rendering/OculusViewer.cpp +++ b/src/Rendering/OculusViewer.cpp @@ -56,7 +56,7 @@ static unsigned int next_pow2(unsigned int x) return x + 1; } -smOculusViewer::smOculusViewer() : smViewer() +OculusViewer::OculusViewer() : Viewer() { hmd = nullptr; fbWidth = 0; @@ -70,12 +70,12 @@ smOculusViewer::smOculusViewer() : smViewer() oculusFBO = 0; } -smOculusViewer::~smOculusViewer() +OculusViewer::~OculusViewer() { } -void smOculusViewer::init() +void OculusViewer::init() { if (isInitialized) { @@ -100,7 +100,7 @@ void smOculusViewer::init() } } -void smOculusViewer::cleanUp() +void OculusViewer::cleanUp() { destroyFboListItems(); destroyGLContext(); @@ -108,7 +108,7 @@ void smOculusViewer::cleanUp() ovr_Shutdown(); } -void smOculusViewer::beginFrame() +void OculusViewer::beginFrame() { if (terminateExecution == true) { @@ -116,13 +116,13 @@ void smOculusViewer::beginFrame() } } -void smOculusViewer::endFrame() +void OculusViewer::endFrame() { //This is here to override swapping buffers, // Oculus doesn't like it when you swap buffers } -void smOculusViewer::renderToScreen(const RenderOperation &p_rop) +void OculusViewer::renderToScreen(const RenderOperation &p_rop) { int i; ovrMatrix4f ovrProj; @@ -196,7 +196,7 @@ void smOculusViewer::renderToScreen(const RenderOperation &p_rop) view = trans * view; //Render Scene - smGLRenderer::renderScene(p_rop.scene, proj, view); + GLRenderer::renderScene(p_rop.scene, proj, view); } //after drawing both eyes into the texture render target, revert to // drawing directly to the display, and we call ovrHmd_EndFrame, to let the @@ -211,7 +211,7 @@ void smOculusViewer::renderToScreen(const RenderOperation &p_rop) glUseProgram(0); } -int smOculusViewer::initOculus(void) +int OculusViewer::initOculus(void) { int i, x, y; unsigned int flags; @@ -310,14 +310,14 @@ int smOculusViewer::initOculus(void) return 0; } -void smOculusViewer::cleanupOculus(void) +void OculusViewer::cleanupOculus(void) { if (hmd) { ovrHmd_Destroy(hmd); } } -void smOculusViewer::updateRenTarg(int width, int height) +void OculusViewer::updateRenTarg(int width, int height) { if (!oculusFBO) { //if oculusFBO does not exist, diff --git a/src/Rendering/OculusViewer.h b/src/Rendering/OculusViewer.h index 72be54d5dc43ffb4df3a836659cb86779f2398f1..2c808a108420a434f07b4be4cf2830a3b0be89fc 100644 --- a/src/Rendering/OculusViewer.h +++ b/src/Rendering/OculusViewer.h @@ -32,11 +32,11 @@ /// \brief This viewer class allows content to be rendered to an Oculus Rift /// -class smOculusViewer : public smViewer +class OculusViewer : public Viewer { public: - smOculusViewer(); - virtual ~smOculusViewer(); + OculusViewer(); + virtual ~OculusViewer(); virtual void init() override; virtual void cleanUp() override; protected: diff --git a/src/Rendering/SceneTextureShader.cpp b/src/Rendering/SceneTextureShader.cpp index 6e2e916bd168a1d063be78523e149f197e459587..80e1ddd03b11624be63cd52093240511398530bf 100644 --- a/src/Rendering/SceneTextureShader.cpp +++ b/src/Rendering/SceneTextureShader.cpp @@ -25,8 +25,8 @@ #include "SceneTextureShader.h" #include "Core/SDK.h" -smSceneTextureShader::smSceneTextureShader(const std::string &p_verteShaderFileName, const std::string &p_fragmentFileName) -: smShader(SDK::getInstance()->getErrorLog()) +SceneTextureShader::SceneTextureShader(const std::string &p_verteShaderFileName, const std::string &p_fragmentFileName) +: Shader(SDK::getInstance()->getErrorLog()) { this->log = SDK::getInstance()->getErrorLog(); this->log->isOutputtoConsoleEnabled = false; @@ -40,25 +40,25 @@ smSceneTextureShader::smSceneTextureShader(const std::string &p_verteShaderFileN this->registerShader(); } -void smSceneTextureShader::predraw(std::shared_ptr<smMesh>/*p_mesh*/) +void SceneTextureShader::predraw(std::shared_ptr<Mesh>/*p_mesh*/) { } -void smSceneTextureShader::handleEvent(std::shared_ptr<mstk::Event::Event> /*p_event*/) +void SceneTextureShader::handleEvent(std::shared_ptr<core::Event> /*p_event*/) { } -void smSceneTextureShader::initDraw() +void SceneTextureShader::initDraw() { - smShader::initDraw(); + Shader::initDraw(); this->depthTex = getFragmentShaderParam("depthTex"); this->sceneTex = getFragmentShaderParam("sceneTex"); this->prevTex = getFragmentShaderParam("prevTex"); } -void smSceneTextureShader::draw() const +void SceneTextureShader::draw() const { glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT | GL_VIEWPORT_BIT); glDisable(GL_LIGHTING); diff --git a/src/Rendering/SceneTextureShader.h b/src/Rendering/SceneTextureShader.h index 2d3827aba57b828d580a3173b7bcb275e7611b5a..d71ef3ed9ccd573f50295a1929b091c0a74edb45 100644 --- a/src/Rendering/SceneTextureShader.h +++ b/src/Rendering/SceneTextureShader.h @@ -27,19 +27,16 @@ // SimMedTK includes #include "Shader.h" -namespace mstk{ -namespace Event{ - +namespace core { class Event; } -} /// \brief scene texture shader. This shader works on the scene that is placed on 2D image. It is for image based effects -class smSceneTextureShader: public smShader +class SceneTextureShader: public Shader { public: /// \brief constructor that receives the vertex and fragment shader file names - smSceneTextureShader(const std::string &p_verteShaderFileName = "shaders/renderSceneVertexShader.glsl", + SceneTextureShader(const std::string &p_verteShaderFileName = "shaders/renderSceneVertexShader.glsl", const std::string &p_fragmentFileName = "shaders/renderSceneFragShader.glsl"); /// \brief called during rendering initialization @@ -49,12 +46,12 @@ public: void draw() const override; /// \brief pre drawing of the shader. used for binding the uniforms if there are. - virtual void predraw(std::shared_ptr<smMesh> p_mesh) override; + virtual void predraw(std::shared_ptr<Mesh> p_mesh) override; - virtual void predraw(std::shared_ptr<smSurfaceMesh>) override{}; + virtual void predraw(std::shared_ptr<SurfaceMesh>) override{}; /// \brief handle the events - virtual void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; + virtual void handleEvent(std::shared_ptr<core::Event> p_event) override; public: /// \brief depth texture GL id that is sent to shader. It stores scene depth values diff --git a/src/Rendering/Shader.cpp b/src/Rendering/Shader.cpp index 2cb5b3d93753e0be1d8fd5407a34a92806fd2a6a..76fd361c9ef35500d664ddde0234710a779a3cc1 100644 --- a/src/Rendering/Shader.cpp +++ b/src/Rendering/Shader.cpp @@ -30,9 +30,9 @@ #include "Shader.h" #include "TextureManager.h" -std::unordered_map<int, std::shared_ptr<smShader>> smShader::shaders; -std::shared_ptr<smShader> smShader::currentShader = nullptr; -std::shared_ptr<smShader> smShader::savedShader = nullptr; +std::unordered_map<int, std::shared_ptr<Shader>> Shader::shaders; +std::shared_ptr<Shader> Shader::currentShader = nullptr; +std::shared_ptr<Shader> Shader::savedShader = nullptr; void printInfoLog(GLhandleARB obj) { @@ -51,7 +51,7 @@ void printInfoLog(GLhandleARB obj) } } -smShader::smShader(std::shared_ptr<ErrorLog> logger) +Shader::Shader(std::shared_ptr<ErrorLog> logger) { type = core::ClassType::Shader; log = logger; @@ -81,7 +81,7 @@ smShader::smShader(std::shared_ptr<ErrorLog> logger) checkErrorEnabled = false; } -bool smShader::readShaderContent(const std::string& p_file, std::string& p_content) +bool Shader::readShaderContent(const std::string& p_file, std::string& p_content) { std::ifstream file; if ("" != p_file) @@ -113,7 +113,7 @@ bool smShader::readShaderContent(const std::string& p_file, std::string& p_conte ///this function gets the vertex,fragment and geometry shader fileNames respectively. if you don't use /// one of them just simply send NULL pointer as a parameter. -bool smShader::initShaders(const std::string& p_vertexProgFileName, +bool Shader::initShaders(const std::string& p_vertexProgFileName, const std::string& p_fragmentProgFileName, const std::string& p_geometryProgFileName) { @@ -212,7 +212,7 @@ bool smShader::initShaders(const std::string& p_vertexProgFileName, return true; } -void smShader::createShaderGLSL(GLhandleARB &p_shaderObject, +void Shader::createShaderGLSL(GLhandleARB &p_shaderObject, const GLhandleARB p_shaderProgramObject, const std::string& p_shaderContent, GLenum p_shaderType) @@ -228,24 +228,24 @@ void smShader::createShaderGLSL(GLhandleARB &p_shaderObject, checkGLError(); } -void smShader::createVertexShaderGLSL() +void Shader::createVertexShaderGLSL() { createShaderGLSL(vertexShaderObject, shaderProgramObject, vertexShaderContent, GL_VERTEX_SHADER); } -void smShader::createFragmentShaderGLSL() +void Shader::createFragmentShaderGLSL() { createShaderGLSL(fragmentShaderObject, shaderProgramObject, fragmentShaderContent, GL_FRAGMENT_SHADER); } -void smShader::createGeometryShaderGLSL() +void Shader::createGeometryShaderGLSL() { createShaderGLSL(geometryShaderObject, shaderProgramObject, geometryShaderContent, GL_GEOMETRY_SHADER_EXT); } -void smShader::reloadShaderGLSL(const GLhandleARB p_shaderObject, +void Shader::reloadShaderGLSL(const GLhandleARB p_shaderObject, const std::string& p_shaderContent) { const char *shaderSrc = p_shaderContent.data(); @@ -254,28 +254,28 @@ void smShader::reloadShaderGLSL(const GLhandleARB p_shaderObject, checkGLError(); } -void smShader::reloadVertexShaderGLSL() +void Shader::reloadVertexShaderGLSL() { reloadShaderGLSL(vertexShaderObject, vertexShaderContent); } -void smShader::reloadFragmentShaderGLSL() +void Shader::reloadFragmentShaderGLSL() { reloadShaderGLSL(fragmentShaderObject, fragmentShaderContent); } -void smShader::reloadGeometryShaderGLSL() +void Shader::reloadGeometryShaderGLSL() { reloadShaderGLSL(geometryShaderObject, geometryShaderContent); } ///checks the opengl error -bool smShader::checkGLError() +bool Shader::checkGLError() { std::string errorText; if (checkErrorEnabled) { - if (smGLUtils::queryGLError(errorText)) + if (GLUtils::queryGLError(errorText)) { if (log != NULL) { @@ -294,7 +294,7 @@ bool smShader::checkGLError() ///enable the shader -void smShader::enableShader() +void Shader::enableShader() { #ifdef SIMMEDTK_OPENGL_SHADER @@ -315,14 +315,14 @@ void smShader::enableShader() } glUseProgramObjectARB(shaderProgramObject); - smShader::currentShader = safeDownCast<smShader>(); + Shader::currentShader = safeDownCast<Shader>(); currentShaderEnabled = true; #endif } ///disable the shader -void smShader::disableShader() +void Shader::disableShader() { #ifdef SIMMEDTK_OPENGL_SHADER @@ -343,20 +343,20 @@ void smShader::disableShader() } glUseProgramObjectARB(0); - smShader::currentShader = safeDownCast<smShader>(); + Shader::currentShader = safeDownCast<Shader>(); currentShaderEnabled = false; #endif } ///enable the shader -void smShader::restoreAndEnableCurrent() +void Shader::restoreAndEnableCurrent() { #ifdef SIMMEDTK_OPENGL_SHADER - if (smShader::savedShader != NULL) + if (Shader::savedShader != NULL) { - smShader::currentShader = smShader::savedShader; + Shader::currentShader = Shader::savedShader; if (currentShader->vertexProgramExist) { @@ -381,37 +381,37 @@ void smShader::restoreAndEnableCurrent() } ///disable the shader -void smShader::saveAndDisableCurrent() +void Shader::saveAndDisableCurrent() { #ifdef SIMMEDTK_OPENGL_SHADER if (currentShader != NULL) { - if (smShader::currentShader->vertexProgramExist) + if (Shader::currentShader->vertexProgramExist) { glDisable(GL_VERTEX_PROGRAM_ARB); } - if (smShader::currentShader->fragmentProgramExist) + if (Shader::currentShader->fragmentProgramExist) { glDisable(GL_FRAGMENT_PROGRAM_ARB); } - if (smShader::currentShader->geometryProgramExist) + if (Shader::currentShader->geometryProgramExist) { glDisable(GL_GEOMETRY_SHADER_ARB); } currentShaderEnabled = false; - smShader::savedShader = smShader::currentShader; + Shader::savedShader = Shader::currentShader; glUseProgramObjectARB(0); } #endif } -GLint smShader::addShaderParamGLSL(const std::string& p_paramName, +GLint Shader::addShaderParamGLSL(const std::string& p_paramName, const GLhandleARB p_shaderProgramObject, std::vector<std::string>& p_shaderParamsString, std::vector<GLint>& p_shaderParams) @@ -424,32 +424,32 @@ GLint smShader::addShaderParamGLSL(const std::string& p_paramName, return param; } -GLint smShader::addVertexShaderParamGLSL(const std::string& p_paramNameVertex) +GLint Shader::addVertexShaderParamGLSL(const std::string& p_paramNameVertex) { return addShaderParamGLSL(p_paramNameVertex, shaderProgramObject, vertexShaderParamsString, vertexShaderParams); } -GLint smShader::addFragmentShaderParamGLSL(const std::string& p_paramNameFragment) +GLint Shader::addFragmentShaderParamGLSL(const std::string& p_paramNameFragment) { return addShaderParamGLSL(p_paramNameFragment, shaderProgramObject, fragmentShaderParamsString, fragmentShaderParams); } -GLint smShader::addGeometryShaderParamGLSL(const std::string& p_paramNameGeometry) +GLint Shader::addGeometryShaderParamGLSL(const std::string& p_paramNameGeometry) { return addShaderParamGLSL(p_paramNameGeometry, shaderProgramObject, geometryShaderParamsString, geometryShaderParams); } -GLint smShader::addVertexShaderParam(const std::string& p_paramNameVertex) +GLint Shader::addVertexShaderParam(const std::string& p_paramNameVertex) { #ifdef SIMMEDTK_OPENGL_SHADER return addVertexShaderParamGLSL(p_paramNameVertex); #endif } -GLint smShader::addFragmentShaderParam(const std::string& p_paramNameFragment) +GLint Shader::addFragmentShaderParam(const std::string& p_paramNameFragment) { #ifdef SIMMEDTK_OPENGL_SHADER @@ -457,7 +457,7 @@ GLint smShader::addFragmentShaderParam(const std::string& p_paramNameFragment) #endif } -GLint smShader::addGeometryShaderParam(const std::string& p_paramNameGeometry) +GLint Shader::addGeometryShaderParam(const std::string& p_paramNameGeometry) { #ifdef SIMMEDTK_OPENGL_SHADER @@ -465,7 +465,7 @@ GLint smShader::addGeometryShaderParam(const std::string& p_paramNameGeometry) #endif } -GLint smShader::addShaderParamForAll(const std::string& p_paramName) +GLint Shader::addShaderParamForAll(const std::string& p_paramName) { #ifdef SIMMEDTK_OPENGL_SHADER @@ -485,7 +485,7 @@ GLint smShader::addShaderParamForAll(const std::string& p_paramName) #endif } -GLint smShader::getShaderParamForAll(const std::string& p_paramName) const +GLint Shader::getShaderParamForAll(const std::string& p_paramName) const { #ifdef SIMMEDTK_OPENGL_SHADER for (size_t i = 0; i < vertexShaderParamsString.size(); i++) @@ -500,7 +500,7 @@ GLint smShader::getShaderParamForAll(const std::string& p_paramName) const #endif } -GLint smShader::getFragmentShaderParam(const std::string& p_paramName) const +GLint Shader::getFragmentShaderParam(const std::string& p_paramName) const { #ifdef SIMMEDTK_OPENGL_SHADER for (size_t i = 0; i < fragmentShaderParamsString.size(); i++) @@ -515,7 +515,7 @@ GLint smShader::getFragmentShaderParam(const std::string& p_paramName) const #endif } -GLint smShader::getShaderAtrribParam(const std::string& p_paramName) const +GLint Shader::getShaderAtrribParam(const std::string& p_paramName) const { #ifdef SIMMEDTK_OPENGL_SHADER for (size_t i = 0; i < attribParamsString.size(); i++) @@ -529,7 +529,7 @@ GLint smShader::getShaderAtrribParam(const std::string& p_paramName) const return -1; #endif } -GLint smShader::addShaderParamAttrib(const std::string& p_paramName) +GLint Shader::addShaderParamAttrib(const std::string& p_paramName) { GLint param; @@ -540,7 +540,7 @@ GLint smShader::addShaderParamAttrib(const std::string& p_paramName) return param; } -bool smShader::reLoadAllShaders() +bool Shader::reLoadAllShaders() { std::ifstream vertexShaderFile; @@ -612,7 +612,7 @@ bool smShader::reLoadAllShaders() return true; } ///checks the shader source code within the given interval in milliseconds -bool smShader::checkShaderUpdate(int interval) +bool Shader::checkShaderUpdate(int interval) { if ((time.elapsed() * 1000) > interval) { @@ -622,28 +622,28 @@ bool smShader::checkShaderUpdate(int interval) return true; } -void smShader::enableCheckingErrors(bool p_checkError) +void Shader::enableCheckingErrors(bool p_checkError) { this->checkErrorEnabled = p_checkError; } -void smShader::attachTexture(std::shared_ptr<UnifiedId> p_meshID, int p_textureID) +void Shader::attachTexture(std::shared_ptr<UnifiedId> p_meshID, int p_textureID) { - smTextureShaderAssignment assign; + TextureShaderAssignment assign; assign.textureId = p_textureID; texAssignments.insert( {p_meshID->getId(), assign} ); } -bool smShader::attachTexture(std::shared_ptr<UnifiedId> p_meshID, +bool Shader::attachTexture(std::shared_ptr<UnifiedId> p_meshID, const std::string& p_textureName, const std::string& p_textureShaderName) { - smTextureShaderAssignment assign; + TextureShaderAssignment assign; - if (smTextureManager::findTextureId(p_textureName, assign.textureId) == SIMMEDTK_TEXTURE_NOTFOUND) + if (TextureManager::findTextureId(p_textureName, assign.textureId) == SIMMEDTK_TEXTURE_NOTFOUND) { std::cout << "texture " << p_textureName << " is not found in shader:" << p_textureShaderName << " for mesh id:" << p_meshID->getId() << "\n"; return false; @@ -655,10 +655,10 @@ bool smShader::attachTexture(std::shared_ptr<UnifiedId> p_meshID, return true; } -void smShader::autoGetTextureIds() +void Shader::autoGetTextureIds() { - std::unordered_multimap<int, smTextureShaderAssignment>::iterator i = texAssignments.begin() ; + std::unordered_multimap<int, TextureShaderAssignment>::iterator i = texAssignments.begin() ; for (; i != texAssignments.end(); i++) { @@ -666,13 +666,13 @@ void smShader::autoGetTextureIds() } } -void smShader::createTextureParam(const std::string& p_textureNameInShaderCode) +void Shader::createTextureParam(const std::string& p_textureNameInShaderCode) { this->textureGLBind[p_textureNameInShaderCode] = -1; } -bool smShader::setShaderFileName(const std::string& p_vertexFileName, +bool Shader::setShaderFileName(const std::string& p_vertexFileName, const std::string& p_geometryFileName, const std::string& p_fragmentFileName) { @@ -722,7 +722,7 @@ bool smShader::setShaderFileName(const std::string& p_vertexFileName, return true; } -void smShader::initDraw() +void Shader::initDraw() { initShaders(vertexProgFileName, fragmentProgFileName, geometryProgFileName); @@ -730,20 +730,20 @@ void smShader::initDraw() autoGetTextureIds(); } -int smShader::createAttrib(const std::string& p_attrib) +int Shader::createAttrib(const std::string& p_attrib) { attribParamsString.push_back(p_attrib); return attribParamsString.size(); } -void smShader::createParam(const std::string& p_param) +void Shader::createParam(const std::string& p_param) { vertexShaderParamsString.push_back(p_param); fragmentShaderParamsString.push_back(p_param); geometryShaderParamsString.push_back(p_param); } -void smShader::getAttribAndParamLocations() +void Shader::getAttribAndParamLocations() { GLint param; @@ -763,7 +763,7 @@ void smShader::getAttribAndParamLocations() { param = glGetUniformLocation(shaderProgramObject, fragmentShaderParamsString[i].data()); fragmentShaderParams.push_back(param); - std::cout << "[smShader::getAttribAndParamLocations] " << fragmentShaderParamsString[i] << " " << param << "\n"; + std::cout << "[Shader::getAttribAndParamLocations] " << fragmentShaderParamsString[i] << " " << param << "\n"; if (textureGLBind[fragmentShaderParamsString[i]] != -1) { @@ -790,42 +790,42 @@ void smShader::getAttribAndParamLocations() } -void smShader::initGLShaders() +void Shader::initGLShaders() { for(auto& x : shaders) x.second->initDraw(); } -void smShader::activeGLTextures(std::shared_ptr<UnifiedId> p_id) +void Shader::activeGLTextures(std::shared_ptr<UnifiedId> p_id) { int counter = 0; auto range = texAssignments.equal_range(p_id->getId()); for (auto i = range.first; i != range.second; i++) { - smTextureManager::activateTexture(i->second.textureId, counter); + TextureManager::activateTexture(i->second.textureId, counter); glUniform1iARB(i->second.textureShaderGLassignment, counter); counter++; } } -void smShader::activeGLVertAttribs(int p_id, core::Vec3d *p_vecs, int /*p_size*/) +void Shader::activeGLVertAttribs(int p_id, core::Vec3d *p_vecs, int /*p_size*/) { glVertexAttribPointer(attribShaderParams[p_id], 3, GL_FLOAT, GL_FALSE, 0, p_vecs); } -void smShader::registerShader() +void Shader::registerShader() { - shaders[this->getUniqueId()->getId()] = safeDownCast<smShader>(); + shaders[this->getUniqueId()->getId()] = safeDownCast<Shader>(); } -void smShader::print() const +void Shader::print() const { for (size_t i = 0; i < vertexShaderParamsString.size(); i++) { std::cout << "Param:" << vertexShaderParamsString[i] << "\n"; } } -bool smShader::setModelViewMatrixShaderName(const std::string& p_modelviewMatrixName ) +bool Shader::setModelViewMatrixShaderName(const std::string& p_modelviewMatrixName ) { if ((core::MaxShaderVariableName - 1) < p_modelviewMatrixName.length()) { @@ -839,7 +839,7 @@ bool smShader::setModelViewMatrixShaderName(const std::string& p_modelviewMatrix createParam(modelViewMatrixName); return true; } -bool smShader::setProjectionMatrixShaderName(const std::string& p_projectionName) +bool Shader::setProjectionMatrixShaderName(const std::string& p_projectionName) { if ((core::MaxShaderVariableName - 1) < p_projectionName.length()) { @@ -853,25 +853,25 @@ bool smShader::setProjectionMatrixShaderName(const std::string& p_projectionName createParam(projectionMatrixName); return true; } -void smShader::updateGLSLMatwithOPENGL() +void Shader::updateGLSLMatwithOPENGL() { Matrix44f proj, model; - smGLUtils::queryModelViewMatrix( model ); - smGLUtils::queryProjectionMatrix( proj ); + GLUtils::queryModelViewMatrix( model ); + GLUtils::queryProjectionMatrix( proj ); //as the our matrix is row major, we need transpose it. Transpose parameters are true glUniformMatrix4fv( modelViewMatrix, 1, true, model.data() ); glUniformMatrix4fv( projectionMatrix, 1, true, proj.data() ); } -GLint smShader::queryUniformLocation(const std::string& p_param) +GLint Shader::queryUniformLocation(const std::string& p_param) { return glGetUniformLocation(shaderProgramObject, p_param.data()); } -std::shared_ptr<smShader> smShader::getShader( std::shared_ptr<UnifiedId> p_shaderID ) +std::shared_ptr<Shader> Shader::getShader( std::shared_ptr<UnifiedId> p_shaderID ) { return shaders[p_shaderID->getId()]; } -smShader::~smShader() +Shader::~Shader() { #ifdef SIMMEDTK_OPENGL_SHADER diff --git a/src/Rendering/Shader.h b/src/Rendering/Shader.h index d923d3aaf89949217b874ba49c5b349b5db69f90..fc4107ea04e95edc5c3b300eb06df33c114007e5 100644 --- a/src/Rendering/Shader.h +++ b/src/Rendering/Shader.h @@ -38,12 +38,12 @@ #include "GLUtils.h" #include "Core/Timer.h" -class smMesh; -class smSurfaceMesh; +class Mesh; +class SurfaceMesh; -struct smTextureShaderAssignment +struct TextureShaderAssignment { - GLint textureShaderGLassignment; // the id that smShader creates... + GLint textureShaderGLassignment; // the id that Shader creates... int textureId; // Id from texture manager std::string shaderParamName; // The parameters that shaders use }; @@ -51,7 +51,7 @@ struct smTextureShaderAssignment // \brief Base shader class. It provides loading, initializing, binding, // enabling disabling current shader functionality.Also it provides // frequent check of the shader code to make shader development easy. -class smShader: public CoreClass +class Shader: public CoreClass { public: #ifdef SIMMEDTK_OPENGL_SHADER @@ -160,7 +160,7 @@ protected: public: // \brief constructor gets the error log class - smShader(std::shared_ptr<ErrorLog> logger); + Shader(std::shared_ptr<ErrorLog> logger); // \brief initialized the shaders. // \param vertexProgFileName vertex program file name @@ -231,18 +231,18 @@ public: void enableCheckingErrors(bool p_checkError); // \brief cleans up of the shader objects - ~smShader(); + ~Shader(); // \brief void implementations for virtual functions. needs to be overwritten for any specific uniform bindings - virtual void predraw(std::shared_ptr<smMesh>/*mesh*/){}; + virtual void predraw(std::shared_ptr<Mesh>/*mesh*/){}; - virtual void predraw(std::shared_ptr<smSurfaceMesh>/*mesh*/){}; + virtual void predraw(std::shared_ptr<SurfaceMesh>/*mesh*/){}; - virtual void posdraw(std::shared_ptr<smMesh>/*mesh*/){}; + virtual void posdraw(std::shared_ptr<Mesh>/*mesh*/){}; - virtual void posdraw(std::shared_ptr<smSurfaceMesh>/*mesh*/){}; + virtual void posdraw(std::shared_ptr<SurfaceMesh>/*mesh*/){}; - static std::shared_ptr<smShader> getShader(std::shared_ptr<UnifiedId> p_shaderID); + static std::shared_ptr<Shader> getShader(std::shared_ptr<UnifiedId> p_shaderID); bool readShaderContent(const std::string& p_file, std::string& p_content); @@ -273,8 +273,8 @@ protected: GLint tangentAttrib; private: - static std::unordered_map<int, std::shared_ptr<smShader>> shaders; - std::unordered_multimap<int, smTextureShaderAssignment> texAssignments; // + static std::unordered_map<int, std::shared_ptr<Shader>> shaders; + std::unordered_multimap<int, TextureShaderAssignment> texAssignments; // std::unordered_map<std::string, GLint> textureGLBind; // This stores the opengl binded texture id std::vector<std::string> vertexShaderParamsString; // stores the parameters for vertex shader std::vector<std::string> fragmentShaderParamsString; // stores the parameters for fragment shader @@ -299,8 +299,8 @@ private: bool geometryProgramExist; // if the geometry shader exists this will be true bool currentShaderEnabled; // if the currentShader is enabled or not - static std::shared_ptr<smShader> currentShader; // stores the current Active shader. - static std::shared_ptr<smShader> savedShader; // It is also used to save and restore the current shader is disabled for a while to use + static std::shared_ptr<Shader> currentShader; // stores the current Active shader. + static std::shared_ptr<Shader> savedShader; // It is also used to save and restore the current shader is disabled for a while to use #ifdef SIMMEDTK_OPENGL_SHADER GLhandleARB vertexShaderObject; // vertex shader object diff --git a/src/Rendering/TextureManager.cpp b/src/Rendering/TextureManager.cpp index e37d95d03197eaf944a37fc08a8a36346516cacd..74db3da1c03eb73dc0526ee58c8fb8d1a4aab59e 100644 --- a/src/Rendering/TextureManager.cpp +++ b/src/Rendering/TextureManager.cpp @@ -26,16 +26,16 @@ #include <cassert> -std::shared_ptr<ErrorLog> smTextureManager:: errorLog; -std::vector<Texture*> smTextureManager:: textures; -std::unordered_map<std::string, int> smTextureManager::textureIndexId; -int smTextureManager:: activeTextures; -bool smTextureManager::isInitialized = false; -bool smTextureManager::isInitializedGL = false; -bool smTextureManager::isDeleteImagesEnabled = false; +std::shared_ptr<ErrorLog> TextureManager:: errorLog; +std::vector<Texture*> TextureManager:: textures; +std::unordered_map<std::string, int> TextureManager::textureIndexId; +int TextureManager:: activeTextures; +bool TextureManager::isInitialized = false; +bool TextureManager::isInitializedGL = false; +bool TextureManager::isDeleteImagesEnabled = false; /// \brief -smTextureReturnType smTextureManager::initGLTextures() +smTextureReturnType TextureManager::initGLTextures() { std::string texManagerError; Texture *texture; @@ -77,7 +77,7 @@ smTextureReturnType smTextureManager::initGLTextures() glGenerateMipmap(GL_TEXTURE_2D); - if (smGLUtils::queryGLError(texManagerError)) + if (GLUtils::queryGLError(texManagerError)) { if(nullptr != errorLog) { @@ -94,7 +94,7 @@ smTextureReturnType smTextureManager::initGLTextures() /// \brief load the texture and associated it with reference name. /// Also you could use texture Id for activation of the texture -smTextureReturnType smTextureManager::loadTexture(const std::string& p_fileName, +smTextureReturnType TextureManager::loadTexture(const std::string& p_fileName, const std::string& p_textureReferenceName, int &p_textureId) { smTextureReturnType ret = loadTexture(p_fileName, p_textureReferenceName, true); @@ -106,7 +106,7 @@ smTextureReturnType smTextureManager::loadTexture(const std::string& p_fileName, } /// \brief -smTextureReturnType smTextureManager::loadTexture(const std::string& p_fileName, const std::string& p_textureReferenceName, bool p_flipImage) +smTextureReturnType TextureManager::loadTexture(const std::string& p_fileName, const std::string& p_textureReferenceName, bool p_flipImage) { Texture *texture = nullptr; sf::Vector2u imageSize; @@ -123,7 +123,7 @@ smTextureReturnType smTextureManager::loadTexture(const std::string& p_fileName, assert(texture); if (false == texture->image.loadFromFile(p_fileName)) { - std::cout << "[smTextureManager::loadTexture] Texture not found: \"" << p_fileName << "\"\n"; + std::cout << "[TextureManager::loadTexture] Texture not found: \"" << p_fileName << "\"\n"; return SIMMEDTK_TEXTURE_NOTFOUND; } @@ -145,7 +145,7 @@ smTextureReturnType smTextureManager::loadTexture(const std::string& p_fileName, /// \brief if the texture is not loaded previously, create and the texture return the id -smTextureReturnType smTextureManager::findTextureId(const std::string& p_textureReferenceName, +smTextureReturnType TextureManager::findTextureId(const std::string& p_textureReferenceName, int &p_textureId) { if (textureIndexId.count(p_textureReferenceName) > 0) @@ -162,7 +162,7 @@ smTextureReturnType smTextureManager::findTextureId(const std::string& p_texture } /// \brief activate the texture with given texture reference name -GLuint smTextureManager::activateTexture(const std::string& p_textureReferenceName) +GLuint TextureManager::activateTexture(const std::string& p_textureReferenceName) { int textureId; @@ -176,7 +176,7 @@ GLuint smTextureManager::activateTexture(const std::string& p_textureReferenceNa } /// \brief activate the texture given the Texture argument -GLuint smTextureManager::activateTexture(Texture *p_texture) +GLuint TextureManager::activateTexture(Texture *p_texture) { glBindTexture(GL_TEXTURE_2D, p_texture->textureGLId); @@ -186,7 +186,7 @@ GLuint smTextureManager::activateTexture(Texture *p_texture) /// \brief This function binds the texture to the appropriate texture. ///For instance if the argument is 0, the it will bind to GL_TEXTURE0 -GLuint smTextureManager::activateTexture(const std::string& p_textureReferenceName, int p_textureGLOrder) +GLuint TextureManager::activateTexture(const std::string& p_textureReferenceName, int p_textureGLOrder) { int textureId; @@ -203,7 +203,7 @@ GLuint smTextureManager::activateTexture(const std::string& p_textureReferenceNa /// first parameter is texture reference /// For instance if the argument is 0, the it will bind to GL_TEXTURE0 /// Also for the shader the binded name will be p_shaderBindName -GLuint smTextureManager::activateTexture(const std::string& p_textureReferenceName, +GLuint TextureManager::activateTexture(const std::string& p_textureReferenceName, int p_textureGLOrder, int p_shaderBindGLId) { @@ -221,7 +221,7 @@ GLuint smTextureManager::activateTexture(const std::string& p_textureReferenceNa /// \brief This function binds the Texture to the appropriate shader texture. /// For instance if the argument is 0, the it will bind to GL_TEXTURE0 /// Also for the shader the binded name will be p_shaderBindName -GLuint smTextureManager::activateTexture(Texture *p_texture, +GLuint TextureManager::activateTexture(Texture *p_texture, int p_textureGLOrder, int p_shaderBindGLId) { @@ -233,7 +233,7 @@ GLuint smTextureManager::activateTexture(Texture *p_texture, } /// \brief -GLuint smTextureManager::activateTexture(int p_textureId) +GLuint TextureManager::activateTexture(int p_textureId) { Texture *texture; @@ -245,7 +245,7 @@ GLuint smTextureManager::activateTexture(int p_textureId) } /// \brief -GLuint smTextureManager::activateTexture(int p_textureId, int p_textureGLOrder) +GLuint TextureManager::activateTexture(int p_textureId, int p_textureGLOrder) { Texture *texture; @@ -257,7 +257,7 @@ GLuint smTextureManager::activateTexture(int p_textureId, int p_textureGLOrder) } /// \brief -void smTextureManager::activateTextureGL(GLuint p_textureId, int p_textureGLOrder) +void TextureManager::activateTextureGL(GLuint p_textureId, int p_textureGLOrder) { glActiveTexture(GL_TEXTURE0 + p_textureGLOrder); @@ -266,7 +266,7 @@ void smTextureManager::activateTextureGL(GLuint p_textureId, int p_textureGLOrd } /// \brief -GLuint smTextureManager::disableTexture(const std::string& p_textureReferenceName) +GLuint TextureManager::disableTexture(const std::string& p_textureReferenceName) { GLuint textureId; @@ -279,7 +279,7 @@ GLuint smTextureManager::disableTexture(const std::string& p_textureReferenceNam } /// \brief -GLuint smTextureManager::disableTexture(const std::string& p_textureReferenceName, int p_textureGLOrder) +GLuint TextureManager::disableTexture(const std::string& p_textureReferenceName, int p_textureGLOrder) { GLuint textureId; @@ -294,7 +294,7 @@ GLuint smTextureManager::disableTexture(const std::string& p_textureReferenceNam } /// \brief -GLuint smTextureManager::disableTexture(int p_textureId) +GLuint TextureManager::disableTexture(int p_textureId) { Texture *texture; @@ -305,7 +305,7 @@ GLuint smTextureManager::disableTexture(int p_textureId) } /// \brief -GLuint smTextureManager::getOpenglTextureId(const std::string& p_textureReferenceName) +GLuint TextureManager::getOpenglTextureId(const std::string& p_textureReferenceName) { int textureId; @@ -317,7 +317,7 @@ GLuint smTextureManager::getOpenglTextureId(const std::string& p_textureReferenc } /// \brief -GLuint smTextureManager::getOpenglTextureId(int p_textureId) +GLuint TextureManager::getOpenglTextureId(int p_textureId) { Texture *texture; @@ -327,7 +327,7 @@ GLuint smTextureManager::getOpenglTextureId(int p_textureId) } /// \brief -void smTextureManager::createDepthTexture(const std::string& p_textureReferenceName, int p_width, int p_height) +void TextureManager::createDepthTexture(const std::string& p_textureReferenceName, int p_width, int p_height) { Texture *tex; @@ -343,7 +343,7 @@ void smTextureManager::createDepthTexture(const std::string& p_textureReferenceN } /// \brief -void smTextureManager::duplicateTexture(const std::string& p_textureReferenceName, Texture *p_texture, ImageColorType p_type) +void TextureManager::duplicateTexture(const std::string& p_textureReferenceName, Texture *p_texture, ImageColorType p_type) { Texture *tex; @@ -359,7 +359,7 @@ void smTextureManager::duplicateTexture(const std::string& p_textureReferenceNam } /// \brief -void smTextureManager::copyTexture(const std::string& /*p_textureDestinationName*/, const std::string& /*p_textureSourceName*/) +void TextureManager::copyTexture(const std::string& /*p_textureDestinationName*/, const std::string& /*p_textureSourceName*/) { // WARNING: This function does nothing // int textureDstId; @@ -375,7 +375,7 @@ void smTextureManager::copyTexture(const std::string& /*p_textureDestinationName } /// \brief -void smTextureManager::createColorTexture(const std::string& p_textureReferenceName, int p_width, int p_height) +void TextureManager::createColorTexture(const std::string& p_textureReferenceName, int p_width, int p_height) { Texture *tex; @@ -391,7 +391,7 @@ void smTextureManager::createColorTexture(const std::string& p_textureReferenceN } /// \brief -void smTextureManager::initDepthTexture(Texture *p_texture) +void TextureManager::initDepthTexture(Texture *p_texture) { glGenTextures(1, &p_texture->textureGLId); @@ -409,7 +409,7 @@ void smTextureManager::initDepthTexture(Texture *p_texture) } /// \brief -void smTextureManager::initColorTexture(Texture *p_texture) +void TextureManager::initColorTexture(Texture *p_texture) { glGenTextures(1, &p_texture->textureGLId); @@ -424,7 +424,7 @@ void smTextureManager::initColorTexture(Texture *p_texture) } /// \brief -Texture *smTextureManager::getTexture(const std::string& p_textureReferenceName) +Texture *TextureManager::getTexture(const std::string& p_textureReferenceName) { int textureId; @@ -434,7 +434,7 @@ Texture *smTextureManager::getTexture(const std::string& p_textureReferenceName) } /// \brief -void smTextureManager::generateMipMaps(int p_textureId) +void TextureManager::generateMipMaps(int p_textureId) { Texture *texture; @@ -444,7 +444,7 @@ void smTextureManager::generateMipMaps(int p_textureId) } /// \brief -void smTextureManager::generateMipMaps(const std::string& p_textureReferenceName) +void TextureManager::generateMipMaps(const std::string& p_textureReferenceName) { int textureId; diff --git a/src/Rendering/TextureManager.h b/src/Rendering/TextureManager.h index a24bde05de8068243f49abf64ba0a50b905f1974..d70db331069041b0f69fa6d2dcaee24ab97c6176 100644 --- a/src/Rendering/TextureManager.h +++ b/src/Rendering/TextureManager.h @@ -38,7 +38,7 @@ #include "Core/ErrorLog.h" /// \brief texture manager. It loads any image format and initializes in the GL context -class smTextureManager: public CoreClass +class TextureManager: public CoreClass { static std::shared_ptr<ErrorLog> errorLog; diff --git a/src/Rendering/VAO.cpp b/src/Rendering/VAO.cpp index 2b2a5d4c69864cd7e5c954518ebc5087c5b8a336..8b68554e64f8efdaaf22fba5ff7d449e8ba66679 100644 --- a/src/Rendering/VAO.cpp +++ b/src/Rendering/VAO.cpp @@ -25,14 +25,14 @@ #include "Shader.h" #include "Viewer.h" -std::unordered_map<int, std::shared_ptr<smVAO>> smVAO::VAOs; +std::unordered_map<int, std::shared_ptr<VAO>> VAO::VAOs; -void smVAO::initBuffers() +void VAO::initBuffers() { std::string error; ///Create the Vertex Array Objects - glGenVertexArrays(1, &VAO); - glBindVertexArray(VAO); + glGenVertexArrays(1, &vaObject); + glBindVertexArray(vaObject); ///Create Vertex Buffer Objects(VBOs) glGenBuffers(totalNbrBuffers, bufferIndices); @@ -127,7 +127,7 @@ void smVAO::initBuffers() } ///Updates the buffers. Call this function if there is change in the mesh. If it is a simulation mesh, it needs to be called in and very frame -bool smVAO::updateStreamData() const +bool VAO::updateStreamData() const { if (this->vboType == SIMMEDTK_VBO_STATIC) @@ -162,7 +162,7 @@ bool smVAO::updateStreamData() const return false; } -void smVAO::draw() const +void VAO::draw() const { glPushAttrib(GL_ENABLE_BIT); shader->enableShader(); @@ -174,7 +174,7 @@ void smVAO::draw() const shader->disableShader(); glPopAttrib(); } -smVBOBufferEntryInfo::smVBOBufferEntryInfo() +VBOBufferEntryInfo::VBOBufferEntryInfo() { shaderAttribLocation = -1; attributeIndex = 1; @@ -182,18 +182,18 @@ smVBOBufferEntryInfo::smVBOBufferEntryInfo() nbrElements = 0; arrayBufferType = SMVBO_POS; } -smVAO::smVAO( std::shared_ptr<ErrorLog> p_log, smVBOType p_vboType, bool p_bindShaderObjects ) +VAO::VAO( std::shared_ptr<ErrorLog> p_log, VBOType p_vboType, bool p_bindShaderObjects ) { this->log = p_log; renderingError = false; totalNbrBuffers = 0; vboType = p_vboType; - VAOs[this->getUniqueId()->getId()] = safeDownCast<smVAO>(); + VAOs[this->getUniqueId()->getId()] = safeDownCast<VAO>(); indexBufferLocation = -1; bindShaderObjects = p_bindShaderObjects; } -void smVAO::setBufferData( smVBOBufferType p_type, std::string p_ShaderAttribName, int p_nbrElements, void *p_ptr ) +void VAO::setBufferData( VBOBufferType p_type, std::string p_ShaderAttribName, int p_nbrElements, void *p_ptr ) { bufferInfo[totalNbrBuffers].arrayBufferType = p_type; @@ -207,7 +207,7 @@ void smVAO::setBufferData( smVBOBufferType p_type, std::string p_ShaderAttribNam else if ( p_type == SMVBO_TEXTURECOORDS || p_type == SMVBO_VEC2F ) { - bufferInfo[totalNbrBuffers].size = sizeof( smTexCoord ) * p_nbrElements; + bufferInfo[totalNbrBuffers].size = sizeof( TexCoord ) * p_nbrElements; } else if ( p_type == SMVBO_VEC4F ) { @@ -220,7 +220,7 @@ void smVAO::setBufferData( smVBOBufferType p_type, std::string p_ShaderAttribNam bufferInfo[totalNbrBuffers].shaderAttribName = p_ShaderAttribName; totalNbrBuffers++; } -void smVAO::setTriangleInfo( std::string p_ShaderAttribName, int p_nbrTriangles, void *p_ptr ) +void VAO::setTriangleInfo( std::string p_ShaderAttribName, int p_nbrTriangles, void *p_ptr ) { bufferInfo[totalNbrBuffers].arrayBufferType = SMVBO_INDEX; bufferInfo[totalNbrBuffers].nbrElements = p_nbrTriangles * 3; @@ -229,11 +229,11 @@ void smVAO::setTriangleInfo( std::string p_ShaderAttribName, int p_nbrTriangles, bufferInfo[totalNbrBuffers].shaderAttribName = p_ShaderAttribName; totalNbrBuffers++; } -bool smVAO::setBufferDataFromMesh( smMesh *p_mesh, std::shared_ptr<smShader> p_shader, std::string p_POSITIONShaderName, std::string p_NORMALShaderName, std::string p_TEXTURECOORDShaderName, std::string p_TANGENTSName ) +bool VAO::setBufferDataFromMesh( Mesh *p_mesh, std::shared_ptr<Shader> p_shader, std::string p_POSITIONShaderName, std::string p_NORMALShaderName, std::string p_TEXTURECOORDShaderName, std::string p_TANGENTSName ) { if ( p_shader == NULL ) { - shader = smShader::getShader( p_mesh->getRenderDetail()->shaders[0] ); + shader = Shader::getShader( p_mesh->getRenderDetail()->shaders[0] ); } else { @@ -258,7 +258,7 @@ bool smVAO::setBufferDataFromMesh( smMesh *p_mesh, std::shared_ptr<smShader> p_s ///texture coord is for each vertex bufferInfo[totalNbrBuffers].arrayBufferType = SMVBO_TEXTURECOORDS; - bufferInfo[totalNbrBuffers].size = sizeof( smTexCoord ) * p_mesh->nbrVertices; + bufferInfo[totalNbrBuffers].size = sizeof( TexCoord ) * p_mesh->nbrVertices; bufferInfo[totalNbrBuffers].attribPointer = p_mesh->texCoord; bufferInfo[totalNbrBuffers].nbrElements = p_mesh->nbrVertices; bufferInfo[totalNbrBuffers].attributeIndex = totalNbrBuffers; @@ -286,29 +286,29 @@ bool smVAO::setBufferDataFromMesh( smMesh *p_mesh, std::shared_ptr<smShader> p_s mesh = p_mesh; return true; } -void smVAO::initVAOs() +void VAO::initVAOs() { for ( auto & x : VAOs ) { x.second->initBuffers(); } } -std::shared_ptr<smVAO> smVAO::getVAO( std::shared_ptr<UnifiedId> p_shaderID ) +std::shared_ptr<VAO> VAO::getVAO( std::shared_ptr<UnifiedId> p_shaderID ) { return VAOs[p_shaderID->getId()]; } -void smVAO::enable() const +void VAO::enable() const { - glBindVertexArray( VAO ); + glBindVertexArray( vaObject ); } -void smVAO::disable() const +void VAO::disable() const { glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); } -smVAO::~smVAO() +VAO::~VAO() { glDeleteBuffers( totalNbrBuffers, bufferIndices ); - glDeleteVertexArrays( 1, &VAO ); + glDeleteVertexArrays( 1, &vaObject ); } diff --git a/src/Rendering/VAO.h b/src/Rendering/VAO.h index 2e0e2e4334538b266e388ec9b2278ffb36ff3d11..6bfdee268631f9b74bd746d530dabf7a94bddc2e 100644 --- a/src/Rendering/VAO.h +++ b/src/Rendering/VAO.h @@ -39,7 +39,7 @@ #include "VAO.h" #include "Shader.h" -enum smVBOBufferType +enum VBOBufferType { SMVBO_POS, SMVBO_NORMALS, @@ -51,12 +51,12 @@ enum smVBOBufferType SMVBO_VEC2F }; -struct smVBOBufferEntryInfo +struct VBOBufferEntryInfo { ///attrib index; 0, 1, 2. It starts from 0 int attributeIndex; ///based on type the data buffer will change. It may be Position, normals, texture coords, tangents - smVBOBufferType arrayBufferType; + VBOBufferType arrayBufferType; ///pointer to the actual that. It is mesh data. void *attribPointer; ///total number of elements @@ -67,25 +67,25 @@ struct smVBOBufferEntryInfo std::string shaderAttribName; GLint shaderAttribLocation; public: - smVBOBufferEntryInfo(); + VBOBufferEntryInfo(); }; /// \brief Vertex Array Object for fast rendering -class smVAO: public CoreClass +class VAO: public CoreClass { public: /// \brief need error log and totalBuffer Size - smVAO(std::shared_ptr<ErrorLog> p_log, smVBOType p_vboType = SIMMEDTK_VBO_DYNAMIC, bool p_bindShaderObjects = true); + VAO(std::shared_ptr<ErrorLog> p_log, VBOType p_vboType = SIMMEDTK_VBO_DYNAMIC, bool p_bindShaderObjects = true); /// \brief set internal buffer manually. type, attrib name, number of elements and pointer to the data - void setBufferData(smVBOBufferType p_type, std::string p_ShaderAttribName, int p_nbrElements, void *p_ptr); + void setBufferData(VBOBufferType p_type, std::string p_ShaderAttribName, int p_nbrElements, void *p_ptr); /// \brief set the triangle information void setTriangleInfo(std::string p_ShaderAttribName, int p_nbrTriangles, void *p_ptr); /// \brief fills the buffer by directly using mesh. It uses default attrib location for shader - bool setBufferDataFromMesh(smMesh *p_mesh, - std::shared_ptr<smShader> p_shader, + bool setBufferDataFromMesh(Mesh *p_mesh, + std::shared_ptr<Shader> p_shader, std::string p_POSITIONShaderName = "Position", std::string p_NORMALShaderName = "Normal", std::string p_TEXTURECOORDShaderName = "texCoords", @@ -99,7 +99,7 @@ public: void initBuffers(); /// \brief get VAO given the shader ID - static std::shared_ptr<smVAO> getVAO(std::shared_ptr<UnifiedId> p_shaderID); + static std::shared_ptr<VAO> getVAO(std::shared_ptr<UnifiedId> p_shaderID); /// \brief enable the vertex array object void enable() const; @@ -111,22 +111,22 @@ public: void draw() const override; /// \brief constructor - ~smVAO(); + ~VAO(); public: - GLuint VAO; + GLuint vaObject; int totalNbrBuffers; GLuint bufferIndices[SIMMEDTK_MAX_VBOBUFFERS]; int indexBufferLocation;///stores the index buffer location in the bufferIndices array to easy access - smVBOBufferEntryInfo bufferInfo[SIMMEDTK_MAX_VBOBUFFERS]; - smVBOType vboType; + VBOBufferEntryInfo bufferInfo[SIMMEDTK_MAX_VBOBUFFERS]; + VBOType vboType; ///All VBOs are stored here - static std::unordered_map<int, std::shared_ptr<smVAO>> VAOs; - smMesh *mesh; + static std::unordered_map<int, std::shared_ptr<VAO>> VAOs; + Mesh *mesh; private: std::shared_ptr<ErrorLog> log; - std::shared_ptr<smShader> shader; + std::shared_ptr<Shader> shader; bool renderingError; ///Used for attaching attribs to the vertex objects bool bindShaderObjects; diff --git a/src/Rendering/VBO.cpp b/src/Rendering/VBO.cpp index 02b1c7aac8a28bd46225de5de498b599ffaa59e8..2345e546f9e51afaab1ce17d81a07b4d7289df49 100644 --- a/src/Rendering/VBO.cpp +++ b/src/Rendering/VBO.cpp @@ -23,13 +23,13 @@ #include "VBO.h" -smVBO::smVBO( ErrorLog *p_log ) +VBO::VBO( ErrorLog *p_log ) { this->log = p_log; renderingError = false; } -smVBO::~smVBO() +VBO::~VBO() { glDeleteBuffersARB( 1, &vboDataId ); glDeleteBuffersARB( 1, &vboIndexId ); @@ -37,7 +37,7 @@ smVBO::~smVBO() /// WARNING: This function takes arrays to Eigen 3d vectors, /// it is not clear to me that the memory is aligned. -smVBOResult smVBO::updateVertices(const core::Vectorf &p_vectors, +VBOResult VBO::updateVertices(const core::Vectorf &p_vectors, const core::Vectorf &p_normals, const core::Vectorf &p_textureCoords, size_t p_objectId) @@ -82,7 +82,7 @@ smVBOResult smVBO::updateVertices(const core::Vectorf &p_vectors, return SIMMEDTK_VBO_OK; } -smVBOResult smVBO::updateTriangleIndices(const Vector<size_t> &p_indices, size_t p_objectId) +VBOResult VBO::updateTriangleIndices(const Vector<size_t> &p_indices, size_t p_objectId) { if ((vboType == SIMMEDTK_VBO_STATIC) | (vboType == SIMMEDTK_VBO_DYNAMIC)) { @@ -111,7 +111,7 @@ smVBOResult smVBO::updateTriangleIndices(const Vector<size_t> &p_indices, size_t return SIMMEDTK_VBO_OK; } -smVBOResult smVBO::drawElements(size_t p_objectId) +VBOResult VBO::drawElements(size_t p_objectId) { int dataOffset; @@ -152,7 +152,7 @@ smVBOResult smVBO::drawElements(size_t p_objectId) ///Static Binding of the buffers. It is mandatory to call this function /// this function must be called when the binding is SIMMEDTK_VBO_STATIC -smVBOResult smVBO::initStaticVertices(const core::Vectorf &p_vectors, +VBOResult VBO::initStaticVertices(const core::Vectorf &p_vectors, const core::Vectorf &p_normals, const core::Vectorf &p_textureCoords, size_t p_objectId) @@ -186,7 +186,7 @@ smVBOResult smVBO::initStaticVertices(const core::Vectorf &p_vectors, ///init Triangle Indices for the very first time for static objects ///this function must be called when the indices are not changing ///SIMMEDTK_VBO_NOINDICESCHANGE -smVBOResult smVBO::initTriangleIndices(const Vector<size_t> &p_indices, size_t p_objectId) +VBOResult VBO::initTriangleIndices(const Vector<size_t> &p_indices, size_t p_objectId) { size_t indexOffset; @@ -197,14 +197,14 @@ smVBOResult smVBO::initTriangleIndices(const Vector<size_t> &p_indices, size_t p indexOffset = indexOffsetMap[p_objectId]; glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vboIndexId); - glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexOffset, sizeof(smTriangle)*p_indices.size(), p_indices.data()); + glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexOffset, sizeof(Triangle)*p_indices.size(), p_indices.data()); // Unmap the buffer glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB); return SIMMEDTK_VBO_OK; } -void smVBO::init( smVBOType p_vboType ) +void VBO::init( VBOType p_vboType ) { std::string error; glGenBuffersARB(1, &vboDataId); @@ -245,9 +245,9 @@ void smVBO::init( smVBOType p_vboType ) glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); } -smVBOResult smVBO::addVerticestoBuffer( const size_t p_nbrVertices, const size_t p_nbrTriangles, const size_t p_objectId ) +VBOResult VBO::addVerticestoBuffer( const size_t p_nbrVertices, const size_t p_nbrTriangles, const size_t p_objectId ) { - if ( sizeof( core::Vec3d )*p_nbrVertices + sizeof( core::Vec3d )*p_nbrVertices + sizeof( smTexCoord )*p_nbrVertices > sizeOfDataBuffer - currentDataOffset ) + if ( sizeof( core::Vec3d )*p_nbrVertices + sizeof( core::Vec3d )*p_nbrVertices + sizeof( TexCoord )*p_nbrVertices > sizeOfDataBuffer - currentDataOffset ) { return SIMMEDTK_VBO_NODATAMEMORY; } @@ -262,7 +262,7 @@ smVBOResult smVBO::addVerticestoBuffer( const size_t p_nbrVertices, const size_t numberofVertices[p_objectId] = p_nbrVertices; numberofTriangles[p_objectId] = p_nbrTriangles; ///add the vertices and normals and the texture coordinates - currentDataOffset += sizeof( core::Vec3d ) * p_nbrVertices + sizeof( core::Vec3d ) * p_nbrVertices + sizeof( smTexCoord ) * p_nbrVertices; - currentIndexOffset += p_nbrTriangles * sizeof( smTriangle ); + currentDataOffset += sizeof( core::Vec3d ) * p_nbrVertices + sizeof( core::Vec3d ) * p_nbrVertices + sizeof( TexCoord ) * p_nbrVertices; + currentIndexOffset += p_nbrTriangles * sizeof( Triangle ); return SIMMEDTK_VBO_OK; } diff --git a/src/Rendering/VBO.h b/src/Rendering/VBO.h index 3e95a26076ee1ff8c98081350bf54e2914905937..bfe8cb94679bbeb78504e211a5382a7d3feced20 100644 --- a/src/Rendering/VBO.h +++ b/src/Rendering/VBO.h @@ -38,7 +38,7 @@ #include "Core/Vector.h" /// \brief VBO for rendering -class smVBO: public CoreClass +class VBO: public CoreClass { private: /// \brief offsets for each mesh @@ -47,7 +47,7 @@ private: size_t sizeOfDataBuffer; size_t sizeOfIndexBuffer; /// \brief VBO type - smVBOType vboType; + VBOType vboType; /// \brief vertices, normals, tangets data buffer GLuint vboDataId; /// \brief index data @@ -67,39 +67,39 @@ private: public: /// \brief constructor. gets error log or NULL - smVBO(ErrorLog *p_log); + VBO(ErrorLog *p_log); /// \brief init with given VBO type - void init(smVBOType p_vboType); + void init(VBOType p_vboType); /// \brief add vertices to the data buffer - smVBOResult addVerticestoBuffer(const size_t p_nbrVertices, + VBOResult addVerticestoBuffer(const size_t p_nbrVertices, const size_t p_nbrTriangles, const size_t p_objectId); /// \brief update vertex data buffer - smVBOResult updateVertices(const core::Vectorf &p_vectors, + VBOResult updateVertices(const core::Vectorf &p_vectors, const core::Vectorf &p_normals, const core::Vectorf &p_textureCoords, size_t p_objectId); /// \brief update triangle index - smVBOResult updateTriangleIndices(const Vector<size_t> &p_indices, size_t p_objectId); + VBOResult updateTriangleIndices(const Vector<size_t> &p_indices, size_t p_objectId); /// \brief draw elements in VBO - smVBOResult drawElements(size_t p_objectId); + VBOResult drawElements(size_t p_objectId); /// \brief update the static vertices initially - smVBOResult initStaticVertices(const core::Vectorf &p_vectors, + VBOResult initStaticVertices(const core::Vectorf &p_vectors, const core::Vectorf &p_normals, const core::Vectorf &p_textureCoords, size_t p_objectId); /// \brief update the static triangle indices initially - smVBOResult initTriangleIndices(const Vector<size_t> &p_indices, size_t p_objectId); + VBOResult initTriangleIndices(const Vector<size_t> &p_indices, size_t p_objectId); /// \brief deletion of the VBO buffers - ~smVBO(); + ~VBO(); }; diff --git a/src/Rendering/Viewer.cpp b/src/Rendering/Viewer.cpp index 448add6bf1c24e0cb1fed310a7e673029383628e..bf4255f289996917c55297639a560009555ef9be 100644 --- a/src/Rendering/Viewer.cpp +++ b/src/Rendering/Viewer.cpp @@ -49,22 +49,22 @@ typedef bool (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int); #endif -void smViewer::setVSync(bool sync) +void Viewer::setVSync(bool sync) { this->sfmlWindow->setVerticalSyncEnabled(sync); } -smViewer::smViewer() +Viewer::Viewer() { this->windowOutput = std::make_shared<smOpenGLWindowStream>(); } -void smViewer::exitViewer() +void Viewer::exitViewer() { } /// \brief Initializes OpenGL capabilities and flags -void smViewer::initRenderingCapabilities() +void Viewer::initRenderingCapabilities() { //use multiple fragment samples in computing the final color of a pixel glEnable(GL_MULTISAMPLE); @@ -98,17 +98,17 @@ void smViewer::initRenderingCapabilities() } /// \brief Initializes FBOs, textures, shaders and VAOs -void smViewer::initResources() +void Viewer::initResources() { - smTextureManager::initGLTextures(); - smShader::initGLShaders(); - smVAO::initVAOs(); + TextureManager::initGLTextures(); + Shader::initGLShaders(); + VAO::initVAOs(); initFboListItems(); } /// \brief Initializes the OpenGL context, and window containing it -void smViewer::initRenderingContext() +void Viewer::initRenderingContext() { // Init OpenGL context @@ -139,13 +139,13 @@ void smViewer::initRenderingContext() } /// \brief Cleans up after initGLContext() -void smViewer::destroyRenderingContext() +void Viewer::destroyRenderingContext() { //nothing to do } /// \brief render depth texture for debugging -void smViewer::renderTextureOnView() +void Viewer::renderTextureOnView() { glPushAttrib(GL_TEXTURE_BIT | GL_VIEWPORT_BIT | GL_LIGHTING_BIT); @@ -158,7 +158,7 @@ void smViewer::renderTextureOnView() glLoadIdentity(); glColor4f(1, 1, 1, 1); glActiveTextureARB(GL_TEXTURE0); - smTextureManager::activateTexture("depth"); + TextureManager::activateTexture("depth"); glEnable(GL_TEXTURE_2D); glTranslated(0, 0, -1); glBegin(GL_QUADS); @@ -184,7 +184,7 @@ void smViewer::renderTextureOnView() /// \param p_depthTex A texture that will contain the fbo's depth texture. /// \param p_width The width of the fbo /// \param p_height The height of the fbo -void smViewer::addFBO(const std::string &p_fboName, +void Viewer::addFBO(const std::string &p_fboName, Texture *p_colorTex, Texture *p_depthTex, unsigned int p_width, unsigned int p_height) @@ -207,12 +207,12 @@ void smViewer::addFBO(const std::string &p_fboName, } /// \brief Initializes the FBOs in the FBO list -void smViewer::initFboListItems() +void Viewer::initFboListItems() { for (size_t i = 0; i < this->fboListItems.size(); i++) { FboListItem *item = &fboListItems[i]; - item->fbo = new smFrameBuffer(); + item->fbo = new FrameBuffer(); item->fbo->setDim(item->width, item->height); if (item->colorTex) { @@ -234,7 +234,7 @@ void smViewer::initFboListItems() } /// \brief Destroys all the FBOs in the FBO list -void smViewer::destroyFboListItems() +void Viewer::destroyFboListItems() { for (size_t i = 0; i < this->fboListItems.size(); i++) { @@ -247,16 +247,16 @@ void smViewer::destroyFboListItems() } /// \brief Processes viewerRenderDetail options -void smViewer::processViewerOptions() +void Viewer::processViewerOptions() { if (viewerRenderDetail & SIMMEDTK_VIEWERRENDER_FADEBACKGROUND) { - smGLUtils::fadeBackgroundDraw(); + GLUtils::fadeBackgroundDraw(); } } ///\brief Render and then process window events until the event queue is empty. -void smViewer::processWindowEvents() +void Viewer::processWindowEvents() { sf::Event event; this->render(); @@ -265,7 +265,7 @@ void smViewer::processWindowEvents() } /// \brief Renders the render operation to an FBO -void smViewer::renderToFBO(const RenderOperation &p_rop) +void Viewer::renderToFBO(const RenderOperation &p_rop) { assert(p_rop.fbo); //Enable FBO for rendering @@ -276,13 +276,13 @@ void smViewer::renderToFBO(const RenderOperation &p_rop) processViewerOptions(); //Render Scene - smGLRenderer::renderScene(p_rop.scene); + GLRenderer::renderScene(p_rop.scene); //Disable FBO p_rop.fbo->disable(); } /// \brief Renders the render operation to screen -void smViewer::renderToScreen(const RenderOperation &p_rop) +void Viewer::renderToScreen(const RenderOperation &p_rop) { //Setup Viewport & Clear buffers glViewport(0, 0, this->width(), this->height()); @@ -290,7 +290,7 @@ void smViewer::renderToScreen(const RenderOperation &p_rop) processViewerOptions(); //Render Scene - smGLRenderer::renderScene(p_rop.scene); + GLRenderer::renderScene(p_rop.scene); //Render axis if (viewerRenderDetail & SIMMEDTK_VIEWERRENDER_GLOBAL_AXIS) @@ -309,7 +309,7 @@ void smViewer::renderToScreen(const RenderOperation &p_rop) p_rop.scene->enableLights(); p_rop.scene->placeLights(); - smGLRenderer::drawAxes(this->globalAxisLength); + GLRenderer::drawAxes(this->globalAxisLength); p_rop.scene->disableLights(); @@ -322,7 +322,7 @@ void smViewer::renderToScreen(const RenderOperation &p_rop) } /// \brief Registers a scene for rendering with the viewer -void smViewer::registerScene(std::shared_ptr<Scene> p_scene, +void Viewer::registerScene(std::shared_ptr<Scene> p_scene, smRenderTargetType p_target, const std::string &p_fboName) { @@ -344,7 +344,7 @@ void smViewer::registerScene(std::shared_ptr<Scene> p_scene, } /// \brief Set the color and other viewer defaults -void smViewer::setToDefaults() +void Viewer::setToDefaults() { glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, defaultDiffuseColor.toGLColor()); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, defaultSpecularColor.toGLColor()); @@ -353,7 +353,7 @@ void smViewer::setToDefaults() } /// \brief Called at the beginning of each frame by the module -void smViewer::beginFrame() +void Viewer::beginFrame() { if (terminateExecution == true) { @@ -364,12 +364,12 @@ void smViewer::beginFrame() } ///\brief Called at the end of each frame by the module -void smViewer::endFrame() +void Viewer::endFrame() { this->sfmlWindow->display(); //swaps buffers } -void smViewer::processSFMLEvents(const sf::Event& p_event) +void Viewer::processSFMLEvents(const sf::Event& p_event) { switch(p_event.type) { @@ -380,18 +380,18 @@ void smViewer::processSFMLEvents(const sf::Event& p_event) case sf::Event::KeyReleased: { auto keyboardEvent = - std::make_shared<mstk::Event::smKeyboardEvent>(mstk::Event::SFMLKeyToSmKey(p_event.key.code)); + std::make_shared<event::KeyboardEvent>(event::SFMLKeyToSmKey(p_event.key.code)); keyboardEvent->setPressed(sf::Event::KeyPressed == p_event.type); - keyboardEvent->setModifierKey(mstk::Event::smModKey::none); + keyboardEvent->setModifierKey(event::ModKey::none); if (p_event.key.shift) - keyboardEvent->setModifierKey(keyboardEvent->getModifierKey() | mstk::Event::smModKey::shift); + keyboardEvent->setModifierKey(keyboardEvent->getModifierKey() | event::ModKey::shift); if (p_event.key.control) - keyboardEvent->setModifierKey(keyboardEvent->getModifierKey() | mstk::Event::smModKey::control); + keyboardEvent->setModifierKey(keyboardEvent->getModifierKey() | event::ModKey::control); if (p_event.key.alt) - keyboardEvent->setModifierKey(keyboardEvent->getModifierKey() | mstk::Event::smModKey::alt); + keyboardEvent->setModifierKey(keyboardEvent->getModifierKey() | event::ModKey::alt); if (p_event.key.system) - keyboardEvent->setModifierKey(keyboardEvent->getModifierKey() | mstk::Event::smModKey::super); + keyboardEvent->setModifierKey(keyboardEvent->getModifierKey() | event::ModKey::super); eventHandler->triggerEvent(keyboardEvent); break; @@ -399,17 +399,17 @@ void smViewer::processSFMLEvents(const sf::Event& p_event) case sf::Event::MouseButtonPressed: case sf::Event::MouseButtonReleased: { - mstk::Event::smMouseButton mouseButton; + event::MouseButton mouseButton; if (sf::Mouse::Left == p_event.mouseButton.button) - mouseButton = mstk::Event::smMouseButton::Left; + mouseButton = event::MouseButton::Left; else if (sf::Mouse::Right == p_event.mouseButton.button) - mouseButton = mstk::Event::smMouseButton::Right; + mouseButton = event::MouseButton::Right; else if (sf::Mouse::Middle == p_event.mouseButton.button) - mouseButton = mstk::Event::smMouseButton::Middle; + mouseButton = event::MouseButton::Middle; else - mouseButton = mstk::Event::smMouseButton::Unknown; + mouseButton = event::MouseButton::Unknown; - auto mouseEvent = std::make_shared<mstk::Event::smMouseButtonEvent>(mouseButton); + auto mouseEvent = std::make_shared<event::MouseButtonEvent>(mouseButton); mouseEvent->setPresed(sf::Event::MouseButtonPressed == p_event.type); mouseEvent->setWindowCoord(core::Vec2d(p_event.mouseButton.x,p_event.mouseButton.y)); eventHandler->triggerEvent(mouseEvent); @@ -417,8 +417,8 @@ void smViewer::processSFMLEvents(const sf::Event& p_event) } case sf::Event::MouseMoved: { - auto mouseEvent = std::make_shared<mstk::Event::smMouseMoveEvent>(); - mouseEvent->setSender(mstk::Event::EventSender::Module); + auto mouseEvent = std::make_shared<event::MouseMoveEvent>(); + mouseEvent->setSender(core::EventSender::Module); mouseEvent->setWindowCoord(core::Vec2d(p_event.mouseMove.x, p_event.mouseMove.y)); eventHandler->triggerEvent(mouseEvent); break; @@ -428,41 +428,41 @@ void smViewer::processSFMLEvents(const sf::Event& p_event) } } -void smViewer::addObject(std::shared_ptr<CoreClass> object) +void Viewer::addObject(std::shared_ptr<CoreClass> object) { SDK::getInstance()->addRef(object); objectList.push_back(object); } -void smViewer::handleEvent(std::shared_ptr<mstk::Event::Event> p_event ) +void Viewer::handleEvent(std::shared_ptr<core::Event> /*p_event*/ ) { } -void smViewer::addText(std::string p_tag) +void Viewer::addText(std::string p_tag) { windowOutput->addText(p_tag, std::string("")); } -void smViewer::updateText(std::string p_tag, std::string p_string) +void Viewer::updateText(std::string p_tag, std::string p_string) { windowOutput->updateText(p_tag, p_string); } -void smViewer::updateText(int p_handle, std::string p_string) +void Viewer::updateText(int p_handle, std::string p_string) { windowOutput->updateText(p_handle, p_string); } -void smViewer::setWindowTitle(const std::string &str) +void Viewer::setWindowTitle(const std::string &str) { windowTitle = str; } -void smViewer::cleanUp() +void Viewer::cleanUp() { destroyFboListItems(); destroyRenderingContext(); @@ -473,6 +473,6 @@ void smViewer::cleanUp() SIMMEDTK_BEGIN_DYNAMIC_LOADER() SIMMEDTK_BEGIN_ONLOAD(register_rendering_viewer) - SIMMEDTK_REGISTER_CLASS(CoreClass,ViewerBase,smViewer,100); + SIMMEDTK_REGISTER_CLASS(CoreClass,ViewerBase,Viewer,100); SIMMEDTK_FINISH_ONLOAD() SIMMEDTK_FINISH_DYNAMIC_LOADER() diff --git a/src/Rendering/Viewer.h b/src/Rendering/Viewer.h index ce6f658546a18610197b69495d67d9e1e6c4c259..f14f7ea70f0effed941bd1e1690e780f4b8f6071 100644 --- a/src/Rendering/Viewer.h +++ b/src/Rendering/Viewer.h @@ -42,7 +42,7 @@ class smOpenGLWindowStream; /// \brief Handles all rendering routines. -class smViewer : public ViewerBase +class Viewer : public ViewerBase { public: std::unique_ptr<sf::Context> sfmlContext; @@ -51,7 +51,7 @@ public: std::shared_ptr<smOpenGLWindowStream> windowOutput; /// \brief default constructor - smViewer(); + Viewer(); /// \brief for exit viewer virtual void exitViewer() override; /// \brief add object for rendering @@ -62,7 +62,7 @@ public: virtual void updateText(std::string p_tag, std::string p_string) override; virtual void updateText(int p_handle, std::string p_string) override; /// \brief set scene as texture - void setSceneAsTextureShader(std::shared_ptr<smSceneTextureShader> p_shader); + void setSceneAsTextureShader(std::shared_ptr<SceneTextureShader> p_shader); /// \brief set the window title void setWindowTitle(const std::string &str); /// \brief enable/disable VSync @@ -98,7 +98,7 @@ protected: virtual void endFrame() override; virtual void renderTextureOnView() override; /// \brief event handler - virtual void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; + virtual void handleEvent(std::shared_ptr<core::Event> p_event) override; /// \brief processes an SFML event void processSFMLEvents(const sf::Event& p_event); }; diff --git a/src/Simulators/DummySimulator.cpp b/src/Simulators/DummySimulator.cpp index b58accf41c5a71285c043ffb68a54538ee47f33c..2de4cefee16a5f47c78c0dc65078a1de84eaba0c 100644 --- a/src/Simulators/DummySimulator.cpp +++ b/src/Simulators/DummySimulator.cpp @@ -52,7 +52,7 @@ void smDummySimulator::initCustom() { break; } - std::shared_ptr<smMesh> mesh = model->getMesh(); + std::shared_ptr<Mesh> mesh = model->getMesh(); object->getLocalVertices().reserve( mesh->nbrVertices ); // WARNING: Copy!!? @@ -83,7 +83,7 @@ void smDummySimulator::run() { break; } - std::shared_ptr<smMesh> mesh = model->getMesh(); + std::shared_ptr<Mesh> mesh = model->getMesh(); for ( int vertIndex = 0; vertIndex < mesh->nbrVertices; vertIndex++ ) { @@ -113,25 +113,25 @@ void smDummySimulator::syncBuffers() { break; } - std::shared_ptr<smMesh> mesh = model->getMesh(); + std::shared_ptr<Mesh> mesh = model->getMesh(); // WARNING: Copy??! mesh->vertices = staticSceneObject->getLocalVertices(); } } } -void smDummySimulator::handleEvent(std::shared_ptr<mstk::Event::Event> p_event ) +void smDummySimulator::handleEvent(std::shared_ptr<core::Event> p_event ) { if(!this->isListening()) { return; } - auto keyboardEvent = std::static_pointer_cast<mstk::Event::smKeyboardEvent>(p_event); + auto keyboardEvent = std::static_pointer_cast<event::KeyboardEvent>(p_event); if(keyboardEvent) { switch(keyboardEvent->getKeyPressed()) { - case mstk::Event::smKey::F1: + case event::Key::F1: { std::cout << "F1 Keyboard is pressed " ;//<< keyboardEvent->getKeyPressed() << std::endl; break; diff --git a/src/Simulators/DummySimulator.h b/src/Simulators/DummySimulator.h index 33af10a336494204ec96b9eb3f43587760a16ee9..0b9364bc579fc67602a34d08c3aaf0441b10750e 100644 --- a/src/Simulators/DummySimulator.h +++ b/src/Simulators/DummySimulator.h @@ -54,7 +54,7 @@ protected: void syncBuffers() override; /// \brief catch events such as key presses and other user inputs - void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; + void handleEvent(std::shared_ptr<core::Event> p_event) override; }; #endif diff --git a/src/Simulators/MyStylus.cpp b/src/Simulators/MyStylus.cpp index d6f9f228a5e6482c38b1066b068681da47112b95..119439f78040549209517018afd658323a0a407a 100644 --- a/src/Simulators/MyStylus.cpp +++ b/src/Simulators/MyStylus.cpp @@ -37,20 +37,20 @@ MyStylus::MyStylus(const std::string& p_shaft, const std::string& p_lower, const angle = 0; Matrix33d rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitX()).matrix(); - smSurfaceMesh *mesh = new smSurfaceMesh(SMMESH_RIGID, NULL); - mesh->loadMesh(p_shaft, SM_FILETYPE_3DS); + SurfaceMesh *mesh = new SurfaceMesh(BaseMesh::MeshType::Rigid, NULL); + mesh->loadMesh(p_shaft, BaseMesh::MeshFileType::ThreeDS); mesh->assignTexture("hookCautery"); mesh->scale(core::Vec3d(0.2, 0.2, 0.2)); mesh->rotate(rot); - smSurfaceMesh *lowerMesh = new smSurfaceMesh(SMMESH_RIGID, NULL); - lowerMesh->loadMesh(p_lower, SM_FILETYPE_3DS); + SurfaceMesh *lowerMesh = new SurfaceMesh(BaseMesh::MeshType::Rigid, NULL); + lowerMesh->loadMesh(p_lower, BaseMesh::MeshFileType::ThreeDS); lowerMesh->assignTexture("metal"); lowerMesh->scale(core::Vec3d(0.2, 0.2, 0.2)); lowerMesh->rotate(rot); - smSurfaceMesh *upperMesh = new smSurfaceMesh(SMMESH_RIGID, NULL); - upperMesh->loadMesh(p_upper, SM_FILETYPE_3DS); + SurfaceMesh *upperMesh = new SurfaceMesh(BaseMesh::MeshType::Rigid, NULL); + upperMesh->loadMesh(p_upper, BaseMesh::MeshFileType::ThreeDS); upperMesh->assignTexture("metal"); upperMesh->scale(core::Vec3d(0.2, 0.2, 0.2)); upperMesh->rotate(rot); @@ -105,14 +105,14 @@ void MyStylus::updateOpenClose() } //This function is not fixed for a reason....I'll give you a hint...try to match the brackets -void MyStylus::handleEvent (std::shared_ptr<mstk::Event::Event> p_event) +void MyStylus::handleEvent (std::shared_ptr<core::Event> p_event) { if(!this->isListening()) { return; } - auto hapticEvent = std::static_pointer_cast<mstk::Event::smHapticEvent>(p_event); + auto hapticEvent = std::static_pointer_cast<event::HapticEvent>(p_event); if(hapticEvent != nullptr && hapticEvent->getDeviceId() == this->phantomID) { smMeshContainer *containerLower = this->getMeshContainer ( "HookCauteryLower" ); @@ -157,21 +157,21 @@ void MyStylus::handleEvent (std::shared_ptr<mstk::Event::Event> p_event) return; } - auto keyboardEvent = std::static_pointer_cast<mstk::Event::smKeyboardEvent>(p_event); + auto keyboardEvent = std::static_pointer_cast<event::KeyboardEvent>(p_event); if(keyboardEvent) { switch(keyboardEvent->getKeyPressed()) { - case mstk::Event::smKey::Num1: + case event::Key::Num1: { - this->eventHandler->detachEvent(mstk::Event::EventType::Haptic,shared_from_this()); + this->eventHandler->detachEvent(core::EventType::Haptic,shared_from_this()); this->getRenderDetail()->renderType = this->getRenderDetail()->renderType & ( ~SIMMEDTK_RENDER_NONE ); break; } - case mstk::Event::smKey::Num2: + case event::Key::Num2: { - this->eventHandler->attachEvent(mstk::Event::EventType::Haptic,shared_from_this()); + this->eventHandler->attachEvent(core::EventType::Haptic,shared_from_this()); this->getRenderDetail()->renderType = this->getRenderDetail()->renderType | SIMMEDTK_RENDER_NONE; break; } @@ -185,8 +185,8 @@ HookCautery::HookCautery(const std::string& p_pivot) { Matrix33d rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitX()).matrix(); - smSurfaceMesh *mesh = new smSurfaceMesh(SMMESH_RIGID, NULL); - mesh->loadMesh(p_pivot, SM_FILETYPE_3DS); + SurfaceMesh *mesh = new SurfaceMesh(BaseMesh::MeshType::Rigid, NULL); + mesh->loadMesh(p_pivot, BaseMesh::MeshFileType::ThreeDS); mesh->assignTexture("metal"); mesh->scale(core::Vec3d(0.2, 0.2, 0.2)); mesh->rotate(rot); @@ -198,14 +198,14 @@ HookCautery::HookCautery(const std::string& p_pivot) addMeshContainer(&meshContainer); } -void HookCautery::handleEvent(std::shared_ptr<mstk::Event::Event> p_event) +void HookCautery::handleEvent(std::shared_ptr<core::Event> p_event) { if(!this->isListening()) { return; } - auto hapticEvent = std::static_pointer_cast<mstk::Event::smHapticEvent>(p_event); + auto hapticEvent = std::static_pointer_cast<event::HapticEvent>(p_event); if(hapticEvent != nullptr && hapticEvent->getDeviceId() == this->phantomID) { transRot = hapticEvent->getTransform(); @@ -222,21 +222,21 @@ void HookCautery::handleEvent(std::shared_ptr<mstk::Event::Event> p_event) return; } - auto keyboardEvent = std::static_pointer_cast<mstk::Event::smKeyboardEvent>(p_event); + auto keyboardEvent = std::static_pointer_cast<event::KeyboardEvent>(p_event); if(keyboardEvent) { switch(keyboardEvent->getKeyPressed()) { - case mstk::Event::smKey::Num1: + case event::Key::Num1: { - this->eventHandler->detachEvent(mstk::Event::EventType::Haptic,shared_from_this()); + this->eventHandler->detachEvent(core::EventType::Haptic,shared_from_this()); this->getRenderDetail()->renderType = this->getRenderDetail()->renderType & ( ~SIMMEDTK_RENDER_NONE ); break; } - case mstk::Event::smKey::Num2: + case event::Key::Num2: { - this->eventHandler->attachEvent(mstk::Event::EventType::Haptic,shared_from_this()); + this->eventHandler->attachEvent(core::EventType::Haptic,shared_from_this()); this->getRenderDetail()->renderType = this->getRenderDetail()->renderType | SIMMEDTK_RENDER_NONE; break; } diff --git a/src/Simulators/MyStylus.h b/src/Simulators/MyStylus.h index d86584406757751e2be7245450a70b6dd64989da..8483f04cd4e2f2b8ccb5d890bc277c3440586cf1 100644 --- a/src/Simulators/MyStylus.h +++ b/src/Simulators/MyStylus.h @@ -44,7 +44,7 @@ public: smMeshContainer meshContainer, meshContainerLower, meshContainerUpper; ///< !! /// \brief handle keyboard and omni button presses - void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; + void handleEvent(std::shared_ptr<core::Event> p_event) override; /// \brief constructor MyStylus(const std::string& p_shaft = "../../resources/models/blunt_diss_pivot.3DS", @@ -65,7 +65,7 @@ public: smMeshContainer meshContainer; ///< !! /// \brief handle keyboard and omni button presses - void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; + void handleEvent(std::shared_ptr<core::Event> p_event) override; /// \brief constructor HookCautery(const std::string& p_pivot = "../../resources/models/hook_cautery_new.3DS"); diff --git a/src/Simulators/PBDObjectSimulator.cpp b/src/Simulators/PBDObjectSimulator.cpp index a69f31bc7ba47200ded85cab664a88bb9c45d1aa..339b0502507c636caa4a5eba56014233dd409845 100644 --- a/src/Simulators/PBDObjectSimulator.cpp +++ b/src/Simulators/PBDObjectSimulator.cpp @@ -33,7 +33,7 @@ void smPBDObjectSimulator::draw() for (size_t i = 0; i < objectsSimulated.size(); i++) { sceneObject = std::static_pointer_cast<smPBDSurfaceSceneObject>(objectsSimulated[i]); - smGLRenderer::draw(sceneObject->mesh->aabb); + GLRenderer::draw(sceneObject->mesh->aabb); } } smPBDObjectSimulator::smPBDObjectSimulator( std::shared_ptr<ErrorLog> p_errorLog ) : ObjectSimulator( p_errorLog ) @@ -202,7 +202,7 @@ void smPBDObjectSimulator::syncBuffers() } } } -void smPBDObjectSimulator::handleEvent(std::shared_ptr<mstk::Event::Event> p_event ) +void smPBDObjectSimulator::handleEvent(std::shared_ptr<core::Event> p_event ) { ; @@ -213,7 +213,7 @@ void smPBDObjectSimulator::handleEvent(std::shared_ptr<mstk::Event::Event> p_eve auto keyBoardData = std::static_pointer_cast<smKeyboardEventData>(p_event->getEventData()); - if ( keyBoardData->keyBoardKey == smKey::F1 ) + if ( keyBoardData->keyBoardKey == Key::F1 ) { printf( "F1 Keyboard is pressed %c\n", keyBoardData->keyBoardKey ); } diff --git a/src/Simulators/PBDObjectSimulator.h b/src/Simulators/PBDObjectSimulator.h index d5b35390c4cf9de6408c9ee914dc709a62dc7a2f..5704076585343d8413a03cb72efbe9fb73cb94ea 100644 --- a/src/Simulators/PBDObjectSimulator.h +++ b/src/Simulators/PBDObjectSimulator.h @@ -53,7 +53,7 @@ protected: void syncBuffers() override; /// \brief handle key presses and other user events - void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; + void handleEvent(std::shared_ptr<core::Event> p_event) override; /// \brief render the PBD objects void draw() override; diff --git a/src/Simulators/PBDSceneObject.cpp b/src/Simulators/PBDSceneObject.cpp index b9f693608185f7952396513e00e68c549ee3ba49..53111713843db66136154f0d2ad31b96bd48d2ee 100644 --- a/src/Simulators/PBDSceneObject.cpp +++ b/src/Simulators/PBDSceneObject.cpp @@ -61,7 +61,7 @@ void smPBDSceneObject::unSerialize( void */*p_memoryBlock*/ ) smPBDSurfaceSceneObject::smPBDSurfaceSceneObject( std::shared_ptr<ErrorLog> p_log ) { type = core::ClassType::PbdSurfaceSceneObject; - mesh = new smSurfaceMesh( SMMESH_DEFORMABLE, p_log ); + mesh = new SurfaceMesh( BaseMesh::MeshType::Deformable, p_log ); } std::shared_ptr<SceneObject> smPBDSurfaceSceneObject::clone() { diff --git a/src/Simulators/PBDSceneObject.h b/src/Simulators/PBDSceneObject.h index 0340364d988d8eb6e9f5f54de4bd53efbbe114b0..c992ab225d6c085cfa43c55179f2adf4c73ec193 100644 --- a/src/Simulators/PBDSceneObject.h +++ b/src/Simulators/PBDSceneObject.h @@ -107,7 +107,7 @@ public: public: friend class smPBDSurfaceRenderDetail; - smSurfaceMesh *mesh; ///< surface mesh + SurfaceMesh *mesh; ///< surface mesh int nbrTri; ///< number of surface triangles int **triVertIdx; ///< !! int **sprInTris; ///< triangles that include a spring diff --git a/src/Simulators/SceneObjectDeformable.cpp b/src/Simulators/SceneObjectDeformable.cpp index 80a7fb76396343ee0f0b1b850cb248d9103c51ff..370b933223df259dacad5dad06dbfe96ced121f0 100644 --- a/src/Simulators/SceneObjectDeformable.cpp +++ b/src/Simulators/SceneObjectDeformable.cpp @@ -45,7 +45,7 @@ void smSceneObjectDeformable::applyContactForces() { if (f_contact.size() != 0) { - for (int i = 0; i < f_contact.size(); i++) + for (size_t i = 0; i < f_contact.size(); i++) { f_ext[i] += f_contact[i]; } @@ -138,12 +138,12 @@ void smSceneObjectDeformable::setRenderPrimaryMesh() renderSecondaryMesh = false; } -std::shared_ptr<smSurfaceMesh> smSceneObjectDeformable::getPrimarySurfaceMesh() const +std::shared_ptr<SurfaceMesh> smSceneObjectDeformable::getPrimarySurfaceMesh() const { return primarySurfaceMesh; } -std::shared_ptr<smSurfaceMesh> smSceneObjectDeformable::getSecondarySurfaceMesh() const +std::shared_ptr<SurfaceMesh> smSceneObjectDeformable::getSecondarySurfaceMesh() const { return secondarySurfaceMesh; } diff --git a/src/Simulators/SceneObjectDeformable.h b/src/Simulators/SceneObjectDeformable.h index b0da0a341ff544545e648d8903b157eb308c7b43..25436a0dc09d3c53c47204482ab7c36b60df46e7 100644 --- a/src/Simulators/SceneObjectDeformable.h +++ b/src/Simulators/SceneObjectDeformable.h @@ -117,10 +117,10 @@ public: void setRenderPrimaryMesh(); /// \brief get the primary surface mesh - std::shared_ptr<smSurfaceMesh> getPrimarySurfaceMesh() const; + std::shared_ptr<SurfaceMesh> getPrimarySurfaceMesh() const; /// \brief get the secondary surface mesh - std::shared_ptr<smSurfaceMesh> getSecondarySurfaceMesh() const; + std::shared_ptr<SurfaceMesh> getSecondarySurfaceMesh() const; // Get generalized velocity vector std::vector<double> &getVelocities() @@ -156,19 +156,19 @@ public: } protected: - friend class smSceneObjectDeformableRenderDelegate; + friend class SceneObjectDeformableRenderDelegate; int numNodes; int numFixedNodes; int numTotalDOF; int numDOF; int numFixedDof; - int timestepCounter; - int subTimestepCounter; - int pulledVertex; ///< vertex that is pulled by user using external force - bool topologyAltered; bool renderSecondaryMesh; + bool topologyAltered; + int pulledVertex; ///< vertex that is pulled by user using external force + size_t timestepCounter; + int subTimestepCounter; std::string ConfigFileName; @@ -186,9 +186,9 @@ protected: std::vector<int> fixedVertices; ///< fixed vertcies - std::shared_ptr<smVolumeMesh> volumeMesh; - std::shared_ptr<smSurfaceMesh> primarySurfaceMesh; - std::shared_ptr<smSurfaceMesh> secondarySurfaceMesh; + std::shared_ptr<VolumeMesh> volumeMesh; + std::shared_ptr<SurfaceMesh> primarySurfaceMesh; + std::shared_ptr<SurfaceMesh> secondarySurfaceMesh; }; #endif // SMVEGAFEMSCENEOBJECT_DEFORMABLE_H diff --git a/src/Simulators/StylusObject.cpp b/src/Simulators/StylusObject.cpp index 94c13ee9e7e14ee3f7311061fc2c31d93dad7db2..c667b4761d288e308900a0dac8440090b8fb6578 100644 --- a/src/Simulators/StylusObject.cpp +++ b/src/Simulators/StylusObject.cpp @@ -89,7 +89,7 @@ smMeshContainer::smMeshContainer( std::string p_name ) colModel = NULL; } -smMeshContainer::smMeshContainer( std::string p_name, smMesh */*p_mesh*/, core::Vec3d p_prePos, core::Vec3d p_posPos, float p_offsetRotX, float p_offsetRotY, float p_offsetRotZ ) +smMeshContainer::smMeshContainer( std::string p_name, Mesh */*p_mesh*/, core::Vec3d p_prePos, core::Vec3d p_posPos, float p_offsetRotX, float p_offsetRotY, float p_offsetRotZ ) { offsetRotX = p_offsetRotX; offsetRotY = p_offsetRotY; @@ -128,7 +128,7 @@ void smStylusSceneObject::unSerialize( void */*p_memoryBlock*/ ) { } -void smStylusSceneObject::handleEvent(std::shared_ptr<mstk::Event::Event>/*p_event*/ ) {} +void smStylusSceneObject::handleEvent(std::shared_ptr<core::Event>/*p_event*/ ) {} void smStylusRigidSceneObject::posTraverseCallBack() { } @@ -179,7 +179,7 @@ tree< smMeshContainer * >::iterator smStylusRigidSceneObject::addMeshContainer( return meshes.insert( p_iterator, p_meshContainer ); } -void smStylusRigidSceneObject::handleEvent(std::shared_ptr<mstk::Event::Event>/*p_event*/ ) {} +void smStylusRigidSceneObject::handleEvent(std::shared_ptr<core::Event>/*p_event*/ ) {} std::shared_ptr<SceneObject> smStylusRigidSceneObject::clone() { diff --git a/src/Simulators/StylusObject.h b/src/Simulators/StylusObject.h index 01eaf6da22cdb09f404dcad59a6f6fe6d323a9db..12ddfd1a4f812242205da9e8ae391ac2a6bc5d93 100644 --- a/src/Simulators/StylusObject.h +++ b/src/Simulators/StylusObject.h @@ -36,12 +36,9 @@ #include "Core/SceneObject.h" #include "External/tree.hh" -namespace mstk { - namespace Event { - class Event; - class smEventHandler; - class smCameraEvent; - } +namespace core { + class Event; + class EventHandler; } template<typename SurfaceTreeCell> class SurfaceTree; @@ -58,7 +55,7 @@ public: smMeshContainer(std::string p_name = ""); /// \brief constructor - smMeshContainer(std::string p_name, smMesh *p_mesh, core::Vec3d p_prePos, core::Vec3d p_posPos, float p_offsetRotX, float p_offsetRotY, float p_offsetRotZ); + smMeshContainer(std::string p_name, Mesh *p_mesh, core::Vec3d p_prePos, core::Vec3d p_posPos, float p_offsetRotX, float p_offsetRotY, float p_offsetRotZ); void computeCurrentMatrix(); @@ -77,7 +74,7 @@ public: Matrix44d currentDeviceMatrix; // !! Matrix44d tempCurrentMatrix; // !! Matrix44d tempCurrentDeviceMatrix; // !! - smMesh * mesh; // mesh + Mesh * mesh; // mesh std::shared_ptr<SurfaceTreeType> colModel; // octree of surface }; @@ -105,7 +102,7 @@ public: virtual void unSerialize(void *p_memoryBlock) override; /// \brief handle the events such as button presses related to stylus - void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; + void handleEvent(std::shared_ptr<core::Event> p_event) override; public: core::Vec3d pos; // position of stylus @@ -116,7 +113,7 @@ public: bool toolEnabled; // !! protected: - std::shared_ptr<mstk::Event::smEventHandler> eventHandler; + std::shared_ptr<core::EventHandler> eventHandler; }; /// \brief !! @@ -156,7 +153,7 @@ public: /// \brief !! smMeshContainer *getMeshContainer(std::string p_string) const; - virtual void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; + virtual void handleEvent(std::shared_ptr<core::Event> p_event) override; /// \brief !! std::shared_ptr<SceneObject> clone() override; @@ -166,7 +163,7 @@ public: void loadInitialStates() override{}; - bool configure(const std::string ConfigFile) + bool configure(const std::string /*ConfigFile*/) { return false; } @@ -198,7 +195,7 @@ public: void loadInitialStates() {}; - bool configure(std::string ConfigFile) + bool configure(std::string /*ConfigFile*/) { return false; } @@ -208,14 +205,14 @@ public: std::shared_ptr<smStylusDeformableSceneObject> newSO = std::make_shared<smStylusDeformableSceneObject>(); - return (std::shared_ptr<void>)newSO; + return std::static_pointer_cast<void>(newSO); } std::shared_ptr<void> duplicateAtInitialization() { std::shared_ptr<smStylusDeformableSceneObject> newSO = std::make_shared<smStylusDeformableSceneObject>(); - return (std::shared_ptr<void>)newSO; + return std::static_pointer_cast<void>(newSO); } std::shared_ptr<SceneObject> clone() override { diff --git a/src/Simulators/ToolSimulator.cpp b/src/Simulators/ToolSimulator.cpp index 4fd1fa75cdc87745507e9b9ad4791e4405e9919a..9ecf83050b07f06414f95690c6b0b32259969c83 100644 --- a/src/Simulators/ToolSimulator.cpp +++ b/src/Simulators/ToolSimulator.cpp @@ -118,19 +118,19 @@ void smToolSimulator::syncBuffers() { } -void smToolSimulator::handleEvent(std::shared_ptr<mstk::Event::Event> p_event ) +void smToolSimulator::handleEvent(std::shared_ptr<core::Event> p_event ) { if(!this->isListening()) { return; } - auto keyboardEvent = std::static_pointer_cast<mstk::Event::smKeyboardEvent>(p_event); + auto keyboardEvent = std::static_pointer_cast<event::KeyboardEvent>(p_event); if(keyboardEvent) { switch(keyboardEvent->getKeyPressed()) { - case mstk::Event::smKey::F1: + case event::Key::F1: { std::cout << "F1 Keyboard is pressed " ;//<< keyboardEvent->getKeyPressed() << std::endl; } diff --git a/src/Simulators/ToolSimulator.h b/src/Simulators/ToolSimulator.h index be8279e3a8c33e3488f8d6388842c38bc56d3be5..b91ae4bd0b8a6ef6e242210432c1b3c31ab1f1da 100644 --- a/src/Simulators/ToolSimulator.h +++ b/src/Simulators/ToolSimulator.h @@ -52,7 +52,7 @@ public: void syncBuffers() override; /// \brief handle the events such as button presses related to tool - void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; + void handleEvent(std::shared_ptr<core::Event> p_event) override; }; #endif diff --git a/src/Simulators/VegaFemSceneObject.cpp b/src/Simulators/VegaFemSceneObject.cpp index 6f421233701903bc81f6a2fee9a41890c753bd53..8a9ac6fc6d60c1d85638e7b561ff25f6f418d185 100644 --- a/src/Simulators/VegaFemSceneObject.cpp +++ b/src/Simulators/VegaFemSceneObject.cpp @@ -46,7 +46,7 @@ smVegaFemSceneObject::smVegaFemSceneObject() : "SceneObjectDeformableRenderDelegate")); } -smVegaFemSceneObject::smVegaFemSceneObject(const std::shared_ptr<ErrorLog> p_log, +smVegaFemSceneObject::smVegaFemSceneObject(const std::shared_ptr<ErrorLog> /*p_log*/, const std::string ConfigFile): staticSolver(0), graphicFrame(0), @@ -137,11 +137,11 @@ void smVegaFemSceneObject::initialize() if (importAndUpdateVolumeMeshToSmtk) { - this->volumeMesh = std::make_shared<smVolumeMesh>(); + this->volumeMesh = std::make_shared<VolumeMesh>(); this->volumeMesh->importVolumeMeshFromVegaFormat(this->volumetricMesh, true); } - this->primarySurfaceMesh = std::make_shared<smSurfaceMesh>(); + this->primarySurfaceMesh = std::make_shared<SurfaceMesh>(); this->primarySurfaceMesh->importSurfaceMeshFromVegaFormat( this->vegaPrimarySurfaceMesh->GetMesh(), true); @@ -150,7 +150,7 @@ void smVegaFemSceneObject::initialize() femConfig->secondaryRenderingMeshFilename[0] && (strcmp(femConfig->secondaryRenderingMeshFilename, "__none") != 0)) { - this->secondarySurfaceMesh = std::make_shared<smSurfaceMesh>(); + this->secondarySurfaceMesh = std::make_shared<SurfaceMesh>(); this->secondarySurfaceMesh->importSurfaceMeshFromVegaFormat( this->vegaSecondarySurfaceMesh->GetMesh(), true); @@ -376,7 +376,7 @@ void smVegaFemSceneObject::loadSurfaceMesh() } } - vegaPrimarySurfaceMesh = std::make_shared<smVegaSceneObjectDeformable>(femConfig->renderingMeshFilename); + vegaPrimarySurfaceMesh = std::make_shared<VegaSceneObjectDeformable>(femConfig->renderingMeshFilename); if (!vegaPrimarySurfaceMesh->GetMesh()) return; // Go no further if given an invalid filename @@ -390,7 +390,7 @@ void smVegaFemSceneObject::loadSurfaceMesh() if (strcmp(femConfig->secondaryRenderingMeshFilename, "__none") != 0) { - vegaSecondarySurfaceMesh = std::make_shared<smVegaSceneObjectDeformable>( + vegaSecondarySurfaceMesh = std::make_shared<VegaSceneObjectDeformable>( femConfig->secondaryRenderingMeshFilename); if (vegaSecondarySurfaceMesh == nullptr) diff --git a/src/Simulators/VegaFemSceneObject.h b/src/Simulators/VegaFemSceneObject.h index 1b01b90aec1f69dffd4db2061bdee6480ccc5d70..b6959c0468d3552b0a7da6f46ef40252a0cca94f 100644 --- a/src/Simulators/VegaFemSceneObject.h +++ b/src/Simulators/VegaFemSceneObject.h @@ -177,10 +177,10 @@ public: /// \brief serialize function explicity writes the object to the memory block ///each scene object should know how to write itself to a memory block - virtual void serialize(void *p_memoryBlock) override {}; + virtual void serialize(void */*p_memoryBlock*/) override {}; /// \brief Unserialize function can recover the object from the memory location - virtual void unSerialize(void *p_memoryBlock) override {}; + virtual void unSerialize(void */*p_memoryBlock*/) override {}; /// \brief this function may not be used ///every Scene Object should know how to clone itself. @@ -233,8 +233,8 @@ private: std::shared_ptr<LinearSolver> linearSolver; // Vega surface meshes - std::shared_ptr<smVegaSceneObjectDeformable> vegaPrimarySurfaceMesh; - std::shared_ptr<smVegaSceneObjectDeformable> vegaSecondarySurfaceMesh; + std::shared_ptr<VegaSceneObjectDeformable> vegaPrimarySurfaceMesh; + std::shared_ptr<VegaSceneObjectDeformable> vegaSecondarySurfaceMesh; }; #endif //SMVEGAFEMSCENEOBJECT_H diff --git a/src/Simulators/VegaFemSimulator.cpp b/src/Simulators/VegaFemSimulator.cpp index 59649067bff69a3ab8c92aebb8cc42444c1a8a37..bca354a2774b6b961edc9af7a9fca1c5355ebb83 100644 --- a/src/Simulators/VegaFemSimulator.cpp +++ b/src/Simulators/VegaFemSimulator.cpp @@ -80,14 +80,14 @@ void smVegaFemSimulator::syncBuffers() { } -void smVegaFemSimulator::handleEvent(std::shared_ptr<mstk::Event::Event> p_event ) +void smVegaFemSimulator::handleEvent(std::shared_ptr<core::Event> /*p_event*/ ) { if (!this->isListening()) { return; } - /*auto hapticEvent = std::static_pointer_cast<mstk::Event::smHapticEvent>(p_event); + /*auto hapticEvent = std::static_pointer_cast<event::HapticEvent>(p_event); if (hapticEvent != nullptr && hapticEvent->getDeviceId() == 1) { hapticPosition = hapticEvent->getPosition(); diff --git a/src/Simulators/VegaFemSimulator.h b/src/Simulators/VegaFemSimulator.h index 96513fd5873b046e173a365ed9424edcbde7e542..bd4c7863d3241eca8746b8a682c2aec547b9ae4e 100644 --- a/src/Simulators/VegaFemSimulator.h +++ b/src/Simulators/VegaFemSimulator.h @@ -54,7 +54,7 @@ public: void syncBuffers() override; /// \brief handle the keyboard and haptic button press events - void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; + void handleEvent(std::shared_ptr<core::Event> p_event) override; private: core::Vec3d hapticPosition; ///< position of the haptic device end effector diff --git a/src/Tools/curvedGrasper.cpp b/src/Tools/curvedGrasper.cpp index 50b8b031022b60b70b29eeb723495c1dd26b1c3b..1466164592578b0561b10d02997ddf060cb90492 100644 --- a/src/Tools/curvedGrasper.cpp +++ b/src/Tools/curvedGrasper.cpp @@ -42,24 +42,24 @@ curvedGrasper::curvedGrasper(size_t p_PhantomID, this->phantomID = p_PhantomID; Matrix33d rot; - mesh_pivot = new smSurfaceMesh(SMMESH_RIGID, NULL); - mesh_pivot->loadMesh(p_pivotModelFileName, SM_FILETYPE_3DS); + mesh_pivot = new SurfaceMesh(BaseMesh::MeshType::Rigid, NULL); + mesh_pivot->loadMesh(p_pivotModelFileName, BaseMesh::MeshFileType::ThreeDS); mesh_pivot->scale(core::Vec3d(0.5, 0.5, 0.5)); rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitX()).matrix(); mesh_pivot->rotate(rot); rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitZ()).matrix(); mesh_pivot->rotate(rot); - mesh_upperJaw = new smSurfaceMesh(SMMESH_RIGID, NULL); - mesh_upperJaw->loadMesh(p_upperModelFileName, SM_FILETYPE_3DS); + mesh_upperJaw = new SurfaceMesh(BaseMesh::MeshType::Rigid, NULL); + mesh_upperJaw->loadMesh(p_upperModelFileName, BaseMesh::MeshFileType::ThreeDS); mesh_upperJaw->scale(core::Vec3d(0.5, 0.5, 0.5)); rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitY()).matrix(); mesh_upperJaw->rotate(rot); rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitZ()).matrix(); mesh_upperJaw->rotate(rot); - mesh_lowerJaw = new smSurfaceMesh(SMMESH_RIGID, NULL); - mesh_lowerJaw->loadMesh(p_lowerModelFileName, SM_FILETYPE_3DS); + mesh_lowerJaw = new SurfaceMesh(BaseMesh::MeshType::Rigid, NULL); + mesh_lowerJaw->loadMesh(p_lowerModelFileName, BaseMesh::MeshFileType::ThreeDS); mesh_lowerJaw->scale(core::Vec3d(0.5, 0.5, 0.5)); rot = Eigen::AngleAxisd(-M_PI_2, core::Vec3d::UnitY()).matrix(); mesh_lowerJaw->rotate(rot); @@ -84,14 +84,14 @@ curvedGrasper::curvedGrasper(size_t p_PhantomID, DAQdataID = 0; } -void curvedGrasper::handleEvent(std::shared_ptr<mstk::Event::Event> p_event) +void curvedGrasper::handleEvent(std::shared_ptr<core::Event> p_event) { if(!this->isListening()) { return; } - auto hapticEvent = std::static_pointer_cast<mstk::Event::smHapticEvent>(p_event); + auto hapticEvent = std::static_pointer_cast<event::HapticEvent>(p_event); if(hapticEvent != nullptr && hapticEvent->getDeviceId() == this->phantomID) { smMeshContainer *containerLower = this->getMeshContainer("curvedGrasperLower"); @@ -128,22 +128,22 @@ void curvedGrasper::handleEvent(std::shared_ptr<mstk::Event::Event> p_event) return; } - auto keyboardEvent = std::static_pointer_cast<mstk::Event::smKeyboardEvent>(p_event); + auto keyboardEvent = std::static_pointer_cast<event::KeyboardEvent>(p_event); if(keyboardEvent) { switch(keyboardEvent->getKeyPressed()) { - case mstk::Event::smKey::Num1: + case event::Key::Num1: { - this->eventHandler->detachEvent(mstk::Event::EventType::Haptic,shared_from_this()); + this->eventHandler->detachEvent(core::EventType::Haptic,shared_from_this()); this->getRenderDetail()->renderType = this->getRenderDetail()->renderType & ( ~SIMMEDTK_RENDER_NONE ); break; } - case mstk::Event::smKey::Num2: + case event::Key::Num2: { - this->eventHandler->attachEvent(mstk::Event::EventType::Haptic,shared_from_this()); + this->eventHandler->attachEvent(core::EventType::Haptic,shared_from_this()); this->getRenderDetail()->renderType = this->getRenderDetail()->renderType | SIMMEDTK_RENDER_NONE; break; diff --git a/src/Tools/curvedGrasper.h b/src/Tools/curvedGrasper.h index 4c8553df7fac29633b69f43b8ff3c9e66c24c4fe..5672eacee3d7971d200100be55600ffb5ae5b21a 100644 --- a/src/Tools/curvedGrasper.h +++ b/src/Tools/curvedGrasper.h @@ -28,12 +28,8 @@ #include "Simulators/StylusObject.h" #include "Mesh/SurfaceMesh.h" -namespace mstk { -namespace Event { +namespace core { class Event; - class smEventHandler; - class smCameraEvent; -} } /// \brief Cruver Grasper tool @@ -47,7 +43,7 @@ public: const std::string& p_upperModelFileName = "../../resources/models/curved_lower.3DS"); /// \brief event handler - void handleEvent(std::shared_ptr<mstk::Event::Event> p_event) override; + void handleEvent(std::shared_ptr<core::Event> p_event) override; /// \brief for open and close motion void updateOpenClose(); @@ -60,9 +56,9 @@ public: smMeshContainer meshContainer_pivot; // the pivto mesh container smMeshContainer meshContainer_lowerJaw; // lower jaw container smMeshContainer meshContainer_upperJaw; // upper jaw container - smSurfaceMesh *mesh_pivot; // stores the pivot mesh - smSurfaceMesh *mesh_lowerJaw; // stores lower jaw mesh - smSurfaceMesh *mesh_upperJaw; // stores upper mesh jaw + SurfaceMesh *mesh_pivot; // stores the pivot mesh + SurfaceMesh *mesh_lowerJaw; // stores lower jaw mesh + SurfaceMesh *mesh_upperJaw; // stores upper mesh jaw #ifdef smNIUSB6008DAQ smPipeRegisteration NIUSB6008pipeReg; // #endif