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

📄 joglpipeline.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        // Get vertex attribute arrays        if (vattrDefined) {            vertexAttrBufs = getVertexAttrSetBuffer(vertexAttrData);        }                // get texture arrays        if (textureDefined) {            texCoordBufs = getTexCoordSetBuffer(texCoords);        }                // process alpha for geometryArray without alpha        boolean useAlpha = false;        if (updateAlpha && !ignoreVertexColors) {            useAlpha = true;        }                int[] sarray = null;        int[] start_array = null;        int strip_len = 0;        if (geo_type == GeometryRetained.GEO_TYPE_TRI_STRIP_SET ||                geo_type == GeometryRetained.GEO_TYPE_TRI_FAN_SET   ||                geo_type == GeometryRetained.GEO_TYPE_LINE_STRIP_SET) {            sarray = ((GeometryStripArrayRetained) geo).stripVertexCounts;            strip_len = sarray.length;            start_array = ((GeometryStripArrayRetained) geo).stripStartOffsetIndices;        }                if (ignoreVertexColors) {            vformat &= ~GeometryArray.COLOR;            floatColorsDefined = false;            byteColorsDefined = false;        }                // get coordinate array        if (floatCoordDefined) {            gl.glEnableClientState(GL.GL_VERTEX_ARRAY);            fverts = getVertexArrayBuffer(vfcoords, (xform == null));            if (xform != null) {                // Must copy in and transform data                for (int i = initialCoordIndex; i < vcount * 3; i += 3) {                    fverts.put(i  , (float) (xform[0]  * vfcoords[i] +                            xform[1]  * vfcoords[i+1] +                            xform[2]  * vfcoords[i+2]));                    fverts.put(i+1, (float) (xform[4]  * vfcoords[i] +                            xform[5]  * vfcoords[i+1] +                            xform[6]  * vfcoords[i+2]));                    fverts.put(i+2, (float) (xform[8]  * vfcoords[i] +                            xform[9]  * vfcoords[i+1] +                            xform[10] * vfcoords[i+2]));                }            }        } else if (doubleCoordDefined) {            gl.glEnableClientState(GL.GL_VERTEX_ARRAY);            dverts = getVertexArrayBuffer(vdcoords, (xform == null));            if (xform != null) {                // Must copy in and transform data                for (int i = initialCoordIndex; i < vcount * 3; i += 3) {                    dverts.put(i  , (xform[0]  * vdcoords[i] +                            xform[1]  * vdcoords[i+1] +                            xform[2]  * vdcoords[i+2]));                    dverts.put(i+1, (xform[4]  * vdcoords[i] +                            xform[5]  * vdcoords[i+1] +                            xform[6]  * vdcoords[i+2]));                    dverts.put(i+2, (xform[8]  * vdcoords[i] +                            xform[9]  * vdcoords[i+1] +                            xform[10] * vdcoords[i+2]));                }            }        } else {            gl.glDisableClientState(GL.GL_VERTEX_ARRAY);        }                // get color array        if (floatColorsDefined) {            gl.glEnableClientState(GL.GL_COLOR_ARRAY);            fclrs = getColorArrayBuffer(cfdata, !useAlpha);            if (useAlpha) {                // Must copy in and modify color data                if ((vformat & GeometryArray.WITH_ALPHA) != 0) {                    for (int i = initialColorIndex; i < vcount * 4; i += 4) {                        fclrs.put(i  , cfdata[i]);                        fclrs.put(i+1, cfdata[i+1]);                        fclrs.put(i+2, cfdata[i+2]);                        fclrs.put(i+3, alpha * cfdata[i+3]);                    }                } else {                    int k = 0;                    for (int i = initialColorIndex; i < vcount * 4; i += 4) {                        fclrs.put(i  , cfdata[k++]);                        fclrs.put(i+1, cfdata[k++]);                        fclrs.put(i+2, cfdata[k++]);                        fclrs.put(i+3, alpha);                    }                }                vformat |= GeometryArray.WITH_ALPHA;            }        } else if (byteColorsDefined) {            gl.glEnableClientState(GL.GL_COLOR_ARRAY);            bclrs = getColorArrayBuffer(cbdata, !useAlpha);            if (useAlpha) {                // Must copy in and modify color data                if ((vformat & GeometryArray.WITH_ALPHA) != 0) {                    for (int i = initialColorIndex; i < vcount * 4; i += 4) {                        bclrs.put(i  , cbdata[i]);                        bclrs.put(i+1, cbdata[i+1]);                        bclrs.put(i+2, cbdata[i+2]);                        bclrs.put(i+3, (byte) (alpha * (int) (cbdata[i+3] & 0xFF)));                    }                } else {                    int k = 0;                    for (int i = initialColorIndex; i < vcount * 4; i += 4) {                        bclrs.put(i  , cbdata[k++]);                        bclrs.put(i+1, cbdata[k++]);                        bclrs.put(i+2, cbdata[k++]);                        bclrs.put(i+3, (byte) (alpha * 255.0f));                    }                }                vformat |= GeometryArray.WITH_ALPHA;            }        } else {            gl.glDisableClientState(GL.GL_COLOR_ARRAY);        }                // get normal array        if (normalsDefined) {            gl.glEnableClientState(GL.GL_NORMAL_ARRAY);            norms = getNormalArrayBuffer(ndata, (nxform == null));            if (nxform != null) {                // Must copy in and transform data                for (int i = initialNormalIndex; i < vcount * 3; i += 3) {                    norms.put(i  , (float) (nxform[0]  * ndata[i] +                            nxform[1]  * ndata[i+1] +                            nxform[2]  * ndata[i+2]));                    norms.put(i+1, (float) (nxform[4]  * ndata[i] +                            nxform[5]  * ndata[i+1] +                            nxform[6]  * ndata[i+2]));                    norms.put(i+2, (float) (nxform[8]  * ndata[i] +                            nxform[9]  * ndata[i+1] +                            nxform[10] * ndata[i+2]));                }            }        } else {            gl.glDisableClientState(GL.GL_NORMAL_ARRAY);        }                executeGeometryArrayVA(ctx, geo, geo_type,                isNonUniformScale, ignoreVertexColors,                vcount, vformat, vdefined,                initialCoordIndex, fverts, dverts,                initialColorIndex, fclrs, bclrs,                initialNormalIndex, norms,                vertexAttrCount, vertexAttrSizes,                vertexAttrIndices, vertexAttrBufs,                texCoordMapLength,                tcoordsetmap, texCoordMapLength,                texIndices, texStride, texCoordBufs, 0,                sarray, strip_len, start_array);    }        //----------------------------------------------------------------------    // Private helper methods for GeometryArrayRetained    //        private void            testForInterleavedArrays(int vformat,            boolean[] useInterleavedArrays,            int[] iaFormat) {        if (VERBOSE) System.err.println("JoglPipeline.testForInterleavedArrays()");        useInterleavedArrays[0] = true;        switch (vformat) {            case GeometryArray.COORDINATES :                iaFormat[0] = GL.GL_V3F; break;            case (GeometryArray.COORDINATES | GeometryArray.NORMALS) :                iaFormat[0] = GL.GL_N3F_V3F; break;            case (GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2) :                iaFormat[0] = GL.GL_T2F_V3F; break;            case (GeometryArray.COORDINATES | GeometryArray.NORMALS | GeometryArray.COLOR) :            case (GeometryArray.COORDINATES | GeometryArray.NORMALS | GeometryArray.COLOR | GeometryArray.WITH_ALPHA) :                iaFormat[0] = GL.GL_C4F_N3F_V3F; break;            case (GeometryArray.COORDINATES | GeometryArray.NORMALS | GeometryArray.TEXTURE_COORDINATE_2) :                iaFormat[0] = GL.GL_T2F_N3F_V3F; break;            case (GeometryArray.COORDINATES | GeometryArray.NORMALS | GeometryArray.COLOR | GeometryArray.TEXTURE_COORDINATE_2):            case (GeometryArray.COORDINATES | GeometryArray.NORMALS | GeometryArray.COLOR | GeometryArray.WITH_ALPHA | GeometryArray.TEXTURE_COORDINATE_2):                iaFormat[0] = GL.GL_T2F_C4F_N3F_V3F; break;            default:                useInterleavedArrays[0] = false; break;        }    }        private void            enableTexCoordPointer(GL gl,            int texUnit,            int texSize,            int texDataType,            int stride,            Buffer pointer) {        if (VERBOSE) System.err.println("JoglPipeline.enableTexCoordPointer()");        clientActiveTextureUnit(gl, texUnit);        gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);        gl.glTexCoordPointer(texSize, texDataType, stride, pointer);    }        private void            disableTexCoordPointer(GL gl,            int texUnit) {        if (VERBOSE) System.err.println("JoglPipeline.disableTexCoordPointer()");        clientActiveTextureUnit(gl, texUnit);        gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);    }        private void            clientActiveTextureUnit(GL gl,            int texUnit) {        if (VERBOSE) System.err.println("JoglPipeline.clientActiveTextureUnit()");        if (gl.isExtensionAvailable("GL_VERSION_1_3")) {            gl.glClientActiveTexture(texUnit + GL.GL_TEXTURE0);        }    }            private void            executeTexture(int texCoordSetMapLen,            int texSize, int bstride, int texCoordoff,            int[] texCoordSetMapOffset,            int numActiveTexUnit,            FloatBuffer verts, GL gl) {        if (VERBOSE) System.err.println("JoglPipeline.executeTexture()");        int tus = 0;  /* texture unit state index */                for (int i = 0; i < numActiveTexUnit; i++) {                        tus = i;                  /*       * it's possible thattexture unit state index (tus)       * is greater than the texCoordSetMapOffsetLen, in this       * case, just disable TexCoordPointer.       */            if ((tus < texCoordSetMapLen) &&                    (texCoordSetMapOffset[tus] != -1)) {                if (EXTRA_DEBUGGING) {                    System.err.println("  texCoord position " + i + ": " + (texCoordoff + texCoordSetMapOffset[tus]));                }                verts.position(texCoordoff + texCoordSetMapOffset[tus]);                enableTexCoordPointer(gl, i,                        texSize, GL.GL_FLOAT, bstride,                        verts);            } else {                disableTexCoordPointer(gl, i);            }        }    }        private void            resetTexture(GL gl, JoglContext ctx) {        if (VERBOSE) System.err.println("JoglPipeline.resetTexture()");        /* Disable texture coordinate arrays for all texture units */        for (int i = 0; i < ctx.getMaxTexCoordSets(); i++) {            disableTexCoordPointer(gl, i);        }        /* Reset client active texture unit to 0 */        clientActiveTextureUnit(gl, 0);    }        private void            executeGeometryArray(Context absCtx,            GeometryArrayRetained geo, int geo_type,            boolean isNonUniformScale,            boolean useAlpha,            boolean ignoreVertexColors,            int startVIndex, int vcount, int vformat,            int texCoordSetCount, int[] texCoordSetMap,            int texCoordSetMapLen,            int[] texCoordSetMapOffset,            int numActiveTexUnitState,            int vertexAttrCount, int[] vertexAttrSizes,            float[] varray, Buffer varrayBuffer,            float[] carray, int cDirty) {        if (VERBOSE) System.err.println("JoglPipeline.executeGeometryArray()");        JoglContext ctx = (JoglContext) absCtx;        GLContext context = context(ctx);        GL gl = context.getGL();                boolean useInterleavedArrays;        int iaFormat = 0;        int primType = 0;        int stride = 0, coordoff = 0, normoff = 0, coloroff = 0, texCoordoff = 0;        int texSize = 0, texStride = 0;        int vAttrOff = 0;        int vAttrStride = 0;        int bstride = 0, cbstride = 0;        FloatBuffer verts = null;        FloatBuffer clrs  = null;        int[] sarray = null;        int[] start_array = null;                if (EXTRA_DEBUGGING) {

⌨️ 快捷键说明

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