Real-Time 3D Programming in Scala

2,665 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,665
On SlideShare
0
From Embeds
0
Number of Embeds
189
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Real-Time 3D Programming in Scala

  1. 1. +Scala LWJGL 3D @chimerast
  2. 2. + n  n  Twitter: @chimerast n  Blog: http://chimera.st/ n  Scala : 1 n  LWJGL : 3 n  NEET n  Web/ n  Seasar Foundation S2Wicket 1.4 n  wicket-ja, java-ja n  3D n  3D n  DirectX7 Immediate Mode
  3. 3. + n  n  n  n  n  n  n  n  n  n 
  4. 4. + Scala 3D n  n  3D (or ) n  n  MikuMikuDance 3D n  n  Scala n  LWJGL n  Slick
  5. 5. + MikuMikuDance n  n  http://www.geocities.jp/higuchuu4/ n  n  DirectX http://www.nicovideo.jp/watch/sm9647253 n  n  n  n  n  JVM
  6. 6. + Scala A Scalable Language n  + n  n  n  Java 1 n  3D scala> List(3,2,5,1).reduceLeft(math.max) res0: Int = 5 n  Java n 
  7. 7. + LWJGL Lightweight Java Game Library n  + n  http://www.lwjgl.org/ n  OpenGL n  3D API n  n  OpenAL n  3D API n  n  OpenCL n  GPGPU GPU API n  n 
  8. 8. + Slick 2D Game Library based on LWJGL n  LWJGL 2D n  http://slick.cokeandcode.com/ n  LWJGL(OpenGL) 2D n  n  2D n  n  n  SVG
  9. 9. + LWJGL n  https://github.com/chimerast/scala-lwjgl-sample n  sbt n  n  3D n  3D n  LWJGL native java.library.path n  sbt fork
  10. 10. + n  3D n  n  IK ( ) n  n  n  n  n  n 
  11. 11. + n  n  n  60fps(1 60 ) n  16ms
  12. 12. + Java/Scala n  (GC) n  n  n  C++ n  JIT C++ JIT n  SIMD C+ + n  SIMD 1CPU n  10 n  3D
  13. 13. + n  n  n  Array[Float] n  n  Scala immutable.List n  GC n  n  Java n  OpenGL GPU n  GPU SIMD n 
  14. 14. + Scala : .apply .update .foreach .prepend .append .insert java.util.ArrayList[AnyRef] 11 19 16 19,746 158 39,317 java.util.LinkedList[AnyRef] 38.622 388,877 43 152 141 320 Array[AnyRef] 1 21 174 - - - mutable.ArrayBuffer[AnyRef] 11 19 122 19,734 172 40,118 mutable.ListBuffer[AnyRef] 94,595 94,861 367 119 170 95,643 mutable.Queue[AnyRef] 99.916 100,672 497 142 230 - immutable.List[AnyRef] 94,543 4,718,559 312 175 2,482,455 - immutable.Vector[AnyRef] 107 517 211 779 662 - Scala http://d.hatena.ne.jp/chimerast/20110304/1299237142 Array[AnyRef].apply JIT (DCE) JIT
  15. 15. + MikuMikuDance n  PMD (.pmd) n  3D n  VMD (.vmd) n  3D n  2ch n  - MMD (PMD) http://bit.ly/fFYlS n  n  n  AS3 (b2ox ): http://www.libspark.org/browser/as3/FLARMMD n  XNA (wilfrem ): http://sourceforge.jp/projects/mmdx/
  16. 16. + PMD n  in MMD n  3D n  n  n  n  IK n  n  n  Direct3D OpenGL n  n  OpenGL DirectX n  z
  17. 17. + VMD n  n  n  n  n  n 
  18. 18. + in Scala val file = new File(path)using(new RandomAccessFile(file, "r")) { f => val channel = f.getChannel val buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size) buffer.order(ByteOrder.LITTLE_ENDIAN) Some(new PMDModel(file, buffer))} class PMDModel(file: File, buffer: ByteBuffer) { val header = new PMDHeader(buffer) val vertices = Array.fill(buffer.getInt) { new PMDVertex(buffer) } val indices = Array.fill(buffer.getInt) { buffer.getShort } val materials = Array.fill(buffer.getInt) { new PMDMaterial(buffer) } val bones = Array.fill(buffer.getShort) { new PMDBone(buffer) } val iks = Array.fill(buffer.getShort) { new PMDIKData(buffer) } val skins = Array.fill(buffer.getShort) { new PMDSkinData(buffer) } val skinIndex = Array.fill(buffer.get) { buffer.getShort } val boneDispName = Array.fill(buffer.get) { buffer.getString(50) } val boneDisp = Array.fill(buffer.getInt) { new PMDBoneDisp(buffer) }}
  19. 19. + n  IK n  n  n  JBullet: http://jbullet.advel.cz/ n  n  n  n  Prolog =
  20. 20. + n 

×