Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
Assimp.cpp File Reference
#include <iostream>
#include "../../Config.hpp"
#include "Assimp.hpp"
#include "ObjectReader.hpp"
#include "TextureReader.hpp"
#include "Utils.hpp"
#include <algorithm>
#include <queue>
Include dependency graph for Assimp.cpp:

Functions

float interpolatedTimeFactor (const double now, const double prevTimeFrame, const double frameDiff, const double totalTime)
 
bool equalD (const double a, const double b)
 
bool equalF (const float a, const float b)
 
glm::vec3 interpolateLinear (const glm::vec3 &start, const glm::vec3 &end, float timeFactor)
 
glm::quat interpolateLinear (const glm::quat &start, const glm::quat &end, float timeFactor)
 
glm::vec3 interpolateAIVectorkeys (const aiVectorKey &current, const aiVectorKey &prev, const double now, const double totalTicks)
 
glm::quat interpolateAIQuatkeys (const aiQuatKey &current, const aiQuatKey &prev, const double now, double totalTicks)
 
bool containsSubString (const std::string &str, const std::string &subStr)
 
bool loadOBJFile (const std::string &path, std::vector< Vertex > &vertices, std::vector< uint32_t > &faces, const float scalingFactor)
 Loads the object from the given path. More...
 
bool loadOBJTile (std::vector< Vertex > &vertices, std::vector< uint32_t > &faces)
 Loads a double sided tile object. More...
 
bool loadGlTFFile (const std::string &path, std::vector< CharacterVertex > &vertices, std::vector< uint32_t > &indices, std::array< Animation, ANIMATION_TYPE_COUNT > &animations, std::vector< BoneNode > &bones, std::vector< glm::mat4 > &transformations)
 Loads the object from the given path. More...
 
size_t loadAnimations (const aiScene *scene, std::map< std::string, uint32_t > nameToIndex, std::array< Animation, ANIMATION_TYPE_COUNT > &animations)
 Loads animations from the given scene. More...
 
size_t fillSkeleton (aiNode *rootNode, std::vector< BoneNode > &boneList, std::vector< glm::mat4 > &transformations, std::map< std::string, uint32_t > &nameToIndex)
 Fills the given vectors with hierarchy and bone data. More...
 
glm::mat4 aiMatrix4x4ToGlm (const aiMatrix4x4 &matrix)
 Convert aiMatrix4x4 to glm::mat4. More...
 
glm::quat aiQuaternionToGlm (const aiQuaternion &quaternion)
 Convert aiQuaternion to glm::quat. More...
 
glm::vec3 aiVector3DToGlm (const aiVector3D &vector)
 Convert aiVector3D to glm::vec3. More...
 
void debugCharacterVertices (const std::vector< CharacterVertex > &vertices)
 Prints out faulty vertices. More...
 
Vertex aiVector3DToVertex (const aiVector3D &vector)
 Convert aiVector3D to Vertex. More...
 
std::vector< VertexaiVector3DVectorToVertexVector (const std::vector< aiVector3D > &vectors)
 Convert vector of aiVector3D to vector of Vertex. More...
 
std::vector< uint32_t > aiFaceToFace (const aiFace &face)
 Convert aiFace to RehtiGraphics Face. More...
 
std::vector< uint32_t > aiFaceVectorToFaceVector (const std::vector< aiFace > &faces)
 Convert vector of aiFace to vector of RehtiGraphics Faces. More...
 

Variables

constexpr double EPSILON = 0.00001
 
constexpr float EPSILON_F = 0.00001f
 

Function Documentation

◆ aiFaceToFace()

std::vector<uint32_t> aiFaceToFace ( const aiFace &  face)

Convert aiFace to RehtiGraphics Face.

Returns
RehtiGraphics Face
Here is the caller graph for this function:

◆ aiFaceVectorToFaceVector()

std::vector<uint32_t> aiFaceVectorToFaceVector ( const std::vector< aiFace > &  faces)

Convert vector of aiFace to vector of RehtiGraphics Faces.

Returns
Vector of RehtiGraphics Faces
Here is the call graph for this function:

◆ aiMatrix4x4ToGlm()

glm::mat4 aiMatrix4x4ToGlm ( const aiMatrix4x4 &  matrix)

Convert aiMatrix4x4 to glm::mat4.

Returns
glm::mat4
Here is the caller graph for this function:

◆ aiQuaternionToGlm()

glm::quat aiQuaternionToGlm ( const aiQuaternion &  quaternion)

Convert aiQuaternion to glm::quat.

Returns
glm::quat
Here is the caller graph for this function:

◆ aiVector3DToGlm()

glm::vec3 aiVector3DToGlm ( const aiVector3D &  vector)

Convert aiVector3D to glm::vec3.

Returns
glm::vec3
Here is the caller graph for this function:

◆ aiVector3DToVertex()

Vertex aiVector3DToVertex ( const aiVector3D &  vector)

Convert aiVector3D to Vertex.

Returns
Vertex
Here is the caller graph for this function:

◆ aiVector3DVectorToVertexVector()

std::vector<Vertex> aiVector3DVectorToVertexVector ( const std::vector< aiVector3D > &  vectors)

Convert vector of aiVector3D to vector of Vertex.

Returns
Vector of Vertex
Here is the call graph for this function:

◆ containsSubString()

bool containsSubString ( const std::string &  str,
const std::string &  subStr 
)
inline
Here is the caller graph for this function:

◆ debugCharacterVertices()

void debugCharacterVertices ( const std::vector< CharacterVertex > &  vertices)

Prints out faulty vertices.

Parameters
verticesto check
Here is the caller graph for this function:

◆ equalD()

bool equalD ( const double  a,
const double  b 
)
inline
Here is the caller graph for this function:

◆ equalF()

bool equalF ( const float  a,
const float  b 
)
inline
Here is the caller graph for this function:

◆ fillSkeleton()

size_t fillSkeleton ( aiNode *  rootNode,
std::vector< BoneNode > &  boneList,
std::vector< glm::mat4 > &  transformations,
std::map< std::string, uint32_t > &  nameToIndex 
)

Fills the given vectors with hierarchy and bone data.

Parameters
rootNodeis the root node of the hierarchy.
boneListis the list of bones.
transformationsis the list of transformations.
nameToIndexis the map of bone names to their indices.
Returns
The number of bones.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ interpolateAIQuatkeys()

glm::quat interpolateAIQuatkeys ( const aiQuatKey &  current,
const aiQuatKey &  prev,
const double  now,
double  totalTicks 
)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ interpolateAIVectorkeys()

glm::vec3 interpolateAIVectorkeys ( const aiVectorKey &  current,
const aiVectorKey &  prev,
const double  now,
const double  totalTicks 
)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ interpolatedTimeFactor()

float interpolatedTimeFactor ( const double  now,
const double  prevTimeFrame,
const double  frameDiff,
const double  totalTime 
)
inline
Here is the caller graph for this function:

◆ interpolateLinear() [1/2]

glm::quat interpolateLinear ( const glm::quat &  start,
const glm::quat &  end,
float  timeFactor 
)
inline

◆ interpolateLinear() [2/2]

glm::vec3 interpolateLinear ( const glm::vec3 &  start,
const glm::vec3 &  end,
float  timeFactor 
)
inline
Here is the caller graph for this function:

◆ loadAnimations()

size_t loadAnimations ( const aiScene *  scene,
const std::map< std::string, uint32_t >  nameToIndex,
std::array< Animation, ANIMATION_TYPE_COUNT > &  animations 
)

Loads animations from the given scene.

Parameters
sceneto load animations from.
nameToIndexmap of bone names to their indices.
animationsarray to fill with animations.
Returns
boolean indicating success
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadGlTFFile()

bool loadGlTFFile ( const std::string &  path,
std::vector< CharacterVertex > &  vertices,
std::vector< uint32_t > &  indices,
std::array< Animation, ANIMATION_TYPE_COUNT > &  animations,
std::vector< BoneNode > &  bones,
std::vector< glm::mat4 > &  transformations 
)

Loads the object from the given path.

Parameters
pathto the object file.
verticesEmpty vector of float that will be filled with the vertices.
indicesEmpty vector of unsigned int that will be filled with the indices.
animationsEmpty array of Animation that will be filled with the animations.
bonesEmpty vector of BoneNode that will be filled with the bones.
Returns
True if the object was loaded successfully, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadOBJFile()

bool loadOBJFile ( const std::string &  path,
std::vector< Vertex > &  vertices,
std::vector< uint32_t > &  faces,
const float  scalingFactor = 1.0f 
)

Loads the object from the given path.

Parameters
pathto the object file.
verticesEmpty vector of float that will be filled with the vertices.
indicesEmpty vector of unsigned int that will be filled with the indices.
scalingFactorThe scaling factor for the vertices
Returns
True if the object was loaded successfully, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadOBJTile()

bool loadOBJTile ( std::vector< Vertex > &  vertices,
std::vector< uint32_t > &  faces 
)

Loads a double sided tile object.

Parameters
verticesto be filled.
facesto be filled.
Returns
boolean indicating success (always true)
Here is the caller graph for this function:

Variable Documentation

◆ EPSILON

constexpr double EPSILON = 0.00001
constexpr

◆ EPSILON_F

constexpr float EPSILON_F = 0.00001f
constexpr