S
S
Stratimon2015-10-23 18:59:29
C++ / C#
Stratimon, 2015-10-23 18:59:29

World Editor war3 in c++ and openGl?

There is a map editor for war3 World Editor where, when editing a map, the Z coordinate of three corners changes and thus elevations or depressions are made (there are many more functions, but I don’t need it).
And so I sit and think how it's done =)
just no ideas
Tell me pliz. As I understand it, the whole map is made of three squares, and when the landscape changes, they change one Z coordinate.
Yes, I do not argue, you can make redneck coding easy. Create a bunch of variables and put them on the Z coordinate of the three gons. But let's imagine that I have 500 three-gons each with 3 points, that is, 500 * 3 = 1500 variables, well, this is nonsense!
You can make a function from drawing three squares that takes x, y, z, z1, z2 and put it in for which repeats it 4 times and draws a square, in turn put it in for which repeats this all n times and draws a map. But the question is how can I change the z of the desired trigon? or rather, four three-gons!
In short, the ideas of transcription!
Here is a video of World Editor war3 if someone doesn't know
https://www.youtube.com/watch?v=56u8KbqiJxw&featur...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stanislav Makarov, 2015-10-23
@Sratimon

But let's imagine that I have 500 three-gons each with 3 points, that is, 500 * 3 = 1500 variables, well, this is nonsense!

Really, I've never seen anything more crazy. Have you heard about structs, classes, arrays? What's stopping you from doing this:
struct point {
   float x, y, z;
};

struct triangle {
  point points[3];
};

triangle triangles[500]; // вот ваши 500 треугольников, рисуйте их как хотите
triangles[234].points[3].z = 155; // вот я меняю координату у 234-го треугольника

M
MiiNiPaa, 2015-10-23
@MiiNiPaa

WC3 stores the terrain in the file as a contiguous array of points (line by line). Each dot occupies 7 bytes.
The first 2 bytes are the height of the landscape at that point. Then 2 bytes of water height + service flag, 4 bits of flags, 4 bits - terrain type (so you can’t cram more than 16 textures into the map, no matter how hard you try) 1 byte of landscape decorations, 4 bits of cliff type and 4 bits of cliff level.
All these "triangles" are fiction - they are drawn by the game at the time of rendering for the player on the fly using information about the terrain and have no effect on the simulation of the game itself.

S
Stanislav Silin, 2015-10-23
@byme

I did not understand your idea with 3 triangles a little, can you be more specific?
My idea is the following:
We take a height map (you can just use a matrix to start with, it doesn't change the essence). Then for each pixel (cell) we calculate the position on the OXY plane and, depending on the height in this pixel, put n cubes on top of each other.
You need to keep in memory a height map and a cube model, which we will draw in the places we need.
But it all depends on how detailed the map should be. I recommend reading about terrain rendering.
PS Then it will be possible to optimize so that invisible cubes are not drawn, but that's a completely different story ..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question