BufferedImage纹理没有出现在java3D中
|
我在java3D和stackoverflow上还是很新的。我的问题是我尝试将BufferedImage纹理添加到矩形,但它没有出现。我将BufferedImage保存到文件中,因此我确定它不为空。 \“ bi \”是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
没有找到相关结果
已邀请:
1 个回复
渴翅吮斡撤