亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? zbufferedrenderer.java

?? Java games programing--很好的java游戲編程源碼
?? JAVA
字號:
package com.brackeen.javagamebook.graphics3D;

import java.awt.*;
import java.awt.image.*;
import java.util.HashMap;
import com.brackeen.javagamebook.math3D.*;
import com.brackeen.javagamebook.graphics3D.texture.*;
import com.brackeen.javagamebook.game.*;

/**
    The ZBufferedRenderer is a PolygonRenderer that
    renders polygons with a Z-Buffer to ensure correct rendering
    (closer objects appear in front of farther away objects).
*/
public class ZBufferedRenderer
    extends ShadedSurfacePolygonRenderer
    implements GameObjectRenderer
{
    /**
        The minimum distance for z-buffering. Larger values give
        more accurate calculations for further distances.
    */
    protected static final int MIN_DISTANCE = 12;

    protected TexturedPolygon3D temp;
    protected ZBuffer zBuffer;
    // used for calculating depth
    protected float w;

    public ZBufferedRenderer(Transform3D camera,
        ViewWindow viewWindow)
    {
        this(camera, viewWindow, true);
    }

    public ZBufferedRenderer(Transform3D camera,
        ViewWindow viewWindow, boolean eraseView)
    {
        super(camera, viewWindow, eraseView);
        temp = new TexturedPolygon3D();
    }

    protected void init() {
        destPolygon = new TexturedPolygon3D();
        scanConverter = new ScanConverter(viewWindow);

        // create renders for each texture (HotSpot optimization)
        scanRenderers = new HashMap();
        scanRenderers.put(PowerOf2Texture.class,
            new PowerOf2TextureZRenderer());
        scanRenderers.put(ShadedTexture.class,
            new ShadedTextureZRenderer());
        scanRenderers.put(ShadedSurface.class,
            new ShadedSurfaceZRenderer());
    }


    public void startFrame(Graphics2D g) {
        super.startFrame(g);
        // initialize depth buffer
        if (zBuffer == null ||
            zBuffer.getWidth() != viewWindow.getWidth() ||
            zBuffer.getHeight() != viewWindow.getHeight())
        {
            zBuffer = new ZBuffer(
                viewWindow.getWidth(), viewWindow.getHeight());
        }
        else if (clearViewEveryFrame) {
            zBuffer.clear();
        }
    }

    public boolean draw(Graphics2D g, GameObject object) {
        return draw(g, object.getPolygonGroup());
    }

    public boolean draw(Graphics2D g, PolygonGroup group) {
        boolean visible = false;
        group.resetIterator();
        while (group.hasNext()) {
            group.nextPolygonTransformed(temp);
            visible |= draw(g, temp);
        }
        return visible;
    }


    protected void drawCurrentPolygon(Graphics2D g) {
        if (!(sourcePolygon instanceof TexturedPolygon3D)) {
            // not a textured polygon - return
            return;
        }
        buildSurface();
        TexturedPolygon3D poly = (TexturedPolygon3D)destPolygon;
        Texture texture = poly.getTexture();
        ScanRenderer scanRenderer = (ScanRenderer)
            scanRenderers.get(texture.getClass());
        scanRenderer.setTexture(texture);
        Rectangle3D textureBounds = poly.getTextureBounds();

        a.setToCrossProduct(textureBounds.getDirectionV(),
            textureBounds.getOrigin());
        b.setToCrossProduct(textureBounds.getOrigin(),
            textureBounds.getDirectionU());
        c.setToCrossProduct(textureBounds.getDirectionU(),
            textureBounds.getDirectionV());

        // w is used to compute depth at each pixel
        w = SCALE * MIN_DISTANCE * Short.MAX_VALUE /
            (viewWindow.getDistance() *
            c.getDotProduct(textureBounds.getOrigin()));

        int y = scanConverter.getTopBoundary();
        viewPos.y = viewWindow.convertFromScreenYToViewY(y);
        viewPos.z = -viewWindow.getDistance();

        while (y<=scanConverter.getBottomBoundary()) {
            ScanConverter.Scan scan = scanConverter.getScan(y);

            if (scan.isValid()) {
                viewPos.x = viewWindow.
                    convertFromScreenXToViewX(scan.left);
                int offset = (y - viewWindow.getTopOffset()) *
                    viewWindow.getWidth() +
                    (scan.left - viewWindow.getLeftOffset());

                scanRenderer.render(offset, scan.left, scan.right);
            }
            y++;
            viewPos.y--;
        }
    }


    // the following three ScanRenderers are the same, but refer
    // to textures explicitly as either a PowerOf2Texture, a
    // ShadedTexture, or a ShadedSurface.
    // This allows HotSpot to do some inlining of the textures'
    // getColor() method, which significantly increases
    // performance.

    public class PowerOf2TextureZRenderer extends ScanRenderer {

        public void render(int offset, int left, int right) {
            PowerOf2Texture texture =
                (PowerOf2Texture)currentTexture;
            float u = SCALE * a.getDotProduct(viewPos);
            float v = SCALE * b.getDotProduct(viewPos);
            float z = c.getDotProduct(viewPos);
            float du = INTERP_SIZE * SCALE * a.x;
            float dv = INTERP_SIZE * SCALE * b.x;
            float dz = INTERP_SIZE * c.x;
            int nextTx = (int)(u/z);
            int nextTy = (int)(v/z);
            int depth = (int)(w*z);
            int dDepth = (int)(w*c.x);
            int x = left;
            while (x <= right) {
                int tx = nextTx;
                int ty = nextTy;
                int maxLength = right-x+1;
                if (maxLength > INTERP_SIZE) {
                    u+=du;
                    v+=dv;
                    z+=dz;
                    nextTx = (int)(u/z);
                    nextTy = (int)(v/z);
                    int dtx = (nextTx-tx) >> INTERP_SIZE_BITS;
                    int dty = (nextTy-ty) >> INTERP_SIZE_BITS;
                    int endOffset = offset + INTERP_SIZE;
                    while (offset < endOffset) {
                        if (zBuffer.checkDepth(offset,
                            (short)(depth >> SCALE_BITS)))
                        {
                            doubleBufferData[offset] =
                                texture.getColor(tx >> SCALE_BITS,
                                ty >> SCALE_BITS);
                        }
                        offset++;
                        tx+=dtx;
                        ty+=dty;
                        depth+=dDepth;
                    }
                    x+=INTERP_SIZE;
                }
                else {
                    // variable interpolation size
                    int interpSize = maxLength;
                    u += interpSize * SCALE * a.x;
                    v += interpSize * SCALE * b.x;
                    z += interpSize * c.x;
                    nextTx = (int)(u/z);
                    nextTy = (int)(v/z);
                    int dtx = (nextTx-tx) / interpSize;
                    int dty = (nextTy-ty) / interpSize;
                    int endOffset = offset + interpSize;
                    while (offset < endOffset) {
                        if (zBuffer.checkDepth(offset,
                            (short)(depth >> SCALE_BITS)))
                        {
                            doubleBufferData[offset++] =
                                texture.getColor(tx >> SCALE_BITS,
                                ty >> SCALE_BITS);
                        }
                        offset++;
                        tx+=dtx;
                        ty+=dty;
                        depth+=dDepth;
                    }
                    x+=interpSize;

                }

            }
        }
    }

    public class ShadedTextureZRenderer extends ScanRenderer {

        public void render(int offset, int left, int right) {
            ShadedTexture texture =
                (ShadedTexture)currentTexture;
            float u = SCALE * a.getDotProduct(viewPos);
            float v = SCALE * b.getDotProduct(viewPos);
            float z = c.getDotProduct(viewPos);
            float du = INTERP_SIZE * SCALE * a.x;
            float dv = INTERP_SIZE * SCALE * b.x;
            float dz = INTERP_SIZE * c.x;
            int nextTx = (int)(u/z);
            int nextTy = (int)(v/z);
            int depth = (int)(w*z);
            int dDepth = (int)(w*c.x);
            int x = left;
            while (x <= right) {
                int tx = nextTx;
                int ty = nextTy;
                int maxLength = right-x+1;
                if (maxLength > INTERP_SIZE) {
                    u+=du;
                    v+=dv;
                    z+=dz;
                    nextTx = (int)(u/z);
                    nextTy = (int)(v/z);
                    int dtx = (nextTx-tx) >> INTERP_SIZE_BITS;
                    int dty = (nextTy-ty) >> INTERP_SIZE_BITS;
                    int endOffset = offset + INTERP_SIZE;
                    while (offset < endOffset) {
                        if (zBuffer.checkDepth(offset,
                            (short)(depth >> SCALE_BITS)))
                        {
                            doubleBufferData[offset] =
                                texture.getColor(tx >> SCALE_BITS,
                                ty >> SCALE_BITS);
                        }
                        offset++;
                        tx+=dtx;
                        ty+=dty;
                        depth+=dDepth;
                    }
                    x+=INTERP_SIZE;
                }
                else {
                    // variable interpolation size
                    int interpSize = maxLength;
                    u += interpSize * SCALE * a.x;
                    v += interpSize * SCALE * b.x;
                    z += interpSize * c.x;
                    nextTx = (int)(u/z);
                    nextTy = (int)(v/z);
                    int dtx = (nextTx-tx) / interpSize;
                    int dty = (nextTy-ty) / interpSize;
                    int endOffset = offset + interpSize;
                    while (offset < endOffset) {
                        if (zBuffer.checkDepth(offset,
                            (short)(depth >> SCALE_BITS)))
                        {
                            doubleBufferData[offset] =
                                texture.getColor(tx >> SCALE_BITS,
                                ty >> SCALE_BITS);
                        }
                        offset++;
                        tx+=dtx;
                        ty+=dty;
                        depth+=dDepth;
                    }
                    x+=interpSize;
                }

            }
        }
    }

    public class ShadedSurfaceZRenderer extends ScanRenderer {

        public int checkBounds(int vScaled, int bounds) {
            int v = vScaled >> SCALE_BITS;
            if (v < 0) {
                vScaled = 0;
            }
            else if (v >= bounds) {
                vScaled = (bounds - 1) << SCALE_BITS;
            }
            return vScaled;
        }

        public void render(int offset, int left, int right) {
            ShadedSurface texture =
                (ShadedSurface)currentTexture;
            float u = SCALE * a.getDotProduct(viewPos);
            float v = SCALE * b.getDotProduct(viewPos);
            float z = c.getDotProduct(viewPos);
            float du = INTERP_SIZE * SCALE * a.x;
            float dv = INTERP_SIZE * SCALE * b.x;
            float dz = INTERP_SIZE * c.x;
            int nextTx = (int)(u/z);
            int nextTy = (int)(v/z);
            int depth = (int)(w*z);
            int dDepth = (int)(w*c.x);
            int x = left;
            while (x <= right) {
                int tx = nextTx;
                int ty = nextTy;
                int maxLength = right-x+1;
                if (maxLength > INTERP_SIZE) {
                    u+=du;
                    v+=dv;
                    z+=dz;
                    nextTx = (int)(u/z);
                    nextTy = (int)(v/z);
                    int dtx = (nextTx-tx) >> INTERP_SIZE_BITS;
                    int dty = (nextTy-ty) >> INTERP_SIZE_BITS;
                    int endOffset = offset + INTERP_SIZE;
                    while (offset < endOffset) {
                        if (zBuffer.checkDepth(offset,
                            (short)(depth >> SCALE_BITS)))
                        {
                            doubleBufferData[offset] =
                                texture.getColor(tx >> SCALE_BITS,
                                ty >> SCALE_BITS);
                        }
                        offset++;
                        tx+=dtx;
                        ty+=dty;
                        depth+=dDepth;
                    }
                    x+=INTERP_SIZE;
                }
                else {
                    // variable interpolation size
                    int interpSize = maxLength;
                    u += interpSize * SCALE * a.x;
                    v += interpSize * SCALE * b.x;
                    z += interpSize * c.x;
                    nextTx = (int)(u/z);
                    nextTy = (int)(v/z);

                    // make sure tx, ty, nextTx, and nextTy are
                    // all within bounds
                    tx = checkBounds(tx, texture.getWidth());
                    ty = checkBounds(ty, texture.getHeight());
                    nextTx = checkBounds(nextTx, texture.getWidth());
                    nextTy = checkBounds(nextTy, texture.getHeight());

                    int dtx = (nextTx-tx) / interpSize;
                    int dty = (nextTy-ty) / interpSize;
                    int endOffset = offset + interpSize;
                    while (offset < endOffset) {
                        if (zBuffer.checkDepth(offset,
                            (short)(depth >> SCALE_BITS)))
                        {
                            doubleBufferData[offset] =
                                texture.getColor(tx >> SCALE_BITS,
                                ty >> SCALE_BITS);
                        }
                        offset++;
                        tx+=dtx;
                        ty+=dty;
                        depth+=dDepth;
                    }
                    x+=interpSize;

                }

            }
        }
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久www免费人成看片高清| 国产精品一级在线| 久久久三级国产网站| 色综合久久久久网| 国产一区二区中文字幕| 亚洲成人tv网| 一区精品在线播放| 精品乱码亚洲一区二区不卡| 日本精品一级二级| 成人精品小蝌蚪| 国产一区二三区| 青青青伊人色综合久久| 亚洲综合激情另类小说区| 国产偷v国产偷v亚洲高清| 91精品国产综合久久久蜜臀粉嫩 | 亚洲高清在线视频| 国产精品女主播av| 26uuu色噜噜精品一区| 在线成人免费视频| 欧洲亚洲国产日韩| 一本色道久久综合亚洲91 | 日韩有码一区二区三区| 亚洲视频狠狠干| 国产精品激情偷乱一区二区∴| www亚洲一区| 亚洲国产一区二区a毛片| 国产精品久久久久影院亚瑟| 久久久久综合网| 久久天天做天天爱综合色| 日韩视频在线你懂得| 欧美日韩aaaaa| 欧美男生操女生| 欧美久久免费观看| 欧美日韩精品一区二区天天拍小说| 91色九色蝌蚪| 97久久超碰国产精品电影| 99国内精品久久| 91在线国产福利| 91福利视频在线| 在线观看三级视频欧美| 欧美系列日韩一区| 欧美男女性生活在线直播观看| 欧美性猛交xxxx乱大交退制版 | 国产精品亚洲第一| 国产一区二区免费看| 国产精品一区不卡| 国产1区2区3区精品美女| 成人免费高清在线| 91美女蜜桃在线| 欧美综合天天夜夜久久| 欧美群妇大交群中文字幕| 91麻豆精品国产无毒不卡在线观看| 欧美福利一区二区| 欧美大片一区二区| 久久久www成人免费无遮挡大片| 日本一区二区久久| 亚洲人成影院在线观看| 亚洲成av人片一区二区| 蜜臀av性久久久久av蜜臀妖精| 精品综合免费视频观看| 国产成人精品免费在线| 色综合天天综合色综合av| 在线观看欧美日本| 日韩手机在线导航| 欧美国产日韩亚洲一区| 亚洲欧美日韩久久精品| 天涯成人国产亚洲精品一区av| 青娱乐精品视频| 高清国产一区二区三区| 91官网在线免费观看| 欧美高清视频在线高清观看mv色露露十八 | 亚洲视频一区二区在线观看| 亚洲一区二区三区中文字幕| 日本在线不卡视频| 成人激情校园春色| 欧美美女网站色| 国产亚洲精品aa午夜观看| 亚洲九九爱视频| 国内精品视频一区二区三区八戒| 波多野结衣在线aⅴ中文字幕不卡| 欧美日韩中文字幕一区二区| wwwwww.欧美系列| 亚洲国产aⅴ成人精品无吗| 国产很黄免费观看久久| 欧美无乱码久久久免费午夜一区| 久久这里只有精品6| 亚洲精品中文在线影院| 国产精品小仙女| 91精品国产一区二区三区蜜臀 | 日韩精品一区二区三区中文不卡 | 国产精品久久久久久久久果冻传媒| 亚洲国产精品一区二区www在线 | 奇米色777欧美一区二区| www.亚洲免费av| 精品嫩草影院久久| 亚洲综合一二三区| 国产成+人+日韩+欧美+亚洲| 91麻豆精品国产91久久久久久久久| 国产三级精品在线| 秋霞午夜av一区二区三区| 91天堂素人约啪| 国产亚洲精品精华液| 美女在线一区二区| 欧美亚州韩日在线看免费版国语版| 国产亚洲精品久| 久久99精品国产.久久久久久| 欧美亚洲动漫精品| 亚洲欧洲精品成人久久奇米网| 激情成人综合网| 日韩一级精品视频在线观看| 亚洲一级片在线观看| 一本久道久久综合中文字幕 | 欧美电视剧在线观看完整版| 一区二区成人在线| 不卡视频免费播放| 国产日韩v精品一区二区| 精品午夜久久福利影院| 欧美一区二区在线不卡| 亚洲国产精品一区二区久久| 色婷婷亚洲精品| 成人免费在线观看入口| 成人网在线免费视频| 国产亚洲精品bt天堂精选| 国产一区二区免费在线| 欧美一卡2卡三卡4卡5免费| 亚洲www啪成人一区二区麻豆| 在线一区二区观看| 一区二区理论电影在线观看| 91免费国产在线| 亚洲欧美精品午睡沙发| 91日韩精品一区| 亚洲视频香蕉人妖| 91久久久免费一区二区| 亚洲乱码日产精品bd| 另类中文字幕网| 欧美乱妇一区二区三区不卡视频| 亚洲一区在线观看视频| 日本伦理一区二区| 亚洲综合色自拍一区| 精品视频全国免费看| 五月婷婷久久丁香| 91精品国产色综合久久| 琪琪久久久久日韩精品| 精品久久久久久久久久久久包黑料 | 亚洲一区二区在线观看视频| 一本一道久久a久久精品综合蜜臀| 亚洲免费观看视频| 欧美亚一区二区| 日本在线不卡视频一二三区| 日韩精品一区二区三区视频在线观看| 久久激情五月婷婷| 国产亚洲一区二区三区在线观看| 国产伦精品一区二区三区视频青涩| 久久久www免费人成精品| 不卡av免费在线观看| 亚洲欧美日韩精品久久久久| 精品视频999| 看片网站欧美日韩| 国产婷婷色一区二区三区在线| av高清不卡在线| 香蕉成人啪国产精品视频综合网| 日韩一区二区高清| 高清国产一区二区三区| 亚洲精品欧美激情| 日韩一区二区三区四区| 国产aⅴ精品一区二区三区色成熟| 国产精品传媒视频| 欧美高清www午色夜在线视频| 精品在线播放午夜| 亚洲免费观看高清在线观看| 欧美久久久久久久久| 国产精品一卡二卡| 亚洲高清三级视频| 国产亚洲欧洲997久久综合 | 国产一区二区精品久久| 国产精品超碰97尤物18| 欧美日韩一区二区三区四区五区| 韩国一区二区在线观看| 亚洲天堂免费看| 欧美xxxx老人做受| 色婷婷国产精品| 国产一区欧美二区| 亚洲大型综合色站| 国产精品久久久久影院亚瑟| 91精品国产色综合久久不卡电影| 99这里只有精品| 麻豆国产欧美一区二区三区| 亚洲精品国产精华液| 久久婷婷综合激情| 欧美日韩国产bt| av日韩在线网站| 国产美女视频一区| 丝袜美腿亚洲综合| 综合久久国产九一剧情麻豆| 日韩女同互慰一区二区| 欧美在线免费观看视频| jlzzjlzz亚洲日本少妇| 九九热在线视频观看这里只有精品| 亚洲精品免费在线观看| 国产欧美精品国产国产专区 |