Skip to content

Commit

Permalink
Merge pull request #29 from stereolabs/RC2.7
Browse files Browse the repository at this point in the history
Update 2.7
  • Loading branch information
obraun-sl committed Oct 24, 2018
2 parents 296dbc6 + 9105cc1 commit 2fa34e4
Show file tree
Hide file tree
Showing 13 changed files with 523 additions and 83 deletions.
24 changes: 19 additions & 5 deletions ZEDCamera/Assets/ZED/Doc/ReleaseNotes.md
@@ -1,15 +1,29 @@

<!------------------------- Release notes ------------------------------------->
### 2.7.0

* **Features**:
- Added toggle box to reveal a camera rig used for final HMD output, normally hidden, for advanced users
- Added toggle boxes for the fade-in effect when the ZED initializes, and setting the ZED rig Gameobject to "DontDestroyOnLoad" on start


* **Bug Fixes**:
- Fixed Rift/Vive controller drift when using ZED's tracking instead of the HMD's
- Changed the previously hard-coded layers the ZED plugin used (8-11) to be adjusted in the Inspector, and set them to 28-31 by default
- Changed greenscreen config file loading so that it will work in a build when placed in a Resources folder, and changed default save path accordingly
- Clarified error messages from playing SVOs in loop mode with tracking enabled


* **Compatibility**:
- Compatible with ZED SDK 2.7, CUDA 9.0 or 10.0.


### 2.6.0
* **Features/Bug Fixes**:
- Add WindowsMR support through SteamVR Only (Beta).
- Fixed overwriting old mesh textures when Spatial mapping button is used while Save Mesh is checked.
- Forced pause state to false when starting a new mapping in case it's been left in a pause state from a previous mapping.
- Forced pasue state to false when stating a scan in case it's been left in a pause state from a previous scan.
- Fixed restart (not) required when changing post-processing settings.
- Fixed repetitve UI error when not using plugin in VR mode in ZEDControllerTracker.cs. [issue #21 reported on github].
- Simplified changing near and far planes in camera projection matrix.
- Fixed error messages when a wrong SVO path was provided for record or read.
- Fixed repetitve UI error when not using plugin in VR mode in ZEDControllerTracker.cs. [ssue #21 reported on github].


* **Documentation**:
Expand Down
158 changes: 150 additions & 8 deletions ZEDCamera/Assets/ZED/Editor/Scripts/ZEDCameraEditor.cs
Expand Up @@ -13,17 +13,28 @@ public class ZEDCameraEditor : Editor
/// <summary>
/// Reference to the ZEDManager instance we're editing.
/// </summary>
ZEDManager manager;
ZEDManager manager;

//Store copies of ZEDManager's fields to detect changes later with CheckChange().
//These do not need to be SerializedProperties because they're only used for checking recent changes.
sl.RESOLUTION resolution;
sl.DEPTH_MODE depthmode;
bool usespatialmemory;
bool usedepthocclusion = true;
bool usepostprocessing = true;
bool usedepthocclusion;
bool usepostprocessing;

bool restartneeded = false;


SerializedProperty showadvanced; //Show advanced settings or not.

SerializedProperty lefteyelayer;
SerializedProperty righteyelayer;
SerializedProperty lefteyelayerfinal;
SerializedProperty righteyelayerfinal;

SerializedProperty showarrig;
SerializedProperty fadeinonstart;
SerializedProperty dontdestroyonload;

private void OnEnable()
{
Expand All @@ -34,11 +45,23 @@ private void OnEnable()
usespatialmemory = manager.enableSpatialMemory;
usedepthocclusion = manager.depthOcclusion;
usepostprocessing = manager.postProcessing;

showadvanced = serializedObject.FindProperty("advancedPanelOpen");

showarrig = serializedObject.FindProperty("showarrig");

lefteyelayer = serializedObject.FindProperty("lefteyelayer");
righteyelayer = serializedObject.FindProperty("righteyelayer");
lefteyelayerfinal = serializedObject.FindProperty("lefteyelayerfinal");
righteyelayerfinal = serializedObject.FindProperty("righteyelayerfinal");

fadeinonstart = serializedObject.FindProperty("fadeInOnStart");
dontdestroyonload = serializedObject.FindProperty("dontDestroyOnLoad");
}

public override void OnInspectorGUI()
{
DrawDefaultInspector(); //Draws what you'd normally see in the inspector in absense of a custom inspector.
DrawDefaultInspector(); //Draws what you'd normally see in the inspector in absence of a custom inspector.

if(GUI.changed)
{
Expand Down Expand Up @@ -72,13 +95,132 @@ public override void OnInspectorGUI()
}
}

GUIStyle standardStyle = new GUIStyle(EditorStyles.textField);
GUIStyle errorStyle = new GUIStyle(EditorStyles.textField);
errorStyle.normal.textColor = Color.red;

//Advanced Settings.
GUILayout.Space(10);
GUIStyle boldfoldout = new GUIStyle(EditorStyles.foldout);
boldfoldout.fontStyle = FontStyle.Bold;
showadvanced.boolValue = EditorGUILayout.Foldout(showadvanced.boolValue, "Advanced Settings", boldfoldout);
if(showadvanced.boolValue)
{
EditorGUI.indentLevel++;

GUILayout.Space(5);
EditorGUILayout.LabelField("ZED Plugin Layers", EditorStyles.boldLabel);

//Style for the number boxes.
GUIStyle layerboxstyle = new GUIStyle(EditorStyles.numberField);
layerboxstyle.fixedWidth = 0;
layerboxstyle.stretchWidth = false;
layerboxstyle.alignment = TextAnchor.MiddleCenter;

GUIStyle layerboxstyleerror = new GUIStyle(layerboxstyle);
layerboxstyleerror.normal.textColor = new Color(.8f, 0, 0); //Red color if number is invalid.


GUIContent lefteyelayerlabel = new GUIContent("Left Eye Layer", "Layer that the left canvas GameObject " +
"(showing the image from the left eye) is set to. The right camera in ZED_Rig_Stereo can't see this layer.");
lefteyelayer.intValue = EditorGUILayout.IntField(lefteyelayerlabel, manager.leftEyeLayer,
lefteyelayer.intValue < 32 ? layerboxstyle : layerboxstyleerror);

GUIContent righteyelayerlabel = new GUIContent("Right Eye Layer", "Layer that the right canvas GameObject " +
"(showing the image from the right eye) is set to. The left camera in ZED_Rig_Stereo can't see this layer.");
righteyelayer.intValue = EditorGUILayout.IntField(righteyelayerlabel, manager.rightEyeLayer,
righteyelayer.intValue < 32 ? layerboxstyle : layerboxstyleerror);

//Cache current final layers in case we need to unhide their old layers.
int oldleftfinal = manager.leftEyeLayerFinal;
int oldrightfinal = manager.rightEyeLayerFinal;

GUIContent lefteyefinallayerlabel = new GUIContent("Final Left Eye Layer", "Layer that the final left image canvas "
+ "in the hidden AR rig is set to. Hidden from all ZED cameras except the final left camera.");
lefteyelayerfinal.intValue = EditorGUILayout.IntField(lefteyefinallayerlabel, manager.leftEyeLayerFinal,
lefteyelayerfinal.intValue < 32 ? layerboxstyle : layerboxstyleerror);

GUIContent righteyefinallayerlabel = new GUIContent("Final Right Eye Layer", "Layer that the final right image canvas "
+ "in the hidden AR rig is set to. Hidden from all ZED cameras except the final right camera.");
righteyelayerfinal.intValue = EditorGUILayout.IntField(righteyefinallayerlabel, manager.rightEyeLayerFinal,
righteyelayerfinal.intValue < 32 ? layerboxstyle : layerboxstyleerror);

//If either final eye layer changed, make sure the old layer is made visible.
if (oldleftfinal != lefteyelayerfinal.intValue)
{
Tools.visibleLayers |= (1 << oldleftfinal);
if (manager.showARRig) Tools.visibleLayers |= (1 << lefteyelayerfinal.intValue);
else Tools.visibleLayers &= ~(1 << lefteyelayerfinal.intValue);
}
if (oldrightfinal != righteyelayerfinal.intValue)
{
Tools.visibleLayers |= (1 << oldrightfinal);
if (manager.showARRig) Tools.visibleLayers |= (1 << righteyelayerfinal.intValue);
else Tools.visibleLayers &= ~(1 << righteyelayerfinal.intValue);
}

//Show small error message if any of the above values are too big.
if(lefteyelayer.intValue > 31 || righteyelayer.intValue > 31 || lefteyelayerfinal.intValue > 31 || righteyelayerfinal.intValue > 31)
{
GUIStyle errormessagestyle = new GUIStyle(EditorStyles.label);
errormessagestyle.normal.textColor = layerboxstyleerror.normal.textColor;
errormessagestyle.wordWrap = true;
errormessagestyle.fontSize = 10;

string errortext = "Unity doesn't support layers above 31.";
Rect labelrect = GUILayoutUtility.GetRect(new GUIContent(errortext, ""), errormessagestyle);
EditorGUI.LabelField(labelrect, errortext, errormessagestyle);
}


GUILayout.Space(7);

EditorGUILayout.LabelField("Miscellaneous", EditorStyles.boldLabel);

//Show AR Rig toggle.
GUIContent showarlabel = new GUIContent("Show Final AR Rig", "Whether to show the hidden camera rig used in stereo AR mode to " +
"prepare images for HMD output. You normally shouldn't tamper with this rig, but seeing it can be useful for " +
"understanding how the ZED output works.");
bool lastshowar = manager.showARRig;
showarrig.boolValue = EditorGUILayout.Toggle(showarlabel, manager.showARRig);

if (showarrig.boolValue != lastshowar)
{
LayerMask arlayers = (1 << manager.leftEyeLayerFinal);
arlayers |= (1 << manager.rightEyeLayerFinal);

if (showarrig.boolValue == true)
{
Tools.visibleLayers |= arlayers;
}
else
{
Tools.visibleLayers &= ~(arlayers);
}

if (manager.zedRigDisplayer != null && Application.isPlaying)
{
manager.zedRigDisplayer.hideFlags = showarrig.boolValue ? HideFlags.None : HideFlags.HideAndDontSave;
}
}

//Fade In At Start toggle.
GUIContent fadeinlabel = new GUIContent("Fade In At Start", "When enabled, makes the ZED image fade in from black when the application starts.");
fadeinonstart.boolValue = EditorGUILayout.Toggle(fadeinlabel, manager.fadeInOnStart);

//Don't Destroy On Load toggle.
GUIContent dontdestroylable = new GUIContent("Don't Destroy on Load", "When enabled, applies DontDestroyOnLoad() on the ZED rig in Awake(), " +
"preserving it between scene transitions.");
dontdestroyonload.boolValue = EditorGUILayout.Toggle(dontdestroylable, manager.dontDestroyOnLoad);

EditorGUI.indentLevel--;
}
serializedObject.ApplyModifiedProperties();

//Status window.
GUIStyle standardStyle = new GUIStyle(EditorStyles.textField);
GUIStyle errorStyle = new GUIStyle(EditorStyles.textField);
errorStyle.normal.textColor = Color.red;


GUILayout.Space(10);
EditorGUILayout.LabelField("Status", EditorStyles.boldLabel);
EditorGUI.BeginDisabledGroup(true);

Expand Down
Expand Up @@ -227,7 +227,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 093ceb9e77bac7a4ea5ec3013f638a87, type: 3}
m_Name:
m_EditorClassIdentifier:
SecondsToDisplayEffect: 1
secondsToDisplayEffect: 1
--- !u!135 &78578991
SphereCollider:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -599,6 +599,16 @@ Prefab:
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 114228649437443144, guid: d0ab09dfdb72e614aadbc6e474b9bc3e,
type: 2}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114575857264643554, guid: d0ab09dfdb72e614aadbc6e474b9bc3e,
type: 2}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: d0ab09dfdb72e614aadbc6e474b9bc3e, type: 2}
m_IsPrefabParent: 0
Expand Down Expand Up @@ -974,7 +984,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
resolution: 2
depthMode: 1
enableTracking: 0
enableTracking: 1
enableSpatialMemory: 0
pathSpatialMemory:
depthOcclusion: 1
Expand Down
Expand Up @@ -90,7 +90,7 @@ IEnumerator Start()
int children = transform.childCount;
for (int i = 0; i < children; ++i)
transform.GetChild(i).gameObject.SetActive(false);
this.enabled = false;
//this.enabled = false;
}
else
{
Expand Down Expand Up @@ -121,7 +121,7 @@ IEnumerator Start()
for (int i = 0; i < children; ++i)
transform.GetChild(i).gameObject.SetActive(false);

this.enabled = false;
//this.enabled = false;
yield break;
}
}
Expand Down Expand Up @@ -169,8 +169,24 @@ void Update ()

#if ZED_OCULUS

//We're controlling the fire Rate OVRInput doesn't have a GetDown function for the IndexTrigger. Only an axis output.
//Update whether the Touch controllers are active.
int children = transform.childCount;
if (OVRManager.isHmdPresent)
{
if (OVRInput.GetConnectedControllers().ToString() == "Touch")
{
for (int i = 0; i < children; ++i)
transform.GetChild(i).gameObject.SetActive(true);

}
else
{
for (int i = 0; i < children; ++i)
transform.GetChild(i).gameObject.SetActive(false);
}
}

//We're controlling the fire Rate. OVRInput doesn't have a GetDown function for the IndexTrigger. Only an axis output.
if (objecttracker != null)
{
if (OVRInput.GetConnectedControllers().ToString() == "Touch")
Expand Down
Expand Up @@ -158,7 +158,7 @@ private void Update()
}
#elif ZED_OCULUS
//Check if a Controller is tracked.
if ((int)trackedObj.deviceToTrack == 0)
if ((int)tracker.deviceToTrack == 0)
{
//Oculus Touch Triggers aren't of Button type, but Axis.
//So we have to create our own state for this Input, based on sensitivity from 0 to 1.
Expand Down Expand Up @@ -186,7 +186,7 @@ private void Update()
}
}

if ((int)trackedObj.deviceToTrack == 1)
if ((int)tracker.deviceToTrack == 1)
{
if (OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, OVRInput.Controller.LTouch) > 0.5f)
{
Expand Down

0 comments on commit 2fa34e4

Please sign in to comment.