public virtual void PreInitialize(NVRPlayer player) { Player = player; IsRight = Player.RightHand == this; IsLeft = Player.LeftHand == this; CurrentInteractionStyle = Player.InteractionStyle; CurrentlyHoveringOver = new Dictionary <NVRInteractable, Dictionary <Collider, float> >(); LastPositions = new Vector3[EstimationSamples]; LastRotations = new Quaternion[EstimationSamples]; LastDeltas = new float[EstimationSamples]; EstimationSampleIndex = 0; VisibilityLocked = false; Inputs = new Dictionary <NVRButtons, NVRButtonInputs>(new NVRButtonsComparer()); for (int buttonIndex = 0; buttonIndex < NVRButtonsHelper.Array.Length; buttonIndex++) { if (Inputs.ContainsKey(NVRButtonsHelper.Array[buttonIndex]) == false) { Inputs.Add(NVRButtonsHelper.Array[buttonIndex], new NVRButtonInputs()); } } if (Player.CurrentIntegrationType == NVRSDKIntegrations.Oculus) { InputDevice = this.gameObject.AddComponent <NVROculusInputDevice>(); if (Player.OverrideOculus == true) { if (IsLeft) { CustomModel = Player.OverrideOculusLeftHand; CustomPhysicalColliders = Player.OverrideOculusLeftHandPhysicalColliders; } else if (IsRight) { CustomModel = Player.OverrideOculusRightHand; CustomPhysicalColliders = Player.OverrideOculusRightHandPhysicalColliders; } else { Debug.LogError("[NewtonVR] Error: Unknown hand for oculus model override."); } } } else if (Player.CurrentIntegrationType == NVRSDKIntegrations.SteamVR) { InputDevice = this.gameObject.AddComponent <NVRSteamVRInputDevice>(); if (Player.OverrideSteamVR == true) { if (IsLeft) { CustomModel = Player.OverrideSteamVRLeftHand; CustomPhysicalColliders = Player.OverrideSteamVRLeftHandPhysicalColliders; } else if (IsRight) { CustomModel = Player.OverrideSteamVRRightHand; CustomPhysicalColliders = Player.OverrideSteamVRRightHandPhysicalColliders; } else { Debug.LogError("[NewtonVR] Error: Unknown hand for SteamVR model override."); } } } else { //Debug.LogError("[NewtonVR] Critical Error: NVRPlayer.CurrentIntegration not setup."); return; } if (Player.OverrideAll) { if (IsLeft) { CustomModel = Player.OverrideAllLeftHand; CustomPhysicalColliders = Player.OverrideAllLeftHandPhysicalColliders; } else if (IsRight) { CustomModel = Player.OverrideAllRightHand; CustomPhysicalColliders = Player.OverrideAllRightHandPhysicalColliders; } else { Debug.LogError("[NewtonVR] Error: Unknown hand for SteamVR model override."); return; } } InputDevice.Initialize(this); InitializeRenderModel(); }
public virtual void PreInitialize(NVRPlayer player) { Player = player; IsRight = Player.RightHand == this; IsLeft = Player.LeftHand == this; CurrentInteractionStyle = Player.InteractionStyle; CurrentlyHoveringOver = new Dictionary <NVRInteractable, Dictionary <Collider, float> >(); LastPositions = new Vector3[EstimationSamples]; LastRotations = new Quaternion[EstimationSamples]; LastDeltas = new float[EstimationSamples]; EstimationSampleIndex = 0; VisibilityLocked = false; // If we already have an input device attached to this object, use that. if (Player.CurrentIntegrationType == NVRSDKIntegrations.Oculus) { if (Player.OverrideOculus) { if (IsLeft) { CustomModel = Player.OverrideOculusLeftHand; CustomPhysicalColliders = Player.OverrideOculusLeftHandPhysicalColliders; } else if (IsRight) { CustomModel = Player.OverrideOculusRightHand; CustomPhysicalColliders = Player.OverrideOculusRightHandPhysicalColliders; } else { Debug.LogError("[NewtonVR] Error: Unknown hand for oculus model override."); } } } else if (Player.CurrentIntegrationType == NVRSDKIntegrations.SteamVR) { if (Player.OverrideSteamVR) { if (IsLeft) { CustomModel = Player.OverrideSteamVRLeftHand; CustomPhysicalColliders = Player.OverrideSteamVRLeftHandPhysicalColliders; } else if (IsRight) { CustomModel = Player.OverrideSteamVRRightHand; CustomPhysicalColliders = Player.OverrideSteamVRRightHandPhysicalColliders; } else { Debug.LogError("[NewtonVR] Error: Unknown hand for SteamVR model override."); } } } else { Debug.LogError("[NewtonVR] Error: NVRPlayer.CurrentIntegration not setup."); return; } if (Player.OverrideAll) { if (IsLeft) { CustomModel = Player.OverrideAllLeftHand; CustomPhysicalColliders = Player.OverrideAllLeftHandPhysicalColliders; } else if (IsRight) { CustomModel = Player.OverrideAllRightHand; CustomPhysicalColliders = Player.OverrideAllRightHandPhysicalColliders; } else { Debug.LogError("[NewtonVR] Error: Unknown hand for SteamVR model override."); } } }