add 'region', 'region-scale' properties
This commit is contained in:
parent
da107309ac
commit
27b194816b
@ -32,6 +32,9 @@ static void perform_rect(const xmlelement& root, model::Model& model) {
|
|||||||
} else {
|
} else {
|
||||||
region.scale(glm::length(right), glm::length(up));
|
region.scale(glm::length(right), glm::length(up));
|
||||||
}
|
}
|
||||||
|
if (root.has("region-scale")) {
|
||||||
|
region.scale(root.attr("region-scale").asVec2());
|
||||||
|
}
|
||||||
|
|
||||||
auto flip = root.attr("flip", "").getText();
|
auto flip = root.attr("flip", "").getText();
|
||||||
if (flip == "h") {
|
if (flip == "h") {
|
||||||
@ -87,6 +90,12 @@ static void perform_box(const xmlelement& root, model::Model& model) {
|
|||||||
if (elem->has("texture")) {
|
if (elem->has("texture")) {
|
||||||
texfaces[idx] = elem->attr("texture").getText();
|
texfaces[idx] = elem->attr("texture").getText();
|
||||||
}
|
}
|
||||||
|
if (elem->has("region")) {
|
||||||
|
regions[idx].set(elem->attr("region").asVec4());
|
||||||
|
}
|
||||||
|
if (elem->has("region-scale")) {
|
||||||
|
regions[idx].scale(elem->attr("region-scale").asVec2());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,7 +140,9 @@ static std::unique_ptr<model::Model> load_model(const xmlelement& root) {
|
|||||||
return std::make_unique<model::Model>(std::move(model));
|
return std::make_unique<model::Model>(std::move(model));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<model::Model> vcm::parse(std::string_view file, std::string_view src) {
|
std::unique_ptr<model::Model> vcm::parse(
|
||||||
|
std::string_view file, std::string_view src
|
||||||
|
) {
|
||||||
auto doc = xml::parse(file, src);
|
auto doc = xml::parse(file, src);
|
||||||
const auto& root = *doc->getRoot();
|
const auto& root = *doc->getRoot();
|
||||||
if (root.getTag() != "model") {
|
if (root.getTag() != "model") {
|
||||||
|
|||||||
@ -53,6 +53,10 @@ struct UVRegion {
|
|||||||
v2 = cy + h * 0.5f * y;
|
v2 = cy + h * 0.5f * y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scale(const glm::vec2& vec) {
|
||||||
|
scale(vec.x, vec.y);
|
||||||
|
}
|
||||||
|
|
||||||
void set(const glm::vec4& vec) {
|
void set(const glm::vec4& vec) {
|
||||||
u1 = vec.x;
|
u1 = vec.x;
|
||||||
v1 = vec.y;
|
v1 = vec.y;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user