[XUI] 3D, rotations and pivots

Star-Dust

Expert
Licensed User
Longtime User
Thank's, good suggest
 

moster67

Expert
Licensed User
Longtime User
I am sure that your work generates interest but the thing is, like in my case, I don't have currently a "usecase" for it but rest assured it is imprinted in my memory somewhere so when I need it, I will remember it.
However, ideally, as suggested by others, is to make a library thread and a sample project, then it will be easier for other users to find and try your work.
Keep up the good work!
 

Star-Dust

Expert
Licensed User
Longtime User
I am sure that your work generates interest but the thing is, like in my case, I don't have currently a "usecase" for it but rest assured it is imprinted in my memory somewhere so when I need it, I will remember it.
However, ideally, as suggested by others, is to make a library thread and a sample project, then it will be easier for other users to find and try your work.
Keep up the good work!
An example I attached to post # 14 with source code
But I suppose the problem is that I'm not clear either, what kind of application can use a similar code.
I think too slow for a game, too complex to create a 3D menu and a 3D interface. Too little to create a sw for modeling objects.

I have no idea, I will probably start from the idea that gave me the boost, the Rubik's cube, following the suggestion of @JordiCP
 

Star-Dust

Expert
Licensed User
Longtime User
I tried the XUI code with B4J. The video is poor but makes the idea good.
Greater fluidity (as can be expected) and the same 3D effect.
16j.gif
ezgif.com-video-to-gif.gif

We will have to test it for IOS, we'll see in the future.

update sphere:
17.gif
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
This is the last update.
I have changed the rendering again in order to have full objects and calculate the priority, ie the faces that are in front and the back ones. But unfortunately they are still struggle to work properly.

Also I should correct the perspective and enter color calculations based on the light source.

18.gif

But at this point I need help. So I stop here and start again as soon as I get a new inspiration.
For the moment, I stop the project and go back to my main activities.
 

Peter Simpson

Expert
Licensed User
Longtime User
You do not ask me questions ... maybe you get bored ...

That's a 100% yes from me.
I've been watching boths yours and @JordiCP threads with interest as I can see a B4X developer creating a rubics cube like game using one of the 3D methods created by you or JCP.

Both of you keep up the great work. I may not ask any quedtions, but I do enjoy learning from reading both of your threads.
 

Star-Dust

Expert
Licensed User
Longtime User
Thank you. Sometimes I do not have time and I disappear, but when I go back to programming I try to achieve something that stimulates me.
I could do App management and billing and maybe I would be rich ... but I would die of boredom. What are you doing with a rich dead man? Better a poor live :p

@JordiCP is much better, has made clickable and animated 3D views. Really exceptional.
He has always done interesting things with graphics.
 

Star-Dust

Expert
Licensed User
Longtime User
To get the Click of each face, you should check if the point touched is inside the polygon.
How can this be achieved?

You have to draw an ideal line from point of touch to the other (or the bottom) and count the number of lines that touch each other.
If the number is even then it is outside the polygon, if it is odd it is inside
upload_2018-6-12_11-52-28.png

Let's assume we have these two points (one the yellow one and the other the blue one) and we want to know if they are inside the polygon ... count the intersecting lines.

see this: https://en.wikipedia.org/wiki/Point_in_polygon

see here the java impementation: https://www.hwupgrade.it/forum/showthread.php?t=2368254
 
Last edited:

JordiCP

Expert
Licensed User
Longtime User
I could do App management and billing and maybe I would be rich ... but I would die of boredom. What are you doing with a rich dead man? Better a poor live :p
Hehe, i know what you mean :D. In my case I have always liked the 'mix' of programming with graphics and some maths here and there, so for me it's the perfect combination (and a great danger!!) to procrastinate from time to time (I use B4X quite often in my daily work, so it's easier to fall into temptation as the IDE is nearly always there :mad:)

Stopping from time to time, let the idea rest and bring it back to life later is a good idea. I'm sure we'll see more advances soon :)
 

Star-Dust

Expert
Licensed User
Longtime User
Tonight I could spend a couple of hours and finally I added the identifier of touch on 3D objects.

To understand the method, see post#29. There is a simple algorithm that allows to verify if a point is inside a polygon delineated by the path method.

24.gif


To make a significant breakthrough I should have a map for each 3D object.

In the key field enter the ID identifier and in the value field a custom type containing the list of points that represents it and in the case of the image the bitmapCreator.

This would mean rewriting all the code, because now I use a coarser system, putting all the data in a list of different types. This slows me down.

But I do not want to rewrite everything. I will take another long pause to understand how to do it.

___________________________________________________________________________
UPDATE: I have rewritten all the code. :D:D:D :confused::confused::confused::confused:
Next step: since I'm tired, find testers willing to produce some sample apps with my library and to test any (certain) bugs.
___________________________________________________________________
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Incredible, every time I love these B4X tools, I also thank people like you who always surprise you. Thank you!!
Thank you.

With the new rewriting, the code has been reduced considerably. From over 1400 lines of code to just over 800 lines.
Now the code is leaner and more readable and even slightly faster.

Now I will work to completely eliminate B4Canvas for the fastest BitmapCreator and I have to improve the prospects.

Update: For abandonment B4XCanvas I have to rebuild 2 commands in BiptampCreator. Line (x, y) - (x2, y2) to make the DrawPath, and it is also the command for the filler the polygon traced by the path.

For the lines I used this algorithm, but modified because in some cases the original algorithm lines seem to be discontinuous: https://it.wikipedia.org/wiki/Algoritmo_di_rasterizzazione_di_linea
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
I'm ready to release a alfa version.

Who is willing to collaborate on this crazy project, developing and testing the library, contact me in private. I enclose the example, I will send the Library in private.

An example of the speed that reaches now:
25.gif
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
This is a small deformation effect giving the wrong (specifically) coordinates of the image
26.gif



The first figure is how the coordinates should be drawn, the image is all on the same plane because the value of the Z axis is equal for the 4 points.

In figure 2 the vertices at the bottom of the image have X the same while they change on the Z axis. In the third figure we can see from above.
upload_2018-6-21_18-32-8.png
 

Star-Dust

Expert
Licensed User
Longtime User
Other animations created with my library.

Semi-Sphere and 3D function
27.gif
28.gif

____________________________________________________________________________
VISIBILY PRIORITY
For the priority on the Z plane I am using the painter's algorithm that you find explained here:
https://en.wikipedia.org/wiki/Painter's_algorithm

The best, but slower, algorithm is the Z-Buffer. I particularly like it, in order to implement it we must have a matrix containing the Z value for each point drawn.
If you draw on the same point, it occurs if the Z value of the previous writing is lower or higher. If it is higher, the point is overwritten, otherwise it is a point behind it and therefore so don't should be drawn. See here for a better explanation:
https://en.m.wikipedia.org/wiki/Z-buffering
This method works well if you use BitmapCreator to save the image in a Vector. Each point is stored on 4 bytes. It would be enough to have a second vector with the 5th byte, the depth.
Unfortunately I left the BitmapCreator Matrix in favor of Canvas ...
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
With suggestions from @sorex who worked on a project similar years ago, I speeded up rendering of polygons and added to the possibility of loading lightweight obj files.

I still have to implement some methods to speed up the calculations but already the result is this
30.gif
29.gif
 
Last edited:
Top