organisation & splat changes

This commit is contained in:
2024-03-28 14:55:33 +00:00
parent d487af62b8
commit 0535f6df4c
347 changed files with 3579 additions and 1956 deletions

View File

@@ -0,0 +1,53 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(Muscles))]
public class MusclesEditor : Editor
{
[SerializeField]
SerializedProperty Muscles;
void OnEnable()
{
Muscles = serializedObject.FindProperty("Muscles");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
GUILayout.Label("");
base.OnInspectorGUI();
/*
if (GUILayout.Button("Recalculate Center of Masses"))
{
Muscles t = target as Muscles;
t.CenterABMasses();
}*/
serializedObject.ApplyModifiedProperties();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8f8a6234c58fa4a4abe62d80512988dd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,145 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
//This script assumes information was stored as SwingTwist
//This means the script goes together with ROMparserSwingTwist
//we assume the articulationBodies have a name structure of hte form ANYNAME:something-in-the-targeted-joint
[CustomEditor(typeof(ROMparserSwingTwist))]
public class ROMparserSwingTwistEditor : Editor
{
[SerializeField]
SerializedProperty ROMparserSwingTwist;
//NOT USED ANYMORE
//[SerializeField]
//string keyword4prefabs = "Constrained-procedurally";
//[SerializeField]
//RangeOfMotion004 theRagdollPrefab;
void OnEnable()
{
ROMparserSwingTwist = serializedObject.FindProperty("ROMparserSwingTwist");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
GUILayout.Label("");
base.OnInspectorGUI();
/*
if (GUILayout.Button("0.Debug: Set Joints To Max ROM"))
{
ROMparserSwingTwist t = target as ROMparserSwingTwist;
t.SetJointsToMaxROM();
}
if (GUILayout.Button("1.Store ROM info "))
{
ROMparserSwingTwist t = target as ROMparserSwingTwist;
EditorUtility.SetDirty(t.info2store);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
GUILayout.Label("Prefab Ragdoll:");
GUILayout.Label("How to use:");
GUILayout.TextArea(
"Step 1: execute in play mode until the values in the Range Of Motion Preview do not change any more" +
// " \n Step 2: click on button 1 to apply the constraints to check if the ragdoll looks reasonable" +
// " \n Step 3: in edit mode, click on button 1, and then on button 2, to generate a new constrained ragdoll. If a template for a SpawnableEnv is provided, also a new environment for training");
" \n Step 2: open the Ragdoll on which you want to apply the range of motion, and use the script ApplyRangeOfMotion004");
*/
serializedObject.ApplyModifiedProperties();
}
void storeNewPrefabWithROM(ProcRagdollAgent rda, ManyWorlds.SpawnableEnv envPrefab = null)
{
ROMparserSwingTwist t = target as ROMparserSwingTwist;
//ROMinfoCollector infoStored = t.info2store;
Transform targetRoot = t.targetRagdollRoot.transform;
//string add2prefabs = keyword4prefabs;
// Set the path,
// and name it as the GameObject's name with the .Prefab format
string localPath = "Assets/MarathonEnvs/Agents/Characters/MarathonMan004/" + targetRoot.name + ".prefab";
// Make sure the file name is unique, in case an existing Prefab has the same name.
string uniqueLocalPath = AssetDatabase.GenerateUniqueAssetPath(localPath);
if (PrefabUtility.IsAnyPrefabInstanceRoot(targetRoot.gameObject))
//We want to store it independently from the current prefab. Therefore:
PrefabUtility.UnpackPrefabInstance(targetRoot.gameObject, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
// Create the new Prefab.
PrefabUtility.SaveAsPrefabAsset(targetRoot.gameObject, uniqueLocalPath);
Debug.Log("Saved new CharacterPrefab at: " + uniqueLocalPath);
if (envPrefab != null)
{
Transform targetEnv = envPrefab.transform;
targetEnv.name = "ControllerMarathonManEnv";
string localEnvPath = "Assets/MarathonController/Environments/" + targetEnv.name + ".prefab";
// Make sure the file name is unique, in case an existing Prefab has the same name.
string uniqueLocalEnvPath = AssetDatabase.GenerateUniqueAssetPath(localEnvPath);
if (PrefabUtility.IsAnyPrefabInstanceRoot(targetEnv.gameObject))
//We want to store it independently from the current prefab. Therefore:
PrefabUtility.UnpackPrefabInstance(targetEnv.gameObject, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
// Create the new Prefab.
PrefabUtility.SaveAsPrefabAsset(targetEnv.gameObject, uniqueLocalEnvPath);
Debug.Log("Saved new Environment Prefab at: " + uniqueLocalEnvPath);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c871e0208cc70214e856b80d03e2025c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,109 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(TrainingEnvironmentGenerator))]
public class TrainingEnvironmentGeneratorEditor : Editor
{
public override void OnInspectorGUI()
{
serializedObject.Update();
if (GUILayout.Button("1.Generate training environment "))
{
TrainingEnvironmentGenerator t = target as TrainingEnvironmentGenerator;
t.GenerateTrainingEnv();
}
if (GUILayout.Button("2 (optional) Generate ROM values"))
{
TrainingEnvironmentGenerator t = target as TrainingEnvironmentGenerator;
t.GenerateRangeOfMotionParser();
t.Prepare4RangeOfMotionParsing();
}
GUILayout.Label("If (2), press play until the values in the ROM file do not change. Then press stop.");
if (GUILayout.Button("3.Configure and Store")) {
TrainingEnvironmentGenerator t = target as TrainingEnvironmentGenerator;
//"3.We Configure Ragdoll and learning agent"
t.Prepare4EnvironmentStorage();
t.ApplyROMasConstraintsAndConfigure();
//instructions below stores them, it can only be done in an editor script
storeEnvAsPrefab(t.Outcome);
//once stored we can destroy them to keep the scene clean
//DestroyImmediate(t.Outcome.gameObject);
EditorUtility.SetDirty(t.info2store);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
//GUILayout.Label("After (3), activate the Ragdoll game object within the hierarchy of the training environment generated.");
GUILayout.Label("");
base.OnInspectorGUI();
serializedObject.ApplyModifiedProperties();
}
void storeEnvAsPrefab(ManyWorlds.SpawnableEnv env)
{
// Set the path,
// and name it as the GameObject's name with the .Prefab format
string localPath = "Assets/MarathonController/GeneratedEnvironments/" + env.name + ".prefab";
// Make sure the file name is unique, in case an existing Prefab has the same name.
string uniqueLocalPath = AssetDatabase.GenerateUniqueAssetPath(localPath);
if (PrefabUtility.IsAnyPrefabInstanceRoot(env.gameObject))
//We want to store it independently from the current prefab. Therefore:
PrefabUtility.UnpackPrefabInstance(env.gameObject, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
// Create the new Prefab.
PrefabUtility.SaveAsPrefabAsset(env.gameObject, uniqueLocalPath);
Debug.Log("Saved new Training Environment at: " + uniqueLocalPath);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7f334119640072547b9ed56881d813da
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: