本文整理汇总了Java中javax.media.j3d.PolygonAttributes类的典型用法代码示例。如果您正苦于以下问题:Java PolygonAttributes类的具体用法?Java PolygonAttributes怎么用?Java PolygonAttributes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PolygonAttributes类属于javax.media.j3d包,在下文中一共展示了PolygonAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exportTriangle
import javax.media.j3d.PolygonAttributes; //导入依赖的package包/类
/**
* Stores in <code>verticesIndices</code> the indices vertexIndex1, vertexIndex2, vertexIndex3.
*/
private int exportTriangle(GeometryArray geometryArray, int vertexIndex1, int vertexIndex2, int vertexIndex3,
int[] verticesIndices, int index, float[] vertices, Set<Triangle> exportedTriangles, int cullFace)
{
if (cullFace == PolygonAttributes.CULL_FRONT)
{
// Reverse vertex order
int tmp = vertexIndex1;
vertexIndex1 = vertexIndex3;
vertexIndex3 = tmp;
}
Triangle exportedTriangle = new Triangle(vertices, vertexIndex1, vertexIndex2, vertexIndex3);
if (!exportedTriangles.contains(exportedTriangle))
{
exportedTriangles.add(exportedTriangle);
verticesIndices[index++] = vertexIndex1;
verticesIndices[index++] = vertexIndex2;
verticesIndices[index++] = vertexIndex3;
}
return index;
}
示例2: writeIndexedTriangle
import javax.media.j3d.PolygonAttributes; //导入依赖的package包/类
/**
* Writes the triangle indices given at vertexIndex1, vertexIndex2,
* vertexIndex3, in a line f at OBJ format.
*/
private void writeIndexedTriangle(IndexedGeometryArray geometryArray, int vertexIndex1, int vertexIndex2, int vertexIndex3, int[] vertexIndexSubstitutes, int[] normalIndexSubstitutes, int[] oppositeSideNormalIndexSubstitutes, boolean normalsDefined, int[] textureCoordinatesIndexSubstitutes, boolean textureCoordinatesGenerated, int cullFace) throws IOException {
if (cullFace == PolygonAttributes.CULL_FRONT) {
// Reverse vertex order
int tmp = vertexIndex1;
vertexIndex1 = vertexIndex3;
vertexIndex3 = tmp;
}
if (textureCoordinatesGenerated || (geometryArray.getVertexFormat() & GeometryArray.TEXTURE_COORDINATE_2) != 0) {
if (normalsDefined) {
this.out.write("f " + (vertexIndexSubstitutes[geometryArray.getCoordinateIndex(vertexIndex1)]) + "/" + (textureCoordinatesIndexSubstitutes[geometryArray.getTextureCoordinateIndex(0, vertexIndex1)]) + "/" + (normalIndexSubstitutes[geometryArray.getNormalIndex(vertexIndex1)]) + " " + (vertexIndexSubstitutes[geometryArray.getCoordinateIndex(vertexIndex2)]) + "/" + (textureCoordinatesIndexSubstitutes[geometryArray.getTextureCoordinateIndex(0, vertexIndex2)]) + "/" + (normalIndexSubstitutes[geometryArray.getNormalIndex(vertexIndex2)]) + " " + (vertexIndexSubstitutes[geometryArray.getCoordinateIndex(vertexIndex3)]) + "/" + (textureCoordinatesIndexSubstitutes[geometryArray.getTextureCoordinateIndex(0, vertexIndex3)]) + "/" + (normalIndexSubstitutes[geometryArray.getNormalIndex(vertexIndex3)]) + "\n");
} else {
this.out.write("f " + (vertexIndexSubstitutes[geometryArray.getCoordinateIndex(vertexIndex1)]) + "/" + (textureCoordinatesIndexSubstitutes[geometryArray.getTextureCoordinateIndex(0, vertexIndex1)]) + " " + (vertexIndexSubstitutes[geometryArray.getCoordinateIndex(vertexIndex2)]) + "/" + (textureCoordinatesIndexSubstitutes[geometryArray.getTextureCoordinateIndex(0, vertexIndex2)]) + " " + (vertexIndexSubstitutes[geometryArray.getCoordinateIndex(vertexIndex3)]) + "/" + (textureCoordinatesIndexSubstitutes[geometryArray.getTextureCoordinateIndex(0, vertexIndex3)]) + "\n");
}
} else {
if (normalsDefined) {
this.out.write("f " + (vertexIndexSubstitutes[geometryArray.getCoordinateIndex(vertexIndex1)]) + "//" + (normalIndexSubstitutes[geometryArray.getNormalIndex(vertexIndex1)]) + " " + (vertexIndexSubstitutes[geometryArray.getCoordinateIndex(vertexIndex2)]) + "//" + (normalIndexSubstitutes[geometryArray.getNormalIndex(vertexIndex2)]) + " " + (vertexIndexSubstitutes[geometryArray.getCoordinateIndex(vertexIndex3)]) + "//" + (normalIndexSubstitutes[geometryArray.getNormalIndex(vertexIndex3)]) + "\n");
} else {
this.out.write("f " + (vertexIndexSubstitutes[geometryArray.getCoordinateIndex(vertexIndex1)]) + " " + (vertexIndexSubstitutes[geometryArray.getCoordinateIndex(vertexIndex2)]) + " " + (vertexIndexSubstitutes[geometryArray.getCoordinateIndex(vertexIndex3)]) + "\n");
}
}
if (cullFace == PolygonAttributes.CULL_NONE) {
// Use opposite side normal index substitutes array
writeIndexedTriangle(geometryArray, vertexIndex1, vertexIndex2, vertexIndex3, vertexIndexSubstitutes, oppositeSideNormalIndexSubstitutes, null, normalsDefined, textureCoordinatesIndexSubstitutes, textureCoordinatesGenerated, PolygonAttributes.CULL_FRONT);
}
}
示例3: writeTriangle
import javax.media.j3d.PolygonAttributes; //导入依赖的package包/类
/**
* Writes the triangle indices given at vertexIndex1, vertexIndex2,
* vertexIndex3, in a line f at OBJ format.
*/
private void writeTriangle(GeometryArray geometryArray, int vertexIndex1, int vertexIndex2, int vertexIndex3, int[] vertexIndexSubstitutes, int[] normalIndexSubstitutes, int[] oppositeSideNormalIndexSubstitutes, boolean normalsDefined, int[] textureCoordinatesIndexSubstitutes, boolean textureCoordinatesGenerated, int cullFace) throws IOException {
if (cullFace == PolygonAttributes.CULL_FRONT) {
// Reverse vertex order
int tmp = vertexIndex1;
vertexIndex1 = vertexIndex3;
vertexIndex3 = tmp;
}
if (textureCoordinatesGenerated || (geometryArray.getVertexFormat() & GeometryArray.TEXTURE_COORDINATE_2) != 0) {
if (normalsDefined) {
this.out.write("f " + (vertexIndexSubstitutes[vertexIndex1]) + "/" + (textureCoordinatesIndexSubstitutes[vertexIndex1]) + "/" + (normalIndexSubstitutes[vertexIndex1]) + " " + (vertexIndexSubstitutes[vertexIndex2]) + "/" + (textureCoordinatesIndexSubstitutes[vertexIndex2]) + "/" + (normalIndexSubstitutes[vertexIndex2]) + " " + (vertexIndexSubstitutes[vertexIndex3]) + "/" + (textureCoordinatesIndexSubstitutes[vertexIndex3]) + "/" + (normalIndexSubstitutes[vertexIndex3]) + "\n");
} else {
this.out.write("f " + (vertexIndexSubstitutes[vertexIndex1]) + "/" + (textureCoordinatesIndexSubstitutes[vertexIndex1]) + " " + (vertexIndexSubstitutes[vertexIndex2]) + "/" + (textureCoordinatesIndexSubstitutes[vertexIndex2]) + " " + (vertexIndexSubstitutes[vertexIndex3]) + "/" + (textureCoordinatesIndexSubstitutes[vertexIndex3]) + "\n");
}
} else {
if (normalsDefined) {
this.out.write("f " + (vertexIndexSubstitutes[vertexIndex1]) + "//" + (normalIndexSubstitutes[vertexIndex1]) + " " + (vertexIndexSubstitutes[vertexIndex2]) + "//" + (normalIndexSubstitutes[vertexIndex2]) + " " + (vertexIndexSubstitutes[vertexIndex3]) + "//" + (normalIndexSubstitutes[vertexIndex3]) + "\n");
} else {
this.out.write("f " + (vertexIndexSubstitutes[vertexIndex1]) + " " + (vertexIndexSubstitutes[vertexIndex2]) + " " + (vertexIndexSubstitutes[vertexIndex3]) + "\n");
}
}
if (cullFace == PolygonAttributes.CULL_NONE) {
// Use opposite side normal index substitutes array
writeTriangle(geometryArray, vertexIndex1, vertexIndex2, vertexIndex3, vertexIndexSubstitutes, oppositeSideNormalIndexSubstitutes, null, normalsDefined, textureCoordinatesIndexSubstitutes, textureCoordinatesGenerated, PolygonAttributes.CULL_FRONT);
}
}
示例4: setBackFaceNormalFlip
import javax.media.j3d.PolygonAttributes; //导入依赖的package包/类
/**
* Sets whether all <code>Shape3D</code> children nodes of <code>node</code> should have
* their normal flipped or not.
* Caution !!! Should be executed only once per instance
* @param backFaceNormalFlip <code>true</code> if normals should be flipped.
*/
private void setBackFaceNormalFlip(Node node, boolean backFaceNormalFlip)
{
if (node instanceof Group)
{
// Set back face normal flip of all children
Enumeration<?> enumeration = ((Group) node).getAllChildren();
while (enumeration.hasMoreElements())
{
setBackFaceNormalFlip((Node) enumeration.nextElement(), backFaceNormalFlip);
}
}
else if (node instanceof Link)
{
setBackFaceNormalFlip(((Link) node).getSharedGroup(), backFaceNormalFlip);
}
else if (node instanceof Shape3D)
{
Appearance appearance = ((Shape3D) node).getAppearance();
if (appearance == null)
{
appearance = createAppearanceWithChangeCapabilities();
((Shape3D) node).setAppearance(appearance);
}
PolygonAttributes polygonAttributes = appearance.getPolygonAttributes();
if (polygonAttributes == null)
{
polygonAttributes = createPolygonAttributesWithChangeCapabilities();
appearance.setPolygonAttributes(polygonAttributes);
}
// Change back face normal flip
polygonAttributes.setBackFaceNormalFlip(
backFaceNormalFlip ^ polygonAttributes.getCullFace() == PolygonAttributes.CULL_FRONT);
}
}
示例5: createPolygonAttributesWithChangeCapabilities
import javax.media.j3d.PolygonAttributes; //导入依赖的package包/类
private PolygonAttributes createPolygonAttributesWithChangeCapabilities()
{
PolygonAttributes polygonAttributes = new PolygonAttributes();
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);
return polygonAttributes;
}
示例6: setAppearanceCapabilities
import javax.media.j3d.PolygonAttributes; //导入依赖的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);
}
}
示例7: exportIndexedTriangle
import javax.media.j3d.PolygonAttributes; //导入依赖的package包/类
/**
* Stores in <code>verticesIndices</code> the indices given at vertexIndex1, vertexIndex2, vertexIndex3.
*/
private int exportIndexedTriangle(IndexedGeometryArray geometryArray, int vertexIndex1, int vertexIndex2,
int vertexIndex3, int[] verticesIndices, int[] normalsIndices, int[] textureCoordinatesIndices, int index,
float[] vertices, Set<Triangle> exportedTriangles, int cullFace)
{
if (cullFace == PolygonAttributes.CULL_FRONT)
{
// Reverse vertex order
int tmp = vertexIndex1;
vertexIndex1 = vertexIndex3;
vertexIndex3 = tmp;
}
int coordinateIndex1 = geometryArray.getCoordinateIndex(vertexIndex1);
int coordinateIndex2 = geometryArray.getCoordinateIndex(vertexIndex2);
int coordinateIndex3 = geometryArray.getCoordinateIndex(vertexIndex3);
Triangle exportedTriangle = new Triangle(vertices, coordinateIndex1, coordinateIndex2, coordinateIndex3);
if (!exportedTriangles.contains(exportedTriangle))
{
exportedTriangles.add(exportedTriangle);
verticesIndices[index] = coordinateIndex1;
verticesIndices[index + 1] = coordinateIndex2;
verticesIndices[index + 2] = coordinateIndex3;
if (normalsIndices != null)
{
normalsIndices[index] = geometryArray.getNormalIndex(vertexIndex1);
normalsIndices[index + 1] = geometryArray.getNormalIndex(vertexIndex2);
normalsIndices[index + 2] = geometryArray.getNormalIndex(vertexIndex3);
}
if (textureCoordinatesIndices != null)
{
textureCoordinatesIndices[index] = geometryArray.getTextureCoordinateIndex(0, vertexIndex1);
textureCoordinatesIndices[index + 1] = geometryArray.getTextureCoordinateIndex(0, vertexIndex2);
textureCoordinatesIndices[index + 2] = geometryArray.getTextureCoordinateIndex(0, vertexIndex3);
}
return index + 3;
}
return index;
}
示例8: createAppearance
import javax.media.j3d.PolygonAttributes; //导入依赖的package包/类
private void createAppearance() {
Appearance app = new Appearance();
PolygonAttributes pa = new PolygonAttributes();
pa.setCullFace(PolygonAttributes.CULL_NONE);
// so can see the ColouredTiles from both sides
app.setPolygonAttributes(pa);
setAppearance(app);
}
示例9: SlicePlane3DRenderer
import javax.media.j3d.PolygonAttributes; //导入依赖的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: SlicePlane2DRenderer
import javax.media.j3d.PolygonAttributes; //导入依赖的package包/类
public SlicePlane2DRenderer(View view, Context context, Volume vol)
{
super(view, context, vol);
texVol = new Texture2DVolume(context, vol);
for (int i = 0; i < 4; i++)
{
shapeColrs[i] = new Color4f();
}
texAttr.setTextureMode(TextureAttributes.MODULATE);
texAttr.setCapability(TextureAttributes.ALLOW_COLOR_TABLE_WRITE);
trans.setTransparencyMode(TransparencyAttributes.BLENDED);
trans.setSrcBlendFunction(TransparencyAttributes.BLEND_ONE);
trans.setDstBlendFunction(TransparencyAttributes.BLEND_ONE);
m.setLightingEnable(false);
p.setCullFace(PolygonAttributes.CULL_NONE);
r.setDepthBufferWriteEnable(false);
// these are the default for no texture
trans.setTransparency(0.0f);
clr.setColor(0.0f, 0.0f, 0.0f);
// set up an initial, empty slice
sliceGroup.setCapability(Group.ALLOW_CHILDREN_READ);
sliceGroup.setCapability(Group.ALLOW_CHILDREN_WRITE);
sliceGroup.addChild(null);
root.addChild(sliceGroup);
numSlicePts = 0;
setSliceGeo();
}
示例11: CorticalColumn
import javax.media.j3d.PolygonAttributes; //导入依赖的package包/类
public CorticalColumn(float scale) {
super();
this.scale = scale;
Region.Param.ColumnParam par = Region.Param.getInstance().getColumnParam();
lengthX = par.getLength() * scale;
widthY = par.getWidth() * scale;
layer1 = par.getLayer1() * scale;
layer23 = par.getLayer23() * scale;
layer4 = par.getLayer4() * scale;
layer5A = par.getLayer5A() * scale;
layer5B = par.getLayer5B() * scale;
layer6 = par.getLayer6() * scale;
heightZ = par.getHeight() * scale;
Appearance ap = new Appearance();
ColoringAttributes ca = new ColoringAttributes();
ca.setColor(Utils3D.grey);
ap.setColoringAttributes(ca);
TransparencyAttributes myTA = new TransparencyAttributes();
myTA.setTransparency(0.7f);
myTA.setTransparencyMode(TransparencyAttributes.NICEST);
ap.setTransparencyAttributes(myTA);
//render the Box as a wire frame
PolygonAttributes polyAttrbutes = new PolygonAttributes();
polyAttrbutes.setPolygonMode(PolygonAttributes.POLYGON_LINE);
polyAttrbutes.setCullFace(PolygonAttributes.CULL_NONE);
ap.setPolygonAttributes(polyAttrbutes);
setAppearance(ap);
}
示例12: RegionCA1
import javax.media.j3d.PolygonAttributes; //导入依赖的package包/类
public RegionCA1(float scale) {
super();
this.scale = scale;
Region.Param.CA1Param regPar = Region.Param.getInstance().getCa1Param();
lengthX = regPar.getLength() * scale;
widthY = regPar.getWidth() * scale;
stratumOriens = regPar.getStratumOriens() * scale;
stratumPyramidale = regPar.getStratumPyramidale() * scale;
stratumRadiatum = regPar.getStratumRadiatum() * scale;
stratumLacunosum = regPar.getStratumLacunosum() * scale;
heightZ = regPar.getHeight() * scale;
Appearance ap = new Appearance();
ColoringAttributes ca = new ColoringAttributes();
ca.setColor(Utils3D.grey);
ap.setColoringAttributes(ca);
TransparencyAttributes myTA = new TransparencyAttributes();
myTA.setTransparency(0.7f);
myTA.setTransparencyMode(TransparencyAttributes.FASTEST);
ap.setTransparencyAttributes(myTA);
//render the Box as a wire frame
PolygonAttributes polyAttrbutes = new PolygonAttributes();
polyAttrbutes.setPolygonMode(PolygonAttributes.POLYGON_LINE);
polyAttrbutes.setCullFace(PolygonAttributes.CULL_NONE);
ap.setPolygonAttributes(polyAttrbutes);
setAppearance(ap);
}
示例13: createMaterialAppearance
import javax.media.j3d.PolygonAttributes; //导入依赖的package包/类
@SuppressWarnings("unused")
private static Appearance createMaterialAppearance() {
Appearance materialAppear = new Appearance();
PolygonAttributes polyAttrib = new PolygonAttributes();
polyAttrib.setCullFace(PolygonAttributes.CULL_NONE);
materialAppear.setPolygonAttributes(polyAttrib);
Material material = new Material();
material.setDiffuseColor(ColorUtil.red);
materialAppear.setMaterial(material);
return materialAppear;
}
示例14: createWireFrameAppearance
import javax.media.j3d.PolygonAttributes; //导入依赖的package包/类
@SuppressWarnings("unused")
private static Appearance createWireFrameAppearance() {
Appearance materialAppear = new Appearance();
PolygonAttributes polyAttrib = new PolygonAttributes();
polyAttrib.setPolygonMode(PolygonAttributes.POLYGON_LINE);
materialAppear.setPolygonAttributes(polyAttrib);
ColoringAttributes redColoring = new ColoringAttributes();
redColoring.setColor(ColorUtil.red);
materialAppear.setColoringAttributes(redColoring);
return materialAppear;
}
示例15: Java3dFactory
import javax.media.j3d.PolygonAttributes; //导入依赖的package包/类
public Java3dFactory( Colors colors, Boolean useEmissiveColor )
{
mHasEmissiveColor = useEmissiveColor .booleanValue();
mAppearances = new Appearances( colors, mHasEmissiveColor );
outlines = new Appearance();
PolygonAttributes wirePa = new PolygonAttributes( PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_BACK, -10f );
outlines .setPolygonAttributes( wirePa );
LineAttributes lineAtts = new LineAttributes( 1, LineAttributes .PATTERN_SOLID, true );
outlines .setLineAttributes( lineAtts );
outlines .setColoringAttributes( new ColoringAttributes( new Color3f( Color.BLACK ), ColoringAttributes .SHADE_FLAT ) );
}