MeshGeometry PrimitiveGeometryBuilder::buildCylinderMesh(std::vector<tgt::vec3>& vertices, size_t numSides, tgt::vec3 color) { // Transform vec3 to vec4 tgt::vec4 color4(color[0], color[1], color[2], 1.f); // Build cylinder's sides MeshGeometry cyl; for (size_t i = 0; i < 2*numSides; i+=2) { FaceGeometry face; tgt::vec3 faceNormal = tgt::cross(vertices[i+1] - vertices[i], vertices[i+2] - vertices[i]); // Face vertices // TODO Replace faceNormal with vertex normals for smoother representation VertexGeometry fv1(vertices[i], tgt::vec3(0.f), color4, faceNormal); VertexGeometry fv2(vertices[i+1], tgt::vec3(0.f), color4, faceNormal); VertexGeometry fv3(vertices[i+3], tgt::vec3(0.f), color4, faceNormal); VertexGeometry fv4(vertices[i+2], tgt::vec3(0.f), color4, faceNormal); face.addVertex(fv1); face.addVertex(fv2); face.addVertex(fv3); face.addVertex(fv4); cyl.addFace(face); } return cyl; }
int main(int argc, char **argv) { plan_tests(17); ok1(Directory::Exists(_T("test/data/file_visitor_test"))); ok1(File::Exists(_T("test/data/file_visitor_test/a.txt"))); ok1(File::Exists(_T("test/data/file_visitor_test/b.txt"))); ok1(File::Exists(_T("test/data/file_visitor_test/c.tx"))); ok1(File::Exists(_T("test/data/file_visitor_test/subfolder/d.txt"))); TestingFileVisitor fv1(false, false); Directory::VisitFiles(_T("test/data/file_visitor_test"), fv1, false); TestingFileVisitor fv2(true, false); Directory::VisitFiles(_T("test/data/file_visitor_test"), fv2, true); TestingFileVisitor fv3(false, true); Directory::VisitSpecificFiles(_T("test/data/file_visitor_test"), _T("*.txt"), fv3, false); TestingFileVisitor fv4(true, true); Directory::VisitSpecificFiles(_T("test/data/file_visitor_test"), _T("*.txt"), fv4, true); return exit_status(); }
//------------------------------------------------------------------------ // llgl_dump() //------------------------------------------------------------------------ void llgl_dump() { int i; F32 fv[16]; GLboolean b; LL_INFOS() << "==========================" << LL_ENDL; LL_INFOS() << "OpenGL State" << LL_ENDL; LL_INFOS() << "==========================" << LL_ENDL; LL_INFOS() << "-----------------------------------" << LL_ENDL; LL_INFOS() << "Current Values" << LL_ENDL; LL_INFOS() << "-----------------------------------" << LL_ENDL; glGetFloatv(GL_CURRENT_COLOR, fv); LL_INFOS() << "GL_CURRENT_COLOR : " << fv4(fv) << LL_ENDL; glGetFloatv(GL_CURRENT_NORMAL, fv); LL_INFOS() << "GL_CURRENT_NORMAL : " << fv3(fv) << LL_ENDL; LL_INFOS() << "-----------------------------------" << LL_ENDL; LL_INFOS() << "Lighting" << LL_ENDL; LL_INFOS() << "-----------------------------------" << LL_ENDL; LL_INFOS() << "GL_LIGHTING : " << boolstr(glIsEnabled(GL_LIGHTING)) << LL_ENDL; LL_INFOS() << "GL_COLOR_MATERIAL : " << boolstr(glIsEnabled(GL_COLOR_MATERIAL)) << LL_ENDL; glGetIntegerv(GL_COLOR_MATERIAL_PARAMETER, (GLint*)&i); LL_INFOS() << "GL_COLOR_MATERIAL_PARAMETER: " << cmstr(i) << LL_ENDL; glGetIntegerv(GL_COLOR_MATERIAL_FACE, (GLint*)&i); LL_INFOS() << "GL_COLOR_MATERIAL_FACE : " << facestr(i) << LL_ENDL; fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f; glGetMaterialfv(GL_FRONT, GL_AMBIENT, fv); LL_INFOS() << "GL_AMBIENT material : " << fv4(fv) << LL_ENDL; fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f; glGetMaterialfv(GL_FRONT, GL_DIFFUSE, fv); LL_INFOS() << "GL_DIFFUSE material : " << fv4(fv) << LL_ENDL; fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f; glGetMaterialfv(GL_FRONT, GL_SPECULAR, fv); LL_INFOS() << "GL_SPECULAR material : " << fv4(fv) << LL_ENDL; fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f; glGetMaterialfv(GL_FRONT, GL_EMISSION, fv); LL_INFOS() << "GL_EMISSION material : " << fv4(fv) << LL_ENDL; fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f; glGetMaterialfv(GL_FRONT, GL_SHININESS, fv); LL_INFOS() << "GL_SHININESS material : " << fv1(fv) << LL_ENDL; fv[0] = fv[1] = fv[2] = fv[3] = 12345.6789f; glGetFloatv(GL_LIGHT_MODEL_AMBIENT, fv); LL_INFOS() << "GL_LIGHT_MODEL_AMBIENT : " << fv4(fv) << LL_ENDL; glGetBooleanv(GL_LIGHT_MODEL_LOCAL_VIEWER, &b); LL_INFOS() << "GL_LIGHT_MODEL_LOCAL_VIEWER: " << boolstr(b) << LL_ENDL; glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE, &b); LL_INFOS() << "GL_LIGHT_MODEL_TWO_SIDE : " << boolstr(b) << LL_ENDL; for (int l=0; l<8; l++) { b = glIsEnabled(GL_LIGHT0+l); LL_INFOS() << "GL_LIGHT" << l << " : " << boolstr(b) << LL_ENDL; if (!b) continue; glGetLightfv(GL_LIGHT0+l, GL_AMBIENT, fv); LL_INFOS() << " GL_AMBIENT light : " << fv4(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_DIFFUSE, fv); LL_INFOS() << " GL_DIFFUSE light : " << fv4(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_SPECULAR, fv); LL_INFOS() << " GL_SPECULAR light : " << fv4(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_POSITION, fv); LL_INFOS() << " GL_POSITION light : " << fv4(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_CONSTANT_ATTENUATION, fv); LL_INFOS() << " GL_CONSTANT_ATTENUATION : " << fv1(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_QUADRATIC_ATTENUATION, fv); LL_INFOS() << " GL_QUADRATIC_ATTENUATION : " << fv1(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_SPOT_DIRECTION, fv); LL_INFOS() << " GL_SPOT_DIRECTION : " << fv4(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_SPOT_EXPONENT, fv); LL_INFOS() << " GL_SPOT_EXPONENT : " << fv1(fv) << LL_ENDL; glGetLightfv(GL_LIGHT0+l, GL_SPOT_CUTOFF, fv); LL_INFOS() << " GL_SPOT_CUTOFF : " << fv1(fv) << LL_ENDL; } LL_INFOS() << "-----------------------------------" << LL_ENDL; LL_INFOS() << "Pixel Operations" << LL_ENDL; LL_INFOS() << "-----------------------------------" << LL_ENDL; LL_INFOS() << "GL_ALPHA_TEST : " << boolstr(glIsEnabled(GL_ALPHA_TEST)) << LL_ENDL; LL_INFOS() << "GL_DEPTH_TEST : " << boolstr(glIsEnabled(GL_DEPTH_TEST)) << LL_ENDL; glGetBooleanv(GL_DEPTH_WRITEMASK, &b); LL_INFOS() << "GL_DEPTH_WRITEMASK : " << boolstr(b) << LL_ENDL; LL_INFOS() << "GL_BLEND : " << boolstr(glIsEnabled(GL_BLEND)) << LL_ENDL; LL_INFOS() << "GL_DITHER : " << boolstr(glIsEnabled(GL_DITHER)) << LL_ENDL; }