本文整理汇总了C++中ofMesh::getNumVertices方法的典型用法代码示例。如果您正苦于以下问题:C++ ofMesh::getNumVertices方法的具体用法?C++ ofMesh::getNumVertices怎么用?C++ ofMesh::getNumVertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofMesh
的用法示例。
在下文中一共展示了ofMesh::getNumVertices方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setMesh
//--------------------------------------------------------------
void ofVbo::setMesh(const ofMesh & mesh, int usage, bool useColors, bool useTextures, bool useNormals){
if(mesh.getVertices().empty()){
ofLogWarning("ofVbo") << "setMesh(): ignoring mesh with no vertices";
return;
}
setVertexData(mesh.getVerticesPointer(),mesh.getNumVertices(),usage);
if(mesh.hasColors() && useColors){
setColorData(mesh.getColorsPointer(),mesh.getNumColors(),usage);
enableColors();
}else{
disableColors();
}
if(mesh.hasNormals() && useNormals){
setNormalData(mesh.getNormalsPointer(),mesh.getNumNormals(),usage);
enableNormals();
}else{
disableNormals();
}
if(mesh.hasTexCoords() && useTextures){
setTexCoordData(mesh.getTexCoordsPointer(),mesh.getNumTexCoords(),usage);
enableTexCoords();
}else{
disableTexCoords();
}
if(mesh.hasIndices()){
setIndexData(mesh.getIndexPointer(), mesh.getNumIndices(), usage);
enableIndices();
}else{
disableIndices();
}
}
示例2: updateMesh
//--------------------------------------------------------------
void ofVbo::updateMesh(const ofMesh & mesh){
ofMesh * nonconstMesh = (ofMesh*)&mesh;
if(nonconstMesh->haveVertsChanged()) updateVertexData(mesh.getVerticesPointer(),mesh.getNumVertices());
if(nonconstMesh->haveColorsChanged()) updateColorData(mesh.getColorsPointer(),mesh.getNumColors());
if(nonconstMesh->haveNormalsChanged()) updateNormalData(mesh.getNormalsPointer(),mesh.getNumNormals());
if(nonconstMesh->haveTexCoordsChanged()) updateTexCoordData(mesh.getTexCoordsPointer(),mesh.getNumTexCoords());
}
示例3: draw
//----------------------------------------------------------
void ofGLRenderer::draw(const ofMesh & vertexData, bool useColors, bool useTextures, bool useNormals) const{
if(vertexData.getNumVertices()){
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(ofVec3f), &vertexData.getVerticesPointer()->x);
}
if(vertexData.getNumNormals() && useNormals){
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, sizeof(ofVec3f), &vertexData.getNormalsPointer()->x);
}
if(vertexData.getNumColors() && useColors){
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4,GL_FLOAT, sizeof(ofFloatColor), &vertexData.getColorsPointer()->r);
}
if(vertexData.getNumTexCoords() && useTextures){
set<int>::iterator textureLocation = textureLocationsEnabled.begin();
for(;textureLocation!=textureLocationsEnabled.end();textureLocation++){
glActiveTexture(GL_TEXTURE0+*textureLocation);
glClientActiveTexture(GL_TEXTURE0+*textureLocation);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(ofVec2f), &vertexData.getTexCoordsPointer()->x);
}
glActiveTexture(GL_TEXTURE0);
glClientActiveTexture(GL_TEXTURE0);
}
if(vertexData.getNumIndices()){
#ifdef TARGET_OPENGLES
glDrawElements(ofGetGLPrimitiveMode(vertexData.getMode()), vertexData.getNumIndices(),GL_UNSIGNED_SHORT,vertexData.getIndexPointer());
#else
glDrawElements(ofGetGLPrimitiveMode(vertexData.getMode()), vertexData.getNumIndices(),GL_UNSIGNED_INT,vertexData.getIndexPointer());
#endif
}else{
glDrawArrays(ofGetGLPrimitiveMode(vertexData.getMode()), 0, vertexData.getNumVertices());
}
if(vertexData.getNumColors() && useColors){
glDisableClientState(GL_COLOR_ARRAY);
}
if(vertexData.getNumNormals() && useNormals){
glDisableClientState(GL_NORMAL_ARRAY);
}
if(vertexData.getNumTexCoords() && useTextures){
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
示例4: deformMesh
ofMesh ofxFfd::deformMesh(ofMesh mesh){
ofMesh dst;
dst.append(mesh);
for ( int i=0; i<mesh.getNumVertices(); i++ ) {
ofVec3f vec = mesh.getVertex(i);
dst.setVertex(i, deform(vec));
}
return dst;
}
示例5: getProjectedMesh
ofMesh getProjectedMesh(const ofMesh& mesh) {
ofMesh projected = mesh;
for(std::size_t i = 0; i < mesh.getNumVertices(); i++) {
glm::vec3 cur = ofWorldToScreen(mesh.getVerticesPointer()[i]);
cur.z = 0;
projected.setVertex(i, cur);
}
return projected;
}
示例6: create
//--------------------------------------------------------------
void ofxBulletSoftTriMesh::create( ofxBulletWorldSoft* a_world, ofMesh& aMesh, btTransform &a_bt_tr, float a_mass ) {
if(a_world == NULL) {
ofLogError("ofxBulletSoftTriMesh") << "create(): a_world param is NULL";
return;
}
if( aMesh.getMode() != OF_PRIMITIVE_TRIANGLES ) {
ofLogError("ofxBulletSoftTriMesh") << " only excepts meshes that are triangles";
return;
}
_world = a_world;
_cachedMesh.clear();
_cachedMesh = aMesh;
if( bullet_vertices != NULL ) {
delete bullet_vertices;
bullet_vertices = NULL;
}
int vertStride = sizeof(btVector3);
int indexStride = 3*sizeof(int);
int totalVerts = (int)aMesh.getNumVertices();
int totalIndices = (int)aMesh.getNumIndices();
bullet_vertices = new btScalar[ totalVerts * 3 ];
int* bullet_indices = new int[ totalIndices ];
auto& tverts = aMesh.getVertices();
vector< ofIndexType >& tindices = aMesh.getIndices();
for( int i = 0; i < totalVerts; i++ ) {
bullet_vertices[i*3+0] = tverts[i].x;
bullet_vertices[i*3+1] = tverts[i].y;
bullet_vertices[i*3+2] = tverts[i].z;
}
for( int i = 0; i < totalIndices; i++ ) {
bullet_indices[i] = tindices[i];
}
_softBody = btSoftBodyHelpers::CreateFromTriMesh( _world->getInfo(),
bullet_vertices,
bullet_indices,
totalIndices/3 );
_softBody->transform( a_bt_tr );
setMass( a_mass, true );
setCreated(_softBody);
createInternalUserData();
delete [] bullet_indices;
}
示例7: update
void update() {
int n = mesh.getNumVertices();
int start = ofMap(mouseX, 0, ofGetWidth(), 0, n, true);
controlPoints.clear();
controlPoints.setMode(OF_PRIMITIVE_POINTS);
for(int i = start; i < n; i++) {
unsigned int index = rankedCorners[i];
controlPoints.addVertex(mesh.getVertex(index));
}
}
示例8: buildNormalsFaces
void buildNormalsFaces(ofMesh& mesh) {
mesh.clearNormals();
for(int i = 0; i < mesh.getNumVertices(); i += 3) {
int i0 = i + 0, i1 = i + 1, i2 = i + 2;
ofVec3f normal = getNormal(mesh.getVertices()[i0], mesh.getVertices()[i1], mesh.getVertices()[i2]);
for(int j = 0; j < 3; j++) {
mesh.addNormal(normal);
}
}
}
示例9: getNearestVertex
float getNearestVertex(const ofMesh& mesh, const ofVec2f& target, int& vertexIndex) {
float bestDistance = 0;
for(int i = 0; i < mesh.getNumVertices(); i++) {
float distance = target.distance(mesh.getVertex(i));
if(distance < bestDistance || i == 0) {
bestDistance = distance;
vertexIndex = i;
}
}
return bestDistance;
}
示例10: appendMesh
void MeshHelper::appendMesh( ofMesh& targetMesh, const ofMesh& toAppend, bool fuse )
{
ofIndexType indexOffset = targetMesh.getNumVertices();
targetMesh.addVertices( toAppend.getVertices() );
// append indices
const vector<ofIndexType>& indices = toAppend.getIndices();
for ( int i=0; i<indices.size(); i++ ) {
targetMesh.addIndex( indices[i]+indexOffset );
}
if ( fuse )
fuseNeighbours(targetMesh);
}
示例11:
// adjacency list of triangulation
vector< set<size_t> > ofxDelaunay2D::adjacencyForTriMesh(ofMesh &triMesh) {
vector< set<size_t> > adjacency; adjacency.reserve(triMesh.getNumVertices());
for(size_t i=0; i<(size_t)(triMesh.getNumVertices()); ++i) {
adjacency.push_back(set<size_t>());
}
for(int i0=0; i0<(int)triMesh.getIndices().size() - 2; i0+=3) {
size_t i = triMesh.getIndex(i0);
size_t j = triMesh.getIndex(i0 + 1);
size_t k = triMesh.getIndex(i0 + 2);
adjacency[i].insert(j);
adjacency[j].insert(i);
adjacency[i].insert(k);
adjacency[k].insert(i);
adjacency[j].insert(k);
adjacency[k].insert(j);
}
return adjacency;
}
示例12: draw
//----------------------------------------------------------
void ofGLRenderer::draw(ofMesh & vertexData){
if(vertexData.getNumVertices()){
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(ofVec3f), vertexData.getVerticesPointer());
}
if(vertexData.getNumNormals()){
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, vertexData.getNormalsPointer());
}
if(vertexData.getNumColors()){
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4,GL_FLOAT, sizeof(ofColor), vertexData.getColorsPointer());
}
if(vertexData.getNumTexCoords()){
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, vertexData.getTexCoordsPointer());
}
if(vertexData.getNumIndices()){
#ifdef TARGET_OPENGLES
glDrawElements(ofGetGLPrimitiveMode(vertexData.getMode()), vertexData.getNumIndices(),GL_UNSIGNED_SHORT,vertexData.getIndexPointer());
#else
glDrawElements(ofGetGLPrimitiveMode(vertexData.getMode()), vertexData.getNumIndices(),GL_UNSIGNED_INT,vertexData.getIndexPointer());
#endif
}else{
glDrawArrays(ofGetGLPrimitiveMode(vertexData.getMode()), 0, vertexData.getNumVertices());
}
if(vertexData.getNumColors()){
glDisableClientState(GL_COLOR_ARRAY);
}
if(vertexData.getNumNormals()){
glDisableClientState(GL_NORMAL_ARRAY);
}
if(vertexData.getNumTexCoords()){
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
示例13: ofSaveMesh
void ofSaveMesh(const ofMesh& mesh, string filename) {
ofFile ply;
if (ply.open(filename, ofFile::WriteOnly, true)) {
int vertexCount = mesh.getNumVertices();
int triangleCount = mesh.getNumVertices() / 3;
cout << "saving mesh with " << mesh.getNumIndices() << " indices" << endl;
cout << "saving mesh with " << mesh.getNumVertices() << " vertices" << endl;
// write the header
ply << "ply" << endl;
ply << "format binary_little_endian 1.0" << endl;
ply << "element vertex " << vertexCount << endl;
ply << "property float x" << endl;
ply << "property float y" << endl;
ply << "property float z" << endl;
ply << "element face " << triangleCount << endl;
ply << "property list uchar int vertex_index" << endl;
ply << "end_header" << endl;
// write all the vertices
const vector<ofVec3f>& surface = mesh.getVertices();
for(int i = 0; i < surface.size(); i++) {
// write the raw data as if it were a stream of bytes
ply.write((char*) &surface[i], sizeof(ofVec3f));
}
// write all the faces
unsigned char faceSize = 3;
for(int i = 0; i < vertexCount; i += faceSize) {
// write the raw data as if it were a stream of bytes
ply.write((char*) &faceSize, sizeof(unsigned char));
for(int j = 0; j < faceSize; j++) {
int curIndex = i + j;
ply.write((char*) &curIndex, sizeof(int));
}
}
}
}
示例14: convertToIndices
ofMesh convertToIndices(const ofMesh& mesh){
ofMesh result;
ofMesh& cmesh = const_cast<ofMesh&>(mesh);
int vertices = mesh.getNumVertices();
int colors = mesh.getNumColors();
int normals = mesh.getNumNormals();
int texcoords = mesh.getNumTexCoords();
//int indices = mesh.getNumIndices();
for (int i = 0; i < vertices; i++){
// check if this vertex already exists.
//int who = isPointInVector(
}
}
示例15: computeMeshFromProtoAndTF
void Body::computeMeshFromProtoAndTF(
ofMesh &m,
const ofMesh* protoMesh,
ofMatrix4x4 T )
{
m = *protoMesh;
ofVec3f* vtp = m.getVerticesPointer();
int NumVts = m.getNumVertices();
for(int i=0;i<NumVts;i++)
{
ofVec3f& vt = *(vtp+i);
vt = vt*T;
}
}