Example #1
0
    void UpdateLines()
    {
        bool bParticle = (IsLegacy() || IsShuriken());

        if ((bParticle == false) && (m_BaseTrans.GetComponent <MeshFilter>() == null || m_BaseTrans.GetComponent <MeshFilter>().mesh == null))
        {
            m_bWireframe = false;
            return;
        }

        ArrayList linesArray = new ArrayList();
        Mesh      mesh;

        if (bParticle)
        {
            mesh             = NgSerialized.GetParticleMesh(GetParticleComponent());
            m_bWorldParticle = NgSerialized.GetSimulationSpaceWorld(m_BaseTrans);
        }
        else
        {
            mesh = m_BaseTrans.GetComponent <MeshFilter>().mesh;
        }

        if (mesh != null)
        {
            Vector3[] vertices  = mesh.vertices;
            int[]     triangles = mesh.triangles;

            for (int i = 0; i < triangles.Length / 3; i++)
            {
                linesArray.Add(vertices[triangles[i * 3]]);
                linesArray.Add(vertices[triangles[i * 3 + 1]]);
                linesArray.Add(vertices[triangles[i * 3 + 2]]);
            }
            m_lines = NgConvert.ToArray <Vector3>(linesArray);
        }
    }
Example #2
0
    // Event -------------------------------------------------------------------------
    // Function ----------------------------------------------------------------------
    public bool SetWireframe(bool bWireframe, bool bTexture, bool bRoot)
    {
        if (m_BaseTrans == null || m_BaseTrans.renderer == null)
        {
            m_bWireframe = false;
            return(false);
        }

        m_bTexture   = bTexture;
        m_bWireframe = bWireframe;
        m_bRoot      = bRoot;
//		m_BaseTrans.renderer.enabled = m_bTexture;
//      if (bWireframe == false)
//      {
//          m_bWireframe = false;
//          return false;
//      }

        bool bParticle = (IsLegacy() || IsShuriken());

        if ((bParticle == false) && (m_BaseTrans.GetComponent <MeshFilter>() == null || m_BaseTrans.GetComponent <MeshFilter>().sharedMesh == null))
        {
            m_bWireframe = false;
            return(false);
        }

//      m_meshRenderer = GetComponent<MeshRenderer>();
//      if (!m_meshRenderer)
//          m_meshRenderer = gameObject.AddComponent<MeshRenderer>();
//      if (m_meshRenderer.material == null)
//      {
//          m_meshRenderer.material = new Material("Shader \"Lines/Background\" { Properties { _Color (\"Main Color\", Color) = (1,1,1,1) } SubShader { Pass {" + (m_ZWrite ? " ZWrite on " : " ZWrite off ") + (m_blend ? " Blend SrcAlpha OneMinusSrcAlpha" : " ") + (m_AWrite ? " Colormask RGBA " : " ") + "Lighting Off Offset 1, 1 Color[_Color] }}}");
// //           m_meshRenderer.material = FXMakerMain.inst.m_LineBackMaterial;
//      }
        if (m_lineMaterial == null)
        {
//          m_lineMaterial	= new Material("Shader \"Lines/Colored Blended\" { SubShader { Pass { Blend SrcAlpha OneMinusSrcAlpha BindChannels { Bind \"Color\",color } ZWrite On Cull Front Fog { Mode Off } } } }");
            m_lineMaterial                  = FXMakerMain.inst.m_LineColorMaterial;
            m_lineMaterial.hideFlags        = HideFlags.HideAndDontSave;
            m_lineMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
        }

        ArrayList linesArray = new ArrayList();
        Mesh      mesh;

        if (bParticle)
        {
            mesh             = NgSerialized.GetParticleMesh(GetParticleComponent());
            m_bWorldParticle = NgSerialized.GetSimulationSpaceWorld(m_BaseTrans);
        }
        else
        {
            mesh = m_BaseTrans.GetComponent <MeshFilter>().sharedMesh;
        }

        if (mesh != null)
        {
            Vector3[] vertices  = mesh.vertices;
            int[]     triangles = mesh.triangles;

            for (int i = 0; i < triangles.Length / 3; i++)
            {
                linesArray.Add(vertices[triangles[i * 3]]);
                linesArray.Add(vertices[triangles[i * 3 + 1]]);
                linesArray.Add(vertices[triangles[i * 3 + 2]]);
            }
            m_lines = NgConvert.ToArray <Vector3>(linesArray);
        }
        return(m_bWireframe);
    }