Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reference target model config #354

Merged
merged 2 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/experimentConfigReadme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
Expand Down
13 changes: 13 additions & 0 deletions docs/general_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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? |
Expand All @@ -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
Expand Down
27 changes: 14 additions & 13 deletions source/FPSciApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions source/FpsConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions source/FpsConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
9 changes: 8 additions & 1 deletion source/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,14 @@ shared_ptr<FlyingEntity> 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<FlyingEntity>& 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<FlyingEntity>& target = FlyingEntity::create("reference", m_scene, (*m_targetModels)[refId][scaleIndex], CFrame());

// Setup additional target parameters
target->setFrame(position);
Expand Down