HeightField Data
by Neel "Roy Fokker" Raiyani · in Torque Game Engine · 09/26/2002 (8:20 pm) · 7 replies
I want get the x y and z values from the Ter files. I was looking at the terData.cc, and at bool TerrainBlock::getHeight(const Point2F &pos, F32 *height);
in particular
My Question is, where does getHeight gets is &pos values from.
OR even better,
Is there any function that i am overlooking that gives you the x,y,z coords.
All i want is just the x y and the z coord. Nothin else.
Also is that even possible.??
OR am i just wasting my time, looking for it, and should just make my own thing? (<-- Me Not that smart)
Any Insights Appreciated
Thnkx
in particular
My Question is, where does getHeight gets is &pos values from.
OR even better,
Is there any function that i am overlooking that gives you the x,y,z coords.
All i want is just the x y and the z coord. Nothin else.
Also is that even possible.??
OR am i just wasting my time, looking for it, and should just make my own thing? (<-- Me Not that smart)
Any Insights Appreciated
Thnkx
About the author
#2
In less specific terms, the terrain data is a data set of elevations (z values) at points on a regular grid. An element of elevation data has a corresponding position (x and y values) that can be calculated from its row and column address in the grid scaled by the terrain block's grid size (the norm seems to be 8).
eg An elevation 10 at row 2 column 3 of a terrain block with a grid size of 8 would have the following values x=16, y=8, y=10. (please excuse me if I have inavertantly got my x/y and row/column thingies around the wrong way).
Hope that helps.
09/29/2002 (10:16 pm)
I haven't got the code in front of me right now, so I cannot comment on the actual function you mentioned.In less specific terms, the terrain data is a data set of elevations (z values) at points on a regular grid. An element of elevation data has a corresponding position (x and y values) that can be calculated from its row and column address in the grid scaled by the terrain block's grid size (the norm seems to be 8).
eg An elevation 10 at row 2 column 3 of a terrain block with a grid size of 8 would have the following values x=16, y=8, y=10. (please excuse me if I have inavertantly got my x/y and row/column thingies around the wrong way).
Hope that helps.
#3
09/30/2002 (5:01 am)
You could try using the cast ray function. I'm working on some things that need to know XYZ positions on the level; the raycast is a nice way to bypass having to deal with the complications of multiple/scaled/rotated terrains, use of interiors, etc. The script version tells you the ID of what it hit, normal of the surface, and position of impact of the ray.
#4
-edit-
I may have misread, my function will give you x,y,z of wherever you have the camera, so if that happens to be on the ground, you'll get that value for that point, z+wherevertheeyeis.
09/30/2002 (6:41 am)
x y and z can be got from script, catch me on IRC, I can paste the function when I get home tonight.-edit-
I may have misread, my function will give you x,y,z of wherever you have the camera, so if that happens to be on the ground, you'll get that value for that point, z+wherevertheeyeis.
#5
Based on what have been able to understand of getHeight function, its that it returns the z values for the terrain.
Ok only problem i am having is trying to determine how many point i have to send through before i can get all the height values for that particular terrain.
I know 8 is usually the norm. but if the user changed the square grid sized... i am screwed. since i can't figrue out how to get the grid size for the terrain. :(
09/30/2002 (7:33 am)
Thanks for the responseBased on what have been able to understand of getHeight function, its that it returns the z values for the terrain.
Ok only problem i am having is trying to determine how many point i have to send through before i can get all the height values for that particular terrain.
I know 8 is usually the norm. but if the user changed the square grid sized... i am screwed. since i can't figrue out how to get the grid size for the terrain. :(
#6
09/30/2002 (8:57 am)
So you need the terrain size? Or am I misunderstanding you? Each tile is 256x256, approximately 8 meters to scale on one side. The overall map is 2048x2048. If that helps.
#7
Try the getHeight(x,y) function. It returns the height at a given control point. If you cycle through all 256x256 control points, and call this for each one, you will extract the data stored in the terrain block (and as a result the ter file that generated the terrain block). If you take the x and y values you pass to the function and multiply them by 8, you will get the true x and y values of the position of the control point. pseudo code time:
for(cpy=0,cpy<256,cpy++)
for(cpx=0,cpx<256,cpx++)
x=cpx*8
y=cpy*8
z=terrainblock->getHeight(cpx,cpy)
}
}
Hope that helps, else give more detail of what you are trying to do and I will try again.
10/01/2002 (6:00 am)
To answer your original questions &pos is the position that you want the height of, and *height is the returned value.Try the getHeight(x,y) function. It returns the height at a given control point. If you cycle through all 256x256 control points, and call this for each one, you will extract the data stored in the terrain block (and as a result the ter file that generated the terrain block). If you take the x and y values you pass to the function and multiply them by 8, you will get the true x and y values of the position of the control point. pseudo code time:
for(cpy=0,cpy<256,cpy++)
for(cpx=0,cpx<256,cpx++)
x=cpx*8
y=cpy*8
z=terrainblock->getHeight(cpx,cpy)
}
}
Hope that helps, else give more detail of what you are trying to do and I will try again.
Torque Owner Mike Stoddart