本文整理汇总了C++中ofMesh::getVerticesPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ ofMesh::getVerticesPointer方法的具体用法?C++ ofMesh::getVerticesPointer怎么用?C++ ofMesh::getVerticesPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofMesh
的用法示例。
在下文中一共展示了ofMesh::getVerticesPointer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateMesh
//--------------------------------------------------------------
void ofVboByteColor::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());
}
示例2: getClosestTripletOnMesh
int getClosestTripletOnMesh(const ofMesh& objectMesh,const ofMesh& imageMesh, float x, float y, float* distance) {
float bestDistance = numeric_limits<float>::infinity();
int bestChoice = 0;
for(int i = 0; i < objectMesh.getNumIndices()/3; i++) {
ofVec3f cur = ofVec3f(0,0,0);
for (int j=0;j<3;j++) {
cur+=imageMesh.getVerticesPointer()[objectMesh.getIndexPointer()[3*i+j]];
}
cur/=3.0;
float dx = x - cur.x;
float dy = y - cur.y;
float dz = 0 - cur.z;
float curDistance = dx * dx + dy * dy + dz * dz;
if(curDistance < bestDistance) {
bestDistance = curDistance;
bestChoice = i;
}
}
return bestChoice;
}
示例3: setMesh
//--------------------------------------------------------------
void ofVboByteColor::setMesh(const ofMesh & mesh, int usage){
setVertexData(mesh.getVerticesPointer(),mesh.getNumVertices(),usage);
setColorData(mesh.getColorsPointer(),mesh.getNumColors(),usage);
setNormalData(mesh.getNormalsPointer(),mesh.getNumNormals(),usage);
setTexCoordData(mesh.getTexCoordsPointer(),mesh.getNumTexCoords(),usage);
setIndexData(mesh.getIndexPointer(), mesh.getNumIndices(), usage);
}
示例4: 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();
}
}
示例5: draw
//----------------------------------------------------------
void ofGLRenderer::draw(ofMesh & vertexData, ofPolyRenderMode renderType, bool useColors, bool useTextures, bool useNormals){
if (bSmoothHinted) startSmoothing();
#ifndef TARGET_OPENGLES
glPushAttrib(GL_POLYGON_BIT);
glPolygonMode(GL_FRONT_AND_BACK, ofGetGLPolyMode(renderType));
draw(vertexData,useColors,useTextures,useNormals);
glPopAttrib(); //TODO: GLES doesnt support polygon mode, add renderType to gl renderer?
#else
if(vertexData.getNumVertices()){
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(ofVec3f), vertexData.getVerticesPointer());
}
if(vertexData.getNumNormals() && useNormals){
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, vertexData.getNormalsPointer());
}
if(vertexData.getNumColors() && useColors){
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4,GL_FLOAT, sizeof(ofFloatColor), vertexData.getColorsPointer());
}
if(vertexData.getNumTexCoords() && useTextures){
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, vertexData.getTexCoordsPointer());
}
GLenum drawMode;
switch(renderType){
case OF_MESH_POINTS:
drawMode = GL_POINTS;
break;
case OF_MESH_WIREFRAME:
drawMode = GL_LINES;
break;
case OF_MESH_FILL:
drawMode = ofGetGLPrimitiveMode(vertexData.getMode());
break;
default:
drawMode = ofGetGLPrimitiveMode(vertexData.getMode());
break;
}
if(vertexData.getNumIndices()){
glDrawElements(drawMode, vertexData.getNumIndices(),GL_UNSIGNED_SHORT,vertexData.getIndexPointer());
}else{
glDrawArrays(drawMode, 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);
}
#endif
if (bSmoothHinted) endSmoothing();
}
示例6: 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;
}
示例7: 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;
}
}
示例8: 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);
}
}
示例9: 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);
}
}
示例10: addShape
Handle <Device::RTShape> Renderer::addMesh(Device::RTMaterial material, const ofMesh & meshPr, const ofMatrix4x4& transform) {
int vertsNum = meshPr.getNumVertices();
int vertsSize = vertsNum * sizeof(ofVec3f);
Device::RTData positions = g_device->rtNewData("immutable_managed", vertsSize, meshPr.getVerticesPointer());
int normalsNum = meshPr.getNumNormals();
int normalsSize = normalsNum * sizeof(ofVec3f);
Device::RTData normals = g_device->rtNewData("immutable_managed", normalsSize, meshPr.getNormalsPointer());
int textcoordsNum = meshPr.getNumTexCoords();
int textcoordsSize = textcoordsNum * sizeof(ofVec2f);
Device::RTData texcoords = g_device->rtNewData("immutable_managed", textcoordsSize, meshPr.getTexCoordsPointer());
int indicesNum = meshPr.getNumIndices();
int indicesSize = indicesNum * sizeof(ofIndexType);
Device::RTData triangles = g_device->rtNewData("immutable_managed", indicesSize, meshPr.getIndexPointer());
Handle <Device::RTShape> mesh = device->rtNewShape("trianglemesh");
if(vertsNum) {
g_device->rtSetArray(mesh, "positions", "float3", positions, vertsNum, sizeof(ofVec3f), 0);
}
if(normalsNum) {
g_device->rtSetArray(mesh, "normals", "float3", normals, normalsNum, sizeof(ofVec3f), 0);
}
if(textcoordsNum) {
g_device->rtSetArray(mesh, "texcoords", "float2", texcoords, textcoordsNum, sizeof(ofVec2f), 0);
}
if(indicesNum) {
g_device->rtSetArray(mesh, "indices", "int3", triangles, indicesNum / 3, 3 * sizeof(ofIndexType), 0);
}
device->rtCommit(mesh);
device->rtClear(mesh);
return addShape(material, mesh, transform);
}
示例11: setMesh
//--------------------------------------------------------------
void ofVbo::setMesh(const ofMesh & mesh, int usage){
setVertexData(mesh.getVerticesPointer(),mesh.getNumVertices(),usage,sizeof(ofVec3f));
setColorData(mesh.getColorsPointer(),mesh.getNumColors(),usage,sizeof(ofColor));
setNormalData(mesh.getNormalsPointer(),mesh.getNumNormals(),usage,sizeof(ofVec3f));
setTexCoordData(mesh.getTexCoordsPointer(),mesh.getNumTexCoords(),usage,sizeof(ofVec2f));
}