30 Commits
v0.3 ... main

Author SHA1 Message Date
e1940bb8c2 j3ml update 2024-09-12 20:51:17 -04:00
c2c59adefc fixed cmake_minimum_required using rebitch 2024-08-26 19:54:51 -04:00
5c23ff7701 update for J3ML 3.0 2024-08-21 13:36:31 -04:00
cedad4f3ea Latest J3ML 2024-08-19 22:39:41 -04:00
65792fbff2 Initial MSVC 2024-06-30 01:27:46 -04:00
maxbyte9p
b37eba52aa added disclamer to amo parser 2024-05-21 16:00:01 -04:00
maxbyte9p
1a90e00fd6 removed uneeded included libs 2024-05-21 15:55:35 -04:00
maxbyte9p
c527d4fa57 animation parsing janky as shit, but it's working I think 2024-05-21 15:48:26 -04:00
maxbyte9p
2fb62d38ce animation parsing underway 2024-05-21 15:46:59 -04:00
maxbyte9p
87ce88c02a removed more old code 2024-05-21 11:30:01 -04:00
maxbyte9p
f9085722fd Cleaned up vertice parser 2024-05-21 11:29:08 -04:00
maxbyte9p
51a68240b0 removed some old commented out code 2024-05-21 11:21:34 -04:00
maxbyte9p
88adf1618e cleaned up vt parse 2024-05-21 11:19:47 -04:00
maxbyte9p
b1a6202a3b cleaned up vn parsing 2024-05-21 11:01:16 -04:00
maxbyte9p
40d88cdb9f more cleanup 2024-05-21 10:48:33 -04:00
maxbyte9p
7dc9fc2f23 rewriting shittastic AMO parsing. 2024-05-20 16:53:04 -04:00
maxbyte9p
586149c770 wrote vw parser 2024-05-20 11:36:02 -04:00
maxbyte9p
8fee6a54f3 vj parser 2024-05-20 11:31:53 -04:00
maxbyte9p
2a8b371b89 commented out non-working line 2024-05-20 11:21:49 -04:00
maxbyte9p
785f2b63d6 wrote vn parser 2024-05-20 11:21:29 -04:00
maxbyte9p
15e5d76326 added back loadAMO 2024-05-20 11:21:05 -04:00
maxbyte9p
f43623c163 Merge branch 'main' of https://git.redacted.cc/Redacted/Collage
I'm committing my AMO parser shit
2024-05-20 10:43:43 -04:00
maxbyte9p
5eebaa294a fleshing out amo parser. Got v N parsable. 2024-05-20 10:41:25 -04:00
301e36e3bb Some functions 2024-05-19 20:04:09 -04:00
maxbyte9p
37d81e9c0f tweaked for amo parser implementation and testing 2024-05-16 13:57:30 -04:00
maxbyte9p
00ccfcce4d Initial AMO file parser 2024-05-16 13:55:43 -04:00
maxbyte9p
89c87c6699 animations[0] -> animations[0][0] 2024-05-16 11:16:42 -04:00
2f4e14d292 Animation stuff 2024-05-12 10:21:01 -04:00
5a65f57ad7 Refactor & Readme 2024-05-07 23:00:16 -04:00
c294f6e50a Update obj.cpp 2024-05-07 18:44:42 -04:00
16 changed files with 63 additions and 60 deletions

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.18..3.27)
project(Collage
VERSION 1.0
LANGUAGES CXX
@@ -11,7 +11,7 @@ include(cmake/CPM.cmake)
CPMAddPackage(
NAME J3ML
URL https://git.redacted.cc/josh/j3ml/archive/Release-1.zip
URL https://git.redacted.cc/josh/j3ml/archive/Release-3.1.zip
)
set(CMAKE_CXX_STANDARD 20)
@@ -25,10 +25,17 @@ if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-Source builds are not allowed")
endif()
add_library(Collage SHARED ${SOURCES} ${HEADERS})
if (UNIX AND NOT APPLE)
add_library(Collage SHARED ${SOURCES} ${HEADERS})
endif()
if (WIN32)
add_library(Collage STATIC ${SOURCES} ${HEADERS})
endif()
add_executable(CollageTest main.cpp)
set_target_properties(Collage PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(Collage PUBLIC J3ML)
target_link_libraries(CollageTest PUBLIC Collage)
set_target_properties(CollageTest PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(CollageTest PROPERTIES LINKER_LANGUAGE CXX)

15
README.md Normal file
View File

@@ -0,0 +1,15 @@
## Collage
#### [![License: Unlicense](https://img.shields.io/badge/license-Unlicense-blue.svg)](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
```

View File

@@ -0,0 +1,2 @@
#pragma once
#include <Collage/types/model.h>

View File

@@ -0,0 +1,10 @@
#pragma once
#include <vector>
#include <Collage/types/bone.h>
struct KeyFrame {
unsigned int index;
Bone bone;
};
typedef std::vector<KeyFrame> Animation;

View File

@@ -1,6 +1,6 @@
#pragma once
#include <vector>
#include <J3ML/LinearAlgebra.h>
#include <J3ML/LinearAlgebra.hpp>
class Bone {
protected:
std::string name;
@@ -14,7 +14,7 @@ public:
const Matrix4x4& getMatrix();
void setMatrix(const Matrix4x4& m);
void appendChild(const Bone& bone);
uint getDepth(); //The "depth" refers to how far in the bone is on the bonemap. For ex, the fingers would be deeper than the elbow.
unsigned int getDepth(); //The "depth" refers to how far in the bone is on the bonemap. For ex, the fingers would be deeper than the elbow.
Bone* getParent();
Bone* getChildByName(const std::string& bName);
Bone* getChildByNameRecursive(const std::string& bName);

View File

@@ -0,0 +1,2 @@
#pragma once
#include <Collage/types/bone.h>

View File

@@ -2,10 +2,10 @@
#include <vector>
#include <sstream>
#include <fstream>
#include <J3ML/LinearAlgebra.h>
#include <J3ML/LinearAlgebra/Vector3.h>
#include<J3ML/Geometry.h>
#include <types/textureInfo.h>
#include <J3ML/LinearAlgebra.hpp>
#include <J3ML/LinearAlgebra/Vector3.hpp>
#include<J3ML/Geometry.hpp>
#include <Collage/types/textureInfo.h>
typedef Vector3 Vertex;
@@ -27,18 +27,16 @@ class SkeletalVertex : public Vertex {
};
class Model {
private:
void loadOBJ(const std::string& filename);
void load(const std::string& file);
protected:
void load(const std::string& file);
void loadOBJ(const std::string& filename);
std::vector<Vertex> vertices;
std::vector<uint> indices;
std::vector<unsigned int> indices;
std::vector<TextureInformation> textureInfo;
void mapFaces(const FaceIndices& facedata, const std::vector<Vector3>& positions, const std::vector<Vector2>& uvs);
public:
ModelType type;
const std::vector<Vertex>& getVertices();
const std::vector<uint>& getIndices();
const std::vector<unsigned int>& getIndices();
const std::vector<TextureInformation>& getTextureInformation();
Model() = default;
explicit Model(const std::string& file);
@@ -48,5 +46,5 @@ class SkeletalModel : public Model {
protected:
std::vector<SkeletalVertex> vertices;
public:
std::vector<SkeletalVertex>& getSkeletalertices();
std::vector<SkeletalVertex>& getSkeletalVertices();
};

View File

@@ -1,6 +1,6 @@
#pragma once
#include <vector>
#include <J3ML/LinearAlgebra.h>
#include <J3ML/LinearAlgebra.hpp>
struct TextureInformation {
std::string path;

View File

@@ -1,2 +0,0 @@
#pragma once
#include <types/model.h>

View File

@@ -1,10 +0,0 @@
#pragma once
#include <vector>
#include <types/bone.h>
struct KeyFrame {
uint index;
Bone bone;
};
typedef std::vector<KeyFrame> Animation;

View File

@@ -1,2 +0,0 @@
#pragma once
#include <types/bone.h>

View File

@@ -1,9 +1,8 @@
#include <iostream>
#include <types/model.h>
#include <Collage/types/model.h>
void Model::loadOBJ(const std::string& filename) {
std::ifstream file(filename);
//if (!file.is_open())
std::vector<Vector3> positions;
std::vector<Vector2> uvs;
TextureInformation tInfo = {};
@@ -35,7 +34,6 @@ void Model::loadOBJ(const std::string& filename) {
Vector2 textureCoordinate;
vertex = positions[vertexIndex[i]];
textureCoordinate = uvs[texCoordIndex[i]];
vertices.push_back(vertex);
tInfo.textureCoordinates.push_back(textureCoordinate);
indices.push_back(static_cast<unsigned int>(indices.size()));
@@ -44,19 +42,4 @@ void Model::loadOBJ(const std::string& filename) {
}
textureInfo.push_back(tInfo);
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});
}
};

View File

@@ -1,2 +1,2 @@
#include <types/animation.h>
#include <types/keyFrame.h>
#include <Collage/types/animation.h>
#include <Collage/types/keyFrame.h>

View File

@@ -1,4 +1,4 @@
#include <types/bone.h>
#include <Collage/types/bone.h>
const Matrix4x4& Bone::getMatrix() {
return matrix;
@@ -54,12 +54,12 @@ Bone* Bone::getParent() {
return parent;
}
uint Bone::getDepth() {
unsigned int Bone::getDepth() {
if (isRootBone())
return 0;
Bone* b = parent;
uint depth = 1;
unsigned int depth = 1;
while (b != nullptr && !b->isRootBone()) {
b = b->getParent();
depth++;

View File

@@ -1,4 +1,4 @@
#include <types/bone.h>
#include <Collage/types/bone.h>
struct BoneMap {
std::vector<Bone> bones;
};

View File

@@ -1,4 +1,4 @@
#include <types/model.h>
#include <Collage/types/model.h>
void Model::load(const std::string& file) {
if (file.ends_with(".obj"))
@@ -9,7 +9,7 @@ const std::vector<Vector3>& Model::getVertices() {
return vertices;
}
const std::vector<uint>& Model::getIndices() {
const std::vector<unsigned int>& Model::getIndices() {
return indices;
}
@@ -21,6 +21,6 @@ Model::Model(const std::string &file) {
load(file);
}
std::vector<SkeletalVertex> &SkeletalModel::getSkeletalertices() {
std::vector<SkeletalVertex>& SkeletalModel::getSkeletalVertices() {
return vertices;
}