コード例 #1
0
        private void UpdateSmartTerrain(VuforiaManagerImpl.FrameState frameState, StateManagerImpl stateManager)
        {
            SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();

            if (tracker != null && tracker.SmartTerrainBuilder.GetReconstructions().Any <ReconstructionAbstractBehaviour>())
            {
                VuforiaManagerImpl.SmartTerrainRevisionData[] array = new VuforiaManagerImpl.SmartTerrainRevisionData[frameState.numSmartTerrainRevisions];
                VuforiaManagerImpl.SurfaceData[] array2             = new VuforiaManagerImpl.SurfaceData[frameState.numUpdatedSurfaces];
                VuforiaManagerImpl.PropData[]    array3             = new VuforiaManagerImpl.PropData[frameState.numUpdatedProps];
                for (int i = 0; i < frameState.numSmartTerrainRevisions; i++)
                {
                    VuforiaManagerImpl.SmartTerrainRevisionData smartTerrainRevisionData = (VuforiaManagerImpl.SmartTerrainRevisionData)Marshal.PtrToStructure(new IntPtr(frameState.smartTerrainRevisionsArray.ToInt64() + (long)(i * Marshal.SizeOf(typeof(VuforiaManagerImpl.SmartTerrainRevisionData)))), typeof(VuforiaManagerImpl.SmartTerrainRevisionData));
                    array[i] = smartTerrainRevisionData;
                }
                for (int j = 0; j < frameState.numUpdatedSurfaces; j++)
                {
                    VuforiaManagerImpl.SurfaceData surfaceData = (VuforiaManagerImpl.SurfaceData)Marshal.PtrToStructure(new IntPtr(frameState.updatedSurfacesArray.ToInt64() + (long)(j * Marshal.SizeOf(typeof(VuforiaManagerImpl.SurfaceData)))), typeof(VuforiaManagerImpl.SurfaceData));
                    array2[j] = surfaceData;
                }
                for (int k = 0; k < frameState.numUpdatedProps; k++)
                {
                    VuforiaManagerImpl.PropData propData = (VuforiaManagerImpl.PropData)Marshal.PtrToStructure(new IntPtr(frameState.updatedPropsArray.ToInt64() + (long)(k * Marshal.SizeOf(typeof(VuforiaManagerImpl.PropData)))), typeof(VuforiaManagerImpl.PropData));
                    array3[k] = propData;
                }
                ((SmartTerrainBuilderImpl)tracker.SmartTerrainBuilder).UpdateSmartTerrainData(array, array2, array3);
            }
        }
コード例 #2
0
 internal void ClearOnReset()
 {
     VuforiaManagerImpl.SmartTerrainRevisionData[] smartTerrainRevisions = new VuforiaManagerImpl.SmartTerrainRevisionData[0];
     VuforiaManagerImpl.SurfaceData[] updatedSurfaceData = new VuforiaManagerImpl.SurfaceData[0];
     VuforiaManagerImpl.PropData[]    updatedPropData    = new VuforiaManagerImpl.PropData[0];
     this.UpdateSurfaces(smartTerrainRevisions, updatedSurfaceData);
     this.UpdateProps(smartTerrainRevisions, updatedPropData);
     this.mIgnoreNextUpdate = true;
 }
コード例 #3
0
        private void UpdateProps(VuforiaManagerImpl.SmartTerrainRevisionData[] smartTerrainRevisions, VuforiaManagerImpl.PropData[] updatedPropData)
        {
            List <Prop> list  = new List <Prop>();
            List <Prop> list2 = new List <Prop>();
            List <Prop> list3 = new List <Prop>();

            for (int i = 0; i < updatedPropData.Length; i++)
            {
                VuforiaManagerImpl.PropData propData = updatedPropData[i];
                bool     flag = false;
                PropImpl propImpl;
                bool     flag2;
                if (!this.mProps.ContainsKey(propData.id))
                {
                    propImpl = new PropImpl(propData.id, this.FindSmartTerrainTrackable(propData.parentID));
                    this.mProps.Add(propData.id, propImpl);
                    list.Add(propImpl);
                    flag2 = true;
                    flag  = true;
                }
                else
                {
                    propImpl = (PropImpl)this.mProps[propData.id];
                    flag2    = (propData.revision != propImpl.MeshRevision);
                }
                if (flag2)
                {
                    Mesh mesh = MeshUtils.UpdateMesh(propData.meshData, propImpl.GetMesh(), false, true);
                    if (flag)
                    {
                        propImpl.SetLocalPose(propData.localPose);
                    }
                    propImpl.SetMesh(propData.revision, mesh);
                    VuforiaManagerImpl.Obb3D boundingBox = propData.boundingBox;
                    OrientedBoundingBox3D    obb         = new OrientedBoundingBox3D(boundingBox.center, boundingBox.halfExtents, boundingBox.rotationZ * 57.29578f);
                    propImpl.SetObb(obb);
                    list2.Add(propImpl);
                }
                else
                {
                    Debug.LogError("Inconsistency: received updated Prop, but mesh revision is unchanged!");
                }
            }
            int[] array = new int[this.mProps.Count];
            this.mProps.Keys.CopyTo(array, 0);
            int[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                int  num   = array2[i];
                bool flag3 = false;
                for (int j = 0; j < smartTerrainRevisions.Length; j++)
                {
                    if (smartTerrainRevisions[j].id == num)
                    {
                        flag3 = true;
                    }
                }
                if (!flag3)
                {
                    list3.Add(this.mProps[num]);
                    ((PropImpl)this.mProps[num]).DestroyMesh();
                    this.mProps.Remove(num);
                }
            }
            this.UnregisterDeletedProps(list3);
            foreach (Prop current in list3)
            {
                if (current.Parent != null)
                {
                    ((SmartTerrainTrackableImpl)current.Parent).RemoveChild(current);
                }
            }
            foreach (Prop current2 in list)
            {
                if (current2.Parent != null)
                {
                    ((SmartTerrainTrackableImpl)current2.Parent).AddChild(current2);
                }
            }
            this.NotifyPropEventHandlers(list, list2, list3);
        }