3

我需要转换 Model3DGroup 两次(一次设置位置,一次设置旋转)。我试过这个:

var model = ModelImporter.Load(gameAssetPath);
model.Transform = new TranslateTransform3D(
        placedObject.SpawnCoordinates.X,
        placedObject.SpawnCoordinates.Y,
        placedObject.SpawnCoordinates.Z);
var modelRotation = new Model3DGroup();
modelRotation.Children.Add(model);
modelRotation.Transform = new RotateTransform3D(new AxisAngleRotation3D(), placedObject.SpawnCoordinates.Roll, placedObject.SpawnCoordinates.Pitch, placedObject.SpawnCoordinates.Yaw);

那是不行的。我在谷歌和 SO 上搜索过,似乎找不到任何东西。

4

1 回答 1

4

为此,您需要TransformGroup类。

该课程将结合您的转换。

var model = ModelImporter.Load(gameAssetPath);
var modelRotation = new Model3DGroup();
modelRotation.Children.Add(model);
var t1 = new TranslateTransform3D(
        placedObject.SpawnCoordinates.X,
        placedObject.SpawnCoordinates.Y,
        placedObject.SpawnCoordinates.Z);
var t2 = new RotateTransform3D(
         new AxisAngleRotation3D(), 
        placedObject.SpawnCoordinates.Roll, 
        placedObject.SpawnCoordinates.Pitch, 
        placedObject.SpawnCoordinates.Yaw);
var tg = new TransformGroup();
tg.Children.Add(t1);
tg.Children.Add(t2);
modelRotation.Transform = tg;
于 2013-02-17T18:56:24.747 回答