Exemplo n.º 1
0
        private void Paint(Collision collision, PaintingCollision pCont)
        {
            if (pCont.painter.PaintCommand.SetBrush(brush).Is3DBrush)
            {
                var v = pCont.vector;
                v.posTo = transform.position;
                if (v.MouseDownEvent)
                {
                    v.posFrom = v.posTo;
                }

                var command = pCont.painter.PaintCommand;

                var originalStroke = command.Stroke;

                brush.Paint(command);

                command.Stroke = originalStroke;
            }
            else
            {
                if (collision.contacts.Length <= 0)
                {
                    return;
                }

                var cp = collision.contacts[0];

                var ray = new Ray(cp.point + cp.normal * 0.1f, -cp.normal);

                RaycastHit hit;
                if (!collision.collider.Raycast(ray, out hit, 2f))
                {
                    return;
                }

                var v = pCont.vector;

                v.uvTo = hit.textureCoord;
                if (v.MouseDownEvent)
                {
                    v.uvFrom = v.uvTo;
                }

                var command = pCont.painter.PaintCommand;

                var originalVector = command.Stroke;

                command.Stroke = pCont.vector;

                pCont.painter.SetTexTarget(brush);

                brush.Paint(command);

                command.Stroke = originalVector;
            }
        }
Exemplo n.º 2
0
        private void TryGetPainterFrom(GameObject go)
        {
            var target = go.GetComponent <PlaytimePainter>();

            if (!target || target.LockTextureEditing)
            {
                return;
            }

            var col = new PaintingCollision(target);

            paintingOn.Add(col);
            col.vector.posFrom     = transform.position;
            col.vector.firstStroke = true;
            target.UpdateOrSetTexTarget(TexTarget.RenderTexture);
        }
Exemplo n.º 3
0
        private void Paint(Collision collision, PaintingCollision pCont)
        {
            if (brush.IsA3DBrush(pCont.painter))
            {
                var v = pCont.vector;
                v.posTo = transform.position;
                if (v.mouseDwn)
                {
                    v.posFrom = v.posTo;
                }
                brush.Paint(v, pCont.painter);
            }
            else
            {
                if (collision.contacts.Length <= 0)
                {
                    return;
                }

                var cp = collision.contacts[0];



                var ray = new Ray(cp.point + cp.normal * 0.1f, -cp.normal);

                RaycastHit hit;
                if (!collision.collider.Raycast(ray, out hit, 2f))
                {
                    return;
                }

                var v = pCont.vector;
                var p = pCont.painter;

                v.uvTo = hit.textureCoord;
                if (v.mouseDwn)
                {
                    v.uvFrom = v.uvTo;
                }

                brush.Paint(pCont.vector, pCont.painter.SetTexTarget(brush));
            }
        }
Exemplo n.º 4
0
        private PaintingCollision GetPainterFrom(GameObject go)
        {
            foreach (var col in _paintingOn)
            {
                if (col.painter.gameObject == go)
                {
                    return(col);
                }
            }

            var pp = go.GetComponent <PlaytimePainter>();

            if (!pp)
            {
                return(null);
            }

            var nCol = new PaintingCollision(pp);

            _paintingOn.Add(nCol);

            return(nCol);
        }