public ToyCombination(BaseToy toyBase, IEnumerable <ToyAttachment> toyAttachments, PaintJob paintJob) { ToyBase = toyBase; PaintJob = paintJob; ToyAttachments = toyAttachments.ToArray(); }
void FillMesh(PaintJob job) { PrepBrushMode(job); for (int i = 0; i < job.stream.colors.Length; ++i) { SetValue(job.stream, i); } job.stream.Apply(); }
/// <summary> /// Compute part of animation. /// </summary> private void ComputeAnimationPart(int from, int to, int steps, ParameterHistory animationHistory, int historyIndex) { lblAnimationProgress.Text = "compute: " + from.ToString() + " " + to.ToString(); for (int i = 0; i < steps && !_animationAbort; i++) { lblAnimationProgress.Text = "compute: " + from.ToString() + " " + to.ToString() + " Step " + i.ToString() + " (from " + steps.ToString() + ")"; double r = 1.0 / steps * (double)i; Application.DoEvents(); if (_animationSmooth) { animationHistory.LoadSmoothed(r + historyIndex); } else { animationHistory.Load(r + historyIndex); } int updateSteps = ParameterDict.Current.GetInt("View.UpdateSteps"); if (updateSteps <= 0) { updateSteps = 0; } if (updateSteps > 1) { ParameterDict.Current.SetInt("View.UpdateSteps", updateSteps - 1); } ResultImageView.PublicForm.SetPictureBoxSize(); Fractrace.Scheduler.PaintJob paintJob = new Scheduler.PaintJob(ResultImageView.PublicForm, ResultImageView.PublicForm.GestaltPicture); _currentPaintJob = paintJob; paintJob.Run(updateSteps); ResultImageView.PublicForm.CallDrawImage(); if (_stepPreviewControls.ContainsKey(from)) { _stepPreviewControls[from].UpdateComputedStep(i); } } }
public void SelectedPaintJob(PaintJob paintJob) { PaintJob = paintJob; }
void PrepBrushMode(PaintJob j) { // make sure the instance data is initialized switch (brushMode) { case BrushMode.Color: goto case BrushMode.ValueA; case BrushMode.ValueR:goto case BrushMode.ValueA; case BrushMode.ValueG:goto case BrushMode.ValueA; case BrushMode.ValueB:goto case BrushMode.ValueA; case BrushMode.ValueA: { Color[] colors = j.stream.colors; if (colors == null || colors.Length != j.verts.Length) { j.stream.SetColor(Color.white, j.verts.Length); colors = j.stream.colors; } break; } case BrushMode.U0:goto case BrushMode.V0; case BrushMode.V0: { Vector2[] uvs = j.stream.uv0; if (uvs == null || uvs.Length != j.verts.Length) { if (j.meshFilter.sharedMesh.uv != null && j.meshFilter.sharedMesh.uv.Length == j.verts.Length) { j.stream.uv0 = new Vector2[j.meshFilter.sharedMesh.uv.Length]; j.meshFilter.sharedMesh.uv.CopyTo(j.stream.uv0, 0); } else { j.stream.SetUV0(Vector2.zero, j.verts.Length); } } break; } case BrushMode.U1: goto case BrushMode.V1; case BrushMode.V1: { Vector2[] uvs = j.stream.uv1; if (uvs == null || uvs.Length != j.verts.Length) { if (j.meshFilter.sharedMesh.uv2 != null && j.meshFilter.sharedMesh.uv2.Length == j.verts.Length) { j.stream.uv1 = new Vector2[j.meshFilter.sharedMesh.uv2.Length]; j.meshFilter.sharedMesh.uv2.CopyTo(j.stream.uv1, 0); } else { j.stream.SetUV1(Vector2.zero, j.verts.Length); } } break; } case BrushMode.U2: goto case BrushMode.V2; case BrushMode.V2: { Vector2[] uvs = j.stream.uv2; if (uvs == null || uvs.Length != j.verts.Length) { if (j.meshFilter.sharedMesh.uv3 != null && j.meshFilter.sharedMesh.uv3.Length == j.verts.Length) { j.stream.uv2 = new Vector2[j.meshFilter.sharedMesh.uv3.Length]; j.meshFilter.sharedMesh.uv3.CopyTo(j.stream.uv2, 0); } else { j.stream.SetUV2(Vector2.zero, j.verts.Length); } } break; } case BrushMode.U3: goto case BrushMode.V3; case BrushMode.V3: { Vector2[] uvs = j.stream.uv3; if (uvs == null || uvs.Length != j.verts.Length) { if (j.meshFilter.sharedMesh.uv4 != null && j.meshFilter.sharedMesh.uv4.Length == j.verts.Length) { j.stream.uv3 = new Vector2[j.meshFilter.sharedMesh.uv4.Length]; j.meshFilter.sharedMesh.uv4.CopyTo(j.stream.uv3, 0); } else { j.stream.SetUV3(Vector2.zero, j.verts.Length); } } break; } } }
void PaintVert(PaintJob j, int i, float strength) { float bv = (float)brushValue/255.0f; switch (brushMode) { case BrushMode.Color: { j.stream.colors[i] = Color.Lerp(j.stream.colors[i], brushColor, strength); break; } case BrushMode.ValueR: { j.stream.colors[i].r = Mathf.Lerp (j.stream.colors[i].r, bv, strength); break; } case BrushMode.ValueG: { j.stream.colors[i].g = Mathf.Lerp (j.stream.colors[i].g, bv, strength); break; } case BrushMode.ValueB: { j.stream.colors[i].b = Mathf.Lerp (j.stream.colors[i].b, bv, strength); break; } case BrushMode.ValueA: { j.stream.colors[i].a = Mathf.Lerp (j.stream.colors[i].a, bv, strength); break; } case BrushMode.U0: { j.stream.uv0[i].x = Mathf.Lerp(j.stream.uv0[i].x, floatBrushValue, strength); break; } case BrushMode.V0: { j.stream.uv0[i].y = Mathf.Lerp(j.stream.uv0[i].y, floatBrushValue, strength); break; } case BrushMode.U1: { j.stream.uv1[i].x = Mathf.Lerp(j.stream.uv1[i].x, floatBrushValue, strength); break; } case BrushMode.V1: { j.stream.uv1[i].y = Mathf.Lerp(j.stream.uv1[i].y, floatBrushValue, strength); break; } case BrushMode.U2: { j.stream.uv2[i].x = Mathf.Lerp(j.stream.uv2[i].x, floatBrushValue, strength); break; } case BrushMode.V2: { j.stream.uv2[i].y = Mathf.Lerp(j.stream.uv2[i].y, floatBrushValue, strength); break; } case BrushMode.U3: { j.stream.uv3[i].x = Mathf.Lerp(j.stream.uv3[i].x, floatBrushValue, strength); break; } case BrushMode.V3: { j.stream.uv3[i].y = Mathf.Lerp(j.stream.uv3[i].y, floatBrushValue, strength); break; } } }
void PaintMesh(PaintJob j, Vector3 point) { PrepBrushMode(j); // convert point into local space, so we don't have to convert every point point = j.renderer.transform.worldToLocalMatrix.MultiplyPoint(point); // we could do a spacial hash for more speed for (int i = 0; i < j.verts.Length; ++i) { float d = Vector3.Distance(point, j.verts[i]); if (d < brushSize) { float str = 1.0f - d/brushSize; float pressure = Event.current.pressure > 0 ? Event.current.pressure : 1.0f; PaintVert(j, i, str * (float)deltaTime * brushFlow * pressure); } } j.stream.Apply(); }