A toroid is said to be non-regular if not all of its faces have the same number of vertices, or not all of its vertices join the same number of faces. All of the toroids on this page are non-regular.
float C0 = length * 0.0f; float C1 = length * (float) Math.sqrt(2.0) / 6.0f; float C2 = length * (float) Math.sqrt(2.0) / 3.0f; float C3 = length * (float) Math.sqrt(2.0) / 2.0f; float C4 = length * (float) (5.0 * Math.sqrt(2.0)) / 6.0f; float C5 = length * (float) Math.sqrt(2.0); // 建立TriangleMesh TriangleMesh trianglemesh = new TriangleMesh(); // 設定頂點座標 trianglemesh.getPoints().addAll( C3, C0, C5, C3, C0, -C5, -C3, C0, C5, -C3, C0, -C5, C5, C3, C0, C5, -C3, C0, -C5, C3, C0, -C5, -C3, C0, C0, C5, C3, C0, C5, -C3, C0, -C5, C3, C0, -C5, -C3, C0, C3, C5, C0, C3, -C5, C0, -C3, C5, C0, -C3, -C5, C5, C0, C3, C5, C0, -C3, -C5, C0, C3, -C5, C0, -C3, C3, C5, C0, C3, -C5, C0, -C3, C5, C0, -C3, -C5, C0, -C1, -C1, -C4, C4, -C1, C1, -C1, C4, C1, -C2, C1, C2, -C2, -C2, -C1, C1, -C2, C2 ); // 設定貼圖座標 trianglemesh.getTexCoords().addAll( 0.0f, 0.0f, // 0 0.5f, 0.0f, // 1 1.0f, 0.0f, // 2 0.0f, 0.5f, // 3 0.5f, 0.5f, // 4 1.0f, 0.5f, // 5 0.0f, 1.0f, // 6 0.5f, 1.0f, // 7 1.0f, 1.0f // 8 ); // 設定各三角形的面 trianglemesh.getFaces().addAll( 0, 1, 14, 5, 10, 2, // Yellow 0, 1, 10, 5, 21, 2, // Yellow 0, 1, 21, 5, 5, 2, // Yellow 0, 1, 5, 5, 16, 2, // Yellow 0, 1, 10, 5, 14, 2, // Yellow 0, 1, 21, 5, 10, 2, // Yellow 0, 1, 5, 5, 21, 2, // Yellow 0, 1, 16, 5, 5, 2, // Yellow 0, 1, 16, 5, 4, 2, // Yellow 0, 1, 4, 5, 20, 2, // Yellow 0, 1, 20, 5, 8, 2, // Yellow 0, 1, 8, 5, 12, 2, // Yellow 0, 1, 4, 5, 16, 2, // Yellow 0, 1, 20, 5, 4, 2, // Yellow 0, 1, 8, 5, 20, 2, // Yellow 0, 1, 12, 5, 8, 2, // Yellow 1, 1, 24, 5, 28, 2, // Yellow 1, 1, 28, 5, 29, 2, // Yellow 1, 1, 29, 5, 25, 2, // Yellow 1, 1, 25, 5, 17, 2, // Yellow 1, 1, 28, 5, 24, 2, // Yellow 1, 1, 29, 5, 28, 2, // Yellow 1, 1, 25, 5, 29, 2, // Yellow 1, 1, 17, 5, 25, 2, // Yellow 1, 1, 17, 5, 5, 2, // Yellow 1, 1, 5, 5, 21, 2, // Yellow 1, 1, 21, 5, 11, 2, // Yellow 1, 1, 11, 5, 15, 2, // Yellow 1, 1, 5, 5, 17, 2, // Yellow 1, 1, 21, 5, 5, 2, // Yellow 1, 1, 11, 5, 21, 2, // Yellow 1, 1, 15, 5, 11, 2, // Yellow 2, 1, 12, 5, 8, 2, // Yellow 2, 1, 8, 5, 22, 2, // Yellow 2, 1, 22, 5, 6, 2, // Yellow 2, 1, 6, 5, 18, 2, // Yellow 2, 1, 8, 5, 12, 2, // Yellow 2, 1, 22, 5, 8, 2, // Yellow 2, 1, 6, 5, 22, 2, // Yellow 2, 1, 18, 5, 6, 2, // Yellow 3, 1, 15, 5, 11, 2, // Yellow 3, 1, 11, 5, 23, 2, // Yellow 3, 1, 23, 5, 7, 2, // Yellow 3, 1, 7, 5, 19, 2, // Yellow 3, 1, 11, 5, 15, 2, // Yellow 3, 1, 23, 5, 11, 2, // Yellow 3, 1, 7, 5, 23, 2, // Yellow 3, 1, 19, 5, 7, 2, // Yellow 3, 1, 19, 5, 6, 2, // Yellow 3, 1, 6, 5, 22, 2, // Yellow 3, 1, 22, 5, 9, 2, // Yellow 3, 1, 9, 5, 13, 2, // Yellow 3, 1, 6, 5, 19, 2, // Yellow 3, 1, 22, 5, 6, 2, // Yellow 3, 1, 9, 5, 22, 2, // Yellow 3, 1, 13, 5, 9, 2, // Yellow 4, 1, 25, 5, 29, 2, // Yellow 4, 1, 29, 5, 27, 2, // Yellow 4, 1, 27, 5, 26, 2, // Yellow 4, 1, 26, 5, 20, 2, // Yellow 4, 1, 29, 5, 25, 2, // Yellow 4, 1, 27, 5, 29, 2, // Yellow 4, 1, 26, 5, 27, 2, // Yellow 4, 1, 20, 5, 26, 2, // Yellow 9, 1, 26, 5, 27, 2, // Yellow 9, 1, 27, 5, 28, 2, // Yellow 9, 1, 28, 5, 24, 2, // Yellow 9, 1, 24, 5, 13, 2, // Yellow 9, 1, 27, 5, 26, 2, // Yellow 9, 1, 28, 5, 27, 2, // Yellow 9, 1, 24, 5, 28, 2, // Yellow 9, 1, 13, 5, 24, 2, // Yellow 0, 0, 12, 3, 2, 1, // Red 0, 0, 2, 3, 14, 1, // Red 0, 0, 2, 3, 12, 1, // Red 0, 0, 14, 3, 2, 1, // Red 1, 0, 15, 3, 3, 1, // Red 1, 0, 3, 3, 13, 1, // Red 1, 0, 3, 3, 15, 1, // Red 1, 0, 13, 3, 3, 1, // Red 2, 0, 27, 3, 29, 1, // Red 2, 0, 29, 3, 14, 1, // Red 2, 0, 29, 3, 27, 1, // Red 2, 0, 14, 3, 29, 1, // Red 4, 0, 16, 3, 5, 1, // Red 4, 0, 5, 3, 17, 1, // Red 4, 0, 5, 3, 16, 1, // Red 4, 0, 17, 3, 5, 1, // Red 6, 0, 19, 3, 7, 1, // Red 6, 0, 7, 3, 18, 1, // Red 6, 0, 7, 3, 19, 1, // Red 6, 0, 18, 3, 7, 1, // Red 7, 0, 28, 3, 27, 1, // Red 7, 0, 27, 3, 18, 1, // Red 7, 0, 27, 3, 28, 1, // Red 7, 0, 18, 3, 27, 1, // Red 8, 0, 20, 3, 9, 1, // Red 8, 0, 9, 3, 22, 1, // Red 8, 0, 9, 3, 20, 1, // Red 8, 0, 22, 3, 9, 1, // Red 10, 0, 29, 3, 28, 1, // Red 10, 0, 28, 3, 23, 1, // Red 10, 0, 28, 3, 29, 1, // Red 10, 0, 23, 3, 28, 1, // Red 10, 0, 23, 3, 11, 1, // Red 10, 0, 11, 3, 21, 1, // Red 10, 0, 11, 3, 23, 1, // Red 10, 0, 21, 3, 11, 1, // Red 24, 3, 1, 6, 13, 7, // Green 24, 3, 13, 6, 1, 7, // Green 25, 3, 4, 6, 17, 7, // Green 25, 3, 17, 6, 4, 7, // Green 26, 3, 9, 6, 20, 7, // Green 26, 3, 20, 6, 9, 7, // Green 27, 3, 2, 6, 18, 7, // Green 27, 3, 18, 6, 2, 7, // Green 28, 3, 7, 6, 23, 7, // Green 28, 3, 23, 6, 7, 7, // Green 29, 3, 10, 6, 14, 7, // Green 29, 3, 14, 6, 10, 7 // Green ); // 設定各面的平滑參數 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, 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, 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(95)); ...【參考資料】
[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
沒有留言:
張貼留言