Example #1
0
        internal Mesh GetDistortionMesh(View viewId, Mesh oldMesh)
        {
            IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VuforiaManagerImpl.MeshData)));

            VuforiaWrapper.Instance.RenderingPrimitives_GetDistortionMesh((int)viewId, intPtr);
            VuforiaManagerImpl.MeshData arg_3F_0 = (VuforiaManagerImpl.MeshData)Marshal.PtrToStructure(intPtr, typeof(VuforiaManagerImpl.MeshData));
            Marshal.FreeHGlobal(intPtr);
            return(MeshUtils.UpdateMesh(arg_3F_0, oldMesh, false, false));
        }
Example #2
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);
        }
Example #3
0
        private void UpdateSurfaces(VuforiaManagerImpl.SmartTerrainRevisionData[] smartTerrainRevisions, VuforiaManagerImpl.SurfaceData[] updatedSurfaceData)
        {
            List <Surface> list  = new List <Surface>();
            List <Surface> list2 = new List <Surface>();
            List <Surface> list3 = new List <Surface>();

            for (int i = 0; i < updatedSurfaceData.Length; i++)
            {
                VuforiaManagerImpl.SurfaceData surfaceData = updatedSurfaceData[i];
                bool        flag = false;
                SurfaceImpl surfaceImpl;
                bool        flag2;
                if (!this.mSurfaces.ContainsKey(surfaceData.id))
                {
                    surfaceImpl = new SurfaceImpl(surfaceData.id, this.FindSmartTerrainTrackable(surfaceData.parentID));
                    this.mSurfaces.Add(surfaceData.id, surfaceImpl);
                    list.Add(surfaceImpl);
                    flag2 = true;
                    flag  = true;
                }
                else
                {
                    surfaceImpl = (SurfaceImpl)this.mSurfaces[surfaceData.id];
                    flag2       = (surfaceData.revision != surfaceImpl.MeshRevision);
                }
                if (flag2)
                {
                    Mesh mesh = MeshUtils.UpdateMesh(surfaceData.meshData, surfaceImpl.GetMesh(), false, true);
                    if (flag)
                    {
                        surfaceImpl.SetLocalPose(surfaceData.localPose);
                    }
                    if (mesh != null)
                    {
                        Mesh navMesh = null;
                        if (this.mReconstruction.IsNavMeshUpdating())
                        {
                            navMesh = MeshUtils.UpdateMesh(surfaceData.navMeshData, surfaceImpl.GetNavMesh(), true, true);
                        }
                        int[] meshBoundaries = ReconstructionAbstractBehaviour.ReadMeshBoundaries(surfaceData.numBoundaryIndices, surfaceData.meshBoundaryArray);
                        surfaceImpl.SetMesh(surfaceData.revision, mesh, navMesh, meshBoundaries);
                    }
                    RectangleData boundingBox  = surfaceData.boundingBox;
                    Rect          boundingBox2 = new Rect(boundingBox.leftTopX, boundingBox.leftTopY, boundingBox.rightBottomX - boundingBox.leftTopX, boundingBox.rightBottomY - boundingBox.leftTopY);
                    surfaceImpl.SetBoundingBox(boundingBox2);
                    list2.Add(surfaceImpl);
                }
                else
                {
                    Debug.LogError("Inconsistency: received updated Surface, but mesh revision is unchanged!");
                }
            }
            int[] array = new int[this.mSurfaces.Count];
            this.mSurfaces.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.mSurfaces[num]);
                    ((SurfaceImpl)this.mSurfaces[num]).DestroyMesh();
                    this.mSurfaces.Remove(num);
                }
            }
            this.UnregisterDeletedSurfaces(list3);
            foreach (Surface current in list3)
            {
                if (current.Parent != null)
                {
                    ((SmartTerrainTrackableImpl)current.Parent).RemoveChild(current);
                }
            }
            foreach (Surface current2 in list)
            {
                if (current2.Parent != null)
                {
                    ((SmartTerrainTrackableImpl)current2.Parent).AddChild(current2);
                }
            }
            this.NotifySurfaceEventHandlers(list, list2, list3);
        }