From e1bf674c16e3c8472b29574159c789cd3f0c64e0 Mon Sep 17 00:00:00 2001 From: Bryan Galdrikian Date: Fri, 24 Feb 2017 09:32:20 -0800 Subject: Updating to blast_source-windows@1.0.347-21749006 and blast_tools_and_samples-windows@1.0.347-21749006 with a new directory structure. NvBlast folder is gone, files have been moved to top level directory. README is changed to reflect this. --- samples/SampleAssetViewer/Main.cpp | 132 +++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 samples/SampleAssetViewer/Main.cpp (limited to 'samples/SampleAssetViewer/Main.cpp') diff --git a/samples/SampleAssetViewer/Main.cpp b/samples/SampleAssetViewer/Main.cpp new file mode 100644 index 0000000..fca0339 --- /dev/null +++ b/samples/SampleAssetViewer/Main.cpp @@ -0,0 +1,132 @@ +/* +* 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 "Sample.h" +#include "tclap/CmdLine.h" +#include + +#include + + +#define DEFAULT_ASSET_LIST "assets.xml" + +struct TCLAPvec3 +{ + float x, y, z; + TCLAPvec3() :x(0), y(0), z(0){}; + TCLAPvec3& operator=(const std::string &inp) + { + std::istringstream stream(inp); + if (!(stream >> x >> y >> z)) + throw TCLAP::ArgParseException(inp + " is not vec3"); + return *this; + } +}; + +struct TCLAPvec4 +{ + float x, y, z, w; + TCLAPvec4() :x(0), y(0), z(0), w(0){}; + TCLAPvec4& operator=(const std::string &inp) + { + std::istringstream stream(inp); + if (!(stream >> x >> y >> z >> w)) + throw TCLAP::ArgParseException(inp + " is not vec4"); + return *this; + } +}; + +namespace TCLAP { + template<> + struct ArgTraits { + typedef StringLike ValueCategory; + }; + template<> + struct ArgTraits { + typedef StringLike ValueCategory; + }; +} + +using namespace std; +using namespace physx; + +int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) +{ + PX_UNUSED(hInstance); + PX_UNUSED(hPrevInstance); + PX_UNUSED(lpCmdLine); + PX_UNUSED(nCmdShow); + + // Enable run-time memory check for debug builds. +#if defined(DEBUG) | defined(_DEBUG) + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); + AllocConsole(); +#endif + + + LPWSTR* argv; + int argc; + argv = CommandLineToArgvW(GetCommandLineW(), &argc); + TCLAP::CmdLine cmd("Blast Sample: Asset Viewer", ' ', "0.1"); + TCLAP::ValueArg inpXmlArg("x", "xml", "Asset list to load", false, DEFAULT_ASSET_LIST, "inassetlist"); + cmd.add(inpXmlArg); + TCLAP::ValueArg alternatePathArg("t", "path", "Alternate path", false, "", "altPath"); + cmd.add(alternatePathArg); + + TCLAP::ValueArg addAssetArg("n", "nAsset", "Additional asset to load", false, "", "additionalAsset"); + cmd.add(addAssetArg); + + TCLAP::ValueArg rotationArg("r", "rot", "Additional asset rotation", false, TCLAPvec4(), "rotation"); + cmd.add(rotationArg); + TCLAP::ValueArg positionArg("p", "pos", "Additional asset position", false, TCLAPvec3(), "position"); + cmd.add(positionArg); + + + PxVec3 transform; + bool addedExternalAsset = false; + + std::vector argsVect; + if (argc > 1) + { + for (size_t i = 0; i < (size_t)argc; ++i) + { + argsVect.push_back(string()); + argsVect.back().resize(wcslen(argv[i]), 0); + wcstombs(&argsVect.back()[0], argv[i], 255); + } + cmd.parse(argsVect); + } + LocalFree(argv); + + SampleConfig config; + config.assetsFile = inpXmlArg.getValue(); + config.sampleName = L"Blast Sample: Asset Viewer"; + + config.assetsFile = inpXmlArg.getValue(); + if (alternatePathArg.isSet()) + { + config.additionalResourcesDir.push_back(alternatePathArg.getValue().c_str()); + } + if (addAssetArg.isSet()) + { + AssetList::ModelAsset asset; + TCLAPvec3 p = positionArg.getValue(); + TCLAPvec4 r = rotationArg.getValue(); + asset.transform.p = PxVec3(p.x, p.y, p.z); + asset.transform.q = PxQuat(r.w, PxVec3(r.x, r.y, r.z).getNormalized()); + asset.name = addAssetArg.getValue(); + asset.id = asset.name; + config.additionalAssetList.models.push_back(asset); + } + + int result = runSample(config); + + return result; +} -- cgit v1.2.3