本文整理汇总了C++中TriangleMesh::Triangles方法的典型用法代码示例。如果您正苦于以下问题:C++ TriangleMesh::Triangles方法的具体用法?C++ TriangleMesh::Triangles怎么用?C++ TriangleMesh::Triangles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriangleMesh
的用法示例。
在下文中一共展示了TriangleMesh::Triangles方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetMesh
void TessellatedSolid::SetMesh(TriangleMesh &mesh)
{
G4TessellatedSolid *ts = this->m_Solid;
for (int i=0; i<mesh.Triangles().size(); ++i) {
const Vector3i &trg = mesh.Triangles().at(i);
G4TriangularFacet *facet = new G4TriangularFacet(
DetectorsSolidPimpl::getG4Vector3f(mesh.Points().at(trg(0))),
DetectorsSolidPimpl::getG4Vector3f(mesh.Points().at(trg(1))),
DetectorsSolidPimpl::getG4Vector3f(mesh.Points().at(trg(2))),
ABSOLUTE);
ts->AddFacet((G4VFacet *)facet);
}
this->m_Logical->SetSolid(ts);
}
示例2: main
//Program entry point.
//argc is a count of the number of arguments (including the filename of the program).
//argv is a pointer to each c-style string.
int main(int argc, char **argv)
{
atexit(cleanup);
cout << "Computer Graphics Assignment 1 Demo Program" << endl;
if (argc > 1)
{
geom.LoadFile(argv[1]);
}
else
{
cerr << "Usage:" << endl;
cerr << argv[0] << " <filename> " << endl;
exit(1);
}
geom.CalculateNormals();
//initialise OpenGL
GLFWwindow* window = initialiseGL();
//create framebuffers
glGenFramebuffers(1, &frameBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer);
renderTarget = setupTextureGL(NULL, 800, 600, GL_RGBA);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, renderTarget, 0);
//depth/stencil buffer
glGenTextures(1, &depthStencil);
glBindTexture(GL_TEXTURE_2D, depthStencil);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, 800, 600, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthStencil, 0);
GLenum err = GL_NO_ERROR;
while ((err = glGetError()) != GL_NO_ERROR)
{
printf("%d\n", err);
}
//load and compile the shaders
GLuint objectVertexShader = loadVertexShaderGL("vertex.glsl");
GLuint objectFragmentShader = loadFragmentShaderGL("fragment.glsl");
objectShaderProgram = makeShaderProgramGL(objectVertexShader, objectFragmentShader);
GLuint screenVertexShader = loadVertexShaderGL("postvertex.glsl");
GLuint screenFragmentShader = loadFragmentShaderGL("postfragment.glsl");
screenShaderProgram = makeShaderProgramGL(screenVertexShader, screenFragmentShader);
//transfer the geometry to the GPU
glGenVertexArrays(1, &objectVertexArray);
glBindVertexArray(objectVertexArray);
//create buffers we will use
glGenBuffers(1, &objectVertexBuffer);
glGenBuffers(1, &objectElementBuffer);
glGenBuffers(1, &objectNormBuffer);
//get geometry vertices, normals and edge lists
vector <glm::vec3> vert = geom.Vertices();
vector <glm::vec3> norm = geom.Norms();
//vector <glm::vec2> uv=geom.UVs();
vector <Triangle> tri = geom.Triangles();
//transfer to GPU
//data for each vertex
glBindBuffer(GL_ARRAY_BUFFER, objectVertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * vert.size(), &vert[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, objectNormBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * norm.size(), &norm[0], GL_STATIC_DRAW);
//element array (triangles)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, objectElementBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, tri.size() * 3 * sizeof(unsigned int), &tri[0], GL_STATIC_DRAW);
//setup for postprocessing
glGenVertexArrays(1, &screenVertexArray);
glBindVertexArray(screenVertexArray);
//create buffers we will use
glGenBuffers(1, &screenVertexBuffer);
glGenBuffers(1, &screenElementBuffer);
//data for each vertex
glBindBuffer(GL_ARRAY_BUFFER, screenVertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 2 * 4, &screenVertex[0], GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, screenElementBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 2 * 3 * sizeof(GLuint), &screenTri[0], GL_STATIC_DRAW);
//load the texture
readTexture();
texture = setupTextureGL(tex, 256, 256, GL_RGB);
//main loop
while (!glfwWindowShouldClose(window))
{
DemoDisplay();
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
//.........这里部分代码省略.........