Skip to content

Commit

Permalink
Added orientation. Fixed negative rotation or orientation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Barbelot committed Aug 28, 2020
1 parent eae8557 commit df92641
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 16 deletions.
11 changes: 9 additions & 2 deletions Assets/Prefab/DebugPoint.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ MeshRenderer:
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
Expand All @@ -81,6 +82,7 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!65 &5889586618647902927
BoxCollider:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -141,6 +143,7 @@ MeshRenderer:
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
Expand All @@ -165,6 +168,7 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!102 &102360146734640142
TextMesh:
serializedVersion: 3
Expand Down Expand Up @@ -246,6 +250,7 @@ MeshRenderer:
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
Expand All @@ -270,6 +275,7 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &1885169814117324
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -357,7 +363,6 @@ MonoBehaviour:
orientationMaterial: {fileID: 2100000, guid: 7ac04779c33b2a54f9d75c6734cc65a5, type: 2}
velocityColor: {r: 0, g: 0.6636367, b: 1, a: 1}
orientationColor: {r: 1, g: 0.60341847, b: 0, a: 1}
rotationSpeed: 0.1
vectorThickness: 0.03
vectorDefaultMagnitude: 0.5
textScaleMultiplier: 0.01
Expand All @@ -379,7 +384,7 @@ MonoBehaviour:
movementNoiseFrequency: 20
rotationNoiseAmplitude: 0
rotationNoiseFrequency: 20
speedThresholdForOrientation: 1
speedThresholdForOrientation: 0.5
isIncorrectDetection: 0
isFlickering: 0
--- !u!54 &2776326774191610709
Expand Down Expand Up @@ -453,6 +458,7 @@ MeshRenderer:
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
Expand All @@ -477,6 +483,7 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &4973331371144654101
GameObject:
m_ObjectHideFlags: 0
Expand Down
19 changes: 17 additions & 2 deletions Assets/Scripts/AugmentaSimulation/PointBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class PointBehaviour : MonoBehaviour {
public float rotationNoiseAmplitude = 0;
public float rotationNoiseFrequency = 20;

public float speedThresholdForOrientation = 1;
public float speedThresholdForOrientation = 0.5f;

public bool isIncorrectDetection = false;
public bool isFlickering = false;
Expand All @@ -59,6 +59,8 @@ public class PointBehaviour : MonoBehaviour {

private float _speedAngle;
private float _oldAngle;
private float _oldVelocityMagnitude;
private float _orientationOffset = 0;

#region MonoBehaviour Implementation

Expand Down Expand Up @@ -149,6 +151,8 @@ public void UpdatePoint() {

private void ComputeNormalizedVelocity()
{
_oldVelocityMagnitude = normalizedVelocity.magnitude;

if (_oldPositionIsValid) {
normalizedVelocity = (transform.position - _oldPosition) / Time.deltaTime;
normalizedVelocity = new Vector3(-normalizedVelocity.x / manager.width, 0, normalizedVelocity.z / manager.height);
Expand All @@ -172,7 +176,18 @@ private void UpdateSpeedVisualization() {

private void ComputePointOrientation() {

orientation = Mathf.Lerp(point.transform.localRotation.eulerAngles.z, _speedAngle, normalizedVelocity.magnitude * 5.0f / speedThresholdForOrientation);
if (normalizedVelocity.magnitude >= speedThresholdForOrientation) {
orientation = _speedAngle;
} else {
if(_oldVelocityMagnitude >= speedThresholdForOrientation) {
//Update offset
_orientationOffset = orientation - point.transform.localRotation.eulerAngles.z;
}

orientation = point.transform.localRotation.eulerAngles.z + _orientationOffset;
}

orientation = orientation >= 0 ? orientation : orientation + 360.0f;
}

private void UpdateOrientationVisualization() {
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/AugmentaSimulation/PointManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ private OSCMessage CreateAugmentaObjectMessageV2(string address, GameObject obj)
float pointX = 0.5f + behaviour.transform.position.x / width;
float pointY = 0.5f - behaviour.transform.position.z / height;

float rotation = behaviour.point.transform.localRotation.eulerAngles.z;
float rotation = behaviour.point.transform.localRotation.eulerAngles.z >= 0 ? behaviour.point.transform.localRotation.eulerAngles.z : behaviour.point.transform.localRotation.eulerAngles.z + 360.0f ;

msg.Append(_frameCounter); // Frame number
msg.Append(behaviour.id); // id ex : 42th object to enter stage has id=42
Expand All @@ -949,7 +949,7 @@ private OSCMessage CreateAugmentaObjectMessageV2(string address, GameObject obj)
msg.Append(pointY);
msg.Append(-behaviour.normalizedVelocity.x); // Speed and direction vector (in unit.s-1) (normalized)
msg.Append(-behaviour.normalizedVelocity.z);
msg.Append(45.0f); // Orientation with respect to horizontal axis right (0° = (1,0)), rotate counterclockwise. Estimation of the object orientation from its rotation and velocity
msg.Append(behaviour.orientation); // Orientation with respect to horizontal axis right (0° = (1,0)), rotate counterclockwise. Estimation of the object orientation from its rotation and velocity
msg.Append(pointX); // Bounding box center coord (normalized)
msg.Append(pointY);
msg.Append(behaviour.size.x / width); // Bounding box width (normalized)
Expand Down
3 changes: 2 additions & 1 deletion Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"dependencies": {
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.ide.visualstudio": "2.0.2",
"com.unity.ide.vscode": "1.2.1",
"com.unity.postprocessing": "2.3.0",
"com.unity.textmeshpro": "2.0.1",
"com.unity.textmeshpro": "3.0.1",
"com.unity.ugui": "1.0.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
Expand Down
24 changes: 22 additions & 2 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
"source": "builtin",
"dependencies": {}
},
"com.unity.ide.visualstudio": {
"version": "2.0.2",
"depth": 0,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.ide.vscode": {
"version": "1.2.1",
"depth": 0,
Expand All @@ -27,7 +34,7 @@
"url": "https://packages.unity.com"
},
"com.unity.textmeshpro": {
"version": "2.0.1",
"version": "3.0.1",
"depth": 0,
"source": "registry",
"dependencies": {
Expand All @@ -40,7 +47,8 @@
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.ui": "1.0.0"
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.imgui": "1.0.0"
}
},
"com.unity.modules.ai": {
Expand Down Expand Up @@ -176,6 +184,18 @@
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.uielementsnative": "1.0.0"
}
},
"com.unity.modules.uielementsnative": {
"version": "1.0.0",
"depth": 1,
"source": "builtin",
"dependencies": {
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
}
Expand Down
23 changes: 19 additions & 4 deletions ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ PlayerSettings:
m_StereoRenderingPath: 0
m_ActiveColorSpace: 1
m_MTRendering: 1
mipStripping: 0
numberOfMipsStripped: 0
m_StackTraceTypes: 010000000100000001000000010000000100000001000000
iosShowActivityIndicatorOnLoading: -1
androidShowActivityIndicatorOnLoading: -1
Expand Down Expand Up @@ -111,6 +113,8 @@ PlayerSettings:
switchNVNShaderPoolsGranularity: 33554432
switchNVNDefaultPoolsGranularity: 16777216
switchNVNOtherPoolsGranularity: 16777216
switchNVNMaxPublicTextureIDCount: 0
switchNVNMaxPublicSamplerIDCount: 0
stadiaPresentMode: 0
stadiaTargetFramerate: 0
vulkanNumSwapchainBuffers: 3
Expand All @@ -121,7 +125,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 3.3
bundleVersion: 3.4
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down Expand Up @@ -182,10 +186,10 @@ PlayerSettings:
StripUnusedMeshComponents: 1
VertexChannelCompressionMask: 214
iPhoneSdkVersion: 988
iOSTargetOSVersionString: 10.0
iOSTargetOSVersionString: 11.0
tvOSSdkVersion: 0
tvOSRequireExtendedGameController: 0
tvOSTargetOSVersionString: 10.0
tvOSTargetOSVersionString: 11.0
uIPrerenderedIcon: 0
uIRequiresPersistentWiFi: 0
uIRequiresFullScreen: 1
Expand Down Expand Up @@ -257,6 +261,9 @@ PlayerSettings:
height: 180
banner: {fileID: 0}
androidGamepadSupportLevel: 0
AndroidMinifyWithR8: 0
AndroidMinifyRelease: 0
AndroidMinifyDebug: 0
AndroidValidateAppBundleSize: 1
AndroidAppBundleSizeToValidate: 150
m_BuildTargetIcons:
Expand Down Expand Up @@ -398,12 +405,14 @@ PlayerSettings:
cameraUsageDescription:
locationUsageDescription:
microphoneUsageDescription:
switchNMETAOverride:
switchNetLibKey:
switchSocketMemoryPoolSize: 6144
switchSocketAllocatorPoolSize: 128
switchSocketConcurrencyLimit: 14
switchScreenResolutionBehavior: 2
switchUseCPUProfiler: 0
switchUseGOLDLinker: 0
switchApplicationID: 0x01004b9000490000
switchNSODependencies:
switchTitleNames_0:
Expand Down Expand Up @@ -554,6 +563,7 @@ PlayerSettings:
ps4ShareFilePath:
ps4ShareOverlayImagePath:
ps4PrivacyGuardImagePath:
ps4ExtraSceSysFile:
ps4NPtitleDatPath:
ps4RemotePlayKeyAssignment: -1
ps4RemotePlayKeyMappingDir:
Expand Down Expand Up @@ -596,6 +606,8 @@ PlayerSettings:
ps4disableAutoHideSplash: 0
ps4videoRecordingFeaturesUsed: 0
ps4contentSearchFeaturesUsed: 0
ps4CompatibilityPS5: 0
ps4GPU800MHz: 1
ps4attribEyeToEyeDistanceSettingVR: 0
ps4IncludedModules: []
ps4attribVROutputEnabled: 0
Expand All @@ -615,9 +627,10 @@ PlayerSettings:
webGLAnalyzeBuildSize: 0
webGLUseEmbeddedResources: 0
webGLCompressionFormat: 1
webGLWasmArithmeticExceptions: 0
webGLLinkerTarget: 0
webGLThreadsSupport: 0
webGLWasmStreaming: 0
webGLDecompressionFallback: 0
scriptingDefineSymbols:
1: UNITY_POST_PROCESSING_STACK_V2
4: UNITY_POST_PROCESSING_STACK_V2
Expand All @@ -640,6 +653,7 @@ PlayerSettings:
managedStrippingLevel: {}
incrementalIl2cppBuild: {}
allowUnsafeCode: 0
useDeterministicCompilation: 1
additionalIl2CppArgs:
scriptingRuntimeVersion: 1
gcIncremental: 0
Expand Down Expand Up @@ -727,3 +741,4 @@ PlayerSettings:
enableNativePlatformBackendsForNewInputSystem: 0
disableOldInputManagerSupport: 0
legacyClampBlendShapeWeights: 1
virtualTexturingSupportEnabled: 0
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 2019.4.4f1
m_EditorVersionWithRevision: 2019.4.4f1 (1f1dac67805b)
m_EditorVersion: 2020.1.3f1
m_EditorVersionWithRevision: 2020.1.3f1 (cf5c4788e1d8)
8 changes: 8 additions & 0 deletions ProjectSettings/VersionControlSettings.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!890905787 &1
VersionControlSettings:
m_ObjectHideFlags: 0
m_Mode: Visible Meta Files
m_CollabEditorSettings:
inProgressEnabled: 1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ For the simulator to create a Zeroconf service on Windows, you need to have Appl

## Version

Unity 2019.4.1f1
Unity 2020.1.3f1
19 changes: 19 additions & 0 deletions UserSettings/EditorUserSettings.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!162 &1
EditorUserSettings:
m_ObjectHideFlags: 0
serializedVersion: 4
m_ConfigSettings:
vcSharedLogLevel:
value: 0d5e400f0650
flags: 0
m_VCAutomaticAdd: 1
m_VCDebugCom: 0
m_VCDebugCmd: 0
m_VCDebugOut: 0
m_SemanticMergeMode: 2
m_VCShowFailedCheckout: 1
m_VCOverwriteFailedCheckoutAssets: 1
m_VCOverlayIcons: 1
m_VCAllowAsyncUpdate: 0

0 comments on commit df92641

Please sign in to comment.