CameraPick, Terrain, and Heightmaps.
Blitz3D Forums/Blitz3D Beginners Area/CameraPick, Terrain, and Heightmaps.
| ||
If I use camerapick to return a triangle from the terrain, does each triangle point correspond to a pixel in the heightmap? If I use the scale of the texture, and the position of the terrain, and the position of the triangle corner, can I reverse enginere to find which pixel in the heightmap represent that triangle corner? Is there a one to one ratio between the pixels in the heightmap and the points in the terrain? |
| ||
Unless the camera is very far away from the terrain then no, a triangle will be made up of many pixels. To see exactly the distribution of triangles in a terrain, use this command after you set the graphics mode WireFrame true This will allow you to see the edges of the triangles which make up the terrain and give you an idea of what scale everything is at. If you are stretching a texture over the whole terrain then yes it is a simple matter to reverse engineer from the pick and find out which pixel in the texture the pick corresponds to. |
| ||
You misunderstand his question, possibly because he mixes up his vocabulary in his post by referring to the "scale of the texture" when the relevant information is dimensions and not scale. He was not asking about the texture on a terrain or about the rendered image of the terrain, he was asking about the heightmap image used to generate the terrain. That said, I have no idea. I doubt it (that is, I doubt each vertex corresponds to a pixel) but I'm not sure since I've never really used Blitz terrain. Logically there can only be a 1 to 1 correlation if the number of vertices is the same as the number of pixels in the heightmap image, and you can set the number of polygons to anything you want with the TerrainDetail command. It may be however that by default, before you use TerrainDetail, terrains are loaded with a number of vertices equal to the number of pixels in the image; I'm just don't know. As for the second part of the question, whether one can determine the heightmap pixel based on knowing information like the vertex position and the heightmap image dimensions, well sure. A terrain is just a regular grid of vertices on the X and Z axes; the shape of a terrain is determined by deflections of the vertices on the Y axis. Thus you can use the X and Z coordinates of a vertex to find the corresponding position on the heightmap image. |
| ||
The answer is yes. If you use ModifyTerrain terrain,1.5,1.5,0.9 or ModifyTerrain terrain,2.0,2.0,0.9 you will see the same triangular area of the terrain modified. the ScaleEntity x,z values times the x,z pixel location in the height map will corrispond to the terrain x,z coords. |
| ||
Actually I need to refrase that. Each pixel in the height map corrisponds to the vertex of 4 different triangles that make up a square. Changing just 1 pixel with ModifyTerrain will make a pointed square with 4 sides. I suggest you exparament with ModifyTerrain. ScaleEntity x,z times x,z coords in height map will corrispond with the Terrain x,z coords of the closest vertex. |