GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing android.googlesource.com — platform/external/tinyobjloader - Git at Google Bug: 68939465Clone this repo:
Branches
tinyobjloaderhttps://github.com/syoyo/tinyobjloader Tiny but powerful single file wavefront obj loader written in C++. No dependency except for C++ STL. It can parse over 10M polygons with moderate memory and time.
If you are looking for C89 version, please see https://github.com/syoyo/tinyobjloader-c . Notice!We have released new version v1.0.0 on 20 Aug, 2016. Old version is available What's new
Old versionPrevious old version is avaiable in Exampletinyobjloader can successfully load 6M triangles Rungholt scene. http://casual-effects.com/data/index.html
Use caseTinyObjLoader is successfully used in ... New version(v1.0.x)
Old version(v0.9.x)
Features
TODO
LicenseLicensed under MIT license. UsageData format
attrib_t::vertices => 3 floats per vertex
v[0] v[1] v[2] v[3] v[n-1]
+-----------+-----------+-----------+-----------+ +-----------+
| x | y | z | x | y | z | x | y | z | x | y | z | .... | x | y | z |
+-----------+-----------+-----------+-----------+ +-----------+
attrib_t::normals => 3 floats per vertex
n[0] n[1] n[2] n[3] n[n-1]
+-----------+-----------+-----------+-----------+ +-----------+
| x | y | z | x | y | z | x | y | z | x | y | z | .... | x | y | z |
+-----------+-----------+-----------+-----------+ +-----------+
attrib_t::texcoords => 2 floats per vertex
t[0] t[1] t[2] t[3] t[n-1]
+-----------+-----------+-----------+-----------+ +-----------+
| u | v | u | v | u | v | u | v | .... | u | v |
+-----------+-----------+-----------+-----------+ +-----------+
attrib_t::colors => 3 floats per vertex(vertex color. optional)
c[0] c[1] c[2] c[3] c[n-1]
+-----------+-----------+-----------+-----------+ +-----------+
| x | y | z | x | y | z | x | y | z | x | y | z | .... | x | y | z |
+-----------+-----------+-----------+-----------+ +-----------+
Each
Note that when float data typeTinyObjLoader now use Example code#define TINYOBJLOADER_IMPLEMENTATION // define this in only *one* .cc #include "tiny_obj_loader.h" std::string inputfile = "cornell_box.obj"; tinyobj::attrib_t attrib; std::vector<tinyobj::shape_t> shapes; std::vector<tinyobj::material_t> materials; std::string err; bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, inputfile.c_str()); if (!err.empty()) { // `err` may contain warning message. std::cerr << err << std::endl; } if (!ret) { exit(1); } // Loop over shapes for (size_t s = 0; s < shapes.size(); s++) { // Loop over faces(polygon) size_t index_offset = 0; for (size_t f = 0; f < shapes[s].mesh.num_face_vertices.size(); f++) { int fv = shapes[s].mesh.num_face_vertices[f]; // Loop over vertices in the face. for (size_t v = 0; v < fv; v++) { // access to vertex tinyobj::index_t idx = shapes[s].mesh.indices[index_offset + v]; tinyobj::real_t vx = attrib.vertices[3*idx.vertex_index+0]; tinyobj::real_t vy = attrib.vertices[3*idx.vertex_index+1]; tinyobj::real_t vz = attrib.vertices[3*idx.vertex_index+2]; tinyobj::real_t nx = attrib.normals[3*idx.normal_index+0]; tinyobj::real_t ny = attrib.normals[3*idx.normal_index+1]; tinyobj::real_t nz = attrib.normals[3*idx.normal_index+2]; tinyobj::real_t tx = attrib.texcoords[2*idx.texcoord_index+0]; tinyobj::real_t ty = attrib.texcoords[2*idx.texcoord_index+1]; // Optional: vertex colors // tinyobj::real_t red = attrib.colors[3*idx.vertex_index+0]; // tinyobj::real_t green = attrib.colors[3*idx.vertex_index+1]; // tinyobj::real_t blue = attrib.colors[3*idx.vertex_index+2]; } index_offset += fv; // per-face material shapes[s].mesh.material_ids[f]; } } Optimized loaderOptimized multi-threaded .obj loader is available at Here is some benchmark result. Time are measured on MacBook 12(Early 2016, Core m5 1.2GHz).
TestsUnit tests are provided in |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |