TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
hakan aydogan
NA
2
32.9k
3D rotation problem on WPF
Jan 16 2011 5:24 PM
Hi everyone,
I have been trying to animate a 3D rotation for a viewport3d object
On one of its edges.
My animation rotates the object around its centre axis but not around the desired edge. I need to do this on either sides of the object, it will rotate on a specific edge. Below is my animation. Thanks for the help.
<
Window
x:Class
=
"Sepis.MainWindow"
xmlns
=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
=
"http://schemas.microsoft.com/winfx/2006/xaml"
Title
=
"MainWindow"
Height
=
"768"
MinWidth
=
"800"
Width
=
"1000"
mc:Ignorable
=
"d"
xmlns:d
=
"http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc
=
"http://schemas.openxmlformats.org/markup-compatibility/2006"
>
<
Window.Resources
>
</
Window.Resources
>
Name
=
"rectangle1"
Width
=
"100"
Height
=
"100"
Fill
=
"Red"
>
</
Rectangle
>
<
Viewport3D
Name
=
"BAckgroundWindow"
ClipToBound
<
Grid
Height
=
"Auto"
Width
=
"1400"
MinWidth
=
"1280"
Name
=
"MainGrid"
HorizontalAlignment
=
"Left"
Margin
=
"0,0,0,0"
VerticalAlignment
=
"Stretch"
Opacity
=
"1"
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"0*"
/>
<
ColumnDefinition
Width
=
"1210*"
/>
</
Grid.ColumnDefinitions
>
<
Button
Name
=
"btnOper"
>
</
Button
>
<
Rectangle
s
=
"True"
Margin
=
"353,0,747,180"
Grid.Column
=
"1"
Width
=
"300"
Height
=
"300"
HorizontalAlignment
=
"Center"
VerticalAlignment
=
"Bottom"
>
<!-- Defines the camera used to view the 3D object. -->
<
Viewport3D.Camera
>
<
PerspectiveCamera
UpDirection
=
"0,1,0"
Position
=
"0,0,2"
LookDirection
=
"0,0,-1"
FieldOfView
=
"33"
/>
</
Viewport3D.Camera
>
<!-- The ModelVisual3D children contain the 3D models -->
<
Viewport3D.Children
>
<!-- This ModelVisual3D defines the light cast in the scene. Without light, the 3D
object cannot be seen. Also, the direction of the lights affect shadowing. If desired,
you can create multiple lights with different colors that shine from different directions. --
>
<
ModelVisual3D
>
<
ModelVisual3D.Content
>
<
AmbientLight
Color
=
"#FFFFFF"
/>
</
ModelVisual3D.Content
>
</
ModelVisual3D
>
<
ModelVisual3D
>
<
ModelVisual3D.Content
>
<
GeometryModel3D
x:Name
=
"geometryMode3"
>
<!-- The geometry specifes the shape of the 3D plane. In this sample, a flat sheet is created. -->
<
GeometryModel3D.Geometry
>
<
MeshGeometry3D
TriangleIndices
=
"0,1,2 2,3,0 2,1,0 0,3,2"
Normals
=
"0,0,1 0,1,1 0,0,1 0,0,1"
TextureCoordinates
=
"0,1 1,1 1,0 0,0"
Positions
=
"-0.5,-0.5,0 0.5,-0.5,0 0.5,0.5,0 -0.5,0.5,0"
/>
</
GeometryModel3D.Geometry
>
<!-- The material specifies the material applied to the 3D object. In this sample a linear gradient
covers the surface of the 3D object.--
>
<
GeometryModel3D.Material
>
<
MaterialGroup
>
<
DiffuseMaterial
>
<
DiffuseMaterial.Brush
>
<
SolidColorBrush
Color
=
"Red"
/>
</
DiffuseMaterial.Brush
>
</
DiffuseMaterial
>
</
MaterialGroup
>
</
GeometryModel3D.Material
>
<!-- Apply a transform to the object. In this sample, a rotation transform is applied, rendering the
3D object rotated. --
>
<
GeometryModel3D.Transform
>
<
Transform3DGroup
>
<
RotateTransform3D
>
<
RotateTransform3D.Rotation
>
<
AxisAngleRotation3D
Axis
=
"1,0,0"
Angle
=
"-85"
x:Name
=
"rotation3"
/>
</
RotateTransform3D.Rotation
>
</
RotateTransform3D
>
<
ScaleTransform3D
ScaleX
=
"1"
ScaleY
=
"1"
ScaleZ
=
"3"
x:Name
=
"scale3"
/>
</
Transform3DGroup
>
</
GeometryModel3D.Transform
>
</
GeometryModel3D
>
</
ModelVisual3D.Content
>
</
ModelVisual3D
>
</
Viewport3D.Children
>
</
Viewport3D
>
<
Button
Content
=
"Button"
Grid.Column
=
"1"
Height
=
"48"
HorizontalAlignment
=
"Left"
Margin
=
"80,97,0,0"
Name
=
"button1"
VerticalAlignment
=
"Top"
Width
=
"101"
/>
</
Grid
>
<
Window.Triggers
>
<
EventTrigger
RoutedEvent
=
"Button.Click"
SourceName
=
"button1"
>
<
BeginStoryboard
>
<
Storyboard
>
<!--Fourth Rotate the SecondaryComponents Viewport 3D>-->
<
DoubleAnimation
RepeatBehavior
=
"0:0:0.5"
Storyboard.TargetName
=
"rotation3"
Storyboard.TargetProperty
=
"(AxisAngleRotation3D.Angle)"
From
=
"-85"
To
=
"0"
Duration
=
"0:0:0.5"
/>
</
Storyboard
>
</
BeginStoryboard
>
</
EventTrigger
>
</
Window.Triggers
>
</
Window
>
Reply
Answers (
0
)
What is the Difference between XML and XAML
XML- XPath - Whats wrong with my query?