Beispiel #1
0
        public AXMesh CloneReverse(Matrix4x4 mx)
        {
            Vector3[] vertices  = (Vector3[])mesh.vertices.Clone();
            Vector2[] uv        = (Vector2[])mesh.uv.Clone();
            int[]     triangles = (int[])mesh.triangles.Clone();
            Vector3[] normals   = (Vector3[])mesh.normals.Clone();

            Mesh tmpMesh = new Mesh();

            tmpMesh.vertices  = vertices;
            tmpMesh.uv        = uv;
            tmpMesh.triangles = triangles.Reverse().ToArray();
            tmpMesh.normals   = normals;

            //tmpMesh.RecalculateNormals();
            //AXGeometryTools.Utilities.calculateMeshTangents(ref tmpMesh);

            AXMesh clone = new AXMesh(tmpMesh, transMatrix, mat, uScale, vScale, uShift, vShift);

            clone.transMatrix  = mx;
            clone.rot_Y_rand   = rot_Y_rand;
            clone.name         = name;
            clone.getsCollider = getsCollider;

            clone.makerPO = makerPO;

            return(clone);
        }
Beispiel #2
0
        public AXMesh next()
        {
            if (axMeshes[Cursor] == null)
            {
                axMeshes[Cursor] = new AXMesh();
            }

            Cursor++;

            return(axMeshes[Cursor - 1]);
        }
Beispiel #3
0
        public AXMesh Clone()
        {
            AXMesh clone = new AXMesh(meshClone(), transMatrix, mat, uScale, vScale, uShift, vShift);

            clone.m_drawMesh       = m_drawMesh;
            clone.m_drawMeshMatrix = m_drawMeshMatrix;

            clone.rot_Y_rand   = rot_Y_rand;
            clone.name         = name;
            clone.getsCollider = getsCollider;
            clone.makerPO      = makerPO;

            return(clone);
        }
Beispiel #4
0
        public AXMesh CloneTransformed(Matrix4x4 mx)
        {
            AXMesh clone = new AXMesh(meshClone(), transMatrix, mat, uScale, vScale, uShift, vShift);

            transformWithMatrix(ref clone.mesh, mx);
            clone.transMatrix = Matrix4x4.identity;

            transformWithMatrix(ref m_drawMesh, mx);
            clone.drawMeshMatrix = Matrix4x4.identity;


            clone.rot_Y_rand   = rot_Y_rand;
            clone.name         = name;
            clone.getsCollider = getsCollider;

            clone.makerPO = makerPO;

            return(clone);
        }
Beispiel #5
0
        public AXMesh CloneReverse()
        {
            Vector3[] vertices  = (Vector3[])mesh.vertices.Clone();
            Vector2[] uv        = (Vector2[])mesh.uv.Clone();
            int[]     triangles = (int[])mesh.triangles.Clone();


            Mesh tmpMesh = new Mesh();

            tmpMesh.triangles = triangles.Reverse().ToArray();
            tmpMesh.uv        = uv;
            tmpMesh.vertices  = vertices;
            tmpMesh.RecalculateNormals();

            AXMesh clone = new AXMesh(tmpMesh, transMatrix, mat, uScale, vScale, uShift, vShift);

            clone.rot_Y_rand   = rot_Y_rand;
            clone.name         = name;
            clone.getsCollider = getsCollider;

            clone.makerPO = makerPO;

            return(clone);
        }
Beispiel #6
0
        public static void render(AXParametricObject po, bool makeTexture = false)
        {
            AXModel model = po.model;

            if (model == null)
            {
                return;
            }

            model.assertThumnailSupport();


            // THUMBNAIL BACKGROUND COLOR
            if (po.generator != null && makeTexture)
            {
                model.thumbnailCamera.backgroundColor = po.generator.ThumbnailColor;
            }

            // WHY ARE THE THUMNAIL AND RenTex null?

            if (po.renTex == null)
            {
                po.renTex = new RenderTexture(256, 256, 24);
            }

            if (!po.renTex.IsCreated())
            {
                po.renTex.antiAliasing = 8;
                po.renTex.Create();
            }

            // This started giving an error in 5.3 and did not seem to be needed anyway!

            if (makeTexture)
            {
                RenderTexture.active = po.renTex;
            }

            model.thumbnailCamera.targetTexture = po.renTex;



            model.thumbnailCameraGO.transform.position = po.getThumbnailCameraPosition();
            model.thumbnailCameraGO.gameObject.transform.LookAt(po.getThumbnailCameraTarget());



            // USE THIS MATRIX TO DRAW THE PO's MESHES SOMEWHERE FAR, FAR AWAY


            //Debug.Log("RENDER: " + po.Name);

            Material tmpMat = null;

            if (po.generator is MaterialTool)
            {
                if (po.axMat != null && po.axMat.mat != null)
                {
                    tmpMat = po.axMat.mat;
                }
                else if (po.grouper != null && po.grouper.axMat != null && po.grouper.axMat.mat != null)
                {
                    tmpMat = po.grouper.axMat.mat;
                }
                else
                {
                    tmpMat = model.axMat.mat;
                }

                //Debug.Log("RENDER TEXTURETOOL " + model.thumbnailCameraGO.transform.position + " mesh-> " + model.thumbnailMaterialMesh.vertices.Length + " -- " + tmpMat);

                Graphics.DrawMesh(model.thumbnailMaterialMesh, model.remoteThumbnailLocation, tmpMat, 0, model.thumbnailCamera);

                model.thumbnailCamera.Render();
            }
            else
            {
                AXParameter op = po.getParameter("Output Mesh");
                if (op != null)
                {
                    // RE-RENDER
                    // After a save or reload, the RenterTextures are empty
                    if (op.meshes != null)
                    {
                        for (int mi = 0; mi < op.meshes.Count; mi++)
                        {
                            AXMesh axmesh = op.meshes [mi];
                            if (axmesh.mat != null)
                            {
                                tmpMat = axmesh.mat;
                            }
                            else
                            if (po.axMat != null && po.axMat.mat != null)
                            {
                                tmpMat = po.axMat.mat;
                            }
                            else if (po.grouper != null && po.grouper.axMat != null && po.grouper.axMat.mat != null)
                            {
                                tmpMat = po.grouper.axMat.mat;
                            }

                            else
                            {
                                tmpMat = model.axMat.mat;
                            }


                            Graphics.DrawMesh(axmesh.drawMesh, (model.remoteThumbnailLocation * axmesh.transMatrix), tmpMat, 0, model.thumbnailCamera);
                        }
                    }

                    model.thumbnailCamera.Render();
                }
            }

            // write to texture
            if (makeTexture)
            {
                if (po.thumbnail == null)
                {
                    po.thumbnail = new Texture2D(256, 256);
                }

                po.thumbnail.ReadPixels(new Rect(0, 0, po.renTex.width, po.renTex.height), 0, 0);
                po.thumbnail.Apply();
            }
            if (makeTexture)
            {
                RenderTexture.active = null;
            }

            // 3. Set helper objects to inactive
            model.thumbnailLightGO.SetActive(false);
            model.thumbnailCameraGO.SetActive(false);
        }