本文整理汇总了Java中javax.media.j3d.Appearance.setMaterial方法的典型用法代码示例。如果您正苦于以下问题:Java Appearance.setMaterial方法的具体用法?Java Appearance.setMaterial怎么用?Java Appearance.setMaterial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.j3d.Appearance
的用法示例。
在下文中一共展示了Appearance.setMaterial方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create3D
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/** Create 3D geometry. */
@Override
protected void create3D() {
Appearance appear = new Appearance();
material.setCapability(Material.ALLOW_COMPONENT_WRITE);
material.setDiffuseColor(color);
material.setSpecularColor(black);
appear.setMaterial(material);
int flags = Primitive.GEOMETRY_NOT_SHARED | Primitive.ENABLE_GEOMETRY_PICKING | Primitive.GENERATE_NORMALS;
body = new Sphere(radius, flags, appear);
// we must be able to change the pick flag of the agent
body.setCapability(Node.ALLOW_PICKABLE_READ);
body.setCapability(Node.ALLOW_PICKABLE_WRITE);
body.setPickable(true);
body.setCollidable(true);
addChild(body);
// Add bounds for interactions
Bounds bounds = new BoundingSphere(new Point3d(0, 0, 0), radius);
setBounds(bounds);
}
示例2: buildScene
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
@Override
void buildScene(TransformGroup transformGroup) {
transformGroup.addChild(getColorBackground(new Color(.905f, .905f, 0.95f)));
Appearance appearance = new Appearance();
Material mat = new Material();
mat.setAmbientColor(0.5f, 0.5f, 0.5f);
mat.setDiffuseColor(1.0f, 1.0f, 1.0f);
mat.setEmissiveColor(0.0f, 0.0f, 0.0f);
mat.setSpecularColor(1.0f, 1.0f, 1.0f);
mat.setShininess(80.0f);
appearance.setMaterial(mat);
TransparencyAttributes ta = new TransparencyAttributes();
ta.setTransparency(0.5f);
ta.setTransparencyMode(TransparencyAttributes.BLENDED);
appearance.setTransparencyAttributes(ta);
transformGroup.addChild(new Box(0.6f, 0.5f, 0.4f, appearance));
transformGroup.addChild(getPointLight(new Color(1.0f, 1.0f, 1.0f), new Point3f(2.0f, 2.0f, 2.0f)));
transformGroup.addChild(getAmbientLight(new Color(0.1f, 0.1f, 0.1f)));
transformGroup.setTransform(getTransform(new Vector3f(0.3f, 0.3f, 0.3f), 0.75, -1, Math.PI / 4.0d));
}
示例3: create3D
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
void create3D(float size) {
super.create3D(true);
// lamp body
onColor = new Color3f(0.1f, 1f, 1f);
offColor = new Color3f(0.3f, 0.3f, 0.3f);
blinkColor = new Color3f(1f, 0.3f, 0.3f);
Appearance appear = new Appearance();
material = new Material();
material.setAmbientColor(offColor);
material.setDiffuseColor(offColor);
material.setCapability(Material.ALLOW_COMPONENT_WRITE);
material.setSpecularColor(offColor);
material.setColorTarget(Material.DIFFUSE);
appear.setMaterial(material);
Node node = new com.sun.j3d.utils.geometry.Cylinder(size, size, appear);
node.setCollidable(false);
node.setPickable(false);
addChild(node);
}
示例4: create3D
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/** Create 3D geometry. */
@Override
protected void create3D() {
Appearance appear = new Appearance();
material.setDiffuseColor(color);
material.setSpecularColor(black);
appear.setMaterial(material);
int flags = Primitive.GEOMETRY_NOT_SHARED | Primitive.ENABLE_GEOMETRY_PICKING | Primitive.GENERATE_NORMALS;
body = new Sphere(radius, flags, appear);
// we must be able to change the pick flag of the agent
body.setCapability(Node.ALLOW_PICKABLE_READ);
body.setCapability(Node.ALLOW_PICKABLE_WRITE);
body.setPickable(true);
body.setCollidable(true);
addChild(body);
// Add bounds for interactions
Bounds bounds = new BoundingSphere(new Point3d(0, 0, 0), radius);
setBounds(bounds);
}
示例5: makeAppearance
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
private Appearance makeAppearance( Material material, Color4f color, boolean transparent )
{
Appearance appearance = new Appearance();
appearance .setMaterial( material );
appearance .setCapability( Appearance .ALLOW_MATERIAL_READ );
appearance .setCapability( Appearance .ALLOW_MATERIAL_WRITE );
material .setLightingEnable( true );
Color3f justColor = new Color3f( color .x, color.y, color.z );
appearance .setColoringAttributes( new ColoringAttributes( justColor, ColoringAttributes .SHADE_FLAT ) );
if ( transparent || color.w < 1.0f ) {
TransparencyAttributes ta = new TransparencyAttributes();
ta .setTransparencyMode( TransparencyAttributes .BLENDED );
float alpha = transparent? ( PREVIEW_TRANSPARENCY * color.w ) : color.w;
ta .setTransparency( PREVIEW_TRANSPARENCY );
appearance .setTransparencyAttributes( ta );
}
return appearance;
}
示例6: create3D
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
void create3D(float size) {
super.create3D(true);
// lamp body
onColor = new Color3f(0.1f, 1f, 1f);
offColor = new Color3f(0.3f, 0.3f, 0.3f);
blinkColor = new Color3f(1f, 0.3f, 0.3f);
Appearance appear = new Appearance();
material = new Material();
material.setAmbientColor(offColor);
material.setDiffuseColor(offColor);
material.setCapability(Material.ALLOW_COMPONENT_WRITE);
material.setSpecularColor(offColor);
material.setColorTarget(Material.DIFFUSE);
appear.setMaterial(material);
Node node = new com.sun.j3d.utils.geometry.Cylinder(size, size, appear);
node.setCollidable(false);
node.setPickable(false);
addChild(node);
}
示例7: create3D
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/** Create 3D geometry. */
@Override
protected void create3D() {
Appearance appear = new Appearance();
material.setDiffuseColor(color);
material.setSpecularColor(black);
appear.setMaterial(material);
int flags = Primitive.GEOMETRY_NOT_SHARED | Primitive.ENABLE_GEOMETRY_PICKING | Primitive.GENERATE_NORMALS;
body = new Sphere(radius, flags, appear);
// we must be able to change the pick flag of the agent
body.setCapability(Node.ALLOW_PICKABLE_READ);
body.setCapability(Node.ALLOW_PICKABLE_WRITE);
body.setPickable(true);
body.setCollidable(true);
addChild(body);
// Add bounds for interactions
Bounds bounds = new BoundingSphere(new Point3d(0, 0, 0), radius);
setBounds(bounds);
}
示例8: create3D
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/** Create 3D geometry. */
@Override
protected void create3D() {
Appearance appear = new Appearance();
material.setCapability(Material.ALLOW_COMPONENT_WRITE);
material.setDiffuseColor(color);
material.setSpecularColor(black);
appear.setMaterial(material);
int flags = Primitive.GEOMETRY_NOT_SHARED | Primitive.ENABLE_GEOMETRY_PICKING | Primitive.GENERATE_NORMALS;
body = new Sphere(radius, flags, appear);
// we must be able to change the pick flag of the agent
body.setCapability(Node.ALLOW_PICKABLE_READ);
body.setCapability(Node.ALLOW_PICKABLE_WRITE);
body.setPickable(true);
body.setCollidable(true);
addChild(body);
// Add bounds for interactions
Bounds bounds = new BoundingSphere(new Point3d(0, 0, 0), radius);
setBounds(bounds);
}
示例9: createBox
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
private Box createBox() {
// ��
Appearance app = new Appearance();
Material mat = new Material();
mat.setAmbientColor(new Color3f(0.0f, 0.0f, 1.0f));
mat.setSpecularColor(new Color3f(1.0f, 1.0f, 1.0f));
app.setMaterial(mat);
// �����ɂ���
TransparencyAttributes transAttr = new TransparencyAttributes(
TransparencyAttributes.BLENDED, 0.5f);
app.setTransparencyAttributes(transAttr);
Box box = new Box(0.5f, 0.5f, 0.5f, app);
return box;
}
示例10: Floor
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
public Floor() {
floorBG = new BranchGroup();
Appearance app = new Appearance();
// ��
Material mat = new Material();
mat.setAmbientColor(new Color3f(1.0f, 1.0f, 0.0f)); // ���F
mat.setSpecularColor(new Color3f(1.0f, 1.0f, 1.0f));
app.setMaterial(mat);
// �����쐬
Box floor = new Box(10.0f, 0.001f, 10.0f, app);
floorBG.addChild(floor);
}
示例11: Ball
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
public Ball(double x, double y, double z) {
position = new Vector3d(x, y, z);
velocity = new Vector3d(0, 0, 0);
acceleration = new Vector3d(0, -0.01, 0); // �����x�͈��
// �ړ��\
this.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
this.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
app = new Appearance();
Material mat = new Material();
mat.setAmbientColor(new Color3f(0.0f, 0.0f, 1.0f));
mat.setSpecularColor(new Color3f(1.0f, 1.0f, 1.0f));
app.setMaterial(mat);
TransparencyAttributes transAttr = new TransparencyAttributes(
TransparencyAttributes.BLENDED, 0.2f);
app.setTransparencyAttributes(transAttr);
// �{�[����lj�
this.addChild(new Sphere(radius, Sphere.GENERATE_NORMALS, 100, app));
move();
}
示例12: createWallPartShape
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Returns a new wall part shape with no geometry
* and a default appearance with a white material.
*/
private Node createWallPartShape(boolean outline)
{
Shape3D wallShape = new Shape3D();
// Allow wall shape to change its geometry
wallShape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
wallShape.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
wallShape.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
Appearance wallAppearance = new Appearance();
wallShape.setAppearance(wallAppearance);
wallAppearance.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
TransparencyAttributes transparencyAttributes = new TransparencyAttributes();
transparencyAttributes.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
transparencyAttributes.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
wallAppearance.setTransparencyAttributes(transparencyAttributes);
wallAppearance.setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_READ);
RenderingAttributes renderingAttributes = new RenderingAttributes();
renderingAttributes.setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE);
wallAppearance.setRenderingAttributes(renderingAttributes);
if (outline)
{
wallAppearance.setColoringAttributes(Object3DBranch.OUTLINE_COLORING_ATTRIBUTES);
wallAppearance.setPolygonAttributes(Object3DBranch.OUTLINE_POLYGON_ATTRIBUTES);
wallAppearance.setLineAttributes(Object3DBranch.OUTLINE_LINE_ATTRIBUTES);
}
else
{
wallAppearance.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
wallAppearance.setMaterial(DEFAULT_MATERIAL);
wallAppearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
wallAppearance.setCapability(Appearance.ALLOW_TEXTURE_READ);
// Mix texture and wall color
wallAppearance.setTextureAttributes(MODULATE_TEXTURE_ATTRIBUTES);
}
return wallShape;
}
示例13: updateFilledWallSideAppearance
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Sets filled wall side appearance with its color, texture, transparency and visibility.
*/
private void updateFilledWallSideAppearance(final Appearance wallSideAppearance, final HomeTexture wallSideTexture,
boolean waitTextureLoadingEnd, Integer wallSideColor, float shininess)
{
if (wallSideTexture == null)
{
wallSideAppearance.setMaterial(getMaterial(wallSideColor, wallSideColor, shininess));
wallSideAppearance.setTexture(null);
}
else
{
// Update material and texture of wall side
wallSideAppearance.setMaterial(getMaterial(DEFAULT_COLOR, DEFAULT_AMBIENT_COLOR, shininess));
final TextureManager textureManager = TextureManager.getInstance();
textureManager.loadTexture(wallSideTexture.getImage(), wallSideTexture.getAngle(), waitTextureLoadingEnd,
new TextureManager.TextureObserver()
{
public void textureUpdated(Texture texture)
{
wallSideAppearance.setTexture(getHomeTextureClone(texture, home));
}
});
}
// Update wall side transparency
float wallsAlpha = this.home.getEnvironment().getWallsAlpha();
TransparencyAttributes transparencyAttributes = wallSideAppearance.getTransparencyAttributes();
transparencyAttributes.setTransparency(wallsAlpha);
// If walls alpha is equal to zero, turn off transparency to get better results
transparencyAttributes
.setTransparencyMode(wallsAlpha == 0 ? TransparencyAttributes.NONE : TransparencyAttributes.NICEST);
// Update wall side visibility
RenderingAttributes renderingAttributes = wallSideAppearance.getRenderingAttributes();
HomeEnvironment.DrawingMode drawingMode = this.home.getEnvironment().getDrawingMode();
renderingAttributes.setVisible(drawingMode == null || drawingMode == HomeEnvironment.DrawingMode.FILL
|| drawingMode == HomeEnvironment.DrawingMode.FILL_AND_OUTLINE);
}
示例14: getModelBox
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Returns a box that may replace model.
*/
private Node getModelBox(Color color)
{
Material material = new Material();
material.setDiffuseColor(new Color3f(color));
material.setAmbientColor(new Color3f(color.darker()));
Appearance boxAppearance = new Appearance();
boxAppearance.setMaterial(material);
return new Box(0.5f, 0.5f, 0.5f, boxAppearance);
}
示例15: createRoomPartShape
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Returns a new room part shape with no geometry
* and a default appearance with a white material.
*/
private Node createRoomPartShape()
{
Shape3D roomShape = new Shape3D();
// Allow room shape to change its geometry
roomShape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
roomShape.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
roomShape.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
Appearance roomAppearance = new Appearance();
roomShape.setAppearance(roomAppearance);
roomAppearance.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
TransparencyAttributes transparencyAttributes = new TransparencyAttributes();
transparencyAttributes.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
transparencyAttributes.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
roomAppearance.setTransparencyAttributes(transparencyAttributes);
roomAppearance.setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_READ);
RenderingAttributes renderingAttributes = new RenderingAttributes();
renderingAttributes.setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE);
roomAppearance.setRenderingAttributes(renderingAttributes);
roomAppearance.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
roomAppearance.setMaterial(DEFAULT_MATERIAL);
roomAppearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
roomAppearance.setCapability(Appearance.ALLOW_TEXTURE_READ);
// Mix texture and room color
roomAppearance.setTextureAttributes(MODULATE_TEXTURE_ATTRIBUTES);
return roomShape;
}