我嘗試使用下面的代碼爲皮膚添加到多維數據集,但不會對皮膚在所有的工作。我測試,看它是否會加入到一個默認的立方體,它會(但重複每邊,而不是包裹周圍,這就是爲什麼我想提出一個自定義的立方體,以防止這種完整的圖像)。任何幫助將不勝感激。剝皮定製3D立方體的JavaFX 8
private void buildGraphics()
{
Image dieImage = new Image(getClass().getResourceAsStream("images/die.gif"));
PhongMaterial material = new PhongMaterial();
material.setDiffuseMap(dieImage);
material.setSpecularColor(Color.RED);
float hw = 100/2f;
float hh = 100/2f;
float hd = 100/2f;
float points[] =
{
hw, hh, hd,
hw, hh, -hd,
hw, -hh, hd,
hw, -hh, -hd,
-hw, hh, hd,
-hw, hh, -hd,
-hw, -hh, hd,
-hw, -hh, -hd,
};
float tex[] =
{
100, 0,
200, 0,
0, 100,
100, 100,
200, 100,
300, 100,
400, 100,
0, 200,
100, 200,
200, 200,
300, 200,
400, 200,
100, 300,
200, 300
};
int faces[] =
{
0, 10, 2, 5, 1, 9,
2, 5, 3, 4, 1, 9,
4, 7, 5, 8, 6, 2,
6, 2, 5, 8, 7, 3,
0, 13, 1, 9, 4, 12,
4, 12, 1, 9, 5, 8,
2, 1, 6, 0, 3, 4,
3, 4, 6, 0, 7, 3,
0, 10, 4, 11, 2, 5,
2, 5, 4, 11, 6, 6,
1, 9, 3, 4, 5, 8,
5, 8, 3, 4, 7, 3
};
TriangleMesh mesh = new TriangleMesh();
mesh.getPoints().addAll(points);
mesh.getTexCoords().addAll(tex);
mesh.getFaces().addAll(faces);
MeshView box = new MeshView(mesh);
box.setMaterial(material);
graphicGroup.getChildren().add(box);
Box box2 = new Box(100, 100, 100);
box2.setTranslateX(150);
box2.setMaterial(material);
graphicGroup.getChildren().add(box2);
world.getChildren().add(graphicGroup);
}
得到的答案從PavelSafrata對甲骨文OTN我的問題,TEX COORDS必須成正比...... –
所以在這種情況下,我的質地COORDS應該如下:「代碼」浮動TEX [] = { 0.25F ,0F, 0.5F,0F, 0F,0.33f, 0.25F,0.33f, 0.5F,0.33f, 0.75f,0.33f, 1F,0.33f, 0F,0.66f, 0.25 f,0.66f, 0.5f,0.66f, 0.75f,0.66f, 1f,0.66f, 0.25f,1f, 0.5f,1f}; –