Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:syoyo/tinyusdz into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
syoyo committed Jul 28, 2023
2 parents 5cc8b10 + f6f53e6 commit 0099503
Show file tree
Hide file tree
Showing 13 changed files with 3,599 additions and 889 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ TinyUSDZ is in v0.8.0 release candidate.
Core loading feature(both USDA and USDC) is now working and production-grade(And no seg fault for corrupted USDA/USDC/USDZ input).

v0.8.0 is Flattened scene only(i.e, USDA/USDC generated by using pxrUSD's `usdcat --flatten` or USDZ scene).
Composition features are work-in-progress(experimental Composition feature support in next major release v0.9.0(Q3/2023 expected) planned)
Composition features are work-in-progress(experimental Composition feature support in v0.8.0. Better composition feature in next major release v0.9.0(Q4/2023 expected) planned)

Remaining tasks for v0.8.0 release are writing examples, demos and utility functions(Tydra).
Remaining tasks for v0.8.0 release are writing examples, demos and utility functions(Tydra. Especially access to Material/Shader attributes).

* [x] USDZ/USDC(Crate) parser
* USDC Crate version v0.8.0(most commonly used version as of 2022 Nov) or higher is supported.
* [ ] USDZ/USDC(Crate) writer (Work-in-progress)
* [x] USDA parser(Hand-written from a scratch. No Bison/Flex dependency!)
* [x] USDA writer
* [x] Support basic Primitives(Xform, Mesh, BasisCurves, etc.), basic Lights and Shaders(UsdPreviewSurface, UsdUVTexture, UsdPrimvarReader)
* **Experimental** support of some Composition features
* **Experimental** support of some Composition features https://github.com/syoyo/tinyusdz/issues/25
* [x] subLayers
* [x] references
* [ ] payloads
Expand Down
2 changes: 1 addition & 1 deletion examples/tusdcat/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Simple USD(Z) dump tool.
TinyUSDZ version of usdcat in pxrUSD.

Assume this project is built from tinyusdz root(../../)
39 changes: 28 additions & 11 deletions examples/tusdcat/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct CompositionFeatures {
bool inherits{true};
bool variantSets{true};
bool references{true};
bool payloads{true};
bool payload{true}; // Not 'payloads'
bool specializes{true};
};

Expand All @@ -26,20 +26,20 @@ static std::string GetFileExtension(const std::string &filename) {

static std::string str_tolower(std::string s) {
std::transform(s.begin(), s.end(), s.begin(),
[](unsigned char c) { return std::tolower(c); }
[](unsigned char c) { return std::tolower(c); }
);
return s;
}

int main(int argc, char **argv) {
if (argc < 2) {
std::cout << "Usage tusdcat [--flatten] [--composition=STRLIST] [--relative] input.usda/usdc/usdz\n";
std::cout << "\n --flatten (not implemented yet) Do composition(load sublayers, refences, payloads, evaluate `over`, inherit, variants..)";
std::cout << "\n --flatten (not implemented yet) Do composition(load sublayers, refences, payload, evaluate `over`, inherit, variants..)";
std::cout << " --composition: Specify which composition feature to be "
"enabled(valid when `--flatten` is supplied). Comma separated "
"list. \n l "
"`subLayers`, i `inherits`, v `variantSets`, r `references`, "
"p `payloads`, s `specializes`. \n Example: "
"p `payload`, s `specializes`. \n Example: "
"--composition=r,p --composition=references,subLayers\n";
std::cout << "\n --relative (not implemented yet) Print Path as relative Path\n";
return EXIT_FAILURE;
Expand Down Expand Up @@ -71,7 +71,7 @@ int main(int argc, char **argv) {
comp_features.inherits = false;
comp_features.variantSets = false;
comp_features.references = false;
comp_features.payloads = false;
comp_features.payload = false;
comp_features.specializes = false;

for (const auto &item : items) {
Expand All @@ -83,8 +83,8 @@ int main(int argc, char **argv) {
comp_features.variantSets = true;
} else if ((item == "r") || (item == "references")) {
comp_features.references = true;
} else if ((item == "p") || (item == "payloads")) {
comp_features.payloads = true;
} else if ((item == "p") || (item == "payload")) {
comp_features.payload = true;
} else if ((item == "s") || (item == "specializes")) {
comp_features.specializes = true;
} else {
Expand Down Expand Up @@ -168,7 +168,7 @@ int main(int argc, char **argv) {
// - [ ] Inherits
// - [ ] VariantSets
// - [x] References
// - [ ] Payload
// - [x] Payload
// - [ ] Specializes
//

Expand All @@ -184,12 +184,12 @@ int main(int argc, char **argv) {
std::cout << "WARN: " << warn << "\n";
}

std::cout << "# composited\n";
std::cout << "# `subLayers` composited\n";
std::cout << composited_layer << "\n";

src_layer = std::move(composited_layer);
}

if (comp_features.references) {
tinyusdz::Layer composited_layer;
if (!tinyusdz::CompositeReferences(resolver, src_layer, &composited_layer, &warn, &err)) {
Expand All @@ -201,7 +201,24 @@ int main(int argc, char **argv) {
std::cout << "WARN: " << warn << "\n";
}

std::cout << "# composited\n";
std::cout << "# `references` composited\n";
std::cout << composited_layer << "\n";

src_layer = std::move(composited_layer);
}

if (comp_features.payload) {
tinyusdz::Layer composited_layer;
if (!tinyusdz::CompositePayload(resolver, src_layer, &composited_layer, &warn, &err)) {
std::cerr << "Failed to composite `payload`: " << err << "\n";
return -1;
}

if (warn.size()) {
std::cout << "WARN: " << warn << "\n";
}

std::cout << "# `payload` composited\n";
std::cout << composited_layer << "\n";

src_layer = std::move(composited_layer);
Expand Down
33 changes: 25 additions & 8 deletions examples/usda_parser/parser-main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct CompositionFeatures {
bool inherits{true};
bool variantSets{true};
bool references{true};
bool payloads{true};
bool payload{true};
bool specializes{true};
};

Expand All @@ -27,7 +27,7 @@ int main(int argc, char **argv) {
"enabled(valid when `--flatten` is supplied). Comma separated "
"list. \n l "
"`subLayers`, i `inherits`, v `variantSets`, r `references`, "
"p `payloads`, s `specializes`. \n Example: "
"p `payload`, s `specializes`. \n Example: "
"--composition=r,p --composition=references,subLayers\n";
exit(-1);
}
Expand Down Expand Up @@ -56,7 +56,7 @@ int main(int argc, char **argv) {
comp_features.inherits = false;
comp_features.variantSets = false;
comp_features.references = false;
comp_features.payloads = false;
comp_features.payload = false;
comp_features.specializes = false;

for (const auto &item : items) {
Expand All @@ -68,8 +68,8 @@ int main(int argc, char **argv) {
comp_features.variantSets = true;
} else if ((item == "r") || (item == "references")) {
comp_features.references = true;
} else if ((item == "p") || (item == "payloads")) {
comp_features.payloads = true;
} else if ((item == "p") || (item == "payload")) {
comp_features.payload = true;
} else if ((item == "s") || (item == "specializes")) {
comp_features.specializes = true;
} else {
Expand Down Expand Up @@ -180,7 +180,7 @@ int main(int argc, char **argv) {
// - [ ] Inherits
// - [ ] VariantSets
// - [x] References
// - [ ] Payload
// - [x] Payload
// - [ ] Specializes
//

Expand All @@ -196,7 +196,7 @@ int main(int argc, char **argv) {
std::cout << "WARN: " << warn << "\n";
}

std::cout << "# composited\n";
std::cout << "# `subLayers` composited\n";
std::cout << composited_layer << "\n";

src_layer = std::move(composited_layer);
Expand All @@ -213,7 +213,24 @@ int main(int argc, char **argv) {
std::cout << "WARN: " << warn << "\n";
}

std::cout << "# composited\n";
std::cout << "# `references` composited\n";
std::cout << composited_layer << "\n";

src_layer = std::move(composited_layer);
}

if (comp_features.payload) {
tinyusdz::Layer composited_layer;
if (!tinyusdz::CompositePayload(resolver, src_layer, &composited_layer, &warn, &err)) {
std::cerr << "Failed to composite `payload`: " << err << "\n";
return -1;
}

if (warn.size()) {
std::cout << "WARN: " << warn << "\n";
}

std::cout << "# `payload` composited\n";
std::cout << composited_layer << "\n";

src_layer = std::move(composited_layer);
Expand Down
33 changes: 25 additions & 8 deletions examples/usdc_parser/usdc-parser-main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct CompositionFeatures {
bool inherits{true};
bool variantSets{true};
bool references{true};
bool payloads{true};
bool payload{true};
bool specializes{true};
};

Expand All @@ -26,7 +26,7 @@ int main(int argc, char **argv) {
"enabled(valid when `--flatten` is supplied). Comma separated "
"list. \n l "
"`subLayers`, i `inherits`, v `variantSets`, r `references`, "
"p `payloads`, s `specializes`. \n Example: "
"p `payload`, s `specializes`. \n Example: "
"--composition=r,p --composition=references,subLayers\n";
exit(-1);
}
Expand Down Expand Up @@ -55,7 +55,7 @@ int main(int argc, char **argv) {
comp_features.inherits = false;
comp_features.variantSets = false;
comp_features.references = false;
comp_features.payloads = false;
comp_features.payload = false;
comp_features.specializes = false;

for (const auto &item : items) {
Expand All @@ -67,8 +67,8 @@ int main(int argc, char **argv) {
comp_features.variantSets = true;
} else if ((item == "r") || (item == "references")) {
comp_features.references = true;
} else if ((item == "p") || (item == "payloads")) {
comp_features.payloads = true;
} else if ((item == "p") || (item == "payload")) {
comp_features.payload = true;
} else if ((item == "s") || (item == "specializes")) {
comp_features.specializes = true;
} else {
Expand Down Expand Up @@ -151,7 +151,7 @@ int main(int argc, char **argv) {
// - [ ] Inherits
// - [ ] VariantSets
// - [x] References
// - [ ] Payload
// - [x] Payload
// - [ ] Specializes
//

Expand All @@ -167,7 +167,7 @@ int main(int argc, char **argv) {
std::cout << "WARN: " << warn << "\n";
}

std::cout << "# composited\n";
std::cout << "# `subLayers` composited\n";
std::cout << composited_layer << "\n";

src_layer = std::move(composited_layer);
Expand All @@ -184,7 +184,24 @@ int main(int argc, char **argv) {
std::cout << "WARN: " << warn << "\n";
}

std::cout << "# composited\n";
std::cout << "# `references` composited\n";
std::cout << composited_layer << "\n";

src_layer = std::move(composited_layer);
}

if (comp_features.payload) {
tinyusdz::Layer composited_layer;
if (!tinyusdz::CompositePayload(resolver, src_layer, &composited_layer, &warn, &err)) {
std::cerr << "Failed to composite `payload`: " << err << "\n";
return -1;
}

if (warn.size()) {
std::cout << "WARN: " << warn << "\n";
}

std::cout << "# `payload` composited\n";
std::cout << composited_layer << "\n";

src_layer = std::move(composited_layer);
Expand Down
Loading

0 comments on commit 0099503

Please sign in to comment.