Answered by:
WPF 3D How to make a cube on each side of which is another picture?

-
text/sourcefragment 7/5/2013 5:17:02 PM sg6336 0
Good day!
Please help!
I did the program that created a cube that can be rotated on the axes. I pulled on this cube texture in the form of a cat. For some reason, the texture appeared on 4 of the 6 sides of the cube (you can tell why? Although, it is not the main issue in this thread).
The main question is: I need that would be on each side of the cube has been different pictures. How to do it?
So, a full listing of the 'cube rotation about the axes'
<Window x:Class="Вращение_кубика_вокруг_осей.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Вращение кубика вокруг осей" Height="350" Width="525" WindowStartupLocation="CenterScreen"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"></ColumnDefinition> <ColumnDefinition Width="3*"></ColumnDefinition> </Grid.ColumnDefinitions> <GridSplitter Grid.Column="0" VerticalAlignment="Stretch" Width="5"></GridSplitter> <Label Grid.Column="0" Content="xyz" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5,0,0,0" FontSize="14"/> <Label Grid.Column="0" Content="z" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="18,25,0,0" FontSize="14"/> <Label Grid.Column="0" Content="y" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="12,50,0,0" FontSize="14"/> <Label Grid.Column="0" Content="x" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="8,75,0,0" FontSize="14"/> <Slider Grid.Column="0" Height="25" VerticalAlignment="Top" Minimum="-360" Maximum="360" Value="{Binding ElementName=rotate_xyz, Path= Angle}" Margin="40,3,0,0" /> <Slider Grid.Column="0" Height="25" VerticalAlignment="Top" Minimum="-360" Maximum="360" Value="{Binding ElementName=rotate_z, Path= Angle}" Margin="40,28,0,0" /> <Slider Grid.Column="0" Height="25" VerticalAlignment="Top" Minimum="-360" Maximum="360" Value="{Binding ElementName=rotate_y, Path= Angle}" Margin="40,53,0,0" /> <Slider Grid.Column="0" Height="25" VerticalAlignment="Top" Minimum="-360" Maximum="360" Value="{Binding ElementName=rotate_x, Path= Angle}" Margin="40,78,0,0" /> <Viewport3D Grid.Column="1" Margin="0,0,0,0"> <Viewport3D.Camera> <!--Установка камеры - перспективная проекция--> <PerspectiveCamera Position="0, 0, 8" LookDirection="0, 0, -3.5" /> <!--FieldOfView="120"--> </Viewport3D.Camera> <Viewport3D.Children> <ModelVisual3D> <ModelVisual3D.Content> <!--Установка освещения - прямой свет--> <DirectionalLight Color="White" Direction="-2, -2.5, -2" /> <!--<PointLight Color="White" Position="2,2,2" />--> <!--<SpotLight Color="White" Position="1,3,2" Direction="1,-1,-1" InnerConeAngle="90" OuterConeAngle="90" Range="4" />--> </ModelVisual3D.Content> </ModelVisual3D> <ModelVisual3D> <ModelVisual3D.Content> <GeometryModel3D> <!--Определяем геометрию объекта--> <GeometryModel3D.Geometry> <MeshGeometry3D Positions="-1,-1,-1 1,-1,-1 -1,1,-1 1,1,-1 -1,-1, 1 1,-1, 1 -1,1, 1 1,1,1" TriangleIndices="0,2,1 1,2,3 4,6,0 2,0,6 0,1,4 1,5,4 1,7,5 1,3,7 4,5,6 7,6,5 2,6,3 3,6,7" TextureCoordinates="1,1 0,1 1,0 0,0 0,1 1,1 0,0 1,0"/> </GeometryModel3D.Geometry> <!--Установка материала - красный цвет--> <GeometryModel3D.Material> <!--<DiffuseMaterial Brush="LightCoral" AmbientColor="Red" />--> <MaterialGroup> <DiffuseMaterial Brush="LightBlue" /> <DiffuseMaterial> <DiffuseMaterial.Brush> <ImageBrush ImageSource="cat.jpg" /> </DiffuseMaterial.Brush> <!--<DiffuseMaterial.Brush> <ImageBrush ImageSource="http://social.msdn.microsoft.com/Forums/getfile/305344" /> </DiffuseMaterial.Brush>--> </DiffuseMaterial> <EmissiveMaterial Brush="DarkBlue" /> </MaterialGroup> </GeometryModel3D.Material> </GeometryModel3D> </ModelVisual3D.Content> <ModelVisual3D.Transform> <Transform3DGroup> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D x:Name="rotate_xyz" Axis="1 1 1" /> </RotateTransform3D.Rotation> </RotateTransform3D> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D x:Name="rotate_x" Axis="1 0 0" /> </RotateTransform3D.Rotation> </RotateTransform3D> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D x:Name="rotate_y" Axis="0 1 0" /> </RotateTransform3D.Rotation> </RotateTransform3D> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D x:Name="rotate_z" Axis="0 0 1" /> </RotateTransform3D.Rotation> </RotateTransform3D> </Transform3DGroup> </ModelVisual3D.Transform> </ModelVisual3D> </Viewport3D.Children> </Viewport3D> </Grid> </Window>
sorry for my english
I saw this: WPF 3D CUBE design
Is it possible to not draw 6 sides? And draw a 1 cube. And on each side of the cube to place another picture?
P.S. my original question: WPF 3D Как сделать кубик на каждой стороне которого будет свой рисунок?
- Edited by sg6336 Friday, July 05, 2013 5:22 PM
Question
Answers
-
text/html 7/5/2013 5:43:51 PM Reed Copsey, Jr 1
"Is it possible to not draw 6 sides? And draw a 1 cube. And on each side of the cube to place another picture?"
Yes, but you have to do it differently. Instead of making one "cube" geometry, you need to make 6 "faces" of the cube as 6 separate geometries, each with their own texture (image).
- Marked as answer by sg6336 Saturday, July 06, 2013 7:02 AM
-
text/html 7/5/2013 10:52:14 PM Reed Copsey, Jr 1
Put them into a single Model3DGroup: http://msdn.microsoft.com/en-us/library/system.windows.media.media3d.model3dgroup.aspx
This will make them behave like a single 3d Model.
- Marked as answer by sg6336 Saturday, July 06, 2013 7:01 AM
-
text/html 7/6/2013 7:01:07 AM sg6336 0thank you
I think that this example describes what I need Анимация и трансформация 3d модели в WPF
This example contains all your recommendations (Model3DGroup and RotateTransform3D).- Marked as answer by sg6336 Saturday, July 06, 2013 7:02 AM
All replies
-
text/html 7/5/2013 5:43:51 PM Reed Copsey, Jr 1
"Is it possible to not draw 6 sides? And draw a 1 cube. And on each side of the cube to place another picture?"
Yes, but you have to do it differently. Instead of making one "cube" geometry, you need to make 6 "faces" of the cube as 6 separate geometries, each with their own texture (image).
- Marked as answer by sg6336 Saturday, July 06, 2013 7:02 AM
-
text/sourcefragment 7/5/2013 8:59:49 PM sg6336 0
How to control the rotation of the 6 sides at the same time?
<Viewport2DVisual3D> <!-- Give the plane a slight rotation --> <Viewport2DVisual3D.Transform> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D x:Name="side1" Angle="40" Axis="0, 1, 0" /> </RotateTransform3D.Rotation> </RotateTransform3D> </Viewport2DVisual3D.Transform> <!-- The Geometry, Material, and Visual for the Viewport2DVisual3D --> <Viewport2DVisual3D.Geometry> <MeshGeometry3D Positions="-2,1,0 -2,-2,0 1,-2,0 1,1,0" TextureCoordinates="0,0 0,1 1,1 1,0" TriangleIndices="0 1 2 0 2 3"/> </Viewport2DVisual3D.Geometry> <Viewport2DVisual3D.Material> <DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" Brush="White"/> </Viewport2DVisual3D.Material> <!--<Button>Hello, 3D</Button>--> <Label>Hello, 3D</Label> </Viewport2DVisual3D>
<Slider Grid.Column="0" Height="25" VerticalAlignment="Top" Minimum="-360" Maximum="360" Value="{Binding ElementName=side1, Path= Angle}" Margin="40,103,0,0" />
For example, I have 6 of these parties.How are they all rotate at the same time?
-
text/html 7/5/2013 10:52:14 PM Reed Copsey, Jr 1
Put them into a single Model3DGroup: http://msdn.microsoft.com/en-us/library/system.windows.media.media3d.model3dgroup.aspx
This will make them behave like a single 3d Model.
- Marked as answer by sg6336 Saturday, July 06, 2013 7:01 AM
-
text/html 7/6/2013 7:01:07 AM sg6336 0thank you
I think that this example describes what I need Анимация и трансформация 3d модели в WPF
This example contains all your recommendations (Model3DGroup and RotateTransform3D).- Marked as answer by sg6336 Saturday, July 06, 2013 7:02 AM