Android Question SD XUI_View3D--mesh from a dem--

PABLO2013

Well-Known Member
Licensed User
Longtime User
Greetings, I hope you are well, I want to know how I could create a surface from a dem 4x4, the cell width is 5, this library adapts very well but I don't know how to do it, thanks, I'll give a similar example, thanks

+1000 tks Star-Dust


example:
        Case "Function 3D"
            Dim ID As Int = 0
            For z=-120 To 120 Step 10
                For x=-120 To 120 Step 10
                    Dim NewPointList(2) As Point3D_Type
                    Dim y1 As Int =50 * CosD(z*2) * SinD(x*2)
                    Dim y2 As Int =50* CosD(z*2) * SinD(x*2+20)
                    NewPointList(0)=(P3D.CtP(X,y1,z))
                    NewPointList(1)=(P3D.CtP(X+10,y2,z))
                    P3D.AddPolygon(ID,NewPointList,xui.Color_White,xui.Color_Transparent)
                    ID=ID+1
                Next
            Next
           
            For x=-120 To 120 Step 10
                For z=-120 To 120 Step 10
                    Dim NewPointList(2) As Point3D_Type
                    Dim y1 As Int =50 * CosD(z*2) * SinD(x*2)
                    Dim y2 As Int =50* CosD(z*2+20) * SinD(x*2)
                    NewPointList(0)=(P3D.CtP(X,y1,z))
                    NewPointList(1)=(P3D.CtP(X,y2,z+10))
                    P3D.AddPolygon(ID,NewPointList,xui.Color_White,xui.Color_Transparent)
                    ID=ID+1
                Next
            Next



dem:
   Dim dem(4, 4) As Double
    dem(0, 0) = 100.0
    dem(0, 1) = 50.0
    dem(0, 2) = 70.0
    dem(0, 3) = 10.0
    dem(1, 0) = 10.0
    dem(1, 1) = 10.0
    dem(1, 2) = 10.0
    dem(1, 3) = 10.0
    dem(2, 0) = 10.0
    dem(2, 1) = 220.0
    dem(2, 2) = 10.0
    dem(2, 3) = 10.0
    dem(3, 0) = 10.0
    dem(3, 1) = 10.0
    dem(3, 2) = 10.0
    dem(3, 3) = 10.0


1686269240566.png
 

Star-Dust

Expert
Licensed User
Longtime User
Forgive me but I don't quite understand what you are asking
 
Upvote 0

PABLO2013

Well-Known Member
Licensed User
Longtime User
Hi Star D. Tks for write. I want to plot a Dem (matrix 4x4) . It have 0.0 ....0.1....0.2 positions and values = heights i want plot it like a terrain or mesh like a picture
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
If you see example 1 for B4A, it achieves a similar thing by drawing horizontal and vertical lines passing through the vertices

If I can find some time, I'll give you an example
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Sample for this
B4X:
   Dim dem(4, 4) As Double
    dem(0, 0) = 100.0
    dem(0, 1) = 50.0
    dem(0, 2) = 70.0
    dem(0, 3) = 10.0
    dem(1, 0) = 10.0
    dem(1, 1) = 10.0
    dem(1, 2) = 10.0
    dem(1, 3) = 10.0
    dem(2, 0) = 10.0
    dem(2, 1) = 220.0
    dem(2, 2) = 10.0
    dem(2, 3) = 10.0
    dem(3, 0) = 10.0
    dem(3, 1) = 10.0
    dem(3, 2) = 10.0
    dem(3, 3) = 10.0
 

Attachments

  • dem.zip
    14.4 KB · Views: 66
Upvote 0

PABLO2013

Well-Known Member
Licensed User
Longtime User
Thank you very much, I appreciate your time and your code, I have reviewed many other codes in other languages and yours is the best, it is light, and for applications with limited resources it works very well, I understand that the expectations were not as expected, but I think that these are very specific codes and the interest is more limited, I think, in any case, thanks a lot.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
That's the simplest, but better implementations could be done. Instead of drawing lines, trapezoids could be created which would also give a more realistic light effect.

It also depends on the distance between the dots, maybe 50dip is too little to get the correct ide of the image. Try with 300dip and reduce the zoom from 1 to 0.2 you will have a better effect.

It all depends on what you want to achieve with such a small grid
 

Attachments

  • Dem.zip
    3.4 KB · Views: 66
Last edited:
Upvote 0

PABLO2013

Well-Known Member
Licensed User
Longtime User
Thank you very much, I appreciate your time.
I am going to review what you indicate and I would like to know three additional things:
1. when you talk about trapezoids, how would at least one line of code be.
2. when I add an image to mark a specific point since it is in 2d when rotating In some positions it looks deformed, it is possible to improve this and I still do not.
3. understand roughly the mechanism of data entry to the library. In this case, two "for" statements are added and NewPointList(0) and NewPointList(1) are added. .. and they are added as polygons (I don't understand this two-point polygon...)
3. And to finish... I'm doing this... I draw a 3d figure in autocad (based on triangle blocks), then I go convert with qgis to geojeson (i make a parser) and from there to a 3d object from your library, the process is not very efficient...but it works well in 2d, in 3d it's complicated...is there any idea to do that better...I need this to be selectable parts (individual) to get its data (x,y,z)


1686495666822.png
1686496147699.png


many tks.
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
1. When I was talking about trapezoids I was referring to the vertices you indicated in the first post. In general, 3D objects are represented in the files as many triangles which then make up the objects. In the case of the vertices that you indicated to me by grouping them by 4 you can draw trapezoids which are filled objects, with respect to lines.

2. If the image is warped it is obviously off center and rotated. If it is perfectly aligned parallel to the X axis it is straight. If it is far from the PIVOT point it is distorted from the display trajectory.

3. In reality they are lines, I used the command which easily allowed me to obtain a line with 2 points even if the method is used to draw polygons. If I entered all the points together it would create a polygon with many points and the result would not be correct. The correct solution in terms of logic is the one I posted in the previous post

4. I need to understand better what you want to do
 
Upvote 0

PABLO2013

Well-Known Member
Licensed User
Longtime User
Ok, sorry for making a lot of confusion.

The issue is that I have an electric tower drawn in 3d in autocad) by means of the line between points are around 150 lines, I want to use your library to present it but I also want to select or deselect a particular line and know its x, y, Z values
I did it as indicated in the previous post (I invented a method--autocad--draw triangles as blocks--parse in qgis to geojeson---and convert to P3D.LoadObiectj3 file, it works well for 2d, but for 3d it is very laborious, ...
I used stl format, and it works, but stl format makes the figure a single one as a solid and I want is to be able to touch its parts...I'll make a diagram to see you... ..thank you.
1686509654357.png
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
With my library it is possible to click only one element because it handles the touch event. With the stl format the object is divided into triangles so it will be possible to click triangles not lines.

When you load an STL file all elements acquire the same ID and therefore raise the same event any triangle. So you should modify the reading of the file to assign a different id to each element.

I don't know if the loading and processing speed is sufficient for what you need.
 
Upvote 0
Top