C# 在xna中保存旋转后的骨骼位置
我正在开发一个在xna框架c#中求解魔方的游戏。我想知道旋转骨骼后如何保存骨骼位置。我调用此方法来绘制构造立方体面侧的骨骼C# 在xna中保存旋转后的骨骼位置,c#,xna,rotation,C#,Xna,Rotation,我正在开发一个在xna框架c#中求解魔方的游戏。我想知道旋转骨骼后如何保存骨骼位置。我调用此方法来绘制构造立方体面侧的骨骼 protected void DrawModel() { cube.CopyAbsoluteBoneTransformsTo(modelTransforms); ModelMeshCollection cubes = cube.Meshes; List<string> yellowFace = new List<string>
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();
}
}
}
//this before the drawing loop
model.CopyAbsoluteBoneTransformsTo(modelTransforms);
//drawing loop ....
//basiceffect loop
......
//after basiceffect loop
Matrix rotationmatrix = Matrix.CreateRotationX(angle);
// X,Y Z are the axis , angle is the rotaion value
mesh.parentbone.Transform = rotationmatrix * mesh.parentbone.transform;
//end drawing loop
protected void DrawModel()
{
CopyAbsoluteBonetTransformsTo(modelTransforms);
ModelMeshCollection cubes=cube.mesh;
List yellowFace=新列表();
for(int i=0;i 如果(xtanHi everyone)要在旋转后保存骨骼位置,必须在矩阵变换中对其进行变换
//this before the drawing loop
model.CopyAbsoluteBoneTransformsTo(modelTransforms);
//drawing loop ....
//basiceffect loop
......
//after basiceffect loop
Matrix rotationmatrix = Matrix.CreateRotationX(angle);
// X,Y Z are the axis , angle is the rotaion value
mesh.parentbone.Transform = rotationmatrix * mesh.parentbone.transform;
//end drawing loop
我希望这对每个人都有帮助
多谢各位
//this before the drawing loop
model.CopyAbsoluteBoneTransformsTo(modelTransforms);
//drawing loop ....
//basiceffect loop
......
//after basiceffect loop
Matrix rotationmatrix = Matrix.CreateRotationX(angle);
// X,Y Z are the axis , angle is the rotaion value
mesh.parentbone.Transform = rotationmatrix * mesh.parentbone.transform;
//end drawing loop