Blender V5.0
obj_import_objects.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BLI_map.hh"
12#include "BLI_math_base.hh"
14#include "BLI_set.hh"
15#include "BLI_vector.hh"
16
17#include "DNA_object_types.h"
18
19namespace blender::io::obj {
20
28
34
40
46
47 void set_vertex_color(size_t index, float3 color)
48 {
49 if (index >= vertex_colors.size()) {
50 vertex_colors.resize(index + 1, float3(-1.0, -1.0, -1.0));
51 }
52 vertex_colors[index] = color;
53 }
54
55 void set_vertex_weight(size_t index, float weight)
56 {
57 if (index >= vertex_weights.size()) {
58 vertex_weights.resize(index + 1, 1.0);
59 }
60 vertex_weights[index] = weight;
61 }
62
63 bool has_vertex_color(size_t index) const
64 {
65 return index < vertex_colors.size() && vertex_colors[index].x >= 0.0;
66 }
67
69 {
70 if (!mrgb_block.is_empty()) {
71 /* Set color of the last mrgb_block.size() verts. */
72 size_t start_of_block = 0;
73 if (mrgb_block.size() <= vertices.size()) {
74 start_of_block = vertices.size() - mrgb_block.size();
75 }
76 if (start_of_block == 0) {
77 vertex_colors = std::move(mrgb_block);
78 }
79 else {
80 vertex_colors.resize(start_of_block, float3(-1.0, -1.0, -1.0));
82 }
83 mrgb_block.clear();
84 }
85 }
86};
87
91struct FaceCorner {
92 /* These indices range from zero to total vertices in the OBJ file. */
94 /* -1 is to indicate absence of UV vertices. Only < 0 condition should be checked since
95 * it can be less than -1 too. */
96 int uv_vert_index = -1;
98};
99
100struct FaceElem {
103 bool shaded_smooth = false;
106};
107
116 std::string group_;
117 int degree = 0;
118 float2 range{0.0f, 1.0f};
123 /* Values in the parm u/v line in a curve definition. */
125};
126
131
132struct Geometry {
134 std::string geometry_name_;
139
140 int vertex_index_min_ = INT_MAX;
142 /* Global vertex indices used by this geometry. */
144 /* Mapping from global vertex index to geometry-local vertex index. */
146 /* Loose edges in the file. */
148
151
152 bool has_invalid_faces_ = false;
153 bool has_vertex_groups_ = false;
156
158 {
159 return int(vertices_.size());
160 }
161 void track_vertex_index(int index)
162 {
163 vertices_.add(index);
166 }
168 {
169 vertices_.reserve(count);
170 for (int i = 0; i < count; ++i) {
171 vertices_.add(i);
172 }
175 }
176};
177
178} // namespace blender::io::obj
Object is a sort of wrapper for general info.
@ OB_MESH
@ OB_CURVES_LEGACY
int count
void min_inplace(T &a, const T &b)
void max_inplace(T &a, const T &b)
VecBase< float, 2 > float2
VecBase< float, 3 > float3
Vector< std::string > material_order_
Map< int, int > global_to_local_vertices_
Vector< FaceCorner > face_corners_
Map< std::string, int > group_indices_
Vector< std::string > group_order_
Map< std::string, int > material_indices_
void set_vertex_weight(size_t index, float weight)
bool has_vertex_color(size_t index) const
void set_vertex_color(size_t index, float3 color)
i
Definition text_draw.cc:230