Question Wpf different images on a 3d cube!

konhee93

New member
Joined
Jun 14, 2011
Messages
1
Programming Experience
Beginner
Hello, I am a student working on a school project.
I have created a 3D shape that moves when I click the cube, and I am trying to insert a different photo in each side of the cube.
Can anyone give me a hand? Thank you!

Here is my XAML

<Window x:Class="Window1"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"


xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"


Title="Rotating Cube" Background="White" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="300" d:DesignWidth="300" SizeToContent="WidthAndHeight" FontFamily="Tekton Pro">


<Viewport3D>


<!-- The camera describes the point of view from which we view the 3D scene -->


<Viewport3D.Camera>


<PerspectiveCamera LookDirection="0,0,-1" UpDirection="0,1,0" Position="0,0,8" FieldOfView="45" />


</Viewport3D.Camera>


<!--This ModelUIElement3D is an interactive 3D object . The MouseDown event engages a rotation animation -->


<ModelUIElement3D x:Name="uiElement3D" MouseDown="uiElement3D_MouseDown">


<ModelUIElement3D.Model>


<GeometryModel3D>


<GeometryModel3D.Geometry>


<MeshGeometry3D
TriangleIndices="0 1 2 0 2 3 4 5 6 4 6 7 8 9 10 8 10 11 12


13 14 12 14 15 16 17 18 16 18 19 20 21 22 20 22 23
"

TextureCoordinates="0,1 0,0 1,0 1,1 1,1 0,1 0,-0 1,0 1,1


0,1 0,-0 1,0 1,0 1,1 0,1 0,-0 0,0 1,-0 1,1 0,1 1,-0


1,1 0,1 0,0"

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 1,1,-1 1,1,1 1,-1,1 1,-1,-1 1,-1,-1 1,-1,1 -1,-1,1 -1,-1,-1


-1,-1,-1 -1,-1,1 -1,1,1 -1,1,-1 1,1,1 1,1,-1 -1,1,-1 -1,1,1
"


Normals="0,0,1 0,0,1 0,0,1 0,0,1 "






/>


</GeometryModel3D.Geometry>




<GeometryModel3D.Material>


<DiffuseMaterial>


<DiffuseMaterial.Brush>


<ImageBrush
ImageSource="http://postfiles11.naver.net/20110614_74/silver_eagle_1308031626835BCBUW_JPEG/galaxy_s2.jpg?type=w3"
/>


</DiffuseMaterial.Brush>


</DiffuseMaterial>


</GeometryModel3D.Material>




<GeometryModel3D.BackMaterial>


<DiffuseMaterial>


<DiffuseMaterial.Brush>


<SolidColorBrush Color="Red"/>


</DiffuseMaterial.Brush>


</DiffuseMaterial>


</GeometryModel3D.BackMaterial>


</GeometryModel3D>


</ModelUIElement3D.Model>


</ModelUIElement3D>


<!-- In general, we need lighting in our 3D space, otherwise the scene will be black.-->


<ModelVisual3D x:Name="Lighting">


<ModelVisual3D.Content>


<Model3DGroup x:Name="Scene">


<AmbientLight Color="White" />


</Model3DGroup>


</ModelVisual3D.Content>


</ModelVisual3D>


</Viewport3D>


</Window>



This is the xaml.vb



Imports System.Windows.Media.Media3D


Imports System.Windows.Media.Animation


Class Window1


Private Sub uiElement3D_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)


Dim angleAnimation As DoubleAnimation = New DoubleAnimation


angleAnimation.From = 0


angleAnimation.To = 90


angleAnimation.Duration = TimeSpan.FromSeconds(1)


Dim rotation As AxisAngleRotation3D = New AxisAngleRotation3D


rotation.Axis = New Vector3D(0, 1, 0)


uiElement3D.Transform = New RotateTransform3D(rotation)


rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, angleAnimation)


End Sub


End Class




These are the photos i want to insert

http://postfiles6.naver.net/20110614_37/silver_eagle_13080316243689pfqF_JPEG/galaxy_s2_2.jpg?type=w3

http://postfiles2.naver.net/2011061...080316252084H9Y6_JPEG/galaxy_s2_3.jpg?type=w3

http://postfiles13.naver.net/201106...08031626062SbqCr_JPEG/galaxy_s2_4.jpg?type=w3

http://postfiles11.naver.net/20110614_74/silver_eagle_1308031626835BCBUW_JPEG/galaxy_s2.jpg?type=w3
 
Back
Top