title: jMonkey optimization similar to Java3D's
body: <p><strong>Edit: For having real-time drawing, started using lwjgl which is base of jmonkeyengine and jocl in an "interoperability" between opengl and opencl, now can calculate and draw 100k particles real-time. Maybe mantle version of jmonkey engine can cure this drawcall overhead problem.</strong></p>
  
  <p>For several days, I have been learning jMonkey engine(ver:3.0) in Eclipse(java 64 bit) and trying how to optimize a scene with using <code>GeometryBatchFactory.optimize(rootNode);</code> command.</p>
  
  <p><strong>Without optimization(with capability of changing spheres positions):</strong></p>
  
  <p><img src="https://i.stack.imgur.com/uGG58.jpg" alt="enter image description here"></p>
  
  <p>Okay, only 1-fps is originated from both pci-express bandwidth+jvm overhead.</p>
  
  <p><strong>With optimization(without capability to change positions of spheres):</strong></p>
  
  <p><img src="https://i.stack.imgur.com/vjiiw.jpg" alt="enter image description here"></p>
  
  <p>Now it is 29 fps even with increased triangle number. </p>
  
  <p>Java3D had a <code>setCapability()</code> method which makes a scene object be able to be read/written even in an optimized form. jMonkey engine 3.0 must be capable of this subject but I couldn't find any trace of it(searched tutorials and examples, failed).</p>
  
  <p><strong>Question:</strong> How can I set <code>read/write position/rotation/scale</code> capabilities of <code>optimized</code> nodes of a scene in jMonkey 3.0? If you cannot give an answer to first question, can you tell me why triangle numbers increase when I use optimization command? Do I have to create a new method to access the graphics card and change the variables myself(jogl maybe?)?</p>
  
  <p>Scene information: 16k particles(spheres of 16x16 res) + 1 point light(and its 4096 resolutioned shadow).</p>
  
  <p>I'm sure we can send several thousands of float numbers in a millisecond through pci-express with ease.</p>
  
  <ul>
  <li>Additional info: I'm using Aparapi-kernels to update particle
  positions which takes 10 milliseconds(16k * 16k interactions to
  calculate forces).(does not change anything in optimized mode :( )
  Can aparapi access those optimized data?</li>
  </ul>
  
  <p>For the case of <code>batchNode.batch();</code> optimization, here is 1 fps again with lessened object-numbers:</p>
  
  <p><img src="https://i.stack.imgur.com/FsQzw.jpg" alt="enter image description here"></p>
  
  <p>Object number is now only several hundreds but fps is still at 1!</p>
  
  <p>Sending just sphere positions to gpu and letting it calculate the vertex positions could be better than calculating vertexes on cpu plus sending huge data to gpu.</p>
  
  <p>No-one here to help? Already tried batchNode but did not help enough.</p>
  
  <p>I dont want to change 3d api because jMonkey people already reinvented the wheel and I'm happy with current situation. Just trying to squeeze a little more performance(canceling shadows gives %100 speed but quality is important too!).</p>
  
  <p>This java program will become an asteroid-impact scene simulator(there will be choice of asteroid size,mass,speed,angle) with marching-cubes algorithm with LOD(will be millions of particles).</p>
  
  <p><strong>Marching-cubes algorithm would decrease the triangle numbers greatly. If you couldnt give any answer the question, any marching-cubes(or any O(n) convex hull) algorithm for java will be accepted! Data: x,y,z arrays as source and triangle-strip-array as target(iso-surface mesh points)</strong></p>
  
  <p>Thanks.</p>
  
  <p>Here are some samples about the stream(with a much lower resolution):</p>
  
  <p>1)Collapsing of a cube-shaped rock-group by gravitation:
  <img src="https://i.stack.imgur.com/mf0PG.jpg" alt="enter image description here"></p>
  
  <p>2)Exclusion force starts to show itself:
  <img src="https://i.stack.imgur.com/RLMN0.jpg" alt="enter image description here"></p>
  
  <p>3)Exclusion force + gravitation makes the group form a more smooth shape:
  <img src="https://i.stack.imgur.com/NMhm5.jpg" alt="enter image description here"></p>
  
  <p>4)Group forms a sphere(as expected):
  <img src="https://i.stack.imgur.com/nGfwK.jpg" alt="enter image description here"></p>
  
  <p>5)Then, a big stellar body approaches:
  <img src="https://i.stack.imgur.com/zRRDg.jpg" alt="enter image description here"></p>
  
  <p>6)About to touch:
  <img src="https://i.stack.imgur.com/3eIEt.jpg" alt="enter image description here"></p>
  
  <p>7)The moment of impact:
  <img src="https://i.stack.imgur.com/dcUAx.jpg" alt="enter image description here"></p>
  
  <p>With help of Barnes-Hutt algorithm and a truncated potential, particle numbers will be 10x(maybe 100x) more.</p>
  
  <p>Rather than Marching-Cubes algorithm, a ghost cloth which wraps the nbody can give a low-resolutioned hull(more easier than BH but need more computation)</p>
  
  <p>Ghost cloth will be affected by nbody(gravity + exclusion) but nbody will not be affected by cloth which wraps it. Nbody wont be rendered but cloth mesh will be rendered with lower triange count.</p>
  
  <p><img src="https://i.stack.imgur.com/eqGhD.jpg" alt="enter image description here">
  <img src="https://i.stack.imgur.com/NA4eb.jpg" alt="enter image description here"></p>
  
  <p>If MC or above works, this will let the program render a wrapping-cloth for ~200x more particles.</p>