/// <summary>This will add a paint command to this texture's paint stack. The paint stack will be executed at the end of the current frame.</summary>
        public T AddCommand <T>(P3dModel model, List <T> pool, ref int poolCount, bool preview)
            where T : P3dCommand, new()
        {
            var command = default(T);

            if (poolCount > 0)
            {
                poolCount--;

                command = pool[poolCount];

                pool.RemoveAt(poolCount);
            }
            else
            {
                command = new T();
            }

            command.Preview = preview;
            command.Model   = model;

            commands.Add(command);

            return(command);
        }
        private static void SubmitAll(P3dCommand command, bool preview, P3dModel model, int groupMask)
        {
            var paintableTextures = P3dPaintableTexture.Filter(model, groupMask);

            for (var i = paintableTextures.Count - 1; i >= 0; i--)
            {
                Submit(command, model, paintableTextures[i], preview);
            }
        }
        private static void SubmitAll(P3dCommand command, bool preview, int layerMask, int groupMask)
        {
            var models = P3dModel.FindOverlap(command.Position, command.Radius, layerMask);

            for (var i = models.Count - 1; i >= 0; i--)
            {
                SubmitAll(command, preview, models[i], groupMask);
            }
        }
        private static void SubmitAll(P3dCommand command, Vector3 position, float radius, int layerMask, P3dGroup group)
        {
            var models = P3dModel.FindOverlap(position, radius, layerMask);

            for (var i = models.Count - 1; i >= 0; i--)
            {
                SubmitAll(command, models[i], group);
            }
        }
Beispiel #5
0
            public static void SubmitAll(bool preview, P3dModel model, int groupMask = -1)
            {
                var paintableTextures = P3dPaintableTexture.Filter(model, groupMask);

                for (var i = paintableTextures.Count - 1; i >= 0; i--)
                {
                    Submit(model, paintableTextures[i], preview);
                }
            }
        private static void SubmitAll(P3dCommand command, P3dModel model, P3dGroup group)
        {
            var paintableTextures = P3dPaintableTexture.Filter(model, group);

            for (var i = paintableTextures.Count - 1; i >= 0; i--)
            {
                Submit(command, model, paintableTextures[i]);
            }
        }
Beispiel #7
0
            public static void SubmitAll(bool preview = false, int layerMask = -1, int groupMask = -1)
            {
                var models = P3dModel.FindOverlap(cachedPosition, cachedSqrRadius, layerMask);

                for (var i = models.Count - 1; i >= 0; i--)
                {
                    SubmitAll(preview, models[i], groupMask);
                }
            }
Beispiel #8
0
        public static void TryUnregister(P3dModel model)
        {
            int hash;

            if (ModelToHash.TryGetValue(model, out hash) == true)
            {
                ModelToHash.Remove(model);
                HashToModel.Remove(hash);
            }
        }
        public static void Submit(P3dCommand command, P3dModel model, P3dPaintableTexture paintableTexture, bool preview)
        {
            var copy = command.SpawnCopy();

            copy.Model   = model;
            copy.Groups  = -1;
            copy.Preview = preview;

            paintableTexture.AddCommand(copy);
        }
Beispiel #10
0
        public bool TryGetInstance(out P3dModel model)
        {
            if (instance != null)
            {
                model = instance;

                return(true);
            }

            return(P3dSerialization.HashToModel.TryGetValue(hash, out model));
        }
        public static void Submit(P3dCommand command, P3dModel model, P3dPaintableTexture paintableTexture)
        {
            var copy = command.SpawnCopy();

            if (copy.Blend.Index == P3dBlendMode.REPLACE_ORIGINAL)
            {
                copy.Blend.Color   = paintableTexture.Color;
                copy.Blend.Texture = paintableTexture.Texture;
            }

            paintableTexture.AddCommand(copy);
        }
        public static P3dCommand Submit(P3dCommand command, P3dModel model, P3dPaintableTexture paintableTexture)
        {
            var copy = command.SpawnCopy();

            copy.Apply(paintableTexture);

            copy.Model   = model;
            copy.Submesh = model.GetSubmesh(paintableTexture);

            paintableTexture.AddCommand(copy);

            return(copy);
        }
        public static void Submit(P3dCommand command, P3dModel model, P3dPaintableTexture paintableTexture, bool preview)
        {
            var copy = command.SpawnCopy();

            copy.Model   = model;
            copy.Groups  = -1;
            copy.Preview = preview;

            if (copy.Blend.Index == P3dBlendMode.REPLACE_ORIGINAL)
            {
                copy.Blend.Color   = paintableTexture.Color;
                copy.Blend.Texture = paintableTexture.Texture;
            }

            paintableTexture.AddCommand(copy);
        }
Beispiel #14
0
        public static int TryRegister(P3dModel model)
        {
            // If you want to be able to network a P3dModel instance, replace this line with something from your networking library that can return the same value for all clients
            var hash = model.GetInstanceID();

            //if (cannotCalculateHash == true) return 0;

            if (HashToModel.ContainsKey(hash) == true)
            {
                throw new System.Exception("You're trying to register the " + model + " P3dModel, but you've already registered the " + HashToModel[hash] + " P3dModel with the same hash.");
            }

            ModelToHash.Add(model, hash);
            HashToModel.Add(hash, model);

            return(hash);
        }
Beispiel #15
0
        /// <summary>This allows you to get a list of all paintable textures on a P3dModel/P3dPaintable within the specified group mask.</summary>
        public static List <P3dPaintableTexture> Filter(P3dModel model, int groupMask)
        {
            tempPaintableTextures.Clear();

            if (model.Paintable != null)
            {
                var paintableTextures = model.Paintable.PaintableTextures;

                for (var i = paintableTextures.Count - 1; i >= 0; i--)
                {
                    var paintableTexture = paintableTextures[i];

                    if (P3dHelper.IndexInMask(paintableTexture.group, groupMask) == true)
                    {
                        tempPaintableTextures.Add(paintableTexture);
                    }
                }
            }

            return(tempPaintableTextures);
        }
Beispiel #16
0
 public static void SubmitAll(bool preview, P3dModel model, P3dPaintableTexture paintableTexture, int groupMask = -1)
 {
     if (model != null)
     {
         if (paintableTexture != null)
         {
             Submit(model, paintableTexture, preview);
         }
         else
         {
             SubmitAll(preview, model, groupMask);
         }
     }
     else
     {
         if (paintableTexture != null)
         {
             Submit(paintableTexture.CachedPaintable, paintableTexture, preview);
         }
     }
 }
        /// <summary>This allows you to get a list of all paintable textures on a P3dModel/P3dPaintable with the specified group.</summary>
        public static List <P3dPaintableTexture> Filter(P3dModel model, P3dGroup group)
        {
            tempPaintableTextures.Clear();

            if (model.Paintable != null)
            {
                var paintableTextures = model.Paintable.PaintableTextures;

                for (var i = paintableTextures.Count - 1; i >= 0; i--)
                {
                    var paintableTexture = paintableTextures[i];

                    if (paintableTexture.group == group)
                    {
                        tempPaintableTextures.Add(paintableTexture);
                    }
                }
            }

            return(tempPaintableTextures);
        }
Beispiel #18
0
            public static void Submit(P3dModel model, P3dPaintableTexture paintableTexture, bool preview)
            {
                var command = paintableTexture.AddCommand(model, pool, ref poolCount, preview);

                CopyTo(command);
            }
        public static void SubmitAll(P3dCommand command, bool preview, int layerMask, int groupMask, P3dModel model = null, P3dPaintableTexture paintableTexture = null, List <P3dTransform> repeaters = null, List <P3dCommand> commands = null)
        {
            command.Model   = null;
            command.Groups  = groupMask;
            command.Preview = preview;

            if (commands != null)
            {
                commands.Add(command.SpawnCopy());

                // Repeat paint?
                BuildRepeaters(command.Matrix, repeaters);

                for (var r = 0; r < RepeaterCount; r++)
                {
                    for (var m = 0; m < MatrixCount; m++)
                    {
                        command.SetLocation(Repeat(r, m));

                        commands.Add(command.SpawnCopy());
                    }
                }
            }
            else
            {
                SubmitAll(command, preview, layerMask, groupMask, model, paintableTexture);

                // Repeat paint?
                BuildRepeaters(command.Matrix);

                for (var r = 0; r < RepeaterCount; r++)
                {
                    for (var m = 0; m < MatrixCount; m++)
                    {
                        command.SetLocation(Repeat(r, m));

                        SubmitAll(command, preview, layerMask, groupMask, model, paintableTexture);
                    }
                }
            }
        }
 private static void DoSubmitAll(P3dCommand command, Vector3 position, float radius, int layerMask, P3dGroup group, P3dModel targetModel, P3dPaintableTexture targetTexture)
 {
     if (targetModel != null)
     {
         if (targetTexture != null)
         {
             Submit(command, targetModel, targetTexture);
         }
         else
         {
             SubmitAll(command, targetModel, group);
         }
     }
     else
     {
         if (targetTexture != null)
         {
             Submit(command, targetTexture.CachedPaintable, targetTexture);
         }
         else
         {
             SubmitAll(command, position, radius, layerMask, group);
         }
     }
 }
        public static void SubmitAll(P3dCommand command, Vector3 position, float radius, int layerMask, P3dGroup group, P3dModel targetModel, P3dPaintableTexture targetTexture)
        {
            DoSubmitAll(command, position, radius, layerMask, group, targetModel, targetTexture);

            // Repeat paint?
            P3dClone.BuildCloners();

            for (var c = 0; c < P3dClone.ClonerCount; c++)
            {
                for (var m = 0; m < P3dClone.MatrixCount; m++)
                {
                    var copy = command.SpawnCopy();

                    P3dClone.Clone(copy, c, m);

                    DoSubmitAll(copy, position, radius, layerMask, group, targetModel, targetTexture);

                    copy.Pool();
                }
            }
        }
 private static void SubmitAll(P3dCommand command, bool preview, int layerMask, int groupMask, P3dModel model, P3dPaintableTexture paintableTexture)
 {
     if (model != null)
     {
         if (paintableTexture != null)
         {
             Submit(command, model, paintableTexture, preview);
         }
         else
         {
             SubmitAll(command, preview, model, groupMask);
         }
     }
     else
     {
         if (paintableTexture != null)
         {
             Submit(command, paintableTexture.CachedPaintable, paintableTexture, preview);
         }
         else
         {
             SubmitAll(command, preview, layerMask, groupMask);
         }
     }
 }