[XUI] 3D, rotations and pivots

Peter Simpson

Expert
Licensed User
Longtime User
Just tested the apk file, I'm more than impressed by your hard work. The app is running extremely smoothly on my phone, excellent work and keep up the great work...
 

Star-Dust

Expert
Licensed User
Longtime User
I have just tested it. The obj files is a great addition!!

Respect :cool::)
Thanks, but it was born from an idea of @sorex. I had not even thought about it, I was drawing everything with formulas and algorithms.

Among other things, the idea of shared vertices was born with the OBJ files.
Let me explain: The same vertex is shared by several faces, such as in a simple cube, each vertex is shared by 3 faces.
It is not necessary to calculate it 3 times that point, when making a rotation. Just get a list of shared points, and just rotate that list. This streamlines the calculation a lot. Thousands of vectors can be reduced to a few hundred vertices.

So it's faster and I can also represent complex OBJs. Anyway I'm still begging, maybe tomorrow will be ready.
 

Star-Dust

Expert
Licensed User
Longtime User
Just tested the apk file, I'm more than impressed by your hard work. The app is running extremely smoothly on my phone, excellent work and keep up the great work...
Thank's.
 
D

Deleted member 103

Guest
I wanted to try your APK, but I do not see anything. :(
Tried with Samsung-A5 (2017) and Nexus-7 (2012).
upload_2018-6-23_14-47-58.png
 

Star-Dust

Expert
Licensed User
Longtime User
I wanted to try your APK, but I do not see anything. :(
Tried with Samsung-A5 (2017) and Nexus-7 (2012).
View attachment 69219
Did you select what you want to see from the SpinnerView at the top left?


UPDATE

31.gif

I have optimized for larger OBJs, with the unique vertex method explained above.
 

Star-Dust

Expert
Licensed User
Longtime User
I attach an APK and JAR file to try a first version of my library.
I have also attached the example I used for this App (without the library) so as to understand the use of the library

For some spider, first it was very fast in B4J and slow in B4A.
Now it seems the opposite. Probably BitmapCreator that I used before for the whole panel worked better with B4J
 
Last edited:
D

Deleted member 103

Guest
You are a genius! :)

if you continue like this you can compete with the CAD-software producers. ;)
 

Star-Dust

Expert
Licensed User
Longtime User
exaggerated, I do not even know if it can be used for some application or I'll have to sell it in the stalls of the used :p
 

Sagenut

Expert
Licensed User
Longtime User
I am totally speechless and amazed by Your works.
Hat Down.
 
D

Deleted member 103

Guest
exaggerated, I do not even know if it can be used for some application or I'll have to sell it in the stalls of the used :p
it's no joke! If you need help, I'm always available for that.
I always wanted to do something like that.
I've been working with cad software for 30 years.
 

Peter Simpson

Expert
Licensed User
Longtime User
Did you select what you want to see from the SpinnerView at the top left?


UPDATE

View attachment 69220
I have optimized for larger OBJs, with the unique vertex method explained above.

A cat @Star-Dust, what next the star ship Enterprise;), that's excellent...

Star Dust but not as in Stardust the Mafia ran casino in Last Vargas that was built in the late 80's or early 90's. The Mafioso run casino made millions for bosses back in the day :p

Anyway your work is absolutely astonishing, that cat looks the dogs bits and I'm completely impressed with your work.

Question, how on earth did you insert a 3D cat, actually any 3D objects???

Cheers...
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
A cat @Star-Dust, what next the star ship Enterprise;), that's excellent...

Star Dust but not as Stardust the Mafia ran casino in Last Vargas that was built in the late 80's or early 90's. The Mafioso run casino made millions for bosses back in the day :p

Anyway your work is absolutely astonishing, that cat looks the dogs bits and I'm completely impressed with your work.

Question, how on earth did you insert a 3D cat, actually any 3D objects???

Cheers...
I simply found this, I would have preferred coke but without the texture the image was not clear, I folded with the cat.
Then on the mobile arrangement I have ram limits, I can not put objects with too many polygons
 

Star-Dust

Expert
Licensed User
Longtime User
I'm wondering about one thing, if instead of using the XUI library I used the native Canvas of Android I would have better performance?
 

sorex

Expert
Licensed User
Longtime User
Question, how on earth did you insert a 3D cat, actually any 3D objects???

I suggested to add object file reading and gave an example on how to parse it and display it the fastest way (he called it shared vertices above I believe).
it's based on a speed test I did 6 years ago of which you can see a screenshot and partial code here > https://www.b4x.com/android/forum/threads/simple-3d-wireframe-object.53210/#post-334045

modeling is hard so it's easier to use what's already available and without manually typing over coordinates. ;)
 

Star-Dust

Expert
Licensed User
Longtime User
From an idea of @Filippo
32.gif



B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    P3D.Initialize
    P3D.RenderToView(Panel)
End Sub

Sub ButtonClear_Click
    P3D.Initialize
    P3D.RenderToView(Panel)
End Sub

Sub Button1Rotate_Click
    For i=0 To 360 Step 10
        P3D.RotateY(i).RotateZ(SeekBarZ.Value).RotateX(SeekBarX.Value).RenderToView(Panel)
        Sleep(0)
    Next
End Sub

Sub Panel_Touch (Action As Int, X As Float, Y As Float)
    Select Action
        Case Activity.ACTION_DOWN
            LastX=X
            LastY=y
        Case Activity.ACTION_MOVE
            Dim ZoomFrac As Int = 5
            Dim ZFront As Int = 0
            Dim ZBack As Int = -15
            Dim Xi As Int = (LastX-Panel.Width/2)/ZoomFrac
            Dim Yi As Int = (LastY-Panel.Height/2)/ZoomFrac
            Dim Xf As Int = (x-Panel.Width/2)/ZoomFrac
            Dim Yf As Int = (Y-Panel.Height/2)/ZoomFrac
            P3D.AddPolygon(1,Array As Point_Type(P3D.CtP(Xi,Yi,ZFront),P3D.CtP(Xf,Yf,ZFront),P3D.CtP(Xf,Yf,ZBack),P3D.CtP(Xi,Yi,ZBack)),xui.Color_Gray,xui.Color_White).RenderToView(Panel)
            LastX=X
            LastY=y
    End Select
End Sub
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
I suggested to add object file reading and gave an example on how to parse it and display it the fastest way (he called it shared vertices above I believe).
it's based on a speed test I did 6 years ago of which you can see a screenshot and partial code here > https://www.b4x.com/android/forum/threads/simple-3d-wireframe-object.53210/#post-334045

modeling is hard so it's easier to use what's already available and without manually typing over coordinates. ;)
Having done the tests, it seems that the gain in time to kick is not particularly significant and sometimes even slower. There is a memory gain

These are the results by loading the cat file you saw in the example:

*** Service (starter) Create *** ( RENDER WITH VERTICES SEPARATED)
Time load: 110 Vertices: 6246
Time Draw: 88
*** Service (starter) Create *** ( RENDER WITH VERTICES COMMON)
Time load: 92 Vertices: 1136
Time Draw: 127

Here I loaded a heavy OBJ file, containing a glass of coke glass
*** Service (starter) Create ***
Time load: 3637 Vertices: 432534 ( RENDER WITH VERTICES SEPARATED)
Time Draw: 2653
*** Service (starter) Create ***
Time load: 2721 Vertices: 147084 ( RENDER WITH VERTICES COMMON)
Time Draw: 2774

I will return to the previous algorithm
 
Last edited:

sorex

Expert
Licensed User
Longtime User
strange.

rotation calculations should be atleast a lot faster.

using 2 arrays instead of a list would also be faster to store screenbased coordinates.

but it's all guessing as I don't know how it is all working internally for all your other routines.
 
Top