1
0
mirror of https://github.com/xiaopeng12138/MaiDXR.git synced 2024-11-24 03:50:10 +01:00

v0.4 update

Add json config fuction
Update new smooth camera display method
Update framework materials
This commit is contained in:
xpeng 2022-01-26 00:03:29 +01:00
parent 638a0c7a60
commit 66f4101943
5 changed files with 112 additions and 60 deletions

View File

@ -455,7 +455,7 @@ Camera:
m_FocalLength: 12
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0.1
x: 0
y: 0
width: 1
height: 1
@ -464,7 +464,7 @@ Camera:
field of view: 90
orthographic: 0
orthographic size: 5
m_Depth: 0
m_Depth: 1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
@ -707,7 +707,7 @@ Camera:
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowMSAA: 0
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
@ -2726,11 +2726,11 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 949242374}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.8799009, y: 0.5712118, z: 0.14460258}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &995594085
GameObject:
@ -3209,6 +3209,54 @@ Transform:
m_Father: {fileID: 747929426}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!1 &1419342721
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1419342723}
- component: {fileID: 1419342722}
m_Layer: 0
m_Name: Settings Manager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1419342722
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1419342721}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5826d7e028a40364c9d0e2514ceeee6b, type: 3}
m_Name:
m_EditorClassIdentifier:
LHandObj: {fileID: 1213452594}
RHandObj: {fileID: 995594085}
ScreenObj: {fileID: 856927129}
SmoothCameraObj: {fileID: 366364277}
XROriginObj: {fileID: 1647048262}
--- !u!4 &1419342723
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1419342721}
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: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1522911141 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 7675345320277832881, guid: ea6463ca199d52046962b69f2ab654ef, type: 3}
@ -3292,50 +3340,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: -90, z: 0}
--- !u!1 &1759784305
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1759784307}
- component: {fileID: 1759784306}
m_Layer: 0
m_Name: JsonManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1759784306
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1759784305}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 516380dd8af0ccd45940ea4a1bb8c942, type: 3}
m_Name:
m_EditorClassIdentifier:
JsonPath:
--- !u!4 &1759784307
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1759784305}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -12.495436, y: -1.1547682, z: -2.1243403}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1900118868
GameObject:
m_ObjectHideFlags: 0

View File

@ -1,6 +1,6 @@
using UnityEngine;
public class CameraFollow : MonoBehaviour {
public class CameraSmooth : MonoBehaviour {
public Transform target;
public float smoothSpeed = 0.125f;

View File

@ -1,12 +1,13 @@
using System.IO;
using UnityEngine;
using Newtonsoft.Json;
using Unity.XR.CoreUtils;
using uWindowCapture;
public class SettingsManager : MonoBehaviour
{
public string JsonPath;
public string JsonStr;
public Settings Setting = new Settings();
string JsonPath;
string JsonStr;
Settings Setting = new Settings();
void Start()
{
JsonPath = Path.GetDirectoryName(Application.dataPath) + "/Settings.json";
@ -16,8 +17,10 @@ public class SettingsManager : MonoBehaviour
Settings Setting = new Settings()
{
HandSize = 8.5f,
//HandPosition = new Vector3(0.01f, -0.02f, 0.06f),
PlayerHigh = 1.7f,
HandPositionX = 1f,
HandPositionY = -2f,
HandPositionZ = 6f,
PlayerHigh = 170f,
CaptureFrameRate = 90,
TouchRefreshRate = 120,
CameraSmooth = 0.1f,
@ -34,16 +37,58 @@ public class SettingsManager : MonoBehaviour
Setting = JsonConvert.DeserializeObject<Settings>(JsonStr);
}
}
bool FocusChecked = true;
void Update()
{
if (Input.GetKeyDown(KeyCode.F5) | !FocusChecked)
{
if (Application.isFocused)
{
FocusChecked=true;
JsonStr = File.ReadAllText(JsonPath);
Setting = JsonConvert.DeserializeObject<Settings>(JsonStr);
UpdateFromFile();
Debug.Log("Setting Updated");
}
}
if (!Application.isFocused)
FocusChecked=false;
}
public GameObject LHandObj;
public GameObject RHandObj;
public GameObject ScreenObj;
public GameObject SmoothCameraObj;
public GameObject XROriginObj;
void UpdateFromFile()
{
LHandObj.transform.localScale = new Vector3(Setting.HandSize/100,Setting.HandSize/100,Setting.HandSize/100);
RHandObj.transform.localScale = new Vector3(Setting.HandSize/100,Setting.HandSize/100,Setting.HandSize/100);
LHandObj.transform.localPosition = new Vector3(Setting.HandPositionX/100,Setting.HandPositionY/100,Setting.HandPositionZ/100);
RHandObj.transform.localPosition = new Vector3(Setting.HandPositionX/-100,Setting.HandPositionY/100,Setting.HandPositionZ/100);
XROrigin XROriginScp = XROriginObj.GetComponent<XROrigin>();
XROriginScp.CameraYOffset = Setting.PlayerHigh;
UwcWindowTexture ScreenScp = ScreenObj.GetComponent<UwcWindowTexture>();
ScreenScp.captureFrameRate = Setting.CaptureFrameRate;
CameraSmooth CameraSmoothScp = SmoothCameraObj.GetComponent<CameraSmooth>();
CameraSmoothScp.smoothSpeed = Setting.CameraSmooth;
Controller LHandScp = LHandObj.GetComponent<Controller>();
LHandScp.amplitude = Setting.HapticAmplitude;
Controller RHandScp = RHandObj.GetComponent<Controller>();
RHandScp.amplitude = Setting.HapticAmplitude;
XROriginScp.CameraYOffset = Setting.PlayerHigh/100;
Time.fixedDeltaTime = 1/Setting.TouchRefreshRate;
}
}
public class Settings
{
public float HandSize { get; set; }
//public Vector3 HandPosition { get; set; }
public float HandPositionX { get; set; }
public float HandPositionY { get; set; }
public float HandPositionZ { get; set; }
public float PlayerHigh { get; set; }
public int CaptureFrameRate { get; set; }
public float TouchRefreshRate { get; set; }

View File

@ -1,6 +1,9 @@
{
"HandSize": 8.5,
"PlayerHigh": 1.7,
"HandPositionX": 1,
"HandPositionY": -2,
"HandPositionZ": 6,
"PlayerHigh": 170,
"CaptureFrameRate": 90,
"TouchRefreshRate": 120.0,
"CameraSmooth": 0.1,