|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| How do you get an X,Y,Z DTM to a mesh in Max?
|
|
|
I’ve been looking at this land height data from Getmapping.com
I downloaded some samples to see if I could use the data before buying the bits I wanted. The files have an .xyz extension. When opened they are just a list of x,y,z coordinated, one per line, no headers or anything else, just a list like this:-
201002.500,810997.500,575.914
201002.500,810992.500,579.075
201002.500,810987.500,582.948
201002.500,810982.500,587.415
201002.500,810977.500,591.849
201002.500,810972.500,595.725
201002.500,810967.500,599.915
but much longer.
So I’m looking for a way to get this data into Max and create a mesh from the x,y,z points. I already looked at the plugins on MAX Plugins.de, DEM to Max and Terrain2, but they don’t seem to support the *.xyz format files.
Does anyone know of a plugin, script or other means to get a mesh from this data? I would think it’s not that big a job to script, for someone who knows maxscript, so there may be a script out there somewhere.
I know I could always download the digital contours as .DWG or .DXF to use with the Terrain compound object, I’ve done this before, but thought these would give me more detail and a cleaner, grid-like, quad mesh.
I attach a sample for anyone who wants to try it.
|
|
|
|
Given only the xyz positions of the vertices it is actually a very difficult job. Importing the data and creating vertices from it is easy, the problem is that there is zero information on which vertices contribute to a particular face. What you have is, in essence, a “point cloud”.
Have a read through the “How to Read and Write Geometry Data” topic in the Maxscript help. You’ll quickly see that without the “face data” you have a real problem on your hands.
Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.
|
|
|
|
I think the data comes in square tiles of 1x1Km for your chosen area. In the sample I’m looking at there are 200 points in both the x and y directions, so that’s 40,000 points in a grid formation at 5m intervals, each with a z height.
What if the script started with a Plain primitive or similar, 1x1Km with 199x199 segments. Then shifted each vertex on the z axis in order?
Must admit, scripting is one aspect of Max I have yet to tackle. I keep thinking about it but never can find the time, I’ve a feeling it will take time. Will take a look at that section though.
|
|
|
|
|
If the data is regular then it may be easier to work with.
Random points are very, very difficult. There are some scripts around, I think, but none of them do a perfect job.
Yes, starting with a Plane with the correct number of vertices would make life much easier indeed.
Would you like me to move this discussion (thread) to the Maxscript forum? May be more appropriate there than here.
Author: Steve_Curley
|
| Replied: 15 December 2009 08:41 AM
|
|
|
|
|
Set your System Units to Metres before you run this. However, if you un-comment the format line and run the script, you will see (in the listener) that the values are not being read correctly.
For example, the first line of the file (201002.500,810997.500,575.914) is being read as 201003.0,810998.0,575.941. A prefect example of Max’s numeric limits (single precision numbers). Fortunately, we only need the Z values which are coming in correctly.
(
local vertCount = 200
fName = getOpenFileName caption:"Open file" types:"(*.xyz)|*.xyz|" fS = undefined if fName != undefined then
fS = openfile fName if fS != undefined do
(
obj = plane length:1000 width:1000 lengthSegs:(vertCount-1) widthsegs:(vertCount-1)
convertToMesh obj
for col = 1 to vertCount do
(
for row = 0 to vertCount - 1 do
(
vertNum = col + (row * vertCount)
fx = readValue fS; fy= readValue fS; fz = readValue fS -- format "col %, row %, vert % - x %, y %, z %\n" col (row+1) vertNum fx fy fz
vPos = getVert obj vertNum
vPos.z = fz
setVert obj vertNum vPos
)
)
update obj
close fS
)
)
Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.
|
|
|
|
That works. Thank you.
The horizontal coords don’t really matter to me. They would only place the mesh miles from the origin, so I would end up moving it back to the centre anyway. They would only be of use if piecing multiple tile togerther, which I don’t need in this case.
And a neat quad mesh too, that will smooth nicely. Not like the nasty tri meshes you get from contours and terrain. Thanks again.
|
|
|
|
|
Glad it helped :)
Author: Steve_Curley
|
| Replied: 15 December 2009 09:19 PM
|
|
|
|
|
Bringing this one back up again. I have a similar, but not the same problem.
I have recieved a Digital Surface Model from an architect for a project. It is in DXF format. I imported it into Max, which took over an hour to do, andd the result was a grid of Point Helpers with varying Z heights as per the terrain.
The thing is there are over 160 thousand of these point helpers which makes Max painfully slow to the point of being unuseable.
The question is, does anyone know of a script or other method to create a mesh with the verts snapped to the points, so I can get rid of all the points and just have a single mesh that I can work with.
Looking at the DXF in a text editor, it may be easier to do directly from the DXF text. It just seems like a list of the points, like this:-
0
SECTION
2
ENTITIES
0
POINT
8
HeightPoint
10
268355.00
20
844155.00
30
33.28
0
POINT
8
HeightPoint
10
268355.00
20
844160.00
30
33.44
0
POINT
8
HeightPoint
10
268355.00
20
844165.00
30
32.86
Which probably makes sense to someone, if you know the DXF format.
It is possible that the architect got the data in the first place from a text file like the one I had at the beginning of this thread, if I could get that I could just use that script again.
|
|
|
|
|
Assuming the source is a kind of points cloud file, ask him (the architect) is it possible
to convert the source into STL. There is software able to do it, I have worked with scanned object this way, I don’t remember how it was done, I chose the STL from the few opportunity they gave to me.
Keep in mind every format is convertible, just a suggestion.
Author: ivan iliev
|
| Replied: 25 February 2011 12:39 AM
|
|
|
|
|
This might help Samab. OpenSource program which converts between dxf and dwg. Max can, ofc, import dwg’s.
Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.
|
|
|
OpenSource program which converts between dxf and dwg. Max can, ofc, import dwg’s.
I have got the DXF into Max (after waiting over an hour for it to load), the problem is what the data is, a bunch of points that make Max very slow. What I want is a mesh defined by the points.
The text view of the DXF suggests that points are all that’s in the file, no geom.
Assuming the source is a kind of points cloud file, ask him (the architect) is it possible
to convert the source into STL.
That’s another option to try. I think my best bet is to call the architect and see if he has an XYZ file of the points, then use Steve’s script, or if he has a mesh of the land.
If none of this comes off, I’ll just have to manually trace the contours off a map and do a terrain. A more laborious and less accurate method. Or see if we can buy the data.
I recall a thread about getting terrain data off Google Earth, but it’s not that detailed.
|
|
|
|