Initial AMO file parser
This commit is contained in:
84
src/amo.cpp
Normal file
84
src/amo.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <Collage/types/model.h>
|
||||
|
||||
void Model::loadAMO(const std::string& filename) {
|
||||
std::cout << filename << std::endl;
|
||||
std::ifstream file(filename);
|
||||
std::vector<Vector3> positions;
|
||||
std::vector<Vector2> uvs;
|
||||
TextureInformation tInfo = {};
|
||||
std::string line;
|
||||
while (std::getline(file, line)) {
|
||||
std::istringstream stream(line);
|
||||
std::string prefix;
|
||||
stream >> prefix;
|
||||
|
||||
// Animated Object
|
||||
if (prefix == "ao") {
|
||||
std::string name;
|
||||
int statecnt;
|
||||
stream >> name >> statecnt;
|
||||
std::cout << "ao " << name << " " << statecnt << std::endl;
|
||||
// Vertices Count
|
||||
} else if (prefix == "v") {
|
||||
int vcnt;
|
||||
stream >> vcnt;
|
||||
std::cout << "v " << vcnt << std::endl;
|
||||
// Vertex Texture Count
|
||||
} else if (prefix == "vt") {
|
||||
int vtcnt;
|
||||
stream >> vtcnt;
|
||||
std::cout << "vt " << vtcnt << std::endl;
|
||||
// Vertex Normals Count
|
||||
} else if (prefix == "vn") {
|
||||
int vncnt;
|
||||
stream >> vncnt;
|
||||
std::cout << "vn " << vncnt << std::endl;
|
||||
// Vertex Joint Count
|
||||
} else if (prefix == "vj") {
|
||||
int vjcnt;
|
||||
stream >> vjcnt;
|
||||
std::cout << "vj " << vjcnt << std::endl;
|
||||
// Vertex Weights Count
|
||||
} else if (prefix == "vw") {
|
||||
int vwcnt;
|
||||
stream >> vwcnt;
|
||||
std::cout << "vw " << vwcnt << std::endl;
|
||||
// Faces Count
|
||||
} else if (prefix == "f") {
|
||||
int fcnt;
|
||||
stream >> fcnt;
|
||||
std::cout << "f " << fcnt << std::endl;
|
||||
// Joints Count
|
||||
} else if (prefix == "j") {
|
||||
int jcnt;
|
||||
stream >> jcnt;
|
||||
std::cout << "j " << jcnt << std::endl;
|
||||
// Animations Count
|
||||
} else if (prefix == "a") {
|
||||
int acnt;
|
||||
stream >> acnt;
|
||||
std::cout << "a " << acnt << std::endl;
|
||||
// Start Animation Definition
|
||||
} else if (prefix == "an") {
|
||||
std::string aname;
|
||||
int atimems; // Animation time in milliseconds
|
||||
int n_interps; // Number of interpolations between key frames
|
||||
stream >> aname >> atimems >> n_interps;
|
||||
std::cout << "an " << aname << " " << atimems << " " << n_interps << std::endl;
|
||||
// Animation Key Frame
|
||||
} else if (prefix == "k") {
|
||||
float kstart; // Timestamp of when key fram starts.
|
||||
int n_movbones; // Number of moving bones.
|
||||
stream >> kstart >> n_movbones;
|
||||
std::cout << "k " << kstart << " " << n_movbones << std::endl;
|
||||
// End
|
||||
} else if (prefix == "end") {
|
||||
std::cout << "End of AMO" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
Reference in New Issue
Block a user