float C0 = length * (float) (Math.sqrt(2.0)+1.0) / 2.0f; float C1 = length * 0.5f; // 建立TriangleMesh TriangleMesh trianglemesh = new TriangleMesh(); // 設定頂點座標 trianglemesh.getPoints().addAll( C1, C1, C0, C1, C1, -C0, C1, -C1, C0, C1, -C1, -C0, -C1, C1, C0, -C1, C1, -C0, -C1, -C1, C0, -C1, -C1, -C0, C0, C1, C1, C0, C1, -C1, C0, -C1, C1, C0, -C1, -C1, -C0, C1, C1, -C0, C1, -C1, -C0, -C1, C1, -C0, -C1, -C1, C1, C0, C1, C1, C0, -C1, C1, -C0, C1, C1, -C0, -C1, -C1, C0, C1, -C1, C0, -C1, -C1, -C0, C1, -C1, -C0, -C1 ); // 設定貼圖座標 trianglemesh.getTexCoords().addAll( 0.50f, 1.0f, 0.75f, (float) (1.0-Math.sqrt(3.0)/4.0f), 0.25f, (float) (1.0-Math.sqrt(3.0)/4.0f), 1.00f, 1.0f, 0.50f, (float) (1.0-Math.sqrt(3.0)/2.0f), 0.00f, 1.0f ); // 設定各三角形的面 trianglemesh.getFaces().addAll( 0, 2, 8, 1, 16, 4, 1, 2, 17, 1, 9, 4, 2, 2, 18, 1, 10, 4, 3, 2, 11, 1, 19, 4, 4, 2, 20, 1, 12, 4, 5, 2, 13, 1, 21, 4, 6, 2, 14, 1, 22, 4, 7, 2, 23, 1, 15, 4, 0, 0, 16, 1, 20, 2, 0, 0, 20, 1, 4, 2, 0, 0, 4, 1, 6, 2, 0, 0, 6, 1, 2, 2, 0, 0, 2, 1, 10, 2, 0, 0, 10, 1, 8, 2, 7, 0, 15, 1, 13, 2, 7, 0, 13, 1, 5, 2, 7, 0, 5, 1, 1, 2, 7, 0, 1, 1, 3, 2, 7, 0, 3, 1, 19, 2, 7, 0, 19, 1, 23, 2, 11, 0, 3, 1, 1, 2, 11, 0, 1, 1, 9, 2, 11, 0, 9, 1, 8, 2, 11, 0, 8, 1, 10, 2, 11, 0, 10, 1, 18, 2, 11, 0, 18, 1, 19, 2, 12, 0, 20, 1, 21, 2, 12, 0, 21, 1, 13, 2, 12, 0, 13, 1, 15, 2, 12, 0, 15, 1, 14, 2, 12, 0, 14, 1, 6, 2, 12, 0, 6, 1, 4, 2, 17, 0, 1, 1, 5, 2, 17, 0, 5, 1, 21, 2, 17, 0, 21, 1, 20, 2, 17, 0, 20, 1, 16, 2, 17, 0, 16, 1, 8, 2, 17, 0, 8, 1, 9, 2, 22, 0, 14, 1, 15, 2, 22, 0, 15, 1, 23, 2, 22, 0, 23, 1, 19, 2, 22, 0, 19, 1, 18, 2, 22, 0, 18, 1, 2, 2, 22, 0, 2, 1, 6, 2 ); // 設定各面的平滑參數 trianglemesh.getFaceSmoothingGroups().addAll( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ); // 建立MeshView MeshView meshview; meshview = new MeshView(createMesh(100)); ...【參考資料】
[1] Java Official Web Site:http://www.oracle.com/technetwork/java/index.html
[2] JavaFX:http://www.oracle.com/technetwork/java/javafx
[3] JavaFX 8.0 API Specification.
[4] Java Platform, Standard Edition 8 API Specification.
[5] JDK 8 Certified System Configurations.
[6] H. M. Cundy, A. P. Rollett, Mathematical Models, Tarquin Publications, 1981.
[7] G. Sellers, R. S. Wright, N. Haemel, OpenGL SuperBible: Comprehensive Tutorial and Reference (6th Edition), Addison-Wesley Professional, 2013.
[8] 黃嘉輝, JavaFX 8技術手冊, ISBN: 9789863474050, 碁峰資訊, 2014.
© Chia-Hui Huang
[2] JavaFX:http://www.oracle.com/technetwork/java/javafx
[3] JavaFX 8.0 API Specification.
[4] Java Platform, Standard Edition 8 API Specification.
[5] JDK 8 Certified System Configurations.
[6] H. M. Cundy, A. P. Rollett, Mathematical Models, Tarquin Publications, 1981.
[7] G. Sellers, R. S. Wright, N. Haemel, OpenGL SuperBible: Comprehensive Tutorial and Reference (6th Edition), Addison-Wesley Professional, 2013.
[8] 黃嘉輝, JavaFX 8技術手冊, ISBN: 9789863474050, 碁峰資訊, 2014.
© Chia-Hui Huang
沒有留言:
張貼留言