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
You can find a detailed description of the methods and algorithms used in this thread.
At the same time I do not authorize to open or decompile in order to obtain the original source. I do not authorize any changes to the source.
You can use the library in your applications, including commercial ones, by inserting the author's acknowledgment of this library.
The examples must be updated to select the complete version of the library (no longer SD_XUIView3D_DEMO but SD_XUIView3D)
If you want you can make a donation for this library, I would be grateful.
SD_XUI_View3D
Author: Star-Dust
Version: 0.26
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
You can find a detailed description of the methods and algorithms used in this thread.
At the same time I do not authorize to open or decompile in order to obtain the original source. I do not authorize any changes to the source.
You can use the library in your applications, including commercial ones, by inserting the author's acknowledgment of this library.
The examples must be updated to select the complete version of the library (no longer SD_XUIView3D_DEMO but SD_XUIView3D)
If you want you can make a donation for this library, I would be grateful.
SD_XUI_View3D
Author: Star-Dust
Version: 0.26
- Object3D
- Fields:
- DrawTime As Int
- light_intensity As Int
- ListVerticesOnScreen As List
- LoadTime As Int
- RotateTime As Int
- SortTime As Int
- 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_Start 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 (IDStart 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 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 - CutObj (IDlist As List) As Object3D
Erase Object List, and returns a new list. If the ID list is empty, it does not perform any operation - 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
- 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
- Properties:
- ListObject As List [read only]
return List of Type_Polygon - Obj3DCount As Int [read only]
Count of Object
- ListObject As List [read only]
- Fields:
Attachments
-
sample2.zip9.9 KB · Views: 637
-
Sample3 Pacman.zip10.8 KB · Views: 631
-
Jsample1.zip95.6 KB · Views: 590
-
sample1.zip81.6 KB · Views: 623
-
iSample1.zip351.4 KB · Views: 533
-
SD_XUI_View3D 0.28.zip21.9 KB · Views: 210
-
jSD_XUI_View3D 0.28.zip21.9 KB · Views: 203
-
iSD_XUI_View3D 0.28.zip156.3 KB · Views: 186
Last edited: