Beispiel #1
0
        void createSpotMeshes(ref List <CGVMesh> vMeshes, ref CGSpots spots, bool combine)
        {
            int    exceededVertexCount = 0;
            int    vmCount             = vMeshes.Count;
            CGSpot spot;

            CGMeshResource res;

            if (combine)
            {
                var sortedSpots = new List <CGSpot>(spots.Points);
                if (GroupMeshes)
                {
                    sortedSpots.Sort((CGSpot a, CGSpot b) => a.Index.CompareTo(b.Index));
                }

                spot = sortedSpots[0];
                CGVMesh curVMesh = new CGVMesh(vMeshes[spot.Index]);
                if (spot.Position != Vector3.zero || spot.Rotation != Quaternion.identity || spot.Scale != Vector3.one)
                {
                    curVMesh.TRS(spot.Matrix);
                }
                for (int s = 1; s < sortedSpots.Count; s++)
                {
                    spot = sortedSpots[s];
                    // Filter spot.index not in vMeshes[]
                    if (spot.Index > -1 && spot.Index < vmCount)
                    {
                        if (curVMesh.Count + vMeshes[spot.Index].Count > 65534 || (GroupMeshes && spot.Index != sortedSpots[s - 1].Index))
                        {         // write curVMesh
                            writeVMeshToMesh(ref curVMesh);
                            curVMesh = new CGVMesh(vMeshes[spot.Index]);
                            if (!spot.Matrix.isIdentity)
                            {
                                curVMesh.TRS(spot.Matrix);
                            }
                        }
                        else
                        {         // Add new vMesh to curVMesh
                            if (!spot.Matrix.isIdentity)
                            {
                                curVMesh.MergeVMesh(vMeshes[spot.Index], spot.Matrix);
                            }
                            else
                            {
                                curVMesh.MergeVMesh(vMeshes[spot.Index]);
                            }
                        }
                    }
                }
                writeVMeshToMesh(ref curVMesh);
            }
            else
            {
                for (int s = 0; s < spots.Count; s++)
                {
                    spot = spots.Points[s];
                    // Filter spot.index not in vMeshes[]
                    if (spot.Index > -1 && spot.Index < vmCount)
                    {
                        // Don't touch vertices, TRS Resource instead
                        if (vMeshes[spot.Index].Count < 65535)
                        {
                            CGVMesh vmesh = vMeshes[spot.Index];
                            res = writeVMeshToMesh(ref vmesh);
                            if (spot.Position != Vector3.zero || spot.Rotation != Quaternion.identity || spot.Scale != Vector3.one)
                            {
                                spot.ToTransform(res.Filter.transform);
                            }
                        }
                        else
                        {
                            exceededVertexCount++;
                        }
                    }
                }
            }

            if (exceededVertexCount > 0)
            {
                UIMessages.Add(string.Format("{0} meshes skipped (VertexCount>65534)", exceededVertexCount));
            }
        }
Beispiel #2
0
        void createSpotMeshes(ref List<CGVMesh> vMeshes, ref CGSpots spots, bool combine)
        {
            int exceededVertexCount = 0;
            int vmCount = vMeshes.Count;
            CGSpot spot;

            CGMeshResource res;
            if (combine)
            {
                var sortedSpots = new List<CGSpot>(spots.Points);
                if (GroupMeshes)
                    sortedSpots.Sort((CGSpot a, CGSpot b) => a.Index.CompareTo(b.Index));

                spot = sortedSpots[0];
                CGVMesh curVMesh = new CGVMesh(vMeshes[spot.Index]);
                if (spot.Position != Vector3.zero || spot.Rotation != Quaternion.identity || spot.Scale != Vector3.one)
                    curVMesh.TRS(spot.Matrix);
                for (int s = 1; s < sortedSpots.Count; s++)
                {
                    spot = sortedSpots[s];
                    // Filter spot.index not in vMeshes[]
                    if (spot.Index > -1 && spot.Index < vmCount)
                    {
                        if (curVMesh.Count + vMeshes[spot.Index].Count > 65534 || (GroupMeshes && spot.Index != sortedSpots[s - 1].Index))
                        { // write curVMesh 
                            writeVMeshToMesh(ref curVMesh);
                            curVMesh = new CGVMesh(vMeshes[spot.Index]);
                            if (!spot.Matrix.isIdentity)
                                curVMesh.TRS(spot.Matrix);
                        }
                        else
                        { // Add new vMesh to curVMesh
                            if (!spot.Matrix.isIdentity)
                                curVMesh.MergeVMesh(vMeshes[spot.Index], spot.Matrix);
                            else
                                curVMesh.MergeVMesh(vMeshes[spot.Index]);
                        }
                    }
                }
                writeVMeshToMesh(ref curVMesh);
            }
            else
            {
                for (int s = 0; s < spots.Count; s++)
                {
                    spot = spots.Points[s];
                    // Filter spot.index not in vMeshes[]
                    if (spot.Index > -1 && spot.Index < vmCount)
                    {
                        // Don't touch vertices, TRS Resource instead
                        if (vMeshes[spot.Index].Count < 65535)
                        {
                            CGVMesh vmesh = vMeshes[spot.Index];
                            res = writeVMeshToMesh(ref vmesh);
                            if (spot.Position != Vector3.zero || spot.Rotation != Quaternion.identity || spot.Scale != Vector3.one)
                                spot.ToTransform(res.Filter.transform);
                        }
                        else
                            exceededVertexCount++;
                    }
                }
            }

            if (exceededVertexCount > 0)
                UIMessages.Add(string.Format("{0} meshes skipped (VertexCount>65534)", exceededVertexCount));
        }