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

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

?? renderer.java

?? NeHe用java與OpenGL結合教程源碼
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
                            if (!((rt[0] <= EPSILON) && (uveloc.dot(norm) > EPSILON))) {
                                normal.set(norm);
                                point.set(Nc);
                                lamda[0] = rt4;
                                BallNr = i;
                            }
                    }
                }

                if (TestIntersionCylinder(cyl3, oldPos[i], uveloc, rt, norm, Nc)) {
                    rt4 = rt[0] * RestTime[0] / rt2;
                    if (rt4 <= lamda[0]) {
                        if (rt4 <= RestTime[0] + EPSILON)
                            if (!((rt[0] <= EPSILON) && (uveloc.dot(norm) > EPSILON))) {
                                normal.set(norm);
                                point.set(Nc);
                                lamda[0] = rt4;
                                BallNr = i;
                            }
                    }
                }
            }

            //After all balls were tested with planes/cylinders test for collision
            //between them and replace if collision time smaller
            if (findBallCol(Pos2, BallTime, RestTime, BallColNr1, BallColNr2) == 1) {
                if (soundsEnabled)
                    audioSample.play();

                if ((lamda[0] == 10000) || (lamda[0] > BallTime[0])) {
                    RestTime[0] = RestTime[0] - BallTime[0];
                    Tuple3d pb1 = new Tuple3d(),
                            pb2 = new Tuple3d(),
                            xaxis = new Tuple3d(),
                            U1x = new Tuple3d(),
                            U1y = new Tuple3d(),
                            U2x = new Tuple3d(),
                            U2y = new Tuple3d(),
                            V1x = new Tuple3d(),
                            V1y = new Tuple3d(),
                            V2x = new Tuple3d(),
                            V2y = new Tuple3d();
                    double a,b;

                    pb1.scaleAdd(BallTime[0], arrayVel[BallColNr1[0]], oldPos[BallColNr1[0]]);
                    pb2.scaleAdd(BallTime[0], arrayVel[BallColNr2[0]], oldPos[BallColNr2[0]]);
                    xaxis.sub(pb2, pb1);
                    xaxis.normalize();

                    a = xaxis.dot(arrayVel[BallColNr1[0]]);
                    U1x.scaleAdd(a, xaxis);
                    U1y.sub(arrayVel[BallColNr1[0]], U1x);

                    xaxis.sub(pb1, pb2);
                    xaxis.normalize();

                    b = xaxis.dot(arrayVel[BallColNr2[0]]);
                    U2x.scaleAdd(b, xaxis);
                    U2y.sub(arrayVel[BallColNr2[0]], U2x);

                    V1x.add(U1x, U2x);
                    V1x.sub(new Tuple3d(U1x.x - U2x.x, U1x.y - U2x.y, U1x.z - U2x.z));
                    V1x.scale(.5);

                    V2x.add(U1x, U2x);
                    V2x.sub(new Tuple3d(U2x.x - U1x.x, U2x.y - U1x.y, U2x.z - U1x.z));
                    V2x.scale(.5);

                    V1y.set(U1y);
                    V2y.set(U2y);

                    for (int j = 0; j < nrOfBalls; j++)
                        arrayPos[j].scaleAdd(BallTime[0], arrayVel[j], oldPos[j]);

                    arrayVel[BallColNr1[0]].add(V1x, V1y);
                    arrayVel[BallColNr2[0]].add(V2x, V2y);

                    //Update explosion array
                    for (int j = 0; j < 20; j++) {
                        if (explosions[j].alpha <= 0) {
                            explosions[j].alpha = 1;
                            explosions[j].position = arrayPos[BallColNr1[0]];
                            explosions[j].scale = 1;
                            break;
                        }
                    }
                    continue;
                }
            }
            //End of tests
            //If test occured move simulation for the correct timestep
            //and compute response for the colliding ball
            if (lamda[0] != 10000) {
                RestTime[0] -= lamda[0];

                for (int j = 0; j < nrOfBalls; j++)
                    arrayPos[j].scaleAdd(lamda[0], arrayVel[j], oldPos[j]);

                rt2 = arrayVel[BallNr].length();
                arrayVel[BallNr].normalize();

                normal.scale(-2 * normal.dot(arrayVel[BallNr]));
                arrayVel[BallNr].add(normal, arrayVel[BallNr]);
                arrayVel[BallNr].normalize();
                arrayVel[BallNr].scale(rt2);

                // Update explosion array
                for (int j = 0; j < 20; j++) {
                    if (explosions[j].alpha <= 0) {
                        explosions[j].alpha = 1;
                        explosions[j].position = point;
                        explosions[j].scale = 1;
                        break;
                    }
                }
            } else
                RestTime[0] = 0;
        }
    }

    public void reshape(GLAutoDrawable drawable,
                        int xstart,
                        int ystart,
                        int width,
                        int height) {
        GL gl = drawable.getGL();

        height = (height == 0) ? 1 : height;

        gl.glViewport(0, 0, width, height);         // Reset The Current Viewport
        gl.glMatrixMode(GL.GL_PROJECTION);       // Select The Projection Matrix
        gl.glLoadIdentity();                     // Reset The Projection Matrix

        // Calculate The Aspect Ratio Of The Window
        glu.gluPerspective(50.0f, (float) width / height, 10.f, 1700.0f);

        gl.glMatrixMode(GL.GL_MODELVIEW);        // Select The Modelview Matrix
        gl.glLoadIdentity();
    }

    public void displayChanged(GLAutoDrawable drawable,
                               boolean modeChanged,
                               boolean deviceChanged) {
    }

    /*
     * Intersetion tests
     */

    /**
     * Fast Intersection Function between ray/plane
     */
    private boolean TestIntersionPlane(Plane plane, Tuple3d position, Tuple3d direction,
                                       double[] lamda, Tuple3d pNormal) {

        double dotProduct = direction.dot(plane.normal);
        double l2;

        //determine if ray paralle to plane
        if ((dotProduct < EPSILON) && (dotProduct > -EPSILON))
            return false;

        Tuple3d substract = new Tuple3d(plane.position);
        substract.sub(position);
        l2 = (plane.normal.dot(substract)) / dotProduct;

        if (l2 < -EPSILON)
            return false;

        pNormal.set(plane.normal);
        lamda[0] = l2;
        return true;
    }

    /**
     * Fast Intersection Function between ray/cylinder
     */
    private boolean TestIntersionCylinder(Cylinder cylinder, Tuple3d position,
                                          Tuple3d direction, double[] lamda,
                                          Tuple3d pNormal, Tuple3d newposition) {
        Tuple3d RC = new Tuple3d(),
                HB = new Tuple3d(),
                n = new Tuple3d(),
                O = new Tuple3d();
        double d,t,s,
                ln,in,out;

        RC.sub(position, cylinder.position);
        n.cross(direction, cylinder.axis);

        ln = n.length();

        if ((ln < EPSILON) && (ln > -EPSILON))
            return false;

        n.normalize();
        d = Math.abs(RC.dot(n));

        if (d <= cylinder.radius) {

            O.cross(RC, cylinder.axis);
            t = -O.dot(n) / ln;
            O.cross(n, cylinder.axis);
            O.normalize();
            s = Math.abs(Math.sqrt(cylinder.radius * cylinder.radius - d * d) / direction.dot(O));

            in = t - s;
            out = t + s;

            if (in < -EPSILON) {
                if (out < -EPSILON)
                    return false;
                else
                    lamda[0] = out;
            } else if (out < -EPSILON) {
                lamda[0] = in;
            } else if (in < out)
                lamda[0] = in;
            else
                lamda[0] = out;

            newposition.scaleAdd(lamda[0], direction, position);
            HB.sub(newposition, cylinder.position);
            pNormal.scaleAdd(-HB.dot(cylinder.axis), cylinder.axis, HB);
            pNormal.normalize();
            return true;
        }
        return false;
    }

    /**
     * Find if any of the current balls intersect with each other in the current timestep.
     * @return the index of the 2 itersecting balls, the point and time of intersection
     */
    private int findBallCol(Tuple3d point, double[] TimePoint,
                            double[] Time2, int[] BallNr1, int[] BallNr2) {

        Tuple3d RelativeVClone = new Tuple3d(),
                RelativeV = new Tuple3d(),
                posi = new Tuple3d();

        double Timedummy = 10000,
                MyTime = 0,
                Add = Time2[0] / 150;
        TRay rays;

        //Test all balls against eachother in 150 small steps
        for (int i = 0; i < nrOfBalls - 1; i++) {
            for (int j = i + 1; j < nrOfBalls; j++) {

                RelativeV.sub(arrayVel[i], arrayVel[j]);
                RelativeVClone.set(RelativeV);
                RelativeVClone.normalize();
                rays = new TRay(oldPos[i], RelativeVClone);
                MyTime = 0;

                if ((rays.dist(oldPos[j])) > 40)
                    continue;

                while (MyTime < Time2[0]) {

                    MyTime += Add;
                    posi.scaleAdd(MyTime, RelativeV, oldPos[i]);
                    if (posi.distance(oldPos[j]) <= 40) {
                        point.set(posi);
                        if (Timedummy > (MyTime - Add))
                            Timedummy = MyTime - Add;

                        BallNr1[0] = i;
                        BallNr2[0] = j;
                        break;
                    }
                }
            }
        }

        if (Timedummy != 10000) {
            TimePoint[0] = Timedummy;
            return 1;
        }
        return 0;
    }

    private static class Explosion {
        public Tuple3d position = new Tuple3d();
        public float alpha;
        public float scale;
    }

    private static class Cylinder {
        public Tuple3d position;
        public Tuple3d axis;
        public double radius;
    }

    private static class Plane {
        public Tuple3d position;
        public Tuple3d normal;
    }

    private static class TRay {
        public Tuple3d p;                     // Any point on the line
        public Tuple3d v;                     // Direction of the line

        public TRay(Tuple3d p,
                    Tuple3d v) {
            this.p = new Tuple3d(p);
            this.v = new Tuple3d(v);
        }

        public double dist(Tuple3d point) {
            double lambda = v.dot(new Tuple3d(point.x - p.x,
                    point.y - p.y,
                    point.z - p.z));
            Tuple3d point2 = new Tuple3d();
            point2.scaleAdd(lambda, v, p);
            return point.distance(point2);
        }
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
激情图片小说一区| 日韩福利电影在线观看| 日韩欧美成人一区| 538在线一区二区精品国产| 欧美日韩视频在线第一区| 欧美视频在线观看一区| 欧美天堂亚洲电影院在线播放| 欧美在线你懂的| 欧美三区在线视频| 欧美日韩精品系列| 日韩欧美一二三四区| xnxx国产精品| 中文字幕制服丝袜一区二区三区| 亚洲色图.com| 亚洲不卡在线观看| 美女一区二区三区| 国产精品白丝jk黑袜喷水| 成人黄色电影在线| 91久久精品网| 欧美mv日韩mv国产网站| 国产精品污www在线观看| 亚洲三级免费电影| 视频一区二区三区在线| 国产原创一区二区| 99久久精品费精品国产一区二区| 欧美日韩在线综合| 久久久精品人体av艺术| 亚洲另类春色国产| 久久精品国产免费| 一本大道久久精品懂色aⅴ| 欧美日韩一区高清| 国产日韩欧美一区二区三区乱码| 一区二区三区成人| 韩国成人在线视频| 欧美四级电影网| 久久久久久久久久久电影| 亚洲黄色小视频| 精品夜夜嗨av一区二区三区| 91在线你懂得| 日韩欧美国产系列| 亚洲一区在线免费观看| 激情欧美一区二区| 欧美日韩一级二级三级| 日本一二三四高清不卡| 日韩精品电影在线观看| 91性感美女视频| 欧美精品一区二区在线观看| 一区二区理论电影在线观看| 国产久卡久卡久卡久卡视频精品| 欧美视频一区二区在线观看| 国产精品久久久久影视| 国产一区日韩二区欧美三区| 9191精品国产综合久久久久久| 欧美激情一区二区三区四区 | 欧美第一区第二区| 中文字幕日本乱码精品影院| 国产伦精品一区二区三区在线观看 | 国产精品视频你懂的| 奇米色777欧美一区二区| 91高清视频在线| 国产精品久久精品日日| 韩国女主播成人在线| 欧美一二三四区在线| 亚洲成人第一页| 欧美午夜精品免费| 亚洲欧美日韩国产另类专区| 99久久综合色| 国产精品成人免费在线| av在线免费不卡| 国产精品久久久久久久浪潮网站| 丁香天五香天堂综合| 日本一二三不卡| 狠狠色综合播放一区二区| 欧美性一二三区| 亚洲与欧洲av电影| 欧美日韩精品系列| 日韩成人一区二区三区在线观看| 欧洲视频一区二区| 一区二区三区在线免费| 色悠久久久久综合欧美99| 亚洲另类中文字| 在线不卡中文字幕播放| 亚洲少妇中出一区| 国产不卡免费视频| 中文字幕一区二区在线观看| 国产精品一区二区在线观看不卡| 国产欧美一区二区精品仙草咪| 国产精品一区免费视频| 国产精品久久777777| 欧美性生活一区| 人人精品人人爱| 国产亚洲制服色| 99久久精品国产一区| 五月婷婷综合激情| 精品久久一二三区| av在线不卡电影| 日韩电影在线一区二区三区| 欧美精品一卡两卡| 国产精品夜夜爽| 亚洲国产精品一区二区久久恐怖片 | 一区二区三区四区av| 欧美午夜电影网| 国产在线麻豆精品观看| 国产精品理伦片| 欧美一级二级三级蜜桃| 国产成人综合视频| 亚洲国产一区视频| 国产色综合一区| 欧美日韩精品福利| 成人丝袜18视频在线观看| 亚洲国产精品一区二区尤物区| 欧美变态tickling挠脚心| 91亚洲精品久久久蜜桃| 麻豆精品视频在线观看| 亚洲天堂精品在线观看| 日韩精品在线网站| 99综合电影在线视频| 久久成人免费日本黄色| 一区二区在线观看av| 国产亚洲一区二区三区| 777精品伊人久久久久大香线蕉| 国产高清精品在线| 蜜桃一区二区三区在线观看| 亚洲欧美日韩在线不卡| 久久综合色一综合色88| 色悠久久久久综合欧美99| 国产成人亚洲综合a∨婷婷| 午夜精品影院在线观看| 亚洲人成影院在线观看| 久久久久久久久蜜桃| 日韩精品一区二区三区老鸭窝| 欧洲精品在线观看| 91在线播放网址| www..com久久爱| 成人一级片网址| 国产不卡视频在线播放| 国产在线不卡一卡二卡三卡四卡| 亚洲电影激情视频网站| 一区二区三区日韩精品| 亚洲乱码国产乱码精品精的特点| 精品国产免费人成电影在线观看四季| 欧美日韩三级一区| 91福利在线观看| 在线免费观看一区| 日本久久一区二区| 欧美亚洲国产一卡| 欧日韩精品视频| 色诱视频网站一区| 欧美三区在线观看| 欧美男人的天堂一二区| 欧美人与性动xxxx| 在线成人免费观看| 日韩视频123| 精品国产欧美一区二区| 亚洲精品一线二线三线| 国产三级一区二区三区| 国产日本亚洲高清| 亚洲欧美综合在线精品| 亚洲日本在线视频观看| 一区二区三区高清不卡| 亚洲超碰97人人做人人爱| 秋霞午夜av一区二区三区| 久久国产尿小便嘘嘘| 国产精品资源在线看| 成人av综合在线| 欧美亚洲图片小说| 欧美一级搡bbbb搡bbbb| 精品奇米国产一区二区三区| 久久久久久电影| 亚洲欧美日韩在线不卡| 三级不卡在线观看| 国产精品99久久久| 91在线观看视频| 欧美精品在欧美一区二区少妇| 精品久久久久99| 国产精品国产三级国产aⅴ中文| 亚洲靠逼com| 久久成人麻豆午夜电影| 成人高清视频免费观看| 欧美性受xxxx黑人xyx| 久久―日本道色综合久久| 亚洲人成网站在线| 久久精品国产99| 91日韩在线专区| 精品国产三级a在线观看| 国产精品国产三级国产专播品爱网 | 99久久精品国产网站| 欧美日韩三级一区二区| 国产婷婷精品av在线| 亚洲国产欧美在线| 国产精品影视网| 欧美日韩免费一区二区三区视频 | 国产精品久久久久7777按摩| 亚洲va天堂va国产va久| www.在线成人| 日韩免费高清视频| 亚洲国产美国国产综合一区二区| 国产成人h网站| 日韩免费在线观看| 亚洲午夜免费电影|