rewrite
This commit is contained in:
parent
7b59aab6db
commit
057e7b94d7
10 changed files with 425 additions and 2323 deletions
63
implementations/main.cpp
Normal file
63
implementations/main.cpp
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
Crafter®.Asset
|
||||
Copyright (C) 2026 Catcrafts®
|
||||
catcrafts.net
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License version 3.0 as published by the Free Software Foundation;
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
import Crafter.Asset;
|
||||
import Crafter.Math;
|
||||
import std;
|
||||
using namespace Crafter;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc != 3) {
|
||||
std::cout << "Usage: crafter-asset <input_file> <output_file>\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
fs::path inputPath = argv[1];
|
||||
fs::path outputPath = argv[2];
|
||||
|
||||
if (!fs::exists(inputPath)) {
|
||||
std::cerr << "Error: Input file does not exist.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string extension = inputPath.extension().string();
|
||||
|
||||
try {
|
||||
if (extension == ".obj") {
|
||||
// Load OBJ as MeshAsset with normal/tangent/uv data
|
||||
auto mesh = MeshAsset<VertexNormalTangentUVPacked>::LoadOBJ(inputPath);
|
||||
mesh.Save(outputPath);
|
||||
}
|
||||
else if (extension == ".png") {
|
||||
// Load PNG as TextureAsset
|
||||
auto texture = TextureAsset<Vector<std::uint8_t, 4, 0>>::LoadPNG(inputPath);
|
||||
texture.Save(outputPath);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Unsupported file type: " << extension << "\n";
|
||||
return 1;
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "Error: " << e.what() << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue