2017年11月13日 星期一

JavaFX 3D - Heptagonal Dodecahedron (Type E) (Form 4)

以下是以JavaFX 8的TriangleMesh類別建構之Heptagonal Dodecahedron (Type E) (Form 4),Heptagonal Dodecahedron (Type E) (Form 4) 屬於Higher Genus Toroidal Solid的一種。

The Higher Genus Toroidal Solids are a collection of toroidal solids. A toroidal solid is an orientable polyhedron without self-intersections that has genus greater than zero, meaning that it contains one or more holes. An orientable polyhedron's genus (G) is related to the number of vertices (V), faces (F), and edges (E) as:

V + F − E = 2 − 2 * G
float C0  = length *  0.0f;
float C1  = length *  1.0f;
float C2  = length *  2.0f;
float C3  = length *  3.0f;
float C4  = length *  6.0f;
float C5  = length *  8.0f;
float C6  = length *  9.0f;
float C7  = length * 10.0f;
float C8  = length * 12.0f;
float C9  = length * 13.0f;
float C10 = length * 14.0f;
float C11 = length * 20.0f;
float C12 = length * 23.0f;

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

// 設定頂點座標
trianglemesh.getPoints().addAll(
  -C12, -C11,   C0,
   C12, -C11,   C0,
   C12,  C11,   C0,
  -C12,  C11,   C0,
   -C9,   C0,  C11,
    C9,   C0, -C11,
    C9,   C0,  C11,
   -C9,   C0, -C11,
   -C3,  -C7,   C7,
    C3,  -C7,  -C7,
    C3,   C7,   C7,
   -C3,   C7,  -C7,
    C3,  -C2,  -C2,
   -C3,  -C2,   C2,
    C3,   C2,   C2,
   -C3,   C2,  -C2,
    C9,   C5,  -C8,
   -C9,   C5,   C8,
    C9,  -C5,   C8,
   -C9,  -C5,  -C8,
   -C1,  -C2,   C4,
    C1,  -C2,  -C4,
    C1,   C2,   C4,
   -C1,   C2,  -C4,
   -C6,   C4,  C10,
    C6,   C4, -C10,
    C6,  -C4,  C10,
   -C6,  -C4, -C10
);

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

// 建立MeshView
MeshView meshview;

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

[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

JavaFX 3D - Heptagonal Dodecahedron (Type E) (Form 3)

以下是以JavaFX 8的TriangleMesh類別建構之Heptagonal Dodecahedron (Type E) (Form 3),Heptagonal Dodecahedron (Type E) (Form 3) 屬於Higher Genus Toroidal Solid的一種。

The Higher Genus Toroidal Solids are a collection of toroidal solids. A toroidal solid is an orientable polyhedron without self-intersections that has genus greater than zero, meaning that it contains one or more holes. An orientable polyhedron's genus (G) is related to the number of vertices (V), faces (F), and edges (E) as:

V + F − E = 2 − 2 * G
float C0 = length *  0.0f;
float C1 = length *  2.0f;
float C2 = length *  3.0f;
float C3 = length *  4.0f;
float C4 = length *  5.0f;
float C5 = length *  8.0f;
float C6 = length *  9.0f;
float C7 = length * 10.0f;
float C8 = length * 12.0f;
float C9 = length * 14.0f;

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

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

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

// 建立MeshView
MeshView meshview;

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

[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

JavaFX 3D - Heptagonal Dodecahedron (Type E) (Form 2)

以下是以JavaFX 8的TriangleMesh類別建構之Heptagonal Dodecahedron (Type E) (Form 2),Heptagonal Dodecahedron (Type E) (Form 2) 屬於Higher Genus Toroidal Solid的一種。

The Higher Genus Toroidal Solids are a collection of toroidal solids. A toroidal solid is an orientable polyhedron without self-intersections that has genus greater than zero, meaning that it contains one or more holes. An orientable polyhedron's genus (G) is related to the number of vertices (V), faces (F), and edges (E) as:

V + F − E = 2 − 2 * G
float C0  = length *  0.0f;
float C1  = length *  2.0f;
float C2  = length *  3.0f;
float C3  = length *  4.0f;
float C4  = length *  5.0f;
float C5  = length *  6.0f;
float C6  = length *  7.0f;
float C7  = length *  8.0f;
float C8  = length *  9.0f;
float C9  = length * 11.0f;
float C10 = length * 13.0f;
float C11 = length * 16.0f;
float C12 = length * 22.0f;

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

// 設定頂點座標
trianglemesh.getPoints().addAll(
   C10,  C10,  C12,
  -C10, -C10,  C12,
   C10, -C10, -C12,
  -C10,  C10, -C12,
    C9,   C7,  C11,
   -C9,  -C7,  C11,
    C9,  -C7, -C11,
   -C9,   C7, -C11,
    C6,   C3,  C11,
   -C6,  -C3,  C11,
    C6,  -C3, -C11,
   -C6,   C3, -C11,
   -C2,  -C4,   C5,
    C2,   C4,   C5,
    C2,  -C4,  -C5,
   -C2,   C4,  -C5,
   -C4,  -C7,   C3,
    C4,   C7,   C3,
    C4,  -C7,  -C3,
   -C4,   C7,  -C3,
    C4,   C1,   C3,
   -C4,  -C1,   C3,
    C4,  -C1,  -C3,
   -C4,   C1,  -C3,
    C8,   C1,   C0,
   -C8,  -C1,   C0,
    C8,  -C1,   C0,
   -C8,   C1,   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(
   8, 0,  0, 3,  1, 1,  // Red
   8, 0,  1, 3, 26, 1,  // Red
   8, 0, 26, 3,  4, 1,  // Red
   4, 0, 26, 3,  6, 1,  // Red
   6, 0, 26, 3, 18, 1,  // Red
   4, 3, 21, 6,  8, 7,  // Green
   4, 3, 13, 6, 21, 7,  // Green
   4, 3, 17, 6, 13, 7,  // Green
  13, 3, 23, 6, 21, 7,  // Green
  13, 3, 15, 6, 23, 7,  // Green
   8, 1, 27, 5,  0, 2,  // Yellow
   8, 1, 21, 5, 27, 2,  // Yellow
  21, 1, 25, 5, 27, 2,  // Yellow
  21, 1, 16, 5, 25, 2,  // Yellow
  21, 1, 12, 5, 16, 2,  // Yellow
   9, 0,  1, 3,  0, 1,  // Red
   9, 0,  0, 3, 27, 1,  // Red
   9, 0, 27, 3,  5, 1,  // Red
   5, 0, 27, 3,  7, 1,  // Red
   7, 0, 27, 3, 19, 1,  // Red
   5, 3, 20, 6,  9, 7,  // Green
   5, 3, 12, 6, 20, 7,  // Green
   5, 3, 16, 6, 12, 7,  // Green
  12, 3, 22, 6, 20, 7,  // Green
  12, 3, 14, 6, 22, 7,  // Green
   9, 1, 26, 5,  1, 2,  // Yellow
   9, 1, 20, 5, 26, 2,  // Yellow
  20, 1, 24, 5, 26, 2,  // Yellow
  20, 1, 17, 5, 24, 2,  // Yellow
  20, 1, 13, 5, 17, 2,  // Yellow
  10, 0,  2, 3,  3, 1,  // Red
  10, 0,  3, 3, 24, 1,  // Red
  10, 0, 24, 3,  6, 1,  // Red
   6, 0, 24, 3,  4, 1,  // Red
   4, 0, 24, 3, 17, 1,  // Red
   6, 3, 23, 6, 10, 7,  // Green
   6, 3, 14, 6, 23, 7,  // Green
   6, 3, 18, 6, 14, 7,  // Green
  14, 3, 21, 6, 23, 7,  // Green
  14, 3, 12, 6, 21, 7,  // Green
  10, 1, 25, 5,  2, 2,  // Yellow
  10, 1, 23, 5, 25, 2,  // Yellow
  23, 1, 27, 5, 25, 2,  // Yellow
  23, 1, 19, 5, 27, 2,  // Yellow
  23, 1, 15, 5, 19, 2,  // Yellow
  11, 0,  3, 3,  2, 1,  // Red
  11, 0,  2, 3, 25, 1,  // Red
  11, 0, 25, 3,  7, 1,  // Red
   7, 0, 25, 3,  5, 1,  // Red
   5, 0, 25, 3, 16, 1,  // Red
   7, 3, 22, 6, 11, 7,  // Green
   7, 3, 15, 6, 22, 7,  // Green
   7, 3, 19, 6, 15, 7,  // Green
  15, 3, 20, 6, 22, 7,  // Green
  15, 3, 13, 6, 20, 7,  // Green
  11, 1, 24, 5,  3, 2,  // Yellow
  11, 1, 22, 5, 24, 2,  // Yellow
  22, 1, 26, 5, 24, 2,  // Yellow
  22, 1, 18, 5, 26, 2,  // Yellow
  22, 1, 14, 5, 18, 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
);

// 建立MeshView
MeshView meshview;

meshview = new MeshView(createMesh(6.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

JavaFX 3D - Heptagonal Dodecahedron (Type E) (Form 1)

以下是以JavaFX 8的TriangleMesh類別建構之Heptagonal Dodecahedron (Type E) (Form 1),Heptagonal Dodecahedron (Type E) (Form 1) 屬於Higher Genus Toroidal Solid的一種。

The Higher Genus Toroidal Solids are a collection of toroidal solids. A toroidal solid is an orientable polyhedron without self-intersections that has genus greater than zero, meaning that it contains one or more holes. An orientable polyhedron's genus (G) is related to the number of vertices (V), faces (F), and edges (E) as:

V + F − E = 2 − 2 * G
float C0  = length *  0.0f;
float C1  = length *  2.0f;
float C2  = length *  3.0f;
float C3  = length *  4.0f;
float C4  = length *  6.0f;
float C5  = length *  7.0f;
float C6  = length *  8.0f;
float C7  = length * 11.0f;
float C8  = length * 13.0f;
float C9  = length * 16.0f;
float C10 = length * 19.0f;
float C11 = length * 22.0f;
float C12 = length * 26.0f;

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

// 設定頂點座標
trianglemesh.getPoints().addAll(
    C0,  C12,  C11,
    C0, -C12,  C11,
   C12,   C0, -C11,
  -C12,   C0, -C11,
    C2,  C10,   C9,
   -C2, -C10,   C9,
   C10,   C2,  -C9,
  -C10,  -C2,  -C9,
    C2,   C7,   C9,
   -C2,  -C7,   C9,
    C7,   C2,  -C9,
   -C7,  -C2,  -C9,
    C1,  -C6,   C4,
   -C1,   C6,   C4,
    C6,  -C1,  -C4,
   -C6,   C1,  -C4,
    C2,  -C8,   C3,
   -C2,   C8,   C3,
    C8,  -C2,  -C3,
   -C8,   C2,  -C3,
    C2,   C5,   C3,
   -C2,  -C5,   C3,
    C5,   C2,  -C3,
   -C5,  -C2,  -C3,
    C5,   C7,   C0,
   -C5,  -C7,   C0,
    C7,   C5,   C0,
   -C7,  -C5,   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(
   8, 0,  0, 3,  1, 1,  // Red
   8, 0,  1, 3, 26, 1,  // Red
   8, 0, 26, 3,  4, 1,  // Red
   4, 0, 26, 3,  6, 1,  // Red
   6, 0, 26, 3, 18, 1,  // Red
   4, 3, 21, 6,  8, 7,  // Green
   4, 3, 13, 6, 21, 7,  // Green
   4, 3, 17, 6, 13, 7,  // Green
  13, 3, 23, 6, 21, 7,  // Green
  13, 3, 15, 6, 23, 7,  // Green
   8, 1, 27, 5,  0, 2,  // Yellow
   8, 1, 21, 5, 27, 2,  // Yellow
  21, 1, 25, 5, 27, 2,  // Yellow
  21, 1, 16, 5, 25, 2,  // Yellow
  21, 1, 12, 5, 16, 2,  // Yellow
   9, 0,  1, 3,  0, 1,  // Red
   9, 0,  0, 3, 27, 1,  // Red
   9, 0, 27, 3,  5, 1,  // Red
   5, 0, 27, 3,  7, 1,  // Red
   7, 0, 27, 3, 19, 1,  // Red
   5, 3, 20, 6,  9, 7,  // Green
   5, 3, 12, 6, 20, 7,  // Green
   5, 3, 16, 6, 12, 7,  // Green
  12, 3, 22, 6, 20, 7,  // Green
  12, 3, 14, 6, 22, 7,  // Green
   9, 1, 26, 5,  1, 2,  // Yellow
   9, 1, 20, 5, 26, 2,  // Yellow
  20, 1, 24, 5, 26, 2,  // Yellow
  20, 1, 17, 5, 24, 2,  // Yellow
  20, 1, 13, 5, 17, 2,  // Yellow
  10, 0,  2, 3,  3, 1,  // Red
  10, 0,  3, 3, 24, 1,  // Red
  10, 0, 24, 3,  6, 1,  // Red
   6, 0, 24, 3,  4, 1,  // Red
   4, 0, 24, 3, 17, 1,  // Red
   6, 3, 23, 6, 10, 7,  // Green
   6, 3, 14, 6, 23, 7,  // Green
   6, 3, 18, 6, 14, 7,  // Green
  14, 3, 21, 6, 23, 7,  // Green
  14, 3, 12, 6, 21, 7,  // Green
  10, 1, 25, 5,  2, 2,  // Yellow
  10, 1, 23, 5, 25, 2,  // Yellow
  23, 1, 27, 5, 25, 2,  // Yellow
  23, 1, 19, 5, 27, 2,  // Yellow
  23, 1, 15, 5, 19, 2,  // Yellow
  11, 0,  3, 3,  2, 1,  // Red
  11, 0,  2, 3, 25, 1,  // Red
  11, 0, 25, 3,  7, 1,  // Red
   7, 0, 25, 3,  5, 1,  // Red
   5, 0, 25, 3, 16, 1,  // Red
   7, 3, 22, 6, 11, 7,  // Green
   7, 3, 15, 6, 22, 7,  // Green
   7, 3, 19, 6, 15, 7,  // Green
  15, 3, 20, 6, 22, 7,  // Green
  15, 3, 13, 6, 20, 7,  // Green
  11, 1, 24, 5,  3, 2,  // Yellow
  11, 1, 22, 5, 24, 2,  // Yellow
  22, 1, 26, 5, 24, 2,  // Yellow
  22, 1, 18, 5, 26, 2,  // Yellow
  22, 1, 14, 5, 18, 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
);

// 建立MeshView
MeshView meshview;

meshview = new MeshView(createMesh(5.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

JavaFX 3D - Hexagonal Antiprism-Trapezohedron Toroid

以下是以JavaFX 8的TriangleMesh類別建構之Hexagonal Antiprism-Trapezohedron Toroid,Hexagonal Antiprism-Trapezohedron Toroid 屬於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 * (float) Math.sqrt(11.0 * Math.sqrt(3.0) - 19.0) / 2.0f;
float C1 = length * (float) (2.0 * Math.sqrt(2.0) - Math.sqrt(6.0)) / 2.0f;
float C2 = length * (float) (Math.sqrt(6.0) - Math.sqrt(2.0)) / 4.0f;
float C3 = length * (float) Math.sqrt(Math.sqrt(3.0) - 1.0) / 2.0f;
float C4 = length * (float) (Math.sqrt(6.0) - Math.sqrt(2.0)) / 2.0f;
float C5 = length * (float) Math.sqrt(2.0) / 2.0f;
float C6 = length * (float) (Math.sqrt(2.0) + Math.sqrt(6.0)) / 4.0f;

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

// 設定頂點座標
trianglemesh.getPoints().addAll(
   C6, -C2,  C3,
   C6,  C2, -C3,
  -C6,  C2,  C3,
  -C6, -C2, -C3,
   C2, -C6,  C3,
   C2,  C6, -C3,
  -C2,  C6,  C3,
  -C2, -C6, -C3,
   C5,  C5,  C3,
   C5, -C5, -C3,
  -C5, -C5,  C3,
  -C5,  C5, -C3,
   C5,  C1,  C0,
   C5, -C1, -C0,
  -C5, -C1,  C0,
  -C5,  C1, -C0,
   C1,  C5,  C0,
   C1, -C5, -C0,
  -C1, -C5,  C0,
  -C1,  C5, -C0,
   C4, -C4,  C0,
   C4,  C4, -C0,
  -C4,  C4,  C0,
  -C4, -C4, -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(
   0, 1, 12, 5, 13, 2,   // Yellow
   0, 1,  8, 5, 12, 2,   // Yellow
   8, 1, 21, 5, 12, 2,   // Yellow
   1, 1, 13, 5, 12, 2,   // Yellow
   1, 1,  9, 5, 13, 2,   // Yellow
   9, 1, 20, 5, 13, 2,   // Yellow
   2, 1, 14, 5, 15, 2,   // Yellow
   2, 1, 10, 5, 14, 2,   // Yellow
  10, 1, 23, 5, 14, 2,   // Yellow
   3, 1, 15, 5, 14, 2,   // Yellow
   3, 1, 11, 5, 15, 2,   // Yellow
  11, 1, 22, 5, 15, 2,   // Yellow
   4, 1, 20, 5, 17, 2,   // Yellow
   4, 1,  0, 5, 20, 2,   // Yellow
   0, 1, 13, 5, 20, 2,   // Yellow
   5, 1, 21, 5, 16, 2,   // Yellow
   5, 1,  1, 5, 21, 2,   // Yellow
   1, 1, 12, 5, 21, 2,   // Yellow
   6, 1, 22, 5, 19, 2,   // Yellow
   6, 1,  2, 5, 22, 2,   // Yellow
   2, 1, 15, 5, 22, 2,   // Yellow
   7, 1, 23, 5, 18, 2,   // Yellow
   7, 1,  3, 5, 23, 2,   // Yellow
   3, 1, 14, 5, 23, 2,   // Yellow
   8, 1, 16, 5, 21, 2,   // Yellow
   8, 1,  6, 5, 16, 2,   // Yellow
   6, 1, 19, 5, 16, 2,   // Yellow
   9, 1, 17, 5, 20, 2,   // Yellow
   9, 1,  7, 5, 17, 2,   // Yellow
   7, 1, 18, 5, 17, 2,   // Yellow
  10, 1, 18, 5, 23, 2,   // Yellow
  10, 1,  4, 5, 18, 2,   // Yellow
   4, 1, 17, 5, 18, 2,   // Yellow
  11, 1, 19, 5, 22, 2,   // Yellow
  11, 1,  5, 5, 19, 2,   // Yellow
   5, 1, 16, 5, 19, 2,   // Yellow
   0, 0,  4, 3,  9, 1,   // Red
   0, 0,  9, 3,  1, 1,   // Red
   2, 0,  6, 3, 11, 1,   // Red
   2, 0, 11, 3,  3, 1,   // Red
   4, 0, 10, 3,  7, 1,   // Red
   4, 0,  7, 3,  9, 1,   // Red
   6, 0,  8, 3,  5, 1,   // Red
   6, 0,  5, 3, 11, 1,   // Red
   8, 0,  0, 3,  1, 1,   // Red
   8, 0,  1, 3,  5, 1,   // Red
  10, 0,  2, 3,  3, 1,   // Red
  10, 0,  3, 3,  7, 1    // Red
);   

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

// 建立MeshView
MeshView meshview;

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

[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

JavaFX 3D - Pentagonal Antiprism-Trapezohedron Toroid

以下是以JavaFX 8的TriangleMesh類別建構之Pentagonal Antiprism-Trapezohedron Toroid,Pentagonal Antiprism-Trapezohedron Toroid 屬於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 * 0.5f;
float C2 = length * (float) (3.0 - Math.sqrt(5.0)) / 4.0f;
float C3 = length * (float) (Math.sqrt(5.0) - 1.0) / 4.0f;
float C4 = length * (float) (1.0 + Math.sqrt(5.0)) / 4.0f;

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

// 設定頂點座標
trianglemesh.getPoints().addAll(
   C1,  C0,  C4,
   C1,  C0, -C4,
  -C1,  C0,  C4,
  -C1,  C0, -C4,
   C0,  C4,  C1,
   C0,  C4, -C1,
   C0, -C4,  C1,
   C0, -C4, -C1,
   C4,  C1,  C0,
  -C4, -C1,  C0,
   C0,  C2,  C1,
   C0,  C2, -C1,
   C0, -C2,  C1,
   C0, -C2, -C1,
   C3,  C3,  C3,
   C3,  C3, -C3,
  -C3, -C3,  C3,
  -C3, -C3, -C3,
   C2,  C1,  C0,
  -C2, -C1,  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(
  0, 1, 12, 5, 10, 2,   // Yellow
  0, 1,  6, 5, 12, 2,   // Yellow
  6, 1, 16, 5, 12, 2,   // Yellow
  1, 1, 15, 5, 11, 2,   // Yellow
  1, 1,  8, 5, 15, 2,   // Yellow
  8, 1, 18, 5, 15, 2,   // Yellow
  2, 1, 10, 5, 12, 2,   // Yellow
  2, 1,  4, 5, 10, 2,   // Yellow
  4, 1, 14, 5, 10, 2,   // Yellow
  3, 1, 17, 5, 13, 2,   // Yellow
  3, 1,  9, 5, 17, 2,   // Yellow
  9, 1, 19, 5, 17, 2,   // Yellow
  4, 1, 18, 5, 14, 2,   // Yellow
  4, 1,  5, 5, 18, 2,   // Yellow
  5, 1, 15, 5, 18, 2,   // Yellow
  5, 1, 11, 5, 15, 2,   // Yellow
  5, 1,  3, 5, 11, 2,   // Yellow
  3, 1, 13, 5, 11, 2,   // Yellow
  6, 1, 19, 5, 16, 2,   // Yellow
  6, 1,  7, 5, 19, 2,   // Yellow
  7, 1, 17, 5, 19, 2,   // Yellow
  7, 1, 13, 5, 17, 2,   // Yellow
  7, 1,  1, 5, 13, 2,   // Yellow
  1, 1, 11, 5, 13, 2,   // Yellow
  8, 1, 14, 5, 18, 2,   // Yellow
  8, 1,  0, 5, 14, 2,   // Yellow
  0, 1, 10, 5, 14, 2,   // Yellow
  9, 1, 16, 5, 19, 2,   // Yellow
  9, 1,  2, 5, 16, 2,   // Yellow
  2, 1, 12, 5, 16, 2,   // Yellow
  2, 0,  6, 3,  0, 1,   // Red
  2, 0,  0, 3,  4, 1,   // Red
  3, 0,  1, 3,  7, 1,   // Red
  3, 0,  7, 3,  9, 1,   // Red
  4, 0,  0, 3,  8, 1,   // Red
  4, 0,  8, 3,  5, 1,   // Red
  5, 0,  8, 3,  1, 1,   // Red
  5, 0,  1, 3,  3, 1,   // Red
  6, 0,  2, 3,  9, 1,   // Red
  6, 0,  9, 3,  7, 1    // Red
);   

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

// 建立MeshView
MeshView meshview;

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

[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

JavaFX 3D - Square Antiprism-Trapezohedron Toroid

以下是以JavaFX 8的TriangleMesh類別建構之Square Antiprism-Trapezohedron Toroid,Square Antiprism-Trapezohedron Toroid 屬於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 * (float) Math.sqrt(2.0 * (17.0 * Math.sqrt(2.0) - 24.0)) / 4.0f;
float C1 = length * (float) Math.sqrt(2.0 * (10.0 - 7.0 * Math.sqrt(2.0))) / 4.0f;
float C2 = length * (float) Math.sqrt(2.0 * (2.0 - Math.sqrt(2.0))) / 4.0f;
float C3 = length * (float) Math.sqrt(2.0 * Math.sqrt(2.0)) / 4.0f;
float C4 = length * (float) Math.sqrt(2.0 * (2.0 + Math.sqrt(2.0))) / 4.0f;

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

// 設定頂點座標
trianglemesh.getPoints().addAll(
   C4,  C2,  C3,
   C4, -C2, -C3,
  -C4, -C2,  C3,
  -C4,  C2, -C3,
   C2, -C4,  C3,
   C2,  C4, -C3,
  -C2,  C4,  C3,
  -C2, -C4, -C3,
   C2, -C1,  C0,
   C2,  C1, -C0,
  -C2,  C1,  C0,
  -C2, -C1, -C0,
   C1,  C2,  C0,
   C1, -C2, -C0,
  -C1, -C2,  C0,
  -C1,  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(
   0, 1, 12, 5,  9, 2,   // Yellow
   0, 1,  6, 5, 12, 2,   // Yellow
   6, 1, 15, 5, 12, 2,   // Yellow
   0, 1,  9, 5,  8, 2,   // Yellow
   0, 1,  8, 5,  4, 2,   // Yellow
   8, 1, 13, 5,  4, 2,   // Yellow
   1, 1, 13, 5,  8, 2,   // Yellow
   1, 1,  7, 5, 13, 2,   // Yellow
   7, 1, 14, 5, 13, 2,   // Yellow
   1, 1,  8, 5,  9, 2,   // Yellow
   1, 1,  9, 5,  5, 2,   // Yellow
   9, 1, 12, 5,  5, 2,   // Yellow
   2, 1, 14, 5, 11, 2,   // Yellow
   2, 1,  4, 5, 14, 2,   // Yellow
   4, 1, 13, 5, 14, 2,   // Yellow
   2, 1, 11, 5, 10, 2,   // Yellow
   2, 1, 10, 5,  6, 2,   // Yellow
  10, 1, 15, 5,  6, 2,   // Yellow
   3, 1, 15, 5, 10, 2,   // Yellow
   3, 1,  5, 5, 15, 2,   // Yellow
   5, 1, 12, 5, 15, 2,   // Yellow
   3, 1, 10, 5, 11, 2,   // Yellow
   3, 1, 11, 5,  7, 2,   // Yellow
  11, 1, 14, 5,  7, 2,   // Yellow
   0, 0,  4, 3,  1, 1,   // Red
   0, 0,  1, 3,  5, 1,   // Red
   2, 0,  6, 3,  3, 1,   // Red
   2, 0,  3, 3,  7, 1,   // Red
   4, 0,  2, 3,  7, 1,   // Red
   4, 0,  7, 3,  1, 1,   // Red
   6, 0,  0, 3,  5, 1,   // Red
   6, 0,  5, 3,  3, 1    // Red
);   

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

// 建立MeshView
MeshView meshview;

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

[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

JavaFX 3D - Hexagonal Trapezohedron-Antiprism Toroid

以下是以JavaFX 8的TriangleMesh類別建構之Hexagonal Trapezohedron-Antiprism Toroid,Hexagonal Trapezohedron-Antiprism Toroid 屬於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 * 1.0f;
float C2 = length * 2.0f;
float C3 = length * (float) Math.sqrt(787.0 * Math.sqrt(3.0) - 1363.0);
float C4 = length * (float) Math.sqrt(Math.sqrt(3.0) - 1.0);
float C5 = length * (float) (7.0 * Math.sqrt(3.0) - 11.0);
float C6 = length * (float) Math.sqrt(3.0);
float C7 = length * (float) (21.0 - 11.0 * Math.sqrt(3.0));
float C8 = length * (float) (2.0 * (7.0 * Math.sqrt(3.0) - 11.0));

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

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

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

// 建立MeshView
MeshView meshview;

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

[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

JavaFX 3D - Pentagonal Trapezohedron-Antiprism Toroid

以下是以JavaFX 8的TriangleMesh類別建構之Pentagonal Trapezohedron-Antiprism Toroid,Pentagonal Trapezohedron-Antiprism Toroid 屬於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 * 1.0f;
float C2 = length * 2.0f;
float C3 = length * (float) (Math.sqrt(5.0) - 2.0f);
float C4 = length * (float) (Math.sqrt(5.0) - 1.0) / 2.0f;
float C5 = length * (float) (Math.sqrt(5.0) - 1.0f);
float C6 = length * (float) (5.0 - Math.sqrt(5.0)) / 2.0f;
float C7 = length * (float) (1.0 + Math.sqrt(5.0)) / 2.0f;
float C8 = length * (float) (Math.sqrt(5.0));
float C9 = length * (float) (3.0 + Math.sqrt(5.0)) / 2.0f;

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

// 設定頂點座標
trianglemesh.getPoints().addAll(
   C4, -C5,  C8,
   C4, -C5, -C8,
  -C4,  C5,  C8,
  -C4,  C5, -C8,
  -C2, -C1,  C6,
  -C2, -C1, -C6,
   C2,  C1,  C6,
   C2,  C1, -C6,
  -C3, -C9,  C0,
   C3,  C9,  C0,
   C0, -C1,  C9,
   C0, -C1, -C9,
   C0,  C1,  C9,
   C0,  C1, -C9,
  -C7, -C7,  C7,
  -C7, -C7, -C7,
   C7,  C7,  C7,
   C7,  C7, -C7,
  -C1, -C9,  C0,
   C1,  C9,  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(
   0, 0, 12, 3, 10, 1,   // Red
   0, 0, 16, 3, 12, 1,   // Red
   0, 0,  6, 3, 16, 1,   // Red
   1, 0, 15, 3, 11, 1,   // Red
   1, 0, 18, 3, 15, 1,   // Red
   1, 0,  8, 3, 18, 1,   // Red
   2, 0, 10, 3, 12, 1,   // Red
   2, 0, 14, 3, 10, 1,   // Red
   2, 0,  4, 3, 14, 1,   // Red
   3, 0, 17, 3, 13, 1,   // Red
   3, 0, 19, 3, 17, 1,   // Red
   3, 0,  9, 3, 19, 1,   // Red
   4, 0, 18, 3, 14, 1,   // Red
   4, 0, 15, 3, 18, 1,   // Red
   4, 0,  5, 3, 15, 1,   // Red
   5, 0, 11, 3, 15, 1,   // Red
   5, 0, 13, 3, 11, 1,   // Red
   5, 0,  3, 3, 13, 1,   // Red
   6, 0, 19, 3, 16, 1,   // Red
   6, 0, 17, 3, 19, 1,   // Red
   6, 0,  7, 3, 17, 1,   // Red
   7, 0, 13, 3, 17, 1,   // Red
   7, 0, 11, 3, 13, 1,   // Red
   7, 0,  1, 3, 11, 1,   // Red
   8, 0, 14, 3, 18, 1,   // Red
   8, 0, 10, 3, 14, 1,   // Red
   8, 0,  0, 3, 10, 1,   // Red
   9, 0, 16, 3, 19, 1,   // Red
   9, 0, 12, 3, 16, 1,   // Red
   9, 0,  2, 3, 12, 1,   // Red
   2, 1,  6, 5,  0, 2,  // Yellow
   2, 1,  0, 5,  4, 2,  // Yellow
   3, 1,  1, 5,  7, 2,  // Yellow
   3, 1,  7, 5,  9, 2,  // Yellow
   4, 1,  0, 5,  8, 2,  // Yellow
   4, 1,  8, 5,  5, 2,  // Yellow
   5, 1,  8, 5,  1, 2,  // Yellow
   5, 1,  1, 5,  3, 2,  // Yellow
   6, 1,  2, 5,  9, 2,  // Yellow
   6, 1,  9, 5,  7, 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
);

// 建立MeshView
MeshView meshview;

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

[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

JavaFX 3D - Tetragonal Trapezohedron-Antiprism Toroid

以下是以JavaFX 8的TriangleMesh類別建構之Tetragonal Trapezohedron-Antiprism Toroid,Tetragonal Trapezohedron-Antiprism Toroid 屬於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 * (float) (3.0 * Math.sqrt(2.0 * (2.0 - Math.sqrt(2.0)))) / 4.0f;
float C2 = length * (float) (Math.sqrt(2.0 * (10.0 + 7.0 * Math.sqrt(2.0)))) / 4.0f;
float C3 = length * (float) (Math.sqrt(7.0 + 5.0 * Math.sqrt(2.0))) / 2.0f;
float C4 = length * (float) (3.0 * Math.sqrt(1.0 + Math.sqrt(2.0))) / 2.0f;
float C5 = length * (float) (Math.sqrt(2.0 * (7.0 + 5.0 * Math.sqrt(2.0)))) / 2.0f;
float C6 = length * (float) (3.0 * Math.sqrt(2.0 * (1.0 + Math.sqrt(2.0)))) / 2.0f;

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

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

// 設定貼圖座標
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, 0, 12, 3,  9, 1,   // Red
  0, 0, 15, 3, 12, 1,   // Red
  0, 0,  6, 3, 15, 1,   // Red
  0, 0, 13, 3,  4, 1,   // Red
  0, 0,  8, 3, 13, 1,   // Red
  0, 0,  9, 3,  8, 1,   // Red
  1, 0, 13, 3,  8, 1,   // Red
  1, 0, 14, 3, 13, 1,   // Red
  1, 0,  7, 3, 14, 1,   // Red
  1, 0, 12, 3,  5, 1,   // Red
  1, 0,  9, 3, 12, 1,   // Red
  1, 0,  8, 3,  9, 1,   // Red
  2, 0, 14, 3, 11, 1,   // Red
  2, 0, 13, 3, 14, 1,   // Red
  2, 0,  4, 3, 13, 1,   // Red
  2, 0, 15, 3,  6, 1,   // Red
  2, 0, 10, 3, 15, 1,   // Red
  2, 0, 11, 3, 10, 1,   // Red
  3, 0, 15, 3, 10, 1,   // Red
  3, 0, 12, 3, 15, 1,   // Red
  3, 0,  5, 3, 12, 1,   // Red
  3, 0, 14, 3,  7, 1,   // Red
  3, 0, 11, 3, 14, 1,   // Red
  3, 0, 10, 3, 11, 1,   // Red
  0, 1,  4, 5,  1, 2,   // Yellow
  0, 1,  1, 5,  5, 2,   // Yellow
  2, 1,  6, 5,  3, 2,   // Yellow
  2, 1,  3, 5,  7, 2,   // Yellow
  4, 1,  2, 5,  7, 2,   // Yellow
  4, 1,  7, 5,  1, 2,   // Yellow
  6, 1,  0, 5,  5, 2,   // Yellow
  6, 1,  5, 5,  3, 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
);

// 建立MeshView
MeshView meshview;

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

[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

2017年11月11日 星期六

JavaFX 3D - Cube-Octahedron Toroid

以下是以JavaFX 8的TriangleMesh類別建構之Cube-Octahedron Toroid,Cube-Octahedron Toroid 屬於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 * 1.0f;
float C1 = length * 2.0f;

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

// 設定頂點座標
trianglemesh.getPoints().addAll(
   C1,  C1,  C1,
   C1,  C1, -C1,
  -C1, -C1,  C1,
  -C1, -C1, -C1,
   C1, -C1,  C1,
  -C1,  C1, -C1,
   C1, -C1,  C0,
  -C1,  C1, -C0,
   C0,  C1,  C1,
  -C0, -C1, -C1,
  -C1, -C0,  C1,
   C1,  C0, -C1
);

// 設定貼圖座標
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, 0, 11, 3,  1, 1,   // Red
   0, 0,  6, 3, 11, 1,   // Red
   0, 0,  4, 3,  6, 1,   // Red
   1, 0,  8, 3,  0, 1,   // Red
   1, 0,  7, 3,  8, 1,   // Red
   1, 0,  5, 3,  7, 1,   // Red
   2, 0,  6, 3,  4, 1,   // Red
   2, 0,  9, 3,  6, 1,   // Red
   2, 0,  3, 3,  9, 1,   // Red
   3, 0,  7, 3,  5, 1,   // Red
   3, 0, 10, 3,  7, 1,   // Red
   3, 0,  2, 3, 10, 1,   // Red
   4, 0, 10, 3,  2, 1,   // Red
   4, 0,  8, 3, 10, 1,   // Red
   4, 0,  0, 3,  8, 1,   // Red
   5, 0,  9, 3,  3, 1,   // Red
   5, 0, 11, 3,  9, 1,   // Red
   5, 0,  1, 3, 11, 1,   // Red
   6, 1,  9, 5, 10, 2,   // Yellow
   7, 1, 10, 5,  9, 2,   // Yellow
   8, 1,  7, 5, 11, 2,   // Yellow
   9, 1, 11, 5,  7, 2,   // Yellow
  10, 1,  8, 5,  6, 2,   // Yellow
  11, 1,  6, 5,  8, 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
);

// 建立MeshView
MeshView meshview;

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

[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

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

以下是以JavaFX 8的TriangleMesh類別建構之Cairo-Tiling Toroid with 16 Faces (Type C),Cairo-Tiling Toroid with 16 Faces (Type C) 屬於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 *  2.0f;
float C2 = length *  3.0f;
float C3 = length *  4.0f;
float C4 = length *  5.0f;
float C5 = length *  6.0f;
float C6 = length *  7.0f;
float C7 = length *  9.0f;
float C8 = length * 11.0f;

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

// 設定頂點座標
trianglemesh.getPoints().addAll(
   C5,  C0,  C5,
  -C5,  C0, -C5,
   C2,  C0, -C2,
  -C2,  C0,  C2,
  -C2, -C2,  C7,
   C7,  C2, -C2,
  -C7,  C2,  C2,
   C2, -C2, -C7,
  -C3, -C1,  C3,
   C3,  C1, -C3,
  -C3,  C1,  C3,
   C3, -C1, -C3,
  -C2, -C2, -C2,
  -C2,  C2, -C2,
   C2,  C2,  C2,
   C2, -C2,  C2,
   C6, -C4,  C8,
   C8,  C4,  C6,
  -C8,  C4, -C6,
  -C6, -C4, -C8,
   C5,  C0, -C2,
  -C2,  C0,  C5,
   C2,  C0, -C5,
  -C5,  C0,  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(
  10, 1,  4, 5, 21, 2,  // Yellow
  10, 1, 21, 5, 16, 2,  // Yellow
  10, 1, 16, 5,  0, 2,  // Yellow
  10, 1, 21, 5,  4, 2,  // Yellow
  10, 1, 16, 5, 21, 2,  // Yellow
  10, 1,  0, 5, 16, 2,  // Yellow
  11, 1,  5, 5, 20, 2,  // Yellow
  11, 1, 20, 5, 17, 2,  // Yellow
  11, 1, 17, 5,  0, 2,  // Yellow
  11, 1, 20, 5,  5, 2,  // Yellow
  11, 1, 17, 5, 20, 2,  // Yellow
  11, 1,  0, 5, 17, 2,  // Yellow
  17, 1,  6, 5,  8, 2,  // Yellow
  17, 1,  8, 5, 10, 2,  // Yellow
  17, 1, 10, 5,  0, 2,  // Yellow
  17, 1,  8, 5,  6, 2,  // Yellow
  17, 1, 10, 5,  8, 2,  // Yellow
  17, 1,  0, 5, 10, 2,  // Yellow
  11, 1,  0, 5, 16, 2,  // Yellow
  11, 1, 16, 5,  7, 2,  // Yellow
  11, 1,  7, 5,  9, 2,  // Yellow
  11, 1, 16, 5,  0, 2,  // Yellow
  11, 1,  7, 5, 16, 2,  // Yellow
  11, 1,  9, 5,  7, 2,  // Yellow
   8, 1,  1, 5, 19, 2,  // Yellow
   8, 1, 19, 5,  4, 2,  // Yellow
   8, 1,  4, 5, 10, 2,  // Yellow
   8, 1, 19, 5,  1, 2,  // Yellow
   8, 1,  4, 5, 19, 2,  // Yellow
   8, 1, 10, 5,  4, 2,  // Yellow
   9, 1,  1, 5, 18, 2,  // Yellow
   9, 1, 18, 5,  5, 2,  // Yellow
   9, 1,  5, 5, 11, 2,  // Yellow
   9, 1, 18, 5,  1, 2,  // Yellow
   9, 1,  5, 5, 18, 2,  // Yellow
   9, 1, 11, 5,  5, 2,  // Yellow
   8, 1,  6, 5, 23, 2,  // Yellow
   8, 1, 23, 5, 18, 2,  // Yellow
   8, 1, 18, 5,  1, 2,  // Yellow
   8, 1, 23, 5,  6, 2,  // Yellow
   8, 1, 18, 5, 23, 2,  // Yellow
   8, 1,  1, 5, 18, 2,  // Yellow
   9, 1,  7, 5, 22, 2,  // Yellow
   9, 1, 22, 5, 19, 2,  // Yellow
   9, 1, 19, 5,  1, 2,  // Yellow
   9, 1, 22, 5,  7, 2,  // Yellow
   9, 1, 19, 5, 22, 2,  // Yellow
   9, 1,  1, 5, 19, 2,  // Yellow
  12, 1,  4, 5, 19, 2,  // Yellow
  12, 1, 19, 5, 22, 2,  // Yellow
  12, 1, 22, 5,  2, 2,  // Yellow
  12, 1, 19, 5,  4, 2,  // Yellow
  12, 1, 22, 5, 19, 2,  // Yellow
  12, 1,  2, 5, 22, 2,  // Yellow
   2, 1, 20, 5,  5, 2,  // Yellow
   2, 1,  5, 5, 13, 2,  // Yellow
   2, 1, 13, 5, 12, 2,  // Yellow
   2, 1,  5, 5, 20, 2,  // Yellow
   2, 1, 13, 5,  5, 2,  // Yellow
   2, 1, 12, 5, 13, 2,  // Yellow
  14, 1,  6, 5, 17, 2,  // Yellow
  14, 1, 17, 5, 20, 2,  // Yellow
  14, 1, 20, 5,  2, 2,  // Yellow
  14, 1, 17, 5,  6, 2,  // Yellow
  14, 1, 20, 5, 17, 2,  // Yellow
  14, 1,  2, 5, 20, 2,  // Yellow
   2, 1, 22, 5,  7, 2,  // Yellow
   2, 1,  7, 5, 15, 2,  // Yellow
   2, 1, 15, 5, 14, 2,  // Yellow
   2, 1,  7, 5, 22, 2,  // Yellow
   2, 1, 15, 5,  7, 2,  // Yellow
   2, 1, 14, 5, 15, 2,  // Yellow
   3, 1, 21, 5,  4, 2,  // Yellow
   3, 1,  4, 5, 12, 2,  // Yellow
   3, 1, 12, 5, 13, 2,  // Yellow
   3, 1,  4, 5, 21, 2,  // Yellow
   3, 1, 12, 5,  4, 2,  // Yellow
   3, 1, 13, 5, 12, 2,  // Yellow
  13, 1,  5, 5, 18, 2,  // Yellow
  13, 1, 18, 5, 23, 2,  // Yellow
  13, 1, 23, 5,  3, 2,  // Yellow
  13, 1, 18, 5,  5, 2,  // Yellow
  13, 1, 23, 5, 18, 2,  // Yellow
  13, 1,  3, 5, 23, 2,  // Yellow
   3, 1, 23, 5,  6, 2,  // Yellow
   3, 1,  6, 5, 14, 2,  // Yellow
   3, 1, 14, 5, 15, 2,  // Yellow
   3, 1,  6, 5, 23, 2,  // Yellow
   3, 1, 14, 5,  6, 2,  // Yellow
   3, 1, 15, 5, 14, 2,  // Yellow
  15, 1,  7, 5, 16, 2,  // Yellow
  15, 1, 16, 5, 21, 2,  // Yellow
  15, 1, 21, 5,  3, 2,  // Yellow
  15, 1, 16, 5,  7, 2,  // Yellow
  15, 1, 21, 5, 16, 2,  // Yellow
  15, 1,  3, 5, 21, 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(13.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

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

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

以下是以JavaFX 8的TriangleMesh類別建構之Cairo-Tiling Toroid with 16 Faces (Type A),Cairo-Tiling Toroid with 16 Faces (Type A) 屬於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 *  4.0f;
float C2 = length *  6.0f;
float C3 = length *  7.0f;
float C4 = length *  8.0f;
float C5 = length * 12.0f;
float C6 = length * 20.0f;

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

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

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

[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

JavaFX 3D - Cairo-Tiling Toroid with 8 Overarching Faces

以下是以JavaFX 8的TriangleMesh類別建構之Cairo-Tiling Toroid with 8 Overarching Faces,Cairo-Tiling Toroid with 8 Overarching Faces屬於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 * 1.0f;
float C2 = length * 2.0f;
float C3 = length * 4.0f;
float C4 = length * 6.0f;

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

// 設定頂點座標
trianglemesh.getPoints().addAll(
   C4,  C4,  C4,
   C4, -C4, -C4,
  -C4, -C4,  C4,
  -C4,  C4, -C4,
   C3,  C0, -C2,
  -C3,  C0, -C2,
   C0,  C3, -C2,
   C0, -C3, -C2,
   C1, -C1,  C2,
  -C1,  C1,  C2,
   C1,  C1,  C0,
  -C1, -C1,  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(
   8, 0,  4, 3,  0, 1,  // Red
   8, 0,  0, 3,  2, 1,  // Red
   8, 0,  2, 3,  7, 1,  // Red
   8, 0,  0, 3,  4, 1,  // Red
   8, 0,  2, 3,  0, 1,  // Red
   8, 0,  7, 3,  2, 1,  // Red
  10, 3,  4, 6,  8, 7,  // Green
  10, 3,  8, 6,  9, 7,  // Green
  10, 3,  9, 6,  6, 7,  // Green
  10, 3,  8, 6,  4, 7,  // Green
  10, 3,  9, 6,  8, 7,  // Green
  10, 3,  6, 6,  9, 7,  // Green
   1, 7,  4, 8, 10, 5,  // Blue
   1, 7, 10, 8, 11, 5,  // Blue
   1, 7, 11, 8,  7, 5,  // Blue
   1, 7, 10, 8,  4, 5,  // Blue
   1, 7, 11, 8, 10, 5,  // Blue
   1, 7,  7, 8, 11, 5,  // Blue
   4, 1,  6, 5,  0, 2,  // Yellow
   4, 1,  3, 5,  6, 2,  // Yellow
   4, 1,  1, 5,  3, 2,  // Yellow
   4, 1,  0, 5,  6, 2,  // Yellow
   4, 1,  6, 5,  3, 2,  // Yellow
   4, 1,  3, 5,  1, 2,  // Yellow
   9, 0,  5, 3,  2, 1,  // Red
   9, 0,  2, 3,  0, 1,  // Red
   9, 0,  0, 3,  6, 1,  // Red
   9, 0,  2, 3,  5, 1,  // Red
   9, 0,  0, 3,  2, 1,  // Red
   9, 0,  6, 3,  0, 1,  // Red
  11, 3,  5, 6,  9, 7,  // Green
  11, 3,  9, 6,  8, 7,  // Green
  11, 3,  8, 6,  7, 7,  // Green
  11, 3,  9, 6,  5, 7,  // Green
  11, 3,  8, 6,  9, 7,  // Green
  11, 3,  7, 6,  8, 7,  // Green
   3, 7,  5, 8, 11, 5,  // Blue
   3, 7, 11, 8, 10, 5,  // Blue
   3, 7, 10, 8,  6, 5,  // Blue
   3, 7, 11, 8,  5, 5,  // Blue
   3, 7, 10, 8, 11, 5,  // Blue
   3, 7,  6, 8, 10, 5,  // Blue
   5, 1,  7, 5,  2, 2,  // Yellow
   5, 1,  1, 5,  7, 2,  // Yellow
   5, 1,  3, 5,  1, 2,  // Yellow
   5, 1,  2, 5,  7, 2,  // Yellow
   5, 1,  7, 5,  1, 2,  // Yellow
   5, 1,  1, 5,  3, 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
);

// 建立MeshView
MeshView meshview;

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

[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

JavaFX 3D - Knotted Dodecahedron

以下是以JavaFX 8的TriangleMesh類別建構之Knotted Dodecahedron,Knotted Dodecahedron屬於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 *  4.0f;
float C1 = length *  5.0f;
float C2 = length *  8.0f;
float C3 = length * 28.0f;
float C4 = length * 44.0f;
float C5 = length * 47.0f;

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

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

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

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

// 建立MeshView
MeshView meshview;

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

[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

JavaFX 3D - Toroid with Regular Faces

以下是以JavaFX 8的TriangleMesh類別建構之Toroid with Regular Faces,Toroid with Regular Faces屬於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 * (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