private void FillJointGap(Vector2 p, Vector2 b, Vector2 n1, Vector2 n2) { float angle1 = n1.Atan2Deg; float angle2 = n2.Atan2Deg; if (angle1 > angle2) { Toolbox.Swap(ref angle1, ref angle2); } if (angle2 - angle1 > 180) { angle2 -= 360; } var v = new Vertex[10]; v[0] = new Vertex { Pos = p, Color = Color }; float length = n2.Length; for (int i = 0; i < v.Length - 1; i++) { float t = (float)i / (v.Length - 2); p = -Vector2.CosSinRough(Mathf.Lerp(t, angle1, angle2) * Mathf.DegToRad) * length + b; v[i + 1] = new Vertex { Pos = p, Color = Color }; } Renderer.DrawTriangleFan(null, null, v, v.Length); }
protected internal override Lime.RenderObject GetRenderObject() { if (Parent.AsWidget == null) { return(null); } IImageCombinerArg arg1, arg2; if (!GetArgs(out arg1, out arg2)) { return(null); } if (!arg1.GloballyVisible || !arg2.GloballyVisible) { return(null); } var texture1 = arg1.GetTexture(); var texture2 = arg2.GetTexture(); if (texture1 == null || texture2 == null) { return(null); } var ro = RenderObjectPool <RenderObject> .Acquire(); ro.Arg12CommonMaterial = CustomMaterial; ro.Arg1Material = CustomMaterial; if (ro.Arg1Material == null) { var shader = Shader == ShaderId.Inherited ? Parent.AsWidget.GlobalShader : Shader; if (arg2.Shader == ShaderId.Silhuette) { shader = ShaderId.Silhuette; } else if (arg1.Shader == ShaderId.Silhuette) { shader = ShaderId.Silhuette; Toolbox.Swap(ref arg1, ref arg2); Toolbox.Swap(ref texture1, ref texture2); } var blending = Blending == Blending.Inherited ? Parent.AsWidget.GlobalBlending : Blending; ro.Arg1Material = WidgetMaterial.GetInstance(blending, shader, WidgetMaterial.GetNumTextures(texture1, null)); ro.Arg12CommonMaterial = WidgetMaterial.GetInstance( blending, shader, WidgetMaterial.GetNumTextures(texture1, texture2), Operation == ImageCombinerOperation.Multiply ? TextureBlending.Multiply : TextureBlending.CutOut); } ro.Arg1Texture = texture1; ro.Arg2Texture = texture2; ro.Operation = Operation; ro.Arg1Transform = Matrix32.Scaling(arg1.Size) * arg1.CalcLocalToParentTransform(); ro.Arg2Transform = Matrix32.Scaling(arg2.Size) * arg2.CalcLocalToParentTransform(); ro.Arg1UVTransform = arg1.UVTransform; ro.Arg2UVTransform = arg2.UVTransform; ro.LocalToWorldTransform = Parent.AsWidget.LocalToWorldTransform; ro.Color = arg1.Color * arg2.Color * Parent.AsWidget.GlobalColor; return(ro); }
public override void Update(float delta) { while (currQueue.Count > 0) { var animation = currQueue.Dequeue().Value; nextQueue.Enqueue(animation.Owner.Depth, animation.QueueNode); animation.Advance(delta * animation.OwnerNode.EffectiveAnimationSpeed); } Toolbox.Swap(ref currQueue, ref nextQueue); }
public override void Render() { if (Parent.AsWidget == null) { return; } IImageCombinerArg arg1, arg2; if (!GetArgs(out arg1, out arg2)) { return; } if (!arg1.GloballyVisible || !arg2.GloballyVisible) { return; } var texture1 = arg1.GetTexture(); var texture2 = arg2.GetTexture(); if (texture1 == null || texture2 == null) { return; } Renderer.Transform1 = Parent.AsWidget.LocalToWorldTransform; var blending = Blending == Blending.Inherited ? Parent.AsWidget.GlobalBlending : Blending; var shader = Shader == ShaderId.Inherited ? Parent.AsWidget.GlobalShader : Shader; if (arg2.Shader == ShaderId.Silhuette) { shader = ShaderId.Silhuette; } else if (arg1.Shader == ShaderId.Silhuette) { shader = ShaderId.Silhuette; Toolbox.Swap(ref arg1, ref arg2); Toolbox.Swap(ref texture1, ref texture2); } var material = WidgetMaterial.GetInstance(blending, shader, CustomShaderProgram, texture1, texture2); RenderHelper(arg1, arg2, material, texture1, texture2); }
private void Sync() { assetBundle = AssetBundle.Initialized ? AssetBundle.Current : null; Toolbox.Swap(ref renderObjectList1, ref renderObjectList2); }
public override void Render() { arg12CommonArea.Clear(); arg2Area.Clear(); for (int i = 0; i < 4; i++) { arg12CommonArea.Add(rect[i] * Arg1Transform); arg2Area.Add(rect[i] * Arg2Transform); } arg1RemainedAreaCount = 0; var clockwiseOrder = AreVectorsClockwiseOrdered(arg2Area[0], arg2Area[1], arg2Area[2]); for (int i = 0; i < 4; i++) { int j = (i < 3) ? i + 1 : 0; var v1 = clockwiseOrder ? arg2Area[j] : arg2Area[i]; var v2 = clockwiseOrder ? arg2Area[i] : arg2Area[j]; if (Operation == ImageCombinerOperation.Multiply) { SplitPolygon(arg12CommonArea, splitResult1, splitResult2, v1, v2); Toolbox.Swap(ref arg12CommonArea, ref splitResult1); } else if (Operation == ImageCombinerOperation.CutOut) { SplitPolygon(arg12CommonArea, splitResult1, splitResult2, v1, v2); Toolbox.Swap(ref arg12CommonArea, ref splitResult1); if (splitResult2.Count > 0) { Toolbox.Swap(ref splitResult2, ref arg1RemainedAreas[arg1RemainedAreaCount++]); if (splitResult2 == null) { splitResult2 = new Polygon(); } } } else { throw new InvalidOperationException(); } } // Following matrices transform vertices into texture coordinates. var uvTransform1 = Arg1Transform.CalcInversed() * Arg1UVTransform; var uvTransform2 = Arg2Transform.CalcInversed() * Arg2UVTransform; Renderer.Transform1 = LocalToWorldTransform; if (Operation == ImageCombinerOperation.Multiply) { PrepareVertices(arg12CommonArea); Renderer.DrawTriangleFan(Arg1Texture, Arg2Texture, Arg12CommonMaterial, vertices, arg12CommonArea.Count); } else { for (int i = 0; i < arg1RemainedAreaCount; i++) { PrepareVertices(arg1RemainedAreas[i]); Renderer.DrawTriangleFan(Arg1Texture, null, Arg1Material, vertices, arg1RemainedAreas[i].Count); } PrepareVertices(arg12CommonArea); Renderer.DrawTriangleFan(Arg1Texture, Arg2Texture, Arg12CommonMaterial, vertices, arg12CommonArea.Count); } void PrepareVertices(Polygon polygon) { for (int i = 0; i < polygon.Count; i++) { vertices[i].Pos = polygon[i]; vertices[i].Color = Color; var uv1 = polygon[i] * uvTransform1; var uv2 = polygon[i] * uvTransform2; vertices[i].UV1 = uv1; vertices[i].UV2 = uv2; } } }