diff --git a/src/GPUFontAtlasLayerCombo.cpp b/src/GPUFontAtlasLayerCombo.cpp index 9690e93..0118bee 100644 --- a/src/GPUFontAtlasLayerCombo.cpp +++ b/src/GPUFontAtlasLayerCombo.cpp @@ -225,8 +225,8 @@ void GPUFontAtlasLayerCombo::draw(int width, int height){ vertices.resize(totalCharacters * 4); indices.resize(totalCharacters * 6); - std::vector outerBoundingBoxes; - ofRectangle r; + //std::vector outerBoundingBoxes; + //ofRectangle r; for(const auto & layer : layers){ OFX_PROFILER_SCOPE("draw layer"); float ascender = font->getAscender(layer->getProps().fontSize_px); @@ -279,23 +279,23 @@ void GPUFontAtlasLayerCombo::draw(int width, int height){ mirror_bbs.push_back(std::move(bb_mirror_none)); //layer->setBoundingBox(bb); - ofVboMesh mesh; - mesh.addVertices({bb_mirror_none.p0, - bb_mirror_none.p1, - bb_mirror_none.p2, - bb_mirror_none.p3, - glm::vec4(layer->getProps().x, layer->getProps().y, 0, 1), - transformOrigin - }); - mesh.addColors({ - ofColor::red, - ofColor::red, - ofColor::red, - ofColor::red, - ofColor::white, - ofColor::green, - }); - outerBoundingBoxes.push_back(mesh); + //ofVboMesh mesh; + //mesh.addVertices({bb_mirror_none.p0, + //bb_mirror_none.p1, + //bb_mirror_none.p2, + //bb_mirror_none.p3, + //glm::vec4(layer->getProps().x, layer->getProps().y, 0, 1), + //transformOrigin + //}); + //mesh.addColors({ + //ofColor::red, + //ofColor::red, + //ofColor::red, + //ofColor::red, + //ofColor::white, + //ofColor::green, + //}); + //outerBoundingBoxes.push_back(mesh); if(layer->getProps().mirror_x){ auto bbs_mirror_x = bbs; @@ -378,7 +378,7 @@ void GPUFontAtlasLayerCombo::draw(int width, int height){ float layerHeight = max_y - min_y; layer->setBoundingBox(Layer::BoundingBox{min_x, min_y, layerWidth, layerHeight}); - r = ofRectangle(layer->getProps().x, layer->getProps().y, layer->getProps().width, 800); + //r = ofRectangle(layer->getProps().x, layer->getProps().y, layer->getProps().width, 800); // culling deque removeMe; @@ -490,8 +490,8 @@ void GPUFontAtlasLayerCombo::draw(int width, vertices.resize(totalCharacters * 4); indices.resize(totalCharacters * 6); - std::vector outerBoundingBoxes; - ofRectangle r; + //std::vector outerBoundingBoxes; + //ofRectangle r; { OFX_PROFILER_SCOPE("draw layer"); @@ -545,23 +545,23 @@ void GPUFontAtlasLayerCombo::draw(int width, bb_mirror_none.multiply(layer->getInnerNode().getGlobalTransformMatrix()); mirror_bbs.push_back(std::move(bb_mirror_none)); - ofVboMesh mesh; - mesh.addVertices({bb_mirror_none.p0, - bb_mirror_none.p1, - bb_mirror_none.p2, - bb_mirror_none.p3, - glm::vec4(layer->getProps().x, layer->getProps().y, 0, 1), - transformOrigin - }); - mesh.addColors({ - ofColor::red, - ofColor::red, - ofColor::red, - ofColor::red, - ofColor::white, - ofColor::green, - }); - outerBoundingBoxes.push_back(mesh); + //ofVboMesh mesh; + //mesh.addVertices({bb_mirror_none.p0, + //bb_mirror_none.p1, + //bb_mirror_none.p2, + //bb_mirror_none.p3, + //glm::vec4(layer->getProps().x, layer->getProps().y, 0, 1), + //transformOrigin + //}); + //mesh.addColors({ + //ofColor::red, + //ofColor::red, + //ofColor::red, + //ofColor::red, + //ofColor::white, + //ofColor::green, + //}); + //outerBoundingBoxes.push_back(mesh); if(layer->getProps().mirror_x){ auto bbs_mirror_x = bbs; @@ -644,7 +644,7 @@ void GPUFontAtlasLayerCombo::draw(int width, float layerHeight = max_y - min_y; layer->setBoundingBox(Layer::BoundingBox{min_x, min_y, layerWidth, layerHeight}); - r = ofRectangle(layer->getProps().x, layer->getProps().y, layer->getProps().width, 800); + //r = ofRectangle(layer->getProps().x, layer->getProps().y, layer->getProps().width, 800); //cout << vertices.size() << " / " << indices.size() << endl; // culling @@ -754,6 +754,12 @@ void GPUFontAtlasLayerCombo::getAndApplyTransformOrigin(glm::vec4 & transformOri break; } } + + glm::vec2 anchor = glm::vec2(props.textAlignment, + 0.5); + transformOrigin.x -= anchor.x * abs(bb.p1.x - bb.p0.x); + transformOrigin.y -= anchor.y * abs(bb.p1.y - bb.p0.y); + momNode.setOrientation(glm::quat(1, 0, 0, 0)); momNode.rotateDeg(props.rotation, glm::vec3(0, 0, 1)); momNode.setPosition(transformOrigin);