Ejemplo n.º 1
0
    public void UpdateSceneInfo() {
      INTERACTION_SCENE_INFO info = new INTERACTION_SCENE_INFO();
      info.gravity = Vector3.one.ToCVector();
      info.sceneFlags = SceneInfoFlags.HasGravity;

      InteractionC.UpdateSceneInfo(ref _scene, ref info);
    }
Ejemplo n.º 2
0
        protected virtual INTERACTION_SCENE_INFO getSceneInfo()
        {
            INTERACTION_SCENE_INFO info = new INTERACTION_SCENE_INFO();

            info.sceneFlags = SceneInfoFlags.None;

            if (Physics.gravity.sqrMagnitude != 0.0f)
            {
                info.sceneFlags |= SceneInfoFlags.HasGravity;
                info.gravity     = Physics.gravity.ToCVector();
            }

            if (_depthUntilSphericalInside > 0.0f)
            {
                info.sceneFlags |= SceneInfoFlags.SphericalInside;
                info.depthUntilSphericalInside = _depthUntilSphericalInside;
            }

            if (_contactEnabled)
            {
                info.sceneFlags |= SceneInfoFlags.ContactEnabled;
            }

            // _enableGraspingLast gaurds against expensive file IO.  Only load the ldat
            // data when grasping is being enabled.
            if (_graspingEnabled)
            {
                info.sceneFlags |= SceneInfoFlags.GraspEnabled;
            }

            return(info);
        }
Ejemplo n.º 3
0
    public virtual void Setup() {
      InteractionC.CreateScene(ref _scene);

      INTERACTION_SCENE_INFO sceneInfo = new INTERACTION_SCENE_INFO();
      sceneInfo.sceneFlags = SceneInfoFlags.ContactEnabled;

      InteractionC.UpdateSceneInfo(ref _scene, ref sceneInfo);
    }
Ejemplo n.º 4
0
        public void UpdateSceneInfo()
        {
            INTERACTION_SCENE_INFO info = new INTERACTION_SCENE_INFO();

            info.gravity    = Vector3.one.ToCVector();
            info.sceneFlags = SceneInfoFlags.HasGravity;

            InteractionC.UpdateSceneInfo(ref _scene, ref info);
        }
Ejemplo n.º 5
0
        public void EnableContactThenUpdate()
        {
            INTERACTION_SCENE_INFO info = new INTERACTION_SCENE_INFO();

            info.sceneFlags = SceneInfoFlags.ContactEnabled;

            InteractionC.UpdateSceneInfo(ref _scene, ref info);

            UpdateInstance();
        }
Ejemplo n.º 6
0
        public virtual void Setup()
        {
            InteractionC.CreateScene(ref _scene);

            INTERACTION_SCENE_INFO sceneInfo = new INTERACTION_SCENE_INFO();

            sceneInfo.sceneFlags = SceneInfoFlags.ContactEnabled;

            InteractionC.UpdateSceneInfo(ref _scene, ref sceneInfo);
        }
Ejemplo n.º 7
0
    /// <summary>
    /// Loads an ldat file loaded at a path relative to the streaming assets folder.  The file
    /// is stored into the provided scene info struct.  This method returns a disposable that 
    /// releases the ldat resources when disposed.
    /// </summary>
    public static IDisposable LoadLdat(ref INTERACTION_SCENE_INFO info, string ldatPath) {
      string ldatFullPath = Path.Combine(getStreamingAssetsPath(), ldatPath);

      WWW ldat = new WWW(ldatFullPath);
      while (!ldat.isDone) {
        System.Threading.Thread.Sleep(1);
      }

      if (!string.IsNullOrEmpty(ldat.error)) {
        throw new Exception(ldat.error + ": " + ldatFullPath);
      }

      info.ldatData = Marshal.AllocHGlobal(ldat.bytes.Length);

      info.ldatSize = (uint)ldat.bytes.Length;
      info.ldatData = Marshal.AllocHGlobal(ldat.bytes.Length);
      Marshal.Copy(ldat.bytes, 0, info.ldatData, ldat.bytes.Length);

      return new ReleaseUponDispose(info.ldatData);
    }
Ejemplo n.º 8
0
        /// Force an update of the internal scene info.  This should be called if gravity has changed.
        /// </summary>
        public void UpdateSceneInfo()
        {
            if (!_hasSceneBeenCreated)
            {
                return; // UpdateSceneInfo is a side effect of a lot of changes.
            }

            INTERACTION_SCENE_INFO info = getSceneInfo();

            if (_graspingEnabled && !_enableGraspingLast)
            {
                using (LdatLoader.LoadLdat(ref info, _ldatPath)) {
                    InteractionC.UpdateSceneInfo(ref _scene, ref info);
                }
            }
            else
            {
                InteractionC.UpdateSceneInfo(ref _scene, ref info);
            }
            _enableGraspingLast = _graspingEnabled;

            _cachedSimulationScale         = _leapProvider.transform.lossyScale.x;
            _activityManager.OverlapRadius = _activationRadius * _cachedSimulationScale;
        }
Ejemplo n.º 9
0
    public void EnableContactThenUpdate() {
      INTERACTION_SCENE_INFO info = new INTERACTION_SCENE_INFO();
      info.sceneFlags = SceneInfoFlags.ContactEnabled;

      InteractionC.UpdateSceneInfo(ref _scene, ref info);

      UpdateInstance();
    }
Ejemplo n.º 10
0
    protected virtual INTERACTION_SCENE_INFO getSceneInfo() {
      INTERACTION_SCENE_INFO info = new INTERACTION_SCENE_INFO();
      info.sceneFlags = SceneInfoFlags.None;

      if (Physics.gravity.sqrMagnitude != 0.0f) {
        info.sceneFlags |= SceneInfoFlags.HasGravity;
        info.gravity = Physics.gravity.ToCVector();
      }

      if (_depthUntilSphericalInside > 0.0f) {
        info.sceneFlags |= SceneInfoFlags.SphericalInside;
        info.depthUntilSphericalInside = _depthUntilSphericalInside;
      }

      if (_contactEnabled) {
        info.sceneFlags |= SceneInfoFlags.ContactEnabled;
      }

      // _enableGraspingLast gaurds against expensive file IO.  Only load the ldat
      // data when grasping is being enabled.
      if (_graspingEnabled) {
        info.sceneFlags |= SceneInfoFlags.GraspEnabled;
      }

      return info;
    }