From be78dc63927f2fd6efa973dd0145bd09e0fec5ae Mon Sep 17 00:00:00 2001 From: Ben Boudaoud Date: Thu, 31 Mar 2022 12:10:29 -0400 Subject: [PATCH 1/2] Add and document reference target model config --- docs/general_config.md | 13 +++++++++++++ source/FPSciApp.cpp | 27 ++++++++++++++------------- source/FpsConfig.cpp | 1 + source/FpsConfig.h | 12 ++++++++++++ source/Session.cpp | 9 ++++++++- 5 files changed, 48 insertions(+), 14 deletions(-) diff --git a/docs/general_config.md b/docs/general_config.md index 77e8fd80..9023e1c1 100644 --- a/docs/general_config.md +++ b/docs/general_config.md @@ -494,6 +494,7 @@ These flags help control the behavior of click-to-photon monitoring in applicati |`showReferenceTarget` |`bool` | Show a reference target to re-center the view between trials/sessions? | |`referenceTargetColor` |`Color3` | The color of the "reference" targets spawned between trials | |`referenceTargetSize` |m | The size of the "reference" targets spawned between trials | +|`referenceTargetModelSpec`|`ArticulatedModel::Specification`| The model specification of the "reference" targets spawned between trials | |`clearMissDecalsWithReference`|`bool` | Clear miss decals when the reference target is destroyed | |`showPreviewTargetsWithReference` |`bool` | Show a preview of the trial targets (unhittable) with the reference target. Make these targets hittable once the reference is destroyed | |`showReferenceTargetMissDecals`|`bool` | Show miss decals when the weapon is firing at a reference target? | @@ -507,6 +508,18 @@ These flags help control the behavior of click-to-photon monitoring in applicati "showReferenceTarget": true, // Show a reference target between trials "referenceTargetColor": Color3(1.0,1.0,1.0), // Reference target color (return to "0" view direction) "referenceTargetSize": 0.01, // This is a size in meters +"referenceTargetModelSpec" : ArticulatedModel::Specification{ // Basic model spec for reference target + filename = "model/target/target.obj"; + cleanGeometrySettings = ArticulatedModel::CleanGeometrySettings{ + allowVertexMerging = true; + forceComputeNormals = false; + forceComputeTangents = false; + forceVertexMerging = true; + maxEdgeLength = inf; + maxNormalWeldAngleDegrees = 0; + maxSmoothAngleDegrees = 0; + }; +} "clearMissDecalsWithReference" : false, // Don't clear the miss decals when the reference target is eliminated "showPreviewTargetsWithReference" : false, // Don't show the preview targets with the reference "showReferenceTargetMissDecals" : true, // Show miss decals for reference targets diff --git a/source/FPSciApp.cpp b/source/FPSciApp.cpp index 0c0399f8..59ed2ce1 100644 --- a/source/FPSciApp.cpp +++ b/source/FPSciApp.cpp @@ -207,19 +207,20 @@ void FPSciApp::loadModels() { explosionsToBuild.set(target.id, target.destroyDecal); explosionScales.set(target.id, target.destroyDecalScale); } - // Append the basic model automatically (used for reference targets for now) - targetsToBuild.set("reference", PARSE_ANY(ArticulatedModel::Specification{ - filename = "model/target/target.obj"; - cleanGeometrySettings = ArticulatedModel::CleanGeometrySettings{ - allowVertexMerging = true; - forceComputeNormals = false; - forceComputeTangents = false; - forceVertexMerging = true; - maxEdgeLength = inf; - maxNormalWeldAngleDegrees = 0; - maxSmoothAngleDegrees = 0; - }; - })); + + // Append reference target model(s) + Any& defaultRefTarget = experimentConfig.targetView.refTargetModelSpec; + for (SessionConfig& sess : experimentConfig.sessions) { + if (sess.targetView.refTargetModelSpec != defaultRefTarget) { + // This is a custom reference target model + String id = sess.id + "_reference"; + targetsToBuild.set(id, sess.targetView.refTargetModelSpec); + explosionsToBuild.set(id, "explosion_01.png"); + explosionScales.set(id, 1.0); + } + } + // Add default reference + targetsToBuild.set("reference", defaultRefTarget); explosionsToBuild.set("reference", "explosion_01.png"); explosionScales.set("reference", 1.0); diff --git a/source/FpsConfig.cpp b/source/FpsConfig.cpp index 52f65764..bb515e96 100644 --- a/source/FpsConfig.cpp +++ b/source/FpsConfig.cpp @@ -452,6 +452,7 @@ void TargetViewConfig::load(FPSciAnyTableReader reader, int settingsVersion) { reader.getIfPresent("showReferenceTarget", showRefTarget); reader.getIfPresent("referenceTargetSize", refTargetSize); reader.getIfPresent("referenceTargetColor", refTargetColor); + reader.getIfPresent("referenceTargetModelSpec", refTargetModelSpec); reader.getIfPresent("clearMissDecalsWithReference", clearDecalsWithRef); reader.getIfPresent("showPreviewTargetsWithReference", previewWithRef); reader.getIfPresent("showReferenceTargetMissDecals", showRefDecals); diff --git a/source/FpsConfig.h b/source/FpsConfig.h index ede34943..c19d7885 100644 --- a/source/FpsConfig.h +++ b/source/FpsConfig.h @@ -222,6 +222,18 @@ class TargetViewConfig { bool showRefTarget = true; ///< Show the reference target? float refTargetSize = 0.05f; ///< Size of the reference target Color3 refTargetColor = Color3(1.0, 0.0, 0.0); ///< Default reference target color + Any refTargetModelSpec = PARSE_ANY(ArticulatedModel::Specification{ ///< Basic model spec for reference target + filename = "model/target/target.obj"; + cleanGeometrySettings = ArticulatedModel::CleanGeometrySettings{ + allowVertexMerging = true; + forceComputeNormals = false; + forceComputeTangents = false; + forceVertexMerging = true; + maxEdgeLength = inf; + maxNormalWeldAngleDegrees = 0; + maxSmoothAngleDegrees = 0; + }; + }); bool clearDecalsWithRef = false; ///< Clear the decals created from the reference target at the start of the task bool previewWithRef = false; ///< Show preview of per-trial targets with the reference? diff --git a/source/Session.cpp b/source/Session.cpp index 9b2dfa9a..09f9833e 100644 --- a/source/Session.cpp +++ b/source/Session.cpp @@ -829,7 +829,14 @@ shared_ptr Session::spawnReferenceTarget( const Color3& color) { const int scaleIndex = clamp(iRound(log(size) / log(1.0f + TARGET_MODEL_ARRAY_SCALING) + TARGET_MODEL_ARRAY_OFFSET), 0, TARGET_MODEL_SCALE_COUNT - 1); - const shared_ptr& target = FlyingEntity::create("reference", m_scene, (*m_targetModels)["reference"][scaleIndex], CFrame()); + + String refId = m_config->id + "_reference"; + if (isNull(m_targetModels->getPointer(refId))) { + // This session doesn't have a custom reference target + refId = "reference"; + } + + const shared_ptr& target = FlyingEntity::create("reference", m_scene, (*m_targetModels)[refId][scaleIndex], CFrame()); // Setup additional target parameters target->setFrame(position); From f64fc4b267cffbc8b0b177def09adb44af80e9d5 Mon Sep 17 00:00:00 2001 From: Josef Spjut Date: Mon, 11 Apr 2022 12:22:12 -0400 Subject: [PATCH 2/2] Added target modelSpec sample doc --- docs/experimentConfigReadme.md | 3 +++ docs/general_config.md | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/experimentConfigReadme.md b/docs/experimentConfigReadme.md index e6156665..d32138d5 100644 --- a/docs/experimentConfigReadme.md +++ b/docs/experimentConfigReadme.md @@ -162,6 +162,9 @@ targets = [ ... {"t": 10.2, "xyz": Vector3(10.1, 1.01, -100.3)} }, + modelSpec = ArticulatedModel::Specification{ + filename = "model/target/sphere.obj"; + }, }, #include("example_target.Any"), // Example of including an external .Any file ], diff --git a/docs/general_config.md b/docs/general_config.md index 9023e1c1..99f571ca 100644 --- a/docs/general_config.md +++ b/docs/general_config.md @@ -509,17 +509,17 @@ These flags help control the behavior of click-to-photon monitoring in applicati "referenceTargetColor": Color3(1.0,1.0,1.0), // Reference target color (return to "0" view direction) "referenceTargetSize": 0.01, // This is a size in meters "referenceTargetModelSpec" : ArticulatedModel::Specification{ // Basic model spec for reference target - filename = "model/target/target.obj"; - cleanGeometrySettings = ArticulatedModel::CleanGeometrySettings{ - allowVertexMerging = true; - forceComputeNormals = false; - forceComputeTangents = false; - forceVertexMerging = true; - maxEdgeLength = inf; - maxNormalWeldAngleDegrees = 0; - maxSmoothAngleDegrees = 0; + filename = "model/target/target.obj"; + cleanGeometrySettings = ArticulatedModel::CleanGeometrySettings{ + allowVertexMerging = true; + forceComputeNormals = false; + forceComputeTangents = false; + forceVertexMerging = true; + maxEdgeLength = inf; + maxNormalWeldAngleDegrees = 0; + maxSmoothAngleDegrees = 0; }; -} +}, "clearMissDecalsWithReference" : false, // Don't clear the miss decals when the reference target is eliminated "showPreviewTargetsWithReference" : false, // Don't show the preview targets with the reference "showReferenceTargetMissDecals" : true, // Show miss decals for reference targets