Example #1
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);
                    }
                }
            }
        }
Example #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);
                        }
                    }
                }
            }
        }
Example #3
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);
                        }
                    }
                }
            }
        }
        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);
                        }
                    }
                }
            }
        }
Example #5
0
        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]);
            }
        }
        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);
            }
        }
Example #7
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);
                }
            }
Example #8
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);
                    }
                }
            }
Example #9
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);
                }
            }
        }
Example #10
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 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)
                {
                    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);
                    }
                }
            }
        }