本文整理汇总了C++中ofTexture::getCoordFromPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ ofTexture::getCoordFromPoint方法的具体用法?C++ ofTexture::getCoordFromPoint怎么用?C++ ofTexture::getCoordFromPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofTexture
的用法示例。
在下文中一共展示了ofTexture::getCoordFromPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
void Puppet::setup(string paintingID, ofTexture tex, vector<ofPolyline> lines, ofPoint pos)
{
this->tex = tex;
this->pos = pos;
this->lines = lines;
scale = 1.0;
rot = 0.0;
if (!lines.empty())
{
ofPolyline line = lines.at(0);
line = line.getResampledBySpacing(20);
line.getVertices().erase(line.getVertices().begin());
if (line.size() > 5)
{
ofPolyline lineForTri = line;
ofVec2f tweakForDeformer(tex.getWidth()/2, tex.getHeight()/2);
ofVec2f centroid = lineForTri.getCentroid2D();
for (auto& p : lineForTri.getVertices())
{
// enlarge from centroid
// ofVec2f dir = (p - centroid).getNormalized();
// p += dir * 15;
p -= tweakForDeformer;
}
mesh.triangulate(lineForTri, 28, -1);
for (auto& v: mesh.triangulatedMesh.getVertices())
{
mesh.triangulatedMesh.addTexCoord(tex.getCoordFromPoint(v.x + tweakForDeformer.x,
v.y + tweakForDeformer.y));
}
instance.setup(mesh.triangulatedMesh, lineForTri);
vector<ofPoint> pts = line.getVertices();
b2dObj = ofPtr<ofxBox2dPolygon>(new ofxBox2dPolygon);
b2dObj->addVertices(pts);
b2dObj->setPhysics(1.0, 0.3, 0.3);
b2dObj->triangulatePoly();
b2dObj->create(Globals::box2d->getWorld());
b2dObj->setPosition(pos);
}
}
}