devbit

Untitled

Aug 9th, 2018
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. /*==============================================================================
  2. Copyright 2017 Maxst, Inc. All Rights Reserved.
  3. ==============================================================================*/
  4.  
  5. using UnityEngine;
  6. using System.Collections.Generic;
  7. using System.Collections;
  8.  
  9. namespace maxstAR
  10. {
  11.  
  12. public class ObjectTrackableBehaviour : AbstractObjectTrackableBehaviour
  13. {
  14. //[SerializeField]
  15. //public Controller ctrlScript;
  16. public bool isTracking;
  17. public override void OnTrackSuccess(string id, string name, Matrix4x4 poseMatrix)
  18. {
  19. if (!isTracking)
  20. {
  21. isTracking = true;
  22. print("isTracking = " + isTracking); ;
  23. }
  24. Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
  25. Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);
  26.  
  27. // Enable renderers
  28. foreach (Renderer component in rendererComponents)
  29. {
  30. component.enabled = true;
  31. }
  32.  
  33. // Enable colliders
  34. foreach (Collider component in colliderComponents)
  35. {
  36. component.enabled = true;
  37. }
  38.  
  39. transform.position = MatrixUtils.PositionFromMatrix(poseMatrix);
  40. transform.rotation = MatrixUtils.QuaternionFromMatrix(poseMatrix);
  41. transform.localScale = MatrixUtils.ScaleFromMatrix(poseMatrix);
  42. }
  43.  
  44. public override void OnTrackFail()
  45. {
  46. if (isTracking)
  47. {
  48. isTracking = false;
  49. print("isTrackingblablalbblalba = " + isTracking);
  50. isNotTracking = true;
  51. }
  52.  
  53.  
  54. Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
  55. Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);
  56. // Disable renderer
  57. foreach (Renderer component in rendererComponents)
  58. {
  59. component.enabled = false;
  60. }
  61.  
  62. // Disable collider
  63. foreach (Collider component in colliderComponents)
  64. {
  65. component.enabled = false;
  66. }
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment