blob: c19be141f9e1ff54aec25f6fe99034f1737a0d4f [file] [log] [blame]
Tanmay Patil9aa69062020-05-29 17:54:22 -07001/*
2 * Copyright 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SURROUND_VIEW_SERVICE_IMPL_OBJREADER_H_
18#define SURROUND_VIEW_SERVICE_IMPL_OBJREADER_H_
19
20#include <map>
21#include <string>
22
23#include "core_lib.h"
24
25namespace android {
26namespace hardware {
27namespace automotive {
28namespace sv {
29namespace V1_0 {
30namespace implementation {
31
32using android_auto::surround_view::CarPart;
33
34// ReadObjOptions for processing obj's vertex coordinates.
35// Sequence of processing ReadObjOptions:
36// 1. coordinate_mapping
37// 2. scales
38// 3. offsets
39struct ReadObjOptions {
40 // Maps obj coordinates to the output overlay coordinate.
41 // 0 <-> x, 1 <-> y, 2 <-> z
42 // Default is {0, 1, 2}, without coordinate changes.
43 int coordinateMapping[3] = {0, 1, 2};
44
45 // scale of each coordinate (after offsets).
46 float scales[3] = {1.0f, 1.0f, 1.0f};
47
48 // offset of each coordinate (after mapping).
49 float offsets[3] = {0, 0, 0};
50
51 // Optional mtl filename. String name is obj file is used if this is empty.
52 std::string mtlFilename;
53};
54
55// Reads obj file to vector of OverlayVertex.
56// |obj_filename| is the full path and name of the obj file.
57// |car_parts_map| is a map containing all car parts.
58// Now it only supports two face formats:
59// 1. f x/x/x x/x/x x/x/x ...
60// 2. f x//x x//x x//x ...
61// b/
62bool ReadObjFromFile(const std::string& objFilename, std::map<std::string, CarPart>* carPartsMap);
63
64// Reads obj file to vector of OverlayVertex.
65// |obj_filename| is the full path and name of the obj file.
66// |option| provides optional changes on the coordinates.
67// |car_parts_map| is a map containing all car parts.
68bool ReadObjFromFile(const std::string& obFilename, const ReadObjOptions& option,
69 std::map<std::string, CarPart>* carPartsMap);
70
71} // namespace implementation
72} // namespace V1_0
73} // namespace sv
74} // namespace automotive
75} // namespace hardware
76} // namespace android
77
78#endif // SURROUND_VIEW_SERVICE_IMPL_OBJREADER_H_