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

📄 geometrydecompressorshape3d.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * diffuse material colors, then start a new vertex list for the new     * color.  The outputColor() method is never called if colors are bundled     * with each vertex in the compressed buffer.     */    void outputColor(Color4f color) {	if (debug) System.out.println(" outputColor: " + color.toString()) ;	if (vlist.size() > 0) {	    // Construct Shape3D using the current color.	    addShape3D() ;	    // Start a new vertex list for the new color.	    vlist = new GeneralizedVertexList(vlist.vertexFormat,					      FRONTFACE_CCW) ;	}	if (curColor == null) curColor = new Color4f() ;	curColor.set(color) ;    }    /**     * Set the current normal that will be copied to each succeeding vertex     * output by the decompressor.  The per-vertex copy is needed since in     * Java 3D a normal is always associated with a vertex.  This method is     * never called if normals are bundled with each vertex in the compressed     * buffer.     */    void outputNormal(Vector3f normal) {	if (debug) System.out.println(" outputNormal: " + normal.toString()) ;	if ((vlist.vertexFormat & GeometryArray.NORMALS) == 0) {	    if (vlist.size() > 0)		// Construct Shape3D using the current vertex format.		addShape3D() ;			    // Start a new vertex list with the new format.	    vlist = new GeneralizedVertexList		(vlist.vertexFormat|GeometryArray.NORMALS, FRONTFACE_CCW) ;	}	if (curNormal == null) curNormal = new Vector3f() ;	curNormal.set(normal) ;    }    /**     * Create a Shape3D object of the desired type from the current vertex     * list.  Apply the current color, if non-null, as a Material attribute.     */    private void addShape3D() {	Material m = new Material() ;	if (curColor != null) {	    if ((vlist.vertexFormat & GeometryArray.COLOR_4) != GeometryArray.COLOR_4) {		m.setAmbientColor(curColor.x, curColor.y, curColor.z) ;		m.setDiffuseColor(curColor.x, curColor.y, curColor.z) ;	    }	    else {		m.setAmbientColor(curColor.x, curColor.y, curColor.z) ;		m.setDiffuseColor(curColor.x, curColor.y, curColor.z,				  curColor.w) ;	    }	}	if ((vlist.vertexFormat & GeometryArray.NORMALS) == 0)	    m.setLightingEnable(false) ;	else	    m.setLightingEnable(true) ;	Appearance a = new Appearance() ;	a.setMaterial(m) ;	switch(bufferDataType) {	  case TYPE_TRIANGLE:	    switch(triOutputType) {	      case TRI_SET:		TriangleArray ta = vlist.toTriangleArray() ;		if (ta != null)		    shapes.add(new Shape3D(ta, a)) ;		break ;	      case TRI_STRIP_SET:		TriangleStripArray tsa = vlist.toTriangleStripArray() ;		if (tsa != null)		    shapes.add(new Shape3D(tsa, a)) ;		break ;	      case TRI_STRIP_AND_FAN_SET:		GeometryStripArray gsa[] = vlist.toStripAndFanArrays() ;		if (gsa[0] != null)		    shapes.add(new Shape3D(gsa[0], a)) ;		if (gsa[1] != null)		    shapes.add(new Shape3D(gsa[1], a)) ;		break ;	      case TRI_STRIP_AND_TRI_SET:		GeometryArray ga[] = vlist.toStripAndTriangleArrays() ;		if (ga[0] != null)		    shapes.add(new Shape3D(ga[0], a)) ;		if (ga[1] != null)		    shapes.add(new Shape3D(ga[1], a)) ;		break ;	      default:		throw new IllegalArgumentException		    (J3dUtilsI18N.getString("GeometryDecompressorShape3D0")) ;	    } 	    break ;	  case TYPE_LINE:	    LineStripArray lsa = vlist.toLineStripArray() ;	    if (lsa != null)		shapes.add(new Shape3D(lsa, a)) ;	    break ;	  case TYPE_POINT:	    PointArray pa = vlist.toPointArray() ;	    if (pa != null)		shapes.add(new Shape3D(pa, a)) ;	    break ;	  default:	    throw new IllegalArgumentException		(J3dUtilsI18N.getString("GeometryDecompressorShape3D1")) ;	}	if (benchmark  || statistics) {	    origVertexCount += vlist.size() ;	    vertexCount += vlist.vertexCount ;	    stripCount += vlist.stripCount ;	    triangleCount += vlist.triangleCount ;	}    }    private void beginPrint() {	System.out.println("\nGeometryDecompressorShape3D") ;	switch(bufferDataType) {	  case TYPE_TRIANGLE:	    System.out.println(" buffer TYPE_TRIANGLE") ; 	    break ;	  case TYPE_LINE:	    System.out.println(" buffer TYPE_LINE") ;	    break ;	  case TYPE_POINT:	    System.out.println(" buffer TYPE_POINT") ;	    break ;	  default:	    throw new IllegalArgumentException		(J3dUtilsI18N.getString("GeometryDecompressorShape3D1")) ;	}	System.out.print(" buffer data present: coords") ;	if ((dataPresent & CompressedGeometryData.Header.NORMAL_IN_BUFFER) != 0)	    System.out.print(" normals") ;	if ((dataPresent & CompressedGeometryData.Header.COLOR_IN_BUFFER) != 0)	    System.out.print(" colors") ;	if ((dataPresent & CompressedGeometryData.Header.ALPHA_IN_BUFFER) != 0)	    System.out.print(" alpha") ;	System.out.println() ;	stripCount = 0 ;	vertexCount = 0 ;	triangleCount = 0 ;	origVertexCount = 0 ;	startTime = System.currentTimeMillis() ;    }    private void endPrint() {	endTime = System.currentTimeMillis() ;	if (benchmark || statistics)	    printBench() ;	     	if (statistics)	    printStats() ;    }    private void printBench() {	float t = (endTime - startTime) / 1000.0f ;	System.out.println	    (" decompression + strip conversion took " + t + " sec.") ;	switch(bufferDataType) {  	  case TYPE_POINT:	    System.out.println		(" points decompressed: " + vertexCount + "\n" +		 " net decompression rate: " + (vertexCount/t) +		 " points/sec.\n") ;	    break ;	  case TYPE_LINE:	    System.out.println		(" lines decompressed: " + (vertexCount - stripCount) + "\n" +		 " net decompression rate: " + ((vertexCount - stripCount)/t) +		 " lines/sec.\n") ;	    break ;	  case TYPE_TRIANGLE:	    System.out.println		(" triangles decompressed: " +		   (vertexCount - 2*stripCount) + "\n" +		 " net decompression rate: " +		   ((vertexCount - 2*stripCount)/t) + " triangles/sec.\n") ;	    break ;	}    }    private void printStats() {	switch(triOutputType) {	  case TRI_SET:	    System.out.println(" using individual triangle output") ;	    break ;	  case TRI_STRIP_SET:	    System.out.println(" using strip output") ;	    break ;	  case TRI_STRIP_AND_FAN_SET:	    System.out.println(" using strips and fans for output") ;	    break ;	  case TRI_STRIP_AND_TRI_SET:	    System.out.println(" using strips and triangles for output") ;	    break ;	}	System.out.print	    (" number of Shape3D objects: " + shapes.size() +	     "\n number of Shape3D decompressed vertices: ") ;	if (triOutputType == TRI_SET || bufferDataType == TYPE_POINT) {	    System.out.println(vertexCount) ;	}	else if (triOutputType == TRI_STRIP_AND_TRI_SET) {	    System.out.println((vertexCount + triangleCount*3) + 			       "\n number of strips: " + stripCount +			       "\n number of individual triangles: " +			       triangleCount) ;	    if (stripCount > 0) 		System.out.println		    (" vertices/strip: " + (float)vertexCount/stripCount +		     "\n triangles represented in strips: " +		     (vertexCount - 2*stripCount)) ;	}	else {	    System.out.println(vertexCount +			       "\n number of strips: " + stripCount) ;	    if (stripCount > 0) 		System.out.println		    (" vertices/strip: " + (float)vertexCount/stripCount) ;	}	System.out.print(" vertex data present in last Shape3D: coords") ;	if ((vlist.vertexFormat & GeometryArray.NORMALS) != 0)	    System.out.print(" normals") ;        boolean color4 =                (vlist.vertexFormat & GeometryArray.COLOR_4) == GeometryArray.COLOR_4;        boolean color3 = !color4 &&                (vlist.vertexFormat & GeometryArray.COLOR_3) == GeometryArray.COLOR_3;	if (color3 || color4) {	    System.out.print(" colors") ;	    if (color4)		System.out.print(" alpha") ;	}	System.out.println() ;    }}

⌨️ 快捷键说明

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