xna フレームワーク c# でルービック キューブを解くゲームを開発しています。ボーンを回転させた後にボーンの位置を保存する方法を知りたいです。このメソッドを呼び出して、立方体の面側を構成するボーンを描画しています。
protected void DrawModel()
{
cube.CopyAbsoluteBoneTransformsTo(modelTransforms);
ModelMeshCollection cubes = cube.Meshes;
List<string> yellowFace = new List<string>();
for (int i = 0; i < cubes.Count; i++)
{
if (cubes.ElementAt(i).Name.ToString().Contains("F"))
{
yellowFace.Add(cubes.ElementAt(i).Name.ToString());
}
}
for (int j = 0; j < yellowFace.Count; j++)
{
foreach (BasicEffect eff in cubes[yellowFace.ElementAt(j)].Effects)
{
eff.View = View;
eff.Projection = Projection;
eff.EnableDefaultLighting();
degree = (float)degree;
if (xtan <= degree)
{
eff.World = Matrix.CreateFromAxisAngle(new Vector3(0, 0, 1), -xtan);
}
}
cubes[yellowFace.ElementAt(j)].Draw();
}
for (int i = 0; i < cubes.Count; i++)
{
if (cubes.ElementAt(i).Name.ToString().Contains("F"))
{
continue;
}
else
{
foreach (BasicEffect eff in cubes.ElementAt(i).Effects)
{
eff.View = View;
eff.World = Matrix.Identity;
eff.Projection = Projection;
eff.EnableDefaultLighting();
}
cubes.ElementAt(i).Draw();
}
}
}
ゲームを実行した後、回転は正常に実行されていますが、完了すると、ゲームは最初に見たようにボーンをリロードします。