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

📄 material.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * is either DIFFUSE or AMBIENT_AND_DIFFUSE, and vertex colors are     * not being ignored, then the vertex colors are used in place of     * this Material's diffuse color in the lighting equation.     *     * @param r the new diffuse color's red component     * @param g the new diffuse color's green component     * @param b the new diffuse color's blue component     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     *     * @see RenderingAttributes#setIgnoreVertexColors     * @see #setColorTarget     */    public void setDiffuseColor(float r, float g, float b) {	if (isLiveOrCompiled())	  if (!this.getCapability(ALLOW_COMPONENT_WRITE))	    throw new CapabilityNotSetException(J3dI18N.getString("Material0"));	if (isLive()) 	    ((MaterialRetained)this.retained).setDiffuseColor(r,g,b);	else	    ((MaterialRetained)this.retained).initDiffuseColor(r,g,b);    }    /**     * Sets this material's diffuse color plus alpha.     * This is the color of the material when illuminated by a light source.     * The diffuse color in this Material object may be overridden by     * per-vertex colors in some cases.  If vertex colors are present     * in the geometry, and lighting is enabled, and the colorTarget     * is either DIFFUSE or AMBIENT_AND_DIFFUSE, and vertex colors are     * not being ignored, then the vertex colors are used in place of     * this Material's diffuse color in the lighting equation.     *     * @param r the new diffuse color's red component     * @param g the new diffuse color's green component     * @param b the new diffuse color's blue component     * @param a the alpha component used to set transparency     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     *     * @see RenderingAttributes#setIgnoreVertexColors     * @see #setColorTarget     */    public void setDiffuseColor(float r, float g, float b, float a) {	if (isLiveOrCompiled())	  if (!this.getCapability(ALLOW_COMPONENT_WRITE))	    throw new CapabilityNotSetException(J3dI18N.getString("Material0"));	if (isLive()) 	    ((MaterialRetained)this.retained).setDiffuseColor(r,g,b,a);	else	    ((MaterialRetained)this.retained).initDiffuseColor(r,g,b,a);    }    /**     * Retrieves this material's diffuse color.     * @param color the vector that will receive this material's diffuse color     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */    public void getDiffuseColor(Color3f color) {	if (isLiveOrCompiled())	  if (!this.getCapability(ALLOW_COMPONENT_READ))	    throw new CapabilityNotSetException(J3dI18N.getString("Material2"));	((MaterialRetained)this.retained).getDiffuseColor(color);    }    /**     * Sets this material's specular color.     * This is the specular highlight color of the material.     * The specular color in this Material object may be overridden by     * per-vertex colors in some cases.  If vertex colors are present     * in the geometry, and lighting is enabled, and the colorTarget     * is SPECULAR, and vertex colors are     * not being ignored, then the vertex colors are used in place of     * this Material's specular color in the lighting equation.     *     * @param color the new specular color     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     *     * @see RenderingAttributes#setIgnoreVertexColors     * @see #setColorTarget     */    public void setSpecularColor(Color3f color) {	if (isLiveOrCompiled())	  if (!this.getCapability(ALLOW_COMPONENT_WRITE))	    throw new CapabilityNotSetException(J3dI18N.getString("Material0"));	if (isLive()) 	    ((MaterialRetained)this.retained).setSpecularColor(color);	else	    ((MaterialRetained)this.retained).initSpecularColor(color);    }    /**     * Sets this material's specular color.     * This is the specular highlight color of the material.     * The specular color in this Material object may be overridden by     * per-vertex colors in some cases.  If vertex colors are present     * in the geometry, and lighting is enabled, and the colorTarget     * is SPECULAR, and vertex colors are     * not being ignored, then the vertex colors are used in place of     * this Material's specular color in the lighting equation.     *     * @param r the new specular color's red component     * @param g the new specular color's green component     * @param b the new specular color's blue component     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     *     * @see RenderingAttributes#setIgnoreVertexColors     * @see #setColorTarget     */    public void setSpecularColor(float r, float g, float b) {	if (isLiveOrCompiled())	  if (!this.getCapability(ALLOW_COMPONENT_WRITE))	    throw new CapabilityNotSetException(J3dI18N.getString("Material0"));	if (isLive()) 	    ((MaterialRetained)this.retained).setSpecularColor(r,g,b);	else	    ((MaterialRetained)this.retained).initSpecularColor(r,g,b);    }    /**     * Retrieves this material's specular color.     * @param color the vector that will receive this material's specular color     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */    public void getSpecularColor(Color3f color) {	if (isLiveOrCompiled())	  if (!this.getCapability(ALLOW_COMPONENT_READ))	    throw new CapabilityNotSetException(J3dI18N.getString("Material2"));	((MaterialRetained)this.retained).getSpecularColor(color);    }    /**     * Sets this material's shininess.     * This specifies a material specular scattering exponent, or     * shininess.  It takes a floating point number in the range [1.0, 128.0]     * with 1.0 being not shiny and 128.0 being very shiny.     * Values outside this range are clamped.     * @param shininess the material's shininess     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */    public void setShininess(float shininess) {	if (isLiveOrCompiled())	  if (!this.getCapability(ALLOW_COMPONENT_WRITE))	    throw new CapabilityNotSetException(J3dI18N.getString("Material0"));	if (isLive()) 	    ((MaterialRetained)this.retained).setShininess(shininess);	else	    ((MaterialRetained)this.retained).initShininess(shininess);    }    /**     * Retrieves this material's shininess.     * @return the material's shininess     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     */    public float getShininess() {	if (isLiveOrCompiled())	  if (!this.getCapability(ALLOW_COMPONENT_READ))	    throw new CapabilityNotSetException(J3dI18N.getString("Material2"));	return ((MaterialRetained)this.retained).getShininess();    }    /**     * Enables or disables lighting for this appearance component object.     * @param state true or false to enable or disable lighting     * @exception CapabilityNotSetException if appropriate capability is      * not set and this object is part of live or compiled scene graph     */    public void setLightingEnable(boolean state) {	if (isLiveOrCompiled())	  if (!this.getCapability(ALLOW_COMPONENT_WRITE))		throw new CapabilityNotSetException(J3dI18N.getString("Material15"));	if (isLive()) 	    ((MaterialRetained)this.retained).setLightingEnable(state);	else	    ((MaterialRetained)this.retained).initLightingEnable(state);    }    /**     * Retrieves the state of the lighting enable flag.     * @return true if lighting is enabled, false if lighting is disabled     * @exception CapabilityNotSetException if appropriate capability is      * not set and this object is part of live or compiled scene graph     */    public boolean getLightingEnable() {	if (isLiveOrCompiled())	  if (!this.getCapability(ALLOW_COMPONENT_READ))		throw new CapabilityNotSetException(J3dI18N.getString("Material16"));	return ((MaterialRetained)this.retained).getLightingEnable();    }    /**     * Sets the color target for per-vertex colors.  When lighting is     * enabled and per-vertex colors are present (and not ignored) in     * the geometry for a given Shape3D node, those per-vertex colors     * are used in place of the specified material color(s) for this     * Material object.  The color target is ignored when lighting is     * disabled or when per-vertex colors are not used.     * The ColorInterpolator behavior also uses the color target to     * determine which color in the associated Material is modified.     * The default target is DIFFUSE.     *     * @param colorTarget one of: AMBIENT, EMISSIVE, DIFFUSE, SPECULAR, or     * AMBIENT_AND_DIFFUSE.     *     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     *     * @see RenderingAttributes#setIgnoreVertexColors     * @see ColorInterpolator     *     * @since Java 3D 1.3     */    public void setColorTarget(int colorTarget) {	if (isLiveOrCompiled())	  if (!this.getCapability(ALLOW_COMPONENT_WRITE))	    throw new CapabilityNotSetException(J3dI18N.getString("Material3"));	if (isLive()) 	    ((MaterialRetained)this.retained).setColorTarget(colorTarget);	else	    ((MaterialRetained)this.retained).initColorTarget(colorTarget);    }    /**     * Retrieves the current color target for this material.     *     * @return one of: AMBIENT, EMISSIVE, DIFFUSE, SPECULAR, or     * AMBIENT_AND_DIFFUSE.     *     * @exception CapabilityNotSetException if appropriate capability is     * not set and this object is part of live or compiled scene graph     *     * @since Java 3D 1.3     */    public int getColorTarget() {	if (isLiveOrCompiled())	  if (!this.getCapability(ALLOW_COMPONENT_READ))	    throw new CapabilityNotSetException(J3dI18N.getString("Material4"));	return ((MaterialRetained)this.retained).getColorTarget();    }	/**	 * Returns a String representation of this Materials values.	 * If the scene graph is live only those values with their	 * Capability read bit set will be displayed.	 */	public String toString() {		StringBuffer str = new StringBuffer(getNamePrefix());		str.append("javax.media.j3d.Material: ");		Color3f color=new Color3f();		try {			getAmbientColor(color);			str.append("AmbientColor="+color);		} catch (CapabilityNotSetException e) {str.append("AmbientColor=N/A");}		try {			getEmissiveColor(color);			str.append(" EmissiveColor="+color);		} catch (CapabilityNotSetException ex) {str.append(" EmissiveColor=N/A");}		try {			getDiffuseColor(color);			str.append(" DiffuseColor="+color);		} catch (CapabilityNotSetException exc) {str.append(" DiffuseColor=N/A");}		try {			getSpecularColor(color);			str.append(" SpecularColor="+color);		} catch (CapabilityNotSetException exce) {str.append(" SpecularColor=N/A");}		try {			float f=getShininess();			str.append(" Shininess="+f);		} catch (CapabilityNotSetException excep) {str.append(" Shininess=N/A");}		try {			boolean b=getLightingEnable();			str.append(" LightingEnable="+b);		} catch (CapabilityNotSetException except) {str.append(" LightingEnable=N/A");}		try {			int i=getColorTarget();			str.append(" ColorTarget="+i);		} catch (CapabilityNotSetException except) {str.append(" ColorTarget=N/A");}		return new String(str);	}    /**     * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate)       */    public NodeComponent cloneNodeComponent() {        Material m = new Material();        m.duplicateNodeComponent(this);        return m;    }    /**     * Copies all node information from <code>originalNodeComponent</code> into     * the current node.  This method is called from the     * <code>duplicateNode</code> method. This routine does     * the actual duplication of all "local data" (any data defined in     * this object).      *     * @param originalNodeComponent the original node to duplicate.     * @param forceDuplicate when set to <code>true</code>, causes the     *  <code>duplicateOnCloneTree</code> flag to be ignored.  When     *  <code>false</code>, the value of each node's     *  <code>duplicateOnCloneTree</code> variable determines whether     *  NodeComponent data is duplicated or copied.     *     * @see Node#cloneTree     * @see NodeComponent#setDuplicateOnCloneTree     */    void duplicateAttributes(NodeComponent originalNodeComponent,			     boolean forceDuplicate) { 	super.duplicateAttributes(originalNodeComponent, 				  forceDuplicate);		MaterialRetained mat =  (MaterialRetained)	    originalNodeComponent.retained;	MaterialRetained rt =  (MaterialRetained) retained;			Color3f c = new Color3f();	mat.getAmbientColor(c);      	rt.initAmbientColor(c);	mat.getEmissiveColor(c);	rt.initEmissiveColor(c);	mat.getDiffuseColor(c);	rt.initDiffuseColor(c);	mat.getSpecularColor(c);	rt.initSpecularColor(c);	rt.initShininess(mat.getShininess());	rt.initLightingEnable(mat.getLightingEnable());	rt.initColorTarget(mat.getColorTarget());    }}

⌨️ 快捷键说明

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