当前位置: 首页>>代码示例>>Java>>正文


Java Appearance.getMaterial方法代码示例

本文整理汇总了Java中javax.media.j3d.Appearance.getMaterial方法的典型用法代码示例。如果您正苦于以下问题:Java Appearance.getMaterial方法的具体用法?Java Appearance.getMaterial怎么用?Java Appearance.getMaterial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.media.j3d.Appearance的用法示例。


在下文中一共展示了Appearance.getMaterial方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAppearanceCapabilities

import javax.media.j3d.Appearance; //导入方法依赖的package包/类
private void setAppearanceCapabilities(Appearance appearance)
{
	// Allow future material and rendering attributes changes
	appearance.setCapability(Appearance.ALLOW_MATERIAL_READ);
	appearance.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
	Material material = appearance.getMaterial();
	if (material != null)
	{
		material.setCapability(Material.ALLOW_COMPONENT_READ);
	}
	appearance.setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_READ);
	appearance.setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_WRITE);
	appearance.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_READ);
	appearance.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE);
	appearance.setCapability(Appearance.ALLOW_TEXGEN_READ);
	appearance.setCapability(Appearance.ALLOW_TEXGEN_WRITE);
	appearance.setCapability(Appearance.ALLOW_TEXTURE_READ);
	appearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
	appearance.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_READ);
	appearance.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE);
	appearance.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
	appearance.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE);
	PolygonAttributes polygonAttributes = appearance.getPolygonAttributes();
	if (polygonAttributes != null)
	{
		polygonAttributes.setCapability(PolygonAttributes.ALLOW_CULL_FACE_READ);
		polygonAttributes.setCapability(PolygonAttributes.ALLOW_CULL_FACE_WRITE);
		polygonAttributes.setCapability(PolygonAttributes.ALLOW_NORMAL_FLIP_READ);
		polygonAttributes.setCapability(PolygonAttributes.ALLOW_NORMAL_FLIP_WRITE);
	}
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:32,代码来源:HomePieceOfFurniture3D.java

示例2: DefaultMaterialAndTexture

import javax.media.j3d.Appearance; //导入方法依赖的package包/类
public DefaultMaterialAndTexture(Appearance appearance)
{
	this.material = appearance.getMaterial();
	this.transparencyAttributes = appearance.getTransparencyAttributes();
	this.polygonAttributes = appearance.getPolygonAttributes();
	this.texCoordGeneration = appearance.getTexCoordGeneration();
	this.texture = appearance.getTexture();
	this.textureAttributes = appearance.getTextureAttributes();
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:10,代码来源:HomePieceOfFurniture3D.java

示例3: getMaterial

import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
 * Returns the material stored in the given <code>appearance</code>.
 */
private static OBJMaterial getMaterial(Appearance appearance)
{
	OBJMaterial material = (OBJMaterial) appearance.getMaterial();
	if (material == null)
	{
		material = new OBJMaterial();
		appearance.setMaterial(material);
	}
	return material;
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:14,代码来源:OBJLoader.java

示例4: getMaterials

import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/** 
 * Returns the materials used by the children shapes of the given <code>node</code>.
 */
public HomeMaterial[] getMaterials(Node node)
{
	// Search appearances used by node shapes 
	Set<Appearance> appearances = new HashSet<Appearance>();
	searchMaterials(node, appearances);
	Set<HomeMaterial> materials = new TreeSet<HomeMaterial>(new Comparator<HomeMaterial>()
	{
		public int compare(HomeMaterial m1, HomeMaterial m2)
		{
			String name1 = m1.getName();
			String name2 = m2.getName();
			if (name1 != null)
			{
				if (name2 != null)
				{
					return name1.compareTo(name2);
				}
				else
				{
					return 1;
				}
			}
			else if (name2 != null)
			{
				return -1;
			}
			else
			{
				return 0;
			}
		}
	});
	for (Appearance appearance : appearances)
	{
		Integer color = null;
		Float shininess = null;
		Material material = appearance.getMaterial();
		if (material != null)
		{
			Color3f diffuseColor = new Color3f();
			material.getDiffuseColor(diffuseColor);
			color = 0xFF000000 | ((int) (diffuseColor.x * 255) << 16) | ((int) (diffuseColor.y * 255) << 8)
					| (int) (diffuseColor.z * 255);
			shininess = material.getShininess() / 128;
		}
		Texture appearanceTexture = appearance.getTexture();
		HomeTexture texture = null;
		if (appearanceTexture != null)
		{
			URL textureImageUrl = (URL) appearanceTexture.getUserData();
			if (textureImageUrl != null)
			{
				Content textureImage = new SimpleURLContent(textureImageUrl);
				// Extract image name
				String textureImageName = textureImageUrl.getFile();
				textureImageName = textureImageName.substring(textureImageName.lastIndexOf('/') + 1);
				int lastPoint = textureImageName.lastIndexOf('.');
				if (lastPoint != -1)
				{
					textureImageName = textureImageName.substring(0, lastPoint);
				}
				texture = new HomeTexture(new CatalogTexture(textureImageName, textureImage, -1, -1));
			}
		}
		try
		{
			materials.add(new HomeMaterial(appearance.getName(), color, texture, shininess));
		}
		catch (NoSuchMethodError ex)
		{
			// Don't support HomeMaterial with Java 3D < 1.4 where getName was added
			return new HomeMaterial[0];
		}
	}
	return materials.toArray(new HomeMaterial[materials.size()]);
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:80,代码来源:ModelManager.java


注:本文中的javax.media.j3d.Appearance.getMaterial方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。