我正在开发一个游戏来解决 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();
}
}
}
在我运行游戏后,旋转运行良好,但一旦完成,游戏会重新加载骨骼,因为它们看着开始。