2017年11月9日 星期四

JavaFX 3D - Truncated Icosidodecahedron

以下是以JavaFX 8的TriangleMesh類別建構之Truncated Icosidodecahedron (大斜方截半二十面體),屬於Archimedean Solid (阿基米德立體)。

The Archimedean solids are a set of 13 polyhedra described by Pappus of Alexandria around 340 AD. Each solid is a convex polyhedron whose faces are regular polygons of two or more types that meet in the same pattern around each vertex. Each has polyhedral group, tetrahedral, octahedral, or icosahedral, rotational symmetry.


float C0  = length * (float) (3.0 + Math.sqrt(5.0)) / 4.0f;
float C1  = length * (float) (1.0 + Math.sqrt(5.0)) / 2.0f;
float C2  = length * (float) (5.0 + Math.sqrt(5.0)) / 4.0f;
float C3  = length * (float) (2.0 + Math.sqrt(5.0)) / 2.0f;
float C4  = length * (float) (1.0 + Math.sqrt(5.0)) / 4.0f * 3.0f;
float C5  = length * (float) (3.0 + Math.sqrt(5.0)) / 2.0f;
float C6  = length * (float) (5.0 + Math.sqrt(5.0) * 3.0) / 4.0f;
float C7  = length * (float) (4.0 + Math.sqrt(5.0)) / 2.0f;
float C8  = length * (float) (7.0 + Math.sqrt(5.0) * 3.0) / 4.0f;
float C9  = length * (float) (3.0 + Math.sqrt(5.0) * 2.0) / 2.0f;
float C10 = length * 0.5f;
float C11 = length * 1.0f;

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

// 設定頂點座標
trianglemesh.getPoints().addAll(
   C10,  C10,   C9,
   C10,  C10,  -C9,
   C10, -C10,   C9,
   C10, -C10,  -C9,
  -C10,  C10,   C9,
  -C10,  C10,  -C9,
  -C10, -C10,   C9,
  -C10, -C10,  -C9,
    C9,  C10,  C10,
    C9,  C10, -C10,
    C9, -C10,  C10,
    C9, -C10, -C10,
   -C9,  C10,  C10,
   -C9,  C10, -C10,
   -C9, -C10,  C10,
   -C9, -C10, -C10,
   C10,   C9,  C10,
   C10,   C9, -C10,
   C10,  -C9,  C10,
   C10,  -C9, -C10,
  -C10,   C9,  C10,
  -C10,   C9, -C10,
  -C10,  -C9,  C10,
  -C10,  -C9, -C10,
   C11,   C0,   C8,
   C11,   C0,  -C8,
   C11,  -C0,   C8,
   C11,  -C0,  -C8,
  -C11,   C0,   C8,
  -C11,   C0,  -C8,
  -C11,  -C0,   C8,
  -C11,  -C0,  -C8,
    C8,  C11,   C0,
    C8,  C11,  -C0,
    C8, -C11,   C0,
    C8, -C11,  -C0,
   -C8,  C11,   C0,
   -C8,  C11,  -C0,
   -C8, -C11,   C0,
   -C8, -C11,  -C0,
    C0,   C8,  C11,
    C0,   C8, -C11,
    C0,  -C8,  C11,
    C0,  -C8, -C11,
   -C0,   C8,  C11,
   -C0,   C8, -C11,
   -C0,  -C8,  C11,
   -C0,  -C8, -C11,
   C10,   C3,   C7,
   C10,   C3,  -C7,
   C10,  -C3,   C7,
   C10,  -C3,  -C7,
  -C10,   C3,   C7,
  -C10,   C3,  -C7,
  -C10,  -C3,   C7,
  -C10,  -C3,  -C7,
    C7,  C10,   C3,
    C7,  C10,  -C3,
    C7, -C10,   C3,
    C7, -C10,  -C3,
   -C7,  C10,   C3,
   -C7,  C10,  -C3,
   -C7, -C10,   C3,
   -C7, -C10,  -C3,
    C3,   C7,  C10,
    C3,   C7, -C10,
    C3,  -C7,  C10,
    C3,  -C7, -C10,
   -C3,   C7,  C10,
   -C3,   C7, -C10,
   -C3,  -C7,  C10,
   -C3,  -C7, -C10,
    C2,   C1,   C6,
    C2,   C1,  -C6,
    C2,  -C1,   C6,
    C2,  -C1,  -C6,
   -C2,   C1,   C6,
   -C2,   C1,  -C6,
   -C2,  -C1,   C6,
   -C2,  -C1,  -C6,
    C6,   C2,   C1,
    C6,   C2,  -C1,
    C6,  -C2,   C1,
    C6,  -C2,  -C1,
   -C6,   C2,   C1,
   -C6,   C2,  -C1,
   -C6,  -C2,   C1,
   -C6,  -C2,  -C1,
    C1,   C6,   C2,
    C1,   C6,  -C2,
    C1,  -C6,   C2,
    C1,  -C6,  -C2,
   -C1,   C6,   C2,
   -C1,   C6,  -C2,
   -C1,  -C6,   C2,
   -C1,  -C6,  -C2,
    C0,   C4,   C5,
    C0,   C4,  -C5,
    C0,  -C4,   C5,
    C0,  -C4,  -C5,
   -C0,   C4,   C5,
   -C0,   C4,  -C5,
   -C0,  -C4,   C5,
   -C0,  -C4,  -C5,
    C5,   C0,   C4,
    C5,   C0,  -C4,
    C5,  -C0,   C4,
    C5,  -C0,  -C4,
   -C5,   C0,   C4,
   -C5,   C0,  -C4,
   -C5,  -C0,   C4,
   -C5,  -C0,  -C4,
    C4,   C5,   C0,
    C4,   C5,  -C0,
    C4,  -C5,   C0,
    C4,  -C5,  -C0,
   -C4,   C5,   C0,
   -C4,   C5,  -C0,
   -C4,  -C5,   C0,
   -C4,  -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(
   0, 1,   4, 5,   6, 2,
   0, 1,   6, 5,   2, 2,
   1, 1,   3, 5,   7, 2,
   1, 1,   7, 5,   5, 2,
   8, 1,  10, 5,  11, 2,
   8, 1,  11, 5,   9, 2,
  12, 1,  13, 5,  15, 2,
  12, 1,  15, 5,  14, 2,
  16, 1,  17, 5,  21, 2,
  16, 1,  21, 5,  20, 2,
  18, 1,  22, 5,  23, 2,
  18, 1,  23, 5,  19, 2,
  24, 1,  72, 5,  96, 2,
  24, 1,  96, 5,  48, 2,
  25, 1,  49, 5,  97, 2,
  25, 1,  97, 5,  73, 2,
  26, 1,  50, 5,  98, 2,
  26, 1,  98, 5,  74, 2,
  27, 1,  75, 5,  99, 2,
  27, 1,  99, 5,  51, 2,
  28, 1,  52, 5, 100, 2,
  28, 1, 100, 5,  76, 2,
  29, 1,  77, 5, 101, 2,
  29, 1, 101, 5,  53, 2,
  30, 1,  78, 5, 102, 2,
  30, 1, 102, 5,  54, 2,
  31, 1,  55, 5, 103, 2,
  31, 1, 103, 5,  79, 2,
  32, 1,  80, 5, 104, 2,
  32, 1, 104, 5,  56, 2,
  33, 1,  57, 5, 105, 2,
  33, 1, 105, 5,  81, 2,
  34, 1,  58, 5, 106, 2,
  34, 1, 106, 5,  82, 2,
  35, 1,  83, 5, 107, 2,
  35, 1, 107, 5,  59, 2,
  36, 1,  60, 5, 108, 2,
  36, 1, 108, 5,  84, 2,
  37, 1,  85, 5, 109, 2,
  37, 1, 109, 5,  61, 2,
  38, 1,  86, 5, 110, 2,
  38, 1, 110, 5,  62, 2,
  39, 1,  63, 5, 111, 2,
  39, 1, 111, 5,  87, 2,
  40, 1,  88, 5, 112, 2,
  40, 1, 112, 5,  64, 2,
  41, 1,  65, 5, 113, 2,
  41, 1, 113, 5,  89, 2,
  42, 1,  66, 5, 114, 2,
  42, 1, 114, 5,  90, 2,
  43, 1,  91, 5, 115, 2,
  43, 1, 115, 5,  67, 2,
  44, 1,  68, 5, 116, 2,
  44, 1, 116, 5,  92, 2,
  45, 1,  93, 5, 117, 2,
  45, 1, 117, 5,  69, 2,
  46, 1,  94, 5, 118, 2,
  46, 1, 118, 5,  70, 2,
  47, 1,  71, 5, 119, 2,
  47, 1, 119, 5,  95, 2,
   0, 3,  24, 7,  48, 4,
   0, 3,  48, 7,  52, 4,
   0, 3,  52, 7,  28, 4,
   0, 3,  28, 7,   4, 4,
   1, 3,   5, 7,  29, 4,
   1, 3,  29, 7,  53, 4,
   1, 3,  53, 7,  49, 4,
   1, 3,  49, 7,  25, 4,
   2, 3,   6, 7,  30, 4,
   2, 3,  30, 7,  54, 4,
   2, 3,  54, 7,  50, 4,
   2, 3,  50, 7,  26, 4,
   3, 3,  27, 7,  51, 4,
   3, 3,  51, 7,  55, 4,
   3, 3,  55, 7,  31, 4,
   3, 3,  31, 7,   7, 4,
   8, 3,  32, 7,  56, 4,
   8, 3,  56, 7,  58, 4,
   8, 3,  58, 7,  34, 4,
   8, 3,  34, 7,  10, 4,
   9, 3,  11, 7,  35, 4,
   9, 3,  35, 7,  59, 4,
   9, 3,  59, 7,  57, 4,
   9, 3,  57, 7,  33, 4,
  12, 3,  14, 7,  38, 4,
  12, 3,  38, 7,  62, 4,
  12, 3,  62, 7,  60, 4,
  12, 3,  60, 7,  36, 4,
  13, 3,  37, 7,  61, 4,
  13, 3,  61, 7,  63, 4,
  13, 3,  63, 7,  39, 4,
  13, 3,  39, 7,  15, 4,
  16, 3,  40, 7,  64, 4,
  16, 3,  64, 7,  65, 4,
  16, 3,  65, 7,  41, 4,
  16, 3,  41, 7,  17, 4,
  18, 3,  19, 7,  43, 4,
  18, 3,  43, 7,  67, 4,
  18, 3,  67, 7,  66, 4,
  18, 3,  66, 7,  42, 4,
  20, 3,  21, 7,  45, 4,
  20, 3,  45, 7,  69, 4,
  20, 3,  69, 7,  68, 4,
  20, 3,  68, 7,  44, 4,
  22, 3,  46, 7,  70, 4,
  22, 3,  70, 7,  71, 4,
  22, 3,  71, 7,  47, 4,
  22, 3,  47, 7,  23, 4,
  72, 3, 104, 7,  80, 4,
  72, 3,  80, 7, 112, 4,
  72, 3, 112, 7,  88, 4,
  72, 3,  88, 7,  96, 4,
  73, 3,  97, 7,  89, 4,
  73, 3,  89, 7, 113, 4,
  73, 3, 113, 7,  81, 4,
  73, 3,  81, 7, 105, 4,
  74, 3,  98, 7,  90, 4,
  74, 3,  90, 7, 114, 4,
  74, 3, 114, 7,  82, 4,
  74, 3,  82, 7, 106, 4,
  75, 3, 107, 7,  83, 4,
  75, 3,  83, 7, 115, 4,
  75, 3, 115, 7,  91, 4,
  75, 3,  91, 7,  99, 4,
  76, 3, 100, 7,  92, 4,
  76, 3,  92, 7, 116, 4,
  76, 3, 116, 7,  84, 4,
  76, 3,  84, 7, 108, 4,
  77, 3, 109, 7,  85, 4,
  77, 3,  85, 7, 117, 4,
  77, 3, 117, 7,  93, 4,
  77, 3,  93, 7, 101, 4,
  78, 3, 110, 7,  86, 4,
  78, 3,  86, 7, 118, 4,
  78, 3, 118, 7,  94, 4,
  78, 3,  94, 7, 102, 4,
  79, 3, 103, 7,  95, 4,
  79, 3,  95, 7, 119, 4,
  79, 3, 119, 7,  87, 4,
  79, 3,  87, 7, 111, 4,
   0, 0,   2, 4,  26, 1, 
   0, 0,  26, 4,  74, 1, 
   0, 0,  74, 4, 106, 1, 
   0, 0, 106, 4,  58, 1, 
   0, 0,  58, 4,  56, 1, 
   0, 0,  56, 4, 104, 1, 
   0, 0, 104, 4,  72, 1, 
   0, 0,  72, 4,  24, 1, 
   1, 0,  25, 4,  73, 1, 
   1, 0,  73, 4, 105, 1, 
   1, 0, 105, 4,  57, 1, 
   1, 0,  57, 4,  59, 1, 
   1, 0,  59, 4, 107, 1, 
   1, 0, 107, 4,  75, 1, 
   1, 0,  75, 4,  27, 1, 
   1, 0,  27, 4,   3, 1, 
   4, 0,  28, 4,  76, 1, 
   4, 0,  76, 4, 108, 1, 
   4, 0, 108, 4,  60, 1, 
   4, 0,  60, 4,  62, 1, 
   4, 0,  62, 4, 110, 1, 
   4, 0, 110, 4,  78, 1, 
   4, 0,  78, 4,  30, 1, 
   4, 0,  30, 4,   6, 1, 
   5, 0,   7, 4,  31, 1, 
   5, 0,  31, 4,  79, 1, 
   5, 0,  79, 4, 111, 1, 
   5, 0, 111, 4,  63, 1, 
   5, 0,  63, 4,  61, 1, 
   5, 0,  61, 4, 109, 1, 
   5, 0, 109, 4,  77, 1, 
   5, 0,  77, 4,  29, 1, 
   8, 0,   9, 4,  33, 1, 
   8, 0,  33, 4,  81, 1, 
   8, 0,  81, 4, 113, 1, 
   8, 0, 113, 4,  65, 1, 
   8, 0,  65, 4,  64, 1, 
   8, 0,  64, 4, 112, 1, 
   8, 0, 112, 4,  80, 1, 
   8, 0,  80, 4,  32, 1, 
  10, 0,  34, 4,  82, 1, 
  10, 0,  82, 4, 114, 1, 
  10, 0, 114, 4,  66, 1, 
  10, 0,  66, 4,  67, 1, 
  10, 0,  67, 4, 115, 1, 
  10, 0, 115, 4,  83, 1, 
  10, 0,  83, 4,  35, 1, 
  10, 0,  35, 4,  11, 1, 
  12, 0,  36, 4,  84, 1,   
  12, 0,  84, 4, 116, 1, 
  12, 0, 116, 4,  68, 1, 
  12, 0,  68, 4,  69, 1, 
  12, 0,  69, 4, 117, 1, 
  12, 0, 117, 4,  85, 1, 
  12, 0,  85, 4,  37, 1, 
  12, 0,  37, 4,  13, 1, 
  14, 0,  15, 4,  39, 1, 
  14, 0,  39, 4,  87, 1, 
  14, 0,  87, 4, 119, 1, 
  14, 0, 119, 4,  71, 1, 
  14, 0,  71, 4,  70, 1, 
  14, 0,  70, 4, 118, 1, 
  14, 0, 118, 4,  86, 1, 
  14, 0,  86, 4,  38, 1, 
  16, 0,  20, 4,  44, 1, 
  16, 0,  44, 4,  92, 1, 
  16, 0,  92, 4, 100, 1, 
  16, 0, 100, 4,  52, 1, 
  16, 0,  52, 4,  48, 1, 
  16, 0,  48, 4,  96, 1, 
  16, 0,  96, 4,  88, 1, 
  16, 0,  88, 4,  40, 1, 
  17, 0,  41, 4,  89, 1, 
  17, 0,  89, 4,  97, 1, 
  17, 0,  97, 4,  49, 1, 
  17, 0,  49, 4,  53, 1, 
  17, 0,  53, 4, 101, 1, 
  17, 0, 101, 4,  93, 1, 
  17, 0,  93, 4,  45, 1, 
  17, 0,  45, 4,  21, 1, 
  18, 0,  42, 4,  90, 1, 
  18, 0,  90, 4,  98, 1, 
  18, 0,  98, 4,  50, 1, 
  18, 0,  50, 4,  54, 1, 
  18, 0,  54, 4, 102, 1, 
  18, 0, 102, 4,  94, 1, 
  18, 0,  94, 4,  46, 1, 
  18, 0,  46, 4,  22, 1, 
  19, 0,  23, 4,  47, 1, 
  19, 0,  47, 4,  95, 1, 
  19, 0,  95, 4, 103, 1, 
  19, 0, 103, 4,  55, 1, 
  19, 0,  55, 4,  51, 1, 
  19, 0,  51, 4,  99, 1, 
  19, 0,  99, 4,  91, 1, 
  19, 0,  91, 4,  43, 1    
);

// 設定各面的平滑參數
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,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0, 
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  0, 0, 0, 0,
  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(45));
...
【參考資料】

[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

沒有留言:

張貼留言