[Обучение] Парсер и моделирование местности (terrain) / Parser and terrain modeling

ntlzthm8

Administrator
[Боженька]
Командный игрок
На днях тут напоролся на одну статью про парсер местности (далее будет понятнее) на одном форуме. Чувак тупо рассказал как криво парсить файлы .h32 в клиенте, вывел это всё в OpenGL и всё на этом. Никакого профита, на деле не было показано.

Из-за долгих споров с местными "топ" разработчиками, эго которых я зацепил своей постоянной критикой 🙂, автор самоудалился, а модеры почистили тему и не оставили следов интересных событий. Какие же все обиженки.

1689051572354.png

Переходим к теме данной темы.

"Земля/terrain" по которой бегают персонажи, мобы и так далее, это генерируемый mesh из карты высот heightMap. Почитать об этом можно в гугле, тут я не буду расписывать. На скрине terrain сгенерированный из карты высот в клиенте.

1689051680537.png

Генерируется это из файла который находится в Levels\'location'\terrain\land_map.h32

Файл читать можно любым языком программирования (java, python, c#).
Ничего сложного в этом файле нет, если считывать его побитово, то получаем следующий формат
2 байта - float значение, 1 байт - цвет (но это не точно)

Python
Python:
Please, Вход or Регистрация to view codes content!
где:
byte_data - это файл land_map.h32
z - координата высоты точки (vertex)
vertex_color - цвет точки (но это не точно)

Java

Java:
Please, Вход or Регистрация to view codes content!
где:
byteData - это файл land_map.h32
heightmap - заполнение массивы высот (далее будет подробнее)
vColor - цвет точки

С#
код можно посмотреть у zzsort по ссылке
Please, Вход or Регистрация to view URLs content!


Далее самое интересное и вкусно, как применить то что мы считываем.

В JMonkeyEngine есть отличная статья
Please, Вход or Регистрация to view URLs content!
а так же очень удобный функционал построения местности по карте высот
Добавляем h32 файл и получаем примерно такой код:
Java:
Please, Вход or Регистрация to view codes content!

По итогу мы получаем готовый mesh вот такого вида:
1689051728951.png

Это упрощенный пример, но на основе его вы можете построить вполне рабочий вариант.

Переходим к варианту с blender. В принципе тут код сложнее, но реализация проще, её можно описать одним скрином

1689051704419.png

Будут вопросы, пишите!)
 
The other day I ran into an article about the terrain parser (it will be clearer later) on one forum. The dude stupidly told how to parse files crookedly .h32 in the client, brought it all to OpenGL and that's it. No profit was actually shown.

Due to long disputes with local "top" developers, whose ego I hooked with my constant criticism, the author withdrew himself, and the moderators cleaned up the topic and left no traces of interesting events. What are all offended.

1689342768073.png

Let's move on to the topic of this topic.

The "land/terrain" on which characters, mobs, and so on run is a generated mesh from the heightMap elevation map. You can read about it in Google, here I will not paint. In the screenshot, the terrain generated from the elevation map in the client.

1689342783611.png

This is generated from a file that is located in Levels\'location'\terrain\land_map.h32

The file can be read in any programming language (java, python, c#).
There is nothing complicated in this file, if you read it bitwise, we get the following format
2 bytes - float value, 1 byte - color (but this is not accurate)

Python
Python:
Please, Вход or Регистрация to view codes content!
where:
byte_data is the land_map.h32 file
z - coordinate of the point height (vertex)
vertex_color - the color of the point (but this is not accurate)

Java

Java:
Please, Вход or Регистрация to view codes content!
where:
byteData is a land_map.h32 file
heightmap - filling in the height array (more details will follow)
vColor - the color of the point

С#
the code can be viewed from zzsort at the link
Please, Вход or Регистрация to view URLs content!


Next, the most interesting and delicious thing is how to apply what we are reading.

In jMonkeyEngine there is an excellent article Hello Terrain as well as a very convenient functionality for plotting terrain on a height map

We add the h32 file and get something like this code:
Java:
Please, Вход or Регистрация to view codes content!

As a result, we get a ready-made mesh of this type:
1689342815467.png

This is a simplified example, but based on it you can build a completely working version.

Let's move on to the option with blender. In principle, the code here is more complicated, but the implementation is simpler, it can be described in one screenshot

1689342824264.png

If you have any questions, write me!)
 
Назад
Верх