WPF 3D Model Transformation

WPF 3D Model Transformation
2009-07-05T15:14:40+02:00
2009-07-05T16:40:31+02:00
2022-08-13T07:00:32+02:00
Leber
Sziasztok!

Írtam egy próba WPF alkalmazást, amiben egy 3D-s modelt, jelen esetben egy horgászbotot forgatok. A gond az, hogy nem tudom, hogyan lehetne átállítani a forgáspontot, mert most a model közepén van kb.

A kódom így néz ki:


<Window x:Class="_3Dproba.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Fishing Tournament Model Viewer - Leber Software" Height="300" Width="300"> <Grid> <Viewport3D Name="viewport"> <Viewport3D.Camera> <PerspectiveCamera x:Name="camera" Position="113.66,106.98,1.63 " LookDirection="-0.85,-0.48,-0.03 " UpDirection="0,1,0 " NearPlaneDistance="1" FarPlaneDistance="400" FieldOfView="40"> </PerspectiveCamera> </Viewport3D.Camera> <ModelVisual3D x:Name="Modellunk"> <ModelVisual3D.Transform> <Transform3DGroup x:Name="transformGroup2"> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D x:Name="rotY" Axis="0 1 0" Angle="0" /> </RotateTransform3D.Rotation> </RotateTransform3D> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D x:Name="rotX" Axis="1 0 0" Angle="0" /> </RotateTransform3D.Rotation> </RotateTransform3D> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D x:Name="rotZ" Axis="0 0 1" Angle="0" /> </RotateTransform3D.Rotation> </RotateTransform3D> </Transform3DGroup> </ModelVisual3D.Transform>

... Itt a model van ...
</ModelVisual3D> </Viewport3D> <Button Height="23" HorizontalAlignment="Right" Margin="0,43,46,0" Name="le" VerticalAlignment="Top" Width="57" Click="le_Click">Dont-Le</Button> <Button Height="23" HorizontalAlignment="Right" Margin="0,12,46,0" Name="fel" VerticalAlignment="Top" Width="57" Click="fel_Click">Dont-Fel</Button> <Button Height="23" HorizontalAlignment="Right" Margin="0,25,8,0" Name="jobb" VerticalAlignment="Top" Width="37" Click="jobb_Click">Jobb</Button> <Button Height="23" Margin="0,25,103,0" Name="bal" VerticalAlignment="Top" Click="bal_Click" HorizontalAlignment="Right" Width="35">Bal</Button> </Grid> </Window>

A gombok forráskódjai(A formalitás kedvéért):


private void jobb_Click(object sender, RoutedEventArgs e) { rotY.Angle = rotY.Angle + 1; Modellunk.Transform = transformGroup; } private void bal_Click(object sender, RoutedEventArgs e) { rotY.Angle = rotY.Angle - 1; Modellunk.Transform = transformGroup; } private void fel_Click(object sender, RoutedEventArgs e) { rotZ.Angle = rotZ.Angle + 1; Modellunk.Transform = transformGroup; } private void le_Click(object sender, RoutedEventArgs e) { rotZ.Angle = rotZ.Angle - 1; Modellunk.Transform = transformGroup; }

Nem tudom hol lehet megadni, hogy hol legyen a forgatási pont.
Mutasd a teljes hozzászólást!
Axis-angle rotations assume rotation about the origin if a value is not specified for the CenterX, CenterY, and CenterZ properties on RotateTransform3D.
Mutasd a teljes hozzászólást!

abcd