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

📄 ground.java

📁 3D snake game with intermediate graphic
💻 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 + -