Skip to content

Commit

Permalink
zelloworldback
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate committed Jun 27, 2022
1 parent 3aa9e14 commit dc88475
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
52 changes: 52 additions & 0 deletions projects/FBX/LoadSampleModel.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#include <zeno/zeno.h>
#include <zeno/core/Graph.h>
#include <zeno/extra/assetDir.h>
#include <zeno/utils/filesystem.h>
#include <zeno/funcs/PrimitiveUtils.h>
#include <zeno/utils/log.h>
#include <zeno_FBX_config.h>
#include <sstream>
#include <cctype>

namespace zeno {
namespace {
Expand All @@ -28,5 +33,52 @@ ZENO_DEFNODE(LoadSampleModel)({
{"primitive"},
});

struct LoadStringPrim : INode {
virtual void apply() override {
auto str = get_input2<std::string>("str");

const float stride = 0.6f;

std::vector<std::shared_ptr<PrimitiveObject>> prims;
std::vector<PrimitiveObject *> primsRaw;
for (int i = 0; i < str.size(); i++) {
int c = str[i];
if (std::isblank(c)) continue;

std::ostringstream ss;
ss << "ascii/" << std::setw(3) << std::setfill('0') << c << ".obj";
//printf("asdasd %s\n", ss.str().c_str());
auto path = getAssetDir(MODELS_DIR, ss.str());
if (!fs::exists(path)) {
zeno::log_warn("LoadStringPrim got ASCII char not printable: {}", c);
continue;
}
auto prim = safe_dynamic_cast<PrimitiveObject>(getThisGraph()->callTempNode("ReadObjPrim", {
{"triangulate:", objectFromLiterial(get_input2<bool>("triangulate"))},
{"decodeUVs:", objectFromLiterial(get_input2<bool>("decodeUVs"))},
{"path", objectFromLiterial(path)},
}).at("prim"));

primTranslate(prim.get(), vec3f(stride * i, 0, 0));
primsRaw.push_back(prim.get());
prims.push_back(std::move(prim));
}

auto retPrim = primMerge(primsRaw, {});
set_output("prim", std::move(retPrim));
}
};

ZENO_DEFNODE(LoadStringPrim)({
{
{"bool", "triangulate", "1"},
{"bool", "decodeUVs", "1"},
{"string", "str", "Zello World!"},
},
{"prim"},
{},
{"primitive"},
});

}
}
2 changes: 1 addition & 1 deletion zenovis/src/bate/GraphicPrimitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ struct ZhxxGraphicPrimitive final : IGraphicDraw {
zeno::vec3f clr0(1.0f);
if (prim->lines.size())
clr0 = {1.0f, 0.6f, 0.2f};
else if (!prim->tris.size())
else if (!prim->tris.size() && !prim->quads.size() && !prim->polys.size())
clr0 = {0.2f, 0.6f, 1.0f};
for (size_t i = 0; i < clr.size(); i++) {
clr[i] = clr0;
Expand Down

0 comments on commit dc88475

Please sign in to comment.