Merge pull request #987 from MihailRis/vcm-cull-face

add VCM 'cull-face' parameter
This commit is contained in:
MihailRis 2026-09-25 21:09:16 +03:00 • committed by GitHub
commit 38e8366afa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 0 deletions

View file

@ -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

View file

@ -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`

View file

@ -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]);
}