B4A Library [BAX] [XUI] SD XUI_View3D

Star-Dust

Expert
Licensed User
Longtime User
I was asked how to figure out which face of the 3D object was touched with the mouse.

I am attaching a cross-platform B4XPages example which allows you to understand how to do it
 

Attachments

  • View3D_Sample_FaceID.zip
    3.3 KB · Views: 107

PABLO2013

Well-Known Member
Licensed User
Longtime User
greetings thank you.
In my sample I cannot choose the correct face, in a cube if I touch face 1 (it is shown on the screen as the one in front), face 2 is selected. Through the case I selected the correct face, how to improve this, thank you.





B4X:
If Action=1  Then 'Tuoch UP
        Dim Pt As Int = P3D.PointClick(X,Y,True)
    End If

        If Pt>-1 Then
            Dim pnt As Type_Polygon=P3D.ListObject.Get(Pt-1)      
'            ll1t.Text=$"Touch Face ID:${pnt.ID} - N.Vertice: ${pnt.ListVertices.Size}"$
            Log($"Touch Face ID:${pnt.ID} - N.Vertice: ${pnt.ListVertices.Size}"$)
        End If



B4X:
If Action=1  Then 'Tuoch UP
        Dim Pt As Int = P3D.PointClick(X,Y,True)
    End If

    Case 1
           Pt=4
        Case 2
            Pt=1
        Case 3
           Pt=2
        Case 4
           Pt=3  



        If Pt>-1 Then
            Dim pnt As Type_Polygon=P3D.ListObject.Get(Pt-1)      
'            ll1t.Text=$"Touch Face ID:${pnt.ID} - N.Vertice: ${pnt.ListVertices.Size}"$
            Log($"Touch Face ID:${pnt.ID} - N.Vertice: ${pnt.ListVertices.Size}"$)
        End If



Other another thing , how used P3D.setColor
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Identifying the clicked face is not always easy also due to the perspective, the library has not been developed and updated for years and may have some imperfections.

As for setColor these are the parameters:
B4X:
setColor(IDList As List, BorderColor As Int, FillColor As Int)

An example of use:
B4X:
setColor(array As Int(1), xui.Color_Balck, xui.Color_White)

In the ID field, instead of a single internal number, there is a list so as to allow you to change the color of several groups at the same time
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
IMPORTANT.
I removed the library because someone opened the sources (B4Xlib) without my consent. From now on only an updated compiled version will be available. There will no longer be a B4XLib version available. I reserve the right to publish the next updates in a limited version.

I do not authorize to open or decompile in order to obtain the original source. I do not authorize any changes to the source.
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
A new example with sensor-based 3D motion. The example can be found in the attachment



This is an example that I didn't attach.
 

Attachments

  • 3Dsensor.zip
    9.7 KB · Views: 25
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…