From 53ba177225330cc6c9758d47866e8df4ccfe670b Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Tue, 18 Apr 2023 16:04:13 +0200 Subject: [PATCH] simple mirroring --- src/GPUFontAtlasLayerCombo.cpp | 54 +++++++++++++++++++++++++++++++++- src/Layer.h | 1 + 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/GPUFontAtlasLayerCombo.cpp b/src/GPUFontAtlasLayerCombo.cpp index b8d6665..2e890b5 100644 --- a/src/GPUFontAtlasLayerCombo.cpp +++ b/src/GPUFontAtlasLayerCombo.cpp @@ -249,6 +249,58 @@ void GPUFontAtlasLayerCombo::draw(){ }); outerBoundingBoxes.push_back(mesh); + if(layer->getProps().mirror_x){ + auto bbs_mirror_x = bbs; + ofNode mirrorOuterNode = layer->getOuterNode(); + ofNode mirrorInnerNode = layer->getInnerNode(); + mirrorInnerNode.setParent(mirrorOuterNode); + mirrorOuterNode.setOrientation(glm::quat(1, 0, 0, 0)); + mirrorOuterNode.rotateDeg(layer->getProps().rotation * -1, glm::vec3(0, 0, 1)); + mirrorOuterNode.setPosition(transformOrigin); + mirrorOuterNode.move(layer->getProps().mirror_x_distance * -1, 0, 0); + mirrorOuterNode.setScale(-1, 1, 1); + font->collectVerticesAndIndices(mirrorInnerNode, + bbs_mirror_x, + vertices, + indices, + layer->getColor(), + layer->getProps().fontSize_px); + } + if(layer->getProps().mirror_y){ + auto bbs_mirror_y = bbs; + ofNode mirrorOuterNode = layer->getOuterNode(); + ofNode mirrorInnerNode = layer->getInnerNode(); + mirrorInnerNode.setParent(mirrorOuterNode); + mirrorOuterNode.setOrientation(glm::quat(1, 0, 0, 0)); + mirrorOuterNode.rotateDeg(layer->getProps().rotation * -1, glm::vec3(0, 0, 1)); + mirrorOuterNode.setPosition(transformOrigin); + mirrorOuterNode.move(0, layer->getProps().mirror_y_distance * -1, 0); + mirrorOuterNode.setScale(1, -1, 1); + font->collectVerticesAndIndices(mirrorInnerNode, + bbs_mirror_y, + vertices, + indices, + layer->getColor(), + layer->getProps().fontSize_px); + } + if(layer->getProps().mirror_xy){ + auto bbs_mirror_xy = bbs; + ofNode mirrorOuterNode = layer->getOuterNode(); + ofNode mirrorInnerNode = layer->getInnerNode(); + mirrorInnerNode.setParent(mirrorOuterNode); + mirrorOuterNode.setOrientation(glm::quat(1, 0, 0, 0)); + mirrorOuterNode.rotateDeg(layer->getProps().rotation * 1, glm::vec3(0, 0, 1)); + mirrorOuterNode.setPosition(transformOrigin); + mirrorOuterNode.move(layer->getProps().mirror_x_distance * -1, + layer->getProps().mirror_y_distance * -1, 0); + mirrorOuterNode.setScale(-1, -1, 1); + font->collectVerticesAndIndices(mirrorInnerNode, + bbs_mirror_xy, + vertices, + indices, + layer->getColor(), + layer->getProps().fontSize_px); + } font->collectVerticesAndIndices(layer->getInnerNode(), bbs, vertices, @@ -267,7 +319,7 @@ void GPUFontAtlasLayerCombo::draw(){ int i = 0; for(const auto & v : b.getVertices()){ ofSetColor(b.getColors()[i]); - ofDrawCircle(v, 4); + ofDrawCircle(v, 2); ofDrawBitmapString(ofToString(i), 0, 0); i++; } diff --git a/src/Layer.h b/src/Layer.h index 12fb1df..cbc2517 100644 --- a/src/Layer.h +++ b/src/Layer.h @@ -35,6 +35,7 @@ class Layer { float mirror_x_distance = 0; bool mirror_y = false; float mirror_y_distance = 0; + bool mirror_xy = false; float letterDelay = 0; int transformOrigin = TransformOrigin::TOP_LEFT; std::vector fontVariations;