Ejemplo n.º 1
0
        private Vector3 HandleHitCommon(Quaternion rotation, float pressure)
        {
            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;
            var finalAspect   = P3dHelper.GetAspect(shape, texture);

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

            rotation = rotation * Quaternion.Euler(0.0f, 0.0f, finalAngle);

            var finalSize = Command.Instance.SetShape(rotation, scale, finalRadius, finalAspect);

            Command.Instance.SetMaterial(blendMode, texture, shape, shapeChannel, finalHardness, wrapping, normalBack, normalFront, normalFade, finalColor, finalOpacity, tileTexture, finalMatrix, tileBlend);

            return(finalSize);
        }
Ejemplo n.º 2
0
        public void HandleHitPoint(List <P3dCommand> commands, List <P3dTransform> repeaters, bool preview, Collider collider, Vector3 worldPosition, Quaternion worldRotation, float pressure)
        {
            var finalOpacity  = opacity + (1.0f - opacity) * opacityPressure * pressure;
            var finalRadius   = radius + radiusPressure * pressure;
            var finalDepth    = depth + depthPressure * pressure;
            var finalHardness = hardness + hardnessPressure * pressure;
            var finalColor    = color;
            var finalAngle    = angle;
            var finalTexture  = texture;

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

            worldRotation = worldRotation * Quaternion.Euler(0.0f, 0.0f, finalAngle);

            Command.Instance.SetLocation(worldPosition, worldRotation, scale, finalRadius, finalTexture, finalDepth);

            Command.Instance.SetMaterial(blendMode, texture, finalHardness, normalBack, normalFront, normalFade, finalColor, finalOpacity, shape);

            P3dPaintableManager.SubmitAll(Command.Instance, preview, layers, groups, targetModel, targetTexture, repeaters, commands);
        }
Ejemplo n.º 3
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);
                }
            }
        }