Android Question B4A and OpenGL to simulate a 3DPrinter

Discussion in 'Android Questions' started by max123, Aug 21, 2018.

  1. max123

    max123 Active Member Licensed User

    Hi All,

    I've developed a Java application capable to open gcode files, parse it line by line, draw a filament on a 3D View, the app can simulate as well 3D printers, CNC Routers and Laser Cutter machines and can connect with these with USB connection and control it manually or by loading a gcode file and execute it on real machine while draw on 3D view.

    This application works even on Raspberry PI 3 with original 7 Inches touchscreen or on HDMI monitor, need just to connect the machine with USB cable and Go.

    Compatible with Marlin and GRBL firmwares.

    As 3D view I've used Java3D library, but now I want to port this application on Android using B4A and I'm a bit confused on how I can do it, because Java3D library works only on desktop machines.

    With Java3D I create a cylinder to simulate the filament or just I draw 3D lines to show a CNC router toolpath. For filament I create a cylinder as explained, it is the same size of 3DPrinter Nozzle, the Java3D library create it to Zero position, then I rotate and translate in the right position on the 3D world. The application can even load STL and OBJ files (for future slicing) and can even load an STL file as body of real machine.

    My question is, what is the best option to do this on B4A? I need to use Agraham OpenGL library 2.0 and GLSurfaceView?

    There are other options? With it I can do all things I explained? Create 3D primitives like Box, Cylinder, sphere, add lights and even import OBJ and STL files?

    I never used native OpenGL so this is a bit problematic, Java3D do large use of object oriented, so there are 3DCanvas, BranchGroups, TranformGroups, ViewingPlatform, Shapes3D and others. I searched on the Forum but not tried tutorials on an OpenGL 3D view.

    I've attached some screens of my desktop application.

    Many thanks for your suggestions ;)

    2018-08-21 12_10_37-Greenshot.png
     

    Attached Files:

    Last edited: Nov 1, 2018
  2. MarkusR

    MarkusR Well-Known Member Licensed User

    Last edited: Aug 21, 2018
    Peter Simpson and LucaMs like this.
  3. LucaMs

    LucaMs Expert Licensed User

  4. max123

    max123 Active Member Licensed User

    Many thanks for your reply and suggestions MarkusR, I think too that WebGL is good thing but I've old devices and not WebGL enabled, so I can't test it. Maybe I can do it with my Nexus 7 2013... I will test it. Java3D even works on browser as Java Applet and on my old Monocore PC with 1GB of ram and only 64MB of video ram on an old ATI Radeon it works like a charm and I,ve a very high framerate, like 60 fps... It slow down If I add more and more to the scene, like 100.000 + cylinders.

    But B4A OpenGL library can do that I developed on Java3D as my screenshots? You used it?

    I can make primitives or I need to create myself with triangles and generate normals too? With Java3D make example a sphere require just one line of code, more if I want to add Appearance and or textures... But already has primitives like Box, ColorCube, Sphere, Cone, Cylinder and others.

    Many thanks
     
    Last edited: Nov 1, 2018
  5. MarkusR

    MarkusR Well-Known Member Licensed User

    Peter Simpson, JordiCP and max123 like this.
  6. LucaMs

    LucaMs Expert Licensed User

    :p
     
  7. max123

    max123 Active Member Licensed User

    Grazie Luca per avermi avvisato, correggo subito... Sto postando dal mio Nexus 7
     
  8. LucaMs

    LucaMs Expert Licensed User

    Pensavo che fosse voluto, per essere "umile". Comunque hai inventato un neologismo e anche simpatico :D

    It's your nice neologism.
     
    max123 likes this.
  9. max123

    max123 Active Member Licensed User

    Many thanks MarkusR, I use Eclipse too and have developed some B4A and B4J libraries... So if you have a Java code this is wonderful... and I can compile on Eclipse
     
    MarkusR likes this.
  10. LucaMs

    LucaMs Expert Licensed User

    For example, the latest screenshot of my app can definitely be called "Screenshit" :D
     
    max123 likes this.
  11. MarkusR

    MarkusR Well-Known Member Licensed User

    ok i will prepare the project soon and upload it then at google drive tomorrow.
     
  12. max123

    max123 Active Member Licensed User

    Ok Markus, thanks. I read your library post and seem very interesting, but only I see cubes, no other primitives, If you need I can send you original Java3D classes to construct a Sphere, a Cone, a Cylinder etc... by passing even a division resolution and others parameters, so if you have time and if you want, maybe you can add to your library.

    Initially to develop my app I started with B4J, but due to work on Raspberry PI (not on browser but as real application) next I've developed it on Jabaco using directly Java3D Classes without intermediary wrappers (Java3D has 100 and plus classes, so make a wrapper is very difficult), so I created a Class to draw just what I need, a plane grid, primitives etc... It is a smal wrap of some Java3D that use it just by add 3 Java3D jars of library to the system and to the classpath, then reference it like B4A or B4J libraries. Jabaco has same syntax of VisualBasic and B4X and convert pure Java code to it is very simple.... If you need I can send my class.

    Many thanks
     
    Last edited: Aug 22, 2018
  13. MarkusR

    MarkusR Well-Known Member Licensed User

    ok, here the android studio project. https://drive.google.com/open?id=1_JJ04TRJD9qqwZqR2NVUoXXUjy1NFebG
    its all together in a folder with the file threedimensional.java
    (ignore the PhotoCube.Java file there)
    this project also contains a test project to start at emulator or device.

    currently i am not working at this lib. (just saw you have other templates for build primitives)
    you can build primitives by triangles or rectangles.
    or make a 3d loader that load a primitive objects.
    i have some old blitz max code, you can open with notepad , search for AddCylinder there. https://drive.google.com/open?id=1fs9evbU4cU0kX2Kj8HtPqv4-co2xAndL
     
    Last edited: Aug 22, 2018
  14. max123

    max123 Active Member Licensed User

    Many thanks MarkusR, I will try it.

    But my question remains open, what is a best way to import STL and OBJ files without write myself a loader? Is that possible using your library? If not I can't use your library and I need to know if OpenGL or libGDX or jPCT-AE libraries can do this....

    I need a fast possible rendering too.

    Many thanks
     
  15. MarkusR

    MarkusR Well-Known Member Licensed User

    i did not had any import fileformat, i used a web api interface with json data and then i build the scene for it.
    i believe that are text files, writing a importer need some time sure.

    u need to look in the provided documentation.
    and if you find they say it can load stl or obj files, it did not means that it works with your files.
    3d data exchange is still a disaster.
     
  16. max123

    max123 Active Member Licensed User

    OBJ files are text (ASCII) format, STL file is a bit more complicated because there are ASCII or BINARY files.

    Java3D by defaul has OBJ loader that even import and map textures on the model from .mtl file exported from CAD.

    About the STL loader, I found java code (STL Loader) on the web, then I adapted and improved, now can import as well both ascii and binary files, from disk and even from URL without download it, just data are in RAM and model rendered.

    Write a loader and parse a file yes is very long work to do with Tokenizer or Regex, so I don't want rewrite it because on Java3D required me 2 month of work.
     
    Last edited: Nov 1, 2018
  17. max123

    max123 Active Member Licensed User

    I would love to know what Erel thinks of this ;)
    Which library is best to use according to you?

    Note that I have no knowledge of OpenGL because Java3D works on objects.

    Many thanks
     
  18. Erel

    Erel Administrator Staff Member Licensed User

    I'm afraid that I cannot help you much here.
     
  19. max123

    max123 Active Member Licensed User

    Thanks Erel for your fast reply.

    But could you direct me indicating where to start?
    Then if I have to study I will study. ;)

    Many thanks
     
    Last edited: Aug 29, 2018
  20. alienhunter

    alienhunter Active Member Licensed User

    Hi Max123
    very nice 3D , is there a Java3D library out there in the forum or did you made one for B4J , i am very i
    interested in that one ;)
    thanks AH
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice