Skip to content

Commit

Permalink
[Meshes] New index and water article (#129)
Browse files Browse the repository at this point in the history
* [Meshes] New index article and article about water
  • Loading branch information
muczc1wek authored Jul 24, 2024
1 parent a7f2bf9 commit 03a2074
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 3 deletions.
3 changes: 0 additions & 3 deletions docs/zengin/meshes.md

This file was deleted.

34 changes: 34 additions & 0 deletions docs/zengin/meshes/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Meshes

In 3D graphics, meshes are collections of vertices, edges, and faces that create 3D objects. ZenGin use meshes to create the world model and objects in the world.

!!! Info
Not all objects that seem to be a mesh are in the "Meshes" category. Except every animated objects, the animation targets (like beds or doors) also belong to the [Animations](../anims/index.md).

## Formats

### Raw

ZenGin uses the `.3ds` file format for raw source meshes. That is one of the file formats used by the [Autodesk 3ds Max](https://en.wikipedia.org/wiki/Autodesk_3ds_Max), which was used by the Gothic developers.

The `.3ds` files can be opened with any 3D modeling software that supports this format. But, to easily import/export them with engine-specific settings, it is recommended to use Blender 2.80+ with the [KrxImpExp](#krximpexp) extension.

**3DS limitations**

The 3DS format has some disadvantages when building levels. With very large levels such as `SURFACE.3DS`, you reach the upper limit of 65,536 triangles per object that are permitted in a `.3ds` file. To get around this problem, proceed as follows: simply “cut” the mesh into several small parts that are below the 64K triangle limit. For example, the `SURFACE.3DS` was dismantled into 4 parts of roughly equal size and then completely exported. This meshes are then merged during the world compilation process into single object in the spacer.

### Compiled

Source formats are great for editing, but can be a bit heavy for the engine use (ASCII based formats are slower to parse and work with), because of that ZenGin compiles these meshes into internal compiled formats. In the case of the world it is `.MSH` format and in the case of objects in the world it is the `.MRM` (multi resolution mesh) with LOD information.

## Tools

### KrxImpExp
Blender add-on that implements support for Gothic 3D formats.

[:octicons-download-16: Download](https://gitlab.com/Patrix9999/krximpexp)

### ZenKit
C++ Library for loading and saving various ZenGin files (including some 3D formats).

[:octicons-arrow-right-24: Read More](../tools/libraries/zenkit.md)
49 changes: 49 additions & 0 deletions docs/zengin/meshes/water.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Water

Water in ZenGin is a special surface. Therefore, there are some rules that have to be followed, to make it work properly.

## Water Modeling

Water is created in Gothic using a double-sided tarp that is assigned a water material. This means you have to create a surface with the normal pointing upwards and the same surface facing downwards again. There must be a floor under the water tarp, otherwise you won't be able to swim. It also makes sense not to connect the double-sided water tarpaulin to the coast, otherwise the coast will follow the wave movement of the water. It's best to let the water run a little into the coast so that the wave movements don't create holes between the water and the coast.

## Segmentation

You should segment (divide) the water surface for the following reasons:

- **Performance**: Areas are always calculated in their entirety. If the area is too large, unnecessary areas (e.g. under an island) are also calculated, which additionally deducts computing power. By segmenting you can delete areas of water that are not visible.
- **Display error**: The entire area is also displayed. However, if the end is out of sight, the water may flicker.
- **Wave movement**: The up and down movement of the water takes place at the corners of the water surfaces. If you have smaller areas, the waves are also more precise.
- In addition, an area that is too large may not work at all, meaning you can walk on it or even fall over.

Water is a big power drain. It is advisable to make the segments towards the coast smaller and smaller so that an unnecessary number of areas in the distance do not have to be calculated, but the wave movement on the coast still looks fine enough. Here are two examples of possible segmentation of the water surface (in Blender):

![Water Segmentation Examples](../../assets/images/segmente.gif)

In the example on the left, the water area was created from squares that get smaller the closer they are to the coast. Since Gothic automatically divides the squares into triangles anyway, the example on the right makes even more sense. The water surface was created from a hexagon and consists of whole or halved equilateral triangles. In addition, the outer boundary of the water is at a more even distance from the coast. In both examples, the segments in the middle of the island are deleted.

## Water Material Properties

To be able to swim in water, you need to place a water material on the double-sided water surfaces. By default, without changing any material settings the water will be frozen. To change that you have to edit [zCMaterial](../worlds/Classes/zCMaterial.md) settings in [Spacer](../worlds/spacer.md).

!!! Tip
You can also place different water materials on the top and bottom.

The most important property - the one that tells the engine that the material is a water and player can swim in it - is [matGroup](../worlds/Classes/zCMaterial.md#matgroup). It has to be set to `WATER`.

To make water look like actual water consider changing following parameters:

- [color](../worlds/Classes/zCMaterial.md#color) - Material color. Something like `150 241 238 200` (in RGBA) will add a little transparency and blue "glow".
- [texAniFPS](../worlds/Classes/zCMaterial.md#texanifps) - Speed at which the animation of the texture should be played.
- [texAniMapDir](../worlds/Classes/zCMaterial.md#texanimapdir) - Speed at which the texture should be moved in the x or y direction (useful for waterfalls and rivers).

Some parameters have only been available since Gothic 2:

- [environmentalMapping](../worlds/Classes/zCMaterial.md#environmentalmapping) - Simulation of a reflection of the surface.
- [environmentalMappingStrength](../worlds/Classes/zCMaterial.md#environmentalmappingstrenght) - Strength of surface reflection.
- [waveMode](../worlds/Classes/zCMaterial.md#wavemode) - Type of wave motion.
- [waveSpeed](../worlds/Classes/zCMaterial.md#wavespeed) - Wave speed. The higher the value, the faster the waves move.
- [waveMaxAmplitude](../worlds/Classes/zCMaterial.md#wavemaxamplitude) - Wave height.
- [waveGridSize](../worlds/Classes/zCMaterial.md#wavegridsize) - Wave expansion.


[^1]: This article is mostly a translation of the one posted on [Gothic Editing Wiki](https://wiki.worldofgothic.de/doku.php?id=quickstart:zengin:wasser)
Binary file added overrides/assets/images/segmente.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 03a2074

Please sign in to comment.