Пример #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);
                    }
                }
            }
        }
        private Vector3 HandleHitCommon(bool preview, float pressure, int seed, Quaternion rotation)
        {
            var finalOpacity    = opacity;
            var finalRadius     = radius;
            var finalHardness   = hardness;
            var finalColor      = color;
            var finalAngle      = angle;
            var finalTileMatrix = tileTransform != null ? tileTransform.localToWorldMatrix : Matrix4x4.identity;

            if (modifiers != null && modifiers.Count > 0)
            {
                P3dHelper.BeginSeed(seed);
                modifiers.ModifyColor(ref finalColor, preview, pressure);
                modifiers.ModifyAngle(ref finalAngle, preview, pressure);
                modifiers.ModifyOpacity(ref finalOpacity, preview, pressure);
                modifiers.ModifyRadius(ref finalRadius, preview, pressure);
                modifiers.ModifyHardness(ref finalHardness, preview, pressure);
                P3dHelper.EndSeed();
            }

            var finalSize = scale * finalRadius;

            P3dCommandSphere.Instance.SetShape(rotation, finalSize, finalAngle);

            P3dCommandSphere.Instance.SetMaterial(BlendMode, finalHardness, finalColor, finalOpacity, tileTexture, finalTileMatrix, tileOpacity, tileTransition);

            return(finalSize);
        }
        private Vector3 HandleHitCommon(bool preview, float pressure, int seed, Quaternion rotation)
        {
            var finalOpacity  = opacity;
            var finalRadius   = radius;
            var finalHardness = hardness;
            var finalColor    = color;
            var finalAngle    = angle;
            var finalTexture  = texture;
            var finalMatrix   = tileTransform != null ? tileTransform.localToWorldMatrix : Matrix4x4.identity;

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

            var finalAspect = P3dHelper.GetAspect(shape, finalTexture);
            var finalSize   = P3dHelper.ScaleAspect(scale * finalRadius, finalAspect);

            P3dCommandDecal.Instance.SetShape(rotation, finalSize, finalAngle);

            P3dCommandDecal.Instance.SetMaterial(blendMode, finalTexture, shape, shapeChannel, finalHardness, wrapping, normalBack, normalFront, normalFade, finalColor, finalOpacity, tileTexture, finalMatrix, tileOpacity, tileTransition);

            return(finalSize);
        }
Пример #4
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);
                    }
                }
            }
        }
Пример #5
0
        /// <summary>This method paints all pixels at the specified point using the shape of a sphere.</summary>
        public void HandleHitPoint(bool preview, int priority, float pressure, int seed, Vector3 position, Quaternion rotation)
        {
            if (paint != PaintType.In3D)
            {
                return;
            }

            if (modifiers != null && modifiers.Count > 0)
            {
                P3dHelper.BeginSeed(seed);
                modifiers.ModifyPosition(ref position, preview, pressure);
                P3dHelper.EndSeed();
            }

            P3dCommandDecal.Instance.SetState(preview, priority);
            P3dCommandDecal.Instance.SetLocation(position);

            var worldSize     = HandleHitCommon(preview, pressure, seed, rotation);
            var worldRadius   = P3dHelper.GetRadius(worldSize);
            var worldPosition = position;

            HandleMaskCommon(worldPosition);

            P3dPaintableManager.SubmitAll(P3dCommandDecal.Instance, worldPosition, worldRadius, layers, group, targetModel, targetTexture);
        }
Пример #6
0
 public void ModifyRadius(ref float radius, float pressure)
 {
     if (unique == true)
     {
         P3dHelper.BeginUniqueSeed();
         OnModifyRadius(ref radius, pressure);
         P3dHelper.EndSeed();
     }
     else
     {
         OnModifyRadius(ref radius, pressure);
     }
 }
Пример #7
0
 public void ModifyOpacity(ref float opacity, float pressure)
 {
     if (unique == true)
     {
         P3dHelper.BeginUniqueSeed();
         OnModifyOpacity(ref opacity, pressure);
         P3dHelper.EndSeed();
     }
     else
     {
         OnModifyOpacity(ref opacity, pressure);
     }
 }
Пример #8
0
 public void ModifyHardness(ref float hardness, float pressure)
 {
     if (unique == true)
     {
         P3dHelper.BeginUniqueSeed();
         OnModifyHardness(ref hardness, pressure);
         P3dHelper.EndSeed();
     }
     else
     {
         OnModifyHardness(ref hardness, pressure);
     }
 }
Пример #9
0
 public void ModifyColor(ref Color color, float pressure)
 {
     if (unique == true)
     {
         P3dHelper.BeginUniqueSeed();
         OnModifyColor(ref color, pressure);
         P3dHelper.EndSeed();
     }
     else
     {
         OnModifyColor(ref color, pressure);
     }
 }
Пример #10
0
 public void ModifyAngle(ref float angle, float pressure)
 {
     if (unique == true)
     {
         P3dHelper.BeginUniqueSeed();
         OnModifyAngle(ref angle, pressure);
         P3dHelper.EndSeed();
     }
     else
     {
         OnModifyAngle(ref angle, pressure);
     }
 }
Пример #11
0
 public void ModifyPosition(ref Vector3 position, float pressure)
 {
     if (unique == true)
     {
         P3dHelper.BeginUniqueSeed();
         OnModifyPosition(ref position, pressure);
         P3dHelper.EndSeed();
     }
     else
     {
         OnModifyPosition(ref position, pressure);
     }
 }
Пример #12
0
 public void ModifyTexture(ref Texture texture, float pressure)
 {
     if (unique == true)
     {
         P3dHelper.BeginUniqueSeed();
         OnModifyTexture(ref texture, pressure);
         P3dHelper.EndSeed();
     }
     else
     {
         OnModifyTexture(ref texture, pressure);
     }
 }
Пример #13
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);
                }
            }
        }