Beispiel #1
0
        public void HandleHitCoord(bool preview, int priority, float pressure, int seed, P3dHit hit, Quaternion rotation)
        {
            var model = hit.Root.GetComponentInParent <P3dModel>();

            if (model != null)
            {
                var paintableTextures = P3dPaintableTexture.FilterAll(model, group);

                if (paintableTextures.Count > 0)
                {
                    var finalColor   = color;
                    var finalOpacity = opacity;
                    var finalTexture = texture;

                    if (modifiers != null && modifiers.Count > 0)
                    {
                        P3dHelper.BeginSeed(seed);
                        modifiers.ModifyColor(ref finalColor, preview, pressure);
                        modifiers.ModifyOpacity(ref finalOpacity, preview, pressure);
                        modifiers.ModifyTexture(ref finalTexture, preview, pressure);
                        P3dHelper.EndSeed();
                    }

                    P3dCommandFill.Instance.SetState(preview, priority);
                    P3dCommandFill.Instance.SetMaterial(blendMode, finalTexture, finalColor, opacity, minimum);

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

                        P3dPaintableManager.Submit(P3dCommandFill.Instance, model, paintableTexture);
                    }
                }
            }
        }
Beispiel #2
0
        public void HandleHitPoint(bool preview, int priority, Collider collider, Vector3 worldPosition, Quaternion worldRotation, float pressure)
        {
            if (collider != null)
            {
                var model = collider.GetComponent <P3dModel>();

                if (model != null)
                {
                    var paintableTextures = P3dPaintableTexture.Filter(model, group);

                    if (paintableTextures.Count > 0)
                    {
                        var finalColor   = color;
                        var finalTexture = texture;

                        P3dPaintableManager.BuildModifiers(gameObject);
                        P3dPaintableManager.ModifyColor(pressure, ref finalColor);
                        P3dPaintableManager.ModifyTexture(pressure, ref finalTexture);

                        Command.Instance.SetState(preview, priority);
                        Command.Instance.SetMaterial(finalTexture, finalColor);

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

                            P3dPaintableManager.Submit(Command.Instance, model, paintableTexture);
                        }
                    }
                }
            }
        }
        public void HandleHitPoint(bool preview, int priority, Collider collider, Vector3 worldPosition, Quaternion worldRotation, float pressure)
        {
            if (collider != null)
            {
                var model = collider.GetComponent <P3dModel>();

                if (model != null)
                {
                    var paintableTextures = P3dPaintableTexture.Filter(model, group);

                    if (paintableTextures.Count > 0)
                    {
                        Command.Instance.SetState(preview, priority);
                        Command.Instance.SetMaterial(textureR, textureG, textureB, textureA, channelR, channelG, channelB, channelA);

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

                            P3dPaintableManager.Submit(Command.Instance, model, paintableTexture);
                        }
                    }
                }
            }
        }
Beispiel #4
0
        public void HandleHitPoint(List <P3dCommand> commands, List <P3dTransform> repeaters, bool preview, Collider collider, Vector3 worldPosition, Quaternion worldRotation, float pressure)
        {
            if (collider != null)
            {
                var model = collider.GetComponent <P3dModel>();

                if (model != null)
                {
                    var paintableTextures = P3dPaintableTexture.Filter(model, groups);

                    if (paintableTextures.Count > 0)
                    {
                        var finalColor   = color;
                        var finalOpacity = opacity;
                        var finalTexture = texture;

                        P3dPaintableManager.BuildModifiers(gameObject);
                        P3dPaintableManager.ModifyColor(ref finalColor);
                        P3dPaintableManager.ModifyOpacity(ref finalOpacity);
                        P3dPaintableManager.ModifyTexture(ref finalTexture);

                        Command.Instance.SetMaterial(blendMode, finalTexture, finalColor, opacity);

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

                            P3dPaintableManager.Submit(Command.Instance, model, paintableTexture, preview);
                        }
                    }
                }
            }
        }
Beispiel #5
0
        public void HandleHitCoord(bool preview, int priority, float pressure, int seed, P3dHit hit, Quaternion rotation)
        {
            if (preview == true && this.preview == false)
            {
                return;
            }

            var model = hit.Root.GetComponent <P3dModel>();

            if (model != null)
            {
                var paintableTextures = P3dPaintableTexture.FilterAll(model, group);

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

                    color = P3dHelper.GetPixel(paintableTexture.Current, coord);

                    if (onColor != null)
                    {
                        onColor.Invoke(color);
                    }
                }
            }
        }
Beispiel #6
0
        public void HandleHitRaycast(bool preview, int priority, float pressure, int seed, RaycastHit hit, Quaternion rotation)
        {
            var model = hit.collider.GetComponentInParent <P3dModel>();

            if (model != null)
            {
                var paintableTextures = P3dPaintableTexture.Filter(model, group);

                if (paintableTextures.Count > 0)
                {
                    var finalColor   = color;
                    var finalTexture = texture;

                    if (modifiers != null && modifiers.Count > 0)
                    {
                        P3dHelper.BeginSeed(seed);
                        modifiers.ModifyColor(ref finalColor, preview, pressure);
                        modifiers.ModifyTexture(ref finalTexture, preview, pressure);
                        P3dHelper.EndSeed();
                    }

                    P3dCommandReplace.Instance.SetState(preview, priority);
                    P3dCommandReplace.Instance.SetMaterial(finalTexture, finalColor);

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

                        P3dPaintableManager.Submit(P3dCommandReplace.Instance, model, paintableTexture);
                    }
                }
            }
        }
        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 #8
0
        public void Unregister()
        {
            if (registeredPaintableTexture != null)
            {
                registeredPaintableTexture.OnModified -= HandleModified;

                registeredPaintableTexture = null;
            }
        }
        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);
            }
        }
Beispiel #10
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);
                }
            }
        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 #12
0
        public static void TryUnregister(P3dPaintableTexture paintableTexture)
        {
            int hash;

            if (PaintableTextureToHash.TryGetValue(paintableTexture, out hash) == true)
            {
                PaintableTextureToHash.Remove(paintableTexture);
                HashToPaintableTexture.Remove(hash);
            }
        }
 /// <summary>This allows you to manually unregister a P3dPaintableTexture.</summary>
 public void Unregister(P3dPaintableTexture paintableTexture)
 {
     for (var i = paintableTextures.Count - 1; i >= 0; i--)
     {
         if (paintableTextures[i] == paintableTexture)
         {
             paintableTextures.RemoveAt(i);
         }
     }
 }
        public override void Apply(P3dPaintableTexture paintableTexture)
        {
            base.Apply(paintableTexture);

            if (Blend.Index == P3dBlendMode.REPLACE_ORIGINAL)
            {
                Blend.Color   = paintableTexture.Color;
                Blend.Texture = paintableTexture.Texture;
            }
        }
Beispiel #15
0
        public void Register()
        {
            Unregister();

            if (paintableTexture != null)
            {
                paintableTexture.OnModified += HandleModified;

                registeredPaintableTexture = paintableTexture;
            }
        }
        /// <summary>This allows you to manually register a P3dPaintableTexture.</summary>
        public void Register(P3dPaintableTexture paintableTexture)
        {
            for (var i = paintableTextures.Count - 1; i >= 0; i--)
            {
                if (paintableTextures[i] == paintableTexture)
                {
                    return;
                }
            }

            paintableTextures.Add(paintableTexture);
        }
        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);
        }
Beispiel #18
0
        public void HandlePaint(P3dPaintableTexture newPaintableTexture, bool preview)
        {
            if (paintableTexture == null)
            {
                paintableTexture = newPaintableTexture;
            }

            if (paintableTexture == newPaintableTexture && preview == false)
            {
                Calculate();
            }
        }
Beispiel #19
0
        private bool HasPaintableTexture(P3dPaintableTexture[] candidates, P3dPaintableTexture paintableTexture)
        {
            foreach (var candidate in candidates)
            {
                if (candidate.Slot.Name == paintableTexture.Slot.Name)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #20
0
        public int GetSubmesh(P3dPaintableTexture paintableTexture)
        {
            var material = paintableTexture.Material;

            if (material == null)
            {
                paintableTexture.UpdateMaterial();

                material = paintableTexture.Material;
            }

            return(Paintable.GetMaterialIndex(material));
        }
        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);
        }
Beispiel #22
0
            public static void SubmitAll(bool preview = false, int layerMask = -1, int groupMask = -1)
            {
                var paintables = P3dPaintable.FindOverlap(cachedPosition, cachedSqrRadius, layerMask);

                for (var i = paintables.Count - 1; i >= 0; i--)
                {
                    var paintableTextures = P3dPaintableTexture.Filter(paintables[i], groupMask);

                    for (var j = paintableTextures.Count - 1; j >= 0; j--)
                    {
                        Submit(paintableTextures[j], preview);
                    }
                }
            }
Beispiel #23
0
        public void HandleHitRaycast(bool preview, int priority, RaycastHit hit, float pressure)
        {
            var model = hit.collider.GetComponent <P3dModel>();

            if (model != null)
            {
                var paintableTextures = P3dPaintableTexture.Filter(model, group);
                var finalOpacity      = opacity + (1.0f - opacity) * opacityPressure * pressure;
                var finalRadius       = radius + radiusPressure * pressure;
                var finalColor        = color;
                var finalAngle        = angle;
                var finalTexture      = texture;

                P3dPaintableManager.BuildModifiers(gameObject);
                P3dPaintableManager.ModifyColor(pressure, ref finalColor);
                P3dPaintableManager.ModifyAngle(pressure, ref finalAngle);
                P3dPaintableManager.ModifyOpacity(pressure, ref finalOpacity);
                P3dPaintableManager.ModifyRadius(pressure, ref finalRadius);
                P3dPaintableManager.ModifyTexture(pressure, ref finalTexture);

                Command.Instance.SetMaterial(blendMode, finalTexture, finalColor, finalOpacity, shape);

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

                    switch (paintableTexture.Channel)
                    {
                    case P3dCoord.First:
                    {
                        coord = hit.textureCoord;
                    }
                    break;

                    case P3dCoord.Second:
                    {
                        coord = hit.textureCoord2;
                    }
                    break;
                    }

                    Command.Instance.SetState(preview, priority);
                    Command.Instance.SetLocation(paintableTexture.Current, coord, finalAngle, scale, finalRadius, texture);

                    P3dPaintableManager.Submit(Command.Instance, model, paintableTexture);
                }
            }
        }
Beispiel #24
0
        public static void TryRegister(P3dPaintableTexture paintableTexture)
        {
            // If you want to be able to network a P3dPaintableTexture instance, replace this line with something from your networking library that can return the same value for all clients
            var hash = paintableTexture.GetInstanceID();

            //if (cannotCalculateHash == true) return;

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

            PaintableTextureToHash.Add(paintableTexture, hash);
            HashToPaintableTexture.Add(hash, paintableTexture);
        }
        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 #26
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);
         }
     }
 }
Beispiel #27
0
        /// <summary>This method paints the scene using the current component settings at the specified <b>RaycastHit</b>.
        /// NOTE: The <b>rotation</b> argument is in world space, where <b>Quaternion.identity</b> means the paint faces forward on the +Z axis, and up is +Y.</summary>
        public void HandleHitRaycast(bool preview, int priority, float pressure, int seed, RaycastHit hit, Quaternion rotation)
        {
            if (paint == PaintType.In3D)
            {
                return;
            }

            var model = hit.collider.GetComponent <P3dModel>();

            if (model != null)
            {
                var paintableTextures = P3dPaintableTexture.Filter(model, group);

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

                    if (modifiers != null && modifiers.Count > 0)
                    {
                        var position = (Vector3)coord;

                        P3dHelper.BeginSeed(seed);
                        modifiers.ModifyPosition(ref position, preview, pressure);
                        P3dHelper.EndSeed();

                        coord = position;
                    }

                    P3dCommandDecal.Instance.SetState(preview, priority);
                    P3dCommandDecal.Instance.SetLocation(coord, false);

                    HandleHitCommon(preview, pressure, seed, rotation);

                    P3dCommandDecal.Instance.ApplyAspect(paintableTexture.Current);

                    P3dPaintableManager.Submit(P3dCommandDecal.Instance, model, paintableTexture);
                }
            }
        }
        public void HandleHitCoord(bool preview, int priority, float pressure, int seed, P3dHit hit, Quaternion rotation)
        {
            var model = hit.Root.GetComponentInParent <P3dModel>();

            if (model != null)
            {
                var paintableTextures = P3dPaintableTexture.FilterAll(model, group);

                if (paintableTextures.Count > 0)
                {
                    P3dCommandReplaceChannels.Instance.SetState(preview, priority);
                    P3dCommandReplaceChannels.Instance.SetMaterial(textureR, textureG, textureB, textureA, channelR, channelG, channelB, channelA);

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

                        P3dPaintableManager.Submit(P3dCommandReplaceChannels.Instance, model, paintableTexture);
                    }
                }
            }
        }
 /// <summary>This allows you to manually unregister a P3dPaintableTexture.</summary>
 public void Unregister(P3dPaintableTexture paintableTexture)
 {
     paintableTextures.Remove(paintableTexture);
 }
 /// <summary>This allows you to manually register a P3dPaintableTexture.</summary>
 public void Register(P3dPaintableTexture paintableTexture)
 {
     paintableTextures.Add(paintableTexture);
 }