2017-05-12 12 views
2

JavaFXとFXyz 0.1.1を使用してメッシュにテクスチャを適用するときに問題が発生しました。javafxのメッシュにテクスチャを適用する

私はthis questionを見つけましたが、詳しい解答でもそれを理解できませんでした。私は最初から始め、答えからコードを正確にコピーし、シーンは黒色で目に見えるicosohedronはありません。

私はJava 8を使用しています。提供されているイメージはgifであり、コードはpngとして参照しています。私は、ファイルのpngとgifの両方のバージョンで試してみました。私が他のすべてのことを話すことができる限り、参照される質問に対する答えのコードとまったく同じです。

私はthisを実行することはできますが、球体は問題なく使用できますが、球体の代わりにicosohedronを使用したいと考えています。

答えて

1

FXyz libraryを使用している場合は、別のテクスチャを二十面体、またはlibraryにあるさまざまなプリミティブに簡単に適用できます。

このスニペットは5つの異なるテクスチャモードを示しています

@Override 
public void start(Stage primaryStage) { 
    PerspectiveCamera camera = new PerspectiveCamera(true); 
    camera.setTranslateY(3); 
    camera.setTranslateX(4); 
    camera.setTranslateZ(-15); 

    IcosahedronMesh icoLine = new IcosahedronMesh(100, 0); 
    icoLine.setDrawMode(DrawMode.LINE); 
    icoLine.getTransforms().addAll(new Rotate(10, Rotate.X_AXIS), new Rotate(-20, Rotate.Y_AXIS)); 

    IcosahedronMesh icoColor = new IcosahedronMesh(100, 0); 
    icoColor.setTextureModeNone(Color.LIGHTGREEN); 
    icoColor.getTransforms().addAll(new Rotate(20, Rotate.X_AXIS), new Rotate(-20, Rotate.Y_AXIS)); 

    IcosahedronMesh icoFunction = new IcosahedronMesh(100, 0); 
    icoFunction.setTextureModeVertices3D(1530, p -> Math.cos(p.z)); 
    icoFunction.getTransforms().addAll(new Rotate(30, Rotate.X_AXIS), new Rotate(-20, Rotate.Y_AXIS)); 

    IcosahedronMesh icoFaces = new IcosahedronMesh(100, 0); 
    icoFaces.setTextureModeFaces(5); 
    icoFaces.getTransforms().addAll(new Rotate(20, Rotate.X_AXIS), new Rotate(-10, Rotate.Y_AXIS)); 

    IcosahedronMesh icoImage = new IcosahedronMesh(100, 0); 
    icoImage.setTextureModeImage(getClass().getResource("icon.jpg").toExternalForm()); 
    icoImage.getTransforms().addAll(new Rotate(20, Rotate.X_AXIS), new Rotate(-20, Rotate.Y_AXIS)); 

    IcosahedronMesh icoPattern = new IcosahedronMesh(100, 0); 
    icoPattern.setTextureModePattern(Patterns.CarbonPatterns.CARBON_KEVLAR, 100); 
    icoPattern.getTransforms().addAll(new Rotate(20, Rotate.X_AXIS), new Rotate(-30, Rotate.Y_AXIS)); 


    GridPane grid = new GridPane(); 
    grid.add(new Group(icoLine), 0, 0); 
    grid.add(new Group(icoColor), 1, 0); 
    grid.add(new Group(icoFunction), 2, 0); 

    grid.add(new Group(icoFaces), 0, 1); 
    grid.add(new Group(icoImage), 1, 1); 
    grid.add(new Group(icoPattern), 2, 1); 
    Scene scene = new Scene(grid, 600, 400, true, SceneAntialiasing.BALANCED); 
    scene.setCamera(camera); 

    primaryStage.setScene(scene); 
    primaryStage.setTitle(("Icosahedron - FXyz3D")); 
    primaryStage.show(); 

} 

Icosahedra Textures

+0

は答えと例をありがとうございました。彼らは私が探していた方向に向かうようになった。 – sdp0et

関連する問題