📄 micro3dcanvas.java
字号:
import javax.microedition.lcdui.*;import javax.microedition.lcdui.game.*;import com.mascotcapsule.micro3d.v3.*; class Micro3DCanvas extends GameCanvas implements Runnable{ private Graphics3D g3d; private int COMMAND = Graphics3D.PRIMITVE_POINT_SPRITES | Graphics3D.PDATA_POINT_SPRITE_PARAMS_PER_CMD| Graphics3D.PATTR_BLEND_NORMAL; private int []POINT = {0, 0, 0}; private int textureIndex; private int []textureCoords = {127, 106, 0, 0, 0, 127, 106, Graphics3D.POINT_SPRITE_PERSPECTIVE}; //w0, h0, a0, x00, y00, x01, y01, f0, private int [] NORMAL = new int[] {0, 0, 4096}; private int []colors = {0x00FFFFFF}; private Effect3D effect; private AffineTrans trans; private FigureLayout layout; private Texture texture; public Micro3DCanvas(){ super(false); // setFullScreenMode(true); g3d = new Graphics3D(); try{ texture = new Texture("/anmitexture.bmp", true); }catch(Exception e){ e.printStackTrace(); } effect = new Effect3D(); effect.setShadingType(Effect3D.NORMAL_SHADING); effect.setTransparency(true); trans = new AffineTrans(); trans.setIdentity(); trans.lookAt(new Vector3D(0, 0, 128), new Vector3D(0, 0, -4096), new Vector3D(0, 4096, 0)); layout = new FigureLayout(); layout.setPerspective(1, 4096, 512); layout.setCenter(getWidth()/2, getHeight()/2); layout.setAffineTrans(trans); Thread t = new Thread(this); t.start(); } public void run(){ Graphics g = getGraphics(); while(true){ textureIndex = textureIndex == 3?0:textureIndex+1; switch(textureIndex){ case 0: textureCoords[3]= 0; textureCoords[4]= 0; textureCoords[5]= 127; textureCoords[6]= 106; break; case 1: textureCoords[3]= 127; textureCoords[4]= 0; textureCoords[5]= 254; textureCoords[6]= 106; break; case 2: textureCoords[3]= 0; textureCoords[4]= 106; textureCoords[5]= 127; textureCoords[6]= 212; break; case 3: textureCoords[3]= 127; textureCoords[4]= 106; textureCoords[5]= 254; textureCoords[6]= 212; break; } g.setColor(0x000000); g.fillRect(0,0, getWidth(), getHeight()); g3d.bind(g); try{ g3d.renderPrimitives(texture, 0, 0, layout, effect, COMMAND, 1, POINT, NORMAL, textureCoords, colors); g3d.flush(); }catch(Exception e){ System.err.println(e); }finally{ g3d.release(g); } flushGraphics(); try{ Thread.sleep(500); }catch(Exception e){} } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -