本文整理汇总了C++中MyMesh::endVertices方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMesh::endVertices方法的具体用法?C++ MyMesh::endVertices怎么用?C++ MyMesh::endVertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMesh
的用法示例。
在下文中一共展示了MyMesh::endVertices方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: centerDisplayCallback
void VRMeshEditor::centerDisplayCallback(Misc::CallbackData* cbData)
{
/* Calculate bounding box of current mesh: */
Vrui::Point bbMin,bbMax;
MyVIt vIt=mesh->beginVertices();
for(int i=0; i<3; ++i)
bbMin[i]=bbMax[i]=(*vIt)[i];
for(++vIt; vIt!=mesh->endVertices(); ++vIt)
{
for(int i=0; i<3; ++i)
{
if(bbMin[i]>(*vIt)[i])
bbMin[i]=(*vIt)[i];
else if(bbMax[i]<(*vIt)[i])
bbMax[i]=(*vIt)[i];
}
}
Vrui::Point modelCenter=Geometry::mid(bbMin,bbMax);
Vrui::Scalar modelSize=Geometry::dist(modelCenter,bbMax);
/* Calculate navigation transformation: */
Vrui::NavTransform t=Vrui::NavTransform::translateFromOriginTo(Vrui::getDisplayCenter());
t*=Vrui::NavTransform::scale(Vrui::Scalar(0.5)*Vrui::getDisplaySize()/modelSize);
t*=Vrui::NavTransform::translateToOriginFrom(modelCenter);
Vrui::setNavigationTransformation(t);
}
示例2: createMorphBoxCallback
void VRMeshEditor::createMorphBoxCallback(Misc::CallbackData* cbData)
{
/* Delete the old morph box: */
if(morphBox!=0)
{
delete morphBox;
morphBox=0;
}
/* Calculate bounding box of current mesh: */
MyMorphBox::Point bbMin,bbMax;
MyVIt vIt=mesh->beginVertices();
for(int i=0; i<3; ++i)
bbMin[i]=bbMax[i]=(*vIt)[i];
for(++vIt; vIt!=mesh->endVertices(); ++vIt)
{
for(int i=0; i<3; ++i)
{
if(bbMin[i]>(*vIt)[i])
bbMin[i]=(*vIt)[i];
else if(bbMax[i]<(*vIt)[i])
bbMax[i]=(*vIt)[i];
}
}
/* Create a new morph box: */
MyMorphBox::Scalar size[3];
for(int i=0; i<3; ++i)
size[i]=bbMax[i]-bbMin[i];
morphBox=new MyMorphBox(mesh,bbMin,size);
}
示例3: renderMesh
void VRMeshEditor::renderMesh(VRMeshEditor::DataItem* dataItem) const
{
/* Check if vertex and triangle arrays are large enough: */
unsigned int numVertices=mesh->getNextVertexIndex();
if(dataItem->numVertices<numVertices)
{
delete[] dataItem->vertices;
dataItem->numVertices=numVertices+(numVertices/2);
dataItem->vertices=new MyVertex[dataItem->numVertices];
}
unsigned int numTriangles=mesh->getNumFaces();
if(dataItem->numTriangles<numTriangles)
{
delete[] dataItem->triangles;
dataItem->numTriangles=numTriangles+(numTriangles/2);
dataItem->triangles=new unsigned int[dataItem->numTriangles*3];
}
/* Reset vertex array: */
for(MyMesh::ConstVertexIterator vIt=mesh->beginVertices(); vIt!=mesh->endVertices(); ++vIt)
{
MyVertex* vPtr=&dataItem->vertices[vIt->index];
for(int i=0; i<3; ++i)
{
vPtr->normal[i]=0.0f;
vPtr->position[i]=(*vIt)[i];
}
}
/* Traverse triangles once to calculate normal vectors for smooth shading: */
unsigned int* viPtr=dataItem->triangles;
for(MyMesh::ConstFaceIterator fIt=mesh->beginFaces(); fIt!=mesh->endFaces(); ++fIt,viPtr+=3)
{
/* Gather triangle's points: */
const MyMesh::Vertex* v[3];
const MyMesh::Edge* e=fIt->getEdge();
for(int i=0; i<3; ++i)
{
v[i]=e->getStart();
viPtr[i]=v[i]->index;
e=e->getFaceSucc();
}
/* Calculate triangle's normal vector: */
float normal[3];
planeNormal(*v[0],*v[1],*v[2],normal);
/* Distribute normal vector to triangle's vertices: */
for(int i=0; i<3; ++i)
{
MyVertex* vPtr=&dataItem->vertices[viPtr[i]];
for(int j=0; j<3; ++j)
vPtr->normal[j]+=normal[j];
}
}
#if 0
static bool saveVertices=true;
if(saveVertices)
{
#if 0
float min[3],max[3];
MyMesh::ConstVertexIterator vIt=mesh->beginVertices();
for(int i=0; i<3; ++i)
min[i]=max[i]=vIt->pos()[i];
for(++vIt; vIt!=mesh->endVertices(); ++vIt)
for(int i=0; i<3; ++i)
{
if(min[i]>vIt->pos()[i])
min[i]=vIt->pos()[i];
else if(max[i]<vIt->pos()[i])
max[i]=vIt->pos()[i];
}
float center[3];
for(int i=0; i<3; ++i)
center[i]=(min[i]+max[i])*0.5f;
float scale=60.0f/(max[0]-min[0]);
for(int i=1; i<3; ++i)
{
float scale2=60.0f/(max[i]-min[i]);
if(scale>scale2)
scale=scale2;
}
#endif
#if 0
FILE* sampleFile=fopen("../ScatteredData/ModelVertices.txt","wt");
fprintf(sampleFile,"%u 3 1\n",numVertices);
for(MyMesh::ConstVertexIterator vIt=mesh->beginVertices(); vIt!=mesh->endVertices(); ++vIt)
{
MyVertex* vPtr=&dataItem->vertices[vIt->index];
float pos[3];
for(int i=0; i<3; ++i)
pos[i]=vPtr->position[i];
//pos[i]=(vPtr->position[i]-center[i])*scale+64.0f;
float normLen=sqrtf(vPtr->normal[0]*vPtr->normal[0]+vPtr->normal[1]*vPtr->normal[1]+vPtr->normal[2]*vPtr->normal[2]);
fprintf(sampleFile,"%8.3f %8.3f %8.3f 0 0 0 %6.3f %6.3f %6.3f\n",pos[0],pos[1],pos[2],vPtr->normal[0]/normLen,vPtr->normal[1]/normLen,vPtr->normal[2]/normLen);
}
fclose(sampleFile);
#endif
//.........这里部分代码省略.........