Hello I am working on project that show 3D model and I use helix 3D toolkit so I have the xaml code here:
<h:HelixViewport3D Name="hlx" ZoomExtentsWhenLoaded="True" RotateAroundMouseDownPoint="False" ShowViewCube="False" Opacity="0.8" Grid.Column="4" Grid.ColumnSpan="2" Grid.Row="4" Grid.RowSpan="3">
<h:DefaultLights/>
</h:HelixViewport3D>
and the C# code here:
void C()
{
ModelVisual3D model = new ModelVisual3D();
model.Content = Display3d(@"D:\tests for projects\Em organic compounds\Em organic compounds\Car.3DS");
hlx.Children.Add(model);
}
private Model3D Display3d(string mdl)
{
Model3D device = null;
try
{
hlx.RotateGesture = new MouseGesture(MouseAction.LeftClick);
ModelImporter import = new ModelImporter();
device = import.Load(mdl);
}
catch (Exception e)
{
MessageBox.Show("Exception Error : " + e.StackTrace);
}
return device;
}
It's workin great. The problem is that I want to rotate the 3D model 360 degrees like a car showroom but I don't know what to do.
you can use RotateManipulator control which allows user to rotate the model in specific axis
void C()
{
ModelVisual3D model = new ModelVisual3D();
model.Content = Display3d(@"D:\tests for projects\Em organic compounds\Em organic compounds\Car.3DS");
RotateManipulator manipulator = new RotateManipulator()
{
//rotate on X axis
Axis = new Vector3D(1, 0, 0),
Diameter = 5 //
};
Binding b = new Binding()
{
ElementName = nameof(model),
Path = new PropertyPath("Transform")
};
BindingOperations.SetBinding(manipulator, RotateManipulator.TransformProperty, b);
BindingOperations.SetBinding(manipulator, RotateManipulator.TargetTransformProperty, b);
view1.Children.Add(manipulator);
view1.Children.Add(model);
}
private Model3D Display3d(string mdl)
{
Model3D device = null;
try
{
// view1.RotateGesture = new MouseGesture(MouseAction.LeftClick);
ModelImporter import = new ModelImporter();
device = import.Load(mdl);
}
catch (Exception e)
{
MessageBox.Show("Exception Error : " + e.StackTrace);
}
return device;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.