0
저는 java3D와 stackoverflow에서 새로 도입되었습니다. 내 문제는 사각형에 BufferedImage 텍스처를 추가하려고 시도하는 것입니다. BufferedImage를 파일에 저장 했으므로 비어 있지 않습니다. "bi"는 BufferedImage입니다. 그것은 내가 java3D에 대해 찾을 수있는 것은 꽤 오래된 것 같습니다. 주석은 위의 명령이 아니라 위의 명령에 대한 것입니다.BufferedImage 텍스처가 java3D에 나타나지 않습니다.
QuadArray alap = new QuadArray(4, QuadArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2);
// [...] setting coordinates for the polygon (rectangle)
Appearance alapAppearance = new Appearance();
PolygonAttributes alapPa = new PolygonAttributes();
alapAppearance.setPolygonAttributes(alapPa);
alap.setTextureCoordinate (0, 0, new TexCoord2f(0.0f,0.0f));
alap.setTextureCoordinate (0, 1, new TexCoord2f(1.0f,0.0f));
alap.setTextureCoordinate (0, 2, new TexCoord2f(1.0f,1.0f));
alap.setTextureCoordinate (0, 3, new TexCoord2f(0.0f,1.0f));
//tryed in different order
TextureAttributes texAttr = new TextureAttributes();
texAttr.setTextureMode(TextureAttributes.REPLACE);
TextureLoader loader = new TextureLoader(bi, TextureLoader.ALLOW_NON_POWER_OF_TWO);
//Tryed with "RGB" flag too (as second parameter).
Texture t1 = loader.getTexture();
t1.setBoundaryModeS(Texture.CLAMP_TO_EDGE);
t1.setBoundaryModeT(Texture.CLAMP_TO_EDGE);
alapAppearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
alapAppearance.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE);
//I don't think it's really needed, but can't hurt I quess.
alapAppearance.setTextureAttributes(texAttr);
alapAppearance.setTexture(t1);
tfg.addChild(new Shape3D(alap, alapAppearance));
//tfg = transformGroup