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

📄 mesh.java

📁 Jake2是一个Java 3D游戏引擎.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        float[] maxs = Vec3Cache.get();        if (pframe == poldframe) {            for (int i = 0; i < 3; i++) {                mins[i] = pframe.translate[i];                maxs[i] = mins[i] + pframe.scale[i] * 255;            }        } else {            float thismaxs, oldmaxs;            for (int i = 0; i < 3; i++) {                thismaxs = pframe.translate[i] + pframe.scale[i] * 255;                oldmaxs = poldframe.translate[i] + poldframe.scale[i] * 255;                if (pframe.translate[i] < poldframe.translate[i])                    mins[i] = pframe.translate[i];                else                    mins[i] = poldframe.translate[i];                if (thismaxs > oldmaxs)                    maxs[i] = thismaxs;                else                    maxs[i] = oldmaxs;            }        }        /*         * * compute a full bounding box         */        float[] tmp;        for (int i = 0; i < 8; i++) {            tmp = bbox[i];            if ((i & 1) != 0)                tmp[0] = mins[0];            else                tmp[0] = maxs[0];            if ((i & 2) != 0)                tmp[1] = mins[1];            else                tmp[1] = maxs[1];            if ((i & 4) != 0)                tmp[2] = mins[2];            else                tmp[2] = maxs[2];        }        /*         * * rotate the bounding box         */        tmp = mins;        Math3D.VectorCopy(e.angles, tmp);        tmp[YAW] = -tmp[YAW];        Math3D.AngleVectors(tmp, vectors[0], vectors[1], vectors[2]);        for (int i = 0; i < 8; i++) {            Math3D.VectorCopy(bbox[i], tmp);            bbox[i][0] = Math3D.DotProduct(vectors[0], tmp);            bbox[i][1] = -Math3D.DotProduct(vectors[1], tmp);            bbox[i][2] = Math3D.DotProduct(vectors[2], tmp);            Math3D.VectorAdd(e.origin, bbox[i], bbox[i]);        }                Vec3Cache.release(2); // mins, maxs        int f, mask;        int aggregatemask = ~0; // 0xFFFFFFFF        for (int p = 0; p < 8; p++) {            mask = 0;            for (f = 0; f < 4; f++) {                float dp = Math3D.DotProduct(frustum[f].normal, bbox[p]);                if ((dp - frustum[f].dist) < 0) {                    mask |= (1 << f);                }            }            aggregatemask &= mask;        }        if (aggregatemask != 0) {            return true;        }        return false;    }    // bounding box    float[][] bbox = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 },            { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };    /*     * ================= R_DrawAliasModel     *      * =================     */    //	TODO sync with jogl renderer. hoz    void R_DrawAliasModel(entity_t e) {        int i;        //qfiles.dmdl_t paliashdr;        //float an;        image_t skin;        if ((e.flags & Defines.RF_WEAPONMODEL) == 0) {            if (R_CullAliasModel(e))                return;        }        if ((e.flags & Defines.RF_WEAPONMODEL) != 0) {            if (r_lefthand.value == 2.0f)                return;        }        qfiles.dmdl_t paliashdr = (qfiles.dmdl_t) currentmodel.extradata;        //        // get lighting information        //        // PMM - rewrote, reordered to handle new shells & mixing        // PMM - 3.20 code .. replaced with original way of doing it to keep mod        // authors happy        //        if ((currententity.flags & (Defines.RF_SHELL_HALF_DAM                | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_RED                | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE)) != 0) {            Math3D.VectorClear(shadelight);            if ((currententity.flags & Defines.RF_SHELL_HALF_DAM) != 0) {                shadelight[0] = 0.56f;                shadelight[1] = 0.59f;                shadelight[2] = 0.45f;            }            if ((currententity.flags & Defines.RF_SHELL_DOUBLE) != 0) {                shadelight[0] = 0.9f;                shadelight[1] = 0.7f;            }            if ((currententity.flags & Defines.RF_SHELL_RED) != 0)                shadelight[0] = 1.0f;            if ((currententity.flags & Defines.RF_SHELL_GREEN) != 0)                shadelight[1] = 1.0f;            if ((currententity.flags & Defines.RF_SHELL_BLUE) != 0)                shadelight[2] = 1.0f;        }        else if ((currententity.flags & Defines.RF_FULLBRIGHT) != 0) {            for (i = 0; i < 3; i++)                shadelight[i] = 1.0f;        } else {            R_LightPoint(currententity.origin, shadelight);            // player lighting hack for communication back to server            // big hack!            if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0) {                // pick the greatest component, which should be the same                // as the mono value returned by software                if (shadelight[0] > shadelight[1]) {                    if (shadelight[0] > shadelight[2])                        r_lightlevel.value = 150 * shadelight[0];                    else                        r_lightlevel.value = 150 * shadelight[2];                } else {                    if (shadelight[1] > shadelight[2])                        r_lightlevel.value = 150 * shadelight[1];                    else                        r_lightlevel.value = 150 * shadelight[2];                }            }            if (gl_monolightmap.string.charAt(0) != '0') {                float s = shadelight[0];                if (s < shadelight[1])                    s = shadelight[1];                if (s < shadelight[2])                    s = shadelight[2];                shadelight[0] = s;                shadelight[1] = s;                shadelight[2] = s;            }        }        if ((currententity.flags & Defines.RF_MINLIGHT) != 0) {            for (i = 0; i < 3; i++)                if (shadelight[i] > 0.1f)                    break;            if (i == 3) {                shadelight[0] = 0.1f;                shadelight[1] = 0.1f;                shadelight[2] = 0.1f;            }        }        if ((currententity.flags & Defines.RF_GLOW) != 0) { // bonus items will                                                            // pulse with time            float scale;            float min;            scale = (float) (0.1f * Math.sin(r_newrefdef.time * 7));            for (i = 0; i < 3; i++) {                min = shadelight[i] * 0.8f;                shadelight[i] += scale;                if (shadelight[i] < min)                    shadelight[i] = min;            }        }        // =================        // PGM ir goggles color override        if ((r_newrefdef.rdflags & Defines.RDF_IRGOGGLES) != 0                && (currententity.flags & Defines.RF_IR_VISIBLE) != 0) {            shadelight[0] = 1.0f;            shadelight[1] = 0.0f;            shadelight[2] = 0.0f;        }        // PGM        // =================        shadedots = r_avertexnormal_dots[((int) (currententity.angles[1] * (SHADEDOT_QUANT / 360.0)))                & (SHADEDOT_QUANT - 1)];        float an = (float) (currententity.angles[1] / 180 * Math.PI);        shadevector[0] = (float) Math.cos(-an);        shadevector[1] = (float) Math.sin(-an);        shadevector[2] = 1;        Math3D.VectorNormalize(shadevector);        //        // locate the proper data        //        c_alias_polys += paliashdr.num_tris;        //        // draw all the triangles        //        if ((currententity.flags & Defines.RF_DEPTHHACK) != 0)            // hack the depth range to prevent view model from poking into walls            gl.glDepthRange(gldepthmin, gldepthmin + 0.3                    * (gldepthmax - gldepthmin));        if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0                && (r_lefthand.value == 1.0f)) {            gl.glMatrixMode(GL.GL_PROJECTION);            gl.glPushMatrix();            gl.glLoadIdentity();            gl.glScalef(-1, 1, 1);            MYgluPerspective(r_newrefdef.fov_y, (float) r_newrefdef.width                    / r_newrefdef.height, 4, 4096);            gl.glMatrixMode(GL.GL_MODELVIEW);            gl.glCullFace(GL.GL_BACK);        }        gl.glPushMatrix();        e.angles[PITCH] = -e.angles[PITCH]; // sigh.        R_RotateForEntity(e);        e.angles[PITCH] = -e.angles[PITCH]; // sigh.        // select skin        if (currententity.skin != null)            skin = currententity.skin; // custom player skin        else {            if (currententity.skinnum >= qfiles.MAX_MD2SKINS)                skin = currentmodel.skins[0];            else {                skin = currentmodel.skins[currententity.skinnum];                if (skin == null)                    skin = currentmodel.skins[0];            }        }        if (skin == null)            skin = r_notexture; // fallback...        GL_Bind(skin.texnum);        // draw it        gl.glShadeModel(GL.GL_SMOOTH);        GL_TexEnv(GL.GL_MODULATE);        if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) {            gl.glEnable(GL.GL_BLEND);        }        if ((currententity.frame >= paliashdr.num_frames)                || (currententity.frame < 0)) {            VID.Printf(Defines.PRINT_ALL, "R_DrawAliasModel "                    + currentmodel.name + ": no such frame "                    + currententity.frame + '\n');            currententity.frame = 0;            currententity.oldframe = 0;        }        if ((currententity.oldframe >= paliashdr.num_frames)                || (currententity.oldframe < 0)) {            VID.Printf(Defines.PRINT_ALL, "R_DrawAliasModel "                    + currentmodel.name + ": no such oldframe "                    + currententity.oldframe + '\n');            currententity.frame = 0;            currententity.oldframe = 0;        }        if (r_lerpmodels.value == 0.0f)            currententity.backlerp = 0;        GL_DrawAliasFrameLerp(paliashdr, currententity.backlerp);        GL_TexEnv(GL.GL_REPLACE);        gl.glShadeModel(GL.GL_FLAT);        gl.glPopMatrix();        if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0                && (r_lefthand.value == 1.0F)) {            gl.glMatrixMode(GL.GL_PROJECTION);            gl.glPopMatrix();            gl.glMatrixMode(GL.GL_MODELVIEW);            gl.glCullFace(GL.GL_FRONT);        }        if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) {            gl.glDisable(GL.GL_BLEND);        }        if ((currententity.flags & Defines.RF_DEPTHHACK) != 0)            gl.glDepthRange(gldepthmin, gldepthmax);        if (gl_shadows.value != 0.0f                && (currententity.flags & (Defines.RF_TRANSLUCENT | Defines.RF_WEAPONMODEL)) == 0) {            gl.glPushMatrix();            R_RotateForEntity(e);            gl.glDisable(GL.GL_TEXTURE_2D);            gl.glEnable(GL.GL_BLEND);            gl.glColor4f(0, 0, 0, 0.5f);            GL_DrawAliasShadow(paliashdr, currententity.frame);            gl.glEnable(GL.GL_TEXTURE_2D);            gl.glDisable(GL.GL_BLEND);            gl.glPopMatrix();        }        gl.glColor4f(1, 1, 1, 1);    }}

⌨️ 快捷键说明

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