本文整理汇总了Java中javax.media.j3d.Appearance.setCapability方法的典型用法代码示例。如果您正苦于以下问题:Java Appearance.setCapability方法的具体用法?Java Appearance.setCapability怎么用?Java Appearance.setCapability使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.j3d.Appearance
的用法示例。
在下文中一共展示了Appearance.setCapability方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: DebugVector
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
public DebugVector( Point3f location , Vector3f extent , Color3f color )
{
ColoringAttributes ca = new ColoringAttributes( );
ca.setCapability( ColoringAttributes.ALLOW_COLOR_WRITE );
RenderingAttributes ra = new RenderingAttributes( );
ra.setCapability( RenderingAttributes.ALLOW_VISIBLE_WRITE );
TransparencyAttributes ta = new TransparencyAttributes( );
ta.setTransparency( 0.3f );
Appearance app = new Appearance( );
app.setColoringAttributes( ca );
app.setCapability( Appearance.ALLOW_COLORING_ATTRIBUTES_READ );
app.setRenderingAttributes( ra );
app.setCapability( Appearance.ALLOW_RENDERING_ATTRIBUTES_READ );
shape.setAppearance( app );
shape.setCapability( Shape3D.ALLOW_APPEARANCE_READ );
shape.setCapability( Shape3D.ALLOW_GEOMETRY_WRITE );
setVector( location , extent );
setColor( color );
addChild( shape );
}
示例3: 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;
}
示例4: createBackgroundNode
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Returns a new background node.
*/
private Node createBackgroundNode(boolean listenToHomeUpdates, final boolean waitForLoading)
{
final Appearance backgroundAppearance = new Appearance();
ColoringAttributes backgroundColoringAttributes = new ColoringAttributes();
backgroundAppearance.setColoringAttributes(backgroundColoringAttributes);
// Allow background color and texture to change
backgroundAppearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
backgroundAppearance.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ);
backgroundColoringAttributes.setCapability(ColoringAttributes.ALLOW_COLOR_WRITE);
Geometry halfSphereGeometry = createHalfSphereGeometry(true);
final Shape3D halfSphere = new Shape3D(halfSphereGeometry, backgroundAppearance);
BranchGroup backgroundBranch = new BranchGroup();
backgroundBranch.addChild(halfSphere);
backgroundBranch.addChild(new Shape3D(createHalfSphereGeometry(false)));
final Background background = new Background(backgroundBranch);
updateBackgroundColorAndTexture(backgroundAppearance, this.home, waitForLoading);
background.setImageScaleMode(Background.SCALE_FIT_ALL);
background.setApplicationBounds(new BoundingBox(new Point3d(-1E7, -1E7, -1E7), new Point3d(1E7, 1E7, 1E7)));
if (listenToHomeUpdates)
{
// Add a listener on sky color and texture properties change
this.skyColorListener = new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent ev)
{
updateBackgroundColorAndTexture(backgroundAppearance, home, waitForLoading);
}
};
this.home.getEnvironment().addPropertyChangeListener(HomeEnvironment.Property.SKY_COLOR,
this.skyColorListener);
this.home.getEnvironment().addPropertyChangeListener(HomeEnvironment.Property.SKY_TEXTURE,
this.skyColorListener);
}
return background;
}
示例5: Ground3D
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Creates a 3D ground for the given <code>home</code>.
*/
public Ground3D(Home home, float originX, float originY, float width, float depth, boolean waitTextureLoadingEnd)
{
setUserData(home);
this.originX = originX;
this.originY = originY;
this.width = width;
this.depth = depth;
Appearance groundAppearance = new Appearance();
groundAppearance.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
groundAppearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
TextureAttributes textureAttributes = new TextureAttributes();
textureAttributes.setTextureMode(TextureAttributes.MODULATE);
groundAppearance.setTextureAttributes(textureAttributes);
groundAppearance.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
TransparencyAttributes transparencyAttributes = new TransparencyAttributes();
transparencyAttributes.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
groundAppearance.setTransparencyAttributes(transparencyAttributes);
final Shape3D groundShape = new Shape3D();
groundShape.setAppearance(groundAppearance);
groundShape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
groundShape.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
groundShape.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
setCapability(ALLOW_CHILDREN_READ);
addChild(groundShape);
update(waitTextureLoadingEnd);
}
示例6: 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;
}
示例7: setOutlineAppearance
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Sets the outline appearance on all the children of <code>node</code>.
*/
private void setOutlineAppearance(Node node)
{
if (node instanceof Group)
{
Enumeration<?> enumeration = ((Group) node).getAllChildren();
while (enumeration.hasMoreElements())
{
setOutlineAppearance((Node) enumeration.nextElement());
}
}
else if (node instanceof Link)
{
setOutlineAppearance(((Link) node).getSharedGroup());
}
else if (node instanceof Shape3D)
{
Appearance outlineAppearance = new Appearance();
((Shape3D) node).setAppearance(outlineAppearance);
outlineAppearance.setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_READ);
RenderingAttributes renderingAttributes = new RenderingAttributes();
renderingAttributes.setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE);
outlineAppearance.setRenderingAttributes(renderingAttributes);
outlineAppearance.setColoringAttributes(Object3DBranch.OUTLINE_COLORING_ATTRIBUTES);
outlineAppearance.setPolygonAttributes(Object3DBranch.OUTLINE_POLYGON_ATTRIBUTES);
outlineAppearance.setLineAttributes(Object3DBranch.OUTLINE_LINE_ATTRIBUTES);
}
}
示例8: 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);
}
}
示例9: SlicePlane3DRenderer
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
public SlicePlane3DRenderer(View view, Context context, Volume vol)
{
super(view, context, vol);
texVol = new Texture3DVolume(context, vol);
TransparencyAttributes transAttr = new TransparencyAttributes();
transAttr.setTransparencyMode(TransparencyAttributes.BLENDED);
texAttr = new TextureAttributes();
texAttr.setTextureMode(TextureAttributes.MODULATE);
texAttr.setCapability(TextureAttributes.ALLOW_COLOR_TABLE_WRITE);
Material m = new Material();
m.setLightingEnable(false);
PolygonAttributes p = new PolygonAttributes();
p.setCullFace(PolygonAttributes.CULL_NONE);
p.setPolygonOffset(1.0f);
p.setPolygonOffsetFactor(1.0f);
appearance = new Appearance();
appearance.setMaterial(m);
appearance.setTextureAttributes(texAttr);
appearance.setTransparencyAttributes(transAttr);
appearance.setPolygonAttributes(p);
appearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
appearance.setCapability(Appearance.ALLOW_TEXGEN_WRITE);
shape = new Shape3D(null, appearance);
shape.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
shape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
root.addChild(shape);
}
示例10: Cylinder
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* creates a cylinder with center endcap at p1 and center endcap at p2
*
* @param p1
* @param p2
*/
public Cylinder( float radius , Point3f p1 , Point3f p2 , TransformComputer3f tc , Color3f color )
{
length = p1.distance( p2 );
if( length == 0 )
{
throw new IllegalArgumentException( "Points must be different!" );
}
this.radius = radius;
m_tc = tc;
// the extra tacked on is ONLY for the bore model ...needs to go elsewhere
m_primative = new com.sun.j3d.utils.geometry.Cylinder( 1 , 1 );
Appearance appearance = new Appearance( );
Material mat = new Material( );
mat.setAmbientColor( color );
mat.setDiffuseColor( color );
mat.setSpecularColor( color );
// mat.setShininess(1.0f);
appearance.setMaterial( mat );
appearance.setCapability( Appearance.ALLOW_MATERIAL_WRITE );
m_primative.setAppearance( appearance );
m_primative.setCapability( com.sun.j3d.utils.geometry.Cylinder.ENABLE_APPEARANCE_MODIFY );
this.setCapability( BranchGroup.ALLOW_DETACH );
m_transformGroup.addChild( m_primative );
m_transformGroup.setCapability( Group.ALLOW_CHILDREN_EXTEND );
m_transformGroup.setCapability( Group.ALLOW_CHILDREN_READ );
m_transformGroup.setCapability( Group.ALLOW_CHILDREN_WRITE );
m_transformGroup.setCapability( TransformGroup.ALLOW_TRANSFORM_WRITE );
setEndpoints( p1 , p2 );
}
示例11: genereApparence
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Permet de créer l'apparence en fonction de paramètres Dans le cadre d'un
* ponctuel, certains paramètres n'ont aucun sens
*
* @param isColored
* @param color
* @param coefOpacity
* @param isRepresentationSolid
* @return l'apparence à appliquer
*/
private Appearance genereApparence(Color color, double coefOpacity) {
Color3f col3f = new Color3f(color);
// Création de l'apparence
Appearance apparenceFinale = new Appearance();
// Autorisations pour l'apparence
apparenceFinale.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_READ);
apparenceFinale.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE);
// Autorisations pour le material
apparenceFinale.setCapability(Appearance.ALLOW_MATERIAL_READ);
apparenceFinale.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
apparenceFinale.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ);
apparenceFinale.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
// Création du material (gestion des couleurs et de l'affichage)
Material material = new Material();
material.setAmbientColor(0.2f, 0.2f, 0.2f);
material.setDiffuseColor(col3f);
material.setSpecularColor(col3f);
material.setShininess(128);
// et de material
apparenceFinale.setMaterial(material);
if (coefOpacity != 1) {
TransparencyAttributes t_attr =
new TransparencyAttributes(TransparencyAttributes.BLENDED,
(float) coefOpacity,
TransparencyAttributes.BLEND_SRC_ALPHA,
TransparencyAttributes.BLENDED);
// et de transparence
apparenceFinale.setTransparencyAttributes(t_attr);
}
return apparenceFinale;
}
示例12: generateAppearance
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Génère l'apparence à appliquer à la géométrie
*
* @param isClrd
* @param color
* @param coefOpacity
* @param isSolid
* @return
*/
private Appearance generateAppearance(boolean isClrd, Color color,
double coefOpacity, boolean isSolid) {
// Création de l'apparence
Appearance apparenceFinale = new Appearance();
// Autorisations pour l'apparence
apparenceFinale.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_READ);
apparenceFinale.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE);
// Autorisations pour le material
apparenceFinale.setCapability(Appearance.ALLOW_MATERIAL_READ);
apparenceFinale.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
// Création des attributs du polygone
PolygonAttributes pa = new PolygonAttributes();
pa.setCullFace(PolygonAttributes.CULL_NONE);
pa.setCapability(PolygonAttributes.ALLOW_CULL_FACE_WRITE);
if (isSolid) {
// Indique que l'on est en mode surfacique
pa.setPolygonMode(PolygonAttributes.POLYGON_FILL);
// Indique que l'on n'affiche pas les faces cachées
if (ConstantRepresentation.cullMode) {
pa.setCullFace(PolygonAttributes.CULL_BACK);
}
} else {
// Indique que l'on est en mode filaire
pa.setPolygonMode(PolygonAttributes.POLYGON_LINE);
}
pa.setCullFace(PolygonAttributes.CULL_NONE);
pa.setBackFaceNormalFlip(false);
// Association à l'apparence des attributs de géométrie et de material
apparenceFinale.setPolygonAttributes(pa);
if (isClrd) {
Color3f couleur3F = new Color3f(color);
// Création du material (gestion des couleurs et de l'affichage)
Material material = new Material();
material.setAmbientColor(couleur3F);
material.setDiffuseColor(couleur3F);
material.setEmissiveColor(couleur3F);
material.setLightingEnable(true);
material.setSpecularColor(couleur3F);
material.setShininess(1);
apparenceFinale.setMaterial(material);
}
if (coefOpacity != 1) {
TransparencyAttributes t_attr =
new TransparencyAttributes(TransparencyAttributes.FASTEST,
(float) (1 - coefOpacity));
apparenceFinale.setTransparencyAttributes(t_attr);
}
return apparenceFinale;
}
示例13: generateAppearance
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Génère l'apparence à appliquer à la géométrie
*
* @param isClrd
* @param color
* @param coefOpacity
* @param isSolid
* @return
*/
private Appearance generateAppearance(boolean isClrd, Color color,
double coefOpacity, boolean isSolid) {
// Création de l'apparence
Appearance apparenceFinale = new Appearance();
// Autorisations pour l'apparence
apparenceFinale.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_READ);
apparenceFinale.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE);
// Autorisations pour le material
apparenceFinale.setCapability(Appearance.ALLOW_MATERIAL_READ);
apparenceFinale.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
// Création des attributs du polygone
PolygonAttributes pa = new PolygonAttributes();
pa.setCullFace(PolygonAttributes.CULL_NONE);
pa.setCapability(PolygonAttributes.ALLOW_CULL_FACE_WRITE);
if (isSolid) {
// Indique que l'on est en mode surfacique
pa.setPolygonMode(PolygonAttributes.POLYGON_FILL);
// Indique que l'on n'affiche pas les faces cachées
} else {
// Indique que l'on est en mode filaire
pa.setPolygonMode(PolygonAttributes.POLYGON_LINE);
}
pa.setBackFaceNormalFlip(false);
// Association à l'apparence des attributs de géométrie et de material
apparenceFinale.setPolygonAttributes(pa);
if (isClrd) {
Color3f couleur3F = new Color3f(color);
// Création du material (gestion des couleurs et de l'affichage)
Material material = new Material();
material.setAmbientColor(couleur3F);
material.setDiffuseColor(couleur3F);
material.setSpecularColor(couleur3F);
material.setEmissiveColor(couleur3F);
material.setShininess(1);
apparenceFinale.setMaterial(material);
}
if (coefOpacity != 1) {
TransparencyAttributes t_attr = new TransparencyAttributes(
TransparencyAttributes.BLENDED, (float) coefOpacity,
TransparencyAttributes.BLEND_SRC_ALPHA,
TransparencyAttributes.BLENDED);
apparenceFinale.setTransparencyAttributes(t_attr);
}
return apparenceFinale;
}
示例14: generateAppearance
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Génère l'apparence à appliquer à la géométrie
*
* @param isClrd
* @param color
* @param coefTransp
* @param isSolid
* @return
*/
private Appearance generateAppearance(boolean isClrd, Color color,
double coefTransp, boolean isSolid) {
// Création de l'apparence
Appearance apparenceFinale = new Appearance();
// Autorisations pour l'apparence
apparenceFinale.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_READ);
apparenceFinale.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE);
// Autorisations pour le material
apparenceFinale.setCapability(Appearance.ALLOW_MATERIAL_READ);
apparenceFinale.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
// Création des attributs du polygone
PolygonAttributes pa = new PolygonAttributes();
pa.setCullFace(PolygonAttributes.CULL_NONE);
pa.setCapability(PolygonAttributes.ALLOW_CULL_FACE_WRITE);
if (isSolid) {
// Indique que l'on est en mode surfacique
pa.setPolygonMode(PolygonAttributes.POLYGON_FILL);
// Indique que l'on n'affiche pas les faces cachées
if (ConstantRepresentation.cullMode) {
pa.setCullFace(PolygonAttributes.CULL_BACK);
}
} else {
// Indique que l'on est en mode filaire
pa.setPolygonMode(PolygonAttributes.POLYGON_LINE);
}
pa.setBackFaceNormalFlip(false);
// Association à l'apparence des attributs de géométrie et de material
apparenceFinale.setPolygonAttributes(pa);
if (isClrd) {
Color3f couleur3F = new Color3f(color);
// Création du material (gestion des couleurs et de l'affichage)
Material material = new Material();
material.setDiffuseColor(couleur3F);
material.setSpecularColor(new Color3f(color.brighter()));
material.setAmbientColor(new Color3f(color.darker()));
material.setEmissiveColor(new Color3f(color.darker()));
material.setShininess(128);
apparenceFinale.setMaterial(material);
}
if (coefTransp != 1) {
TransparencyAttributes t_attr = new TransparencyAttributes(
TransparencyAttributes.BLENDED, (float) coefTransp,
TransparencyAttributes.BLEND_SRC_ALPHA,
TransparencyAttributes.BLENDED);
apparenceFinale.setTransparencyAttributes(t_attr);
}
return apparenceFinale;
}
示例15: initBGSel
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Permet de créer un BranchGroup contenant une sphère Elle servira à indiquer
* si un objet est selectionné
*/
private void initBGSel() {
// On initialise la selection
// On récupère la sphère englobante de l'objet
BoundingSphere bs = new BoundingSphere(this.bGRep.getBounds());
Point3d pt = new Point3d();
bs.getCenter(pt);
// On place le sphère aux bonnes coordonnées
Transform3D translate = new Transform3D();
translate.set(new Vector3f((float) pt.getX(), (float) pt.getY(), (float) pt
.getZ()));
// Création de l'apparence
Appearance apparenceFinale = new Appearance();
// Autorisations pour l'apparence
apparenceFinale.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_READ);
apparenceFinale.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE);
// Autorisations pour le material
apparenceFinale.setCapability(Appearance.ALLOW_MATERIAL_READ);
apparenceFinale.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
// Création des attributs du polygone
PolygonAttributes pa = new PolygonAttributes();
pa.setCullFace(PolygonAttributes.CULL_NONE);
pa.setCapability(PolygonAttributes.ALLOW_CULL_FACE_WRITE);
// Indique que l'on est en mode surfacique
pa.setPolygonMode(PolygonAttributes.POLYGON_FILL);
pa.setCullFace(PolygonAttributes.CULL_BACK);
pa.setBackFaceNormalFlip(false);
Color3f couleur3F = new Color3f(ConstantRepresentation.selectionColor);
// Création du material (gestion des couleurs et de l'affichage)
Material material = new Material();
material.setAmbientColor(couleur3F.x / 2, couleur3F.y / 2, couleur3F.z / 2);
material.setDiffuseColor(couleur3F);
material.setSpecularColor(new Color3f(1.0f, 1.0f, 1.0f));
material.setShininess(128);
apparenceFinale.setMaterial(material);
// On applique l'apparence à la sphère
Sphere sphere = new Sphere((float) bs.getRadius(), apparenceFinale);
TransparencyAttributes t_attr = new TransparencyAttributes(
TransparencyAttributes.BLENDED, (float) 0.5,
TransparencyAttributes.BLEND_SRC_ALPHA, TransparencyAttributes.BLENDED);
apparenceFinale.setTransparencyAttributes(t_attr);
TransformGroup TG1 = new TransformGroup(translate);
TG1.addChild(sphere);
this.bgSel = new BranchGroup();
this.bgSel.setCapability(BranchGroup.ALLOW_DETACH);
this.bgSel.addChild(TG1);
}