# Android QuestionSD XUI_View3D--mesh from a dem--

#### PABLO2013

##### Well-Known Member
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))
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))
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``````

#### Star-Dust

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

#### PABLO2013

##### Well-Known Member
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

#### Star-Dust

##### Expert
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:

#### Star-Dust

##### Expert
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: 118

#### PABLO2013

##### Well-Known Member
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.

#### Star-Dust

##### Expert
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: 123
Last edited:

#### PABLO2013

##### Well-Known Member
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)

many tks.

Last edited:

#### Star-Dust

##### Expert
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

#### PABLO2013

##### Well-Known Member
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.

Last edited:

#### Star-Dust

##### Expert
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.

Replies
11
Views
6K
Android Question Wifi Mesh
Replies
7
Views
1K
Replies
6
Views
1K
Replies
26
Views
10K
Android Example BitmapMeshView
Replies
1
Views
3K