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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
class GameStage : public Stage {
//CSVファイルそのA
CsvFile m_GameStageCsvA;
//CSVファイルそのB
CsvFile m_GameStageCsvB;
//ビューの作成
void CreateViewLight();
//ボックスの作成
void CreateFixedBox();
//CSVのAオブジェクトの作成
void CreateCsvAObjects();
//プレイヤーの作成
void CreatePlayer();
//敵の作成
void CreateEnemy();
public:
//構築と破棄
GameStage() :Stage() {}
virtual ~GameStage() {}
//初期化
virtual void OnCreate()override;
};
void GameStage::OnCreate() {
try {
wstring DataDir;
App::GetApp()->GetDataDirectory(DataDir);
////CSVファイルそのAの読み込み
m_GameStageCsvA.SetFileName(DataDir + L"GameStageA.csv");
m_GameStageCsvA.ReadCsv();
////CSVファイルそのBの読み込み
m_GameStageCsvB.SetFileName(DataDir + L"GameStageB.csv");
m_GameStageCsvB.ReadCsv();
//ビューとライトの作成
CreateViewLight();
//ボックスの作成
CreateFixedBox();
//CSVのAオブジェクトの作成
CreateCsvAObjects();
//プレーヤーの作成
CreatePlayer();
}
catch (...) {
throw;
}
}
void GameStage::CreateCsvAObjects() { //オブジェクトのグループを作成する auto group = CreateSharedObjectGroup(L"SeekGroup"); //CSVの全体の配列 //CSVからすべての行を抜き出す auto& LineVec = m_GameStageCsvA.GetCsvVec(); for (size_t i = 0; i < LineVec.size(); i++) { //トークン(カラム)の配列 vector<wstring> Tokens; //トークン(カラム)単位で文字列を抽出(L','をデリミタとして区分け) Util::WStrToTokenVector(Tokens, LineVec[i], L','); for (size_t j = 0; j < Tokens.size(); j++) { //XとZの位置を計算 float XPos = (float)((int)j - 19); float ZPos = (float)(19 - (int)i); if (Tokens[j] == L"1") { AddGameObject<SeekObject>(Vec3(XPos, 0.125f, ZPos)); } if (Tokens[j] == L"2") { AddGameObject<MoveBox>( Vec3(1.0f, 1.0f, 1.0f), Vec3(0.0f, 0.0f, 0.0f), Vec3(XPos, 0.5f, ZPos)); } } } }
//CSVの全体の配列
//CSVからすべての行を抜き出す
auto& LineVec = m_GameStageCsvA.GetCsvVec();
for (size_t i = 0; i < LineVec.size(); i++) {
//トークン(カラム)単位で文字列を抽出(L','をデリミタとして区分け)
Util::WStrToTokenVector(Tokens, LineVec[i], L',');
for (size_t j = 0; j < Tokens.size(); j++) {
//XとZの位置を計算 float XPos = (float)((int)j - 19); float ZPos = (float)(19 - (int)i);
if (Tokens[j] == L"1") { AddGameObject<SeekObject>(Vec3(XPos, 0.125f, ZPos)); }
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4 4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4 4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4 4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4 4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4 4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4 ...以下省略
Name,Scale,,,Rot,,,Pos,, TilingFixedBox,50,1,50,0,0,0,0,-0.5,0,SKY_TX TilingFixedBox,40,1,1,0,0,0,0,0.5,19.5,WALL_TX TilingFixedBox,40,1,1,0,0,0,0,0.5,-19.5,WALL_TX TilingFixedBox,40,1,1,0,XM_PIDIV2,0,19.5,0.5,0,WALL_TX TilingFixedBox,40,1,1,0,XM_PIDIV2,0,-19.5,0.5,0,WALL_TX
//ボックスの作成
void GameStage::CreateFixedBox() {
//CSVの行単位の配列
vector<wstring> LineVec;
//0番目のカラムがL"TilingFixedBox"である行を抜き出す
m_GameStageCsvB.GetSelect(LineVec, 0, L"TilingFixedBox");
for (auto& v : LineVec) {
//トークン(カラム)の配列
vector<wstring> Tokens;
//トークン(カラム)単位で文字列を抽出(L','をデリミタとして区分け)
Util::WStrToTokenVector(Tokens, v, L',');
//各トークン(カラム)をスケール、回転、位置に読み込む
Vec3 Scale(
(float)_wtof(Tokens[1].c_str()),
(float)_wtof(Tokens[2].c_str()),
(float)_wtof(Tokens[3].c_str())
);
Vec3 Rot;
//回転はXM_PIDIV2の文字列になっている場合がある
Rot.x = (Tokens[4] == L"XM_PIDIV2") ? XM_PIDIV2 : (float)_wtof(Tokens[4].c_str());
Rot.y = (Tokens[5] == L"XM_PIDIV2") ? XM_PIDIV2 : (float)_wtof(Tokens[5].c_str());
Rot.z = (Tokens[6] == L"XM_PIDIV2") ? XM_PIDIV2 : (float)_wtof(Tokens[6].c_str());
Vec3 Pos(
(float)_wtof(Tokens[7].c_str()),
(float)_wtof(Tokens[8].c_str()),
(float)_wtof(Tokens[9].c_str())
);
//各値がそろったのでオブジェクト作成
AddGameObject<TilingFixedBox>(Scale, Rot, Pos, 1.0f, 1.0f, Tokens[10]);
}
}
//CSVの行単位の配列
vector<wstring> LineVec;
//0番目のカラムがL"TilingFixedBox"である行を抜き出す
m_GameStageCsvB.GetSelect(LineVec, 0, L"TilingFixedBox");
TilingFixedBox,50,1,50,0,0,0,0,-0.5,0,SKY_TX TilingFixedBox,40,1,1,0,0,0,0,0.5,19.5,WALL_TX TilingFixedBox,40,1,1,0,0,0,0,0.5,-19.5,WALL_TX TilingFixedBox,40,1,1,0,XM_PIDIV2,0,19.5,0.5,0,WALL_TX TilingFixedBox,40,1,1,0,XM_PIDIV2,0,-19.5,0.5,0,WALL_TX
//トークン(カラム)の配列 vector<wstring> Tokens; //トークン(カラム)単位で文字列を抽出(L','をデリミタとして区分け) Util::WStrToTokenVector(Tokens, v, L','); //各トークン(カラム)をスケール、回転、位置に読み込む Vec3 Scale( (float)_wtof(Tokens[1].c_str()), (float)_wtof(Tokens[2].c_str()), (float)_wtof(Tokens[3].c_str()) ); Vec3 Rot; //回転はXM_PIDIV2の文字列になっている場合がある Rot.x = (Tokens[4] == L"XM_PIDIV2") ? XM_PIDIV2 : (float)_wtof(Tokens[4].c_str()); Rot.y = (Tokens[5] == L"XM_PIDIV2") ? XM_PIDIV2 : (float)_wtof(Tokens[5].c_str()); Rot.z = (Tokens[6] == L"XM_PIDIV2") ? XM_PIDIV2 : (float)_wtof(Tokens[6].c_str()); Vec3 Pos( (float)_wtof(Tokens[7].c_str()), (float)_wtof(Tokens[8].c_str()), (float)_wtof(Tokens[9].c_str()) ); //各値がそろったのでオブジェクト作成 AddGameObject<TilingFixedBox>(Scale, Rot, Pos, 1.0f, 1.0f, Tokens[10]);
void GetSelect(vector< wstring >& RetVec,bool (Func)(const wstring&));
void TilingFixedBox::OnCreate() {
auto PtrTrans = GetComponent<Transform>();
PtrTrans->SetScale(m_Scale);
PtrTrans->SetRotation(m_Rotation);
PtrTrans->SetPosition(m_Position);
auto Coll = AddComponent<CollisionObb>();
Coll->SetFixed(true);
vector<VertexPositionNormalTexture> vertices;
vector<uint16_t> indices;
MeshUtill::CreateCube(1.0f, vertices, indices);
float UCount = m_Scale.x / m_UPic;
float VCount = m_Scale.z / m_VPic;
for (size_t i = 0; i < vertices.size(); i++) {
if (vertices[i].textureCoordinate.x >= 1.0f) {
vertices[i].textureCoordinate.x = UCount;
}
if (vertices[i].textureCoordinate.y >= 1.0f) {
float FrontBetween = bsm::angleBetweenNormals(vertices[i].normal, Vec3(0, 1, 0));
float BackBetween = bsm::angleBetweenNormals(vertices[i].normal, Vec3(0, -1, 0));
if (FrontBetween < 0.01f || BackBetween < 0.01f) {
vertices[i].textureCoordinate.y = VCount;
}
}
}
//描画コンポーネントの追加
auto PtrDraw = AddComponent<BcPNTStaticDraw>();
//描画コンポーネントに形状(メッシュ)を設定
PtrDraw->CreateOriginalMesh(vertices, indices);
PtrDraw->SetOriginalMeshUse(true);
PtrDraw->SetFogEnabled(true);
//自分に影が映りこむようにする
PtrDraw->SetOwnShadowActive(true);
//描画コンポーネントテクスチャの設定
PtrDraw->SetTextureResource(m_Texname);
//タイリング設定
PtrDraw->SetSamplerState(SamplerState::LinearWrap);
}
vector<VertexPositionNormalTexture> vertices; vector<uint16_t> indices; MeshUtill::CreateCube(1.0f, vertices, indices); float UCount = m_Scale.x / m_UPic; float VCount = m_Scale.z / m_VPic; for (size_t i = 0; i < vertices.size(); i++) { if (vertices[i].textureCoordinate.x >= 1.0f) { vertices[i].textureCoordinate.x = UCount; } if (vertices[i].textureCoordinate.y >= 1.0f) { float FrontBetween = bsm::angleBetweenNormals(vertices[i].normal, Vec3(0, 1, 0)); float BackBetween = bsm::angleBetweenNormals(vertices[i].normal, Vec3(0, -1, 0)); if (FrontBetween < 0.01f || BackBetween < 0.01f) { vertices[i].textureCoordinate.y = VCount; } } }
//描画コンポーネントの追加
auto PtrDraw = AddComponent<BcPNTStaticDraw>();
//描画コンポーネントに形状(メッシュ)を設定
PtrDraw->CreateOriginalMesh(vertices, indices);
PtrDraw->SetOriginalMeshUse(true);
//タイリング設定 PtrDraw->SetSamplerState(SamplerState::LinearWrap);