Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*==============================================================================
- Copyright 2017 Maxst, Inc. All Rights Reserved.
- ==============================================================================*/
- using UnityEngine;
- using System.Collections.Generic;
- using System.Collections;
- namespace maxstAR
- {
- public class ObjectTrackableBehaviour : AbstractObjectTrackableBehaviour
- {
- //[SerializeField]
- //public Controller ctrlScript;
- public bool isTracking;
- public override void OnTrackSuccess(string id, string name, Matrix4x4 poseMatrix)
- {
- if (!isTracking)
- {
- isTracking = true;
- print("isTracking = " + isTracking); ;
- }
- Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
- Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);
- // Enable renderers
- foreach (Renderer component in rendererComponents)
- {
- component.enabled = true;
- }
- // Enable colliders
- foreach (Collider component in colliderComponents)
- {
- component.enabled = true;
- }
- transform.position = MatrixUtils.PositionFromMatrix(poseMatrix);
- transform.rotation = MatrixUtils.QuaternionFromMatrix(poseMatrix);
- transform.localScale = MatrixUtils.ScaleFromMatrix(poseMatrix);
- }
- public override void OnTrackFail()
- {
- if (isTracking)
- {
- isTracking = false;
- print("isTrackingblablalbblalba = " + isTracking);
- isNotTracking = true;
- }
- Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
- Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);
- // Disable renderer
- foreach (Renderer component in rendererComponents)
- {
- component.enabled = false;
- }
- // Disable collider
- foreach (Collider component in colliderComponents)
- {
- component.enabled = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment