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

📄 compressionstream.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * Copy vertex data and add it to the end of this stream.     * @param pos position data     * @param stripFlag vertex replacement flag, either RESTART,     * REPLACE_OLDEST, or REPLACE_MIDDLE     */    void addVertex(Point3f pos, int stripFlag) {	stream.add(new CompressionStreamVertex(this, pos,					       (Vector3f)null, (Color3f)null,					       stripFlag, NO_MESH_PUSH)) ;    }    /**     * Copy vertex data and add it to the end of this stream.     * @param pos position data     * @param norm normal data     * @param stripFlag vertex replacement flag, either RESTART,     * REPLACE_OLDEST, or REPLACE_MIDDLE     */    void addVertex(Point3f pos, Vector3f norm, int stripFlag) {	stream.add(new CompressionStreamVertex	    (this, pos, norm, (Color3f)null, stripFlag, NO_MESH_PUSH)) ;    }    /**     * Copy vertex data and add it to the end of this stream.     * @param pos position data     * @param color color data     * @param stripFlag vertex replacement flag, either RESTART,     * REPLACE_OLDEST, or REPLACE_MIDDLE     */    void addVertex(Point3f pos, Color3f color, int stripFlag) {	stream.add(new CompressionStreamVertex	    (this, pos, (Vector3f)null, color, stripFlag, NO_MESH_PUSH)) ;    }    /**     * Copy vertex data and add it to the end of this stream.     * @param pos position data     * @param color color data     * @param stripFlag vertex replacement flag, either RESTART,     * REPLACE_OLDEST, or REPLACE_MIDDLE     */    void addVertex(Point3f pos, Color4f color, int stripFlag) {	stream.add(new CompressionStreamVertex	    (this, pos, (Vector3f)null, color, stripFlag, NO_MESH_PUSH)) ;    }    /**     * Copy vertex data and add it to the end of this stream.     * @param pos position data     * @param norm normal data     * @param color color data     * @param stripFlag vertex replacement flag, either RESTART,     * REPLACE_OLDEST, or REPLACE_MIDDLE     */    void addVertex(Point3f pos, Vector3f norm, Color3f color,			  int stripFlag) {	stream.add(new CompressionStreamVertex	    (this, pos, norm, color, stripFlag, NO_MESH_PUSH)) ;    }    /**     * Copy vertex data and add it to the end of this stream.     * @param pos position data     * @param norm normal data     * @param color color data     * @param stripFlag vertex replacement flag, either RESTART,     * REPLACE_OLDEST, or REPLACE_MIDDLE     */    void addVertex(Point3f pos, Vector3f norm, Color4f color,			  int stripFlag) {	stream.add(new CompressionStreamVertex	    (this, pos, norm, color, stripFlag, NO_MESH_PUSH)) ;    }    /**     * Copy vertex data and add it to the end of this stream.     * @param pos position data     * @param stripFlag vertex replacement flag, either RESTART, REPLACE_OLDEST,     * or REPLACE_MIDDLE     * @param meshFlag if MESH_PUSH the vertex is pushed into the mesh buffer     */    void addVertex(Point3f pos, int stripFlag, int meshFlag) {	stream.add(new CompressionStreamVertex	    (this, pos, (Vector3f)null, (Color3f)null, stripFlag, meshFlag)) ;    }    /**     * Copy vertex data and add it to the end of this stream.     * @param pos position data     * @param norm normal data     * @param stripFlag vertex replacement flag, either RESTART, REPLACE_OLDEST,     * or REPLACE_MIDDLE     * @param meshFlag if MESH_PUSH the vertex is pushed into the mesh buffer     */    void addVertex(Point3f pos, Vector3f norm,			  int stripFlag, int meshFlag) {	stream.add(new CompressionStreamVertex	    (this, pos, norm, (Color3f)null, stripFlag, meshFlag)) ;    }    /**     * Copy vertex data and add it to the end of this stream.     * @param pos position data     * @param color color data     * @param stripFlag vertex replacement flag, either RESTART, REPLACE_OLDEST,     * or REPLACE_MIDDLE     * @param meshFlag if MESH_PUSH the vertex is pushed into the mesh buffer     */    void addVertex(Point3f pos, Color3f color,			  int stripFlag, int meshFlag) {	stream.add(new CompressionStreamVertex	    (this, pos, (Vector3f)null, color, stripFlag, meshFlag)) ;    }    /**     * Copy vertex data and add it to the end of this stream.     * @param pos position data     * @param color color data     * @param stripFlag vertex replacement flag, either RESTART, REPLACE_OLDEST,     * or REPLACE_MIDDLE     * @param meshFlag if MESH_PUSH the vertex is pushed into the mesh buffer     */    void addVertex(Point3f pos, Color4f color,			  int stripFlag, int meshFlag) {	stream.add(new CompressionStreamVertex	    (this, pos, (Vector3f)null, color, stripFlag, meshFlag)) ;    }    /**     * Copy vertex data and add it to the end of this stream.     * @param pos position data     * @param norm normal data     * @param color color data     * @param stripFlag vertex replacement flag, either RESTART, REPLACE_OLDEST,     * or REPLACE_MIDDLE     * @param meshFlag if MESH_PUSH the vertex is pushed into the mesh buffer     */    void addVertex(Point3f pos, Vector3f norm, Color3f color,			  int stripFlag, int meshFlag) {	stream.add(new CompressionStreamVertex	    (this, pos, norm, color, stripFlag, meshFlag)) ;    }    /**     * Copy vertex data and add it to the end of this stream.     * @param pos position data     * @param norm normal data     * @param color color data     * @param stripFlag vertex replacement flag, either RESTART, REPLACE_OLDEST,     * or REPLACE_MIDDLE     * @param meshFlag if MESH_PUSH the vertex is pushed into the mesh buffer     */    void addVertex(Point3f pos, Vector3f norm, Color4f color,			  int stripFlag, int meshFlag) {	stream.add(new CompressionStreamVertex	    (this, pos, norm, color, stripFlag, meshFlag)) ;    }    /**     * Copy vertex data and add it to the end of this stream.     * @param pos position data     * @param norm normal data     * @param color color data, either Color3f or Color4f, determined by     * current vertex format     * @param stripFlag vertex replacement flag, either RESTART, REPLACE_OLDEST,     * or REPLACE_MIDDLE     * @param meshFlag if MESH_PUSH the vertex is pushed into the mesh buffer     */    void addVertex(Point3f pos, Vector3f norm,		   Object color, int stripFlag, int meshFlag) {	if (vertexColor3) 	    stream.add(new CompressionStreamVertex		       (this, pos, norm, (Color3f)color, stripFlag, meshFlag)) ;	else	    stream.add(new CompressionStreamVertex		       (this, pos, norm, (Color4f)color, stripFlag, meshFlag)) ;    }    /**     * Add a mesh buffer reference to this stream.     * @param stripFlag vertex replacement flag, either RESTART, REPLACE_OLDEST,     * or REPLACE_MIDDLE     * @param meshIndex index of vertex to retrieve from the mesh buffer     */    void addMeshReference(int stripFlag, int meshIndex) {	stream.add(new MeshReference(stripFlag, meshIndex)) ;    }    /**     * Copy the given color to the end of this stream and use it as a global     * state change that applies to all subsequent vertices.     */    void addColor(Color3f c3f) {	stream.add(new CompressionStreamColor(this, c3f)) ;    }    /**     * Copy the given color to the end of this stream and use it as a global     * state change that applies to all subsequent vertices.     */    void addColor(Color4f c4f) {	stream.add(new CompressionStreamColor(this, c4f)) ;    }    /**     * Copy the given normal to the end of this stream and use it as a global     * state change that applies to all subsequent vertices.     */    void addNormal(Vector3f n) {	stream.add(new CompressionStreamNormal(this, n)) ;    }    /**     * Add a new position quantization value to the end of this stream that     * will apply to all subsequent vertex positions.     *     * @param value number of bits to quantize each position's X, Y,     * and Z components, ranging from 1 to 16 with a default of 16     */    void addPositionQuantization(int value) {	stream.add(new PositionQuant(value)) ;    }    /**     * Add a new color quantization value to the end of this stream that will     * apply to all subsequent colors.     *     * @param value number of bits to quantize each color's R, G, B, and     * alpha components, ranging from 2 to 16 with a default of 9     */    void addColorQuantization(int value) {	stream.add(new ColorQuant(value)) ;    }    /**     * Add a new normal quantization value to the end of this stream that will     * apply to all subsequent normals.  This value specifies the number of     * bits for each normal's U and V components.     *     * @param value number of bits for quantizing U and V, ranging from 0 to     * 6 with a default of 6     */    void addNormalQuantization(int value) {	stream.add(new NormalQuant(value)) ;    }    /**     * Interface to access GeometryArray vertex components and add them to the     * compression stream.     *      * A processVertex() implementation retrieves vertex components using the     * appropriate access semantics of a particular GeometryArray, and adds     * them to the compression stream.     *      * The implementation always pushes vertices into the mesh buffer unless     * they match ones already there; if they do, it generates mesh buffer     * references instead.  This reduces the number of vertices when     * non-stripped abutting facets are added to the stream.     *      * Note: Level II geometry compression semantics allow the mesh buffer     * normals to be substituted with the value of an immediately     * preceding SetNormal command, but this is unavailable in Level I.     *     * @param index vertex offset from the beginning of its data array     * @param stripFlag RESTART, REPLACE_MIDDLE, or REPLACE_OLDEST     */    private interface GeometryAccessor {	void processVertex(int index, int stripFlag) ;    }    /**     * This class implements the GeometryAccessor interface for geometry     * arrays accessed with by-copy semantics.     */    private class ByCopyGeometry implements GeometryAccessor {	Point3f[] positions = null ;	Vector3f[] normals = null ;	Color3f[] colors3 = null ;	Color4f[] colors4 = null ;	ByCopyGeometry(GeometryArray ga) {	    this(ga, ga.getInitialVertexIndex(), ga.getValidVertexCount()) ;	}	ByCopyGeometry(GeometryArray ga,		       int firstVertex, int validVertexCount) {	    int i ;	    positions = new Point3f[validVertexCount] ;	    for (i = 0 ; i < validVertexCount ; i++)		positions[i] = new Point3f() ;	    ga.getCoordinates(firstVertex, positions) ;	    if (vertexNormals) {		normals = new Vector3f[validVertexCount] ;		for (i = 0 ; i < validVertexCount ; i++)		    normals[i] = new Vector3f() ;		ga.getNormals(firstVertex, normals) ;	    }	    if (vertexColor3) {		colors3 = new Color3f[validVertexCount] ;		for (i = 0 ; i < validVertexCount ; i++)		    colors3[i] = new Color3f() ;		ga.getColors(firstVertex, colors3) ;	    }	    else if (vertexColor4) {		colors4 = new Color4f[validVertexCount] ;		for (i = 0 ; i < validVertexCount ; i++)		    colors4[i] = new Color4f() ;		ga.getColors(firstVertex, colors4) ;	    }	}	public void processVertex(int v, int stripFlag) {	    Point3f p = positions[v] ;	    int r = meshBuffer.getMeshReference(p) ;	    if ((r == meshBuffer.NOT_FOUND) ||		(vertexNormals && noMeshNormalSubstitution &&		 (! normals[v].equals(meshBuffer.getNormal(r))))) {		Vector3f n = vertexNormals? normals[v] : null ;		Object c = vertexColor3? (Object)colors3[v] :		    vertexColor4? (Object)colors4[v] : null ;		addVertex(p, n, c, stripFlag, MESH_PUSH) ;		meshBuffer.push(p, c, n) ;	    }	    else {		if (vertexNormals && !noMeshNormalSubstitution &&		    (! normals[v].equals(meshBuffer.getNormal(r))))		    addNormal(normals[v]) ;		if (vertexColor3 &&		    (! colors3[v].equals(meshBuffer.getColor3(r))))		    addColor(colors3[v]) ;		else if (vertexColor4 &&			 (! colors4[v].equals(meshBuffer.getColor4(r))))		    addColor(colors4[v]) ;		addMeshReference(stripFlag, r) ;	    }	}    }    /**     * Class which holds index array references for a geometry array.     */    private static class IndexArrays {	int colorIndices[] = null ;	int normalIndices[] = null ;	int positionIndices[] = null ;    }    /**     * Retrieves index array references for the specified IndexedGeometryArray.     * Index arrays are copied starting from initialIndexIndex.     */    private void getIndexArrays(GeometryArray ga, IndexArrays ia) {	IndexedGeometryArray iga = (IndexedGeometryArray)ga ;	int initialIndexIndex = iga.getInitialIndexIndex() ;	int indexCount = iga.getValidIndexCount() ;	int vertexFormat = iga.getVertexFormat() ;	boolean useCoordIndexOnly = false ;	if ((vertexFormat & GeometryArray.USE_COORD_INDEX_ONLY) != 0) {	    if (debug) System.out.println("useCoordIndexOnly") ;	    useCoordIndexOnly = true ;	}	ia.positionIndices = new int[indexCount] ;	iga.getCoordinateIndices(initialIndexIndex, ia.positionIndices) ;	if (vertexNormals) {	    if (useCoordIndexOnly) {		ia.normalIndices = ia.positionIndices ;	    }	    else {		ia.normalIndices = new int[indexCount] ;		iga.getNormalIndices(initialIndexIndex, ia.normalIndices) ;	    }	}	if (vertexColor3 || vertexColor4) {	    if (useCoordIndexOnly) {		ia.colorIndices = ia.positionIndices ;	    }	    else {		ia.colorIndices = new int[indexCount] ;		iga.getColorIndices(initialIndexIndex, ia.colorIndices) ;	    }	}    }    /**     * Class which holds indices for a specific vertex of an     * IndexedGeometryArray.      */    private static class VertexIndices {	int pi, ni, ci ;    }    /**     * Retrieves vertex indices for a specific vertex in an     * IndexedGeometryArray.     */    private void getVertexIndices(int v, IndexArrays ia, VertexIndices vi) {	vi.pi = ia.positionIndices[v] ;

⌨️ 快捷键说明

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