?? ground.java
字號:
import java.io.IOException;
import javax.microedition.lcdui.Image;
import javax.microedition.m3g.Appearance;
import javax.microedition.m3g.Fog;
import javax.microedition.m3g.Image2D;
import javax.microedition.m3g.IndexBuffer;
import javax.microedition.m3g.Material;
import javax.microedition.m3g.PolygonMode;
import javax.microedition.m3g.Texture2D;
import javax.microedition.m3g.Transform;
import javax.microedition.m3g.TriangleStripArray;
import javax.microedition.m3g.VertexArray;
import javax.microedition.m3g.VertexBuffer;
/*
* Snake 3D by Krisna
*/
public class Ground {
short[] vert={
50,0,45, 50,0,-45, -50,0,45, -50,0,-45
};
byte[] norm = {
0, 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, 127,
};
private int [] stripLen={4};
private Appearance iAppearancegd;
private Texture2D texture;
private Image2D image2D;
private VertexBuffer iVbgd;
private VertexArray verticeArray;
private IndexBuffer iIbgd;
private Transform transform;
private VertexArray normArray;
private Material iMaterial;
private Fog fm;
public Ground() {
transform = new Transform();
transform.postTranslate(0.0f,0.0f,0.0f);//No Transpostion
//postTranslate(float x,float y,float z);
verticeArray=new VertexArray(vert.length/3,3,2);
//(int numVertices, int numComponents, int componentSize in bytes)
verticeArray.set(0,vert.length/3,vert);
VertexArray normArray = new VertexArray(norm.length / 3, 3, 1);
normArray.set(0, norm.length/3, norm);
iVbgd=new VertexBuffer();
iVbgd.setPositions(verticeArray,1.0f,null);
iVbgd.setNormals(normArray);
iIbgd=new TriangleStripArray(0,stripLen);
iAppearancegd= new Appearance();
iMaterial=new Material();
iMaterial.setColor(Material.DIFFUSE,0x99CCFF);
// iMaterial.setColor(Material.SPECULAR,0x99CCFF);
iMaterial.setShininess( 100.0f);
fm=new Fog();
fm.setColor(0xffffff);
fm.setMode(Fog.LINEAR);
fm.setLinear(1,200);
fm.setDensity(0.5f);
iAppearancegd.setMaterial(iMaterial);
iAppearancegd.setFog(fm);
}
public short[] getVert() {
return vert;
}
public IndexBuffer getIIbgd() {
return iIbgd;
}
public Appearance getIAppearancegd() {
return iAppearancegd;
}
public VertexBuffer getIVbgd() {
return iVbgd;
}
public void setVert(short[] vert) {
this.vert = vert;
}
public int getLenght() {
return vert.length;
}
public Transform getTransform() {
return transform;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -