Initialer Upload neues Unity-Projekt
This commit is contained in:
18
Assets/SteamVR/Extras/SteamVR_CameraHelper.cs
Normal file
18
Assets/SteamVR/Extras/SteamVR_CameraHelper.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Valve.VR
|
||||
{
|
||||
public class SteamVR_CameraHelper : MonoBehaviour
|
||||
{
|
||||
void Start()
|
||||
{
|
||||
#if OPENVR_XR_API && UNITY_LEGACY_INPUT_HELPERS
|
||||
if (this.gameObject.GetComponent<UnityEngine.SpatialTracking.TrackedPoseDriver>() == null)
|
||||
{
|
||||
this.gameObject.AddComponent<UnityEngine.SpatialTracking.TrackedPoseDriver>();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/SteamVR/Extras/SteamVR_CameraHelper.cs.meta
Normal file
12
Assets/SteamVR/Extras/SteamVR_CameraHelper.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c30a2316e98e1dc4b97e432a1301f85c
|
||||
timeCreated: 1591403558
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/SteamVR/Extras/SteamVR_ForceSteamVRMode.cs
Normal file
35
Assets/SteamVR/Extras/SteamVR_ForceSteamVRMode.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Valve.VR.Extras
|
||||
{
|
||||
/// <summary>
|
||||
/// This is an example class of how to force steamvr initialization. You still need to have vr mode enabled
|
||||
/// but you can have the top sdk set to None, then this script will force it to OpenVR after a second
|
||||
/// </summary>
|
||||
public class SteamVR_ForceSteamVRMode : MonoBehaviour
|
||||
{
|
||||
public GameObject vrCameraPrefab;
|
||||
|
||||
public GameObject[] disableObjectsOnLoad;
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
yield return new WaitForSeconds(1f); // just here to show that you can wait a while.
|
||||
|
||||
SteamVR.Initialize(true);
|
||||
|
||||
while (SteamVR.initializedState != SteamVR.InitializedStates.InitializeSuccess)
|
||||
yield return null;
|
||||
|
||||
for (int disableIndex = 0; disableIndex < disableObjectsOnLoad.Length; disableIndex++)
|
||||
{
|
||||
GameObject toDisable = disableObjectsOnLoad[disableIndex];
|
||||
if (toDisable != null)
|
||||
toDisable.SetActive(false);
|
||||
}
|
||||
|
||||
GameObject.Instantiate(vrCameraPrefab);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/SteamVR/Extras/SteamVR_ForceSteamVRMode.cs.meta
Normal file
12
Assets/SteamVR/Extras/SteamVR_ForceSteamVRMode.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4bc5db9c652ff8408b7cda0197f87f1
|
||||
timeCreated: 1539107854
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/SteamVR/Extras/SteamVR_ForceSteamVRMode.unity
(Stored with Git LFS)
Normal file
BIN
Assets/SteamVR/Extras/SteamVR_ForceSteamVRMode.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b1775e13a163e146930422a18e54bfc
|
||||
timeCreated: 1539107812
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
83
Assets/SteamVR/Extras/SteamVR_GazeTracker.cs
Normal file
83
Assets/SteamVR/Extras/SteamVR_GazeTracker.cs
Normal file
@ -0,0 +1,83 @@
|
||||
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Valve.VR.Extras
|
||||
{
|
||||
public class SteamVR_GazeTracker : MonoBehaviour
|
||||
{
|
||||
public bool isInGaze = false;
|
||||
public event GazeEventHandler GazeOn;
|
||||
public event GazeEventHandler GazeOff;
|
||||
public float gazeInCutoff = 0.15f;
|
||||
public float gazeOutCutoff = 0.4f;
|
||||
|
||||
// Contains a HMD tracked object that we can use to find the user's gaze
|
||||
protected Transform hmdTrackedObject = null;
|
||||
|
||||
public virtual void OnGazeOn(GazeEventArgs gazeEventArgs)
|
||||
{
|
||||
if (GazeOn != null)
|
||||
GazeOn(this, gazeEventArgs);
|
||||
}
|
||||
|
||||
public virtual void OnGazeOff(GazeEventArgs gazeEventArgs)
|
||||
{
|
||||
if (GazeOff != null)
|
||||
GazeOff(this, gazeEventArgs);
|
||||
}
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
// If we haven't set up hmdTrackedObject find what the user is looking at
|
||||
if (hmdTrackedObject == null)
|
||||
{
|
||||
SteamVR_TrackedObject[] trackedObjects = FindObjectsOfType<SteamVR_TrackedObject>();
|
||||
foreach (SteamVR_TrackedObject tracked in trackedObjects)
|
||||
{
|
||||
if (tracked.index == SteamVR_TrackedObject.EIndex.Hmd)
|
||||
{
|
||||
hmdTrackedObject = tracked.transform;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hmdTrackedObject)
|
||||
{
|
||||
Ray ray = new Ray(hmdTrackedObject.position, hmdTrackedObject.forward);
|
||||
Plane plane = new Plane(hmdTrackedObject.forward, transform.position);
|
||||
|
||||
float enter = 0.0f;
|
||||
if (plane.Raycast(ray, out enter))
|
||||
{
|
||||
Vector3 intersect = hmdTrackedObject.position + hmdTrackedObject.forward * enter;
|
||||
float dist = Vector3.Distance(intersect, transform.position);
|
||||
//Debug.Log("Gaze dist = " + dist);
|
||||
if (dist < gazeInCutoff && !isInGaze)
|
||||
{
|
||||
isInGaze = true;
|
||||
GazeEventArgs gazeEventArgs;
|
||||
gazeEventArgs.distance = dist;
|
||||
OnGazeOn(gazeEventArgs);
|
||||
}
|
||||
else if (dist >= gazeOutCutoff && isInGaze)
|
||||
{
|
||||
isInGaze = false;
|
||||
GazeEventArgs gazeEventArgs;
|
||||
gazeEventArgs.distance = dist;
|
||||
OnGazeOff(gazeEventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public struct GazeEventArgs
|
||||
{
|
||||
public float distance;
|
||||
}
|
||||
|
||||
public delegate void GazeEventHandler(object sender, GazeEventArgs gazeEventArgs);
|
||||
}
|
||||
12
Assets/SteamVR/Extras/SteamVR_GazeTracker.cs.meta
Normal file
12
Assets/SteamVR/Extras/SteamVR_GazeTracker.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 501eb8b744f73714fbe7dbdd5e3ef66e
|
||||
timeCreated: 1426193800
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
168
Assets/SteamVR/Extras/SteamVR_LaserPointer.cs
Normal file
168
Assets/SteamVR/Extras/SteamVR_LaserPointer.cs
Normal file
@ -0,0 +1,168 @@
|
||||
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Valve.VR.Extras
|
||||
{
|
||||
public class SteamVR_LaserPointer : MonoBehaviour
|
||||
{
|
||||
public SteamVR_Behaviour_Pose pose;
|
||||
|
||||
//public SteamVR_Action_Boolean interactWithUI = SteamVR_Input.__actions_default_in_InteractUI;
|
||||
public SteamVR_Action_Boolean interactWithUI = SteamVR_Input.GetBooleanAction("InteractUI");
|
||||
|
||||
public bool active = true;
|
||||
public Color color;
|
||||
public float thickness = 0.002f;
|
||||
public Color clickColor = Color.green;
|
||||
public GameObject holder;
|
||||
public GameObject pointer;
|
||||
bool isActive = false;
|
||||
public bool addRigidBody = false;
|
||||
public Transform reference;
|
||||
public event PointerEventHandler PointerIn;
|
||||
public event PointerEventHandler PointerOut;
|
||||
public event PointerEventHandler PointerClick;
|
||||
|
||||
Transform previousContact = null;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (pose == null)
|
||||
pose = this.GetComponent<SteamVR_Behaviour_Pose>();
|
||||
if (pose == null)
|
||||
Debug.LogError("No SteamVR_Behaviour_Pose component found on this object", this);
|
||||
|
||||
if (interactWithUI == null)
|
||||
Debug.LogError("No ui interaction action has been set on this component.", this);
|
||||
|
||||
|
||||
holder = new GameObject();
|
||||
holder.transform.parent = this.transform;
|
||||
holder.transform.localPosition = Vector3.zero;
|
||||
holder.transform.localRotation = Quaternion.identity;
|
||||
|
||||
pointer = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
pointer.transform.parent = holder.transform;
|
||||
pointer.transform.localScale = new Vector3(thickness, thickness, 100f);
|
||||
pointer.transform.localPosition = new Vector3(0f, 0f, 50f);
|
||||
pointer.transform.localRotation = Quaternion.identity;
|
||||
BoxCollider collider = pointer.GetComponent<BoxCollider>();
|
||||
if (addRigidBody)
|
||||
{
|
||||
if (collider)
|
||||
{
|
||||
collider.isTrigger = true;
|
||||
}
|
||||
Rigidbody rigidBody = pointer.AddComponent<Rigidbody>();
|
||||
rigidBody.isKinematic = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (collider)
|
||||
{
|
||||
Object.Destroy(collider);
|
||||
}
|
||||
}
|
||||
Material newMaterial = new Material(Shader.Find("Unlit/Color"));
|
||||
newMaterial.SetColor("_Color", color);
|
||||
pointer.GetComponent<MeshRenderer>().material = newMaterial;
|
||||
}
|
||||
|
||||
public virtual void OnPointerIn(PointerEventArgs e)
|
||||
{
|
||||
if (PointerIn != null)
|
||||
PointerIn(this, e);
|
||||
}
|
||||
|
||||
public virtual void OnPointerClick(PointerEventArgs e)
|
||||
{
|
||||
if (PointerClick != null)
|
||||
PointerClick(this, e);
|
||||
}
|
||||
|
||||
public virtual void OnPointerOut(PointerEventArgs e)
|
||||
{
|
||||
if (PointerOut != null)
|
||||
PointerOut(this, e);
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!isActive)
|
||||
{
|
||||
isActive = true;
|
||||
this.transform.GetChild(0).gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
float dist = 100f;
|
||||
|
||||
Ray raycast = new Ray(transform.position, transform.forward);
|
||||
RaycastHit hit;
|
||||
bool bHit = Physics.Raycast(raycast, out hit);
|
||||
|
||||
if (previousContact && previousContact != hit.transform)
|
||||
{
|
||||
PointerEventArgs args = new PointerEventArgs();
|
||||
args.fromInputSource = pose.inputSource;
|
||||
args.distance = 0f;
|
||||
args.flags = 0;
|
||||
args.target = previousContact;
|
||||
OnPointerOut(args);
|
||||
previousContact = null;
|
||||
}
|
||||
if (bHit && previousContact != hit.transform)
|
||||
{
|
||||
PointerEventArgs argsIn = new PointerEventArgs();
|
||||
argsIn.fromInputSource = pose.inputSource;
|
||||
argsIn.distance = hit.distance;
|
||||
argsIn.flags = 0;
|
||||
argsIn.target = hit.transform;
|
||||
OnPointerIn(argsIn);
|
||||
previousContact = hit.transform;
|
||||
}
|
||||
if (!bHit)
|
||||
{
|
||||
previousContact = null;
|
||||
}
|
||||
if (bHit && hit.distance < 100f)
|
||||
{
|
||||
dist = hit.distance;
|
||||
}
|
||||
|
||||
if (bHit && interactWithUI.GetStateUp(pose.inputSource))
|
||||
{
|
||||
PointerEventArgs argsClick = new PointerEventArgs();
|
||||
argsClick.fromInputSource = pose.inputSource;
|
||||
argsClick.distance = hit.distance;
|
||||
argsClick.flags = 0;
|
||||
argsClick.target = hit.transform;
|
||||
OnPointerClick(argsClick);
|
||||
}
|
||||
|
||||
if (interactWithUI != null && interactWithUI.GetState(pose.inputSource))
|
||||
{
|
||||
pointer.transform.localScale = new Vector3(thickness * 5f, thickness * 5f, dist);
|
||||
pointer.GetComponent<MeshRenderer>().material.color = clickColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
pointer.transform.localScale = new Vector3(thickness, thickness, dist);
|
||||
pointer.GetComponent<MeshRenderer>().material.color = color;
|
||||
}
|
||||
pointer.transform.localPosition = new Vector3(0f, 0f, dist / 2f);
|
||||
}
|
||||
}
|
||||
|
||||
public struct PointerEventArgs
|
||||
{
|
||||
public SteamVR_Input_Sources fromInputSource;
|
||||
public uint flags;
|
||||
public float distance;
|
||||
public Transform target;
|
||||
}
|
||||
|
||||
public delegate void PointerEventHandler(object sender, PointerEventArgs e);
|
||||
}
|
||||
12
Assets/SteamVR/Extras/SteamVR_LaserPointer.cs.meta
Normal file
12
Assets/SteamVR/Extras/SteamVR_LaserPointer.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2f511c1adaa1e94ebe7ca97bbcabd17
|
||||
timeCreated: 1539298734
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/SteamVR/Extras/SteamVR_LaserPointer.unity
(Stored with Git LFS)
Normal file
BIN
Assets/SteamVR/Extras/SteamVR_LaserPointer.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
8
Assets/SteamVR/Extras/SteamVR_LaserPointer.unity.meta
Normal file
8
Assets/SteamVR/Extras/SteamVR_LaserPointer.unity.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2343db151bc3864e9088f8e4230cdc1
|
||||
timeCreated: 1539298758
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/SteamVR/Extras/SteamVR_ShowTrackingReferences.unity
(Stored with Git LFS)
Normal file
BIN
Assets/SteamVR/Extras/SteamVR_ShowTrackingReferences.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73743b10c3912094a8a17bc7ac370c15
|
||||
timeCreated: 1550629235
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/SteamVR/Extras/SteamVR_TestIK.unity
(Stored with Git LFS)
Normal file
BIN
Assets/SteamVR/Extras/SteamVR_TestIK.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
8
Assets/SteamVR/Extras/SteamVR_TestIK.unity.meta
Normal file
8
Assets/SteamVR/Extras/SteamVR_TestIK.unity.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b6669fb4e4df9c48926f02b694be9d1
|
||||
timeCreated: 1437433018
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
62
Assets/SteamVR/Extras/SteamVR_TestThrow.cs
Normal file
62
Assets/SteamVR/Extras/SteamVR_TestThrow.cs
Normal file
@ -0,0 +1,62 @@
|
||||
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Valve.VR.Extras
|
||||
{
|
||||
[RequireComponent(typeof(SteamVR_TrackedObject))]
|
||||
public class SteamVR_TestThrow : MonoBehaviour
|
||||
{
|
||||
public GameObject prefab;
|
||||
public Rigidbody attachPoint;
|
||||
|
||||
public SteamVR_Action_Boolean spawn = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("InteractUI");
|
||||
|
||||
SteamVR_Behaviour_Pose trackedObj;
|
||||
FixedJoint joint;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
trackedObj = GetComponent<SteamVR_Behaviour_Pose>();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (joint == null && spawn.GetStateDown(trackedObj.inputSource))
|
||||
{
|
||||
GameObject go = GameObject.Instantiate(prefab);
|
||||
go.transform.position = attachPoint.transform.position;
|
||||
|
||||
joint = go.AddComponent<FixedJoint>();
|
||||
joint.connectedBody = attachPoint;
|
||||
}
|
||||
else if (joint != null && spawn.GetStateUp(trackedObj.inputSource))
|
||||
{
|
||||
GameObject go = joint.gameObject;
|
||||
Rigidbody rigidbody = go.GetComponent<Rigidbody>();
|
||||
Object.DestroyImmediate(joint);
|
||||
joint = null;
|
||||
Object.Destroy(go, 15.0f);
|
||||
|
||||
// We should probably apply the offset between trackedObj.transform.position
|
||||
// and device.transform.pos to insert into the physics sim at the correct
|
||||
// location, however, we would then want to predict ahead the visual representation
|
||||
// by the same amount we are predicting our render poses.
|
||||
|
||||
Transform origin = trackedObj.origin ? trackedObj.origin : trackedObj.transform.parent;
|
||||
if (origin != null)
|
||||
{
|
||||
rigidbody.velocity = origin.TransformVector(trackedObj.GetVelocity());
|
||||
rigidbody.angularVelocity = origin.TransformVector(trackedObj.GetAngularVelocity());
|
||||
}
|
||||
else
|
||||
{
|
||||
rigidbody.velocity = trackedObj.GetVelocity();
|
||||
rigidbody.angularVelocity = trackedObj.GetAngularVelocity();
|
||||
}
|
||||
|
||||
rigidbody.maxAngularVelocity = rigidbody.angularVelocity.magnitude;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/SteamVR/Extras/SteamVR_TestThrow.cs.meta
Normal file
12
Assets/SteamVR/Extras/SteamVR_TestThrow.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff4f36585e15b1942827390ff1a92502
|
||||
timeCreated: 1437513988
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/SteamVR/Extras/SteamVR_TestThrow.unity
(Stored with Git LFS)
Normal file
BIN
Assets/SteamVR/Extras/SteamVR_TestThrow.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
8
Assets/SteamVR/Extras/SteamVR_TestThrow.unity.meta
Normal file
8
Assets/SteamVR/Extras/SteamVR_TestThrow.unity.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d936163b5e9a5047b5e4ba5afaf5126
|
||||
timeCreated: 1437513966
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
86
Assets/SteamVR/Extras/SteamVR_TestTrackedCamera.cs
Normal file
86
Assets/SteamVR/Extras/SteamVR_TestTrackedCamera.cs
Normal file
@ -0,0 +1,86 @@
|
||||
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
|
||||
using UnityEngine;
|
||||
|
||||
namespace Valve.VR.Extras
|
||||
{
|
||||
public class SteamVR_TestTrackedCamera : MonoBehaviour
|
||||
{
|
||||
public Material material;
|
||||
public Transform target;
|
||||
public bool undistorted = true;
|
||||
public bool cropped = true;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// The video stream must be symmetrically acquired and released in
|
||||
// order to properly disable the stream once there are no consumers.
|
||||
SteamVR_TrackedCamera.VideoStreamTexture source = SteamVR_TrackedCamera.Source(undistorted);
|
||||
source.Acquire();
|
||||
|
||||
// Auto-disable if no camera is present.
|
||||
if (!source.hasCamera)
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
// Clear the texture when no longer active.
|
||||
material.mainTexture = null;
|
||||
|
||||
// The video stream must be symmetrically acquired and released in
|
||||
// order to properly disable the stream once there are no consumers.
|
||||
SteamVR_TrackedCamera.VideoStreamTexture source = SteamVR_TrackedCamera.Source(undistorted);
|
||||
source.Release();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
SteamVR_TrackedCamera.VideoStreamTexture source = SteamVR_TrackedCamera.Source(undistorted);
|
||||
Texture2D texture = source.texture;
|
||||
if (texture == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply the latest texture to the material. This must be performed
|
||||
// every frame since the underlying texture is actually part of a ring
|
||||
// buffer which is updated in lock-step with its associated pose.
|
||||
// (You actually really only need to call any of the accessors which
|
||||
// internally call Update on the SteamVR_TrackedCamera.VideoStreamTexture).
|
||||
material.mainTexture = texture;
|
||||
|
||||
// Adjust the height of the quad based on the aspect to keep the texels square.
|
||||
float aspect = (float)texture.width / texture.height;
|
||||
|
||||
// The undistorted video feed has 'bad' areas near the edges where the original
|
||||
// square texture feed is stretched to undo the fisheye from the lens.
|
||||
// Therefore, you'll want to crop it to the specified frameBounds to remove this.
|
||||
if (cropped)
|
||||
{
|
||||
VRTextureBounds_t bounds = source.frameBounds;
|
||||
material.mainTextureOffset = new Vector2(bounds.uMin, bounds.vMin);
|
||||
|
||||
float du = bounds.uMax - bounds.uMin;
|
||||
float dv = bounds.vMax - bounds.vMin;
|
||||
material.mainTextureScale = new Vector2(du, dv);
|
||||
|
||||
aspect *= Mathf.Abs(du / dv);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.mainTextureOffset = Vector2.zero;
|
||||
material.mainTextureScale = new Vector2(1, -1);
|
||||
}
|
||||
|
||||
target.localScale = new Vector3(1, 1.0f / aspect, 1);
|
||||
|
||||
// Apply the pose that this frame was recorded at.
|
||||
if (source.hasTracking)
|
||||
{
|
||||
SteamVR_Utils.RigidTransform rigidTransform = source.transform;
|
||||
target.localPosition = rigidTransform.pos;
|
||||
target.localRotation = rigidTransform.rot;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/SteamVR/Extras/SteamVR_TestTrackedCamera.cs.meta
Normal file
12
Assets/SteamVR/Extras/SteamVR_TestTrackedCamera.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b18b36a995ecb04599f35c2741be8d5
|
||||
timeCreated: 1465946679
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
127
Assets/SteamVR/Extras/SteamVR_TestTrackedCamera.mat
Normal file
127
Assets/SteamVR/Extras/SteamVR_TestTrackedCamera.mat
Normal file
@ -0,0 +1,127 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: SteamVR_TestTrackedCamera
|
||||
m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords: _EMISSION
|
||||
m_LightmapFlags: 1
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
m_SavedProperties:
|
||||
serializedVersion: 2
|
||||
m_TexEnvs:
|
||||
- first:
|
||||
name: _BumpMap
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _DetailAlbedoMap
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _DetailMask
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _DetailNormalMap
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _EmissionMap
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _MainTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 0.5, y: -0.5}
|
||||
m_Offset: {x: 0.25, y: 0.75}
|
||||
- first:
|
||||
name: _MetallicGlossMap
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _OcclusionMap
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParallaxMap
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _BumpScale
|
||||
second: 1
|
||||
- first:
|
||||
name: _Cutoff
|
||||
second: 0.5
|
||||
- first:
|
||||
name: _DetailNormalMapScale
|
||||
second: 1
|
||||
- first:
|
||||
name: _DstBlend
|
||||
second: 0
|
||||
- first:
|
||||
name: _GlossMapScale
|
||||
second: 1
|
||||
- first:
|
||||
name: _Glossiness
|
||||
second: 0.5
|
||||
- first:
|
||||
name: _GlossyReflections
|
||||
second: 1
|
||||
- first:
|
||||
name: _Metallic
|
||||
second: 0
|
||||
- first:
|
||||
name: _Mode
|
||||
second: 0
|
||||
- first:
|
||||
name: _OcclusionStrength
|
||||
second: 1
|
||||
- first:
|
||||
name: _Parallax
|
||||
second: 0.02
|
||||
- first:
|
||||
name: _SmoothnessTextureChannel
|
||||
second: 0
|
||||
- first:
|
||||
name: _SpecularHighlights
|
||||
second: 1
|
||||
- first:
|
||||
name: _SrcBlend
|
||||
second: 1
|
||||
- first:
|
||||
name: _UVSec
|
||||
second: 0
|
||||
- first:
|
||||
name: _ZWrite
|
||||
second: 1
|
||||
m_Colors:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
- first:
|
||||
name: _EmissionColor
|
||||
second: {r: 0, g: 0, b: 0, a: 1}
|
||||
8
Assets/SteamVR/Extras/SteamVR_TestTrackedCamera.mat.meta
Normal file
8
Assets/SteamVR/Extras/SteamVR_TestTrackedCamera.mat.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99ee8d48ccf36264e9d9a72baa681249
|
||||
timeCreated: 1465950289
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/SteamVR/Extras/SteamVR_TestTrackedCamera.unity
(Stored with Git LFS)
Normal file
BIN
Assets/SteamVR/Extras/SteamVR_TestTrackedCamera.unity
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fb811b0ffe615b4dbf1d5e6ced385fd
|
||||
timeCreated: 1464227836
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user