コード例 #1
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]);
            }
        }
コード例 #2
0
            public Texture GetFinalTexture(P3dGroup group)
            {
                var mergedLayer = default(MergedLayer);

                if (MergedLayers.TryGetValue(group, out mergedLayer) == true)
                {
                    return(mergedLayer.Final);
                }

                return(null);
            }
コード例 #3
0
ファイル: P3dPaintMaterial.cs プロジェクト: MikeMnD/Bath-Bomb
        public Slot GetSlot(P3dGroup group)
        {
            foreach (var slot in Slots)
            {
                if (slot.Group == group)
                {
                    return(slot);
                }
            }

            return(null);
        }
コード例 #4
0
            public void UpdateMergedLayers(P3dGroup group)
            {
                var mergedLayer = default(MergedLayer);

                if (MergedLayers.TryGetValue(group, out mergedLayer) == false)
                {
                    mergedLayer = new MergedLayer();

                    MergedLayers.Add(group, mergedLayer);
                }

                mergedLayer.Dirty = false;
            }
コード例 #5
0
            public Image GetImage(int matId, P3dGroup group)
            {
                foreach (var image in Images)
                {
                    if (image.MatId == matId && image.Group == group)
                    {
                        return(image);
                    }
                }

                var newImage = new Image();

                newImage.MatId = matId;
                newImage.Group = group;

                Images.Add(newImage);

                return(newImage);
            }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
        public void Paint(P3dGroup group, P3dCommand command)
        {
            var commandMaterial = command.Material;

            //if (bounds.Intersects(lastBounds) == true)
            {
                for (var i = PaintableTextures.Count - 1; i >= 0; i--)
                {
                    var paintableTexture = PaintableTextures[i];
                    var renderTexture    = paintableTexture.PreparePaint();                     // Prepare the paint regardless, to sync undo states

                    if (paintableTexture.Group == group)
                    {
                        var oldActive = RenderTexture.active;
                        var swap      = default(RenderTexture);

                        RenderTexture.active = renderTexture;

                        if (command.RequireSwap == true)
                        {
                            swap = P3dHelper.GetRenderTexture(renderTexture.width, renderTexture.height, renderTexture.depth, renderTexture.format);

                            P3dHelper.Blit(swap, renderTexture);

                            commandMaterial.SetTexture(P3dShader._Buffer, swap);
                        }

                        command.Apply();

                        if (command.RequireMesh == true)
                        {
                            switch (paintableTexture.Channel)
                            {
                            case P3dChannel.UV: commandMaterial.SetVector(P3dShader._Channel, new Vector4(1.0f, 0.0f, 0.0f, 0.0f)); break;

                            case P3dChannel.UV2: commandMaterial.SetVector(P3dShader._Channel, new Vector4(0.0f, 1.0f, 0.0f, 0.0f)); break;

                            case P3dChannel.UV3: commandMaterial.SetVector(P3dShader._Channel, new Vector4(0.0f, 0.0f, 1.0f, 0.0f)); break;

                            case P3dChannel.UV4: commandMaterial.SetVector(P3dShader._Channel, new Vector4(0.0f, 0.0f, 0.0f, 1.0f)); break;
                            }

                            commandMaterial.SetPass(0);

                            Graphics.DrawMeshNow(lastMesh, lastMatrix, paintableTexture.MaterialIndex);
                        }
                        else
                        {
                            Graphics.Blit(default(Texture), renderTexture, commandMaterial);
                        }

                        RenderTexture.active = oldActive;

                        if (swap != null)
                        {
                            P3dHelper.ReleaseRenderTexture(swap);
                        }
                    }
                }
            }
        }
コード例 #8
0
        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);
            }
        }
コード例 #9
0
 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);
         }
     }
 }
コード例 #10
0
        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();
                }
            }
        }
コード例 #11
0
        private static void TryBlendInto(ref RenderTexture renderTexture, Layer layer, int matId, P3dGroup group)
        {
            var image   = layer.GetImage(matId, group);
            var texture = image.Preview ?? image.Current;

            if (texture != null)
            {
                renderTexture = P3dPaintFill.Blit(renderTexture, P3dBlendMode.AlphaBlend, texture, Color.white, layer.Opacity, 0.0f);
            }
        }