<commit_before>#pragma once
#include <fstream>

struct SCamera
{
	float	tx,ty,tz;
	float	rx,ry,rz;

	SCamera() { memset(this, 0, sizeof(SCamera)); }
};

struct SLitPoint
{
	std::string	strName;
	float	x,y,z;
	float	r,g,b;
	float	radius;
	float	intensity;

	SLitPoint() { memset(this, 0, sizeof(SLitPoint)); }
};

struct SLitSpot : public SLitPoint
{
	float	toward;
	float	inner, outer;

	SLitSpot() { memset(this, 0, sizeof(SLitSpot)); }
};

struct SLitDire
{
	SLitDire() { memset(this, 0, sizeof(SLitDire)); }
};

struct SMaterial
{
	std::string	strName;
	std::string	strColorTexture;
	std::string	strNormalMap;
	std::string	strSpecularMap;
	float	ambientR, ambientG, ambientB;
	float	diffuseR, diffuseG, diffuseB;
	float	specularR, specularG, specularB;
	float	emmissiveR, emmissiveG, emmissiveB;
	float	metallic;
	float	roughness;
	float	shinness;
	bool	bTwoSided;

	SMaterial() { memset(this, 0, sizeof(SMaterial)); }
};

struct STexture
{

};

struct SGeometry
{
	unsigned int	uNumVertex;
	float*			pVertices;
	unsigned int	uNumFace;
	float*			pTriangles;
	unsigned int	uNumUV;
	float*			pUV;
	unsigned int	uNumNor;
	float*			pNormal;
	unsigned int	uNumTang;
	float*			pTangent;
	unsigned int	uNumVerClr;
	float*			pVerClr;

	SGeometry() { memset(this, 0, sizeof(SGeometry)); }
};

struct SSubMesh
{
	unsigned int	uGeomIdx;
	unsigned int	uMateIdx;
	unsigned int	uSubIndex;
	bool			bCollision;

	SSubMesh() { memset(this, 0, sizeof(SSubMesh)); }
};

struct SMesh
{
	std::string		strName;
	bool			bVisible;
	SSubMesh		subFirst;
	unsigned int	uNumSubOther;
	SSubMesh*		pSubOther;
	//
	float			tx, ty, tz, rx, ry, rz, sx, sy, sz;
	bool			bCastShadow;
	bool			bReceiveShadow;
	bool			bSimulate;
	float			mass;
	bool			bDamage;
	//
	unsigned int	uParent;	// 0xffff or -1 means parent is null
	unsigned int	uNumChild;
	unsigned int*	pChildren;
	// instance ?

	SMesh() { memset(this, 0, sizeof(SMesh)); }
};

struct SScene
{
	// shared data
	unsigned int	uNumMesh;
	SMesh*			pMesh;
	//unsigned int	uNumSub;
	//SSubMesh*		pSubMesh;
	unsigned int	uNumGeom;
	SGeometry*		pGeom;
	unsigned int	uNumMate;
	SMaterial*		pMate;
	unsigned int	uNumLitPoint;
	SLitPoint*		pLitPoint;
	unsigned int	uNumLitSpot;
	SLitSpot*		pLitSpot;
	unsigned int	uNumLitDire;
	SLitDire*		pLitDire;
	// scene data
	std::string		strName;
	SCamera			camera;
	SMesh*			pRoot;

	SScene() { memset(this, 0, sizeof(SScene)); }
};

struct SceneRW
{
private:
	template<class T>
	void write(const T* pData, const std::string& strFile, unsigned int uFrom = 0)
	{
		std::ofstream ofs(strFile, std::ios::binary);
		ofs.seekp(uFrom);
		ofs.write((char*)pData, sizeof(T));
		ofs.close();

		//ofs << pScene->mFlags << " , " << pScene->mNumMeshes << std::endl;
	}

	template<class T>
	void read(T& data, const std::string& strFile, unsigned int uFrom = 0)
	{
		std::ifstream ifs(strFile, std::ios::binary);
		ifs.seekg(uFrom);
		ifs.read((char*)&data, sizeof(T));
		ifs.close();

		//unsigned int uFlags, uNumMeshes;
		//char sz[2];<commit_msg>add SRoot<commit_after>#pragma once
#include <fstream>

struct SCamera
{
	float	tx,ty,tz;
	float	rx,ry,rz;

	SCamera() { memset(this, 0, sizeof(SCamera)); }
};

struct SLitPoint
{
	std::string	strName;
	float	x,y,z;
	float	r,g,b;
	float	radius;
	float	intensity;

	SLitPoint() { memset(this, 0, sizeof(SLitPoint)); }
};

struct SLitSpot : public SLitPoint
{
	float	toward;
	float	inner, outer;

	SLitSpot() { memset(this, 0, sizeof(SLitSpot)); }
};

struct SLitDire
{
	SLitDire() { memset(this, 0, sizeof(SLitDire)); }
};

struct SMaterial
{
	std::string	strName;
	std::string	strColorTexture;
	std::string	strNormalMap;
	std::string	strSpecularMap;
	float	ambientR, ambientG, ambientB;
	float	diffuseR, diffuseG, diffuseB;
	float	specularR, specularG, specularB;
	float	emmissiveR, emmissiveG, emmissiveB;
	float	metallic;
	float	roughness;
	float	shinness;
	bool	bTwoSided;

	SMaterial() { memset(this, 0, sizeof(SMaterial)); }
};

struct STexture
{

};

struct SGeometry
{
	unsigned int	uNumVertex;
	float*			pVertices;
	unsigned int	uNumFace;
	float*			pTriangles;
	unsigned int	uNumUV;
	float*			pUV;
	unsigned int	uNumNor;
	float*			pNormal;
	unsigned int	uNumTang;
	float*			pTangent;
	unsigned int	uNumVerClr;
	float*			pVerClr;

	SGeometry() { memset(this, 0, sizeof(SGeometry)); }
};

struct SSubMesh
{
	unsigned int	uGeomIdx;
	unsigned int	uMateIdx;
	unsigned int	uSubIndex;
	bool			bCollision;

	SSubMesh() { memset(this, 0, sizeof(SSubMesh)); }
};

struct SMesh
{
	std::string		strName;
	bool			bVisible;
	SSubMesh		subFirst;
	unsigned int	uNumSubOther;
	SSubMesh*		pSubOther;
	//
	float			trans[16];
	//float			tx, ty, tz, rx, ry, rz, sx, sy, sz;
	bool			bCastShadow;
	bool			bReceiveShadow;
	bool			bSimulate;
	float			mass;
	bool			bDamage;
	//
	unsigned int	uParent;	// 0xffff or -1 means parent is null
	unsigned int	uNumChild;
	unsigned int*	pChildren;
	// instance ?

	SMesh() { memset(this, 0, sizeof(SMesh)); }
};

struct SRoot
{
	unsigned int	uNumChild;
	unsigned int*	pChildren;
};

struct SBank
{
	// bank data
	SMesh*			pMesh;
	SGeometry*		pGeom;
	SMaterial*		pMate;
	SLitPoint*		pLitPoint;
	SLitSpot*		pLitSpot;
	SLitDire*		pLitDire;

	SBank() { memset(this, 0, sizeof(SBank)); }
};

struct SScene
{
	// bank data
	SBank*			pBank;
	unsigned int	uNumMesh;
	unsigned int	uNumGeom;
	unsigned int	uNumMate;
	unsigned int	uNumLitPoint;
	unsigned int	uNumLitSpot;
	unsigned int	uNumLitDire;
	// scene data
	std::string		strName;
	SCamera			camera;
	SRoot*			pRoot;

	SScene() { memset(this, 0, sizeof(SScene)); }
};

struct SceneRW
{
private:
	template<class T>
	void write(const T* pData, const std::string& strFile, unsigned int uFrom = 0)
	{
		std::ofstream ofs(strFile, std::ios::binary);
		ofs.seekp(uFrom);
		ofs.write((char*)pData, sizeof(T));
		ofs.close();

		//ofs << pScene->mFlags << " , " << pScene->mNumMeshes << std::endl;
	}

	template<class T>
	void read(T& data, const std::string& strFile, unsigned int uFrom = 0)
	{
		std::ifstream ifs(strFile, std::ios::binary);
		ifs.seekg(uFrom);
		ifs.read((char*)&data, sizeof(T));
		ifs.close();

		//unsigned int uFlags, uNumMeshes;
		//char sz[2];
{'fraction_non_alphanumeric': 0.1312224579729068, 'fraction_numerical': 0.005059572384527501, 'mean_word_length': 4.25557461406518, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5383221', 'n_tokens_mistral': 2731, 'n_tokens_neox': 2573, 'n_words': 613}