23#ifndef VCL_LOAD_SAVE_OBJ_MATERIAL_H
24#define VCL_LOAD_SAVE_OBJ_MATERIAL_H
26#include <vclib/space/core/color.h>
27#include <vclib/space/core/point.h>
29namespace vcl::detail {
47 bool hasColor =
false;
48 bool hasTexture =
false;
50 ObjMaterial() =
default;
52 ObjMaterial(
const Color& c) : hasColor(true)
60 ObjMaterial(
const std::string& txtName) : map_Kd(txtName), hasTexture(true)
64 ObjMaterial(
const Color& c,
const std::string& txtName) :
65 map_Kd(txtName), hasColor(true), hasTexture(true)
73 bool isEmpty()
const {
return !hasColor && !hasTexture; }
77 return Color(Kd.x() * 255, Kd.y() * 255, Kd.z() * 255, d * 255);
80 const std::string& texture()
const {
return map_Kd; }
82 uint textureId()
const {
return mapId; }
93 bool operator<(
const ObjMaterial& m)
const
103 else if (m.hasColor) {
112 return map_Kd < m.map_Kd;
114 else if (m.hasTexture) {
122 bool operator==(
const ObjMaterial& m)
const
124 return !(*
this < m) && !(m < *
this);
127 bool operator!=(
const ObjMaterial& m)
const {
return !(*
this == m); }
130inline std::ostream& operator<<(std::ostream& out,
const ObjMaterial& m)
133 out <<
"Kd " << m.Kd.x() <<
" " << m.Kd.y() <<
" " << m.Kd.z()
135 out <<
"d " << m.d << std::endl;
138 out <<
"map_Kd " << m.map_Kd << std::endl;
Point3< float > Point3f
A convenience alias for a 3-dimensional Point with floating-point components.
Definition point.h:792