Typically: "How do I... ", "How can I... " questions
yifanzhou
Posts: 4
Joined: 03 Jun 2020, 06:17

Hello,

I am using the model ——terrain bump.ttm. Is it possible to get the position information about the edge point of the terrain bump? As I show in the figure below.

coppelia
Posts: 8450
Joined: 14 Dec 2012, 00:25

### Re: About the terrain bump

Hello,

the data is generated in a generic manner, so you will have to identify where it is generated. In that attached customization script, near the end, you have the generation of the height field. You can modify the code to something like following, in order to visualize the individual points:

Code: Select all

    local points={}
local xSize=dxs
local ySize=yt*dxs/xt
local dx=xSize/xt
local dy=ySize/yt
for y=1,yt,1 do
for x=1,xt,1 do
xp=(x-xt/2)/(xt/2)
yp=(y-yt/2)/(yt/2)
r=dps*math.sqrt(t1*xp*xp+t2*yp*yp)
nh=dzs/((r*r)+1)
if (nh<minw) then minw=nh end
if (nh>maxw) then maxw=nh end
table.insert(heights,nh)
local pos={-xSize*0.5+(x-1)*dx,-ySize*0.5+(y-1)*dy,nh}
points[#points+1]=pos
end
end
bumpShape=sim.createHeightfieldShape(options,0,xt,yt,dxs,heights)

sim.setObjectName(bumpShape,objName)
sim.setObjectProperty(bumpShape,objProperty)
sim.setObjectSpecialProperty(bumpShape,objSpecialProperty)
sim.setObjectParent(bumpShape,h,true)
scaling=(maxw-minw)/(maxv-minv)
matr[12]=matr[12]*scaling
local oldM=sim.getObjectMatrix(bumpShape,-1)
sim.setObjectMatrix(bumpShape,sim.handle_parent,matr)
local newM=sim.getObjectMatrix(bumpShape,-1)
if config.textured then
sim.setShapeTexture(bumpShape,bumpTextureId,sim.texturemap_plane,4+8,{1,1})
sim.setShapeColor(bumpShape,'',0,{1,1,1})
else
sim.setShapeColor(bumpShape,'',sim.colorcomponent_ambient_diffuse,config.color)
end
end