Compare commits

..

No commits in common. "main" and "4.2.0" have entirely different histories.
main ... 4.2.0

204 changed files with 38390 additions and 47129 deletions

5
.gitignore vendored
View File

@ -1,5 +0,0 @@
Samples
Samples.meta
package.json
package.json.meta
Samples~.meta

View File

@ -1023,7 +1023,7 @@ namespace Passer.Humanoid {
}
private static void CheckFaceTracking(Configuration configuration) {
if (DoesTypeExist("Passer.Humanoid.FaceTarget")) {
if (IsFileAvailable(facePath)) {
GlobalDefine("hFACE");
}
else {
@ -1120,9 +1120,6 @@ namespace Passer.Humanoid {
return false;
if (ConfigurationCheck.packageNameList.Contains("com.unity.xr.management"))
return true;
else if (ConfigurationCheck.packageNameList.Contains("com.unity.xr.oculus"))
// Somehow management is no longer available when Oculus is used
return true;
else if (ConfigurationCheck.packageNameList.Contains("com.unity.xr.openxr"))
// Somehow management is no longer available when OpenXR is used
return true;

View File

@ -76,7 +76,7 @@ namespace Passer.Humanoid {
Debug.Log(questManifestPath);
File.Copy(questManifestPath, manifestPath);
}
catch (System.Exception ) {
catch (System.Exception _) {
return;
}
}

View File

@ -855,7 +855,6 @@ namespace Passer {
else {
humanoid.pose.Show(humanoid);
humanoid.CopyRigToTargets();
humanoid.MatchTargetsToAvatar();
}
}

View File

@ -22,8 +22,7 @@ namespace Passer.Humanoid {
}
public static GameObject GetHumanoidPlayerPrefab(string prefabPath) {
//GameObject prefab = PrefabUtility.LoadPrefabContents(prefabPath);
GameObject prefab = null;
GameObject prefab = PrefabUtility.LoadPrefabContents(prefabPath);
return prefab;
}

View File

@ -1,143 +0,0 @@
using UnityEngine;
#if hPHOTON2
using Photon.Pun;
#if hPUNVOICE2 && !UNITY_WEBGL
using Photon.Voice.PUN;
using Photon.Voice.Unity;
#endif
#endif
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Passer.Humanoid {
[InitializeOnLoad]
public class OnLoadHumanoidPlayerPun {
static OnLoadHumanoidPlayerPun() {
CheckHumanoidPlayer();
}
protected static void CheckHumanoidPlayerVoice() {
#if hPUNVOICE2
string prefabPath = OnLoadHumanoidPlayer.GetHumanoidPlayerPrefabPath();
prefabPath = prefabPath.Substring(0, prefabPath.Length - 21) + "HumanoidPlayerVoice.prefab";
GameObject playerVoicePrefab = OnLoadHumanoidPlayer.GetHumanoidPlayerPrefab(prefabPath);
if (playerVoicePrefab == null)
return;
bool hasChanged = false;
#if UNITY_WEBGL
PhotonView photonView = playerVoicePrefab.GetComponent<PhotonView>();
if (photonView == null) {
photonView = playerVoicePrefab.AddComponent<PhotonView>();
hasChanged = true;
}
#else
PhotonVoiceView photonVoiceView = playerVoicePrefab.GetComponent<PhotonVoiceView>();
if (photonVoiceView == null) {
photonVoiceView = playerVoicePrefab.AddComponent<PhotonVoiceView>();
hasChanged = true;
}
if (photonVoiceView.UsePrimaryRecorder == false) {
photonVoiceView.UsePrimaryRecorder = true;
hasChanged = true;
}
PhotonTransformView photonTransformView = playerVoicePrefab.GetComponent<PhotonTransformView>();
if (photonTransformView == null) {
photonTransformView = playerVoicePrefab.AddComponent<PhotonTransformView>();
hasChanged = true;
}
PhotonView photonView = playerVoicePrefab.GetComponent<PhotonView>();
if (photonView != null) {
// should always be there because of the photonVoiceView
if (photonView.ObservedComponents == null) {
photonView.ObservedComponents = new System.Collections.Generic.List<Component>();
photonView.ObservedComponents.Add(photonTransformView);
photonView.Synchronization = ViewSynchronization.UnreliableOnChange;
hasChanged = true;
}
}
//Speaker speaker = playerVoicePrefab.GetComponent<Speaker>();
//if (speaker == null) {
// speaker = playerVoicePrefab.AddComponent<Speaker>();
// photonVoiceView.SpeakerInUse = speaker;
// hasChanged = true;
// AudioSource audioSource = playerVoicePrefab.GetComponent<AudioSource>();
// if (audioSource != null) {
// Debug.Log("adjust rolloff");
// // default logaritmic only work when people are closer than 0.5m...
// audioSource.maxDistance = 5;
// }
//}
#endif
if (hasChanged)
OnLoadHumanoidPlayer.UpdateHumanoidPrefab(playerVoicePrefab, prefabPath);
#if !UNITY_WEBGL
CheckVoiceNetwork();
#endif
#endif
}
#if hPUNVOICE2 && !UNITY_WEBGL
protected static void CheckVoiceNetwork() {
NetworkingStarter networkingStarter = Object.FindObjectOfType<NetworkingStarter>();
if (networkingStarter == null)
return;
PhotonVoiceNetwork voiceNetwork = Object.FindObjectOfType<PhotonVoiceNetwork>();
if (voiceNetwork != null)
return;
GameObject voiceNetworkObject = new GameObject("Voice Network");
voiceNetwork = voiceNetworkObject.AddComponent<PhotonVoiceNetwork>();
Recorder voiceRecorder = voiceNetworkObject.AddComponent<Recorder>();
voiceRecorder.ReactOnSystemChanges = true;
voiceRecorder.TransmitEnabled = true;
voiceRecorder.SamplingRate = POpusCodec.Enums.SamplingRate.Sampling48000;
voiceNetwork.PrimaryRecorder = voiceRecorder;
}
#endif
public static void CheckHumanoidPlayer() {
#if hPHOTON1 || hPHOTON2
string prefabPath = OnLoadHumanoidPlayer.GetHumanoidPlayerPrefabPath();
GameObject playerPrefab = OnLoadHumanoidPlayer.GetHumanoidPlayerPrefab(prefabPath);
bool hasChanged = false;
#if hNW_PHOTON
if (playerPrefab != null) {
PhotonView photonView = playerPrefab.GetComponent<PhotonView>();
if (photonView == null) {
photonView = playerPrefab.AddComponent<PhotonView>();
photonView.ObservedComponents = new System.Collections.Generic.List<Component>();
#if hPHOTON2
photonView.Synchronization = ViewSynchronization.UnreliableOnChange;
#else
photonView.synchronization = ViewSynchronization.UnreliableOnChange;
#endif
HumanoidPlayer humanoidPun = playerPrefab.GetComponent<HumanoidPlayer>();
if (humanoidPun != null)
photonView.ObservedComponents.Add(humanoidPun);
hasChanged = true;
}
}
#else
if (playerPrefab != null) {
PhotonView photonView = playerPrefab.GetComponent<PhotonView>();
if (photonView != null)
Object.DestroyImmediate(photonView, true);
}
#endif
if (hasChanged)
OnLoadHumanoidPlayer.UpdateHumanoidPrefab(playerPrefab, prefabPath);
#endif
CheckHumanoidPlayerVoice();
}
}
}

View File

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

View File

@ -1,108 +0,0 @@
/*
using UnityEditor;
using UnityEngine;
using UnityEngine.Networking;
#if hNW_PHOTON
#if hPHOTON2
using Photon.Pun;
#endif
namespace Passer {
[CustomEditor(typeof(PhotonStarter))]
public class PunStarter_Editor : Editor {
public override void OnInspectorGUI() {
base.OnInspectorGUI();
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
if (humanoids.Length != 1)
// We only support sitatuation with one humanoid in the scene
return;
//HumanoidControl humanoid = humanoids[0];
if (Application.isPlaying)
return;
//GameObject humanoidPrefab = CheckHumanoidPrefab(humanoid);
//NetworkingComponentsInspectorPun(humanoid, humanoidPrefab);
}
//private GameObject CheckHumanoidPrefab(HumanoidControl humanoid) {
// GameObject humanoidPrefab = Resources.Load<GameObject>(humanoid.gameObject.name + "_generated");
// if (humanoidPrefab == null) {
// humanoidPrefab = PrefabUtility.CreatePrefab("Assets/Humanoid/Prefabs/Networking/Resources/" + humanoid.gameObject.name + "_generated.prefab", humanoid.gameObject);
// humanoidPrefab.gameObject.SetActive(true);
// }
// return humanoidPrefab;
//}
//private void UpdateHumanoidPrefab(HumanoidControl humanoid) {
// if (humanoid != null) {
// GameObject humanoidPrefab = Resources.Load<GameObject>(humanoid.gameObject.name + "_generated");
// if (humanoidPrefab != null && humanoid.gameObject != humanoidPrefab)
// PrefabUtility.ReplacePrefab(humanoid.gameObject, humanoidPrefab, ReplacePrefabOptions.ConnectToPrefab);
// }
//}
// private void NetworkingComponentsInspectorPun(HumanoidControl humanoid, GameObject humanoidPrefab) {
//#if hPHOTON1 || hPHOTON2
//#if hNW_PHOTON
// CheckPunStarter(humanoid, humanoidPrefab);
// PhotonView photonView = humanoid.GetComponent<PhotonView>();
// if (photonView == null)
// photonView = humanoid.gameObject.AddComponent<PhotonView>();
// photonView.ObservedComponents = new System.Collections.Generic.List<Component>();
// photonView.ObservedComponents.Add(humanoid);
//#else
// cleanupPhotonView = humanoid.GetComponent<PhotonView>();
//#endif
//#endif
// }
// private void CheckPunStarter(HumanoidControl humanoid, GameObject humanoidPrefab) {
// if (Application.isPlaying)
// return;
//#if hNW_PHOTON
// PhotonStarter photonStarter = FindObjectOfType<PhotonStarter>();
// if (photonStarter != null && humanoidPrefab != null && photonStarter.playerPrefab != humanoidPrefab) {
// Undo.RecordObject(photonStarter, "Updated Player Prefab");
// photonStarter.playerPrefab = humanoidPrefab;
// }
//#endif
// }
public void OnDisable() {
Cleanup();
}
#if hNW_UNET
private NetworkIdentity cleanupNetworkIdentity;
#endif
#if hPHOTON1 || hPHOTON2
private PhotonView cleanupPhotonView;
#endif
private GameObject cleanupPunStarter;
private void Cleanup() {
#if hNW_UNET
if (cleanupNetworkIdentity) {
DestroyImmediate(cleanupNetworkIdentity, true);
cleanupNetworkIdentity = null;
}
#endif
#if hPHOTON1 || hPHOTON2
if (cleanupPhotonView) {
DestroyImmediate(cleanupPhotonView, true);
cleanupPhotonView = null;
}
#endif
if (cleanupPunStarter) {
DestroyImmediate(cleanupPunStarter, true);
cleanupPunStarter = null;
}
}
}
}
#endif
*/

View File

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

View File

@ -236,13 +236,7 @@ namespace Passer.Humanoid {
if (bones[i] == null || bones[i].bone == null || bones[i].bone.transform == null)
continue;
#if UNITY_2022_1_OR_NEWER
Handles.FreeMoveHandle(bones[i].bone.transform.position, 0.002F, Vector3.zero, DotHandleCapSaveID);
#else
Handles.FreeMoveHandle(bones[i].bone.transform.position, bones[i].bone.transform.rotation, 0.002F, Vector3.zero, DotHandleCapSaveID);
#endif
controlIds[i] = lastControlID;
boneIds[i] = bones[i].boneId;
}
@ -323,6 +317,6 @@ namespace Passer.Humanoid {
return;
}
#endregion
#endregion
}
}

View File

@ -63,9 +63,9 @@ namespace Passer {
};
}
#endregion
#endregion
#region Disable
#region Disable
public void OnDisable() {
if (humanoid == null) {
// This target is not connected to a humanoid, so we delete it
@ -82,9 +82,9 @@ namespace Passer {
foreach (TargetProps props in allProps)
props.SetSensor2Target();
}
#endregion
#endregion
#region Inspector
#region Inspector
public override void OnInspectorGUI() {
if (footTarget == null || humanoid == null)
return;
@ -142,7 +142,7 @@ namespace Passer {
return foundHumanoid;
}
#region Sensors
#region Sensors
private static bool showControllers = true;
private void ControllerInspectors(FootTarget footTarget) {
showControllers = EditorGUILayout.Foldout(showControllers, "Controllers", true);
@ -157,9 +157,9 @@ namespace Passer {
EditorGUI.indentLevel--;
}
}
#endregion
#endregion
#region Configuration
#region Configuration
private void InitConfiguration(FootTarget footTarget) {
if (footTarget.humanoid.avatarRig == null)
return;
@ -200,7 +200,7 @@ namespace Passer {
UpdateToesBones(target.toes);
}
#region UpperLeg
#region UpperLeg
//private string upperLegXname;
//private SerializedProperty upperLegMinX;
//private SerializedProperty upperLegMaxX;
@ -276,9 +276,9 @@ namespace Passer {
//upperLeg.bone.maxAngles.z = upperLegMaxZ.floatValue;
}
#endregion
#endregion
#region LowerLeg
#region LowerLeg
//private string lowerLegYname;
//private SerializedProperty lowerLegMinX;
//private SerializedProperty lowerLegMaxX;
@ -326,9 +326,9 @@ namespace Passer {
//lowerLeg.bone.minAngles.x = lowerLegMinX.floatValue;
//lowerLeg.bone.maxAngles.x = lowerLegMaxX.floatValue;
}
#endregion
#endregion
#region Foot
#region Foot
//private string footXname;
//private SerializedProperty footMinX;
//private SerializedProperty footMaxX;
@ -390,9 +390,9 @@ namespace Passer {
//foot.bone.minAngles.z = footMinZ.floatValue;
//foot.bone.maxAngles.z = footMaxZ.floatValue;
}
#endregion
#endregion
#region Toes
#region Toes
//private string toesXname;
//private SerializedProperty toesMinX;
//private SerializedProperty toesMaxX;
@ -441,10 +441,10 @@ namespace Passer {
//toes.bone.maxAngles.x = toesMaxX.floatValue;
}
#endregion
#endregion
#endregion
#endregion
#region Settings
#region Settings
private SerializedProperty rotationSpeedLimitationProp;
private SerializedProperty slidePreventionProp;
@ -470,9 +470,9 @@ namespace Passer {
EditorGUI.indentLevel--;
}
}
#endregion
#endregion
#region Events
#region Events
protected SerializedProperty groundEventProp;
@ -534,11 +534,11 @@ namespace Passer {
// }
//}
#endregion
#endregion
#endregion
#endregion
#region Scene
#region Scene
public void OnSceneGUI() {
if (footTarget == null || humanoid == null)
@ -551,13 +551,12 @@ namespace Passer {
humanoid.pose.UpdatePose(humanoid);
else {
humanoid.pose.Show(humanoid);
humanoid.CopyRigToTargets();
humanoid.MatchTargetsToAvatar();
footTarget.CopyRigToTarget();
}
}
// update the target rig from the current foot target
humanoid.CopyTargetsToRig();
footTarget.CopyTargetToRig();
// update the avatar bones from the target rig
humanoid.UpdateMovements();
// match the target rig with the new avatar pose
@ -569,7 +568,7 @@ namespace Passer {
humanoid.UpdateSensorsFromTargets();
}
#endregion
#endregion
public abstract class TargetProps {
public SerializedProperty enabledProp;

View File

@ -145,6 +145,8 @@ namespace Passer.Humanoid {
InteractionPointerButton(handTarget);
serializedObject.ApplyModifiedProperties();
//serializedObject.Update();
//serializedObject.ApplyModifiedProperties();
}
public static HandTarget Inspector(HandTarget handTarget, string name) {
@ -437,8 +439,8 @@ namespace Passer.Humanoid {
if (showSettings) {
EditorGUI.indentLevel++;
SerializedProperty showObjectsProp = serializedObject.FindProperty("_showRealObjects");
bool showRealObjects = EditorGUILayout.Toggle("Show Real Objects", showObjectsProp.boolValue);
// Cannot use serializedPropery because showRealObjects is a getter/setter
bool showRealObjects = EditorGUILayout.Toggle("Show Real Objects", handTarget.showRealObjects);
if (showRealObjects != handTarget.showRealObjects) {
handTarget.showRealObjects = showRealObjects;
handTarget.ShowSensors(showRealObjects, true);
@ -695,13 +697,12 @@ namespace Passer.Humanoid {
humanoid.pose.UpdatePose(humanoid);
else {
humanoid.pose.Show(humanoid);
humanoid.CopyRigToTargets();
humanoid.MatchTargetsToAvatar();
handTarget.CopyRigToTarget();
}
}
// update the target rig from the current hand target
humanoid.CopyTargetsToRig();
handTarget.CopyTargetToRig();
// update the avatar bones from the target rig
humanoid.UpdateMovements();
// match the target rig with the new avatar pose

View File

@ -275,7 +275,7 @@ namespace Passer.Humanoid {
if (headTarget.humanoid == null)
return;
SerializedProperty animatorProp = serializedObject.FindProperty(nameof(HeadTarget.headAnimator) + "." + nameof(HeadTarget.headAnimator.enabled));
SerializedProperty animatorProp = serializedObject.FindProperty(nameof(HeadTarget.headAnimator)+ "." +nameof(HeadTarget.headAnimator.enabled));
if (animatorProp != null && headTarget.humanoid.animatorEnabled) {
GUIContent text = new GUIContent(
@ -482,13 +482,12 @@ namespace Passer.Humanoid {
humanoid.pose.UpdatePose(humanoid);
else {
humanoid.pose.Show(humanoid);
humanoid.CopyRigToTargets();
humanoid.MatchTargetsToAvatar();
headTarget.CopyRigToTarget();
}
}
// update the target rig from the current head target
humanoid.CopyTargetsToRig();
headTarget.CopyTargetToRig();
// update the avatar bones from the target rig
humanoid.UpdateMovements();
// match the target rig with the new avatar pose

View File

@ -276,13 +276,12 @@ namespace Passer {
humanoid.pose.UpdatePose(humanoid);
else {
humanoid.pose.Show(humanoid);
humanoid.CopyRigToTargets();
humanoid.MatchTargetsToAvatar();
hipsTarget.CopyRigToTarget();
}
}
// update the target rig from the current hips target
humanoid.CopyTargetsToRig();
hipsTarget.CopyTargetToRig();
// update the avatar bones to match the target rig
humanoid.UpdateMovements();
// match the target rig with the new avatar pose

View File

@ -4,7 +4,6 @@ using UnityEngine;
namespace Passer {
using Humanoid;
[CanEditMultipleObjects]
[CustomEditor(typeof(Handle), true)]
public class Handle_Editor : Editor {
@ -43,14 +42,9 @@ namespace Passer {
//if (HumanoidPreferences.help)
// EditorGUILayout.HelpBox("Component to specify behaviour when grabbing the GameObject", MessageType.None);
SerializedProperty handProp = serializedObject.FindProperty(nameof(Handle.hand));
handProp.intValue = (int)(Handle.Hand)EditorGUILayout.EnumPopup("Hand", (Handle.Hand)handProp.intValue);
SerializedProperty grabTypeProp = serializedObject.FindProperty(nameof(Handle.grabType));
grabTypeProp.intValue = (int)(Handle.GrabType)EditorGUILayout.EnumPopup("Grab type", (Handle.GrabType)grabTypeProp.intValue);
SerializedProperty rangeProp = serializedObject.FindProperty(nameof(Handle.range));
rangeProp.floatValue = EditorGUILayout.FloatField("Range", rangeProp.floatValue);
handle.hand = (Handle.Hand)EditorGUILayout.EnumPopup("Hand", handle.hand);
handle.grabType = (Handle.GrabType)EditorGUILayout.EnumPopup("Grab type", handle.grabType);
handle.range = EditorGUILayout.FloatField("Range", handle.range);
HandPoseInspector(handle);
CheckHandTarget(handle);

View File

@ -4,7 +4,7 @@ using UnityEngine;
namespace Passer {
using Humanoid;
[CustomEditor(typeof(ControllerInput), true)]
[CustomEditor(typeof(ControllerInput))]
public class ControllerInput_Editor : Editor {
protected ControllerInput controllerInput;

View File

@ -4,21 +4,19 @@ You can import the Humanoid Control Free package in Unity directly with the Pack
See [Unity: Installing from a Git URL](https://docs.unity3d.com/Manual/upm-ui-giturl.html)
Use the link from 'Clone with HTTP' (for example: https://git.passer.life/HumanoidControl/HumanoidControl_Free.git)
Use the link from 'Clone with HTTP' (for example: https://gitlab.passervr.com/passer/unity/humanoidcontrol4_free.git)
In this way you can always retrieve the latest version by pressing the `Update` button in the Package Manager.
Optionally, you can use a tag to retrieve a specific version. For example:https://git.passer.life/HumanoidControl/HumanoidControl_Free.git#4.1.0.
Optionally, you can use a tag to retrieve a specific version. For example:http://gitlab.passervr.com/passer/unity/humanoidcontrol4_free.git#4.1.0.
This will give you a stable version which does not change. Updating can be done by retrieving the package with a link to a new release.
ChangeLog and Releases
======================
All releases with UnityPackages and links for the Unity Package Manager: [Tags page](https://git.passer.life/HumanoidControl/HumanoidControl_Free/tags).
An RSS/Atom feed with all releases can be found on the [Tags page](https://git.passer.life/HumanoidControl/HumanoidControl_Free/tags). Click on the _RSS Feed_ icon in the top-right corner to retrieve the feed.
You will find all releases with UnityPackages and links for the Unity Package Manager in the [Releases](https://gitlab.passervr.com/passer/unity/humanoidcontrol4_free/-/releases)
Documentation
=============
For the latest version of the documentation, see [PasserVR HumanoidControl Documentation](https://docs.humanoidcontrol.com/)
For the latest version of the documentation, see [PasserVR HumanoidControl Documentation](https://passervr.com/apis/HumanoidControl/Unity/index.html)
Video
=====

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ddd35f516c607da4ab4f97b210606169
timeCreated: 1453468358
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 875a66c1e6398184192242a8674906b3
guid: ed397d272bcc7c14eb9d4a69d7ba578f
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -5,12 +5,11 @@ PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 100156, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3}
propertyPath: m_Name
value: MakeHuman_simple_TP_URP
value: MakeHuman_simple_TP Variant
objectReference: {fileID: 0}
- target: {fileID: 400156, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3}
propertyPath: m_RootOrder
@ -57,23 +56,20 @@ PrefabInstance:
value: 0
objectReference: {fileID: 0}
- target: {fileID: 13700000, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3}
propertyPath: 'm_Materials.Array.data[0]'
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: ce08b92c0a6a4224d8df78eff1db7d93, type: 2}
objectReference: {fileID: 2100000, guid: 457a25bacfd81c34d8db8c9aad406f55, type: 2}
- target: {fileID: 13700002, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3}
propertyPath: 'm_Materials.Array.data[0]'
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 00d69c994b1a86745864920089aba4e6, type: 2}
objectReference: {fileID: 2100000, guid: 0ca0d02c198ab15498856b7fa22650b6, type: 2}
- target: {fileID: 13700004, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3}
propertyPath: 'm_Materials.Array.data[0]'
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 731d624f2e3c1d2488ed97fadc4bdceb, type: 2}
objectReference: {fileID: 2100000, guid: 1924927a790c5b24eb77f51e7fffdbb5, type: 2}
- target: {fileID: 13700006, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3}
propertyPath: 'm_Materials.Array.data[0]'
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: accc8d449e971a341b8b5ad32b0ba19c, type: 2}
objectReference: {fileID: 2100000, guid: 5603bff079abbbf40b7d0569a9ca2e45, type: 2}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 4695857d04e1e734faab072549aa786f
guid: 86f7ba3098b1d6d4f846836e83c3cb42
PrefabImporter:
externalObjects: {}
userData:

View File

@ -1,16 +1,27 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1547744635115364}
m_IsPrefabParent: 1
--- !u!1 &1102845541656492
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224080167443833264}
- component: {fileID: 222382479412892260}
- component: {fileID: 114935358240423544}
- component: {fileID: 114123306642843232}
m_Layer: 0
m_Name: Text
m_TagString: Untagged
@ -18,53 +29,91 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &224080167443833264
RectTransform:
--- !u!1 &1547744635115364
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102845541656492}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 224268792594220398}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &222382479412892260
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1102845541656492}
m_CullTransparentMesh: 1
--- !u!114 &114935358240423544
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224268792594220398}
- component: {fileID: 223133106560874972}
- component: {fileID: 114215111648024090}
- component: {fileID: 114000307814322182}
m_Layer: 0
m_Name: NetworkingStatusCanvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &114000307814322182
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1547744635115364}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &114123306642843232
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1102845541656492}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Script: {fileID: 11500000, guid: d7994b261fec79c4a9a1c329820642f3, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &114215111648024090
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1547744635115364}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!114 &114935358240423544
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1102845541656492}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
@ -79,51 +128,17 @@ MonoBehaviour:
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: New Text
--- !u!1 &1547744635115364
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 224268792594220398}
- component: {fileID: 223133106560874972}
- component: {fileID: 114215111648024090}
- component: {fileID: 114000307814322182}
m_Layer: 0
m_Name: NetworkingStatusCanvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &224268792594220398
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1547744635115364}
m_LocalRotation: {x: -0.0000015646192, y: -0.0000072655666, z: -0.0000067270753, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0.5}
m_LocalScale: {x: 0.001, y: 0.001, z: 0.001}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 224080167443833264}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 160, y: 40}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &222382479412892260
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1102845541656492}
--- !u!223 &223133106560874972
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1547744635115364}
m_Enabled: 1
serializedVersion: 3
@ -135,49 +150,45 @@ Canvas:
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 25
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!114 &114215111648024090
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
--- !u!224 &224080167443833264
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1102845541656492}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224268792594220398}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224268792594220398
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1547744635115364}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!114 &114000307814322182
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1547744635115364}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
m_LocalRotation: {x: -0.0000015646192, y: -0.0000072655666, z: -0.0000067270753,
w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0.5}
m_LocalScale: {x: 0.001, y: 0.001, z: 0.001}
m_Children:
- {fileID: 224080167443833264}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 160, y: 40}
m_Pivot: {x: 0.5, y: 0.5}

View File

@ -13,7 +13,7 @@ namespace Passer.Humanoid {
}
public BodyRotation bodyRotation;
protected float torsoLength;
private float torsoLength;
private Quaternion torsoUprightOrientation;
@ -67,7 +67,7 @@ namespace Passer.Humanoid {
private Vector3 leftFootPosition;
private Quaternion rightFootRotation;
private Vector3 rightFootPosition;
public void StoreTargets() {
private void StoreTargets() {
neckRotation = hipsTarget.humanoid.headTarget.neck.target.transform.rotation;
neckPosition = hipsTarget.humanoid.headTarget.neck.target.transform.position;
leftHandRotation = hipsTarget.humanoid.leftHandTarget.hand.target.transform.rotation;
@ -80,7 +80,7 @@ namespace Passer.Humanoid {
rightFootPosition = hipsTarget.humanoid.rightFootTarget.foot.target.transform.localPosition;
}
public void RestoreTargets() {
private void RestoreTargets() {
hipsTarget.humanoid.headTarget.neck.target.transform.rotation = neckRotation;
hipsTarget.humanoid.headTarget.neck.target.transform.position = neckPosition;
hipsTarget.humanoid.leftHandTarget.hand.target.transform.rotation = leftHandRotation;
@ -177,7 +177,7 @@ namespace Passer.Humanoid {
oldPosition = neckPosition;
}
public Vector3 CalculateHipsPosition() {
private Vector3 CalculateHipsPosition() {
HumanoidControl humanoid = hipsTarget.humanoid;
HeadTarget headTarget = humanoid.headTarget;

View File

@ -6,94 +6,7 @@ namespace Passer.Humanoid {
/// <summary>
/// A tracker wich can be used for custom tracking solutions
/// </summary>
/// This tracking option supports custom trackers and sensors for a humanoid.
/// We support two types of tracking
/// - using a BodySkeleton
/// - using SensorComponent
///
/// BodySkeleton
/// ------------
/// This option is most suited for full body tracking hardware.
/// An example implementation is the PerceptionNeuron extension found in the %Humanoid Control Pro edition.
///
/// For this, you need to implement a class derived from the Passer::Tracking::BodySkeleton class.
/// For the Perception Neuron extension, this new class is Passer::Tracking::PerceptionNeuron.
/// This class should be used for the to the CustomTracker::bodySkeleton parameter:
/// \image html CustomTrackerBodySkeleton.png
/// \image rtf CustomTrackerBodySkeleton.png
/// In the new class, you should override the Passer::Tracking::BodySkeleton::Start
/// and Passer::Tracking::BodySkeleton::Update functions
/// and implement the functionality to correctly start the tracking and retrieving the new body pose.
/// This will ensure that the tracking is started and updated at the right moment.
/// In the update function, you can asssign the tracking result to the correct tracking bones
/// of %Humanoid Control.
/// You can retrieve the %Humanoid Control TrackedBone using the BodySkeleton::GetBone function.
/// Then you can update the position and/or the rotation of the bone.
///
/// *Important*: a confidence value between 0 and 1 should also be set for the bone's position and/or rotation.
/// The default confidence is 0 and in that case, the tracking information will not be used.
/// Next to that, the Passer::Tracking::BodySkeleton::status should reflect the current tracking status of the device.
///
/// Example of updating one bone:
/// \code
/// protected void UpdateBone(Bone boneId) {
/// TrackedBone bone = GetBone(boneId);
/// if (bone == null)
/// return;
///
/// // Get Perception Neuron tracking information
/// SensorBone neuronBone = device.GetBone(0, boneId);
///
/// // Assign the tracking position
/// bone.transform.position = neuronBone.position;
/// // Set the position Confidence
/// bone.positionConfidence = neuronBone.positionConfidence;
///
/// // Assign the tracking rotation
/// bone.transform.rotation = neuronBone.rotation;;
/// // Set the rotation Confidence
/// bone.rotationConfidence = neuronBone.rotationConfidence;
/// }
/// \endcode
///
/// SensorComponents
/// ================
/// This option is most suited for tracking devices which can be mounted on the body.
/// An example implementation is the ViveTracker imnplementation found in the %Humanoid Control Pro edition.
///
/// For this, you need to implement a class derived from the SensorComponent class.
/// For the ViveTracker, this is the Passer::Tracking::ViveTrackerComponent.
/// This class should be used on the Head, Hand, Hips and/or Foot Targets in the Sensor::sensorComponent
/// parameter. Where applicable, selecting the bone in the dropdown determine to which bone the device is attached.
/// \image html CustomTrackerSensorComponent.png
/// \image rtf CustomTrackerSensorComponent.png
/// In the new class, you should override the SensorComponent::StartComponent and SensorComponent::UpdateComponent functions
/// and implement the functionality to correctly start the tracking and retrieve the actual pose of the device.
/// This will ensure that the tracking is started and updated at the right moment.
///
/// In the overridden SensorUpdate function, you should update the Transform of the SensorComponent.
///
/// *Important*: a confidence value between 0 and 1 should also be set for the device.
/// The default confidence is 0 and in that case, the tracking information will not be used.
/// Next to that, the SensorComponent::status should reflect the current tracking status of the device.
/// Example of updating the device rotation and position:
/// \code
/// public override void UpdateComponent() {
/// if (actionPose.poseIsValid) {
/// transform.localPosition = actionPose.localPosition;
/// transform.localRotation = actionPose.localRotation;
///
/// status = Tracker.Status.Tracking;
/// positionConfidence = 0.99F;
/// rotationConfidence = 0.99F;
/// }
/// else {
/// status = Tracker.Status.Present;
/// positionConfidence = 0F;
/// rotationConfidence = 0F;
/// }
/// }
/// \endcode
/// THis tracking option supports custom trackers and sensors for a humanoid.
[System.Serializable]
public class CustomTracker : HumanoidTracker {

View File

@ -86,7 +86,7 @@ namespace Passer.Tracking {
}
if (OculusDevice.GetHandState(OculusDevice.Step.Render, isLeft ? OculusDevice.Hand.HandLeft : OculusDevice.Hand.HandRight, ref handState)) {
if ((handState.Status & OculusDevice.HandStatus.HandTracked) == 0) {
if (handState.Status == 0) {
status = Tracker.Status.Present;
DisableRenderer();
return;

View File

@ -0,0 +1,84 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1103073703406032}
m_IsPrefabParent: 1
--- !u!1 &1103073703406032
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4808734570168326}
- component: {fileID: 33781626903072926}
- component: {fileID: 23539047341558740}
m_Layer: 0
m_Name: Left Quest Controller
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4808734570168326
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1103073703406032}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &23539047341558740
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1103073703406032}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: dc3b3568b7c54234f9d6a9f7297c3425, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &33781626903072926
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1103073703406032}
m_Mesh: {fileID: 4300000, guid: a533ecc148345874ca68507932792b9e, type: 3}

View File

@ -1,8 +1,8 @@
fileFormatVersion: 2
guid: accc8d449e971a341b8b5ad32b0ba19c
guid: 0e0e467473c4c304691fb218ad5d5411
timeCreated: 1562924722
licenseType: Free
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,84 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1038420493408916}
m_IsPrefabParent: 1
--- !u!1 &1038420493408916
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4210319229959686}
- component: {fileID: 33256649974969318}
- component: {fileID: 23472074526415768}
m_Layer: 0
m_Name: Right Quest Controller
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4210319229959686
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1038420493408916}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &23472074526415768
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1038420493408916}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: dc3b3568b7c54234f9d6a9f7297c3425, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &33256649974969318
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1038420493408916}
m_Mesh: {fileID: 4300000, guid: 6d5af71f44006e9478341b87a6c2867b, type: 3}

View File

@ -1,8 +1,8 @@
fileFormatVersion: 2
guid: ce08b92c0a6a4224d8df78eff1db7d93
guid: f78c353d457baeb44987e0ae9bc0a529
timeCreated: 1562924724
licenseType: Free
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -52,11 +52,7 @@ namespace Passer.Tracking {
if (_hmd != null)
return _hmd;
#if UNITY_6000_0_OR_NEWER
_hmd = FindAnyObjectByType<UnityXRHmd>();
#else
_hmd = FindObjectOfType<UnityXRHmd>();
#endif
return _hmd;
}
}
@ -139,7 +135,7 @@ namespace Passer.Tracking {
Object.DestroyImmediate(plane.gameObject);
}
#endregion Hmd
#endregion Hmd
#region Controller
@ -242,7 +238,7 @@ namespace Passer.Tracking {
#endregion
#endregion Manage
#endregion Manage
#region Init

View File

@ -7,17 +7,15 @@ namespace Passer.Tracking {
public class UnityXRController : ControllerComponent {
#if pUNITYXR
//public TrackerComponent tracker;
//public Transform sensorTransform {
// get { return this.transform; }
//}
protected InputDevice device;
protected XRNode xrNode;
protected enum LoadedDeviceType {
None,
Oculus,
OpenXR,
Varjo,
}
protected LoadedDeviceType loadedDevice = LoadedDeviceType.None;
public GameObject model;
#region Manage
@ -137,13 +135,6 @@ namespace Passer.Tracking {
InputDevices.deviceConnected += OnDeviceConnected;
InputDevices.deviceDisconnected += OnDeviceDisconnected;
if (XRSettings.loadedDeviceName == "oculus display")
loadedDevice = LoadedDeviceType.Oculus;
else if (XRSettings.loadedDeviceName == "OpenXR Display")
loadedDevice = LoadedDeviceType.OpenXR;
else if (XRSettings.loadedDeviceName == "VarjoDisplay")
loadedDevice = LoadedDeviceType.Varjo;
}
/// <summary>
@ -191,25 +182,19 @@ namespace Passer.Tracking {
status = Tracker.Status.Present;
bool isTracked = false;
if (device.TryGetFeatureValue(CommonUsages.isTracked, out isTracked)) {
Vector3 position;
if (isTracked && device.TryGetFeatureValue(CommonUsages.devicePosition, out position)) {
if (device.TryGetFeatureValue(CommonUsages.devicePosition, out position)) {
transform.position = trackerTransform.TransformPoint(position);
positionConfidence = 1;
status = Tracker.Status.Tracking;
}
Quaternion rotation;
if (isTracked && device.TryGetFeatureValue(CommonUsages.deviceRotation, out rotation)) {
if (loadedDevice == LoadedDeviceType.OpenXR ||
loadedDevice == LoadedDeviceType.Varjo)
rotation *= Quaternion.AngleAxis(45, Vector3.right);
if (device.TryGetFeatureValue(CommonUsages.deviceRotation, out rotation)) {
transform.rotation = trackerTransform.rotation * rotation;
rotationConfidence = 1;
status = Tracker.Status.Tracking;
}
}
UpdateInput();
@ -264,14 +249,6 @@ namespace Passer.Tracking {
renderers[i].enabled = showModel;
}
public virtual void Vibrate(float length, float strength) {
if (device.TryGetHapticCapabilities(out var capabilities) &&
capabilities.supportsImpulse) {
device.SendHapticImpulse(0u, strength, length);
}
}
#endregion Init
#endif
}

View File

@ -139,12 +139,6 @@ namespace Passer.Humanoid {
controllerInputSide.option |= controller.option > 0;
}
public override void Vibrate(float length, float strength) {
UnityXRController unityXrController = sensorComponent as UnityXRController;
if (unityXrController != null)
unityXrController.Vibrate(length, strength);
}
// arm model for 3DOF tracking: position is calculated from rotation
static public Vector3 CalculateHandPosition(HandTarget handTarget, Vector3 sensor2TargetPosition) {
Quaternion hipsYRotation = Quaternion.AngleAxis(handTarget.humanoid.hipsTarget.transform.eulerAngles.y, handTarget.humanoid.up);

View File

@ -82,17 +82,6 @@ namespace Passer.Humanoid {
return sensorComponent as UnityXRHmd;
}
public void UpdateSensorLocation() {
Vector3 position = headTarget.transform.TransformPoint(headTarget.head2eyes);
Quaternion rotation = headTarget.transform.rotation;
UnityXR unityXRtracker = tracker.trackerComponent as UnityXR;
sensorComponent = unityXRtracker.GetHmd(position, rotation);
sensorComponent.transform.position = position;
sensorComponent.transform.rotation = rotation;
}
#endregion
#region Start

View File

@ -357,14 +357,11 @@ namespace Passer.Humanoid {
#region Avatar
public event OnChangeAvatar OnChangeAvatarEvent;
public delegate void OnChangeAvatar();
protected float GetAvatarNeckHeight() {
private float GetAvatarNeckHeight() {
if (avatarRig == null)
return headTarget.transform.localPosition.y;
Transform avatarNeck = headTarget.neck.bone.transform;
Transform avatarNeck = headTarget.neck.bone.transform; // avatarRig.GetBoneTransform(HumanBodyBones.Neck);
if (avatarNeck != null) {
float neckHeight = avatarNeck.position.y - avatarRig.transform.position.y;
return neckHeight;
@ -396,7 +393,7 @@ namespace Passer.Humanoid {
}
}
public virtual void LocalChangeAvatar(GameObject avatarPrefab) {
public void LocalChangeAvatar(GameObject avatarPrefab) {
if (avatarPrefab == null)
return;
@ -453,11 +450,6 @@ namespace Passer.Humanoid {
AddCharacterColliders();
avatarNeckHeight = GetAvatarNeckHeight();
#if pUNITYXR
if (isRemote == false && headTarget.unityXR != null)
headTarget.unityXR.UpdateSensorLocation();
#endif
switch (scaling) {
case ScalingType.SetHeightToAvatar:
SetTrackingHeightToAvatar();
@ -471,11 +463,9 @@ namespace Passer.Humanoid {
default:
break;
}
OnChangeAvatarEvent?.Invoke();
}
public virtual void InitializeAvatar() {
public void InitializeAvatar() {
avatarRig = GetAvatar(this.gameObject);
// Move the animator controller to the targets rig for proper animation support
@ -718,7 +708,7 @@ namespace Passer.Humanoid {
rightFootTarget.MatchTargetsToAvatar();
}
protected void UpdateTargetsAndMovements() {
private void UpdateTargetsAndMovements() {
CopyTargetsToRig();
UpdateTargets();
@ -751,7 +741,7 @@ namespace Passer.Humanoid {
}
/// <summary>Copies the pose of the target rig to the avatar</summary>
public void CopyTargetsToRig() {
private void CopyTargetsToRig() {
hipsTarget.CopyTargetToRig();
headTarget.CopyTargetToRig();
leftHandTarget.CopyTargetToRig();
@ -1095,7 +1085,7 @@ namespace Passer.Humanoid {
}
}
protected TraditionalDevice traditionalInput;
private TraditionalDevice traditionalInput;
protected void InitTrackers() {
_trackers = new HumanoidTracker[] {
@ -1253,7 +1243,22 @@ namespace Passer.Humanoid {
/// taller or smaller than the avatar itself.
/// It retains 1:1 tracking and the X/Z position of the player are not affected.
protected void SetTrackingHeightToAvatar() {
//#if !pUNITYXR
/*
float localNeckHeight;
if (headTarget.unity.cameraTransform == null ||
UnityVRDevice.xrDevice == UnityVRDevice.XRDeviceType.None ||
headTarget.head.target.confidence.position <= 0
) {
localNeckHeight = headTarget.neck.target.transform.position.y - transform.position.y;
}
else {
//Vector3 neckPosition = HeadMovements.CalculateNeckPosition(headTarget.unityVRHead.cameraTransform.position, headTarget.unityVRHead.cameraTransform.rotation, -headTarget.neck2eyes);
//localNeckHeight = neckPosition.y - transform.position.y;
localNeckHeight = headTarget.neck.target.transform.position.y - transform.position.y;
}
*/
Vector3 neckPosition;
if (headTarget.neck.target.confidence.position > 0.2F)
neckPosition = headTarget.neck.target.transform.position;
@ -1266,6 +1271,7 @@ namespace Passer.Humanoid {
float deltaY = avatarNeckHeight - playersNeckHeight;
AdjustTrackingHeight(deltaY);
//#endif
}
//public void MoveTrackingHeightToAvatar() {
@ -1316,7 +1322,7 @@ namespace Passer.Humanoid {
#region Update
protected virtual void Update() {
protected void Update() {
Controllers.Clear();
UpdatePose();
traditionalInput.UpdateGameController(gameController);
@ -1327,7 +1333,7 @@ namespace Passer.Humanoid {
UpdatePoseEvent();
}
protected virtual void FixedUpdate() {
protected void FixedUpdate() {
DetermineCollision();
CalculateMovement();
CheckBodyPull();
@ -1341,7 +1347,7 @@ namespace Passer.Humanoid {
}
protected virtual void LateUpdate() {
protected void LateUpdate() {
PostAnimationCorrection();
@ -1388,15 +1394,15 @@ namespace Passer.Humanoid {
}
[HideInInspector]
protected Vector3 lastHumanoidPos;
private Vector3 lastHumanoidPos;
[HideInInspector]
protected float lastNeckHeight;
private float lastNeckHeight;
[HideInInspector]
protected Vector3 lastHeadPosition;
private Vector3 lastHeadPosition;
[HideInInspector]
protected Quaternion lastHeadRotation;
private Quaternion lastHeadRotation;
[HideInInspector]
protected float lastHeadDirection;
private float lastHeadDirection;
public event OnNewNeckHeight OnNewNeckHeightEvent;
public delegate void OnNewNeckHeight(float neckHeight);
@ -1426,16 +1432,7 @@ namespace Passer.Humanoid {
#region Calibration
public virtual void SetStartPosition() {
Vector3 localNeckPosition;
if (headTarget.neck.target.confidence.position > 0.2F)
localNeckPosition = headTarget.neck.target.transform.position - transform.position;
else {
Transform headTargetTransform = headTarget.head.target.transform;
localNeckPosition = HeadMovements.CalculateNeckPositionFromEyes(headTargetTransform.position, headTargetTransform.rotation, -headTarget.neck2eyes) - transform.position;
}
Vector3 delta = new Vector3(-localNeckPosition.x, 0, -localNeckPosition.z);
AdjustTracking(delta);
public void SetStartPosition() {
}
/// <summary>Calibrates the tracking with the player</summary>
@ -1938,7 +1935,7 @@ namespace Passer.Humanoid {
[HideInInspector]
private readonly float colliderRadius = 0.15F;
protected void AddCharacterColliders() {
private void AddCharacterColliders() {
if (avatarRig == null || hipsTarget.hips.bone.transform == null || isRemote || !physics)
return;
@ -2071,7 +2068,7 @@ namespace Passer.Humanoid {
rightUpperLegCollider.center = new Vector3(0, -rightUpperLeg.length / 2, 0);
}
protected void DetermineCollision() {
private void DetermineCollision() {
if (proximitySpeed) {
//float angle = Vector3.Angle(hitNormal, targetVelocity);
collided = (triggerEntered && bodyCapsule.radius <= 0.25f);
@ -2083,7 +2080,7 @@ namespace Passer.Humanoid {
hitNormal = Vector3.zero;
}
public virtual bool IsMyRigidbody(Rigidbody rigidbody) {
public bool IsMyRigidbody(Rigidbody rigidbody) {
return
rigidbody != null && (
rigidbody == humanoidRigidbody ||
@ -2140,8 +2137,6 @@ namespace Passer.Humanoid {
/// Correct floating avatars when user is taller than the avatar
/// </summary>
public bool floatCorrection = false;
public bool floatReverting = false;
private float floatCorrectionDistance = 0.0F;
protected void CheckGrounded() {
Vector3 footBase = GetHumanoidPosition();
@ -2181,24 +2176,8 @@ namespace Passer.Humanoid {
if (floatCorrection) {
float leftFootBoneDistance = leftFootTarget.foot.bone.transform.position.y - leftFootTarget.foot.target.transform.position.y;
float rightFootBoneDistance = rightFootTarget.foot.bone.transform.position.y - rightFootTarget.foot.target.transform.position.y;
if (leftFootBoneDistance > 0.02F && rightFootBoneDistance > 0.02F) {
float correction = -0.01F;
AdjustTrackingHeight(correction);
floatCorrectionDistance += correction;
Debug.Log($"{floatCorrectionDistance} {leftFootBoneDistance} {rightFootBoneDistance}");
}
}
if (floatReverting && floatCorrectionDistance < 0) {
float leftFootDistance = leftFootTarget.upperLeg.bone.transform.position.y - leftFootTarget.foot.bone.transform.position.y;
float leftBendingDistance = (leftFootTarget.upperLeg.bone.length + leftFootTarget.lowerLeg.bone.length) - leftFootDistance;
float rightFootDistance = rightFootTarget.upperLeg.bone.transform.position.y - rightFootTarget.foot.bone.transform.position.y;
float rightBendingDistance = (rightFootTarget.upperLeg.bone.length + rightFootTarget.lowerLeg.bone.length) - rightFootDistance;
if (leftBendingDistance > 0.02 && rightBendingDistance > 0.02) {
float correction = +0.01F;
AdjustTrackingHeight(correction);
floatCorrectionDistance += correction;
Debug.Log($"{floatCorrectionDistance} {leftBendingDistance} {rightBendingDistance}");
}
if (leftFootBoneDistance > 0.02F && rightFootBoneDistance > 0.02F)
AdjustTrackingHeight(-0.01F);
}
}
@ -2319,9 +2298,9 @@ namespace Passer.Humanoid {
#endregion
[HideInInspector]
protected float lastTime;
private float lastTime;
protected virtual void CalculateVelocityAcceleration() {
private void CalculateVelocityAcceleration() {
if (lastTime > 0) {
float deltaTime = Time.time - lastTime;

View File

@ -1,9 +1,11 @@
namespace Passer.Humanoid {
/// \author PasserVR
/// \version 4
/// \version 4.0
/// \mainpage %Humanoid Control for Unity
///
/// Note: this documentation is still work in progress...
///
/// Main components
/// ---------------
/// * \ref HumanoidControl "Humanoid Control"
@ -12,18 +14,12 @@
/// -------
/// * \ref UnityXRTracker "UnityXR"
/// * \ref QuestDoc "Meta Rift/Quest"
/// * \ref LeapTracker "Ultraleap"
/// * \ref ViveTrackerDoc "HTC Vive Trackers"
///
/// Input
/// -----
/// * ControllerInput
/// * InteractionPointer
///
/// Avatars
/// -------
/// * Pose
///
/// Generic tools
/// -------------
/// * TeleportTarget
@ -32,63 +28,6 @@
///
/// Networking
/// ----------
/// * \ref PhotonPunDoc "Photon PUN"
/// * NetworkingStarter
///
/// Getting Started
/// ===============
///
/// There are two ways to include an humanoid into a scene:
/// starting with an avatar and starting with the Humanoid Control script.
///
/// Starting with an avatar
/// -----------------------
/// In this case you start by putting an avatar prefab into the scene.
/// This avatar needs to fulfil the requirements of a Mecanim avatar (see below).
/// A couple of avatar prefabs are included in the Grocery Store Demo sample in the package.
///
/// The next step is to attach the HumanoidControl script to the avatar.
/// You can do this by selecting the *Add Component* button in the Inspector and selecting the HumanoidControl script.
///
/// \image html AddHumanoidControlComponent.png
/// \image rtf AddHumanoidControlComponent.png
///
/// Starting with the Humanoid Control script
/// -----------------------------------------
/// In this case we start with an Empty GameObject.
/// We will then add the HumanoidControl script to the object by selecting the *Add Component* button in the Inspector and selecting the HumanoidControl script.
///
/// \image html HumanoidControlWithoutAvatar.png
/// \image rtf HumanoidControlWithoutAvatar.png
///
/// You will see that the script could not detect a suitable avatar because there isn't an avatar attached yet.
/// We can now add an avatar by dropping an avatar onto the Empty GameObject we created. It will become a child of this GameObject.
///
/// \image html HumanoidAvatarInHierarchy.png
/// \image rtf HumanoidAvatarInHierarchy.png
///
/// This makes it easier to replace an avatar at a later moment
///
/// Requirements for the avatar
/// ===========================
/// You should ensure that your avatar has a well formed rig.
/// The script uses the bone structure derived in the Unity Mecanim rig to find the correct bones to move around.Check the rig as follows:
/// - In the prefab, select the Rig tab. Ensure the Animation Type is set to Humanoid.
/// - Ensure 'Optimize Game Objects' is *deselected*.
/// - Click Configure…
/// - Ensure that the following bones are correctly mapped:
/// - Body: Hips, Spine
/// - Left Arm: Upper Arm, Lower Arm & Hand
/// - Right Arm: Upper Arm, Lower Arm & Hand
/// - Left Leg: Upper Leg, Lower Leg & Foot
/// - Right Leg: Upper Leg, Lower Leg & Foot
/// - Head: Neck
///
/// If you need to grab objects with the alternative avatar you can add colliders to the hand and fingers manually.
/// For the thumb, the intermediate joint should at least be used for a collider. For the fingers the proximal joint should at least have a collider.
///
/// The avatar needs to have the same size and proportions as the standard avatar. Using small or giant avatars will result in strange body moments.
///
/// The avatar should face in the forward direction of the root transform. Other directions will result in twisted poses.
}

View File

@ -32,11 +32,7 @@ namespace Passer.Humanoid {
inputModule = humanoid.GetComponent<InteractionModule>();
if (inputModule == null) {
#if UNITY_6000_0_OR_NEWER
inputModule = Object.FindAnyObjectByType<InteractionModule>();
#else
inputModule = Object.FindObjectOfType<InteractionModule>();
#endif
if (inputModule == null) {
inputModule = humanoid.gameObject.AddComponent<InteractionModule>();
}
@ -45,7 +41,7 @@ namespace Passer.Humanoid {
inputModule.EnableTouchInput(humanoid, isLeft, 0);
}
public virtual HandSocket CreateGrabSocket() {
public HandSocket CreateGrabSocket() {
if (hand.bone.transform == null)
return null;
@ -118,7 +114,7 @@ namespace Passer.Humanoid {
}
}
protected void DeterminePalmPosition() {
private void DeterminePalmPosition() {
if (hand.bone.transform == null)
return;
@ -662,37 +658,32 @@ namespace Passer.Humanoid {
return false;
}
// We need to determine this here because the kinematic state
// can change when grabbing
grabbedKinematicRigidbody = objRigidbody.isKinematic;
if (objRigidbody.isKinematic)
GrabStaticWithoutHandle(objRigidbody.gameObject);
else
GrabRigidbodyParenting(objRigidbody);
grabbedRigidbody = true;
grabbedKinematicRigidbody = objRigidbody.isKinematic;
return true;
}
protected virtual bool GrabRigidbodyParenting(Rigidbody objRigidbody) {
GameObject obj = objRigidbody.gameObject;
if (handRigidbody == null)
if (handRigidbody == null) {
Debug.LogError("Hand no longer has a rigidbody...");
}
if (handRigidbody != null)
handRigidbody.mass = objRigidbody.mass;
RigidbodyDisabled.ParentRigidbody(handRigidbody, objRigidbody);
HumanoidNetworking.DisableNetworkSync(objRigidbody.gameObject);
if (!humanoid.isRemote)
HumanoidNetworking.TakeOwnership(objRigidbody.gameObject);
RigidbodyDisabled.ParentRigidbody(handRigidbody, objRigidbody);
//if (Application.isPlaying)
// Object.Destroy(objRigidbody);
//else
// Object.DestroyImmediate(objRigidbody, true);
if (Application.isPlaying)
Object.Destroy(objRigidbody);
else
Object.DestroyImmediate(objRigidbody, true);
grabbedObject = obj;
return true;
@ -825,15 +816,11 @@ namespace Passer.Humanoid {
}
protected virtual void LetGoRigidbodyWithoutHandle() {
protected void LetGoRigidbodyWithoutHandle() {
Rigidbody objRigidbody = RigidbodyDisabled.UnparentRigidbody(handPalm, grabbedObject.transform);
if (objRigidbody != null && !objRigidbody.isKinematic) {
if (handRigidbody != null) {
#if UNITY_6000_0_OR_NEWER
objRigidbody.linearVelocity = handRigidbody.linearVelocity;
#else
objRigidbody.velocity = handRigidbody.velocity;
#endif
objRigidbody.angularVelocity = handRigidbody.angularVelocity;
}
HumanoidNetworking.ReenableNetworkSync(objRigidbody.gameObject);
@ -842,11 +829,11 @@ namespace Passer.Humanoid {
LetGoStaticWithoutHandle();
}
protected virtual void LetGoStaticWithoutHandle() {
protected void LetGoStaticWithoutHandle() {
grabSocket.ReleaseStaticJoint();
}
protected virtual void LetGoRigidbody(Rigidbody grabbedRigidbody) {
protected void LetGoRigidbody(Rigidbody grabbedRigidbody) {
DebugLog("LetGoRigidbody");
if (grabbedRigidbody != null) {
@ -860,24 +847,16 @@ namespace Passer.Humanoid {
}
//grabbedRigidbody.centerOfMass = handTarget.storedCOM;
if (grabbedRigidbody.isKinematic == false) {
#if UNITY_6000_0_OR_NEWER
grabbedRigidbody.linearVelocity = handRigidbody.linearVelocity;
#else
grabbedRigidbody.velocity = handRigidbody.velocity;
#endif
grabbedRigidbody.angularVelocity = handRigidbody.angularVelocity;
}
if (grabbedHandle != null)
LetGoHandle(grabbedHandle);
handRigidbody.mass = 1;
}
this.grabbedRigidbody = false;
}
protected virtual void LetGoHandle(Handle handle) {
protected void LetGoHandle(Handle handle) {
DebugLog("LetGoHandle " + handle);
if (Application.isPlaying) {
if (grabbedHandle != null) {

View File

@ -53,13 +53,8 @@ namespace Passer.Humanoid {
handTarget.handRigidbody = handTarget.hand.bone.transform.gameObject.AddComponent<Rigidbody>();
}
handTarget.handRigidbody.mass = 1;
#if UNITY_6000_0_OR_NEWER
handTarget.handRigidbody.linearDamping = 0;
handTarget.handRigidbody.angularDamping = 10;
#else
handTarget.handRigidbody.drag = 0;
handTarget.handRigidbody.angularDrag = 10;
#endif
handTarget.handRigidbody.useGravity = false;
handTarget.handRigidbody.isKinematic = true;
handTarget.handRigidbody.interpolation = RigidbodyInterpolation.None;

View File

@ -27,7 +27,7 @@ namespace Passer.Humanoid {
#if hFACE
if (headTarget.neck.target.confidence.rotation < 0.2F && headTarget.head.target.confidence.rotation < 0.2F &&
headTarget.face.leftEye.target.confidence.rotation > 0.2F && headTarget.headAnimator.headAnimation == true) {
headTarget.face.leftEye.target.confidence.rotation > 0.2F) {
UpdateHeadBonesFromGazeDirection(headTarget);
}

View File

@ -31,7 +31,7 @@ namespace Passer.Humanoid {
}
}
protected void FullInverseKinematics(FootTarget footTarget) {
private void FullInverseKinematics(FootTarget footTarget) {
//Debug.Log("FullInverseKinematics");
if (footTarget.foot.target.transform == null)
@ -55,7 +55,7 @@ namespace Passer.Humanoid {
PlaceFootOnLowerLeg(footTarget, lowerLegRotation);
}
protected void FullForwardKinematics(FootTarget footTarget) {
private void FullForwardKinematics(FootTarget footTarget) {
//Debug.Log("FullForwardKinematics");
footTarget.upperLeg.SetBoneRotation(footTarget.upperLeg.target.transform.rotation);
footTarget.lowerLeg.SetBoneRotation(footTarget.lowerLeg.target.transform.rotation);
@ -82,7 +82,7 @@ namespace Passer.Humanoid {
#region Upper Leg
protected Quaternion NaturalUpperLegOrientation(FootTarget footTarget, Vector3 footPosition) {
private Quaternion NaturalUpperLegOrientation(FootTarget footTarget, Vector3 footPosition) {
Quaternion oldUpperLegRotation = footTarget.upperLeg.bone.transform.rotation * footTarget.upperLeg.bone.toTargetRotation;
Quaternion upperLegRotation = CalculateUpperLegRotation(footTarget, footTarget.upperLeg.bone.transform.position, footPosition, footTarget.foot.target.transform.rotation, footTarget.upperLeg.bone.length, footTarget.lowerLeg.bone.length);
//upperLegRotation = LimitRotationSpeed(oldUpperLegRotation, upperLegRotation);
@ -130,8 +130,7 @@ namespace Passer.Humanoid {
#endregion
#region Lower Leg
protected Quaternion NaturalLowerLegOrientation(FootTarget footTarget, Quaternion upperLegRotation, Vector3 footPosition) {
private Quaternion NaturalLowerLegOrientation(FootTarget footTarget, Quaternion upperLegRotation, Vector3 footPosition) {
float lowerLegAngle = CalculateKneeAngle(footTarget.upperLeg.bone.transform.position, footPosition, footTarget.upperLeg.bone.length, footTarget.lowerLeg.bone.length);
if (footTarget.lowerLeg.bone.jointLimitations)
@ -164,13 +163,12 @@ namespace Passer.Humanoid {
kneeAngle = 180;
return 180 - kneeAngle;
}
#endregion
#region Foot
// Calculate the foot position taking body limitations into account
protected Vector3 NaturalFootPosition(FootTarget footTarget) {
private Vector3 NaturalFootPosition(FootTarget footTarget) {
if (footTarget.ground == null || !footTarget.physics)
return footTarget.foot.target.transform.position;
else {
@ -179,7 +177,7 @@ namespace Passer.Humanoid {
}
// Calculate the foot orientation taking body limitation into account
protected Quaternion NaturalFootOrientation(FootTarget footTarget) {
private Quaternion NaturalFootOrientation(FootTarget footTarget) {
Quaternion footOrientation = DetermineFootOrientation(footTarget);
if (footTarget.foot.bone.jointLimitations)
footOrientation = LimitAngle(footTarget.foot, ref lastLocalFootRotation, footOrientation);
@ -227,15 +225,14 @@ namespace Passer.Humanoid {
return footPosition;
}
public static void PlaceFootOnLowerLeg(FootTarget footTarget, Quaternion lowerLegRotation) {
private static void PlaceFootOnLowerLeg(FootTarget footTarget, Quaternion lowerLegRotation) {
footTarget.foot.bone.transform.position = footTarget.lowerLeg.bone.transform.position + lowerLegRotation * -footTarget.humanoid.up * footTarget.lowerLeg.bone.length;
}
#endregion
#region Toes
protected Quaternion NaturalToesOrientation(FootTarget footTarget) {
private Quaternion NaturalToesOrientation(FootTarget footTarget) {
Quaternion footRotation = footTarget.foot.bone.transform.rotation * footTarget.foot.bone.toTargetRotation;
if (footTarget.ground != null) {
return Quaternion.LookRotation(footTarget.groundNormal, footRotation * Vector3.back) * Quaternion.Euler(90, 0, 0);
@ -244,7 +241,6 @@ namespace Passer.Humanoid {
return footRotation;
}
}
#endregion
private static float Square(float x) {

View File

@ -287,7 +287,7 @@ namespace Passer.Humanoid {
return;
}
#else
if (!string.IsNullOrEmpty(msg.possessionLocation)) {
if (msg.possessionLocation != null) {
Debug.Log("Need to download instantiate avatar possession from " + msg.possessionLocation);
remoteHumanoid.physics = msg.physics;
@ -1103,17 +1103,9 @@ namespace Passer.Humanoid {
}
HumanoidTarget target = GetTarget(humanoid, targetPose.boneId);
if (target != null) {
if (targetPose.boneId == Tracking.Bone.Head) {
HeadAnimator headAnimator = target.animator as HeadAnimator;
if (headAnimator != null)
headAnimator.headAnimation = false;
}
else {
if (target != null)
target.animator.enabled = false;
//target.EnableAnimator(false);
}
}
if (targetPose.boneId == Tracking.Bone.LeftHand || targetPose.boneId == Tracking.Bone.RightHand)
ReceiveHand((HandTarget)target, (HumanoidHandPose)targetPose);
@ -1718,11 +1710,7 @@ namespace Passer.Humanoid {
public static List<HumanoidControl> FindLocalHumanoids() {
List<HumanoidControl> humanoidList = new List<HumanoidControl>();
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] foundHumanoids = UnityEngine.Object.FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] foundHumanoids = UnityEngine.Object.FindObjectsOfType<HumanoidControl>();
#endif
for (int i = 0; i < foundHumanoids.Length; i++) {
if (!foundHumanoids[i].isRemote) {
humanoidList.Add(foundHumanoids[i]);
@ -1732,11 +1720,7 @@ namespace Passer.Humanoid {
}
public static IHumanoidNetworking GetLocalHumanoidNetworking() {
#if UNITY_6000_0_OR_NEWER
HumanoidPlayer[] humanoidNetworkings = UnityEngine.Object.FindObjectsByType<HumanoidPlayer>(FindObjectsSortMode.None);
#else
HumanoidPlayer[] humanoidNetworkings = UnityEngine.Object.FindObjectsOfType<HumanoidPlayer>();
#endif
foreach (IHumanoidNetworking humanoidNetworking in humanoidNetworkings) {
if (humanoidNetworking.isLocal)
return humanoidNetworking;

View File

@ -0,0 +1,7 @@
using UnityEngine;
namespace Passer.Humanoid {
public partial class HumanoidPlayerPunVoice : MonoBehaviour {
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 69a31162e39169c4fad112f52654bd40
guid: c48e8d9c90f89154daf3a86de9a5f2ad
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -6,19 +6,18 @@ namespace Passer {
protected NetworkingStarter networkingStarter;
protected UnityEngine.UI.Text textcomponent;
protected void Start() {
#if UNITY_6000_0_OR_NEWER
networkingStarter = Object.FindAnyObjectByType<NetworkingStarter>();
#else
void Start() {
networkingStarter = FindObjectOfType<NetworkingStarter>();
#endif
textcomponent = GetComponent<UnityEngine.UI.Text>();
}
protected void Update() {
void Update() {
#if hNW_UNET || hNW_PHOTON
if (networkingStarter == null)
return;
//if (textcomponent != null)
// textcomponent.text = networkingStarter.networkingStatus.ToString();
#endif
}
}

View File

@ -1,670 +0,0 @@
#if hNW_PHOTON
using UnityEngine;
using System.Collections.Generic;
#endif
#if hPHOTON2
using Photon.Realtime;
using Photon.Pun;
#endif
namespace Passer.Humanoid {
using Pawn;
#if hNW_PHOTON
[RequireComponent(typeof(PhotonView))]
#if hPHOTON2
public partial class HumanoidPlayer : MonoBehaviourPunCallbacks, IHumanoidNetworking, IPunInstantiateMagicCallback, IPunObservable {
#else
public partial class HumanoidPlayer : Photon.MonoBehaviour, IHumanoidNetworking {
#endif
public ulong nwId {
#if hPHOTON2
get { return (ulong)photonView.ViewID; }
#else
get { return (ulong)photonView.viewID; }
#endif
}
[SerializeField]
protected float _sendRate = 25;
public float sendRate {
get { return _sendRate; }
}
//[SerializeField]
//protected HumanoidNetworking.DebugLevel _debug = HumanoidNetworking.DebugLevel.Error;
//public HumanoidNetworking.DebugLevel debug {
// get { return _debug; }
//}
[SerializeField]
protected HumanoidNetworking.Smoothing _smoothing = HumanoidNetworking.Smoothing.None;
public HumanoidNetworking.Smoothing smoothing {
get { return _smoothing; }
}
[SerializeField]
protected bool _createLocalRemotes = false;
public bool createLocalRemotes {
get { return _createLocalRemotes; }
set { _createLocalRemotes = value; }
}
public bool isLocal { get; set; }
public List<HumanoidControl> humanoids { get; set; }
public ulong GetObjectIdentity(GameObject obj) {
PhotonView photonView = obj.GetComponent<PhotonView>();
if (photonView == null)
return 0;
#if hPHOTON2
return (ulong)photonView.ViewID;
#else
return (ulong)photonView.viewID;
#endif
}
public GameObject GetGameObject(ulong objIdentity) {
PhotonView objView = PhotonView.Find((int)objIdentity);
if (objView == null)
return this.gameObject;
return objView.gameObject;
}
#region Init
#if hPHOTON2
public override void OnEnable() {
base.OnEnable();
PhotonNetwork.AddCallbackTarget(this);
}
public override void OnDisable() {
base.OnDisable();
PhotonNetwork.RemoveCallbackTarget(this);
}
#endif
public void Awake() {
mInstance = this;
GameObject.DontDestroyOnLoad(this.gameObject);
humanoids = HumanoidNetworking.FindLocalHumanoids();
if (debug <= HumanoidNetworking.DebugLevel.Info)
DebugLog("Found " + humanoids.Count + " Humanoids");
for (int i = 0; i < humanoids.Count; i++) {
HumanoidControl humanoid = humanoids[i];
if (humanoid.isRemote || createLocalRemotes == false)
continue;
humanoid.humanoidNetworking = this;
((IHumanoidNetworking)this).InstantiateHumanoid(humanoid);
}
}
#endregion
#region Start
public void OnPhotonInstantiate(PhotonMessageInfo info) {
#if hPHOTON2
if (photonView.IsMine) {
#else
if (photonView.isMine) {
#endif
isLocal = true;
name = "HumanoidPun(Local)";
humanoids = HumanoidNetworking.FindLocalHumanoids();
if (debug <= HumanoidNetworking.DebugLevel.Info)
DebugLog("Found " + humanoids.Count + " Humanoids");
for (int i = 0; i < humanoids.Count; i++) {
HumanoidControl humanoid = humanoids[i];
if (humanoid.isRemote)
continue;
#if hPHOTON2
humanoid.nwId = (ulong)photonView.ViewID;
#else
humanoid.nwId = nwId; // photonView.viewID;
#endif
humanoid.humanoidNetworking = this;
if (debug <= HumanoidNetworking.DebugLevel.Info)
DebugLog("Send Start Humanoid " + humanoid.humanoidId);
((IHumanoidNetworking)this).InstantiateHumanoid(humanoid);
#if hPUNVOICE2 && !UNITY_WEBGL
InstantiatePlayerVoice(humanoid);
#endif
HumanoidNetworking.Connected(humanoid);
}
NetworkingSpawner spawner = FindObjectOfType<NetworkingSpawner>();
if (spawner != null)
spawner.OnNetworkingStarted();
}
else {
humanoids = HumanoidNetworking.FindLocalHumanoids();
if (debug <= HumanoidNetworking.DebugLevel.Info)
DebugLog("Found " + humanoids.Count + " Humanoids");
}
}
#if hPHOTON2
public override void OnPlayerEnteredRoom(Player newPlayer) {
#else
public void OnPhotonPlayerConnected(PhotonPlayer player) {
#endif
List<HumanoidControl> humanoids = HumanoidNetworking.FindLocalHumanoids();
if (humanoids.Count <= 0)
return;
foreach (HumanoidControl humanoid in humanoids) {
if (debug <= HumanoidNetworking.DebugLevel.Info)
Debug.Log(humanoid.nwId + ": (Re)Send Instantiate Humanoid " + humanoid.humanoidId);
// Notify new player about my humanoid
((IHumanoidNetworking)this).InstantiateHumanoid(humanoid);
if (humanoid.leftHandTarget.grabbedObject != null)
humanoid.humanoidNetworking.Grab(humanoid.leftHandTarget, humanoid.leftHandTarget.grabbedObject, false);
if (humanoid.rightHandTarget.grabbedObject != null)
humanoid.humanoidNetworking.Grab(humanoid.rightHandTarget, humanoid.rightHandTarget.grabbedObject, false);
}
}
#endregion
#region Update
PhotonStream stream;
float lastSend;
// The number of received messages processed in this frame
private int processedThisFrame = 0;
private enum MessageType {
Pose,
Grab,
LetGo
}
private struct QueuedMessage {
public MessageType messageType;
public byte[] data;
}
private Queue<QueuedMessage> messageQueue = new Queue<QueuedMessage>();
protected virtual void LateUpdate() {
processedThisFrame = 0;
if (messageQueue.Count > 0) {
ProcessMessageFromQueue();
Debug.Log("----Processed messages = " + messageQueue.Count);
}
if (!createLocalRemotes)
return;
if (Time.time > lastSend + 1 / sendRate) {
if (humanoids != null) {
foreach (HumanoidControl humanoid in humanoids) {
if (!humanoid.isRemote) {
UpdateHumanoidPose(humanoid);
if (syncTracking)
SyncTrackingSpace(humanoid);
}
}
}
lastSend = Time.time;
}
}
private float lastPoseTime;
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
this.stream = stream;
#if hPHOTON2
if (stream.IsWriting) {
#else
if (stream.isWriting) {
#endif
foreach (HumanoidControl humanoid in humanoids) {
if (!humanoid.isRemote) {
UpdateHumanoidPose(humanoid);
if (syncTracking)
SyncTrackingSpace(humanoid);
}
}
}
else {
ReceiveAvatarPose(stream);
}
}
private void ProcessMessageFromQueue() {
QueuedMessage msg = messageQueue.Dequeue();
switch (msg.messageType) {
case MessageType.Pose:
this.ReceiveHumanoidPose(msg.data);
break;
case MessageType.Grab:
Debug.Log("Processing Queued Grab " + Time.time);
this.ReceiveGrab(msg.data);
break;
case MessageType.LetGo:
Debug.Log("Processsing Queueud Let Go " + Time.time);
this.ReceiveLetGo(msg.data);
break;
}
}
#endregion
#region Stop
private void OnDestroy() {
if (humanoids == null)
return;
if (debug <= HumanoidNetworking.DebugLevel.Info)
DebugLog("Destroy Remote Humanoids");
foreach (HumanoidControl humanoid in humanoids) {
if (humanoid == null)
continue;
if (humanoid.isRemote) {
if (humanoid.gameObject != null)
Destroy(humanoid.gameObject);
}
}
}
#endregion
#region Instantiate Humanoid
void IHumanoidNetworking.InstantiateHumanoid(HumanoidControl humanoid) {
if (debug <= HumanoidNetworking.DebugLevel.Info)
DebugLog("Send Instantiate Humanoid " + humanoid.humanoidId);
HumanoidNetworking.InstantiateHumanoid instantiateHumanoid = new HumanoidNetworking.InstantiateHumanoid(humanoid);
if (createLocalRemotes) {
this.Receive(instantiateHumanoid);
}
byte[] data = instantiateHumanoid.Serialize();
#if hPHOTON2
photonView.RPC("RpcInstantiateHumanoid", RpcTarget.Others, data);
#else
photonView.RPC("RpcInstantiateHumanoid", PhotonTargets.Others, data);
#endif
}
[PunRPC]
protected virtual void RpcInstantiateHumanoid(byte[] data) {
this.ReceiveInstantiate(data);
}
#if hPUNVOICE2 && !UNITY_WEBGL
protected virtual void InstantiatePlayerVoice(HumanoidControl humanoid) {
GameObject playerVoiceGameObject = PhotonNetwork.Instantiate("HumanoidPlayerVoice", humanoid.headTarget.transform.position, humanoid.headTarget.transform.rotation);
HumanoidPlayerPunVoice playerVoice = playerVoiceGameObject.GetComponent<HumanoidPlayerPunVoice>();
if (playerVoice != null)
playerVoice.humanoid = humanoid;
Debug.Log("created voice for " + humanoid);
}
#endif
#endregion
#region Destroy Humanoid
void IHumanoidNetworking.DestroyHumanoid(HumanoidControl humanoid) {
if (humanoid == null)
return;
if (debug <= HumanoidNetworking.DebugLevel.Info)
DebugLog("Destroy Humanoid " + humanoid.humanoidId);
HumanoidNetworking.DestroyHumanoid destroyHumanoid = new HumanoidNetworking.DestroyHumanoid(humanoid);
if (createLocalRemotes)
this.Receive(destroyHumanoid);
byte[] data = destroyHumanoid.Serialize();
#if hPHOTON2
if (PhotonNetwork.IsConnected)
photonView.RPC("RpcDestroyHumanoid", RpcTarget.Others, data);
#else
if (PhotonNetwork.connected)
photonView.RPC("RpcDestroyHumanoid", PhotonTargets.Others, data);
#endif
}
[PunRPC]
public void RpcDestroyHumanoid(byte[] data) {
this.ReceiveDestroy(data);
}
#endregion
#region Pose
public HumanoidNetworking.HumanoidPose lastHumanoidPose { get; set; }
public virtual void UpdateHumanoidPose(HumanoidControl humanoid) {
if (debug <= HumanoidNetworking.DebugLevel.Debug)
DebugLog("Send Pose Humanoid " + humanoid.humanoidId + " nwId: " + humanoid.nwId);
HumanoidNetworking.HumanoidPose humanoidPose = new HumanoidNetworking.HumanoidPose(humanoid, Time.time);
if (createLocalRemotes)
this.Receive(humanoidPose);
if (stream != null) {
byte[] data = humanoidPose.Serialize();
stream.SendNext(data);
}
}
PhotonStream reader;
private void ReceiveAvatarPose(PhotonStream reader) {
this.reader = reader;
byte[] data = (byte[])reader.ReceiveNext();
this.ReceiveHumanoidPose(data);
}
#endregion
#region Grab
void IHumanoidNetworking.Grab(HandTarget handTarget, GameObject obj, bool rangeCheck, HandTarget.GrabType grabType) {
if (debug <= HumanoidNetworking.DebugLevel.Info)
DebugLog("Grab " + obj + " " + grabType);
ulong objIdentity = GetObjectIdentity(obj);
if (objIdentity == 0) {
if (debug <= HumanoidNetworking.DebugLevel.Warning)
Debug.LogError("Photon Grab: Grabbed object does not have a PhotonView");
return;
}
HumanoidNetworking.Grab grab = new HumanoidNetworking.Grab(handTarget, objIdentity, rangeCheck, grabType);
if (createLocalRemotes)
// Does this make sense?
this.Receive(grab);
byte[] data = grab.Serialize();
#if hPHOTON2
photonView.RPC("RpcGrab", RpcTarget.Others, data);
#else
photonView.RPC("RpcGrab", PhotonTargets.Others, data);
#endif
}
[PunRPC]
public void RpcGrab(byte[] data) {
if (processedThisFrame > 0 || messageQueue.Count > 0) {
QueuedMessage msg = new QueuedMessage() {
messageType = MessageType.Grab,
data = data
};
messageQueue.Enqueue(msg);
Debug.Log("++++Buffered Grab message = " + messageQueue.Count + " " + Time.time);
return;
}
this.ReceiveGrab(data);
processedThisFrame++;
}
#endregion
#region Let Go
void IHumanoidNetworking.LetGo(HandTarget handTarget) {
if (debug <= HumanoidNetworking.DebugLevel.Info)
DebugLog("LetGo");
HumanoidNetworking.LetGo letGo = new HumanoidNetworking.LetGo(handTarget);
if (createLocalRemotes)
this.Receive(letGo);
byte[] data = letGo.Serialize();
#if hPHOTON2
photonView.RPC("RpcLetGo", RpcTarget.Others, data);
#else
photonView.RPC("RpcLetGo", PhotonTargets.Others, data);
#endif
}
[PunRPC]
public void RpcLetGo(byte[] data) {
if (processedThisFrame > 0 || messageQueue.Count > 0) {
QueuedMessage msg = new QueuedMessage() {
messageType = MessageType.LetGo,
data = data
};
messageQueue.Enqueue(msg);
Debug.Log("++++Buffered Let Go message = " + messageQueue.Count + " " + Time.time);
return;
}
this.ReceiveLetGo(data);
processedThisFrame++;
}
#endregion
#region Change Avatar
void IHumanoidNetworking.ChangeAvatar(HumanoidControl humanoid, string avatarPrefabName, string possessionLocation) {
if (debug <= HumanoidNetworking.DebugLevel.Info)
Debug.Log(humanoid.nwId + ": Change Avatar: " + avatarPrefabName);
HumanoidNetworking.ChangeAvatar changeAvatar = new HumanoidNetworking.ChangeAvatar(humanoid, avatarPrefabName, possessionLocation);
if (createLocalRemotes)
this.Receive(changeAvatar);
byte[] data = changeAvatar.Serialize();
#if hPHOTON2
photonView.RPC("RpcChangeAvatar", RpcTarget.Others, data); // humanoid.humanoidId, avatarPrefabName);
#else
photonView.RPC("RpcChangeAvatar", PhotonTargets.Others, data); // humanoid.humanoidId, avatarPrefabName);
#endif
}
[PunRPC]
protected virtual void RpcChangeAvatar(byte[] data) {
this.ReceiveChangeAvatar(data);
}
#endregion
#region Tracking
private Transform GetTrackingTransform(HumanoidControl humanoid) {
#if hANTILATENCY
if (humanoid.antilatency != null)
return humanoid.antilatency.trackerTransform;
#endif
//#if hOPENVR && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX)
// if (humanoid.openVR != null)
// return humanoid.openVR.GetTrackingTransform();
//#endif
return null;
}
public void SyncTrackingSpace(HumanoidControl humanoid) {
if (humanoid == null)
return;
Transform trackingTransform = GetTrackingTransform(humanoid);
if (trackingTransform == null)
return;
if (debug <= HumanoidNetworking.DebugLevel.Info)
DebugLog("Send Sync Tracking Space " + humanoid.humanoidId + " " + trackingTransform.position + " " + trackingTransform.rotation);
HumanoidNetworking.SyncTrackingSpace syncTrackingSpace =
new HumanoidNetworking.SyncTrackingSpace(humanoid, trackingTransform.position, trackingTransform.rotation);
if (createLocalRemotes)
// Does this make sense?
this.Receive(syncTrackingSpace);
byte[] data = syncTrackingSpace.Serialize();
#if hPHOTON2
photonView.RPC("RpcSyncTracking", RpcTarget.Others, data);
#else
photonView.RPC("RpcSyncTracking", PhotonTargets.Others, data);
#endif
}
[PunRPC]
protected virtual void RpcSyncTracking(byte[] data) {
this.ReceiveSyncTrackingSpace(data);
}
#endregion
#region Network Sync
void IHumanoidNetworking.ReenableNetworkSync(GameObject obj) {
if (debug <= HumanoidNetworking.DebugLevel.Info)
Debug.Log("ReenableNetworkSync " + obj);
ReenableNetworkSync(obj);
}
void IHumanoidNetworking.DisableNetworkSync(GameObject obj) {
if (debug <= HumanoidNetworking.DebugLevel.Info)
Debug.Log("DisableNetworkSync " + obj);
DisableNetworkSync(obj);
}
public static void ReenableNetworkSync(GameObject obj) {
#if hPHOTON2
PhotonView photonView = obj.GetComponent<PhotonView>();
if (photonView != null) {
photonView.Synchronization = ViewSynchronization.UnreliableOnChange;
}
#endif
PhotonTransformView transformView = obj.GetComponent<PhotonTransformView>();
if (transformView != null) {
#if hPHOTON2
transformView.m_SynchronizePosition = true;
transformView.m_SynchronizeRotation = true;
transformView.enabled = true;
#else
transformView.m_PositionModel.SynchronizeEnabled = true;
transformView.m_RotationModel.SynchronizeEnabled = true;
#endif
}
}
public static void TakeOwnership(GameObject obj) {
#if hPHOTON2
PhotonView photonView = obj.GetComponent<PhotonView>();
if (photonView != null)
photonView.RequestOwnership();
#endif
}
public static void DisableNetworkSync(GameObject obj) {
PhotonTransformView transformView = obj.GetComponent<PhotonTransformView>();
if (transformView != null) {
#if hPHOTON2
transformView.m_SynchronizePosition = false;
transformView.m_SynchronizeRotation = false;
transformView.enabled = false;
#else
transformView.m_PositionModel.SynchronizeEnabled = false;
transformView.m_RotationModel.SynchronizeEnabled = false;
#endif
}
}
#endregion
#region Network Object
#region Void Event
public void RPC(FunctionCall functionCall) {
ulong objIdentity = GetObjectIdentity(functionCall.targetGameObject);
if (objIdentity == 0) {
if (debug <= HumanoidNetworking.DebugLevel.Warning)
Debug.LogError("Photon Grab: Grabbed object does not have a PhotonView");
return;
}
photonView.RPC("RpcFunctionCall", RpcTarget.Others, objIdentity, functionCall.methodName);
}
[PunRPC]
public void RpcFunctionCall(ulong objIdentity, string methodName) {
GameObject targetGameObject = GetGameObject(objIdentity);
if (targetGameObject == null) {
if (debug <= HumanoidNetworking.DebugLevel.Warning)
Debug.LogError("FunctionCall: Could not find object for method " + methodName);
return;
}
FunctionCall.Execute(targetGameObject, methodName);
}
#endregion
#endregion Network Object
#region Send
public void Send(bool b) { stream.SendNext(b); }
public void Send(byte b) { stream.SendNext(b); }
public void Send(int x) { stream.SendNext(x); }
public void Send(float f) { stream.SendNext(f); }
public void Send(Vector3 v) { stream.SendNext(v); }
public void Send(Quaternion q) { stream.SendNext(q); }
#endregion
#region Receive
public bool ReceiveBool() { return (bool)reader.ReceiveNext(); }
public byte ReceiveByte() { return (byte)reader.ReceiveNext(); }
public int ReceiveInt() { return (int)reader.ReceiveNext(); }
public float ReceiveFloat() { return (float)reader.ReceiveNext(); }
public Vector3 ReceiveVector3() { return (Vector3)reader.ReceiveNext(); }
public Quaternion ReceiveQuaternion() { return (Quaternion)reader.ReceiveNext(); }
#endregion
#region Debug
public void DebugLog(string message) {
#if hPHOTON2
Debug.Log(photonView.ViewID + ": " + message);
#else
Debug.Log(photonView.viewID + ": " + message);
#endif
}
public void DebugWarning(string message) {
#if hPHOTON2
Debug.LogWarning(photonView.ViewID + ": " + message);
#else
Debug.LogWarning(photonView.viewID + ": " + message);
#endif
}
public void DebugError(string message) {
#if hPHOTON2
Debug.LogError(photonView.ViewID + ": " + message);
#else
Debug.LogError(photonView.viewID + ": " + message);
#endif
}
#endregion
}
#endif
}

View File

@ -1,72 +0,0 @@
using UnityEngine;
#if hPUNVOICE2
using Photon.Pun;
#endif
namespace Passer.Humanoid {
#if !hPUNVOICE2
public class HumanoidPlayerPunVoice : MonoBehaviour {
#else
public class HumanoidPlayerPunVoice : MonoBehaviourPunCallbacks {
#endif
/// <summary>
/// The humanoid to follow
/// </summary>
public HumanoidControl humanoid;
#if hPUNVOICE2
private bool updateAudioSource = true;
#region Init
protected virtual void Start() {
Debug.Log("Started HumanoidVoice");
DontDestroyOnLoad(this.gameObject);
}
#endregion Init
#region Update
protected virtual void Update() {
if (photonView.Controller.IsLocal) {
transform.position = humanoid.headTarget.transform.position;
}
else {
if (updateAudioSource) {
AudioSource audioSource = GetComponent<AudioSource>();
if (audioSource != null) {
audioSource.rolloffMode = AudioRolloffMode.Linear;
audioSource.spatialBlend = 1;
audioSource.minDistance = 0;
audioSource.maxDistance = 1;
updateAudioSource = false;
}
}
if (humanoid == null) {
foreach (HumanoidControl humanoid in HumanoidControl.allHumanoids) {
if (humanoid.headTarget == null)
continue;
float distance = Vector3.Distance(this.transform.position, humanoid.headTarget.transform.position);
if (distance < 0.01F) {
this.humanoid = humanoid;
AudioSource audioSource = this.humanoid.headTarget.GetComponentInChildren<AudioSource>();
#if pUNITYXR
if (audioSource == null && this.humanoid.headTarget.unityXR.unityXR.hmd != null)
audioSource = this.humanoid.headTarget.unityXR.unityXR.hmd.GetComponentInChildren<AudioSource>();
#endif
if (audioSource != null)
audioSource = this.GetComponent<AudioSource>();
}
}
}
}
}
#endregion Update
#endif
}
}

View File

@ -1,64 +0,0 @@
namespace Passer.Humanoid {
/// \page PhotonPunDoc Photon PUN
///
/// Setup
/// =====
/// In order to use Photon PUN 2 in your project.
/// You need to import the Photon PUN 2 package first from the asset store.
///
/// Networking Starter
/// ==================
/// When using Photon PUN 2, the Networking Starter component has the following options:
/// \image html PhotonPunNetworkingStarter.png
/// \image rtf PhotonPunNetworkingStarter.png
///
/// Networking PrefabThe player prefab which will be spawned across the network.
/// This defaults to HumanoidPlayer for Photon Networking.Room NameThe name of the environment shared by the playersGame VersionThe version of the environment shared by the playersSend RateThe number of updates per second communicated through the network.
///
/// Photon Voice
/// ============
/// You need to include the Photon Voice 2 package in your project.
///
/// In the Photon Server Settings (see Window Menu->Photon Unity Networking->Highlight Server Settings,
/// set the Settings->App Id Voice to the same App Id you use for setting up Photon 2.
/// This App Id is also found in the App Id Realtime field.
///
/// Select the Photon PUN prefab which is spawned across the network.
/// If you use the Networking Starter this usually is the HumanoidPun prefab which is found in
/// Assets/Humanoid/Prefabs/Networking/Resources/
/// Add the following components to the HumanoidPun prefab:
///
/// Add a Photon Voice View component
///
/// Add a Recorder component, make sure you have Auto Start and Transmit Enabled switched on
///
/// Set Photon Voice View->Recorder in Use to this Recorder
///
/// The result should look like this:
/// \image html PhotonPunVoiceSetup.png
/// \image rtf PhotonPunVoiceSetup.png
///
/// Now if you start you project, Photon Voice should work.
///
/// Self Hosted Networking
/// ======================
/// For local networking Photon PUN, go to the following page:
/// https://www.photonengine.com/en-US/sdks#server-sdkserverserver.
/// Then select 'Server':
///
/// And download the SDK. 
///
/// Instructions on how to set it up can be found here: 
/// https://doc.photonengine.com/en-us/server/current/getting-started/photon-server-in-5min
///
/// The settings you need to use in Unity for Photon 2 are as follows:
/// \image html PhotonPunSelfhosted.png
/// \image rtf PhotonPunSelfhosted.png
///
/// In this case, we use a direct IP Address (localhost/127.0.01), so Use Name Server is disabled.
/// As the protocol is Udp, you need to set port to 5055. Other port numbers can be found here:
/// https://doc.photonengine.com/en-us/realtime/current/connection-and-authentication/tcp-and-udp-port-numbers
/// If you start the scene now, Photon should connect to the local server.
///
}

View File

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

View File

@ -1,97 +0,0 @@
using UnityEngine;
#if hPHOTON2
using Photon.Pun;
using Photon.Realtime;
#endif
#if hPUNVOICE2
using Photon.Voice.PUN;
using Photon.Voice.Unity;
#endif
namespace Passer {
#if hNW_PHOTON
public class PunStarter : INetworkingStarter {
public GameObject playerPrefab;
public string roomName;
public int gameVersion;
public int sendRate;
public void Awake() {
#if hPUNVOICE2 && !UNITY_WEBGL
PhotonVoiceNetwork voiceNetwork = Object.FindObjectOfType<PhotonVoiceNetwork>();
if (voiceNetwork != null)
return;
GameObject voiceNetworkObject = new GameObject("Voice Network");
voiceNetwork = voiceNetworkObject.AddComponent<PhotonVoiceNetwork>();
Recorder voiceRecorder = voiceNetworkObject.AddComponent<Recorder>();
voiceRecorder.ReactOnSystemChanges = true;
voiceRecorder.TransmitEnabled = true;
voiceRecorder.SamplingRate = POpusCodec.Enums.SamplingRate.Sampling48000;
voiceNetwork.PrimaryRecorder = voiceRecorder;
#endif
}
GameObject INetworkingStarter.GetHumanoidPrefab() {
GameObject humanoidPrefab = Resources.Load<GameObject>("HumanoidPlayer");
return humanoidPrefab;
}
void INetworkingStarter.StartHost(NetworkingStarter nwStarter) {
((INetworkingStarter)this).StartClient(nwStarter);
}
void INetworkingStarter.StartClient(NetworkingStarter nwStarter) {
((INetworkingStarter)this).StartClient(nwStarter, nwStarter.roomName, nwStarter.gameVersion);
}
void INetworkingStarter.StartClient(NetworkingStarter nwStarter, string _roomName, int _gameVersion) {
roomName = _roomName;
gameVersion = _gameVersion;
playerPrefab = Resources.Load<GameObject>("HumanoidPlayer");
sendRate = nwStarter.sendRate;
#if hPHOTON2
PhotonNetwork.SendRate = sendRate;
PhotonNetwork.SerializationRate = sendRate;
PhotonNetwork.GameVersion = gameVersion.ToString();
PhotonNetwork.ConnectUsingSettings();
#else
PhotonNetwork.sendRate = sendRate;
PhotonNetwork.sendRateOnSerialize = sendRate;
PhotonNetwork.ConnectUsingSettings(gameVersion.ToString());
#endif
}
public virtual void OnConnectedToPhoton() {
Debug.Log("Photon");
}
public virtual void OnConnectedToMaster() {
RoomOptions roomOptions = new RoomOptions() { IsVisible = false, MaxPlayers = 4 };
PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);
}
public virtual void OnPhotonJoinRoomFailed() {
Debug.LogError("Could not joint the " + roomName + " room");
}
public virtual void OnJoinedRoom(GameObject playerPrefab) {
if (playerPrefab != null)
PhotonNetwork.Instantiate(playerPrefab.name, Vector3.zero, Quaternion.identity, 0);
//NetworkingSpawner spawner = FindObjectOfType<NetworkingSpawner>();
//if (spawner != null)
// spawner.OnNetworkingStarted();
}
public void StopClient() {
PhotonNetwork.Disconnect();
}
}
#endif
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: bbe6fd67c1c770e478d9cb8eef19b594
timeCreated: 1466884930
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@
using UnityEngine;
using System.Collections;
public class FootPhysics : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: b2b89683096330a4eb3810fdaeb79fb6
timeCreated: 1504014033
guid: 8485b8871c8f9cf4e870d0ef4ab949cd
timeCreated: 1483383200
licenseType: Free
MonoImporter:
serializedVersion: 2

View File

@ -23,7 +23,7 @@ namespace Passer.Humanoid {
}
[HideInInspector]
public Rigidbody handRigidbody;
protected Rigidbody handRigidbody;
protected virtual void Initialize() {
if (handTarget == null)
@ -186,7 +186,7 @@ namespace Passer.Humanoid {
#region Force
protected virtual Vector3 CalculateForce() {
protected Vector3 CalculateForce() {
/*
//Vector3 locationDifference = handTarget.stretchlessTarget.position - handTarget.handRigidbody.position;
//Debug.DrawLine(handTarget.stretchlessTarget.position, handTarget.handRigidbody.position);
@ -204,17 +204,10 @@ namespace Passer.Humanoid {
return force;
}
public virtual Vector3 CalculateForce(Vector3 position, Vector3 targetPosition, bool damping = false) {
Vector3 force = (targetPosition - position) * handTarget.strength;
if (damping)
force += CalculateForceDamper();
return force;
}
private const float damping = 12;
protected float lastDistanceTime;
protected Vector3 lastDistanceToTarget;
protected virtual Vector3 CalculateForceDamper() {
private float lastDistanceTime;
private Vector3 lastDistanceToTarget;
private Vector3 CalculateForceDamper() {
Vector3 distanceToTarget = handTarget.hand.bone.transform.position - handTarget.hand.target.transform.position;
float deltaTime = Time.fixedTime - lastDistanceTime;
@ -227,11 +220,7 @@ namespace Passer.Humanoid {
//Compensate for absolute rigidbody speed (specifically when on a moving platform)
if (handRigidbody != null) {
#if UNITY_6000_0_OR_NEWER
Vector3 residualVelocity = handRigidbody.linearVelocity - velocityTowardsTarget;
#else
Vector3 residualVelocity = handRigidbody.velocity - velocityTowardsTarget;
#endif
damper += residualVelocity * 10;
}
}
@ -241,7 +230,7 @@ namespace Passer.Humanoid {
return damper;
}
protected virtual void ApplyForce(Vector3 force) {
protected void ApplyForce(Vector3 force) {
if (float.IsNaN(force.magnitude))
return;
@ -270,7 +259,7 @@ namespace Passer.Humanoid {
#endif
}
protected virtual void ApplyForceAtPosition(Vector3 force, Vector3 position) {
protected void ApplyForceAtPosition(Vector3 force, Vector3 position) {
if (float.IsNaN(force.magnitude))
return;
@ -284,7 +273,7 @@ namespace Passer.Humanoid {
#region Torque
protected virtual Vector3 CalculateTorque() {
protected Vector3 CalculateTorque() {
Quaternion sollRotation = handTarget.hand.target.transform.rotation * handTarget.hand.target.toBoneRotation;
Quaternion istRotation = handTarget.hand.bone.transform.rotation;
Quaternion dRot = sollRotation * Quaternion.Inverse(istRotation);
@ -299,7 +288,7 @@ namespace Passer.Humanoid {
return torque;
}
protected virtual Vector3 CalculateWristTorque() {
protected Vector3 CalculateWristTorque() {
//Vector3 wristTension = target.GetWristTension();
// Not stable
@ -315,7 +304,7 @@ namespace Passer.Humanoid {
ApplyTorqueAtPosition(torque, handTarget.hand.bone.transform.position);
}
protected virtual void ApplyTorqueAtPosition(Vector3 torque, Vector3 posToApply) {
protected void ApplyTorqueAtPosition(Vector3 torque, Vector3 posToApply) {
if (float.IsNaN(torque.magnitude))
return;
@ -364,7 +353,7 @@ namespace Passer.Humanoid {
}
public PhysicsMode mode = PhysicsMode.HybridKinematic;
protected bool colliding;
private bool colliding;
public bool hasCollided = false;
public Vector3 contactPoint;
@ -425,7 +414,7 @@ namespace Passer.Humanoid {
colliding = false;
}
public virtual void UpdateRigidbody() {
public void UpdateRigidbody() {
if (handRigidbody == null) {
UpdateGrabbedMechanicalJoint();
return;
@ -452,7 +441,7 @@ namespace Passer.Humanoid {
UpdateNonKinematicRigidbody();
}
protected void UpdateGrabbedMechanicalJoint() {
private void UpdateGrabbedMechanicalJoint() {
Rigidbody grabbedRigidbody = handTarget.hand.bone.transform.GetComponentInParent<Rigidbody>();
if (grabbedRigidbody == null)
return;
@ -474,7 +463,7 @@ namespace Passer.Humanoid {
grabbedRigidbody.transform.rotation = grabbedRigidbody.transform.rotation * correctionRotation;
}
protected void UpdateKinematicRigidbody() {
private void UpdateKinematicRigidbody() {
if (mode == PhysicsMode.NonKinematic ||
mode == PhysicsMode.HybridKinematic && (
handRigidbody.mass > HybridPhysics.kinematicMass ||
@ -556,11 +545,7 @@ namespace Passer.Humanoid {
Vector3 velocityTarget = (positionDelta * velocityMagic) * Time.fixedDeltaTime;
if (float.IsNaN(velocityTarget.x) == false)
#if UNITY_6000_0_OR_NEWER
handRigidbody.linearVelocity = Vector3.MoveTowards(handRigidbody.linearVelocity, velocityTarget, MaxVelocityChange);
#else
handRigidbody.velocity = Vector3.MoveTowards(handRigidbody.velocity, velocityTarget, MaxVelocityChange);
#endif
rotationDelta.ToAngleAxis(out angle, out axis);
@ -685,7 +670,7 @@ namespace Passer.Humanoid {
handTarget.grabbedObject.SendMessage("OnCollisionEnter", collision, SendMessageOptions.DontRequireReceiver);
}
public virtual void OnCollisionStay(Collision collision) {
public void OnCollisionStay(Collision collision) {
if (collision.rigidbody != null && collision.rigidbody.gameObject == handTarget.grabbedObject)
// Don't collide with the things you are holding
return;

View File

@ -13,17 +13,17 @@ namespace Passer.Humanoid {
/// This is the HandTarget of the hand to which the socket is attached
public HandTarget handTarget;
//protected override void MoveHandleToSocket(Transform socketTransform, Handle handle) {
// DebugLog("MoveHandleToHand");
protected override void MoveHandleToSocket(Transform socketTransform, Handle handle) {
DebugLog("MoveHandleToHand");
// Transform handleTransform = handle.GetComponent<Transform>();
// Rigidbody handleRigidbody = handle.GetComponentInParent<Rigidbody>();
// if (handleRigidbody != null)
// handleTransform = handleRigidbody.transform;
Transform handleTransform = handle.GetComponent<Transform>();
Rigidbody handleRigidbody = handle.GetComponentInParent<Rigidbody>();
if (handleRigidbody != null)
handleTransform = handleRigidbody.transform;
// handleTransform.rotation = handle.RotationTo(socketTransform.rotation) * handleTransform.rotation;
// handleTransform.position += handle.TranslationTo(socketTransform.position);
//}
handleTransform.rotation = handle.RotationTo(socketTransform.rotation) * handleTransform.rotation;
handleTransform.position += handle.TranslationTo(socketTransform.position);
}
protected override void MoveSocketToHandle(Transform socketTransform, Handle handle) {
DebugLog("MoveHandToHandle");
@ -155,7 +155,7 @@ namespace Passer.Humanoid {
DestroyedJoints destroyedJoints = objRigidbody.GetComponent<DestroyedJoints>();
// Check if we are grabbing a hand
BasicHandPhysics handPhysics = objRigidbody.GetComponentInParent<BasicHandPhysics>();
BasicHandPhysics handPhysics = objRigidbody.GetComponent<BasicHandPhysics>();
if (handPhysics != null) { // We are grabbing a hand
if (thisRigidbody == null) {
DebugLog("Cannot attach to hand because this handRigidbody is not present");

View File

@ -15,13 +15,8 @@ namespace Passer {
public RigidbodyData(Rigidbody rb) {
mass = rb.mass;
#if UNITY_6000_0_OR_NEWER
drag = rb.linearDamping;
angularDrag = rb.angularDamping;
#else
drag = rb.drag;
angularDrag = rb.angularDrag;
#endif
useGravity = rb.useGravity;
isKinematic = rb.isKinematic;
interpolation = rb.interpolation;
@ -33,13 +28,8 @@ namespace Passer {
public void CopyToRigidbody(Rigidbody rb) {
rb.mass = mass;
#if UNITY_6000_0_OR_NEWER
rb.linearDamping = drag;
rb.angularDamping = angularDrag;
#else
rb.drag = drag;
rb.angularDrag = angularDrag;
#endif
rb.useGravity = useGravity;
rb.isKinematic = isKinematic;
rb.interpolation = interpolation;

View File

@ -40,18 +40,17 @@ namespace Passer.Humanoid {
HumanoidTarget.TargetedBone referenceBone = humanoid.GetBone(referenceBoneRef.boneId);
if (referenceBoneRef.boneId != Bone.None && referenceBone.target.transform != null) {
referencePosition = referenceBone.target.transform.position;
referenceRotation = referenceBone.target.transform.rotation; //referenceBone.bone.targetRotation;
referenceRotation = referenceBone.bone.targetRotation;
referenceScale = referenceBone.target.transform.lossyScale;
}
else {
referencePosition = targetedBone.TargetBasePosition(); // humanoid.transform.position;
referencePosition = humanoid.transform.position;
referenceRotation = humanoid.transform.rotation;
referenceScale = humanoid.transform.lossyScale;
}
if (setTranslation)
//targetedBone.target.transform.position = targetedBone.TargetBasePosition() + Vector3.Lerp(Vector3.zero, referenceRotation * translation, value);
targetedBone.target.transform.position = referencePosition + Vector3.Lerp(Vector3.zero, referenceRotation * translation, value);
targetedBone.target.transform.position = targetedBone.TargetBasePosition() + Vector3.Lerp(Vector3.zero, referenceRotation * translation, value);
if (setRotation)
targetedBone.target.transform.rotation = Quaternion.Slerp(targetedBone.TargetBaseRotation(), referenceRotation * rotation, value);
if (setScale)

View File

@ -114,7 +114,6 @@ namespace Passer.Humanoid {
public void ShowPose(HumanoidControl humanoid, Side showSide) {
detectedPoseIx = -1;
float bestScore = -1;
detectedPose = null;
if (poseMode == PoseMode.Set)
ResetAffectedBones(humanoid, showSide);

View File

@ -1,7 +1,8 @@
fileFormatVersion: 2
guid: 3cec17721dc9fb0499bab2210c9bf0ac
PrefabImporter:
externalObjects: {}
guid: 94cc904628763c548944b198ccc94346
timeCreated: 1486644658
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +1,9 @@
fileFormatVersion: 2
guid: df1bff1867e6b5e42a3d0019e53e5550
guid: cc84ac7c95c473c44b97c107602087b7
folderAsset: yes
timeCreated: 1486643266
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -2,24 +2,19 @@
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 292
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Material
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_ShaderKeywords: _EMISSION
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
@ -59,14 +54,13 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
@ -80,4 +74,3 @@ Material:
m_Colors:
- _Color: {r: 0.8, g: 0.8, b: 0.8, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f288e74f24dec3949aed8e4f550c4b83
timeCreated: 1486643266
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +1,9 @@
fileFormatVersion: 2
guid: 6abcb3631639c01478d992ecbd8dc39a
guid: 02da7ec8c993b874381f34377f818316
folderAsset: yes
timeCreated: 1486643408
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -649,11 +649,7 @@ namespace Passer.Humanoid {
private HumanoidControl GetHumanoid() {
// This does not work for prefabs
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
#endif
for (int i = 0; i < humanoids.Length; i++) {
if ((humanoids[i].leftFootTarget != null && humanoids[i].leftFootTarget.transform == this.transform) ||
@ -833,7 +829,7 @@ namespace Passer.Humanoid {
toes.MatchTargetToAvatar();
}
#endregion
#endregion
#region Update

View File

@ -650,7 +650,7 @@ namespace Passer.Humanoid {
#endregion
protected void InitSubTargets() {
private void InitSubTargets() {
//foreach (TargetedBone subTarget in subTargets)
// subTarget.Init();
shoulder.Init();
@ -911,17 +911,6 @@ namespace Passer.Humanoid {
public bool twoHandedGrab = false;
public Vector3 targetToSecondaryHandle;
public bool TouchedStaticObject() {
if (touchedObject == null)
return false;
Rigidbody rb = touchedObject.GetComponent<Rigidbody>();
if (rb == null || rb.isKinematic)
return true;
return false;
}
public bool GrabbedStaticObject() {
if (grabbedObject != null && grabbedRigidbody && grabbedKinematicRigidbody)
return true;
@ -1163,11 +1152,7 @@ namespace Passer.Humanoid {
private HumanoidControl GetHumanoid() {
// This does not work for prefabs
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
#endif
for (int i = 0; i < humanoids.Length; i++) {
if ((humanoids[i].leftHandTarget != null && humanoids[i].leftHandTarget.transform == this.transform) ||
@ -1199,13 +1184,8 @@ namespace Passer.Humanoid {
handRigidbody = hand.bone.transform.gameObject.AddComponent<Rigidbody>();
}
handRigidbody.mass = 1;
#if UNITY_6000_0_OR_NEWER
handRigidbody.linearDamping = 0;
handRigidbody.angularDamping = 10;
#else
handRigidbody.drag = 0;
handRigidbody.angularDrag = 10;
#endif
handRigidbody.useGravity = false;
handRigidbody.isKinematic = true;
handRigidbody.interpolation = RigidbodyInterpolation.None;
@ -1762,7 +1742,7 @@ namespace Passer.Humanoid {
#region Colliders
protected void CheckColliders() {
private void CheckColliders() {
if (hand.bone.transform == null)
return;

View File

@ -560,7 +560,6 @@ namespace Passer.Humanoid {
neck.RetrieveBones(humanoid);
head.RetrieveBones(humanoid);
#if hFACE
face.InitComponent();
face.RetrieveBones(this);
#endif
}
@ -750,11 +749,7 @@ namespace Passer.Humanoid {
private HumanoidControl GetHumanoid() {
// This does not work for prefabs
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
#endif
for (int i = 0; i < humanoids.Length; i++) {
if (humanoids[i].headTarget != null && humanoids[i].headTarget.transform == this.transform)
@ -804,6 +799,9 @@ namespace Passer.Humanoid {
if (humanoid == null)
return;
#if hFACE
face.InitComponent();
#endif
}
public override void StartTarget() {
@ -880,7 +878,7 @@ namespace Passer.Humanoid {
#endif
}
#endregion
#endregion
#region Update
@ -1066,7 +1064,7 @@ namespace Passer.Humanoid {
#region Tools
/// <summary>Gets the eye position in world coordinates</summary>
public virtual Vector3 GetEyePosition() {
public Vector3 GetEyePosition() {
if (Application.isPlaying && gameObject != null) {
Camera camera = gameObject.GetComponentInChildren<Camera>();
if (camera != null)
@ -1222,6 +1220,15 @@ namespace Passer.Humanoid {
}
}
public void DisableVR() {
UnityEngine.XR.XRSettings.LoadDeviceByName("None");
}
public void EnableVR() {
// Just oculus for now
UnityEngine.XR.XRSettings.LoadDeviceByName("Oculus");
}
#endregion
}
}

View File

@ -47,7 +47,6 @@ namespace Passer.Humanoid {
hips = new TargetedHipsBone(this);
}
public bool simpleSpineIK => newSpineIK;
public bool newSpineIK = false;
public TorsoMovements torsoMovements = new TorsoMovements();
@ -89,7 +88,7 @@ namespace Passer.Humanoid {
public CustomTorso custom = new CustomTorso();
#endif
protected TorsoSensor[] sensors;
private TorsoSensor[] sensors;
public override void InitSensors() {
@ -461,11 +460,7 @@ namespace Passer.Humanoid {
private HumanoidControl GetHumanoid() {
// This does not work for prefabs
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
#endif
for (int i = 0; i < humanoids.Length; i++) {
if (humanoids[i].hipsTarget != null && humanoids[i].hipsTarget.transform == this.transform)
@ -619,7 +614,7 @@ namespace Passer.Humanoid {
}
#endregion
#endregion
#region Update

View File

@ -17,7 +17,6 @@ namespace Passer {
/// </summary>
public abstract class Target : MonoBehaviour {
[SerializeField]
protected bool _showRealObjects = true;
/// <summary>
/// show the target meshes

View File

@ -59,7 +59,7 @@ namespace Passer.Humanoid {
/// as the third person avatar.
public Animator[] tpAvatars = new Animator[0];
protected HumanoidControl humanoid;
private HumanoidControl humanoid;
protected virtual void Start() {
humanoid = GetComponent<HumanoidControl>();

View File

@ -1,9 +1,7 @@
using System.Collections;
using UnityEngine;
namespace Passer {
public class FlashLight : MonoBehaviour {
public class FlashLight : MonoBehaviour {
protected Light thisLight;
@ -32,5 +30,4 @@ namespace Passer {
yield return new WaitForSeconds(duration);
light.enabled = false;
}
}
}

View File

@ -1,12 +1,8 @@
using UnityEngine;
namespace Passer {
public class Hit : MonoBehaviour {
public class Hit : MonoBehaviour {
public void HitMe() {
Debug.Log("AU!");
}
}
}

View File

@ -51,11 +51,7 @@ namespace Passer {
/// </summary>
/// <returns>The found humanoid, null if no local humanoid has been found</returns>
protected HumanoidControl FindHumanoid() {
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
#endif
for (int i = 0; i < humanoids.Length; i++) {
if (humanoids[i].isRemote == false)
return humanoids[i];

View File

@ -1,8 +1,6 @@
using UnityEngine;
namespace Passer {
public class Redrop : MonoBehaviour {
public class Redrop : MonoBehaviour {
// Script which is to be replaced by CollisionEventHandler
@ -12,18 +10,18 @@ namespace Passer {
private Vector3 startPosition;
private Quaternion startRotation;
protected void Start() {
void Start() {
startPosition = transform.position;
startRotation = transform.rotation;
}
protected void Update() {
void Update() {
if (groundCollider == null && transform.position.y < 0) {
MoveToStart();
}
}
protected void OnCollisionEnter(Collision collision) {
private void OnCollisionEnter(Collision collision) {
if (collision.collider == groundCollider) {
MoveToStart();
}
@ -34,14 +32,8 @@ namespace Passer {
if (thisRigidbody != null) {
thisRigidbody.MovePosition(new Vector3(startPosition.x, startPosition.y + 0.1F, startPosition.z));
thisRigidbody.MoveRotation(startRotation);
#if UNITY_6000_0_OR_NEWER
thisRigidbody.linearVelocity = Vector3.zero;
#else
thisRigidbody.velocity = Vector3.zero;
#endif
thisRigidbody.angularVelocity = Vector3.zero;
}
}
}
}

View File

@ -4,10 +4,9 @@ using UnityEngine.SceneManagement;
using UnityEditor;
using UnityEditor.SceneManagement;
namespace Passer {
[InitializeOnLoad]
public class SceneLoader {
[InitializeOnLoad]
public class SceneLoader {
static SceneLoader() {
EditorSceneManager.sceneOpened += SceneOpened;
}
@ -15,31 +14,21 @@ namespace Passer {
private static void SceneOpened(Scene scene, OpenSceneMode mode) {
if ((scene.name == "ObjectTable Pawn" ||
scene.name == "ObjectTable Pawn VR" ||
scene.name == "ObjectTable Humanoid")
#if UNITY_2022_2_OR_NEWER
&& UnityEngine.SceneManagement.SceneManager.loadedSceneCount == 1
#else
&& EditorSceneManager.loadedSceneCount == 1
#endif
) {
scene.name == "ObjectTable Humanoid") &&
EditorSceneManager.loadedSceneCount == 1) {
//Debug.Log("Additive opening ObjectTable scene");
EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ObjectTable.unity", OpenSceneMode.Additive);
}
else if ((scene.name == "ShootingRange Pawn" ||
scene.name == "ShootingRange Pawn VR" ||
scene.name == "ShootingRange Humanoid")
#if UNITY_2022_2_OR_NEWER
&& UnityEngine.SceneManagement.SceneManager.loadedSceneCount == 1
#else
&& EditorSceneManager.loadedSceneCount == 1
#endif
) {
scene.name == "ShootingRange Humanoid") &&
EditorSceneManager.loadedSceneCount == 1) {
//Debug.Log("Additive opening ShootingRange scene");
EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ShootingRange.unity", OpenSceneMode.Additive);
}
}
}
}
#endif

View File

@ -1,4 +1,6 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Passer.Humanoid {
@ -7,11 +9,7 @@ namespace Passer.Humanoid {
protected HandTarget handTarget;
protected void Start() {
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
#endif
if (humanoids.Length != 1)
return;

View File

@ -29,11 +29,7 @@ namespace Passer.Humanoid {
private void Awake() {
HumanoidControl humanoidInScene = GetComponentInParent<HumanoidControl>();
if (humanoidInScene == null) {
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
#endif
foreach (HumanoidControl humanoid in humanoids) {
if (humanoid.isRemote == false)
this.humanoid = humanoid;

View File

@ -21,11 +21,7 @@ namespace Passer {
}
private void OnSceneLoad(Scene scene, LoadSceneMode mode) {
#if UNITY_6000_0_OR_NEWER
Canvas[] canvases = FindObjectsByType<Canvas>(FindObjectsSortMode.None);
#else
Canvas[] canvases = FindObjectsOfType<Canvas>();
#endif
foreach (Canvas canvas in canvases)
canvas.worldCamera = Camera.main;
}

View File

@ -1,6 +1,6 @@
using UnityEngine;
namespace Passer {
//namespace Passer {
public static class RigidbodyTools {
public static void DestroyGameObject(this Rigidbody rigidbody) {
@ -8,4 +8,4 @@ namespace Passer {
}
}
}
//}

View File

@ -43,11 +43,7 @@ namespace Passer {
#if UNITY_EDITOR
UnityEngine.SceneManagement.SceneManager.sceneLoaded += OnSceneLoad;
#if UNITY_6000_0_OR_NEWER
HumanoidControl humanoid = FindAnyObjectByType<HumanoidControl>();
#else
HumanoidControl humanoid = FindObjectOfType<HumanoidControl>();
#endif
if (humanoid == null) {
string visitorScenePath = HumanoidPreferences.visitorSceneName;
if (!string.IsNullOrEmpty(visitorScenePath)) {
@ -61,29 +57,17 @@ namespace Passer {
private void OnSceneLoad(Scene _, LoadSceneMode _1) {
#if UNITY_EDITOR
#if UNITY_6000_0_OR_NEWER
SiteNavigator[] siteNavigators = FindObjectsByType<SiteNavigator>(FindObjectsSortMode.None);
#else
SiteNavigator[] siteNavigators = FindObjectsOfType<SiteNavigator>();
#endif
foreach (SiteNavigator siteNavigator in siteNavigators) {
siteNavigator.startScene = null;
siteNavigator.startSite = null;
}
#if UNITY_6000_0_OR_NEWER
HumanoidControl pawn = FindAnyObjectByType<HumanoidControl>();
#else
HumanoidControl pawn = FindObjectOfType<HumanoidControl>();
#endif
if (pawn == null)
return;
#if UNITY_6000_0_OR_NEWER
HumanoidSpawnPoint[] spawnPoints = FindObjectsByType<HumanoidSpawnPoint>(FindObjectsSortMode.None);
#else
HumanoidSpawnPoint[] spawnPoints = FindObjectsOfType<HumanoidSpawnPoint>();
#endif
foreach (HumanoidSpawnPoint spawnPoint in spawnPoints) {
if (spawnPoint.isFree)
pawn.transform.position = spawnPoint.transform.position;

View File

@ -87,7 +87,7 @@ namespace Passer {
UnityEditor.SceneManagement.EditorSceneManager.LoadSceneInPlayMode(startScene, new LoadSceneParameters(LoadSceneMode.Additive));
currentSite = new HistoryEntry() {
siteName = "directload",
siteLocation = "serrarens.nl/sites/start",
siteLocation = "passervr.com/sites/start",
scenePath = "",
assetBundle = currentAssetBundle,
};
@ -248,7 +248,7 @@ namespace Passer {
UnityEngine.UI.Text text = dialogObj.AddComponent<UnityEngine.UI.Text>();
text.text = dialogText;
text.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
text.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
text.resizeTextForBestFit = true;
text.alignment = TextAnchor.MiddleCenter;

View File

@ -16,11 +16,7 @@ namespace Passer {
UnityEngine.SceneManagement.SceneManager.sceneLoaded += OnSceneLoad;
#if UNITY_6000_0_OR_NEWER
HumanoidControl pawn = FindAnyObjectByType<HumanoidControl>();
#else
HumanoidControl pawn = FindObjectOfType<HumanoidControl>();
#endif
if (pawn == null) {
UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName);
}
@ -30,11 +26,7 @@ namespace Passer {
private void OnSceneLoad(UnityEngine.SceneManagement.Scene _, LoadSceneMode _1) {
#if UNITY_EDITOR
#if UNITY_6000_0_OR_NEWER
SiteNavigator siteNavigator = FindAnyObjectByType<SiteNavigator>();
#else
SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>();
#endif
if (siteNavigator != null) {
siteNavigator.startScene = thisSceneName;
}

View File

@ -1,9 +1,9 @@
using UnityEngine;
using System.Collections;
namespace Passer {
using Passer;
public class ControllerDebugger : MonoBehaviour {
public class ControllerDebugger : MonoBehaviour {
[System.Serializable]
public struct ControllerSideDebugger {
@ -30,14 +30,14 @@ namespace Passer {
private Controller controller;
private void Start() {
private void Start () {
controller = Controllers.GetController(0);
left.buttons = new bool[4];
right.buttons = new bool[4];
}
private void Update() {
private void Update () {
UpdateSide(ref left, controller.left);
UpdateSide(ref right, controller.right);
}
@ -63,6 +63,4 @@ namespace Passer {
sideDebugger.option = controllerSide.option;
}
}
}

View File

@ -62,11 +62,9 @@ namespace Passer {
public float leftStickVertical { get { return controller.left.stickVertical; } }
public float leftStickHorizontal { get { return controller.left.stickHorizontal; } }
public bool leftStickPressed { get { return controller.left.stickButton; } }
public float leftTouchpadVertical { get { return controller.left.touchpadVertical; } }
public float leftTouchpadHorizontal { get { return controller.left.touchpadHorizontal; } }
public bool leftTouchpadPressed { get { return controller.left.touchpadPress; } }
public float leftTrigger1 { get { return controller.left.trigger1; } }
public bool leftTrigger1Touched { get { return controller.left.trigger1 > 0; } }
@ -83,11 +81,9 @@ namespace Passer {
public float rightStickVertical { get { return controller.right.stickVertical; } }
public float rightStickHorizontal { get { return controller.right.stickHorizontal; } }
public bool rightStickPressed { get { return controller.right.stickButton; } }
public float rightTouchpadVertical { get { return controller.right.touchpadVertical; } }
public float rightTouchpadHorizontal { get { return controller.right.touchpadHorizontal; } }
public bool rightTouchpadPressed { get { return controller.right.touchpadPress; } }
public float rightTrigger1 { get { return controller.right.trigger1; } }
public bool rightTrigger1Touched { get { return controller.right.trigger1 > 0; } }

View File

@ -229,11 +229,7 @@ namespace Passer {
damper = -velocityTowardsTarget * damping;
//Compensate for absolute rigidbody speed (specifically when on a moving platform)
#if UNITY_6000_0_OR_NEWER
Vector3 residualVelocity = thisRigidbody.linearVelocity - velocityTowardsTarget;
#else
Vector3 residualVelocity = thisRigidbody.velocity - velocityTowardsTarget;
#endif
damper += residualVelocity * 10;
}
lastDistanceToTarget = distanceToTarget;
@ -324,34 +320,7 @@ namespace Passer {
Vector3 tmp = Vector3.Cross(a, b).normalized;
return tmp;
}
/// <summary>
/// Rotates a rigibogy to the desired rotation.
/// See: https://digitalopus.ca/site/pd-controllers/
/// </summary>
/// <param name="rb">The rigidbody to rotate</param>
/// <param name="desiredRotation">The orientation which is desired</param>
/// <param name="frequency">The speed to reach the desired rotation, duration is approximate 1/frequency</param>
/// <param name="damping">1 = critical damped, < 1 under damped, > 1 over damped </param>
public static void ApplyTorqueBackwardsPD(Rigidbody rb, Quaternion desiredRotation, float frequency = 1, float damping = 1) {
float kp = (6f * frequency) * (6f * frequency) * 0.25f;
float kd = 4.5f * frequency * damping;
Vector3 x;
float xMag;
Quaternion q = desiredRotation * Quaternion.Inverse(rb.transform.rotation);
q.ToAngleAxis(out xMag, out x);
x.Normalize();
x *= Mathf.Deg2Rad;
Vector3 pidv = kp * x * xMag - kd * rb.angularVelocity;
Quaternion rotInertia2World = rb.inertiaTensorRotation * rb.transform.rotation;
pidv = Quaternion.Inverse(rotInertia2World) * pidv;
pidv.Scale(rb.inertiaTensor);
pidv = rotInertia2World * pidv;
rb.AddTorque(pidv);
}
#endregion Torque
#endregion
#region Utilities
@ -413,14 +382,6 @@ namespace Passer {
UnsetCollidersToTrigger(colliders);
}
public static void SetNonKinematic(Rigidbody rigidbody, List<Collider> colliders) {
if (rigidbody == null)
return;
rigidbody.isKinematic = false;
UnsetCollidersToTrigger(colliders);
}
/// <summary>
/// Switches this Rigidbody to Hybrid Kinematic Mode
/// </summary>
@ -465,16 +426,6 @@ namespace Passer {
return changedColliders;
}
public static List<Collider> SetKinematic(Rigidbody rigidbody) {
if (rigidbody == null)
return new List<Collider>();
rigidbody.isKinematic = true;
Collider[] colliders = rigidbody.GetComponentsInChildren<Collider>();
List<Collider> changedColliders = SetCollidersToTrigger(rigidbody, colliders);
return changedColliders;
}
#endregion
#region Colliders
@ -585,11 +536,9 @@ namespace Passer {
if (colliders == null)
return;
foreach (Collider c in colliders) {
if (c != null)
foreach (Collider c in colliders)
c.isTrigger = false;
}
}
/// <summary>
/// Switches the Rigidbody to Non-Kinematic mode.
@ -603,11 +552,9 @@ namespace Passer {
if (colliders == null)
return;
foreach (Collider c in colliders) {
if (c != null)
foreach (Collider c in colliders)
c.isTrigger = false;
}
}
#endregion

View File

@ -30,13 +30,8 @@ namespace Passer {
public void CopyFromRigidbody(Rigidbody rb) {
mass = rb.mass;
#if UNITY_6000_0_OR_NEWER
drag = rb.linearDamping;
angularDrag = rb.angularDamping;
#else
drag = rb.drag;
angularDrag = rb.angularDrag;
#endif
useGravity = rb.useGravity;
isKinematic = rb.isKinematic;
interpolation = rb.interpolation;
@ -49,13 +44,8 @@ namespace Passer {
public void CopyToRigidbody(Rigidbody rb) {
rb.mass = mass;
#if UNITY_6000_0_OR_NEWER
rb.linearDamping = drag;
rb.angularDamping = angularDrag;
#else
rb.drag = drag;
rb.angularDrag = angularDrag;
#endif
rb.useGravity = useGravity;
rb.isKinematic = isKinematic;
rb.interpolation = interpolation;

View File

@ -78,38 +78,6 @@ namespace Passer {
return newRotation1;
}
public static void ToSwingTwist(this Quaternion q, Vector3 twistAxis, out Quaternion swing, out Quaternion twist) {
Vector3 r = new Vector3(q.x, q.y, q.z);
// singularity: rotation by 180 degree
if (r.sqrMagnitude < Mathf.Epsilon) {
Vector3 rotatedTwistAxis = q * twistAxis;
Vector3 swingAxis =
Vector3.Cross(twistAxis, rotatedTwistAxis);
if (swingAxis.sqrMagnitude > Mathf.Epsilon) {
float swingAngle =
Vector3.Angle(twistAxis, rotatedTwistAxis);
swing = Quaternion.AngleAxis(swingAngle, swingAxis);
}
else {
// more singularity:
// rotation axis parallel to twist axis
swing = Quaternion.identity; // no swing
}
// always twist 180 degree on singularity
twist = Quaternion.AngleAxis(180.0f, twistAxis);
return;
}
// meat of swing-twist decomposition
Vector3 p = Vector3.Project(r, twistAxis);
twist = new Quaternion(p.x, p.y, p.z, q.w);
twist = Quaternion.Normalize(twist);
swing = q * Quaternion.Inverse(twist);
}
}
public static class Vectors {
@ -142,4 +110,93 @@ namespace Passer {
}
}
//public class RigidbodyData {
// public float mass = 1;
// public float drag;
// public float angularDrag = 0.05F;
// public bool useGravity = true;
// public bool isKinematic;
// public RigidbodyInterpolation interpolation = RigidbodyInterpolation.None;
// public CollisionDetectionMode collisionDetectionMode = CollisionDetectionMode.Discrete;
// public RigidbodyConstraints constraints = RigidbodyConstraints.None;
// public Transform parent;
// public RigidbodyData(Rigidbody rb) {
// mass = rb.mass;
// drag = rb.drag;
// angularDrag = rb.angularDrag;
// useGravity = rb.useGravity;
// isKinematic = rb.isKinematic;
// interpolation = rb.interpolation;
// collisionDetectionMode = rb.collisionDetectionMode;
// constraints = rb.constraints;
// parent = rb.transform.parent;
// }
// public void CopyToRigidbody(Rigidbody rb) {
// rb.mass = mass;
// rb.drag = drag;
// rb.angularDrag = angularDrag;
// rb.useGravity = useGravity;
// rb.isKinematic = isKinematic;
// rb.interpolation = interpolation;
// rb.collisionDetectionMode = collisionDetectionMode;
// rb.constraints = constraints;
// rb.transform.parent = parent;
// }
// public static RigidbodyData ParentRigidbody(Transform parentTransform, Rigidbody childRigidbody) {
// RigidbodyData rigidbodyData = new RigidbodyData(childRigidbody);
// childRigidbody.transform.parent = parentTransform;
// if (Application.isPlaying)
// Object.Destroy(childRigidbody);
// else
// Object.DestroyImmediate(childRigidbody, true);
// return rigidbodyData;
// }
// public static RigidbodyData ParentRigidbody(Rigidbody parentRigidbody, Rigidbody childRigidbody) {
// RigidbodyData rigidbodyData = new RigidbodyData(childRigidbody);
// childRigidbody.transform.parent = parentRigidbody.transform;
// parentRigidbody.mass += childRigidbody.mass;
// if (Application.isPlaying)
// Object.Destroy(childRigidbody);
// else
// Object.DestroyImmediate(childRigidbody, true);
// return rigidbodyData;
// }
// public Rigidbody UnparentRigidbody(Transform parentTransform, Transform childRigidbodyTransform) {
// Rigidbody childRigidbody = childRigidbodyTransform.GetComponent<Rigidbody>();
// if (!childRigidbodyTransform.gameObject.isStatic && childRigidbody == null) {
// childRigidbody = childRigidbodyTransform.gameObject.AddComponent<Rigidbody>();
// CopyToRigidbody(childRigidbody);
// }
// childRigidbody.transform.parent = null;
// // To do: copy velocity of parent to child
// return childRigidbody;
// }
// public Rigidbody UnparentRigidbody(Rigidbody parentRigidbody, Transform childRigidbodyTransform) {
// Rigidbody childRigidbody = childRigidbodyTransform.GetComponent<Rigidbody>();
// if (!childRigidbodyTransform.gameObject.isStatic && childRigidbody == null) {
// childRigidbody = childRigidbodyTransform.gameObject.AddComponent<Rigidbody>();
// CopyToRigidbody(childRigidbody);
// }
// parentRigidbody.mass -= childRigidbody.mass;
// // To do: copy velocity of parent to child
// return childRigidbody;
// }
//}
}

View File

@ -46,17 +46,13 @@ namespace Passer.Humanoid {
}
}
protected void Awake() {
#if UNITY_6000_0_OR_NEWER
HumanoidControl humanoid = Object.FindAnyObjectByType<HumanoidControl>();
#else
private void Awake() {
HumanoidControl humanoid = FindObjectOfType<HumanoidControl>();
#endif
if (humanoid == null)
return;
Vector3 humanoidXZ = new(humanoid.transform.position.x, 0, humanoid.transform.position.z);
Vector3 thisXZ = new(this.transform.position.x, 0, this.transform.position.z);
Vector3 humanoidXZ = new Vector3(humanoid.transform.position.x, 0, humanoid.transform.position.z);
Vector3 thisXZ = new Vector3(this.transform.position.x, 0, this.transform.position.z);
float distance = Vector3.Distance(humanoidXZ, thisXZ);
if (distance < radius || isFree)
humanoid.transform.MoveTo(this.transform.position);

View File

@ -121,10 +121,8 @@ namespace Passer {
focusing = true;
return;
}
else
ProcessFocus();
}
if (!clicking) { // first activation
touchedObject = data.pointerCurrentRaycast.gameObject;
if (touchedObject == null) // object is a 3D object, as we do not use Physicsraycaster, use the focusObject
@ -256,11 +254,7 @@ namespace Passer {
if (pointers == null)
pointers = new InteractionPointer[maxInteractions]; // 0 = left index, 1 = right index, 2 = head, 3 = controller
#if UNITY_6000_0_OR_NEWER
EventSystem eventSystem = FindAnyObjectByType<EventSystem>();
#else
EventSystem eventSystem = GameObject.FindObjectOfType<EventSystem>();
#endif
if (eventSystem == null)
eventSystem = humanoid.gameObject.AddComponent<EventSystem>();
@ -350,7 +344,7 @@ namespace Passer {
pointer.ProcessTouch();
}
#endregion
#endregion
public Vector3 GetFocusPoint(int inputDeviceID) {
return pointers[inputDeviceID].focusPosition;
@ -534,15 +528,18 @@ namespace Passer {
if (Camera.main == null || pointer.type != PointerType.Touch)
return;
//if (eventSystem == null)
// eventSystem = Object.FindObjectOfType<EventSystem>();
//if (eventSystem == null)
// return;
pointer.data.position = Camera.main.WorldToScreenPoint(pointer.pointerTransform.position);
float distanceToPointer = Vector3.Distance(Camera.main.transform.position, pointer.pointerTransform.position);
System.Collections.Generic.List<RaycastResult> m_RaycastResultCache = new System.Collections.Generic.List<RaycastResult>();
eventSystem.RaycastAll(pointer.data, m_RaycastResultCache);
RaycastResult raycastResult = FindFirstRaycast(m_RaycastResultCache, distanceToPointer);
RaycastResult raycastResult = FindFirstRaycast(m_RaycastResultCache);
m_RaycastResultCache.Clear();
if (raycastResult.gameObject != null) {
if (pointer.type == PointerType.Touch) {
float distance = DistanceTipToTransform(pointer.pointerTransform, raycastResult.gameObject.transform);
@ -562,15 +559,11 @@ namespace Passer {
}
}
private RaycastResult FindFirstRaycast(System.Collections.Generic.List<RaycastResult> raycastResults, float pointerDistance) {
private new RaycastResult FindFirstRaycast(System.Collections.Generic.List<RaycastResult> raycastResults) {
foreach (RaycastResult result in raycastResults) {
float resultDistance = Vector3.Distance(Camera.main.transform.position, result.worldPosition);
if (result.isValid &&
result.worldPosition != Vector3.zero &&
Mathf.Abs(resultDistance - pointerDistance) < 0.02F) {
if (result.isValid)
return result;
}
}
return new RaycastResult();
}
@ -586,6 +579,7 @@ namespace Passer {
}
private float DistanceTipToTransform(Transform fingerTip, Transform transform) {
//Debug.DrawLine(fingerTip.position, transform.position);
return (-transform.InverseTransformPoint(fingerTip.position).z * transform.lossyScale.z) - 0.01F;
}
}

View File

@ -224,11 +224,7 @@ namespace Passer {
protected virtual void Awake() {
Transform rootTransform = this.transform.root;
#if UNITY_6000_0_OR_NEWER
interactionModule = FindAnyObjectByType<InteractionModule>();
#else
interactionModule = FindObjectOfType<InteractionModule>();
#endif
if (interactionModule == null)
interactionModule = CreateInteractionModule();
EventSystem eventSystem = interactionModule.GetComponent<EventSystem>();
@ -589,11 +585,7 @@ namespace Passer {
if (rayType != RayType.Gravity)
return;
#if UNITY_6000_0_OR_NEWER
rigidbody.linearVelocity = transform.forward * speed;
#else
rigidbody.velocity = transform.forward * speed;
#endif
}
public void LaunchPrefab(GameObject prefab) {
@ -646,7 +638,7 @@ namespace Passer {
};
protected GameObject previousObjectInFocus;
protected virtual void UpdateFocus() {
protected void UpdateFocus() {
focusEvent.value = objectInFocus;
if (objectInFocus != previousObjectInFocus) {

View File

@ -658,7 +658,7 @@ namespace Passer {
}
Handle handle = attachedHandle;
Handle handle = attachedHandle; // attachedTransform.GetComponentInChildren<Handle>();
if (handle != null) {
handle.socket = null;
}
@ -672,7 +672,7 @@ namespace Passer {
}
// Released objects should be gone within 1 second or they will be reattached
protected IEnumerator ClearReleasingTransform() {
private IEnumerator ClearReleasingTransform() {
yield return new WaitForSeconds(1);
this.releasingTransform = null;
}
@ -694,11 +694,7 @@ namespace Passer {
Humanoid.HumanoidNetworking.ReenableNetworkSync(objRigidbody.gameObject);
if (thisRigidbody != null) {
#if UNITY_6000_0_OR_NEWER
objRigidbody.linearVelocity = thisRigidbody.linearVelocity;
#else
objRigidbody.velocity = thisRigidbody.velocity;
#endif
objRigidbody.angularVelocity = thisRigidbody.angularVelocity;
}
@ -765,7 +761,7 @@ namespace Passer {
}
}
#endregion Rigidbody
#endregion Rigidbody
#region Static Object
@ -811,7 +807,7 @@ namespace Passer {
#endregion Static Object
#endregion Release
#endregion Release
#region Start

View File

@ -54,11 +54,7 @@ namespace Passer {
if (spawnPoints != null && spawnPoints.Length > 0)
return;
#if UNITY_6000_0_OR_NEWER
spawnPoints = FindObjectsByType<SpawnPoint>(FindObjectsSortMode.None);
#else
spawnPoints = FindObjectsOfType<SpawnPoint>();
#endif
if (spawnPoints.Length == 0) {
SpawnPoint thisSpawnPoint = this.gameObject.AddComponent<SpawnPoint>();
spawnPoints = new SpawnPoint[] { thisSpawnPoint };

View File

@ -1,17 +1,18 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Passer {
public class ShowVisitorName : MonoBehaviour {
public class ShowVisitorName : MonoBehaviour
{
// Start is called before the first frame update
void Start() {
void Start()
{
}
// Update is called once per frame
void Update() {
void Update()
{
}
}
}

View File

@ -1,12 +1,8 @@
using UnityEngine;
namespace Passer {
public class ToggleActive : MonoBehaviour {
public class ToggleActive : MonoBehaviour {
// Temporary helper script to implement toggling the gameobject active state
public void Toggle() {
this.gameObject.SetActive(!this.gameObject.activeSelf);
}
}
}

View File

@ -1,4 +1,6 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Passer {
@ -16,7 +18,7 @@ namespace Passer {
this.site = site;
}
protected void OnEnable() {
private void OnEnable() {
if (site == null)
return;
@ -26,11 +28,7 @@ namespace Passer {
}
private void GoToSite() {
#if UNITY_6000_0_OR_NEWER
SiteNavigator siteNavigator = FindAnyObjectByType<SiteNavigator>();
#else
SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>();
#endif
if (siteNavigator == null) {
Debug.LogError("Could not find a site navigator");
return;

View File

@ -150,11 +150,7 @@ namespace Passer {
}
protected void ShowSite(VisitorSites.Site site, int position) {
#if UNITY_6000_0_OR_NEWER
SiteNavigator siteNavigator = FindAnyObjectByType<SiteNavigator>();
#else
SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>();
#endif
if (siteNavigator == null)
Debug.LogError("Could not find a site navigator");
@ -214,7 +210,7 @@ namespace Passer {
}
#endregion
#endregion
public void AddSite(string siteName, string siteLocation) {
//Debug.Log("Add site " + siteName);
@ -237,11 +233,7 @@ namespace Passer {
}
private void GoToSite(VisitorSites.Site site) {
#if UNITY_6000_0_OR_NEWER
SiteNavigator siteNavigator = FindAnyObjectByType<SiteNavigator>();
#else
SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>();
#endif
if (siteNavigator == null) {
Debug.LogError("Could not find a site navigator");
return;

View File

@ -406,11 +406,7 @@ namespace Passer {
if (avatarIndex < 0 || avatarIndex > avatars.Count)
return;
#if UNITY_6000_0_OR_NEWER
HumanoidControl humanoid = FindAnyObjectByType<HumanoidControl>();
#else
HumanoidControl humanoid = FindObjectOfType<HumanoidControl>();
#endif
if (humanoid == null)
return;
@ -424,11 +420,7 @@ namespace Passer {
}
private static IEnumerator RetrieveAvatarAsync(Possession possession) {
#if UNITY_6000_0_OR_NEWER
HumanoidControl humanoid = FindAnyObjectByType<HumanoidControl>();
#else
HumanoidControl humanoid = FindObjectOfType<HumanoidControl>();
#endif
if (humanoid == null)
yield break;

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More