public override void AfterGpuStroke(BrushConfig br, StrokeVector st, BrushTypes.Base type) { if (br.IsA3DBrush(painter) && painter.IsAtlased()) { PainterShaderVariables.BRUSH_ATLAS_SECTION_AND_ROWS.GlobalValue = new Vector4(0, 0, 1, 0); } }
private void Paint() { RaycastHit hit; if (!Physics.Raycast(new Ray(transform.position, transform.forward), out hit)) { lastShotResult = "Didn't hit any colliders"; return; } var painter = hit.transform.GetComponentInParent <PlaytimePainter>(); if (!painter) { lastShotResult = "No painter detected on {0}".F(hit.transform.name); return; } if (painter.skinnedMeshRenderer && !brush.IsA3DBrush(painter)) { painter.UpdateMeshCollider(); var colliderDisabled = !painter.meshCollider.enabled; if (colliderDisabled) { painter.meshCollider.enabled = true; } if (!painter.meshCollider.Raycast(new Ray(transform.position, transform.forward), out hit, 99999)) { lastShotResult = "Missed updated Collider"; if (colliderDisabled) { painter.meshCollider.enabled = false; } return; } if (colliderDisabled) { painter.meshCollider.enabled = false; } lastShotResult = "Updated Collider for skinned mesh and Painted"; } else { lastShotResult = "Painted on Object"; } var v = new StrokeVector(hit, false); brush.Paint(v, painter.SetTexTarget(brush)); }
private void Update() { brush.brush3DRadius = transform.lossyScale.x * 1.4f; foreach (var col in paintingOn) { var p = col.painter; if (!brush.IsA3DBrush(p)) { continue; } var v = col.vector; v.posTo = transform.position; brush.Paint(v, p); } }
public override void BeforeGpuStroke(BrushConfig br, StrokeVector st, BrushTypes.Base type) { if (!br.IsA3DBrush(painter) || !painter.IsAtlased()) { return; } var ats = GetAtlasedSection(); PainterShaderVariables.BRUSH_ATLAS_SECTION_AND_ROWS.GlobalValue = new Vector4(ats.x, ats.y, atlasRows, 1); }
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)); } }