本文整理汇总了C++中ofMesh::addTexCoord方法的典型用法代码示例。如果您正苦于以下问题:C++ ofMesh::addTexCoord方法的具体用法?C++ ofMesh::addTexCoord怎么用?C++ ofMesh::addTexCoord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofMesh
的用法示例。
在下文中一共展示了ofMesh::addTexCoord方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addFace
//--------------------------------------------------------------
void Page::addFace(ofMesh& mesh, vectorFace& _face) {
addFace(mesh, _face.A, _face.B, _face.C);
mesh.addTexCoord(_face.a);
mesh.addTexCoord(_face.b);
mesh.addTexCoord(_face.c);
addFace(mesh, _face.A, _face.C, _face.D);
mesh.addTexCoord(_face.a);
mesh.addTexCoord(_face.c);
mesh.addTexCoord(_face.d);
}
示例2: aiMeshToOfMesh
//--------------------------------------------------------------
static void aiMeshToOfMesh(const aiMesh* aim, ofMesh& ofm, ofxAssimpMeshHelper * helper = NULL){
// default to triangle mode
ofm.setMode(OF_PRIMITIVE_TRIANGLES);
// copy vertices
for (int i=0; i < (int)aim->mNumVertices;i++){
ofm.addVertex(ofVec3f(aim->mVertices[i].x,aim->mVertices[i].y,aim->mVertices[i].z));
}
if(aim->HasNormals()){
for (int i=0; i < (int)aim->mNumVertices;i++){
ofm.addNormal(ofVec3f(aim->mNormals[i].x,aim->mNormals[i].y,aim->mNormals[i].z));
}
}
// aiVector3D * mTextureCoords [AI_MAX_NUMBER_OF_TEXTURECOORDS]
// just one for now
if(aim->GetNumUVChannels()>0){
for (int i=0; i < (int)aim->mNumVertices;i++){
if( helper != NULL && helper->texture.getWidth() > 0.0 ){
ofVec2f texCoord = helper->texture.getCoordFromPercent(aim->mTextureCoords[0][i].x ,aim->mTextureCoords[0][i].y);
ofm.addTexCoord(texCoord);
}else{
ofm.addTexCoord(ofVec2f(aim->mTextureCoords[0][i].x ,aim->mTextureCoords[0][i].y));
}
}
}
//aiColor4D * mColors [AI_MAX_NUMBER_OF_COLOR_SETS]
// just one for now
if(aim->GetNumColorChannels()>0){
for (int i=0; i < (int)aim->mNumVertices;i++){
ofm.addColor(aiColorToOfColor(aim->mColors[0][i]));
}
}
for (int i=0; i <(int) aim->mNumFaces;i++){
if(aim->mFaces[i].mNumIndices>3){
ofLog(OF_LOG_WARNING,"non-triangular face found: model face # " + ofToString(i));
}
for (int j=0; j<(int)aim->mFaces[i].mNumIndices; j++){
ofm.addIndex(aim->mFaces[i].mIndices[j]);
}
}
ofm.setName(string(aim->mName.data));
// ofm.materialId = aim->mMaterialIndex;
}
示例3: texturedRect
void texturedRect(float width, float height) {
if(texturedRectMesh.getNumVertices() == 0) {
texturedRectMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
texturedRectMesh.addTexCoord(ofVec2f(0, 0));
texturedRectMesh.addVertex(ofVec2f(0, 0));
texturedRectMesh.addTexCoord(ofVec2f(0, 1));
texturedRectMesh.addVertex(ofVec2f(0, 1));
texturedRectMesh.addTexCoord(ofVec2f(1, 0));
texturedRectMesh.addVertex(ofVec2f(1, 0));
texturedRectMesh.addTexCoord(ofVec2f(1, 1));
texturedRectMesh.addVertex(ofVec2f(1, 1));
}
ofPushMatrix();
ofScale(width, height);
texturedRectMesh.drawFaces();
ofPopMatrix();
}
示例4: meshFromFbo
void CloudsVisualSystemNbody::meshFromFbo(ofFbo& fbo, ofMesh& mesh){
mesh.addTexCoord(ofVec2f(0,0));
mesh.addVertex(ofVec3f(0,0,0));
mesh.addTexCoord(ofVec2f(fbo.getWidth(),0));
mesh.addVertex(ofVec3f(fbo.getWidth(),0,0));
mesh.addTexCoord(ofVec2f(0,fbo.getHeight()));
mesh.addVertex(ofVec3f(0,fbo.getHeight(),0));
mesh.addTexCoord(ofVec2f(fbo.getWidth(),fbo.getHeight()));
mesh.addVertex(ofVec3f(fbo.getWidth(),fbo.getHeight(),0));
mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
}
示例5: draw
//--------------------------------------------------------------
void testApp::draw(){
fbo.begin();
ofSetTextureWrap(GL_REPEAT,GL_REPEAT);
fbfbo.draw(0,2);
//cam.draw(0,0);
fbfbo.getTextureReference().bind();
trik2.draw();
fbfbo.getTextureReference().unbind();
ofSetColor(255,255,255);
if(tritimer>tritimerlimit){
float xpt, ypt,xtoff,ytoff;
//draw gradient splashes
ofMesh trik;
for(int b = 0;b<5;b++){
xtoff = ofRandomf()*0.5;
ytoff = ofRandomf()*0.5;
for(int i=0;i<3;i++){
xpt = ofRandomuf()*2+xtoff;
ypt = ofRandomuf()*2+ytoff;
trik.addVertex(ofVec3f(xpt*w,ypt*h,0));
trik.addColor(ofFloatColor(float(ofRandomuf()>0.5)*0.6+0.4,float(ofRandomuf()>0.5)*0.5+0.5,float(ofRandomuf()>0.5)*0.7+0.3));
}
}
trik.draw();
tritimer = 0;
tritimerlimit= ofRandom(20,200);
}
if(tritimer2>45){
//re-generate the feedback triangles
float xpt, ypt,xoff,yoff,xtoff,ytoff;
trik2.clear();
//ofEnableNormalizedTexCoords();
for(int b = 0;b<5;b++){
xoff = ofRandomf()*0.1;
yoff = ofRandomf()*0.1;
xtoff = ofRandomf()*0.5;
ytoff = ofRandomf()*0.5;
for(int i=0;i<3;i++){
xpt = ofRandomuf()+xtoff;
ypt = ofRandomuf()+ytoff;
trik2.addVertex(ofVec3f((xpt+xoff)*w,(ypt+yoff)*h,0));
trik2.addTexCoord(ofVec2f(xpt*w,ypt*h));
trik2.addColor(ofFloatColor(1,1,1));
}
}
tritimer2=0;
tritimer2limit= ofRandom(20,200);
//ofDisableNormalizedTexCoords();
}
fbo.end();
fbfbo.begin();
fbo.draw(0,0);
fbfbo.end();
fbo.draw(0,0);
}
示例6: load
OFX_OBJLOADER_BEGIN_NAMESPACE
void load(string path, ofMesh& mesh, bool generateNormals, bool flipFace)
{
path = ofToDataPath(path);
mesh.clear();
GLMmodel* m;
m = glmReadOBJ((char*)path.c_str());
if (generateNormals)
{
glmFacetNormals(m);
glmVertexNormals(m, 90);
}
if (flipFace)
{
glmReverseWinding(m);
}
for (int j = 0; j < m->numtriangles; j++)
{
const GLMtriangle &tri = m->triangles[j];
for (int k = 0; k < 3; k++)
{
GLfloat *v = m->vertices + (tri.vindices[k] * 3);
mesh.addVertex(ofVec3f(v[0], v[1], v[2]));
if (m->colors)
{
GLfloat *c = m->colors + (tri.vindices[k] * 3);
mesh.addColor(ofFloatColor(c[0], c[1], c[2]));
}
if (m->normals && ofInRange(tri.nindices[k], 0, m->numnormals))
{
GLfloat *n = m->normals + (tri.nindices[k] * 3);
mesh.addNormal(ofVec3f(n[0], n[1], n[2]));
}
if (m->texcoords && ofInRange(tri.tindices[k], 0, m->numtexcoords))
{
GLfloat *c = m->texcoords + (tri.tindices[k] * 2);
mesh.addTexCoord(ofVec2f(c[0], c[1]));
}
}
}
glmDelete(m);
}
示例7: ofGenerateSphereMesh
//----------------------------------------
void ofGenerateSphereMesh( ofMesh& _mesh, float _radius, int _numRings, int _numSegments ){
cout << "*** ofGenerateSphereMesh ***" << endl;
_mesh.clear();
float uTile = 1.0f; // Texcoord tiling, do we want to support that?
float vTile = 1.0f;
float fDeltaRingAngle = (PI / _numRings);
float fDeltaSegAngle = (TWO_PI / _numSegments);
int offset = 0;
// Generate the group of rings for the sphere
for(unsigned int ring = 0; ring <= _numRings; ring++ ) {
float r0 = _radius * sinf (ring * fDeltaRingAngle);
float y0 = _radius * cosf (ring * fDeltaRingAngle);
// Generate the group of segments for the current ring
for(unsigned int seg = 0; seg <= _numSegments; seg++) {
float x0 = r0 * sinf(seg * fDeltaSegAngle);
float z0 = r0 * cosf(seg * fDeltaSegAngle);
// Add one vertex to the strip which makes up the sphere
ofVec3f pos(x0, y0, z0);
_mesh.addVertex( pos );
_mesh.addNormal( pos.getNormalized() );
if( ofGetPrimitiveGenerateTexCoords() ){
//for (unsigned int tc=0;tc<numTexCoordSet;tc++)
_mesh.addTexCoord( ofVec2f( (float) seg / (float)_numSegments * uTile, (float) ring / (float)_numRings * vTile ) );
}
if (ring != _numRings) {
// each vertex (except the last) has six indices pointing to it
_mesh.addIndex(offset + _numSegments);
_mesh.addIndex(offset);
_mesh.addIndex(offset + _numSegments + 1);
_mesh.addIndex(offset);
_mesh.addIndex(offset + 1);
_mesh.addIndex(offset + _numSegments + 1);
offset ++;
}
}; // end for seg
} // end for ring
}
示例8: faceColorToTexture
void faceColorToTexture(ofMesh& mesh, ofImage& image)
{
vector<ofFloatColor> &color = mesh.getColors();
int num_face = color.size() / 3;
int tex_size = ofNextPow2(ceil(sqrt(num_face)));
bool arb = ofGetUsingArbTex();
ofDisableArbTex();
image.allocate(tex_size, tex_size, OF_IMAGE_COLOR);
if (arb) ofEnableArbTex();
mesh.clearTexCoords();
image.getPixelsRef().set(0);
float texel_size = (1. / image.getWidth()) * 0.5;
for (int i = 0; i < num_face; i++)
{
int u = (i % tex_size);
int v = (i / tex_size);
ofColor c = color[i * 3];
image.setColor(u, v, c);
float uu = (float)u / image.getWidth() + texel_size;
float vv = (float)v / image.getHeight() + texel_size;
mesh.addTexCoord(ofVec2f(uu, vv));
mesh.addTexCoord(ofVec2f(uu, vv));
mesh.addTexCoord(ofVec2f(uu, vv));
}
image.update();
mesh.clearColors();
}
示例9: load
void ofxObjLoader::load(string path, ofMesh& mesh, bool generateNormals) {
path = ofToDataPath(path);
mesh.clear();
GLMmodel* m;
m = glmReadOBJ((char*)path.c_str());
if(generateNormals){
glmFacetNormals(m);
glmVertexNormals(m, 90);
}
GLfloat *v, *n, *c;
for(int i = 1; i <= m->numvertices; i++){
v = &m->vertices[3 * i];
mesh.addVertex(ofVec3f(v[0], v[1], v[2]));
}
for(int i = 1; i <= m->numnormals; i++){
n = &m->normals[3 * i];
mesh.addNormal(ofVec3f(n[0], n[1], n[2]));
}
for(int i = 1; i <= m->numtexcoords; i++){
c = &m->texcoords[2 * i];
mesh.addTexCoord(ofVec2f(c[0], c[1]));
}
for (int i = 0; i < m->numtriangles; i++) {
GLMtriangle &t = m->triangles[i];
//NOTE: ofMesh does not have support for different indices for tex coords and mormals
mesh.addIndex(t.vindices[0]);
mesh.addIndex(t.vindices[1]);
mesh.addIndex(t.vindices[2]);
}
glmDelete(m);
return mesh;
}
示例10: addForheadToFaceMesh
void addForheadToFaceMesh(ofMesh & input){
if (input.getVertices().size() != 66) return;
static int forehead[10] = {0,17,18,19,20,/*21,22,*/23,24,25,26,16}; // skipping 21 and 22 because there is a triangle that overlaps somehow
ofPoint extras[10];
ofVec2f texture[10];
for (int i = 0; i < 10; i++){
extras[i] = input.getVertices()[forehead[i]] + (input.getVertices()[27] - input.getVertices()[33]);
texture[i] = input.getTexCoords()[forehead[i]] + (input.getTexCoords()[27] - input.getTexCoords()[33]);
input.addVertex(extras[i]);
input.addTexCoord(texture[i]);
}
for (int i = 0; i < (10-1); i++){
// a b c
// b c d;
int a = forehead[i];
int b = 66 + i;
int c = forehead[i+1];
input.addIndex(a);
input.addIndex(b);
input.addIndex(c);
int d = 66 + i + 1;
input.addIndex(b);
input.addIndex(c);
input.addIndex(d);
}
}
示例11: pushVertex
void BGGraphics::pushVertex(ofMesh & mesh, float x, float y, float z, float nx, float ny, float nz, float offsetX, float offsetY) {
mesh.addVertex(ofVec3f(x, y, z));
mesh.addNormal(ofVec3f(nx, ny, nz));
mesh.addTexCoord(ofVec2f(offsetX, offsetY));
mesh.addColor(ofFloatColor(255, 255, 255));
}
示例12: addTexCoords
void addTexCoords(ofMesh& to, const std::vector<T>& from) {
for(std::size_t i = 0; i < from.size(); i++) {
to.addTexCoord(glm::vec2(from[i].x, from[i].y));
}
}
示例13: addTexCoords
void addTexCoords(ofMesh& to, const vector<T>& from) {
for(int i = 0; i < from.size(); i++) {
to.addTexCoord(from[i]);
}
}
示例14: addTexCoords
void addTexCoords(ofMesh& mesh, ofVec2f a, ofVec2f b, ofVec2f c) {
mesh.addTexCoord(a);
mesh.addTexCoord(b);
mesh.addTexCoord(c);
}
示例15: buildSphereMesh
//from ofSetSphereResolution
void testApp::buildSphereMesh(int radius, int res, ofMesh & sphereMesh) {
int n = res * 2;
float ndiv2=(float)n/2;
/*
Original code by Paul Bourke
A more efficient contribution by Federico Dosil (below)
Draw a point for zero radius spheres
Use CCW facet ordering
http://paulbourke.net/texture_colour/texturemap/
*/
float theta2 = TWO_PI;
float phi1 = -HALF_PI;
float phi2 = HALF_PI;
// float r = 1.f; // normalize the verts
float r = radius;
sphereMesh.clear();
//sphereMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
int i, j;
float theta1 = 0.f;
float jdivn,j1divn,idivn,dosdivn,unodivn=1/(float)n,t1,t2,t3,cost1,cost2,cte1,cte3;
cte3 = (theta2-theta1)/n;
cte1 = (phi2-phi1)/ndiv2;
dosdivn = 2*unodivn;
ofVec3f e,p,e2,p2;
if (n < 0){
n = -n;
ndiv2 = -ndiv2;
}
if (n < 4) {n = 4; ndiv2=(float)n/2;}
if(r <= 0) r = -r;
t2=phi1;
cost2=cos(phi1);
j1divn=0;
ofVec3f vert, normal;
ofVec2f tcoord;
for (j=0;j<ndiv2;j++) {
t1 = t2;
t2 += cte1;
t3 = theta1 - cte3;
cost1 = cost2;
cost2 = cos(t2);
e.y = sin(t1);
e2.y = sin(t2);
p.y = r * e.y;
p2.y = r * e2.y;
idivn=0;
jdivn=j1divn;
j1divn+=dosdivn;
for (i=0;i<=n;i++) {
t3 += cte3;
e.x = cost1 * cos(t3);
e.z = cost1 * sin(t3);
p.x = r * e.x;
p.z = r * e.z;
normal.set( e.x, e.y, e.z );
tcoord.set( idivn, jdivn);
vert.set( p.x, p.y, p.z );
sphereMesh.addNormal(normal);
sphereMesh.addTexCoord(tcoord);
sphereMesh.addVertex(vert);
e2.x = cost2 * cos(t3);
e2.z = cost2 * sin(t3);
p2.x = r * e2.x;
p2.z = r * e2.z;
normal.set(e2.x, e2.y, e2.z);
tcoord.set(idivn, j1divn);
vert.set(p2.x, p2.y, p2.z);
sphereMesh.addNormal(normal);
sphereMesh.addTexCoord(tcoord);
sphereMesh.addVertex(vert);
idivn += unodivn;
}
}
}