mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 14:31:50 +00:00
Merge pull request #969 from MihailRis/add-normal-to-rect-in-vcm
Add normal to 'rect' and 'tri' primitives in vcm
This commit is contained in:
commit
c61b13cb63
3 changed files with 25 additions and 11 deletions
|
|
@ -41,6 +41,7 @@ This primitive describes a triangle.
|
||||||
- `region` - UV region within the selected texture, defined by the positions of opposite corners of a square of normalized texture coordinates. Example: `region (0,0,1,1)`
|
- `region` - UV region within the selected texture, defined by the positions of opposite corners of a square of normalized texture coordinates. Example: `region (0,0,1,1)`
|
||||||
- `region-scale` - multiplier vector for the UV region. Example: `region-scale (0.5,1)`
|
- `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`
|
- `shading` - determines whether shading is enabled on the primitive. Example: `shading off`
|
||||||
|
- `normal` - overrides normal vector. Example: `normal (0,1,0)`
|
||||||
|
|
||||||
By default, texture coordinates are not affected by shape or size, unlike other primitives.
|
By default, texture coordinates are not affected by shape or size, unlike other primitives.
|
||||||
|
|
||||||
|
|
@ -56,6 +57,7 @@ This primitive describes a parallelogram using the right and up vectors.
|
||||||
- `region-scale` - the multiplier vector for the automatically selected UV region. Example: `region-scale (0.5,1)`
|
- `region-scale` - the multiplier vector for the automatically selected UV region. Example: `region-scale (0.5,1)`
|
||||||
- `shading` - determines whether shading is enabled on the primitive. Example: `shading off`
|
- `shading` - determines whether shading is enabled on the primitive. Example: `shading off`
|
||||||
- `flip` - flips the UV region horizontally or vertically. Example: `flip v`
|
- `flip` - flips the UV region horizontally or vertically. Example: `flip v`
|
||||||
|
- `normal` - overrides normal vector. Example: `normal (0,1,0)`
|
||||||
|
|
||||||
### `box` Properties
|
### `box` Properties
|
||||||
|
|
||||||
|
|
@ -66,8 +68,8 @@ This primitive describes a rectangular parallelepiped.
|
||||||
- `origin` - the point relative to which the rotation will be applied. Default: the center of the primitive. Example: `origin (0.5,0.5,0.5)`
|
- `origin` - the point relative to which the rotation will be applied. Default: the center of the primitive. Example: `origin (0.5,0.5,0.5)`
|
||||||
- `rotate` - rotation around the (x,y,z) axes in degrees, or a quaternion (x,y,z,w). Example: `rotate (45,0,0)` or `rotate (0.3826834, 0, 0, 0.9238795)`
|
- `rotate` - rotation around the (x,y,z) axes in degrees, or a quaternion (x,y,z,w). Example: `rotate (45,0,0)` or `rotate (0.3826834, 0, 0, 0.9238795)`
|
||||||
- `texture` - the default texture to display for all sides.
|
- `texture` - the default texture to display for all sides.
|
||||||
- `shading` determines whether shading is enabled on the primitive. Example: `shading off`
|
- `shading` - determines whether shading is enabled on the primitive. Example: `shading off`
|
||||||
- `delete` deletes sides by name (top, bottom, east, west, north, south)
|
- `delete` - deletes sides by name (top, bottom, east, west, north, south)
|
||||||
|
|
||||||
### `part` properties (nested in `box`)
|
### `part` properties (nested in `box`)
|
||||||
|
|
||||||
|
|
@ -76,7 +78,7 @@ This primitive describes the properties of the sides of a rectangular parallelep
|
||||||
- `tags` - determines which side the properties will be applied to. Example: `tags (top,bottom)`
|
- `tags` - determines which side the properties will be applied to. Example: `tags (top,bottom)`
|
||||||
- `texture` - the texture to display. Default: `$side_index`.
|
- `texture` - the texture to display. Default: `$side_index`.
|
||||||
- `region` - the UV region within the selected texture, defined by the positions of opposite corners. Example: `region (0,0,1,1)`
|
- `region` - the UV region within the selected texture, defined by the positions of opposite corners. Example: `region (0,0,1,1)`
|
||||||
- `region-scale` is a multiplier vector for the automatically selected UV region. Example: `region-scale (0.5,1)`
|
- `region-scale` - multiplier vector for the automatically selected UV region. Example: `region-scale (0.5,1)`
|
||||||
|
|
||||||
## Skeleton
|
## Skeleton
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@
|
||||||
- `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов квадрата нормализованных текстурных координат. Пример: `region (0,0,1,1)`
|
- `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов квадрата нормализованных текстурных координат. Пример: `region (0,0,1,1)`
|
||||||
- `region-scale` вектор-множитель для UV региона. Пример: `region-scale (0.5,1)`
|
- `region-scale` вектор-множитель для UV региона. Пример: `region-scale (0.5,1)`
|
||||||
- `shading` определяет возможность затенения на примитиве. Пример: `shading off`
|
- `shading` определяет возможность затенения на примитиве. Пример: `shading off`
|
||||||
|
- `normal` переопределяет вектор нормали. Пример: `normal (0,1,0)`
|
||||||
|
|
||||||
Текстурные координаты по-умолчанию не зависят от формы из размера, в отличие от других примитивов.
|
Текстурные координаты по-умолчанию не зависят от формы из размера, в отличие от других примитивов.
|
||||||
|
|
||||||
|
|
@ -53,9 +54,10 @@
|
||||||
- `up` - вектор Y, также определяющий высоту примитива. Пример: `up (0,1,0)`
|
- `up` - вектор Y, также определяющий высоту примитива. Пример: `up (0,1,0)`
|
||||||
- `texture` - отображаемая текстура. По-умолчанию: `$0`. Пример: `texture "blocks:sand"`
|
- `texture` - отображаемая текстура. По-умолчанию: `$0`. Пример: `texture "blocks:sand"`
|
||||||
- `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов. Пример: `region (0,0,1,1)`
|
- `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов. Пример: `region (0,0,1,1)`
|
||||||
- `region-scale` вектор-множитель для автоматически выбранного UV региона. Пример: `region-scale (0.5,1)`
|
- `region-scale` - вектор-множитель для автоматически выбранного UV региона. Пример: `region-scale (0.5,1)`
|
||||||
- `shading` определяет возможность затенения на примитиве. Пример: `shading off`
|
- `shading` - определяет возможность затенения на примитиве. Пример: `shading off`
|
||||||
- `flip` отражает UV регион по горизонтали или вертикали. Пример: `flip v`
|
- `flip` - отражает UV регион по горизонтали или вертикали. Пример: `flip v`
|
||||||
|
- `normal` - переопределяет вектор нормали. Пример: `normal (0,1,0)`
|
||||||
|
|
||||||
### Свойства `box`
|
### Свойства `box`
|
||||||
|
|
||||||
|
|
@ -66,8 +68,8 @@
|
||||||
- `origin` - точка, относительно которой будет применено вращение. По-умолчанию: центр примитива. Пример: `origin (0.5,0.5,0.5)`
|
- `origin` - точка, относительно которой будет применено вращение. По-умолчанию: центр примитива. Пример: `origin (0.5,0.5,0.5)`
|
||||||
- `rotate` - вращение вокруг осей (x,y,z) в градусах, или кватернион (x,y,z,w). Пример: `rotate (45,0,0)` или `rotate (0.3826834, 0, 0, 0.9238795)`
|
- `rotate` - вращение вокруг осей (x,y,z) в градусах, или кватернион (x,y,z,w). Пример: `rotate (45,0,0)` или `rotate (0.3826834, 0, 0, 0.9238795)`
|
||||||
- `texture` - отображаемая текстура для всех сторон по-умолчанию.
|
- `texture` - отображаемая текстура для всех сторон по-умолчанию.
|
||||||
- `shading` определяет возможность затенения на примитиве. Пример: `shading off`
|
- `shading` - определяет возможность затенения на примитиве. Пример: `shading off`
|
||||||
- `delete` удаляет стороны по именам (top, bottom, east, west, north, south)
|
- `delete` - удаляет стороны по именам (top, bottom, east, west, north, south)
|
||||||
|
|
||||||
### Свойства `part` (вложен в `box`)
|
### Свойства `part` (вложен в `box`)
|
||||||
|
|
||||||
|
|
@ -76,7 +78,7 @@
|
||||||
- `tags` - определяет то, на какаие из сторон будут применены свойства. Пример: `tags (top,bottom)`
|
- `tags` - определяет то, на какаие из сторон будут применены свойства. Пример: `tags (top,bottom)`
|
||||||
- `texture` - отображаемая текстура. По-умолчанию: `$индекс_стороны`.
|
- `texture` - отображаемая текстура. По-умолчанию: `$индекс_стороны`.
|
||||||
- `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов. Пример: `region (0,0,1,1)`
|
- `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов. Пример: `region (0,0,1,1)`
|
||||||
- `region-scale` вектор-множитель для автоматически выбранного UV региона. Пример: `region-scale (0.5,1)`
|
- `region-scale` - вектор-множитель для автоматически выбранного UV региона. Пример: `region-scale (0.5,1)`
|
||||||
|
|
||||||
## Скелет
|
## Скелет
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,12 @@ static void perform_rect(const xmlelement& root, ModelBuilder& builder) {
|
||||||
}
|
}
|
||||||
std::string texture = root.attr("texture", "$0").getText();
|
std::string texture = root.attr("texture", "$0").getText();
|
||||||
|
|
||||||
auto normal = glm::cross(glm::normalize(right), glm::normalize(up));
|
glm::vec3 normal;
|
||||||
|
if (root.has("normal")) {
|
||||||
|
normal = root.attr("normal").asVec3();
|
||||||
|
} else {
|
||||||
|
normal = glm::cross(glm::normalize(right), glm::normalize(up));
|
||||||
|
}
|
||||||
builder.addRect(
|
builder.addRect(
|
||||||
texture,
|
texture,
|
||||||
shading,
|
shading,
|
||||||
|
|
@ -218,7 +223,12 @@ static void perform_triangle(const xmlelement& root, ModelBuilder& builder) {
|
||||||
|
|
||||||
glm::vec3 ba = pointB - pointA;
|
glm::vec3 ba = pointB - pointA;
|
||||||
glm::vec3 ca = pointC - pointA;
|
glm::vec3 ca = pointC - pointA;
|
||||||
glm::vec3 normal = glm::normalize(glm::cross(ba, ca));
|
glm::vec3 normal;
|
||||||
|
if (root.has("normal")) {
|
||||||
|
normal = root.attr("normal").asVec3();
|
||||||
|
} else {
|
||||||
|
normal = glm::normalize(glm::cross(ba, ca));
|
||||||
|
}
|
||||||
|
|
||||||
if (root.has("uv")) {
|
if (root.has("uv")) {
|
||||||
root.attr("uv").asNumbers(glm::value_ptr(uvs[0]), 6);
|
root.attr("uv").asNumbers(glm::value_ptr(uvs[0]), 6);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue