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

📄 geometryinfo.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	  colors4 = new Color4f[colors.length / 4];	  for (int i = 0 ; i < colors.length / 4 ; i++) {	      colors4[i] =		  new Color4f((float)(colors[i * 4] & 0xff) / 255.0f,			      (float)(colors[i * 4 + 1] & 0xff) / 255.0f,			      (float)(colors[i * 4 + 2] & 0xff) / 255.0f,			      (float)(colors[i * 4 + 3] & 0xff) / 255.0f);	  }      }  } // End of setColors4  /**   * Retrieves a reference to the colors array.  Will be either   * <code>Color3f[]</code> or <code>Color4f[]</code> depending on   * the type of the input data.  Call   * getNumColorComponents() to find out which version is returned.   */  public Object[] getColors()  {      if (colors3 != null) return colors3;      else return colors4;  } // End of getColors  /**   * Returns the number of color data components stored per vertex   * in the current GeometryInfo object (3 for RGB or 4 for RGBA).   * If no colors are currently defined, 0 is returned.   */  public int getNumColorComponents()  {      if (colors3 != null) return 3;      else if (colors4 != null) return 4;      else return 0;  } // End of getNumColorComponents  /**   * Sets the normals array.   * No data copying is done because a reference to   * user data is used.   */  public void setNormals(Vector3f normals[])  {      this.normals = normals;  } // End of setNormals  /**   * Sets the normals array.   * The points are copied into the GeometryInfo object.   */  public void setNormals(float normals[])  {      if (normals == null) this.normals = null;      else {	  this.normals = new Vector3f[normals.length / 3];	  for (int i = 0 ; i < this.normals.length ; i++) {	      this.normals[i] = new Vector3f(normals[i * 3],		      			     normals[i * 3 + 1],		      			     normals[i * 3 + 2]);	  }      }  } // End of setNormals(float[])  /**   * Retrieves a reference to the normal array.   */  public Vector3f[] getNormals()  {      return normals;  } // End of getNormals  /**   * This method is used to specify the number of texture coordinate sets     * and the dimensionality of the texture coordinates.   * The number of texture coordinate sets must be specified to the GeometryInfo   * class before any of the sets are specified. The dimensionality of the    * texture coordinates may be 2, 3, or 4, corresponding to 2D, 3D, or 4D    * texture coordinates respectively.(All sets must have the same    * dimensionality.) The default is zero, 2D texture coordinate sets.    * This method should be called before any texture coordinate sets are    * specified because <b>calling this method will delete all previously   * specified texture coordinate and texture coordinate index arrays</b>    * associated with this GeometryInfo.  For example:    * <blockquote><pre>   *	geomInfo.setTextureCoordinateParams(2, 3);   *	geomInfo.setTextureCoordinates(0, tex0);   *	geomInfo.setTextureCoordinates(1, tex1);   *	geomInfo.setTextureCoordinateParams(1, 2);   *	geomInfo.getTexCoordSetCount();   * </blockquote></pre>   * The second call to <code>setTextureCoordinateParams</code> will erase all    * the texture coordinate arrays, so the subsequent call to <code>   * getTexCoordSetCount</code> will return 1.   * @param numSets The number of texture coordinate sets that will be    * specified for this GeometryInfo object.   * @param dim The dimensionality of the texture coordinates. Has to be 2, 3    * or 4.   * @throws IllegalArgumentException if the dimensionality of the texture    * coordinates is not one of 2, 3 or 4.   */  public void setTextureCoordinateParams(int numSets, int dim)  {      if (dim == 2) {	  texCoordSets = new TexCoord2f[numSets][];      } else if (dim == 3) {	  texCoordSets = new TexCoord3f[numSets][];      } else if (dim == 4) {	  texCoordSets = new TexCoord4f[numSets][];      } else {          throw new IllegalArgumentException(	      J3dUtilsI18N.getString("GeometryInfo9"));      }      texCoordIndexSets = new int[numSets][];      texCoordDim = dim;      texCoordSetCount = numSets;  } // End of setTextureCoordinateParams    /**   * Returns the number of texture coordinate sets in this GeometryInfo.   * This value is set with setTextureCoordinateParams().   * If setTextureCoordinateParams()   * has not been called, 0 is returned unless one of the deprecated   * texture coordinate methods has been called.  Calling one of the   * deprecated texture coordinate methods sets the count to 1.   * The deprecated texture coordinate methods are those that don't   * take texCoordSet as the first parameter.   * @return the number of texture coordinate sets in this   * GeometryInfo.   */  public int getTexCoordSetCount() {      return texCoordSetCount;  }  /**   * Returns the number of texture coordinate components that are stored   * per vertex.  Returns 2 for ST (2D), 3 for STR (3D),   * or 4 for STRQ (4D), aslo known as the "dimensionality" of the   * coordinates.  This value is set with    * setTextureCoordinateParams().  If setTextureCoordinateParams()   * has not been called, 0 is returned unless one of the deprecated   * texture coordinate methods has been called.  Calling one of the   * deprecated texture coordinate methods sets the dimensionality   * explicitly (if you called setTextureCoordinates(Point2f[]) then   * 2 is returned).   * The deprecated texture coordinate methods are those that don't   * take texCoordSet as the first parameter.   */  public int getNumTexCoordComponents()  {      return texCoordDim;  } // End of getNumTexCoordComponents  /**   * Sets the mapping between texture coordinate sets and texture units.   * See the    * <a href="../../../../../javax/media/j3d/GeometryArray.html#texCoordSetMap">   * GeometryArray constructor </a> for further details.   * <p> <b>Note:</b> If the texCoordSetMap is not set, multi-texturing is    * turned off. Only the texture coordinate set at index 0 (if set) will be    * used. Any other sets specified by the GeometryInfo.setTextureCoordinate*    * methods will be ignored.   */  public void setTexCoordSetMap(int map[]) {      texCoordSetMap = map;  }  /**   * Returns a reference to the texture coordinate set map.   * See the    * <a href="../../../../../javax/media/j3d/GeometryArray.html#texCoordSetMap">   * GeometryArray constructor </a> for further details.   */  public int[] getTexCoordSetMap() {      return texCoordSetMap;  }   /**   * Sets the 2D texture coordinates for the specified set.   * No data copying is done - a reference to user data is used.    * @param texCoordSet The texture coordinate set for which these    * coordinates are being specified.   * @param texCoords Array of 2D texture coordinates.   * @throws IllegalArgumentException if <code>texCoordSet </code> < 0 or   * <code>texCoordSet >= texCoordSetCount</code>,   * or the texture coordinate parameters were not previously set by   * calling <code>setTextureCoordinateParams(texCoordSetCount, 2)</code>.   */  public void setTextureCoordinates(int texCoordSet, TexCoord2f texCoords[])  {      if (texCoordDim != 2)	  throw new IllegalArgumentException(		  J3dUtilsI18N.getString("GeometryInfo15"));      if ((texCoordSet >= texCoordSetCount) || (texCoordSet < 0))	  throw new IllegalArgumentException(		  J3dUtilsI18N.getString("GeometryInfo18"));      texCoordSets[texCoordSet] = texCoords;  } // End of setTextureCoordinates(int, TexCoord3f[])     /**   * Sets the TextureCoordinates array by copying the data   * into the GeometryInfo object.   * This method sets the number of texture coordinate sets to 1,   * sets the dimensionality of the texture coordinates to 2,   * and sets the coordinates for texture coordinate set 0.   * @deprecated As of Java 3D 1.3 replaced by    * <code>setTextureCoordinates(int texCoordSet, TexCoord2f coords[])</code>   */  public void setTextureCoordinates(Point2f texCoords[])  {      texCoordSetCount = 1;      texCoordDim = 2;      texCoordSets = new TexCoord2f[1][];      if (texCoords != null) {	TexCoord2f[] tex = new TexCoord2f[texCoords.length];	for (int i = 0 ; i < texCoords.length ; i++) 	    tex[i] = new TexCoord2f(texCoords[i]);	texCoordSets[0] = tex;      }  } // End of setTextureCoordinates(Point2f[])   /**   * Sets the texture coordinates array for the specified set.   * No data copying is done - a reference to user data is used.    * @param texCoordSet The texture coordinate set for which these coordinates    * are being specified.   * @param texCoords Array of 3D texture coordinates.   * @throws IllegalArgumentException if <code> texCoordSet </code> < 0 or   * <code>texCoordSet >= texCoordSetCount</code>,   * or the texture coordinate parameters were not previously set by   * calling <code>setTextureCoordinateParams(texCoordSetCount, 3)</code>.   */  public void setTextureCoordinates(int texCoordSet, TexCoord3f texCoords[])  {      if (texCoordDim != 3)	  throw new IllegalArgumentException(		  J3dUtilsI18N.getString("GeometryInfo16"));      if ((texCoordSet >= texCoordSetCount) || (texCoordSet < 0))	  throw new IllegalArgumentException(		  J3dUtilsI18N.getString("GeometryInfo18"));            texCoordSets[texCoordSet] = texCoords;  } // End of setTextureCoordinates(int, TexCoord3f[])  /**   * Sets the TextureCoordinates array by copying the data   * into the GeometryInfo object.   * This method sets the number of texture coordinate sets to 1,   * sets the dimensionality of the texture coordinates to 3,   * and sets the coordinates for texture coordinate set 0.   * @deprecated As of Java 3D 1.3 replaced by    * <code>setTextureCoordinates(int texCoordSet, TexCoord3f coords[])</code>   */  public void setTextureCoordinates(Point3f texCoords[])  {      texCoordSetCount = 1;      texCoordDim = 3;      texCoordSets = new TexCoord3f[1][];      if (texCoords != null) {	TexCoord3f[] tex = new TexCoord3f[texCoords.length];	for (int i = 0 ; i < texCoords.length ; i++) 	    tex[i] = new TexCoord3f(texCoords[i]);	texCoordSets[0] = tex;      }  } // End of setTextureCoordinates(Point3f[])   /**   * Sets the texture coordinates array for the specified set.   * No data copying is done - a reference to user data is used.    * @param texCoordSet The texture coordinate set for which these coordinates    * are being specified.   * @param texCoords Array of 4D texture coordinates.   * @throws IllegalArgumentException if <code> texCoordSet </code> < 0 or   * <code>texCoordSet >= texCoordSetCount</code>,   * or the texture coordinate parameters were not previously set by   * calling <code>setTextureCoordinateParams(texCoordSetCount, 4)</code>.   */  public void setTextureCoordinates(int texCoordSet, TexCoord4f texCoords[]) {      if (texCoordDim != 4)	  throw new IllegalArgumentException(		  J3dUtilsI18N.getString("GeometryInfo17"));      if ((texCoordSet >= texCoordSetCount) || (texCoordSet < 0))	  throw new IllegalArgumentException(		  J3dUtilsI18N.getString("GeometryInfo18"));            texCoordSets[texCoordSet] = texCoords;  } // End of setTextureCoordinates(int, TexCoord4f[])   /**   * Sets the texture coordinates array by copying the data into the   * GeometryInfo object.  The number of sets and dimensionality of   * the sets must have been set previously with    * setTextureCoordinateParams(texCoordSetCount, dim).   * @param texCoordSet The texture coordinate set for which these coordinates    * are being specified.   * @param texCoords The float array of texture coordinates. For n texture    * coordinates with dimensionality d, there must be d*n floats in the array.   * @throws IllegalArgumentException if <code>texCoordSet </code> < 0 or   * <code>texCoordSet >= texCoordSetCount</code>,   * or the texture coordinate parameters were not previously set by   * calling <code>setTextureCoordinateParams</code>.   */  public void setTextureCoordinates(int texCoordSet, float texCoords[])  {      if ((texCoords.length % texCoordDim) != 0)	  throw new IllegalArgumentException(		  J3dUtilsI18N.getString("GeometryInfo2"));            // Copy the texCoords into this GeometryInfo object      if (texCoordDim == 2) {	TexCoord2f tcoords[] = new TexCoord2f[texCoords.length / 2];	for (int i = 0 ; i < tcoords.length ; i++) 	    tcoords[i] = new TexCoord2f(texCoords[i * 2],					texCoords[i * 2 + 1]);	setTextureCoordinates(texCoordSet, tcoords);      } else if (texCoordDim == 3) {	TexCoord3f tcoords[] = new TexCoord3f[texCoords.length / 3];	for (int i = 0 ; i < tcoords.length ; i++) 	    tcoords[i] = new TexCoord3f(texCoords[i * 3],					texCoords[i * 3 + 1],					texCoords[i * 3 + 2]);	setTextureCoordinates(texCoordSet, tcoords);      } else if (texCoordDim == 4) {	TexCoord4f tcoords[] = new TexCoord4f[texCoords.length / 4];	for (int i = 0 ; i < tcoords.length ; i++) 	    tcoords[i] = new TexCoord4f(texCoords[i * 4],					texCoords[i * 4 + 1],					texCoords[i * 4 + 2],					texCoords[i * 4 + 3]);	setTextureCoordinates(texCoordSet, tcoords);      } else {	  throw new IllegalArgumentException(		  J3dUtilsI18N.getString("GeometryInfo21"));      }  } // End of setTextureCoordinates(int, float[])  /**   * Sets the texture coordinates array by copying the data   * into the GeometryInfo object, assuming two numbers   * (S and T) per vertex.   * This method sets the number of texture coordinate sets to 1,   * sets the dimensionality of the texture coordinates to 2,   * and sets the coordinates for texture coordinate set 0.   * @deprecated As of Java 3D 1.3 replaced by    * <code>setTextureCoordinates(int texCoordSet, float texCoords[])</code>   */  public void setTextureCoordinates2(float texCoords[])  {      texCoordSetCount = 1;      texCoordDim = 2;

⌨️ 快捷键说明

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