private void UseSkinMeshAsBrush(PaintCommand.WorldSpace command) { GameObject go = command.GameObject; SkinnedMeshRenderer skinny = command.SkinnedMeshRenderer; int subMesh = command.SubMeshIndexFirst; _modifiedSubMesh = subMesh; meshRenderer.enabled = false; var camTransform = PainterCamera.Inst.transform; _changedSkinnedMeshRenderer = skinny; _changedGameObject = go; modifiedBound = skinny.localBounds; skinny.localBounds = new Bounds(go.transform.InverseTransformPoint(camTransform.position + camTransform.forward * 100), Vector3.one * 15000f); _replacedLayer = go.layer; go.layer = gameObject.layer; var lst = skinny.sharedMaterials; _replacedTargetsMaterial = lst[_modifiedSubMesh]; lst[_modifiedSubMesh] = meshRenderer.sharedMaterial; skinny.sharedMaterials = lst; deformedBounds = true; }
private void UseMeshAsBrush(PaintCommand.WorldSpace command) { GameObject go = command.GameObject; Mesh mesh = command.Mesh; List <int> selectedSubMeshes = command.SelectedSubmeshes; if (!mesh) { Debug.LogError("No mesh in Use Mesh As Brush Command"); return; } if (selectedSubMeshes.IsNullOrEmpty()) { QcUnity.ChillLogger.LogErrorOnce(() => "PaintCommand.WorldSpace arrived with unassigned selectedSubmeshes array. Seeting 0", key: "emptSbM"); selectedSubMeshes = new List <int>(1) { 0 }; } var camTransform = TexMGMT.transform; var target = go.transform; var tf = transform; tf.position = target.position; tf.rotation = target.rotation; tf.localScale = target.localScale; _modifiedMesh = mesh; meshFilter.sharedMesh = mesh; modifiedBound = _modifiedMesh.bounds; _modifiedMesh.bounds = new Bounds(transform.InverseTransformPoint(camTransform.position + camTransform.forward * 100), Vector3.one * 500f); tf.parent = target.parent; _replacedBrushesMaterials = meshRenderer.sharedMaterials; var max = 0; foreach (var e in selectedSubMeshes) { max = Mathf.Max(e, max); } if (max > 0) { var mats = new Material[max + 1]; foreach (var e in selectedSubMeshes) { mats[e] = meshRenderer.sharedMaterial; } meshRenderer.materials = mats; } deformedBounds = true; }
public static void PaintAtlased(PaintCommand.WorldSpace command, int aTexturesInRow) { PainterShaderVariables.BRUSH_ATLAS_SECTION_AND_ROWS.GlobalValue = new Vector4(0, 0, aTexturesInRow, 1); Paint(command); PainterShaderVariables.BRUSH_ATLAS_SECTION_AND_ROWS.GlobalValue = new Vector4(0, 0, 1, 0); }
public void Prepare(PaintCommand.WorldSpace command) { if (command.SkinnedMeshRenderer) { UseSkinMeshAsBrush(command); } else { UseMeshAsBrush(command); } }
public static void Paint(PaintCommand.WorldSpace command) { Brush br = command.Brush; Stroke st = command.Stroke; br.GetBlitMode(false).PrePaint(command); PrepareSphereBrush(command); TexMGMT.brushRenderer.Prepare(command); TexMGMT.Render(); br.GetBrushType(false).AfterStroke(command); }
public override void PaintRenderTextureInWorldSpace(PaintCommand.WorldSpace command) //PlaytimePainter painter, Brush br, Stroke st) { var id = command.TextureData; //painter.TexMeta; BeforeStroke(command); //br, st, painter); //bool alphaBuffer; PrepareSphereBrush(command); //id, br, st, out alphaBuffer, painter); if (!command.Stroke.MouseDownEvent) { TexMGMT.brushRenderer.Prepare(command); TexMGMT.Render(); } AfterStroke(command); //painter, br, st, alphaBuffer, id); }
private void UseMeshAsBrush(PaintCommand.WorldSpace command) { GameObject go = command.GameObject; Mesh mesh = command.Mesh; List <int> selectedSubMeshes = command.SelectedSubmeshes; var camTransform = TexMGMT.transform; var target = go.transform; var tf = transform; tf.position = target.position; tf.rotation = target.rotation; tf.localScale = target.localScale; _modifiedMesh = mesh; meshFilter.sharedMesh = mesh; modifiedBound = _modifiedMesh.bounds; _modifiedMesh.bounds = new Bounds(transform.InverseTransformPoint(camTransform.position + camTransform.forward * 100), Vector3.one * 500f); tf.parent = target.parent; _replacedBrushesMaterials = meshRenderer.sharedMaterials; var max = 0; foreach (var e in selectedSubMeshes) { max = Mathf.Max(e, max); } if (max > 0) { var mats = new Material[max + 1]; foreach (var e in selectedSubMeshes) { mats[e] = meshRenderer.sharedMaterial; } meshRenderer.materials = mats; } deformedBounds = true; }
private static void PrepareSphereBrush(PaintCommand.WorldSpace command) { Brush br = command.Brush; var td = command.TextureData; // if (stroke.mouseDwn) // stroke.posFrom = stroke.posTo; command.strokeAlphaPortion = Mathf.Clamp01(br.Flow * 0.05f); TexMGMT.SHADER_STROKE_SEGMENT_UPDATE(command); // br, br.Speed * 0.05f, id, stroke, out alphaBuffer, painter); var offset = command.TextureData.offset - command.Stroke.unRepeatedUv.Floor(); command.Stroke.SetWorldPosInShader(); PainterShaderVariables.BRUSH_EDITED_UV_OFFSET.GlobalValue = new Vector4(td.tiling.x, td.tiling.y, offset.x, offset.y); PainterShaderVariables.BRUSH_ATLAS_SECTION_AND_ROWS.GlobalValue = new Vector4(0, 0, 1, 0); }
public virtual void PaintRenderTextureInWorldSpace(PaintCommand.WorldSpace command) { }