2017年11月9日 星期四

JavaFX 3D - Klein Map {7,3}

以下是以JavaFX 8的TriangleMesh類別建構之Klein Map {7,3}8,屬於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 *   57.0f;
float C1 = length *  141.0f;
float C2 = length *  209.0f;
float C3 = length *  342.0f;
float C4 = length *  513.0f;
float C5 = length *  549.0f;
float C6 = length *  855.0f;
float C7 = length * 1539.0f;
float C8 = length * 2337.0f;

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

// 設定頂點座標
trianglemesh.getPoints().addAll(
   C4, -C4,  C8,
   C4,  C4, -C8,
  -C4,  C4,  C8,
  -C4, -C4, -C8,
   C8, -C4,  C4,
   C8,  C4, -C4,
  -C8,  C4,  C4,
  -C8, -C4, -C4,
   C4, -C8,  C4,
   C4,  C8, -C4,
  -C4,  C8,  C4,
  -C4, -C8, -C4,
   C8, -C8,  C8,
   C8,  C8, -C8,
  -C8,  C8,  C8,
  -C8, -C8, -C8,
   C3,  C0,  C7,
   C3, -C0, -C7,
  -C3, -C0,  C7,
  -C3,  C0, -C7,
   C7,  C3,  C0,
   C7, -C3, -C0,
  -C7, -C3,  C0,
  -C7,  C3, -C0,
   C0,  C7,  C3,
   C0, -C7, -C3,
  -C0, -C7,  C3,
  -C0,  C7, -C3,
   C2,  C2,  C6,
   C2, -C2, -C6,
  -C2, -C2,  C6,
  -C2,  C2, -C6,
   C6,  C2,  C2,
   C6, -C2, -C2,
  -C6, -C2,  C2,
  -C6,  C2, -C2,
   C2,  C6,  C2,
   C2, -C6, -C2,
  -C2, -C6,  C2,
  -C2,  C6, -C2,
   C5,  C1,  C5,
   C5, -C1, -C5,
  -C5, -C1,  C5,
  -C5,  C1, -C5,
   C5,  C5,  C1,
   C5, -C5, -C1,
  -C5, -C5,  C1,
  -C5,  C5, -C1,
   C1,  C5,  C5,
   C1, -C5, -C5,
  -C1, -C5,  C5,
  -C1,  C5, -C5,
   C3, -C3,  C3,
   C3,  C3, -C3,
  -C3,  C3,  C3,
  -C3, -C3, -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(
  12, 1, 16, 5, 42, 2,  // Yellow
  12, 1, 42, 5, 30, 2,  // Yellow
  12, 1, 30, 5, 11, 2,  // Yellow
  12, 1, 11, 5,  8, 2,  // Yellow
  12, 1, 26, 5, 49, 2,  // Yellow
  12, 1, 49, 5, 37, 2,  // Yellow
  12, 1, 37, 5,  5, 2,  // Yellow
  12, 1,  5, 5,  4, 2,  // Yellow
  12, 1, 21, 5, 44, 2,  // Yellow
  12, 1, 44, 5, 32, 2,  // Yellow
  12, 1, 32, 5,  2, 2,  // Yellow
  12, 1,  2, 5,  0, 2,  // Yellow
  13, 1, 17, 5, 43, 2,  // Yellow
  13, 1, 43, 5, 31, 2,  // Yellow
  13, 1, 31, 5, 10, 2,  // Yellow
  13, 1, 10, 5,  9, 2,  // Yellow
  13, 1, 27, 5, 48, 2,  // Yellow
  13, 1, 48, 5, 36, 2,  // Yellow
  13, 1, 36, 5,  4, 2,  // Yellow
  13, 1,  4, 5,  5, 2,  // Yellow
  13, 1, 20, 5, 45, 2,  // Yellow
  13, 1, 45, 5, 33, 2,  // Yellow
  13, 1, 33, 5,  3, 2,  // Yellow
  13, 1,  3, 5,  1, 2,  // Yellow
  14, 1, 18, 5, 40, 2,  // Yellow
  14, 1, 40, 5, 28, 2,  // Yellow
  14, 1, 28, 5,  9, 2,  // Yellow
  14, 1,  9, 5, 10, 2,  // Yellow
  14, 1, 24, 5, 51, 2,  // Yellow
  14, 1, 51, 5, 39, 2,  // Yellow
  14, 1, 39, 5,  7, 2,  // Yellow
  14, 1,  7, 5,  6, 2,  // Yellow
  14, 1, 23, 5, 46, 2,  // Yellow
  14, 1, 46, 5, 34, 2,  // Yellow
  14, 1, 34, 5,  0, 2,  // Yellow
  14, 1,  0, 5,  2, 2,  // Yellow
  15, 1, 19, 5, 41, 2,  // Yellow
  15, 1, 41, 5, 29, 2,  // Yellow
  15, 1, 29, 5,  8, 2,  // Yellow
  15, 1, 25, 5, 50, 2,  // Yellow
  15, 1, 50, 5, 38, 2,  // Yellow
  15, 1, 38, 5,  6, 2,  // Yellow
  15, 1,  6, 5,  7, 2,  // Yellow
  15, 1, 22, 5, 47, 2,  // Yellow
  15, 1, 47, 5, 35, 2,  // Yellow
  15, 1, 35, 5,  1, 2,  // Yellow
  15, 1,  1, 5,  3, 2,  // Yellow
  52, 0, 40, 4, 18, 1,  // Red
  52, 0, 18, 4,  2, 1,  // Red
  52, 0,  2, 4, 32, 1,  // Red
  52, 0, 32, 4, 33, 1,  // Red
  52, 0, 33, 4, 45, 1,  // Red
  52, 0, 45, 4, 20, 1,  // Red
  52, 0, 20, 4,  5, 1,  // Red
  52, 0,  5, 4, 37, 1,  // Red
  52, 0, 37, 4, 38, 1,  // Red
  52, 0, 38, 4, 50, 1,  // Red
  52, 0, 50, 4, 25, 1,  // Red
  52, 0, 25, 4, 11, 1,  // Red
  52, 0, 11, 4, 30, 1,  // Red
  52, 0, 30, 4, 28, 1,  // Red
  52, 0, 28, 4, 40, 1,  // Red
  53, 0, 41, 4, 19, 1,  // Red
  53, 0, 19, 4,  3, 1,  // Red
  53, 0,  3, 4, 33, 1,  // Red
  53, 0, 33, 4, 32, 1,  // Red
  53, 0, 32, 4, 44, 1,  // Red
  53, 0, 44, 4, 21, 1,  // Red
  53, 0, 21, 4,  4, 1,  // Red
  53, 0,  4, 4, 36, 1,  // Red
  53, 0, 36, 4, 39, 1,  // Red
  53, 0, 39, 4, 51, 1,  // Red
  53, 0, 51, 4, 24, 1,  // Red
  53, 0, 24, 4, 10, 1,  // Red
  53, 0, 10, 4, 31, 1,  // Red
  53, 0, 31, 4, 29, 1,  // Red
  53, 0, 29, 4, 41, 1,  // Red
  54, 0, 42, 4, 16, 1,  // Red
  54, 0, 16, 4,  0, 1,  // Red
  54, 0,  0, 4, 34, 1,  // Red
  54, 0, 34, 4, 35, 1,  // Red
  54, 0, 35, 4, 47, 1,  // Red
  54, 0, 47, 4, 22, 1,  // Red
  54, 0, 22, 4,  7, 1,  // Red
  54, 0,  7, 4, 39, 1,  // Red
  54, 0, 39, 4, 36, 1,  // Red
  54, 0, 36, 4, 48, 1,  // Red
  54, 0, 48, 4, 27, 1,  // Red
  54, 0, 27, 4,  9, 1,  // Red
  54, 0,  9, 4, 28, 1,  // Red
  54, 0, 28, 4, 30, 1,  // Red
  54, 0, 30, 4, 42, 1,  // Red
  55, 0, 43, 4, 17, 1,  // Red
  55, 0, 17, 4,  1, 1,  // Red
  55, 0,  1, 4, 35, 1,  // Red
  55, 0, 35, 4, 34, 1,  // Red
  55, 0, 34, 4, 46, 1,  // Red
  55, 0, 46, 4, 23, 1,  // Red
  55, 0, 23, 4,  6, 1,  // Red
  55, 0,  6, 4, 38, 1,  // Red
  55, 0, 38, 4, 37, 1,  // Red
  55, 0, 37, 4, 49, 1,  // Red
  55, 0, 49, 4, 26, 1,  // Red
  55, 0, 26, 4,  8, 1,  // Red
  55, 0,  8, 4, 29, 1,  // Red
  55, 0, 29, 4, 31, 1,  // Red
  55, 0, 31, 4, 43, 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,
  0, 0, 0, 0,
  0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 
  0, 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(0.045f));
...
【參考資料】

[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

沒有留言:

張貼留言