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

📄 zpolygonlist.java

📁 java 编写的小游戏--坦克大战
💻 JAVA
字号:
// Decompiled by DJ v2.9.9.60 Copyright 2000 Atanas Neshkov  Date: 2004-12-12 17:51:53
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   ZPolygonList.java


public class ZPolygonList
{

    public void Draw()
    {
        ZSort();
        if(fWireframeMode)
        {
            for(int i = 0; i < fNumPolygons; i++)
                fPolygons[i].DrawWireframe();

            return;
        }
        for(int j = 0; j < fNumPolygons; j++)
            fPolygons[j].DrawSolid();

    }

    public ZPolygon GetPolygonPointer(int i)
    {
        return fPolygons[i];
    }

    public ZPolygonList()
    {
        fNumPolygons = 0;
        fPolygons = new ZPolygon[MAX_POLYGONS];
    }

    public int GetPolygonCount()
    {
        return fNumPolygons;
    }

    public void MakePolygonList(ZWorld zworld)
    {
        int i = 0;
        for(int j = 0; j < zworld.fNumObjects; j++)
        {
            ZObject zobject = zworld.fObjects[j];
            for(int k = 0; k < zobject.fNumPolygons; k++)
            {
                ZPolygon zpolygon = zobject.fPolygons[k];
                if(!zpolygon.Backface())
                {
                    int i1;
                    int j1;
                    int l = i1 = j1 = 0x80000000;
                    int l1;
                    int i2;
                    int k1 = l1 = i2 = 0x7fffffff;
                    for(int j2 = 0; j2 < zpolygon.fNumVertices; j2++)
                    {
                        ZVertex zvertex = zpolygon.fVertices[j2];
                        if(zvertex.fAx > l)
                            l = zvertex.fAx;
                        else
                        if(zvertex.fAx < k1)
                            k1 = zvertex.fAx;
                        if(zvertex.fAy > i1)
                            i1 = zvertex.fAy;
                        else
                        if(zvertex.fAy < l1)
                            l1 = zvertex.fAy;
                        if(zvertex.fAz > j1)
                            j1 = zvertex.fAz;
                        else
                        if(zvertex.fAz < i2)
                            i2 = zvertex.fAz;
                    }

                    zpolygon.fZMin = i2;
                    zpolygon.fZMax = j1;
                    if(i2 != 0 && j1 != 0)
                    {
                        int k2 = 0;
                        int l2 = 0;
                        do
                            k2 += zpolygon.fVertices[l2++].fAz;
                        while(l2 < zpolygon.fNumVertices);
                        k2 /= l2;
                        zpolygon.fZDistance = k2;
                        float f = fView.fXMax * k2 >> 8;
                        float f1 = -f;
                        float f2 = fView.fYMax * k2 >> 8;
                        float f3 = -f2;
                        if((float)k1 > f1 && (float)l < f && (float)l1 > f3 && (float)i1 < f2)
                        {
                            fPolygons[i++] = zpolygon;
                            zpolygon.fXMin = k1;
                            zpolygon.fYMin = l1;
                            zpolygon.fXMax = l;
                            zpolygon.fYMax = i1;
                        }
                    }
                }
            }

        }

        fNumPolygons = i;
    }

    public void ZSort()
    {
        boolean flag;
        do
        {
            flag = false;
            for(int i = 0; i < fNumPolygons - 1 && !flag; i++)
                if(fPolygons[i].fZDistance < fPolygons[i + 1].fZDistance)
                {
                    ZPolygon zpolygon = fPolygons[i];
                    fPolygons[i] = fPolygons[i + 1];
                    fPolygons[i + 1] = zpolygon;
                    flag = true;
                }

        } while(flag);
    }

    int fNumPolygons;
    ZPolygon fPolygons[];
    static int MAX_POLYGONS = 500;
    static final int MAX_INTEGER = 0x7fffffff;
    static final int MIN_INTEGER = 0x80000000;
    ZView fView;
    boolean fWireframeMode;

}

⌨️ 快捷键说明

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