[Closed] Maxscript polyop.getvert
Hello,
i’m importing 4x heightmaps as meshes then attach/weld them in order for me to edit all 4 at the same time.
If i want to export 1 map from the 4 combined, i get weird maps.
The maps should be 257×257 – 66049 vertices but if i only append 65536 vertices then it will look good but will miss the edges.
the mesh https://drive.google.com/open?id=1EDknYhDOyMmYvkUVQGed_m5Z28ZRuS7U
script:
Blockquote
hmVals=#() – Heightmap values Array
– Loop through all the verts in the mesh and append only verts below certain x ycoords
for v=1 to (polyop.getNumVerts $) do
(
vertse = polyop.getVert $ v
if vertse.y < 0 and vertse.x < 0 do
append hmVals (vertse.z as integer)
)
– Generate 1 heightmap mesh
hmRes = (sqrt (30000 / 2)) as integer
t = GenerateKCM worldsize:(hmRes * 10.0) values:hmVals – making the mesh
scale t [32,32,1] – scaling it
move t [-8192, -8192, 0] – moving it
fn GenerateKCM worldSize:8192 values:#(1,2,3,4,5,6,7,8,9) =
(
undo off
(
local res = sqrt values.count
local evenRes = res – 1
local t = mesh width:evenRes length:evenRes lengthSegs:evenRes widthSegs:evenRes wirecolor:(color 115 115 115)
local tmpYOffset
for y = 0 to evenRes do
(
tmpYOffset = y * res + 1
for x=0 to evenRes do
(
setVert t (tmpYOffset + x) [ x, y, values[ tmpYOffset + x] ]
)
)
)
return t
)
< 0 means 256
< 1 means 257
now is there a limit to 65536 or something ? o0
There are several ways to do it. You can clone the object and delete faces, create meshes, etc.
Here is one simple option:
(
-- obj: is the combined map
-- clusters: the same number of maps you combined.
fn SplitObject obj clusters:1 = with undo off
(
clusterNumFaces = obj.numfaces/clusters
for j = (clusters-1) to 1 by -1 do
(
polyop.detachfaces obj #{(j*clusterNumFaces+1)..obj.numfaces} delete:true asnode:true
)
)
SplitObject $ clusters:4
)
If you combine 4 maps (2×2) and then you want to split it in 9 (3×3) this function won’t work, you would need to do something completely different.