public void AddColorer(VPaintObject vc) { if (!vc) { return; } if (colorers.Contains(vc)) { return; } if (vc.GetMeshInstance() == null) { Debug.LogError("VPaint Object is missing a mesh."); return; } colorers.Add(vc); vertexCache.Add(new VPaintVertexCache() { vpaintObject = vc, vertices = vc.GetMeshInstance().vertices }); #if UNITY_EDITOR UnityEditor.EditorUtility.SetDirty(this); #endif }
public VPaintVertexData GetOrCreate(VPaintObject vc) { if (vc == null) { return(null); } var data = Get(vc); if (data != null) { return(data); } data = new VPaintVertexData(); data.vpaintObject = vc; var cols = vc.GetDefaultColors(); data.colors = new Color[cols.Length]; data.transparency = new float[cols.Length]; paintData.Add(data); return(data); }
public override Texture2D GetTexture(VPaintObject vc) { Renderer renderer = vc.GetComponent <Renderer>(); LightmapData lmData = LightmapSettings.lightmaps[renderer.lightmapIndex]; return(lmData.lightmapFar); // offset = renderer.lightmapTilingOffset; // texture = lmData.lightmapFar; }
public override Func <Vector2, Vector2> GetUVTransformation(VPaintObject vc) { Renderer renderer = vc.GetComponent <Renderer>(); #if UNITY_5 var offset = renderer.lightmapScaleOffset; #else var offset = renderer.lightmapTilingOffset; #endif return((uv) => { return new Vector2((offset.x * uv.x) + offset.z, (offset.y * uv.y) + offset.w); }); }
public void CacheVertices(VPaintObject obj) { var cache = vertexCache.Find(c => c.vpaintObject == obj); if (cache == null) { vertexCache.Add( new VPaintVertexCache() { vpaintObject = obj, vertices = obj.GetMeshInstance().vertices } ); } else { cache.vertices = obj.GetMeshInstance().vertices; } }
void PaintObject(VPaintObject vc, VPaintLayer layer, VPaintVertexData data) { if (vc.colorsBuilder == null) { vc.colorsBuilder = new Color[data.colors.Length]; } if (vc.transparencyBuilder == null) { vc.transparencyBuilder = new float[data.colors.Length]; } VPaintUtility.MergeColors( vc.colorsBuilder, vc.transparencyBuilder, data.colors, data.transparency, layer.blendMode, layer.opacity, layer.maskR, layer.maskG, layer.maskB, layer.maskA ); }
void PaintObject(VPaintObject vc) { vc.colorsBuilder = null; vc.transparencyBuilder = null; foreach (var layer in layerStack.layers) { if (!layer.enabled) { continue; } var data = layer.Get(vc); if (data == null) { continue; } PaintObject(vc, layer, data); } vc.ApplyColorsBuilder(); }
/// <summary> /// Lerps colors from one set to another /// </summary> /// <returns> /// A coroutine which will lerp colors from one set to another. /// </returns> /// <param name='obj'> /// The VPaint object to lerp /// </param> /// <param name='start'> /// The starting color set /// </param> /// <param name='end'> /// The ending color set /// </param> /// <param name='time'> /// The time the lerp operation should take /// </param> public static IEnumerator LerpColors(VPaintObject obj, Color[] start, Color[] end, float time) { float t = 0; int len = start.Length; Color[] lerp = new Color[len]; while (t < time) { float f = t / time; for (int i = 0; i < len; i++) { lerp[i] = Color.Lerp(start[i], end[i], f); } obj.SetColors(lerp); yield return(null); t += Time.deltaTime; } obj.SetColors(end); }
public override Func <Vector2, Vector2> GetUVTransformation(VPaintObject vc) { return((uv) => { return Vector2.Scale(uv, tile) + offset; }); }
public override Texture2D GetTexture(VPaintObject vc) { return(_texture); }
public void RemoveColorer(VPaintObject vc) { colorers.Remove(vc); vertexCache.RemoveAll(obj => obj.vpaintObject == vc); }
public virtual Func <Vector2, Vector2> GetUVTransformation(VPaintObject vc) { return((v) => { return v; }); }
public virtual Texture2D GetTexture(VPaintObject vc) { return(null); }
public virtual bool IsValid(VPaintObject vc) { return(true); }
public override bool IsValid(VPaintObject vc) { return(GameObjectUtility.AreStaticEditorFlagsSet(vc.gameObject, StaticEditorFlags.LightmapStatic)); }
public virtual VPaintStorageObject CreateStorageObject(VPaintObject source) { return(null); }