#include "pch.h"
#include "ModelNode.h"

#include "Mesh.h"
#include "Model.h"


ModelNode::ModelNode(aiNode* node, Model* model) {
	this->name = std::string(node->mName.C_Str());
	auto metadata = node->mMetaData;

	unsigned* node_meshes = node->mMeshes;
	unsigned node_mesh_cnt = node->mNumMeshes;

	// auto translation = node->mTransformation.a1;

	float* a = &node->mTransformation.a1;
	float* b = &this->transform_matrix[0][0];


	// this->transform_matrix = Matrix<float>({});

	for (int i = 0; i < 16; i++) {
		*(b++) = *(a++);
	}

	for (int i = 0; i < node_mesh_cnt; i++) {
		// aiMesh* ai_mesh = model->ai_scene->mMeshes[node_meshes[i]];
		auto* mesh = model->meshes[node_meshes[i]];
		// auto* mesh_outline = model->mesh_outlines[node_meshes[i]];

		// Mesh* mesh = new Mesh(ai_mesh, false);
		this->meshes.push_back(mesh);
		// this->mesh_outlines.push_back(mesh_outline);
	}
}
