다음 코드를 사용하여 큐브에 스킨을 추가하려고하지만 스킨이 전혀 작동하지 않습니다. 나는 그것이 기본 큐브에 추가되는지를 테스트했다. (그러나 그것을 감싸는 대신에 각면에서 전체 이미지를 반복한다. 그래서 이것을 방지하기 위해 커스텀 큐브를 만들고있다.) 어떤 도움이라도 대단히 감사하겠습니다. 당신은 올바른 ... 나는 또한 등등 캡슐, 높이지도, 토러스, 같은 기본 모양을 만들고 주변에 연주되어있다javafx에서 사용자 정의 3D 큐브를 스키닝 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);
}
Oracles OTN의 PavelSafrata에서 내 질문에 대한 대답을 얻었으므로 텍스 코디는 비례해야합니다 ... –
이 상황에서 텍스처 좌표는 다음과 같아야합니다 : 'code'float 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}; –