aboutsummaryrefslogtreecommitdiff
path: root/tools/ArtistTools/source/BlastPlugin/SampleBase/ui/EditionToolController.cpp
diff options
context:
space:
mode:
authorBryan Galdrikian <[email protected]>2017-02-24 09:32:20 -0800
committerBryan Galdrikian <[email protected]>2017-02-24 09:32:20 -0800
commite1bf674c16e3c8472b29574159c789cd3f0c64e0 (patch)
tree9f0cfce09c71a2c27ff19589fcad6cd83504477c /tools/ArtistTools/source/BlastPlugin/SampleBase/ui/EditionToolController.cpp
parentfirst commit (diff)
downloadblast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.tar.xz
blast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.zip
Updating to [email protected] and [email protected] with a new directory structure.
NvBlast folder is gone, files have been moved to top level directory. README is changed to reflect this.
Diffstat (limited to 'tools/ArtistTools/source/BlastPlugin/SampleBase/ui/EditionToolController.cpp')
-rw-r--r--tools/ArtistTools/source/BlastPlugin/SampleBase/ui/EditionToolController.cpp158
1 files changed, 158 insertions, 0 deletions
diff --git a/tools/ArtistTools/source/BlastPlugin/SampleBase/ui/EditionToolController.cpp b/tools/ArtistTools/source/BlastPlugin/SampleBase/ui/EditionToolController.cpp
new file mode 100644
index 0000000..244f121
--- /dev/null
+++ b/tools/ArtistTools/source/BlastPlugin/SampleBase/ui/EditionToolController.cpp
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#include "EditionToolController.h"
+#include "BlastController.h"
+#include "Renderer.h"
+#include "PhysXController.h"
+#include "SampleProfiler.h"
+#include "PxRigidDynamic.h"
+#include "PxScene.h"
+#include "NvBlastExtPxManager.h"
+#include "SceneController.h"
+#include "NvBlastExtPxActor.h"
+#include "GlobalSettings.h"
+using namespace Nv::Blast;
+using namespace physx;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Setup
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+EditionToolController::EditionToolController()
+{
+}
+
+EditionToolController::~EditionToolController()
+{
+}
+
+void EditionToolController::onSampleStart()
+{
+}
+
+void EditionToolController::onInitialize()
+{
+}
+
+
+void EditionToolController::onSampleStop()
+{
+}
+
+void EditionToolController::Animate(double dt)
+{
+ PROFILER_SCOPED_FUNCTION();
+}
+
+
+LRESULT EditionToolController::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ PROFILER_SCOPED_FUNCTION();
+
+ if (uMsg == WM_LBUTTONDOWN || uMsg == WM_MOUSEMOVE || uMsg == WM_LBUTTONUP)
+ {
+ float mouseX = (short)LOWORD(lParam) / getRenderer().getScreenWidth();
+ float mouseY = (short)HIWORD(lParam) / getRenderer().getScreenHeight();
+ bool press = uMsg == WM_LBUTTONDOWN;
+
+ if (uMsg == WM_LBUTTONUP)
+ {
+ PxVec3 eyePos, pickDir;
+ getPhysXController().getEyePoseAndPickDir(mouseX, mouseY, eyePos, pickDir);
+ pickDir = pickDir.getNormalized();
+
+ PxRaycastHit hit; hit.shape = NULL;
+ PxRaycastBuffer hit1;
+ getPhysXController().getPhysXScene().raycast(eyePos, pickDir, PX_MAX_F32, hit1, PxHitFlag::ePOSITION | PxHitFlag::eNORMAL);
+ hit = hit1.block;
+
+ PxRigidActor* actor = NULL;
+ if (hit.shape)
+ {
+ actor = hit.actor;
+ }
+ fracture(actor);
+ }
+ }
+
+ return 1;
+}
+
+void EditionToolController::drawUI()
+{
+}
+
+void EditionToolController::fracture(PxActor* actor)
+{
+ if (NULL == actor)
+ {
+ return;
+ }
+
+ BlastController& blastController = getBlastController();
+ std::vector<BlastFamilyPtr>& families = blastController.getFamilies();
+ if (families.size() == 0)
+ {
+ return;
+ }
+
+ ExtPxActor* extActor = NULL;
+ PxRigidDynamic* rigidDynamic = actor->is<PxRigidDynamic>();
+ if (NULL != rigidDynamic)
+ {
+ extActor = blastController.getExtPxManager().getActorFromPhysXActor(*rigidDynamic);
+ }
+ if (NULL == extActor)
+ {
+ return;
+ }
+
+ uint32_t chunkCount = extActor->getChunkCount();
+ if (chunkCount <= 0)
+ {
+ return;
+ }
+
+ BlastFamilyPtr pBlastFamily = NULL;
+ std::vector<BlastFamilyPtr>::iterator it = families.begin();
+ for (; it != families.end(); it++)
+ {
+ BlastFamilyPtr f = *it;
+ if (f->find(extActor))
+ {
+ pBlastFamily = f;
+ break;
+ }
+ }
+ if (NULL == pBlastFamily)
+ {
+ return;
+ }
+
+ const uint32_t* chunkIndices = extActor->getChunkIndices();
+
+ const BlastAsset& blastAsset = pBlastFamily->getBlastAsset();
+ const BlastAsset* pBlastAsset = &blastAsset;
+
+ SceneController& sceneController = getManager()->getSceneController();
+ AssetList::ModelAsset desc;
+ sceneController.GetAssetDesc(pBlastAsset, desc);
+
+ std::string assetname = desc.id;
+ GlobalSettings& globalSettings = GlobalSettings::Inst();
+ getManager()->fractureAsset(globalSettings.m_projectFileDir, assetname, pBlastAsset, chunkIndices[0]);
+ getManager()->addModelAsset(globalSettings.m_projectFileDir, assetname, desc.isSkinned, desc.transform, false);
+} \ No newline at end of file