simple mirroring

This commit is contained in:
jrkb 2023-04-18 16:04:13 +02:00
parent 7d4786d418
commit 53ba177225
2 changed files with 54 additions and 1 deletions

View file

@ -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++;
}

View file

@ -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 <ofxVariableLab::FontVariation> fontVariations;