Click here to Skip to main content
15,900,258 members
Home / Discussions / C#
   

C#

 
GeneralCodeDom Pin
danielk_16-Feb-08 23:54
danielk_16-Feb-08 23:54 
GeneralRe: CodeDom Pin
Gareth H17-Feb-08 0:37
Gareth H17-Feb-08 0:37 
GeneralRe: CodeDom Pin
Daniel Grunwald17-Feb-08 6:16
Daniel Grunwald17-Feb-08 6:16 
GeneralRe: CodeDom Pin
danielk_18-Feb-08 1:15
danielk_18-Feb-08 1:15 
GeneralSave & Retrieve Full HTML Pages (with images,styles,...) To Database. Pin
hdv21216-Feb-08 21:57
hdv21216-Feb-08 21:57 
GeneralRe: Save & Retrieve Full HTML Pages (with images,styles,...) To Database. Pin
Christian Graus16-Feb-08 23:09
protectorChristian Graus16-Feb-08 23:09 
GeneralRe: Save & Retrieve Full HTML Pages (with images,styles,...) To Database. Pin
hdv21217-Feb-08 1:05
hdv21217-Feb-08 1:05 
GeneralComplex rotation always has wrong answer. It looks bug is the visual Studio 8.0. Here is the code. Pin
AghaKhan16-Feb-08 20:55
AghaKhan16-Feb-08 20:55 
Press x-axis it (rotates around x-axis looks OK) // Button
Press y-axis it (rotates around y-axis looks OK) // button
Press z-axis it (rotates around z-axis looks OK) // Button
Press x-axis it (rotates around x-axis looks Bad) it is rotating on z-axis, Now you cannot predict how this is going to rotate it.
I checked the angles and I was unable to setValue in any sense. Please look the code.
Best regards
Agha Khan



<Window x:Class="Wpf3DTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="600" Width="600" WindowStartupLocation="CenterScreen">
<Window.Resources>
<MeshGeometry3D x:Key="UnitCube"
Positions="-0.5 0.5 0.5, 0.5 0.5 0.5,
-0.5 -0.5 0.5, 0.5 -0.5 0.5,
0.5 0.5 -0.5, -0.5 0.5 -0.5,
0.5 -0.5 -0.5, -0.5 -0.5 -0.5,
-0.5 0.5 -0.5, -0.5 0.5 0.5,
-0.5 -0.5 -0.5, -0.5 -0.5 0.5,
0.5 0.5 0.5, 0.5 0.5 -0.5,
0.5 -0.5 0.5, 0.5 -0.5 -0.5,
-0.5 0.5 -0.5, 0.5 0.5 -0.5,
-0.5 0.5 0.5, 0.5 0.5 0.5,
0.5 -0.5 -0.5, -0.5 -0.5 -0.5,
0.5 -0.5 0.5, -0.5 -0.5 0.5"
TriangleIndices=" 0 2 1, 1 2 3
4 6 5, 5 6 7,
8 10 9, 9 10 11,
12 14 13, 13 14 15
16 18 17, 17 18 19
20 22 21, 21 22 23"
TextureCoordinates=
"0.000 0, 0.167 0, 0.000 1, 0.167 1,
0.167 0, 0.333 0, 0.167 1, 0.333 1,
0.333 0, 0.500 0, 0.333 1, 0.500 1,
0.500 0, 0.667 0, 0.500 1, 0.667 1,
0.667 0, 0.833 0, 0.667 1, 0.833 1,
0.833 0, 1.000 0, 0.833 1, 1.000 1" />
<DiffuseMaterial x:Key="DMX0Y2Z0">
<DiffuseMaterial.Brush>
<VisualBrush RenderOptions.CachingHint="Cache">
<VisualBrush.Visual>
<UniformGrid Name="GNX0Y2Z0" Rows="1" Columns="6" Width="600" Height="100">
<Grid>
<!-- Front of the cube White -->
<Rectangle Fill="Gray" Stroke="Black"/>
<Rectangle Margin="5" RadiusX="5" RadiusY="5" Fill="Honeydew" />
</Grid>
<Grid>
<!-- Back hand side of the cube Yellow -->
<Rectangle Fill="Gray" Stroke="Black"/>
<Rectangle Margin="5" RadiusX="5" RadiusY="5" Fill="Yellow" />
</Grid>
<Grid>
<!-- Left hand side cube Blue -->
<Rectangle Fill="Gray" Stroke="Black"/>
<Rectangle Margin="5" RadiusX="5" RadiusY="5" Fill="Blue" />
</Grid>

<Grid>
<!-- Right side cube Green -->
<Rectangle Fill="Gray" Stroke="Black"/>
<Rectangle Margin="5" RadiusX="5" RadiusY="5" Fill="Chartreuse" />
</Grid>

<Grid>
<!-- Top side cube Red -->
<Rectangle Fill="Gray" Stroke="Black"/>
<Rectangle Margin="5" RadiusX="5" RadiusY="5" Fill="Red" />
</Grid>

<Grid>
<!-- Bottom side cube Cyan -->
<Rectangle Fill="Gray" Stroke="Black"/>
<Rectangle Margin="5" RadiusX="5" RadiusY="5" Fill="HotPink" />
</Grid>
</UniformGrid>
</VisualBrush.Visual>
</VisualBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>

<GeometryModel3D x:Key="ReCubeX0Y2Z0"
Geometry="{StaticResource UnitCube}"
Material="{StaticResource DMX0Y2Z0}">
<GeometryModel3D.Transform>
<TranslateTransform3D OffsetX="-1.0" OffsetY="1.0" OffsetZ="-1.0" />
</GeometryModel3D.Transform>
</GeometryModel3D>

</Window.Resources>
<Grid>

<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<DockPanel Grid.Column="0">
<StackPanel HorizontalAlignment="Stretch">
<StackPanel.Background>
<LinearGradientBrush>
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="DarkKhaki" Offset=".3"/>
<GradientStop Color="DarkKhaki" Offset=".7"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
</StackPanel.Background>
<Canvas >
<Button Name="simpleButton1" Canvas.Left="30" Canvas.Top="110" Click="RotateClickX">Rotate X</Button>
<Button Name="simpleButton2" Canvas.Left="30" Canvas.Top="150" Click="RotateClickY">Rotate Y</Button>
<Button Name="simpleButton3" Canvas.Left="30" Canvas.Top="190" Click="RotateClickZ">Rotate Z</Button>
</Canvas>
</StackPanel>
</DockPanel>
<DockPanel Grid.ColumnSpan="2">
<ScrollBar Name="horz" DockPanel.Dock="Bottom" Orientation="Horizontal"
Minimum="-180" Maximum="180"
LargeChange="10" SmallChange="1" />

<ScrollBar Name="vert" DockPanel.Dock="Right" Orientation="Vertical"
Minimum="-180" Maximum="180"
LargeChange="10" SmallChange="1" Width="17" />
<Viewport3D Name="viewport3d">

<ModelVisual3D x:Name="CUBEX0Y2Z0" Content="{StaticResource ReCubeX0Y2Z0}"/>

<!-- Light sources. -->
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup>
<AmbientLight Color="White" />
<DirectionalLight Color="White" Direction="2, -3 -1" />
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>

<!-- Camera. -->
<Viewport3D.Camera>
<PerspectiveCamera Position="-3 3 8"
LookDirection="3 -3 -8"
UpDirection="0 1 0"
FieldOfView="60">
<PerspectiveCamera.Transform>
<Transform3DGroup>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D Axis="1,0,0" Angle="{Binding ElementName=vert, Path=Value}" />
</RotateTransform3D.Rotation>
</RotateTransform3D>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D Axis="0,1,0" Angle="{Binding ElementName=horz, Path=Value}" />
</RotateTransform3D.Rotation>
</RotateTransform3D>
</Transform3DGroup>
</PerspectiveCamera.Transform>
</PerspectiveCamera>
</Viewport3D.Camera>
</Viewport3D>
</DockPanel>
</Grid>
</Window>








using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Windows.Media.Media3D;



namespace Wpf3DTest
{
public partial class Window1 : Window
{

public Window1()
{
InitializeComponent();

AxisAngleRotation3D RotationX = new AxisAngleRotation3D();

RotationX.Axis = new Vector3D(1, 0, 0);
RotationX.Angle = 0;
Transform3D t3d = new RotateTransform3D(RotationX);
Transform3DGroup transformGroup = new Transform3DGroup();
transformGroup.Children.Add(t3d); //X

AxisAngleRotation3D RotationY = new AxisAngleRotation3D();
RotationY.Angle = 0;

RotationY.Axis = new Vector3D(0, 1, 0);
t3d = new RotateTransform3D(RotationY);
transformGroup.Children.Add(t3d); //Y

AxisAngleRotation3D RotationZ = new AxisAngleRotation3D();
RotationZ.Angle = 0;

RotationZ.Axis = new Vector3D(0, 0, 1);
t3d = new RotateTransform3D(RotationZ);
transformGroup.Children.Add(t3d); //Z

int c = transformGroup.Children.Count;

CUBEX0Y2Z0.Transform = transformGroup;
}

private void RotateClickX(object sender, RoutedEventArgs e)
{

DoubleAnimation da = new DoubleAnimation();
da.By = 90;
da.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));

double CurrentValue = (double)((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[0]).Rotation.GetValue(AxisAngleRotation3D.AngleProperty);
if (CurrentValue >= 360.0)
{
CurrentValue %= 360;
((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[0]).Rotation.SetValue(AxisAngleRotation3D.AngleProperty, CurrentValue);
}


AxisAngleRotation3D Rotation = (AxisAngleRotation3D)((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[0]).Rotation;
if (Rotation.Angle >= 360)
Rotation.Angle = CurrentValue;
Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, da);

}

private void RotateClickY(object sender, RoutedEventArgs e)
{

DoubleAnimation da = new DoubleAnimation();

da.By = 90;
da.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));

double CurrentValue = (double)((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[1]).Rotation.GetValue(AxisAngleRotation3D.AngleProperty);
if (CurrentValue >= 360.0)
((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[1]).Rotation.SetValue(AxisAngleRotation3D.AngleProperty, 0.0);


AxisAngleRotation3D Rotation = (AxisAngleRotation3D)((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[1]).Rotation;
Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, da);
}

private void RotateClickZ(object sender, RoutedEventArgs e)
{

DoubleAnimation da = new DoubleAnimation();

da.By = 90;
da.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));

double CurrentValue = (double)((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[2]).Rotation.GetValue(AxisAngleRotation3D.AngleProperty);
if (CurrentValue >= 360.0)
((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[2]).Rotation.SetValue(AxisAngleRotation3D.AngleProperty, 0.0);


AxisAngleRotation3D Rotation = (AxisAngleRotation3D)((RotateTransform3D)((Transform3DGroup)CUBEX0Y2Z0.Transform).Children[2]).Rotation;
Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, da);
}

}
}
GeneralRe: Complex rotation always has wrong answer. It looks bug is the visual Studio 8.0. Here is the code. Pin
Christian Graus16-Feb-08 21:40
protectorChristian Graus16-Feb-08 21:40 
GeneralRe: Complex rotation always has wrong answer. It looks bug is the visual Studio 8.0. Here is the code. Pin
AghaKhan17-Feb-08 7:34
AghaKhan17-Feb-08 7:34 
QuestionHow to take snapshot of ListView control with icons and save it to file? Pin
Chesnokov Yuriy16-Feb-08 20:18
professionalChesnokov Yuriy16-Feb-08 20:18 
GeneralRe: How to take snapshot of ListView control with icons and save it to file? Pin
Christian Graus16-Feb-08 21:41
protectorChristian Graus16-Feb-08 21:41 
GeneralRe: How to take snapshot of ListView control with icons and save it to file? Pin
Ravenet16-Feb-08 21:53
Ravenet16-Feb-08 21:53 
GeneralRe: How to take snapshot of ListView control with icons and save it to file? Pin
Christian Graus16-Feb-08 23:16
protectorChristian Graus16-Feb-08 23:16 
GeneralRe: How to take snapshot of ListView control with icons and save it to file? Pin
Gareth H17-Feb-08 0:34
Gareth H17-Feb-08 0:34 
GeneralFind forms in solution of nother solution Pin
laleh.rajabi16-Feb-08 18:22
laleh.rajabi16-Feb-08 18:22 
GeneralRe: Find forms in solution of nother solution Pin
Christian Graus16-Feb-08 21:42
protectorChristian Graus16-Feb-08 21:42 
GeneralRe: Find forms in solution of nother solution Pin
laleh.rajabi17-Feb-08 2:26
laleh.rajabi17-Feb-08 2:26 
GeneralRe: Find forms in solution of nother solution Pin
Gareth H17-Feb-08 3:55
Gareth H17-Feb-08 3:55 
GeneralRe: Find forms in solution of nother solution Pin
darkelv16-Feb-08 22:23
darkelv16-Feb-08 22:23 
GeneralA code for getting a world time Pin
luisgrimaldo16-Feb-08 17:58
luisgrimaldo16-Feb-08 17:58 
GeneralRe: A code for getting a world time Pin
Christian Graus16-Feb-08 21:43
protectorChristian Graus16-Feb-08 21:43 
GeneralRe: A code for getting a world time Pin
Ravenet16-Feb-08 21:57
Ravenet16-Feb-08 21:57 
GeneralRe: A code for getting a world time Pin
Christian Graus16-Feb-08 23:17
protectorChristian Graus16-Feb-08 23:17 
GeneralRe: A code for getting a world time Pin
Ravenet17-Feb-08 1:15
Ravenet17-Feb-08 1:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.