diff --git a/doc/en/vcm.md b/doc/en/vcm.md index 116d9a1d6..b09c615a4 100644 --- a/doc/en/vcm.md +++ b/doc/en/vcm.md @@ -42,6 +42,7 @@ This primitive describes a triangle. - `region-scale` - multiplier vector for the UV region. Example: `region-scale (0.5,1)` - `shading` - determines whether shading is enabled on the primitive. Example: `shading off` - `normal` - overrides normal vector. Example: `normal (0,1,0)` +- `cull-face` - determines which side will be culled. Example: `cull-face front` or `cull-face off` (disables face culling) By default, texture coordinates are not affected by shape or size, unlike other primitives. @@ -58,6 +59,7 @@ This primitive describes a parallelogram using the right and up vectors. - `shading` - determines whether shading is enabled on the primitive. Example: `shading off` - `flip` - flips the UV region horizontally or vertically. Example: `flip v` - `normal` - overrides normal vector. Example: `normal (0,1,0)` +- `cull-face` - determines which side will be culled. Example: `cull-face front` or `cull-face off` (disables face culling) ### `box` Properties diff --git a/doc/ru/vcm.md b/doc/ru/vcm.md index 335f6a7a7..0a1dbc314 100644 --- a/doc/ru/vcm.md +++ b/doc/ru/vcm.md @@ -42,6 +42,7 @@ - `region-scale` вектор-множитель для UV региона. Пример: `region-scale (0.5,1)` - `shading` определяет возможность затенения на примитиве. Пример: `shading off` - `normal` переопределяет вектор нормали. Пример: `normal (0,1,0)` +- `cull-face` - определяет, какая сторона будет отсечена. Пример: `cull-face front` или `cull-face off` (отлючает отсечение сторон) Текстурные координаты по-умолчанию не зависят от формы из размера, в отличие от других примитивов. @@ -58,6 +59,7 @@ - `shading` - определяет возможность затенения на примитиве. Пример: `shading off` - `flip` - отражает UV регион по горизонтали или вертикали. Пример: `flip v` - `normal` - переопределяет вектор нормали. Пример: `normal (0,1,0)` +- `cull-face` - определяет, какая сторона будет отсечена. Пример: `cull-face front` или `cull-face off` (отлючает отсечение сторон) ### Свойства `box` diff --git a/src/coders/vcm.cpp b/src/coders/vcm.cpp index 42a503477..a1ca758de 100644 --- a/src/coders/vcm.cpp +++ b/src/coders/vcm.cpp @@ -198,6 +198,31 @@ static void perform_rect(const xmlelement& root, ModelBuilder& builder) { } else { normal = glm::cross(glm::normalize(right), glm::normalize(up)); } + + auto cullFace = root.attr("cull-face", "back").getText(); + if (cullFace == "front") { + normal *= -1.0f; + } else if (cullFace == "off") { + builder.addRect( + texture, + shading, + from + right * 0.5f + up * 0.5f, + right * 0.5f, + up * 0.5f, + normal, + region + ); + builder.addRect( + texture, + shading, + from + right * 0.5f + up * 0.5f, + right * -0.5f, + up * -0.5f, + -normal, + region + ); + return; + } builder.addRect( texture, shading, @@ -246,6 +271,17 @@ static void perform_triangle(const xmlelement& root, ModelBuilder& builder) { } std::string texture = root.attr("texture", "$0").getText(); + + auto cullFace = root.attr("cull-face", "back").getText(); + if (cullFace == "front") { + std::swap(pointB, pointC); + std::swap(uvs[1], uvs[2]); + normal *= -1.0f; + } else if (cullFace == "off") { + builder.addTriangle(texture, shading, pointA, pointB, pointC, normal, uvs[0], uvs[1], uvs[2]); + builder.addTriangle(texture, shading, pointA, pointC, pointB, -normal, uvs[0], uvs[2], uvs[1]); + return; + } builder.addTriangle(texture, shading, pointA, pointB, pointC, normal, uvs[0], uvs[1], uvs[2]); }