mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-28 07:37:51 -05:00
chore: move xmodel packages
This commit is contained in:
54
src/ObjCommon/XModel/Obj/ObjCommon.cpp
Normal file
54
src/ObjCommon/XModel/Obj/ObjCommon.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#include "ObjCommon.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <tuple>
|
||||
|
||||
bool operator==(const ObjVertex& lhs, const ObjVertex& rhs)
|
||||
{
|
||||
return std::fabs(lhs.coordinates[0] - rhs.coordinates[0]) < std::numeric_limits<float>::epsilon()
|
||||
&& std::fabs(lhs.coordinates[1] - rhs.coordinates[1]) < std::numeric_limits<float>::epsilon()
|
||||
&& std::fabs(lhs.coordinates[2] - rhs.coordinates[2]) < std::numeric_limits<float>::epsilon();
|
||||
}
|
||||
|
||||
bool operator!=(const ObjVertex& lhs, const ObjVertex& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator<(const ObjVertex& lhs, const ObjVertex& rhs)
|
||||
{
|
||||
return std::tie(lhs.coordinates[0], lhs.coordinates[1], lhs.coordinates[2]) < std::tie(rhs.coordinates[0], rhs.coordinates[1], rhs.coordinates[2]);
|
||||
}
|
||||
|
||||
bool operator==(const ObjNormal& lhs, const ObjNormal& rhs)
|
||||
{
|
||||
return std::fabs(lhs.normal[0] - rhs.normal[0]) < std::numeric_limits<float>::epsilon()
|
||||
&& std::fabs(lhs.normal[1] - rhs.normal[1]) < std::numeric_limits<float>::epsilon()
|
||||
&& std::fabs(lhs.normal[2] - rhs.normal[2]) < std::numeric_limits<float>::epsilon();
|
||||
}
|
||||
|
||||
bool operator!=(const ObjNormal& lhs, const ObjNormal& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator<(const ObjNormal& lhs, const ObjNormal& rhs)
|
||||
{
|
||||
return std::tie(lhs.normal[0], lhs.normal[1], lhs.normal[2]) < std::tie(rhs.normal[0], rhs.normal[1], rhs.normal[2]);
|
||||
}
|
||||
|
||||
bool operator==(const ObjUv& lhs, const ObjUv& rhs)
|
||||
{
|
||||
return std::fabs(lhs.uv[0] - rhs.uv[0]) < std::numeric_limits<float>::epsilon() && std::fabs(lhs.uv[1] - rhs.uv[1]) < std::numeric_limits<float>::epsilon();
|
||||
}
|
||||
|
||||
bool operator!=(const ObjUv& lhs, const ObjUv& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator<(const ObjUv& lhs, const ObjUv& rhs)
|
||||
{
|
||||
return std::tie(lhs.uv[0], lhs.uv[1]) < std::tie(rhs.uv[0], rhs.uv[1]);
|
||||
}
|
51
src/ObjCommon/XModel/Obj/ObjCommon.h
Normal file
51
src/ObjCommon/XModel/Obj/ObjCommon.h
Normal file
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
struct ObjObject
|
||||
{
|
||||
std::string name;
|
||||
int materialIndex;
|
||||
};
|
||||
|
||||
struct ObjVertex
|
||||
{
|
||||
float coordinates[3];
|
||||
|
||||
friend bool operator==(const ObjVertex& lhs, const ObjVertex& rhs);
|
||||
friend bool operator!=(const ObjVertex& lhs, const ObjVertex& rhs);
|
||||
friend bool operator<(const ObjVertex& lhs, const ObjVertex& rhs);
|
||||
};
|
||||
|
||||
struct ObjNormal
|
||||
{
|
||||
float normal[3];
|
||||
|
||||
friend bool operator==(const ObjNormal& lhs, const ObjNormal& rhs);
|
||||
friend bool operator!=(const ObjNormal& lhs, const ObjNormal& rhs);
|
||||
friend bool operator<(const ObjNormal& lhs, const ObjNormal& rhs);
|
||||
};
|
||||
|
||||
struct ObjUv
|
||||
{
|
||||
float uv[2];
|
||||
|
||||
friend bool operator==(const ObjUv& lhs, const ObjUv& rhs);
|
||||
friend bool operator!=(const ObjUv& lhs, const ObjUv& rhs);
|
||||
friend bool operator<(const ObjUv& lhs, const ObjUv& rhs);
|
||||
};
|
||||
|
||||
struct ObjFace
|
||||
{
|
||||
int vertexIndex[3];
|
||||
int normalIndex[3];
|
||||
int uvIndex[3];
|
||||
};
|
||||
|
||||
struct MtlMaterial
|
||||
{
|
||||
std::string materialName;
|
||||
std::string colorMapName;
|
||||
std::string normalMapName;
|
||||
std::string specularMapName;
|
||||
};
|
Reference in New Issue
Block a user