B4A Library [BAX] [XUI] SD XUI_View3D (Demo)

Discussion in 'Additional libraries, classes and official updates' started by Star-Dust, Jul 5, 2018.

  1. Star-Dust

    Star-Dust Expert Licensed User

    I created a library to display polygons in 3D. It is also possible to use it to create 3D XUI views.
    This library can be used to create 3D models from code or load them from obj files.
    To create a 2D drawing app, to create games, animations, introductions, and 3D effects

    This is a demo version that lasts only a month, I'm releasing it to show the potential of the library. It is still under development, so methods can be subject to change. If you want the full version, you can contact me in private

    You can find a detailed description of the methods and algorithms used in this thread.

    You can find be the version for B4A, B4j,B4i attached . I will not produce a version for B4R. Required XUI 1.72+

    SD_XUI_View3D_DEMO

    Author: Star-Dust
    Version: 0.25
    • Object3D
      • Fields:
        • DrawTime As Int ' statics
        • ListVerticesOnScreen As List ' reserved
        • LoadTime As Int ' statics
        • RotateTime As Int ' statics
        • SortTime As Int ' statics
      • Functions:
        • AddArcX (ID As Int, StartDegree As Int, EndDegree As Int, X As Float, Y As Float, Z As Float, R As Int, BorderColor As Int, FillColor As Int) As Object3D
          Add Arc or Circle (StartDegree=0, EndDegree=360) - round X axis
        • AddArcY (ID As Int, StartDegree As Int, EndDegree As Int, X As Float, Y As Float, Z As Float, R As Int, BorderColor As Int, FillColor As Int) As Object3D
          Add Arc or Circle (StartDegree=0, EndDegree=360) - round Y axis
        • AddArcZ (ID As Int, StartDegree As Int, EndDegree As Int, X As Float, Y As Float, Z As Float, R As Int, BorderColor As Int, FillColor As Int) As Object3D
          Add Arc or Circle (StartDegree=0, EndDegree=360) - round Z axis
        • AddBitmapCreator (ID As Int, Bmc As b4a.example.bitmapcreator, P_TopLeft As Point3D_Type, P_TopRight As Point3D_Type, P_DownLeft As Point3D_Type, P_DownRight As Point3D_Type) As Object3D
        • AddCube (ID As Int, X1 As Float, Y1 As Float, Z1 As Float, X2 As Float, Y2 As Float, Z2 As Float, BorderColor As Int, FillColor As Int()) As Object3D
          Create Cube - Add 6 Polygon - Set Array as Color (min 1, max 6 Color)
          AddCube(121,10,10,10,-10,-10,-10,xui.Color_Black,array as int(xui.Color_White))
          AddCube(121,10,10,10,-10,-10,-10,xui.Color_Black,array as int(xui.Color_White,xui.Color_Black))
        • AddImage (ID As Int, Image As B4XBitmap, P_TopLeft As Point3D_Type, P_TopRight As Point3D_Type, P_DownLeft As Point3D_Type, P_DownRight As Point3D_Type) As Object3D
          Add Image - Set Coordinate
        • AddObj3D (Obj3d As Type_Polygon) As String
          For internal use
        • AddPolygon (ID As Int, PointList As Point3D_Type(), BorderColor As Int, FillColor As Int) As Object3D
          Add Polygon, trace path
        • AddRec (ID As Int, X1 As Float, Y1 As Float, Z1 As Float, X2 As Float, Y2 As Float, Z2 As Float, BorderColor As Int, FillColor As Int) As Object3D
          Add rectangle, Set TopLeft and DownRight
        • AddSpere (ID As Int, X As Float, Y As Float, Z As Float, R As Int, BorderColor As Int, FillColor As Int) As Object3D
          Create Sphere - Add 300 Polygon
        • AddSpere2 (ID As Int, X As Float, Y As Float, Z As Float, R As Int, BorderColor As Int, FillColor As Int, StartLatitude As Int, StopLatitude As Int, StartLongitude As Int, StopLongitude As Int, OrizontalStep As Int, VerticalStep As Int) As Object3D
          Create Sphere - Add max 300 Polygon
          Latitude : 0-360
          Longitude: 0-180
        • Class_Globals As String
        • Clear As String
          Clear all Object
        • CtP (X As Float, Y As Float, Z As Float) As Point3D_Type
          Coordinate To Point
        • getListObject As List
          return List of Type_Polygon
        • getListObjectFromID (IDList As List) As List
          return List of Type_Polygon with specific ID
        • getObj3DCount As Int
          Count of Object
        • Initialize As String
          Initializes the object. You can add parameters to this method if needed.
        • IsInitialized As Boolean
          Verifica se l'oggetto sia stato inizializzato.
        • LoadObiectj3D (Path As String, FileName As String) As Boolean
          e.g. LoadObiectj3D(File.DirInternal,"object.ddd")
        • LoadObjFile (ID As Int, Path As String, filename As String, BorderColor As Int, FillColor As Int, LimitsPolygon As Int) As String
          LimitsPolygon Set 0 to no-limit
        • LoadStlFile (ID As Int, Path As String, filename As String, BorderColor As Int, FillColor As Int, RatioOfSize As Float) As String
        • MoveObj (IDlist As List, X As Int, Y As Int, Z As Int) As Object3D
          Move Object List, set IDList to null for rotate all Polygon
        • PointClick (x As Int, y As Int, Advise As Boolean) As Int
          Vwerify if point is internal of any Polygon/object - Response -1 if is external
        • RenderToView (V As B4XView, CenterX As Int, CenterY As Int, ZoomValue As Float, DrawMode As Int) As String
          Select the most suitable method for the draw based on the number of polygons contained
          DrawMode 0-Traslucent
          1-Canvas without depth color 2-BitmapCreator without depth color 10-Automatic (Canvas if less 20mil polygon)
          3-Canvas with depth color 4-BitmapCreator with depth color 20-Automatic (Canvas if less 20mil polygon)
        • Rotate (IDList As List, DegreeX As Int, DegreeY As Int, DegreeZ As Int) As Object3D
        • Rotate2 (IDList As List, DegreeX As Int, DegreeY As Int, DegreeZ As Int) As Object3D
          Rotate Polygon List, Set IDList to null for rotate all Polygon (Alternative formulas)
        • RotateX (IDList As List, Degree As Int) As Object3D
        • RotateY (IDList As List, Degree As Int) As Object3D
        • RotateZ (IDList As List, Degree As Int) As Object3D
        • SaveObiectj3D (Path As String, FileName As String) As Boolean
          e.g. SaveObiectj3D(File.DirInternal,"object.ddd")
        • setColor (IDList As List, BorderColor As Int, FillColor As Int) As Object3D
        • setVertices (OriginalVertices As Point3D_Type, X As Float, Y As Float, Z As Float) As String
          Set New Values of Vertices
      • Properties:
        • ListObject As List [read only]
          return List of Type_Polygon
        • Obj3DCount As Int [read only]
          Count of Object

    25.gif 31.gif 33.gif
    34.gif 35.gif 38.gif
     

    Attached Files:

    Last edited: Jul 17, 2018 at 3:47 PM
  2. MrYang

    MrYang New Member Licensed User

    Great job!I like it,and I am learning how to show 3D objects with LibGDX。
     
  3. Star-Dust

    Star-Dust Expert Licensed User

    This library does not use OpenGL or GDX, because it was born as an XUI library and could also work for B4i and B4j. Obviously it would be much faster with OpenGL or GDX

    Like all my libreries, it has been created entirely with B4A, I do not use Java or C
     
  4. Star-Dust

    Star-Dust Expert Licensed User

    This code displays the rotation of objects/polygons on a panel but does not modify the original objects.
    Code:
    P3D.Rotate(Null,X,Y,Z).RenderToView(Panel,centerX,centerY,Zoom,ModeDraw)

    This code makes the rotations definitive and then represent them in the panel
    Code:
    P3D=P3D.Rotate(Null,X,Y,Z)
    P3D.RenderToView(
    Panel,centerX,centerY,Zoom,ModeDraw)
     
    Last edited: Jul 9, 2018
  5. Star-Dust

    Star-Dust Expert Licensed User

    There is no obligation to set up the Manifest with LargHeap, it's just a suggestion. Try to remove it.
    It does not use Java or particular libraries, only XUI and BitmapCreator.


    It is the first time that presents this problem, it has been tested by several collaborators without any problem. And frankly I do not know what it could be, I'll ask @Erel
     
  6. Star-Dust

    Star-Dust Expert Licensed User

  7. Star-Dust

    Star-Dust Expert Licensed User

    Update rel. 0.24

    Update Library (method) and Sample
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    The compilation error is not related to the largeHeap attribute.

    Have you changed it while the IDE is closed?

    If you are unable to solve it then it is better to start a new thread as it is probably not related to this library.
     
  9. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Fixed! Removed my previous posts so that it does not clutter the thread of this great project.

    1.png
     
    Last edited: Jul 9, 2018
  10. Star-Dust

    Star-Dust Expert Licensed User

    I added in the first post also a version of the library for B4J and an example.
    It still has some flaws in B4J, which are resolved in the next version not yet released.

    It seems that B4XCanvas B4J does not draw lines if they are only 2 points, they should be at least 3 and different from each other. I solved using DrawLine if the points are less than three.

    The version for B4I is under construction (see here).

    Update: FIX BUGS in Java Library
     
    Last edited: Jul 11, 2018
    MarcoRome, moster67, Erel and 2 others like this.
  11. Star-Dust

    Star-Dust Expert Licensed User

    Update rel 0.25

    released the version for B4i at the first post and updated the library for the latest version of BitmapCreator
     
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