Refactor & Readme
This commit is contained in:
15
README.md
Normal file
15
README.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
## Collage
|
||||||
|
#### [](http://unlicense.org/)
|
||||||
|
|
||||||
|
Another model loader for Linux & Windows.
|
||||||
|
|
||||||
|
### Supported Formats
|
||||||
|
- Wavefront OBJ
|
||||||
|
- Animated Wavefront OBJ
|
||||||
|
- Collada (maybe)
|
||||||
|
- FBX
|
||||||
|
|
||||||
|
### Building The Demo
|
||||||
|
```bash
|
||||||
|
git clone https://git.redacted.cc/Redacted/Collage.git && cd Collage && mkdir build && cd build && cmake .. && make -j8
|
||||||
|
```
|
2
include/Collage/collage.h
Normal file
2
include/Collage/collage.h
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Collage/types/model.h>
|
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <types/bone.h>
|
#include <Collage/types/bone.h>
|
||||||
|
|
||||||
struct KeyFrame {
|
struct KeyFrame {
|
||||||
uint index;
|
uint index;
|
2
include/Collage/types/keyFrame.h
Normal file
2
include/Collage/types/keyFrame.h
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Collage/types/bone.h>
|
@@ -5,7 +5,7 @@
|
|||||||
#include <J3ML/LinearAlgebra.h>
|
#include <J3ML/LinearAlgebra.h>
|
||||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||||
#include<J3ML/Geometry.h>
|
#include<J3ML/Geometry.h>
|
||||||
#include <types/textureInfo.h>
|
#include <Collage/types/textureInfo.h>
|
||||||
|
|
||||||
typedef Vector3 Vertex;
|
typedef Vector3 Vertex;
|
||||||
|
|
@@ -1,2 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <types/model.h>
|
|
@@ -1,2 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <types/bone.h>
|
|
21
src/obj.cpp
21
src/obj.cpp
@@ -1,9 +1,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <types/model.h>
|
#include <Collage/types/model.h>
|
||||||
|
|
||||||
void Model::loadOBJ(const std::string& filename) {
|
void Model::loadOBJ(const std::string& filename) {
|
||||||
std::ifstream file(filename);
|
std::ifstream file(filename);
|
||||||
//if (!file.is_open())
|
|
||||||
std::vector<Vector3> positions;
|
std::vector<Vector3> positions;
|
||||||
std::vector<Vector2> uvs;
|
std::vector<Vector2> uvs;
|
||||||
TextureInformation tInfo = {};
|
TextureInformation tInfo = {};
|
||||||
@@ -35,7 +34,6 @@ void Model::loadOBJ(const std::string& filename) {
|
|||||||
Vector2 textureCoordinate;
|
Vector2 textureCoordinate;
|
||||||
vertex = positions[vertexIndex[i]];
|
vertex = positions[vertexIndex[i]];
|
||||||
textureCoordinate = uvs[texCoordIndex[i]];
|
textureCoordinate = uvs[texCoordIndex[i]];
|
||||||
|
|
||||||
vertices.push_back(vertex);
|
vertices.push_back(vertex);
|
||||||
tInfo.textureCoordinates.push_back(textureCoordinate);
|
tInfo.textureCoordinates.push_back(textureCoordinate);
|
||||||
indices.push_back(static_cast<unsigned int>(indices.size()));
|
indices.push_back(static_cast<unsigned int>(indices.size()));
|
||||||
@@ -44,19 +42,4 @@ void Model::loadOBJ(const std::string& filename) {
|
|||||||
}
|
}
|
||||||
textureInfo.push_back(tInfo);
|
textureInfo.push_back(tInfo);
|
||||||
file.close();
|
file.close();
|
||||||
};
|
};
|
||||||
|
|
||||||
// map face of model to positions and texture coords
|
|
||||||
void Model::mapFaces(const FaceIndices& facedata, const std::vector<Vector3>& positions, const std::vector<Vector2>& uvs) {
|
|
||||||
std::vector<Vector2> textureCoordinates;
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
|
||||||
Vector3 vertex;
|
|
||||||
//Vector2 textureCoordinate;
|
|
||||||
vertex = positions[facedata.vertexIndex[i]];
|
|
||||||
//textureCoordinate = uvs[facedata.texCoordIndex[i]];
|
|
||||||
vertices.push_back(vertex);
|
|
||||||
indices.push_back(static_cast<unsigned int>(indices.size()));
|
|
||||||
//textureCoordinates.push_back(textureCoordinate);
|
|
||||||
}
|
|
||||||
textureInfo.push_back({"", textureCoordinates});
|
|
||||||
}
|
|
@@ -1,2 +1,2 @@
|
|||||||
#include <types/animation.h>
|
#include <Collage/types/animation.h>
|
||||||
#include <types/keyFrame.h>
|
#include <Collage/types/keyFrame.h>
|
@@ -1,4 +1,4 @@
|
|||||||
#include <types/bone.h>
|
#include <Collage/types/bone.h>
|
||||||
|
|
||||||
const Matrix4x4& Bone::getMatrix() {
|
const Matrix4x4& Bone::getMatrix() {
|
||||||
return matrix;
|
return matrix;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#include <types/bone.h>
|
#include <Collage/types/bone.h>
|
||||||
struct BoneMap {
|
struct BoneMap {
|
||||||
std::vector<Bone> bones;
|
std::vector<Bone> bones;
|
||||||
};
|
};
|
@@ -1,4 +1,4 @@
|
|||||||
#include <types/model.h>
|
#include <Collage/types/model.h>
|
||||||
|
|
||||||
void Model::load(const std::string& file) {
|
void Model::load(const std::string& file) {
|
||||||
if (file.ends_with(".obj"))
|
if (file.ends_with(".obj"))
|
||||||
|
Reference in New Issue
Block a user