Exemple #1
0
        private void Lump(Material material, List <LumpableMesh> lumpables, GameObject parent)
        {
            GameObject lump = parent.AddChild(new GameObject("Lump"));

            lump.AddComponent <MeshFilter>().mesh             = MeshExtensions.CreateCombined(lumpables.Convert(l => l.Lump()));
            lump.AddComponent <MeshRenderer>().sharedMaterial = material;
        }
Exemple #2
0
        static public void DrawQuad(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Color color)
        {
            Mesh mesh = MeshExtensions.CreateCornerQuad();

            mesh.vertices = new Vector3[] {
                p1, p2, p3, p4
            };

            DrawColoredMesh(mesh, color);
        }
Exemple #3
0
 static public void DrawCircle(Vector3 center, float radius)
 {
     GizmosExtensions.UseMatrix(
         Matrix4x4.TRS(
             center,
             Quaternion.identity,
             new Vector3(radius, radius, radius) * 2.0f
             ),
         () => Gizmos.DrawMesh(MeshExtensions.CreateCircle(32))
         );
 }
Exemple #4
0
 static public void DrawDegreeSector(float start_angle, float end_angle, Vector3 center, float radius)
 {
     GizmosExtensions.UseMatrix(
         Matrix4x4.TRS(
             center,
             Quaternion.identity,
             new Vector3(radius, radius, radius) * 2.0f
             ),
         () => Gizmos.DrawMesh(MeshExtensions.CreateDegreeSector(start_angle, end_angle, 32))
         );
 }
Exemple #5
0
        static public void DrawTexture(Vector3 center, Vector2 size, Texture2D texture)
        {
            Mesh     mesh     = MeshExtensions.CreateCenterQuad(size);
            Material material = MaterialExtensions.CreateUnlitTransparentTextureMaterial(texture);

            material.SetPass(0);

            Graphics.DrawMeshNow(
                mesh,
                Matrix4x4.TRS(
                    center,
                    Quaternion.LookRotation(Camera.current.GetSpacarForward(), Vector3.up),
                    Vector3.one
                    )
                );
        }
Exemple #6
0
        private void Render()
        {
            Rect rect = bounds.GetPlanar();

            Clear();

            Camera camera = this.AddChild(new GameObject("Camera")).AddComponent <Camera>();

            camera.enabled = false;

            camera.clearFlags      = CameraClearFlags.SolidColor;
            camera.backgroundColor = Color.clear;
            camera.cullingMask     = source_mask;
            camera.nearClipPlane   = -1.0f;

            camera.orthographic     = true;
            camera.orthographicSize = orthographic_size;
            camera.aspect           = 1.0f;

            int     number_chunks = 0;
            Vector2 cell_size     = camera.GetOrthographicSize() - margins;

            rect.ProcessOverflownGrid(cell_size, delegate(int x, int y, Rect sub_rect) {
                if (number_chunks < maximum_number_chunks)
                {
                    GameObject cell = this.AddChild(new GameObject("RenderedCell"));

                    cell.SetPlanarPosition(sub_rect.center);
                    camera.SetPlanarPosition(sub_rect.center);

                    Texture2D rendered         = camera.RenderToTexture2D(0);
                    MeshFilter mesh_filter     = cell.AddComponent <MeshFilter>();
                    MeshRenderer mesh_renderer = cell.AddComponent <MeshRenderer>();

                    rendered.filterMode = filter_mode;

                    mesh_filter.mesh       = MeshExtensions.CreateCenterQuad(sub_rect.GetSize() + margins);
                    mesh_renderer.material = MaterialExtensions.CreateUnlitTransparentTextureMaterial(rendered);
                    mesh_renderer.SetSortingLayer(destination_layer);

                    number_chunks++;
                }
            });

            camera.DestroyGameObjectAdvisory();
        }