Пример #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));
            }
        }
Пример #2
0
        public override void Refresh()
        {
            base.Refresh();
            mBounds = InBounds.GetAllData<CGBounds>();
            Path = InPath.GetData<CGPath>();
            List<CGSpot> spots = new List<CGSpot>();
            List<GroupSet> endGroups = null;
            prepare();

            if (Path && mBounds.Count > 0 && mGroupsHaveDepth)
            {
                float remainingLength = Length;
                StartDistance = Path.FToDistance(m_Range.Low);
                float currentDistance = StartDistance;

                // Fixed start group(s)
                for (int g = 0; g < FirstRepeating; g++)
                {
                    addGroupItems(Groups[g], ref spots, ref remainingLength, ref currentDistance);
                    if (remainingLength <= 0)
                        break;
                }
                // Fixed end group(s)
                if (GroupCount - LastRepeating - 1 > 0)
                {
                    endGroups = new List<GroupSet>();
                    float endDist = 0;
                    for (int g = LastRepeating + 1; g < GroupCount; g++)
                    {
                        endGroups.Add(addGroupItems(Groups[g], ref spots, ref remainingLength, ref endDist, true));
                    }
                }
                // Mid-Groups, either in row or random
                if (RepeatingOrder == CurvyRepeatingOrderEnum.Row)
                {
                    int g = FirstRepeating;
                    while (remainingLength > 0)
                    {
                        addGroupItems(Groups[g++], ref spots, ref remainingLength, ref currentDistance);
                        if (g > LastRepeating)
                            g = FirstRepeating;
                    }
                }
                else
                {
                    while (remainingLength > 0)
                        addGroupItems(Groups[mGroupBag.Next()], ref spots, ref remainingLength, ref currentDistance);
                }
                // If we have previously generated endgroups data, shift them now
                if (endGroups != null)
                {
                    rebase(ref spots, ref endGroups, currentDistance, remainingLength);
                }

            }

            Count = spots.Count;

            SimulatedSpots = new CGSpots(spots);
            if (Simulate)
                OutSpots.SetData(new CGSpots());
            else
                OutSpots.SetData(SimulatedSpots);

        }
Пример #3
0
 public void Clear()
 {
     Count = 0;
     SimulatedSpots = new CGSpots();
     OutSpots.SetData(SimulatedSpots);
 }
Пример #4
0
        public override void Refresh()
        {
            base.Refresh();
            mBounds = InBounds.GetAllData <CGBounds>();
            Path    = InPath.GetData <CGPath>();
            if (Path != null && Volume == null && UseVolume)
            {
                m_UseVolume = false;
            }
            List <CGSpot>   spots     = new List <CGSpot>();
            List <GroupSet> endGroups = null;

            prepare();

            if (Path && mBounds.Count > 0 && mGroupsHaveDepth)
            {
                float remainingLength = Length;
                StartDistance = Path.FToDistance(m_Range.Low);
                float currentDistance = StartDistance;

                // Fixed start group(s)
                for (int g = 0; g < FirstRepeating; g++)
                {
                    addGroupItems(Groups[g], ref spots, ref remainingLength, ref currentDistance);
                    if (remainingLength <= 0)
                    {
                        break;
                    }
                }
                // Fixed end group(s)
                if (GroupCount - LastRepeating - 1 > 0)
                {
                    endGroups = new List <GroupSet>();
                    float endDist = 0;
                    for (int g = LastRepeating + 1; g < GroupCount; g++)
                    {
                        endGroups.Add(addGroupItems(Groups[g], ref spots, ref remainingLength, ref endDist, true));
                    }
                }
                // Mid-Groups, either in row or random
                if (RepeatingOrder == CurvyRepeatingOrderEnum.Row)
                {
                    int g = FirstRepeating;
                    while (remainingLength > 0)
                    {
                        addGroupItems(Groups[g++], ref spots, ref remainingLength, ref currentDistance);
                        if (g > LastRepeating)
                        {
                            g = FirstRepeating;
                        }
                    }
                }
                else
                {
                    while (remainingLength > 0)
                    {
                        addGroupItems(Groups[mGroupBag.Next()], ref spots, ref remainingLength, ref currentDistance);
                    }
                }
                // If we have previously generated endgroups data, shift them now
                if (endGroups != null)
                {
                    rebase(ref spots, ref endGroups, currentDistance, remainingLength);
                }
            }

            Count = spots.Count;

            SimulatedSpots = new CGSpots(spots);
            if (Simulate)
            {
                OutSpots.SetData(new CGSpots());
            }
            else
            {
                OutSpots.SetData(SimulatedSpots);
            }
        }
Пример #5
0
 public void Clear()
 {
     Count          = 0;
     SimulatedSpots = new CGSpots();
     OutSpots.SetData(SimulatedSpots);
 }
Пример #6
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));
        }