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

📄 joglpipeline.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                                    }                                } else if ((vformat & GeometryArray.TEXTURE_COORDINATE_3) != 0) {                                    for (int k = 0; k < texCoordSetMapLen; k++) {                                        if (texCoordSetMapOffset[k] != -1) {                                            int off = texCoordoff + texCoordSetMapOffset[k];                                            gl.glMultiTexCoord3f(GL.GL_TEXTURE0 + k,                                                    varray[off],                                                    varray[off + 1],                                                    varray[off + 2]);                                        }                                    }                                } else {                                    for (int k = 0; k < texCoordSetMapLen; k++) {                                        if (texCoordSetMapOffset[k] != -1) {                                            int off = texCoordoff + texCoordSetMapOffset[k];                                            gl.glMultiTexCoord4f(GL.GL_TEXTURE0 + k,                                                    varray[off],                                                    varray[off + 1],                                                    varray[off + 2],                                                    varray[off + 3]);                                        }                                    }                                }                            } else { // no multitexture                                if (texCoordSetMapOffset[0] != -1) {                                    int off = texCoordoff + texCoordSetMapOffset[0];                                    if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) != 0) {                                        gl.glTexCoord2f(varray[off], varray[off + 1]);                                    } else if ((vformat & GeometryArray.TEXTURE_COORDINATE_3) != 0) {                                        gl.glTexCoord3f(varray[off], varray[off + 1], varray[off + 2]);                                    } else {                                        gl.glTexCoord4f(varray[off], varray[off + 1], varray[off + 2], varray[off + 3]);                                    }                                }                            } // no multitexture                        }                        // texCoordSetMapLen can't be 0 if texture coordinates                        // is to be specified                    }                                        if ((vformat & GeometryArray.COORDINATES) != 0) {                        if (xform != null) {                            // transform the vertex data with the static transform                            float w    = (float) (xform[12] * varray[coordoff] +                                    xform[13] * varray[coordoff+1] +                                    xform[14] * varray[coordoff+2] +                                    xform[15]);                            float winv = 1.0f/w;                            float vx = (float) (xform[0] * varray[coordoff] +                                    xform[1] * varray[coordoff+1] +                                    xform[2] * varray[coordoff+2] +                                    xform[3]) * winv;                            float vy = (float) (xform[4] * varray[coordoff] +                                    xform[5] * varray[coordoff+1] +                                    xform[6] * varray[coordoff+2] +                                    xform[7]) * winv;                            float vz = (float) (xform[8] * varray[coordoff] +                                    xform[9] * varray[coordoff+1] +                                    xform[10] * varray[coordoff+2] +                                    xform[11]) * winv;                            gl.glVertex3f(vx, vy, vz);                        } else {                            gl.glVertex3f(varray[coordoff], varray[coordoff + 1], varray[coordoff + 2]);                        }                    }                    normoff += stride;                    coloroff += stride;                    coordoff += stride;                    texCoordoff += stride;                    vAttrOff += stride;                }                gl.glEnd();            }        } else if ((geo_type == GeometryRetained.GEO_TYPE_QUAD_SET) ||                (geo_type == GeometryRetained.GEO_TYPE_TRI_SET) ||                (geo_type == GeometryRetained.GEO_TYPE_POINT_SET) ||                (geo_type == GeometryRetained.GEO_TYPE_LINE_SET)) {            int primType = 0;            switch (geo_type) {                case GeometryRetained.GEO_TYPE_QUAD_SET :                    primType = GL.GL_QUADS;                    break;                case GeometryRetained.GEO_TYPE_TRI_SET :                    primType = GL.GL_TRIANGLES;                    break;                case GeometryRetained.GEO_TYPE_POINT_SET :                    primType = GL.GL_POINTS;                    break;                case GeometryRetained.GEO_TYPE_LINE_SET :                    primType = GL.GL_LINES;                    break;            }                        if (ignoreVertexColors) {                vformat &= ~GeometryArray.COLOR;            }                        gl.glBegin(primType);            for (int j = 0; j < vcount; j++) {                if ((vformat & GeometryArray.NORMALS) != 0) {                    if (nxform != null) {                        float nx = (float) (nxform[0] * varray[normoff] +                                nxform[1] * varray[normoff+1] +                                nxform[2] * varray[normoff+2]);                        float ny = (float) (nxform[4] * varray[normoff] +                                nxform[5] * varray[normoff+1] +                                nxform[6] * varray[normoff+2]);                        float nz = (float) (nxform[8] * varray[normoff] +                                nxform[9] * varray[normoff+1] +                                nxform[10] * varray[normoff+2]);                        gl.glNormal3f(nx, ny, nz);                    } else {                        gl.glNormal3f(varray[normoff], varray[normoff + 1], varray[normoff + 2]);                    }                }                if ((vformat & GeometryArray.COLOR) != 0) {                    if (useAlpha) {                        float cr, cg, cb, ca;                        if ((vformat & GeometryArray.WITH_ALPHA) != 0) {                            cr = varray[coloroff];                            cg = varray[coloroff + 1];                            cb = varray[coloroff + 2];                            ca = varray[coloroff + 3] * alpha;                        } else {                            cr = varray[coloroff];                            cg = varray[coloroff + 1];                            cb = varray[coloroff + 2];                            ca = alpha;                        }                        gl.glColor4f(cr, cg, cb, ca);                    } else {                        if ((vformat & GeometryArray.WITH_ALPHA) != 0) { // alpha is present                            gl.glColor4f(varray[coloroff],                                    varray[coloroff + 1],                                    varray[coloroff + 2],                                    varray[coloroff + 3]);                        } else {                            gl.glColor3f(varray[coloroff],                                    varray[coloroff + 1],                                    varray[coloroff + 2]);                        }                    }                }                                if ((vformat & GeometryArray.VERTEX_ATTRIBUTES) != 0) {                    int vaOff = vAttrOff;                    if (verts == null) {                        verts = FloatBuffer.wrap(varray);                    }                    for (int vaIdx = 0; vaIdx < vertexAttrCount; vaIdx++) {                        switch (vertexAttrSizes[vaIdx]) {                            case 1:                                verts.position(vaOff);                                jctx.vertexAttr1fv(gl, vaIdx, verts);                                break;                            case 2:                                verts.position(vaOff);                                jctx.vertexAttr2fv(gl, vaIdx, verts);                                break;                            case 3:                                verts.position(vaOff);                                jctx.vertexAttr3fv(gl, vaIdx, verts);                                break;                            case 4:                                verts.position(vaOff);                                jctx.vertexAttr4fv(gl, vaIdx, verts);                                break;                        }                                                vaOff += vertexAttrSizes[vaIdx];                    }                }                                if ((vformat & GeometryArray.TEXTURE_COORDINATE) != 0) {                    if (texCoordSetMapLen > 0) {                        if (gl.isExtensionAvailable("GL_VERSION_1_3")) {                            if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) != 0) {                                for (int k = 0; k < texCoordSetMapLen; k++) {                                    if (texCoordSetMapOffset[k] != -1) {                                        int off = texCoordoff + texCoordSetMapOffset[k];                                        gl.glMultiTexCoord2f(GL.GL_TEXTURE0 + k,                                                varray[off],                                                varray[off + 1]);                                    }                                }                            } else if ((vformat & GeometryArray.TEXTURE_COORDINATE_3) != 0) {                                for (int k = 0; k < texCoordSetMapLen; k++) {                                    if (texCoordSetMapOffset[k] != -1) {                                        int off = texCoordoff + texCoordSetMapOffset[k];                                        gl.glMultiTexCoord3f(GL.GL_TEXTURE0 + k,                                                varray[off],                                                varray[off + 1],                                                varray[off + 2]);                                    }                                }                            } else {                                for (int k = 0; k < texCoordSetMapLen; k++) {                                    if (texCoordSetMapOffset[k] != -1) {                                        int off = texCoordoff + texCoordSetMapOffset[k];                                        gl.glMultiTexCoord4f(GL.GL_TEXTURE0 + k,                                                varray[off],                                                varray[off + 1],                                                varray[off + 2],                                                varray[off + 3]);                                    }                                }                            }                        } else { // no multitexture                            if (texCoordSetMapOffset[0] != -1) {                                int off = texCoordoff + texCoordSetMapOffset[0];                                if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) != 0) {                                    gl.glTexCoord2f(varray[off], varray[off + 1]);                                } else if ((vformat & GeometryArray.TEXTURE_COORDINATE_3) != 0) {                                    gl.glTexCoord3f(varray[off], varray[off + 1], varray[off + 2]);                                } else {                                    gl.glTexCoord4f(varray[off], varray[off + 1], varray[off + 2], varray[off + 3]);                                }                            }                        } // no multitexture                    }                    // texCoordSetMapLen can't be 0 if texture coordinates is                    // to be specified                }                                if ((vformat & GeometryArray.COORDINATES) != 0) {                    if (xform != null) {                        // transform the vertex data with the static transform                        float w = (float) (xform[12] * varray[coordoff] +                                xform[13] * varray[coordoff+1] +                                xform[14] * varray[coordoff+2] +                                xform[15]);                        float winv = 1.0f/w;                        float vx = (float) (xform[0] * varray[coordoff] +                                xform[1] * varray[coordoff+1] +                                xform[2] * varray[coordoff+2] +                                xform[3]) * winv;                        float vy = (float) (xform[4] * varray[coordoff] +                                xform[5] * varray[coordoff+1] +                                xform[6] * varray[coordoff+2] +                                xform[7]) * winv;                        float vz = (float) (xform[8] * varray[coordoff] +                                xform[9] * varray[coordoff+1] +                                xform[10] * varray[coordoff+2] +                                xform[11]) * winv;                        gl.glVertex3f(vx, vy, vz);                    } else {                        gl.glVertex3f(varray[coordoff], varray[coordoff + 1], varray[coordoff + 2]);                    }                }                normoff += stride;                coloroff += stride;                coordoff += stride;                texCoordoff += stride;                vAttrOff += stride;            }            gl.glEnd();        }    }        // used to Build Dlist GeometryArray by Reference with java arrays    void buildGAForByRef(Context ctx,            GeometryArrayRetained geo, int geo_type,            boolean isNonUniformScale,  boolean updateAlpha,            float alpha,            boolean ignoreVertexColors,            int vcount,            int vformat,            int vdefined,            int initialCoordIndex, float[] vfcoords, double[] vdcoords,            int initialColorIndex, float[] cfdata, byte[] cbdata,            int initialNormalIndex, float[] ndata,            int vertexAttrCount, int[] vertexAttrSizes,            int[] vertexAttrIndices, float[][] vertexAttrData,            int texCoordMapLength,            int[] tcoordsetmap,            int[] texIndices, int texStride, Object[] texCoords,            double[] xform, double[] nxform) {        if (VERBOSE) System.err.println("JoglPipeline.buildGAForByRef()");                GL gl = context(ctx).getGL();                boolean floatCoordDefined  = ((vdefined & GeometryArrayRetained.COORD_FLOAT)    != 0);        boolean doubleCoordDefined = ((vdefined & GeometryArrayRetained.COORD_DOUBLE)   != 0);        boolean floatColorsDefined = ((vdefined & GeometryArrayRetained.COLOR_FLOAT)    != 0);        boolean byteColorsDefined  = ((vdefined & GeometryArrayRetained.COLOR_BYTE)     != 0);        boolean normalsDefined     = ((vdefined & GeometryArrayRetained.NORMAL_FLOAT)   != 0);        boolean vattrDefined       = ((vdefined & GeometryArrayRetained.VATTR_FLOAT)    != 0);        boolean textureDefined     = ((vdefined & GeometryArrayRetained.TEXCOORD_FLOAT) != 0);                FloatBuffer fverts = null;        DoubleBuffer dverts = null;        FloatBuffer fclrs = null;        ByteBuffer bclrs = null;        FloatBuffer[] texCoordBufs = null;        FloatBuffer norms = null;        FloatBuffer[] vertexAttrBufs = null;        

⌨️ 快捷键说明

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