⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 meshcreate.java

📁 在J2ME下面实现3D菜单,可以用于游戏开发(需要jsr184支持)
💻 JAVA
字号:
import javax.microedition.m3g.*;public class MeshCreate {    public static Mesh createItem(){                short []POINTS = new short[] {        		-4, -1, 1,      4, -1, 1,     4, 1, 1,      -4, 1, 1, //Front                4, -1, -1,       -4, -1, -1,   -4, 1, -1,     4, 1, -1, //Back                -4, -1, -1,      -4, -1, 1,   -4, 1, 1,      -4, 1, -1, //Left                4, -1, 1,        4, -1, -1,     4, 1, -1,    4, 1, 1, //Right                -4, 1, 1,        4, 1, 1,        4, 1, -1,    -4, 1, -1, // Top                -4, -1, -1,      4, -1, -1,    4, -1, 1,     -4, -1, 1}; // Bottom                short []TEXTCOORDINATES = new short[] {        		0, 1,      1, 1,       1, 0,       0, 0,                1, 0,      0, 0,       0, 1,       1, 1,                0, 1,      1, 1,       1, 0,       0, 0,                0, 1,      1, 1,       1, 0,       0, 0,                0, 1,      1, 1,       1, 0,       0, 0,                0, 1,      1, 1,       1, 0,       0, 0};      int []FRONT_INDICES = new int[] {0, 1, 3, 2};      int []BACK_INDICES = new int[] {4, 5, 7, 6};      int []LEFT_INDICES = new int[] {8, 9, 11, 10};      int []RIGHT_INDICES = new int[] {12, 13, 15, 14};      int []TOP_INDICES = new int[] {16, 17, 19, 18};      int []BOTTOM_INDICES = new int[] {20, 21, 23, 22};                                         int[] LENGTHS = new int[] {4};         VertexArray POSITIONS_ARRAY, TEXTURE_ARRAY;         IndexBuffer []INDEX_BUFFER = new IndexBuffer[6];        POSITIONS_ARRAY = new VertexArray(POINTS.length/3, 3, 2);         POSITIONS_ARRAY.set(0, POINTS.length/3, POINTS);         TEXTURE_ARRAY = new VertexArray(TEXTCOORDINATES.length/2, 2, 2);        TEXTURE_ARRAY.set(0, TEXTCOORDINATES.length/2, TEXTCOORDINATES);                INDEX_BUFFER[0] = new TriangleStripArray(FRONT_INDICES, LENGTHS);        INDEX_BUFFER[1] = new TriangleStripArray(BACK_INDICES, LENGTHS);        INDEX_BUFFER[2] = new TriangleStripArray(LEFT_INDICES, LENGTHS);        INDEX_BUFFER[3] = new TriangleStripArray(RIGHT_INDICES, LENGTHS);        INDEX_BUFFER[4] = new TriangleStripArray(TOP_INDICES, LENGTHS);        INDEX_BUFFER[5] = new TriangleStripArray(BOTTOM_INDICES, LENGTHS);                VertexBuffer vertexBuffer = new VertexBuffer();         vertexBuffer.setPositions(POSITIONS_ARRAY, 1.0f, null);         vertexBuffer.setTexCoords(0, TEXTURE_ARRAY, 1.0f, null);        vertexBuffer.setDefaultColor(0x80FFFFFF);        Mesh mesh = new Mesh(vertexBuffer, INDEX_BUFFER, null);         Appearance []appearance = new Appearance[6];        PolygonMode polygonMode = new PolygonMode();        polygonMode.setPerspectiveCorrectionEnable(true);        polygonMode.setCulling(PolygonMode.CULL_NONE);        CompositingMode cm = new CompositingMode();        cm.setBlending(CompositingMode.ALPHA);                for(int i=0; i<appearance.length; i++){            appearance[i] = new Appearance();            appearance[i].setPolygonMode(polygonMode);            mesh.setAppearance(i, appearance[i]);        }        return mesh;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -