User avatar
stonstad
Topic Author
Posts: 241
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

CompositeTransform3D Behavior

06 Jan 2022, 21:59

Out of curiosity, why are elements in the top stack rotated differently compared to the elements in the bottom stack panel? (it is a cut and paste of the same XAML). Even if CompositeTrasnform3D coordinates are global, would the result look like this?

Image
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">

  <StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Top">
    <Grid Width="300" Height="200" Margin="20">
      <noesis:Element.Transform3D>
        <noesis:CompositeTransform3D RotationY="-5" CenterX="150" />
      </noesis:Element.Transform3D>      
      <Rectangle Fill="Gray"/>
      <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">A</TextBlock>
    </Grid>
 
    <Grid Width="300" Height="200" Margin="20">
      <noesis:Element.Transform3D>
        <noesis:CompositeTransform3D RotationY="5" CenterX="150" />
      </noesis:Element.Transform3D>      
      <Rectangle Fill="Gray"/>
      <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">B</TextBlock>
    </Grid>
  </StackPanel>
  
  <StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Bottom">
    <Grid Width="300" Height="200" Margin="20">
      <noesis:Element.Transform3D>
        <noesis:CompositeTransform3D RotationY="-5" CenterX="150" />
      </noesis:Element.Transform3D>      
      <Rectangle Fill="Gray"/>
      <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">A</TextBlock>
    </Grid>
 
    <Grid Width="300" Height="200" Margin="20">
      <noesis:Element.Transform3D>
        <noesis:CompositeTransform3D RotationY="5" CenterX="150" />
      </noesis:Element.Transform3D>      
      <Rectangle Fill="Gray"/>
      <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">B</TextBlock>
    </Grid>
  </StackPanel>

</Grid>
 
User avatar
stonstad
Topic Author
Posts: 241
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

Re: CompositeTrasnform3D Behavior

06 Jan 2022, 22:31

I was able to achieve the desired behavior through the following:
Matrix3D rotation = Matrix3D.Identity;
Transform3D = new MatrixTransform3D(rotation.RotateY(-5));
This is resolved for me now -- this seemed to be an easier approach. Not sure why the above behaves the way it does, however.
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: CompositeTrasnform3D Behavior

07 Jan 2022, 12:59

why are elements in the top stack rotated differently compared to the elements in the bottom stack panel?
It is the result of the camera perspective, it is the expected behavior. The CompositeTransform3D matrix is calculated as:
moveToCenter * scale * rotate * translate * moveFromCenter

Who is online

Users browsing this forum: Bing [Bot] and 21 guests