Beispiel #1
0
        public Error Create()
        {
            var error = PhononCore.iplCreateProbeBatch(ref probeBatch);

            if (error != Error.None)
            {
                throw new Exception("Unable to create probe batch.");
            }

            error = PhononCore.iplCreateProbeManager(ref probeManager);
            if (error != Error.None)
            {
                throw new Exception("Unable to create probe batch.");
            }

            //Add all probes from all probe boxes to the probe batch.
            ProbeBox[] allProbeBoxes = GameObject.FindObjectsOfType <ProbeBox>() as ProbeBox[];
            foreach (ProbeBox probeBox in allProbeBoxes)
            {
                if (probeBox.probeBoxData == null || probeBox.probeBoxData.Length == 0)
                {
                    continue;
                }

                IntPtr probeBoxPtr = IntPtr.Zero;
                try
                {
                    PhononCore.iplLoadProbeBox(probeBox.probeBoxData, probeBox.probeBoxData.Length, ref probeBoxPtr);
                }
                catch (Exception e)
                {
                    Debug.LogError(e.Message);
                }

                int numProbes = PhononCore.iplGetProbeSpheres(probeBoxPtr, null);
                for (int i = 0; i < numProbes; ++i)
                {
                    PhononCore.iplAddProbeToBatch(probeBatch, probeBoxPtr, i);
                }

                PhononCore.iplDestroyProbeBox(ref probeBoxPtr);
            }

            //Add probe batch to probe manager.
            PhononCore.iplAddProbeBatch(probeManager, probeBatch);
            PhononCore.iplFinalizeProbeBatch(probeBatch);

            return(error);
        }