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

📄 compressionstream.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	if (vertexNormals)	    vi.ni = ia.normalIndices[v] ;	if (vertexColors)	    vi.ci = ia.colorIndices[v] ;    }    /**     * This class implements the GeometryAccessor interface for indexed     * geometry arrays accessed with by-copy semantics.     */    private class IndexedByCopyGeometry extends ByCopyGeometry {	IndexArrays ia = new IndexArrays() ;	VertexIndices vi = new VertexIndices() ;	IndexedByCopyGeometry(GeometryArray ga) {	    super(ga, 0, ga.getVertexCount()) ;	    getIndexArrays(ga, ia) ;	}	public void processVertex(int v, int stripFlag) {	    getVertexIndices(v, ia, vi) ;	    int r = meshBuffer.getMeshReference(vi.pi) ;	    if ((r == meshBuffer.NOT_FOUND) ||		(vertexNormals && noMeshNormalSubstitution &&		 (vi.ni != meshBuffer.getNormalIndex(r)))) {		Point3f p = positions[vi.pi] ;		Vector3f n = vertexNormals? normals[vi.ni] : null ;		Object c = vertexColor3? (Object)colors3[vi.ci] :		    vertexColor4? (Object)colors4[vi.ci] : null ;		addVertex(p, n, c, stripFlag, MESH_PUSH) ;		meshBuffer.push(vi.pi, vi.ci, vi.ni) ;	    }	    else {		if (vertexNormals && !noMeshNormalSubstitution &&		    vi.ni != meshBuffer.getNormalIndex(r))		    addNormal(normals[vi.ni]) ;		if (vertexColor3 && vi.ci != meshBuffer.getColorIndex(r))		    addColor(colors3[vi.ci]) ;					else if (vertexColor4 && vi.ci != meshBuffer.getColorIndex(r))		    addColor(colors4[vi.ci]) ;		addMeshReference(stripFlag, r) ;	    }	}    }    //    // NOTE: For now, copies are made of all GeometryArray vertex components    // even when by-reference access is available.      //    private static class VertexCopy {	Object c = null ;	Point3f p = null ;	Vector3f n = null ;	Color3f c3 = null ;	Color4f c4 = null ;    }    private void processVertexCopy(VertexCopy vc, int stripFlag) {	int r = meshBuffer.getMeshReference(vc.p) ;	if ((r == meshBuffer.NOT_FOUND) ||	    (vertexNormals && noMeshNormalSubstitution &&	     (! vc.n.equals(meshBuffer.getNormal(r))))) {	    addVertex(vc.p, vc.n, vc.c, stripFlag, MESH_PUSH) ;	    meshBuffer.push(vc.p, vc.c, vc.n) ;	}	else {	    if (vertexNormals && !noMeshNormalSubstitution &&		(! vc.n.equals(meshBuffer.getNormal(r))))		addNormal(vc.n) ;			    if (vertexColor3 && (! vc.c3.equals(meshBuffer.getColor3(r))))		addColor(vc.c3) ;	    else if (vertexColor4 && (! vc.c4.equals(meshBuffer.getColor4(r))))		addColor(vc.c4) ;	    addMeshReference(stripFlag, r) ;	}    }    private void processIndexedVertexCopy(VertexCopy vc,					  VertexIndices vi,					  int stripFlag) {	int r = meshBuffer.getMeshReference(vi.pi) ;	if ((r == meshBuffer.NOT_FOUND) ||	    (vertexNormals && noMeshNormalSubstitution &&	     (vi.ni != meshBuffer.getNormalIndex(r)))) {	    addVertex(vc.p, vc.n, vc.c, stripFlag, MESH_PUSH) ;	    meshBuffer.push(vi.pi, vi.ci, vi.ni) ;	}	else {	    if (vertexNormals && !noMeshNormalSubstitution &&		vi.ni != meshBuffer.getNormalIndex(r))		addNormal(vc.n) ;	    if (vertexColor3 && vi.ci != meshBuffer.getColorIndex(r))		addColor(vc.c3) ;				    else if (vertexColor4 && vi.ci != meshBuffer.getColorIndex(r))		addColor(vc.c4) ;	    addMeshReference(stripFlag, r) ;	}    }    /**     * This abstract class implements the GeometryAccessor interface for     * concrete subclasses which handle float and NIO interleaved geometry     * arrays.     */    private abstract class InterleavedGeometry implements GeometryAccessor {	VertexCopy vc = new VertexCopy() ;	int vstride = 0 ;	int coffset = 0 ;	int noffset = 0 ;	int poffset = 0 ;	int tstride = 0 ;	int tcount = 0 ;	InterleavedGeometry(GeometryArray ga) {	    if (vertexTextures) {		if (vertexTexture2) tstride = 2 ;		else if (vertexTexture3) tstride = 3 ;		else if (vertexTexture4) tstride = 4 ;		tcount = ga.getTexCoordSetCount() ;		vstride += tcount * tstride ;	    }	    if (vertexColors) {		coffset = vstride ;		if (vertexColor3) vstride += 3 ;		else vstride += 4 ;	    }	    if (vertexNormals) {		noffset = vstride ;		vstride += 3 ;	    }	    poffset = vstride ;	    vstride += 3 ;	}	abstract void copyVertex(int pi, int ni, int ci, VertexCopy vc) ;	public void processVertex(int v, int stripFlag) {	    copyVertex(v, v, v, vc) ;	    processVertexCopy(vc, stripFlag) ;	}    }    /**     * This class implements the GeometryAccessor interface for float     * interleaved geometry arrays.     */    private class InterleavedGeometryFloat extends InterleavedGeometry {	float[] vdata = null ;		InterleavedGeometryFloat(GeometryArray ga) {	    super(ga) ;	    vdata = ga.getInterleavedVertices() ;	}	void copyVertex(int pi, int ni, int ci, VertexCopy vc) {	    int voffset ;	    voffset = pi * vstride ;	    vc.p = new Point3f(vdata[voffset + poffset + 0],			       vdata[voffset + poffset + 1],			       vdata[voffset + poffset + 2]) ;	    if (vertexNormals) {		voffset = ni * vstride ;		vc.n = new Vector3f(vdata[voffset + noffset + 0],				    vdata[voffset + noffset + 1],				    vdata[voffset + noffset + 2]) ;	    }	    if (vertexColor3) {		voffset = ci * vstride ;		vc.c3 = new Color3f(vdata[voffset + coffset + 0],				    vdata[voffset + coffset + 1],				    vdata[voffset + coffset + 2]) ;		vc.c = vc.c3 ;	    }	    else if (vertexColor4) {		voffset = ci * vstride ;		vc.c4 = new Color4f(vdata[voffset + coffset + 0],				    vdata[voffset + coffset + 1],				    vdata[voffset + coffset + 2],				    vdata[voffset + coffset + 3]) ;		vc.c = vc.c4 ;	    }	}    }    /**     * This class implements the GeometryAccessor interface for indexed     * interleaved geometry arrays.     */    private class IndexedInterleavedGeometryFloat	extends InterleavedGeometryFloat {	IndexArrays ia = new IndexArrays() ;	VertexIndices vi = new VertexIndices() ;	IndexedInterleavedGeometryFloat(GeometryArray ga) {	    super(ga) ;	    getIndexArrays(ga, ia) ;	}	public void processVertex(int v, int stripFlag) {	    getVertexIndices(v, ia, vi) ;	    copyVertex(vi.pi, vi.ni, vi.ci, vc) ;	    processIndexedVertexCopy(vc, vi, stripFlag) ;	}    }    /**     * This class implements the GeometryAccessor interface for      * interleaved NIO geometry arrays.     */    private class InterleavedGeometryNIO extends InterleavedGeometry {	FloatBufferWrapper fbw = null ;	InterleavedGeometryNIO(GeometryArray ga) {	    super(ga) ;	    J3DBuffer buffer = ga.getInterleavedVertexBuffer() ;	    if (BufferWrapper.getBufferType(buffer) ==		BufferWrapper.TYPE_FLOAT) {		fbw = new FloatBufferWrapper(buffer) ;	    }	    else {		throw new IllegalArgumentException		    ("\ninterleaved vertex buffer must be FloatBuffer") ;	    }	}	void copyVertex(int pi, int ni, int ci, VertexCopy vc) {	    int voffset ;	    voffset = pi * vstride ;	    vc.p = new Point3f(fbw.get(voffset + poffset + 0),			       fbw.get(voffset + poffset + 1),			       fbw.get(voffset + poffset + 2)) ;	    if (vertexNormals) {		voffset = ni * vstride ;		vc.n = new Vector3f(fbw.get(voffset + noffset + 0),				    fbw.get(voffset + noffset + 1),				    fbw.get(voffset + noffset + 2)) ;	    }	    if (vertexColor3) {		voffset = ci * vstride ;		vc.c3 = new Color3f(fbw.get(voffset + coffset + 0),				    fbw.get(voffset + coffset + 1),				    fbw.get(voffset + coffset + 2)) ;		vc.c = vc.c3 ;	    }	    else if (vertexColor4) {		voffset = ci * vstride ;		vc.c4 = new Color4f(fbw.get(voffset + coffset + 0),				    fbw.get(voffset + coffset + 1),				    fbw.get(voffset + coffset + 2),				    fbw.get(voffset + coffset + 3)) ;		vc.c = vc.c4 ;	    }	}    }    /**     * This class implements the GeometryAccessor interface for indexed     * interleaved NIO geometry arrays.     */    private class IndexedInterleavedGeometryNIO extends InterleavedGeometryNIO {	IndexArrays ia = new IndexArrays() ;	VertexIndices vi = new VertexIndices() ;	IndexedInterleavedGeometryNIO(GeometryArray ga) {	    super(ga) ;	    getIndexArrays(ga, ia) ;	}	public void processVertex(int v, int stripFlag) {	    getVertexIndices(v, ia, vi) ;	    copyVertex(vi.pi, vi.ni, vi.ci, vc) ;	    processIndexedVertexCopy(vc, vi, stripFlag) ;	}    }    /**     * This class implements the GeometryAccessor interface for     * non-interleaved geometry arrays accessed with by-reference semantics.     */    private class ByRefGeometry implements GeometryAccessor {	VertexCopy vc = new VertexCopy() ;	byte[]   colorsB    = null ;	float[]  colorsF    = null ;	float[]  normals    = null ;	float[]  positionsF = null ;	double[] positionsD = null ;	int initialPositionIndex = 0 ;	int initialNormalIndex   = 0 ;	int initialColorIndex    = 0 ;	ByRefGeometry(GeometryArray ga) {	    positionsF = ga.getCoordRefFloat() ;	    if (debug && positionsF != null)		System.out.println("float positions") ;	    positionsD = ga.getCoordRefDouble() ;	    if (debug && positionsD != null)		System.out.println("double positions") ;	    if (positionsF == null && positionsD == null)		throw new UnsupportedOperationException		    ("\nby-reference access to Point3{d,f} arrays") ;	    initialPositionIndex = ga.getInitialCoordIndex() ;	    if (vertexColors) {		colorsB = ga.getColorRefByte() ;		if (debug && colorsB != null)		    System.out.println("byte colors") ;		colorsF = ga.getColorRefFloat() ;		if (debug && colorsF != null)		    System.out.println("float colors") ;		if (colorsB == null && colorsF == null)		    throw new UnsupportedOperationException			("\nby-reference access to Color{3b,3f,4b,4f} arrays") ;		initialColorIndex = ga.getInitialColorIndex() ;	    }	    if (vertexNormals) {		normals = ga.getNormalRefFloat() ;		if (debug && normals != null)		    System.out.println("float normals") ;		if (normals == null)		    throw new UnsupportedOperationException			("\nby-reference access to Normal3f array") ;				initialNormalIndex = ga.getInitialNormalIndex() ;	    }	}	void copyVertex(int pi, int ni, int ci, VertexCopy vc) {	    pi *= 3 ;	    if (positionsF != null) {		vc.p = new Point3f(positionsF[pi + 0],				   positionsF[pi + 1],				   positionsF[pi + 2]) ;	    }	    else {		vc.p = new Point3f((float)positionsD[pi + 0],				   (float)positionsD[pi + 1],				   (float)positionsD[pi + 2]) ;	    }	    ni *= 3 ;	    if (vertexNormals) {		vc.n = new Vector3f(normals[ni + 0],				    normals[ni + 1],				    normals[ni + 2]) ;	    }	    if (vertexColor3) {		ci *= 3 ;		if (colorsB != null) {		    vc.c3 = new Color3f			((colorsB[ci + 0] & 0xff) * ByteToFloatScale,			 (colorsB[ci + 1] & 0xff) * ByteToFloatScale,			 (colorsB[ci + 2] & 0xff) * ByteToFloatScale) ;		}		else {		    vc.c3 = new Color3f(colorsF[ci + 0],					colorsF[ci + 1],					colorsF[ci + 2]) ;		}		vc.c = vc.c3 ;	    }	    else if (vertexColor4) {		ci *= 4 ;		if (colorsB != null) {		    vc.c4 = new Color4f			((colorsB[ci + 0] & 0xff) * ByteToFloatScale,			 (colorsB[ci + 1] & 0xff) * ByteToFloatScale,			 (colorsB[ci + 2] & 0xff) * ByteToFloatScale,			 (colorsB[ci + 3] & 0xff) * ByteToFloatScale) ;		}		else {		    vc.c4 = new Color4f(colorsF[ci + 0],					colorsF[ci + 1],					colorsF[ci + 2],					colorsF[ci + 3]) ;		}		vc.c = vc.c4 ;	    }	}

⌨️ 快捷键说明

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