2017年11月11日 星期六

JavaFX 3D - Cairo-Tiling Toroid with 16 Faces (Type B)

以下是以JavaFX 8的TriangleMesh類別建構之Cairo-Tiling Toroid with 16 Faces (Type B),Cairo-Tiling Toroid with 16 Faces (Type B) 屬於Non-Regular Toroidal Solid的一種。

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 *  6.0f;
float C2 = length *  7.0f;
float C3 = length * 14.0f;
float C4 = length * 16.0f;
float C5 = length * 21.0f;
float C6 = length * 28.0f;

// 建立TriangleMesh
TriangleMesh trianglemesh = new TriangleMesh();

// 設定頂點座標
trianglemesh.getPoints().addAll(
   C6,  C6,  C6,
   C6,  C6, -C6,
  -C6, -C6,  C6,
  -C6, -C6, -C6,
   C2,  C2,  C3,
   C2,  C2, -C3,
  -C2, -C2,  C3,
  -C2, -C2, -C3,
   C6,  C2,  C6,
  -C6, -C2,  C6,
   C2,  C6, -C6,
  -C2, -C6, -C6,
   C4, -C2,  C1,
  -C4,  C2,  C1,
   C2, -C4, -C1,
  -C2,  C4, -C1,
   C6, -C5,  C0,
  -C6,  C5,  C0,
   C5, -C6,  C0,
  -C5,  C6,  C0,
   C6, -C6,  C0,
  -C6,  C6,  C0,
   C2, -C2,  C0,
  -C2,  C2,  C0
);

// 設定貼圖座標
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(
  16, 1, 20, 5,  1, 2,  // Yellow
  16, 1,  1, 5,  0, 2,  // Yellow
  16, 1,  0, 5,  8, 2,  // Yellow
  16, 1,  1, 5, 20, 2,  // Yellow
  16, 1,  0, 5,  1, 2,  // Yellow
  16, 1,  8, 5,  0, 2,  // Yellow
  18, 1, 20, 5,  2, 2,  // Yellow
  18, 1,  2, 5,  3, 2,  // Yellow
  18, 1,  3, 5, 11, 2,  // Yellow
  18, 1,  2, 5, 20, 2,  // Yellow
  18, 1,  3, 5,  2, 2,  // Yellow
  18, 1, 11, 5,  3, 2,  // Yellow
   2, 1, 20, 5, 16, 2,  // Yellow
   2, 1, 16, 5, 12, 2,  // Yellow
   2, 1, 12, 5,  9, 2,  // Yellow
   2, 1, 16, 5, 20, 2,  // Yellow
   2, 1, 12, 5, 16, 2,  // Yellow
   2, 1,  9, 5, 12, 2,  // Yellow
   1, 1, 20, 5, 18, 2,  // Yellow
   1, 1, 18, 5, 14, 2,  // Yellow
   1, 1, 14, 5, 10, 2,  // Yellow
   1, 1, 18, 5, 20, 2,  // Yellow
   1, 1, 14, 5, 18, 2,  // Yellow
   1, 1, 10, 5, 14, 2,  // Yellow
  19, 1, 21, 5,  0, 2,  // Yellow
  19, 1,  0, 5,  1, 2,  // Yellow
  19, 1,  1, 5, 10, 2,  // Yellow
  19, 1,  0, 5, 21, 2,  // Yellow
  19, 1,  1, 5,  0, 2,  // Yellow
  19, 1, 10, 5,  1, 2,  // Yellow
  17, 1, 21, 5,  3, 2,  // Yellow
  17, 1,  3, 5,  2, 2,  // Yellow
  17, 1,  2, 5,  9, 2,  // Yellow
  17, 1,  3, 5, 21, 2,  // Yellow
  17, 1,  2, 5,  3, 2,  // Yellow
  17, 1,  9, 5,  2, 2,  // Yellow
   0, 1, 21, 5, 17, 2,  // Yellow
   0, 1, 17, 5, 13, 2,  // Yellow
   0, 1, 13, 5,  8, 2,  // Yellow
   0, 1, 17, 5, 21, 2,  // Yellow
   0, 1, 13, 5, 17, 2,  // Yellow
   0, 1,  8, 5, 13, 2,  // Yellow
   3, 1, 21, 5, 19, 2,  // Yellow
   3, 1, 19, 5, 15, 2,  // Yellow
   3, 1, 15, 5, 11, 2,  // Yellow
   3, 1, 19, 5, 21, 2,  // Yellow
   3, 1, 15, 5, 19, 2,  // Yellow
   3, 1, 11, 5, 15, 2,  // Yellow
  14, 1, 22, 5,  4, 2,  // Yellow
  14, 1,  4, 5,  5, 2,  // Yellow
  14, 1,  5, 5, 10, 2,  // Yellow
  14, 1,  4, 5, 22, 2,  // Yellow
  14, 1,  5, 5,  4, 2,  // Yellow
  14, 1, 10, 5,  5, 2,  // Yellow
  12, 1, 22, 5,  7, 2,  // Yellow
  12, 1,  7, 5,  6, 2,  // Yellow
  12, 1,  6, 5,  9, 2,  // Yellow
  12, 1,  7, 5, 22, 2,  // Yellow
  12, 1,  6, 5,  7, 2,  // Yellow
  12, 1,  9, 5,  6, 2,  // Yellow
   4, 1, 22, 5, 12, 2,  // Yellow
   4, 1, 12, 5, 16, 2,  // Yellow
   4, 1, 16, 5,  8, 2,  // Yellow
   4, 1, 12, 5, 22, 2,  // Yellow
   4, 1, 16, 5, 12, 2,  // Yellow
   4, 1,  8, 5, 16, 2,  // Yellow
   7, 1, 22, 5, 14, 2,  // Yellow
   7, 1, 14, 5, 18, 2,  // Yellow
   7, 1, 18, 5, 11, 2,  // Yellow
   7, 1, 14, 5, 22, 2,  // Yellow
   7, 1, 18, 5, 14, 2,  // Yellow
   7, 1, 11, 5, 18, 2,  // Yellow
  13, 1, 23, 5,  5, 2,  // Yellow
  13, 1,  5, 5,  4, 2,  // Yellow
  13, 1,  4, 5,  8, 2,  // Yellow
  13, 1,  5, 5, 23, 2,  // Yellow
  13, 1,  4, 5,  5, 2,  // Yellow
  13, 1,  8, 5,  4, 2,  // Yellow
  15, 1, 23, 5,  6, 2,  // Yellow
  15, 1,  6, 5,  7, 2,  // Yellow
  15, 1,  7, 5, 11, 2,  // Yellow
  15, 1,  6, 5, 23, 2,  // Yellow
  15, 1,  7, 5,  6, 2,  // Yellow
  15, 1, 11, 5,  7, 2,  // Yellow
   6, 1, 23, 5, 13, 2,  // Yellow
   6, 1, 13, 5, 17, 2,  // Yellow
   6, 1, 17, 5,  9, 2,  // Yellow
   6, 1, 13, 5, 23, 2,  // Yellow
   6, 1, 17, 5, 13, 2,  // Yellow
   6, 1,  9, 5, 17, 2,  // Yellow
   5, 1, 23, 5, 15, 2,  // Yellow
   5, 1, 15, 5, 19, 2,  // Yellow
   5, 1, 19, 5, 10, 2,  // Yellow
   5, 1, 15, 5, 23, 2,  // Yellow
   5, 1, 19, 5, 15, 2,  // Yellow
   5, 1, 10, 5, 19, 2   // Yellow
);   

// 設定各面的平滑參數
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
);

// 建立MeshView
MeshView meshview;

meshview = new MeshView(createMesh(3.5f));
...
【參考資料】

[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

沒有留言:

張貼留言