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

📄 swdiet3d.java

📁 SWDiet3D is a port to SuperWaba of the Diet3D, the free 3D engine for J2ME mobiles, written by Phili
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        //debug(""+ screenscale );        //screen[2] = -  ( mult( MathFixed.sqrt2 ,  MathFixed.one * MathFixed.max(h_,w_) )  / 2 );  //perspective        // fast lightning        colormap = new int[colormapsize];        int offset = 0x000000FF / colormapsize;        int v = 0;        for(int i=0;i<colormapsize;i++) {            v+=offset;            //if ( COLOR_BG == COLOR_BLACK )             colormap[i] = v + (v<<8) + (v<<16) ;            //else             //colormap[colormapsize-1 - i]            //= COLOR( v + (v<<8) + (v<<16) );        }        reset();        rz_ = ry_ = 1;        //toggleShape();    }    public void reset()    {        this.initIdentity(m_);        rx_ = ry_ = rz_ = 0;    }    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    public void toggleShape(int i)    {        this.initIdentity(m_);        shape = i;        switch (i) {        case 1:            obj_nv = mesh_sphere_nv ;            obj_nf = mesh_sphere_nf ;            obj_vv = mesh_sphere_vv ;            obj_vf = mesh_sphere_vf ;            obj_vc = mesh_sphere_vc ;            obj_trans = null ;            obj_center = null;            break;        case 3:            obj_nv = mesh_logo_nv ;            obj_nf = mesh_logo_nf ;            obj_vv = mesh_logo_vv ;            obj_vf = mesh_logo_vf ;            obj_vc = null;            obj_trans = null ;            obj_center = null;            break;        case 2:            obj_nv = mesh_cross_nv ;            obj_nf = mesh_cross_nf ;            obj_vv = mesh_cross_vv ;            obj_vf = mesh_cross_vf ;            obj_vc = null;            obj_trans = null ;            obj_center = null;            break;        case 4:            obj_nv = mesh_tux_nv ;            obj_nf = mesh_tux_nf ;            obj_vv = mesh_tux_vv ;            obj_vf = mesh_tux_vf ;            obj_vc = mesh_tux_vc ;            obj_trans = null ;            obj_center = null;            break;        default: // 0 = cube            obj_nv = mesh_cube_nv ;            obj_nf = mesh_cube_nf ;            obj_vv = mesh_cube_vv ;            obj_vf = mesh_cube_vf ;            obj_vc = mesh_cube_vc ;            obj_trans = null ;            obj_center = null;            shape = 0;            break;        }        recalc();        // debug("#- toggleShape "+ shape + " ; " + obj_nf );    }    public void toggleShape()    {        toggleShape(1+shape);    }    public void toggleAnim(int i)    {        anim = i % vanim.length;        this.initIdentity(m_);    }    public void toggleAnim()    {        toggleAnim (1+anim);    }    public void toggleMode()    {        toggleMode(mode+1);    }    public void recalc()    {        //if ( (mode >= 11 ) && (obj_trans == null ) ) {             //vmode[mode].equals("test/zort" ) ) {      Vm.gc();      obj_trans = new int[obj_nv][3];      obj_center = new int[obj_nf][3];            //}    }    public void toggleMode(int i)    {        light[0] = 0;        light[1] = 0;        light[2] = - one;        mode=i; // %n = 0 .... n-1        if ( mode >= vmode.length ) {            toggleShape();            mode=0;        }        recalc();    }    public void update()    {        rx_ = rx_%this.sinesize;        ry_ = ry_%this.sinesize;        rz_ = rz_%this.sinesize;        //rotation_ += MathFixed.one % MathFixed.PI2;        //MathFixed.rotate(rotation_,rotation_,rotation_, m_);        //MathFixed.rotate(rotation_,0,0, m_);        //MathFixed.rotate(0,rotation_,0, m_);        //MathFixed.rotate(0,0,rotation_, m_);        //MathFixed.rotate(rotation_,0,rotation_, m_);        if ( anim >= 2 ) { // dynlight fx            this.initIdentity(m_);        }        this.rotate( rx_*rotation_, ry_ *rotation_, rz_ *rotation_, m_);        updated++;    }    public void tick()    {        if( anim <= 0 ) {            switch (tick) {            case 1: // point                toggleShape(1);                toggleMode(1);                break;            case 2: //wire                toggleShape(2);                toggleMode(2);                break;            case 12:                toggleShape(0);                toggleMode(0);                break;            case 0:                break;            default:                toggleMode();                break;            }        }        tick++;    }    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     /** Rotation step */    public int rotation_ = this.sinstep;    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    /** lightning */    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        //protected	public        void paint(Graphics g)        {            g.setBackColor(Color.WHITE);        g.fillRect( 0 , 0, w_ , h_ ); //bound box trick //TODO        switch(mode) { // [ %n : 0 ... n-1]        case 1: g.setForeColor(Color.BLACK); paintVertex(g); break;        case 2: g.setForeColor(Color.BLACK); paintLine(g); break;        default: // 0            g.setForeColor(Color.BLACK);            paintLine(g);            g.setForeColor(Color.BLACK);            paintString(g, "Shape " + vshape[shape] + " # " + obj_nf );        }    }    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}/* $Id: Diet3D.java.in,v 1.10 2004/11/02 14:33:14 rzr Exp $ */

⌨️ 快捷键说明

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