本文整理汇总了Java中javax.media.j3d.Appearance.setTextureAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java Appearance.setTextureAttributes方法的具体用法?Java Appearance.setTextureAttributes怎么用?Java Appearance.setTextureAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.j3d.Appearance
的用法示例。
在下文中一共展示了Appearance.setTextureAttributes方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSelected
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
@Override
public void setSelected(boolean isSelected) {
this.selected = isSelected;
List<Shape3D> shapes = this.getShapes();
int nbElem = shapes.size();
for (int i = 0; i < nbElem; i++) {
Appearance ap = shapes.get(i).getAppearance();
if (isSelected) {
ColoringAttributes ca = new ColoringAttributes();
ca.setColor(new Color3f(ConstantRepresentation.selectionColor));
ap.setColoringAttributes(ca);
ap.setTexture(null);
ap.setTextureAttributes(null);
} else {
ap.setTextureAttributes(new TextureAttributes());
ap.setTexture(this.texture);
shapes.get(i).getAppearance().setColoringAttributes(null);
shapes.get(i).setAppearance(ap);
}
}
}
示例2: 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);
}
示例3: 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;
}
示例4: 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;
}
示例5: 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);
}
示例6: outputShape
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
private void outputShape(OrderedGroup triGroup, int orderDir, TexCoordGeneration tg, Texture2D texture, int numPts, Point3d[] pts, Color4f[] colrs)
{
count[0] = numPts;
TriangleFanArray pgonGeo = new TriangleFanArray(numPts,
GeometryArray.COORDINATES | GeometryArray.COLOR_4, count);
pgonGeo.setCoordinates(0, pts, 0, numPts);
pgonGeo.setColors(0, colrs, 0, numPts);
Appearance appearance = new Appearance();
if (texture != null)
{
appearance.setTextureAttributes(texAttr);
appearance.setTexture(texture);
}
appearance.setMaterial(m);
appearance.setColoringAttributes(clr);
appearance.setTransparencyAttributes(trans);
appearance.setPolygonAttributes(p);
appearance.setTexCoordGeneration(tg);
appearance.setRenderingAttributes(r);
Shape3D shape = new Shape3D(pgonGeo, appearance);
Node child = shape;
if (outputLines)
{
Group shapeGroup = new Group();
shapeGroup.addChild(shape);
count[0] = numPts + 1;
pts[numPts] = pts[0];
LineStripArray lineGeo = new LineStripArray(numPts + 1,
GeometryArray.COORDINATES, count);
lineGeo.setCoordinates(0, pts, 0, numPts + 1);
Appearance lineAppearance = new Appearance();
Shape3D lineShape = new Shape3D(lineGeo, lineAppearance);
shapeGroup.addChild(lineShape);
child = shapeGroup;
}
if (verbose)
{
System.out.println("shape is " + child);
}
if (orderDir == FRONT)
{
triGroup.insertChild(child, 0);
} else
{
triGroup.addChild(child);
}
}
示例7: createTerrain
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Create a java3d Shape for the terrain
* @param inModel threedModel
* @param inHelper terrain helper
* @param inBaseImage base image for shape, or null for no image
* @return Shape3D object
*/
private static Shape3D createTerrain(ThreeDModel inModel, TerrainHelper inHelper, GroutedImage inBaseImage)
{
final int numNodes = inHelper.getGridSize();
final int RESULT_SIZE = numNodes * (numNodes * 2 - 2);
int[] stripData = inHelper.getStripLengths();
// Get the scaled terrainTrack coordinates (or just heights) from the model
final int nSquared = numNodes * numNodes;
Point3d[] rawPoints = new Point3d[nSquared];
for (int i=0; i<nSquared; i++)
{
double height = inModel.getScaledTerrainValue(i) * MODEL_SCALE_FACTOR;
rawPoints[i] = new Point3d(inModel.getScaledTerrainHorizValue(i) * MODEL_SCALE_FACTOR,
Math.max(height, 0.05), // make sure it's above the box
-inModel.getScaledTerrainVertValue(i) * MODEL_SCALE_FACTOR);
}
GeometryInfo gi = new GeometryInfo(GeometryInfo.TRIANGLE_STRIP_ARRAY);
gi.setCoordinates(inHelper.getTerrainCoordinates(rawPoints));
gi.setStripCounts(stripData);
Appearance tAppearance = new Appearance();
if (inBaseImage != null)
{
gi.setTextureCoordinateParams(1, 2); // one coord set of two dimensions
gi.setTextureCoordinates(0, inHelper.getTextureCoordinates());
Texture mapImage = new TextureLoader(inBaseImage.getImage()).getTexture();
tAppearance.setTexture(mapImage);
TextureAttributes texAttr = new TextureAttributes();
texAttr.setTextureMode(TextureAttributes.MODULATE);
tAppearance.setTextureAttributes(texAttr);
}
else
{
Color3f[] colours = new Color3f[RESULT_SIZE];
Color3f terrainColour = new Color3f(0.1f, 0.2f, 0.2f);
for (int i=0; i<RESULT_SIZE; i++) {colours[i] = terrainColour;}
gi.setColors(colours);
}
new NormalGenerator().generateNormals(gi);
Material terrnMat = new Material(new Color3f(0.4f, 0.4f, 0.4f), // ambient colour
new Color3f(0f, 0f, 0f), // emissive (none)
new Color3f(0.8f, 0.8f, 0.8f), // diffuse
new Color3f(0.2f, 0.2f, 0.2f), //specular
30f); // shinyness
tAppearance.setMaterial(terrnMat);
return new Shape3D(gi.getGeometryArray(), tAppearance);
}
示例8: generateAppearance
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Génère l'apparence de l'objet
*
* @return
*/
private Appearance generateAppearance() {
// 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_COLORING_ATTRIBUTES_READ);
apparenceFinale.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
apparenceFinale.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_READ);
apparenceFinale.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE);
apparenceFinale.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
apparenceFinale.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
apparenceFinale.setTexture(this.texture);
apparenceFinale.setTextureAttributes(new TextureAttributes());
// Création des attributs du polygone
PolygonAttributes pa = new PolygonAttributes();
pa.setCullFace(PolygonAttributes.CULL_NONE);
pa.setCapability(PolygonAttributes.ALLOW_CULL_FACE_WRITE);
pa.setBackFaceNormalFlip(false);
// Association à l'apparence des attributs de géométrie et de material
apparenceFinale.setPolygonAttributes(pa);
return apparenceFinale;
}
示例9: generateAppearance
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Génère une apparence et gère le style en fonction du fait que c'est un mur
* ou pas
*
* @param isRoof indique si c'est un toit
* @return
*/
private Appearance generateAppearance(boolean isRoof) {
// 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_COLORING_ATTRIBUTES_READ);
apparenceFinale.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
apparenceFinale.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_READ);
apparenceFinale.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE);
apparenceFinale.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
apparenceFinale.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
// Le toit influe sur la texture
if (isRoof) {
apparenceFinale.setTexture(this.roofTexture);
} else {
apparenceFinale.setTexture(this.wallTexture);
}
apparenceFinale.setTextureAttributes(new TextureAttributes());
// Création des attributs du polygone
PolygonAttributes pa = new PolygonAttributes();
pa.setCullFace(PolygonAttributes.CULL_NONE);
pa.setCapability(PolygonAttributes.ALLOW_CULL_FACE_WRITE);
pa.setBackFaceNormalFlip(false);
// Association à l'apparence des attributs de géométrie et de material
apparenceFinale.setPolygonAttributes(pa);
return apparenceFinale;
}
示例10: generateAppearance
import javax.media.j3d.Appearance; //导入方法依赖的package包/类
/**
* Génère l'apparence de l'objet de type texture d'un objet
*
* @return
*/
private Appearance generateAppearance(Texture2D tex) {
// 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_COLORING_ATTRIBUTES_READ);
apparenceFinale.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
apparenceFinale.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_READ);
apparenceFinale.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE);
apparenceFinale.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
apparenceFinale.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
apparenceFinale.setTexture(tex);
apparenceFinale.setTextureAttributes(new TextureAttributes());
// Création des attributs du polygone
PolygonAttributes pa = new PolygonAttributes();
pa.setCullFace(PolygonAttributes.CULL_NONE);
pa.setCapability(PolygonAttributes.ALLOW_CULL_FACE_WRITE);
pa.setBackFaceNormalFlip(false);
// Association à l'apparence des attributs de géométrie et de material
apparenceFinale.setPolygonAttributes(pa);
TransparencyAttributes t_attr = new TransparencyAttributes(
TransparencyAttributes.NICEST, 0,
TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA,
TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA);
apparenceFinale.setTransparencyAttributes(t_attr);
return apparenceFinale;
}