00001 /* 00002 * Copyright 2014 Google Inc. All Rights Reserved. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef TANGO_GL_OBJ_LOADER_H 00018 #define TANGO_GL_OBJ_LOADER_H 00019 00020 #include <vector> 00021 00022 #include "tango-gl/util.h" 00023 00024 namespace tango_gl { 00025 namespace obj_loader { 00026 // Load standard .obj file into vertices, indices or normals vectors, 00027 // OBJ file can be exported from 3D tools like 3ds Max or Blender. 00028 // A readable file with only vertices should look like 00029 // "v 1.00 2.00 3.00 00030 // ... 00031 // f 1 2 3 00032 // f 1 2 3 4 00033 // ..." 00034 // 00035 // If exported with normals, file should look like 00036 // "v 1.00 2.00 3.00 00037 // ... 00038 // f 1//1 2//3 3//4 00039 // f 1//1 2//3 3//4 4//6 00040 // ... 00041 // vn 1.00 2.00 3.00 00042 // ..." 00043 // this can be used with Mesh: 00044 // 00045 // std::vector<GLfloat> vertices; 00046 // std::vector<GLushort> indices; 00047 // std::vector<GLfloat> normals; 00048 // tango_gl::obj_loader::LoadOBJData("/sdcard/model.obj", vertices, indices); 00049 // mesh->SetVertices(vertices, indices); 00050 // or 00051 // tango_gl::obj_loader::LoadOBJData("/sdcard/model.obj", vertices, normals); 00052 // mesh->SetVertices(vertices, normals); 00053 00054 bool LoadOBJData(const char* path, std::vector<GLfloat>& vertices, 00055 std::vector<GLushort>& indices); 00056 00057 bool LoadOBJData(const char* path, std::vector<GLfloat>& vertices, 00058 std::vector<GLfloat>& normals); 00059 } // namespace obj_loader 00060 } // namespace tango_gl 00061 #endif // TANGO_GL_OBJ_LOADER