コード例 #1
0
    public static void UpdatePlane(MeshFilter meshFilter, float fUvScale, NcFrameInfo ncSpriteFrameInfo, bool bTrimCenterAlign, ALIGN_TYPE alignType)
    {
//      Debug.Log(ncSpriteFrameInfo.m_FrameUvOffset);

        // m_AlignType
        Vector3[] planeVertices;
        Vector2   texScale      = new Vector2(fUvScale * ncSpriteFrameInfo.m_FrameScale.x, fUvScale * ncSpriteFrameInfo.m_FrameScale.y);
        float     fVAlignHeight = (alignType == ALIGN_TYPE.BOTTOM ? 1.0f * texScale.y : (alignType == ALIGN_TYPE.TOP ? -1.0f * texScale.y : 0));
        Rect      frameUvOffset = ncSpriteFrameInfo.m_FrameUvOffset;

        if (bTrimCenterAlign)
        {
            frameUvOffset.center = Vector2.zero;
        }

        // Vertices
        planeVertices    = new Vector3[4];
        planeVertices[0] = new Vector3(frameUvOffset.xMax * texScale.x, frameUvOffset.yMax * texScale.y + fVAlignHeight);
        planeVertices[1] = new Vector3(frameUvOffset.xMax * texScale.x, frameUvOffset.yMin * texScale.y + fVAlignHeight);
        planeVertices[2] = new Vector3(frameUvOffset.xMin * texScale.x, frameUvOffset.yMin * texScale.y + fVAlignHeight);
        planeVertices[3] = new Vector3(frameUvOffset.xMin * texScale.x, frameUvOffset.yMax * texScale.y + fVAlignHeight);

        meshFilter.mesh.vertices = planeVertices;
        meshFilter.mesh.RecalculateBounds();

//      for (int n = 0; n < meshFilter.mesh.vertices.Length; n++)
//              Debug.Log(meshFilter.mesh.vertices[n]);
    }
コード例 #2
0
ファイル: NcSpriteFactory.cs プロジェクト: isoundy000/wzry-1
    public static void CreatePlane(MeshFilter meshFilter, float fUvScale, NcFrameInfo ncSpriteFrameInfo, bool bTrimCenterAlign, ALIGN_TYPE alignType, MESH_TYPE m_MeshType)
    {
        int[]   numArray;
        Vector2 vector        = new Vector2(fUvScale * ncSpriteFrameInfo.m_FrameScale.x, fUvScale * ncSpriteFrameInfo.m_FrameScale.y);
        float   num           = (alignType != ALIGN_TYPE.BOTTOM) ? ((alignType != ALIGN_TYPE.TOP) ? 0f : (-1f * vector.y)) : (1f * vector.y);
        Rect    frameUvOffset = ncSpriteFrameInfo.m_FrameUvOffset;

        if (bTrimCenterAlign)
        {
            frameUvOffset.center = Vector2.zero;
        }
        Vector3[] vectorArray  = new Vector3[] { new Vector3(frameUvOffset.xMax * vector.x, (frameUvOffset.yMax * vector.y) + num), new Vector3(frameUvOffset.xMax * vector.x, (frameUvOffset.yMin * vector.y) + num), new Vector3(frameUvOffset.xMin * vector.x, (frameUvOffset.yMin * vector.y) + num), new Vector3(frameUvOffset.xMin * vector.x, (frameUvOffset.yMax * vector.y) + num) };
        Color[]   colorArray   = new Color[] { Color.white, Color.white, Color.white, Color.white };
        Vector3[] vectorArray2 = new Vector3[] { new Vector3(0f, 0f, -1f), new Vector3(0f, 0f, -1f), new Vector3(0f, 0f, -1f), new Vector3(0f, 0f, -1f) };
        Vector4[] vectorArray3 = new Vector4[] { new Vector4(1f, 0f, 0f, -1f), new Vector4(1f, 0f, 0f, -1f), new Vector4(1f, 0f, 0f, -1f), new Vector4(1f, 0f, 0f, -1f) };
        if (m_MeshType == MESH_TYPE.BuiltIn_Plane)
        {
            numArray = new int[] { 1, 2, 0, 0, 2, 3 };
        }
        else
        {
            numArray = new int[] { 1, 2, 0, 0, 2, 3, 1, 0, 3, 3, 2, 1 };
        }
        Vector2[] vectorArray4 = new Vector2[] { new Vector2(1f, 1f), new Vector2(1f, 0f), new Vector2(0f, 0f), new Vector2(0f, 1f) };
        meshFilter.mesh.Clear();
        meshFilter.mesh.vertices  = vectorArray;
        meshFilter.mesh.colors    = colorArray;
        meshFilter.mesh.normals   = vectorArray2;
        meshFilter.mesh.tangents  = vectorArray3;
        meshFilter.mesh.triangles = numArray;
        meshFilter.mesh.uv        = vectorArray4;
        meshFilter.mesh.RecalculateBounds();
    }
コード例 #3
0
ファイル: NcSpriteFactory.cs プロジェクト: isoundy000/wzry-1
    public static void UpdatePlane(MeshFilter meshFilter, float fUvScale, NcFrameInfo ncSpriteFrameInfo, bool bTrimCenterAlign, ALIGN_TYPE alignType)
    {
        Vector2 vector        = new Vector2(fUvScale * ncSpriteFrameInfo.m_FrameScale.x, fUvScale * ncSpriteFrameInfo.m_FrameScale.y);
        float   num           = (alignType != ALIGN_TYPE.BOTTOM) ? ((alignType != ALIGN_TYPE.TOP) ? 0f : (-1f * vector.y)) : (1f * vector.y);
        Rect    frameUvOffset = ncSpriteFrameInfo.m_FrameUvOffset;

        if (bTrimCenterAlign)
        {
            frameUvOffset.center = Vector2.zero;
        }
        meshFilter.mesh.vertices = new Vector3[] { new Vector3(frameUvOffset.xMax * vector.x, (frameUvOffset.yMax * vector.y) + num), new Vector3(frameUvOffset.xMax * vector.x, (frameUvOffset.yMin * vector.y) + num), new Vector3(frameUvOffset.xMin * vector.x, (frameUvOffset.yMin * vector.y) + num), new Vector3(frameUvOffset.xMin * vector.x, (frameUvOffset.yMax * vector.y) + num) };
        meshFilter.mesh.RecalculateBounds();
    }
コード例 #4
0
    // ------------------------------------------------------------------------------------------
    public static void CreatePlane(MeshFilter meshFilter, float fUvScale, NcFrameInfo ncSpriteFrameInfo, bool bTrimCenterAlign, ALIGN_TYPE alignType, MESH_TYPE m_MeshType)
    {
        // 		Debug.Log(ncSpriteFrameInfo.m_FrameUvOffset);

        // m_MeshType, m_AlignType
        Vector3[]	planeVertices;
        Vector2		texScale = new Vector2(fUvScale * ncSpriteFrameInfo.m_FrameScale.x, fUvScale * ncSpriteFrameInfo.m_FrameScale.y);
        float		fVAlignHeight = (alignType == ALIGN_TYPE.BOTTOM ? 1.0f*texScale.y : (alignType == ALIGN_TYPE.TOP ? -1.0f*texScale.y : 0));
        Rect		frameUvOffset = ncSpriteFrameInfo.m_FrameUvOffset;
        if (bTrimCenterAlign)
                frameUvOffset.center = Vector2.zero;

        // Vertices
        planeVertices		= new Vector3[4];
        planeVertices[0]	= new Vector3(frameUvOffset.xMax*texScale.x, frameUvOffset.yMax*texScale.y+fVAlignHeight);
        planeVertices[1]	= new Vector3(frameUvOffset.xMax*texScale.x, frameUvOffset.yMin*texScale.y+fVAlignHeight);
        planeVertices[2]	= new Vector3(frameUvOffset.xMin*texScale.x, frameUvOffset.yMin*texScale.y+fVAlignHeight);
        planeVertices[3]	= new Vector3(frameUvOffset.xMin*texScale.x, frameUvOffset.yMax*texScale.y+fVAlignHeight);

        // Color
        Color[]		colors = new Color[4];
        colors[0]	= Color.white;
        colors[1]	= Color.white;
        colors[2]	= Color.white;
        colors[3]	= Color.white;

        // Normals
        Vector3[]	normals = new Vector3[4];
        normals[0]	= new Vector3(0, 0, -1.0f);
        normals[1]	= new Vector3(0, 0, -1.0f);
        normals[2]	= new Vector3(0, 0, -1.0f);
        normals[3]	= new Vector3(0, 0, -1.0f);

        // Tangents
        Vector4[]	tangents = new Vector4[4];
        tangents[0]	= new Vector4(1, 0, 0, -1.0f);
        tangents[1]	= new Vector4(1, 0, 0, -1.0f);
        tangents[2]	= new Vector4(1, 0, 0, -1.0f);
        tangents[3]	= new Vector4(1, 0, 0, -1.0f);

        // Triangles
        int[]	triangles;
        if (m_MeshType == MESH_TYPE.BuiltIn_Plane)
        {
            triangles = new int[6];
            triangles[0]	= 1;
            triangles[1]	= 2;
            triangles[2]	= 0;
            triangles[3]	= 0;
            triangles[4]	= 2;
            triangles[5]	= 3;
        } else {
            triangles = new int[12];
            triangles[0]	= 1;
            triangles[1]	= 2;
            triangles[2]	= 0;
            triangles[3]	= 0;
            triangles[4]	= 2;
            triangles[5]	= 3;
            triangles[6]	= 1;
            triangles[7]	= 0;
            triangles[8]	= 3;
            triangles[9]	= 3;
            triangles[10]	= 2;
            triangles[11]	= 1;
        }
        // Uv
        Vector2[]	uvs = new Vector2[4];
        uvs[0]			= new Vector2(1, 1);
        uvs[1]			= new Vector2(1, 0);
        uvs[2]			= new Vector2(0, 0);
        uvs[3]			= new Vector2(0, 1);

        meshFilter.mesh.Clear();
        meshFilter.mesh.vertices	= planeVertices;
        meshFilter.mesh.colors		= colors;
        meshFilter.mesh.normals		= normals;
        meshFilter.mesh.tangents	= tangents;
        meshFilter.mesh.triangles	= triangles;
        meshFilter.mesh.uv			= uvs;
        meshFilter.mesh.RecalculateBounds();

        // 		for (int n = 0; n < meshFilter.mesh.vertices.Length; n++)
        //  			Debug.Log(meshFilter.mesh.vertices[n]);
    }
コード例 #5
0
    public static void UpdatePlane(MeshFilter meshFilter, float fUvScale, NcFrameInfo ncSpriteFrameInfo, bool bTrimCenterAlign, ALIGN_TYPE alignType)
    {
        // 		Debug.Log(ncSpriteFrameInfo.m_FrameUvOffset);

        // m_AlignType
        Vector3[]	planeVertices;
        Vector2		texScale = new Vector2(fUvScale * ncSpriteFrameInfo.m_FrameScale.x, fUvScale * ncSpriteFrameInfo.m_FrameScale.y);
        float		fVAlignHeight = (alignType == ALIGN_TYPE.BOTTOM ? 1.0f*texScale.y : (alignType == ALIGN_TYPE.TOP ? -1.0f*texScale.y : 0));
        Rect		frameUvOffset = ncSpriteFrameInfo.m_FrameUvOffset;
        if (bTrimCenterAlign)
                frameUvOffset.center = Vector2.zero;

        // Vertices
        planeVertices		= new Vector3[4];
        planeVertices[0]	= new Vector3(frameUvOffset.xMax*texScale.x, frameUvOffset.yMax*texScale.y+fVAlignHeight);
        planeVertices[1]	= new Vector3(frameUvOffset.xMax*texScale.x, frameUvOffset.yMin*texScale.y+fVAlignHeight);
        planeVertices[2]	= new Vector3(frameUvOffset.xMin*texScale.x, frameUvOffset.yMin*texScale.y+fVAlignHeight);
        planeVertices[3]	= new Vector3(frameUvOffset.xMin*texScale.x, frameUvOffset.yMax*texScale.y+fVAlignHeight);

        meshFilter.mesh.vertices = planeVertices;
        meshFilter.mesh.RecalculateBounds();

        // 		for (int n = 0; n < meshFilter.mesh.vertices.Length; n++)
        //  			Debug.Log(meshFilter.mesh.vertices[n]);
    }
コード例 #6
0
ファイル: NcSpriteFactory.cs プロジェクト: wly2/BaiLaoHui
    // ------------------------------------------------------------------------------------------
    public static void CreatePlane(MeshFilter meshFilter, float fUvScale, NcFrameInfo ncSpriteFrameInfo,
                                   bool bTrimCenterAlign, ALIGN_TYPE alignType, MESH_TYPE m_MeshType, float fHShowRate)
    {
        //      Debug.Log(ncSpriteFrameInfo.m_FrameUvOffset);

        // m_MeshType, m_AlignType
        Vector3[] planeVertices;
        Vector2   texScale = new Vector2(fUvScale * ncSpriteFrameInfo.m_FrameScale.x,
                                         fUvScale * ncSpriteFrameInfo.m_FrameScale.y);
        float fVAlignHeight = (alignType == ALIGN_TYPE.BOTTOM
            ? 1.0f * texScale.y
            : (alignType == ALIGN_TYPE.TOP ? -1.0f * texScale.y : 0));
        float fHAlignHeight = (alignType == ALIGN_TYPE.LEFTCENTER
            ? 1.0f * texScale.x
            : (alignType == ALIGN_TYPE.RIGHTCENTER ? -1.0f * texScale.x : 0));
        Rect frameUvOffset = ncSpriteFrameInfo.m_FrameUvOffset;

        if (bTrimCenterAlign)
        {
            frameUvOffset.center = Vector2.zero;
        }

        // Vertices
        planeVertices = new Vector3[4];
        if (alignType == ALIGN_TYPE.LEFTCENTER && 0 < fHShowRate)
        {
            planeVertices[0] = new Vector3(frameUvOffset.xMax * texScale.x * fHShowRate + fHAlignHeight * fHShowRate,
                                           frameUvOffset.yMax * texScale.y + fVAlignHeight);
            planeVertices[1] = new Vector3(frameUvOffset.xMax * texScale.x * fHShowRate + fHAlignHeight * fHShowRate,
                                           frameUvOffset.yMin * texScale.y + fVAlignHeight);
        }
        else
        {
            planeVertices[0] = new Vector3(frameUvOffset.xMax * texScale.x + fHAlignHeight,
                                           frameUvOffset.yMax * texScale.y + fVAlignHeight);
            planeVertices[1] = new Vector3(frameUvOffset.xMax * texScale.x + fHAlignHeight,
                                           frameUvOffset.yMin * texScale.y + fVAlignHeight);
        }

        planeVertices[2] = new Vector3(frameUvOffset.xMin * texScale.x + fHAlignHeight,
                                       frameUvOffset.yMin * texScale.y + fVAlignHeight);
        planeVertices[3] = new Vector3(frameUvOffset.xMin * texScale.x + fHAlignHeight,
                                       frameUvOffset.yMax * texScale.y + fVAlignHeight);

        Color defColor = Color.white;

        if (meshFilter.mesh.colors != null && 0 < meshFilter.mesh.colors.Length)
        {
            defColor = meshFilter.mesh.colors[0];
        }

        // Color
        Color[] colors = new Color[4];
        colors[0] = defColor;
        colors[1] = defColor;
        colors[2] = defColor;
        colors[3] = defColor;

        // Normals
        Vector3[] normals = new Vector3[4];
        normals[0] = Vector3.back;
        normals[1] = Vector3.back;
        normals[2] = Vector3.back;
        normals[3] = Vector3.back;

        // Tangents
        Vector4[] tangents = new Vector4[4];
        tangents[0] = new Vector4(1, 0, 0, -1.0f);
        tangents[1] = new Vector4(1, 0, 0, -1.0f);
        tangents[2] = new Vector4(1, 0, 0, -1.0f);
        tangents[3] = new Vector4(1, 0, 0, -1.0f);

        // Triangles
        int[] triangles;
        if (m_MeshType == MESH_TYPE.BuiltIn_Plane)
        {
            triangles    = new int[6];
            triangles[0] = 1;
            triangles[1] = 2;
            triangles[2] = 0;
            triangles[3] = 0;
            triangles[4] = 2;
            triangles[5] = 3;
        }
        else
        {
            triangles     = new int[12];
            triangles[0]  = 1;
            triangles[1]  = 2;
            triangles[2]  = 0;
            triangles[3]  = 0;
            triangles[4]  = 2;
            triangles[5]  = 3;
            triangles[6]  = 1;
            triangles[7]  = 0;
            triangles[8]  = 3;
            triangles[9]  = 3;
            triangles[10] = 2;
            triangles[11] = 1;
        }

        // Uv
        Vector2[] uvs      = new Vector2[4];
        float     fHUvRate = 1;

        if (alignType == ALIGN_TYPE.LEFTCENTER && 0 < fHShowRate)
        {
            fHUvRate = fHShowRate;
        }
        uvs[0] = new Vector2(fHUvRate, 1);
        uvs[1] = new Vector2(fHUvRate, 0);
        uvs[2] = new Vector2(0, 0);
        uvs[3] = new Vector2(0, 1);

        meshFilter.mesh.Clear();
        meshFilter.mesh.vertices  = planeVertices;
        meshFilter.mesh.colors    = colors;
        meshFilter.mesh.normals   = normals;
        meshFilter.mesh.tangents  = tangents;
        meshFilter.mesh.triangles = triangles;
        meshFilter.mesh.uv        = uvs;
        meshFilter.mesh.RecalculateBounds();

        //      for (int n = 0; n < meshFilter.mesh.vertices.Length; n++)
        //              Debug.Log(meshFilter.mesh.vertices[n]);
    }
コード例 #7
0
    // ------------------------------------------------------------------------------------------
    public static void CreatePlane(MeshFilter meshFilter, float fUvScale, NcFrameInfo ncSpriteFrameInfo, ALIGN_TYPE alignType, MESH_TYPE m_MeshType)
    {
//      Debug.Log(ncSpriteFrameInfo.m_FrameUvOffset);

        // m_MeshType, m_AlignType
        Vector3[] planeVertices;
        Vector2   texScale      = new Vector2(fUvScale * ncSpriteFrameInfo.m_FrameScale.x, fUvScale * ncSpriteFrameInfo.m_FrameScale.y);
        float     fVAlignHeight = (alignType == ALIGN_TYPE.BOTTOM ? 1.0f * texScale.y : (alignType == ALIGN_TYPE.TOP ? -1.0f * texScale.y : 0));

        // Vertices
        planeVertices    = new Vector3[4];
        planeVertices[0] = new Vector3(ncSpriteFrameInfo.m_FrameUvOffset.xMax * texScale.x, ncSpriteFrameInfo.m_FrameUvOffset.yMax * texScale.y + fVAlignHeight);
        planeVertices[1] = new Vector3(ncSpriteFrameInfo.m_FrameUvOffset.xMax * texScale.x, ncSpriteFrameInfo.m_FrameUvOffset.yMin * texScale.y + fVAlignHeight);
        planeVertices[2] = new Vector3(ncSpriteFrameInfo.m_FrameUvOffset.xMin * texScale.x, ncSpriteFrameInfo.m_FrameUvOffset.yMin * texScale.y + fVAlignHeight);
        planeVertices[3] = new Vector3(ncSpriteFrameInfo.m_FrameUvOffset.xMin * texScale.x, ncSpriteFrameInfo.m_FrameUvOffset.yMax * texScale.y + fVAlignHeight);

        // Color
        Color[] colors = new Color[4];
        colors[0] = Color.white;
        colors[1] = Color.white;
        colors[2] = Color.white;
        colors[3] = Color.white;

        // Normals
        Vector3[] normals = new Vector3[4];
        normals[0] = new Vector3(0, 0, -1.0f);
        normals[1] = new Vector3(0, 0, -1.0f);
        normals[2] = new Vector3(0, 0, -1.0f);
        normals[3] = new Vector3(0, 0, -1.0f);

        // Tangents
        Vector4[] tangents = new Vector4[4];
        tangents[0] = new Vector4(1, 0, 0, -1.0f);
        tangents[1] = new Vector4(1, 0, 0, -1.0f);
        tangents[2] = new Vector4(1, 0, 0, -1.0f);
        tangents[3] = new Vector4(1, 0, 0, -1.0f);

        // Triangles
        int[] triangles;
        if (m_MeshType == MESH_TYPE.BuiltIn_Plane)
        {
            triangles    = new int[6];
            triangles[0] = 1;
            triangles[1] = 2;
            triangles[2] = 0;
            triangles[3] = 0;
            triangles[4] = 2;
            triangles[5] = 3;
        }
        else
        {
            triangles     = new int[12];
            triangles[0]  = 1;
            triangles[1]  = 2;
            triangles[2]  = 0;
            triangles[3]  = 0;
            triangles[4]  = 2;
            triangles[5]  = 3;
            triangles[6]  = 1;
            triangles[7]  = 0;
            triangles[8]  = 3;
            triangles[9]  = 3;
            triangles[10] = 2;
            triangles[11] = 1;
        }
        // Uv
        Vector2[] uvs = new Vector2[4];
        uvs[0] = new Vector2(1, 1);
        uvs[1] = new Vector2(1, 0);
        uvs[2] = new Vector2(0, 0);
        uvs[3] = new Vector2(0, 1);

        meshFilter.mesh.Clear();
        meshFilter.mesh.vertices  = planeVertices;
        meshFilter.mesh.colors    = colors;
        meshFilter.mesh.normals   = normals;
        meshFilter.mesh.tangents  = tangents;
        meshFilter.mesh.triangles = triangles;
        meshFilter.mesh.uv        = uvs;
        meshFilter.mesh.RecalculateBounds();

//      for (int n = 0; n < meshFilter.mesh.vertices.Length; n++)
//              Debug.Log(meshFilter.mesh.vertices[n]);
    }