help in 2D controls on 3D cube

Topics: User Forum
May 13, 2007 at 10:16 PM
i need help in mixing interactive 2D controls in 3D cube.
i watched alot of samples about that but i didn't understand it
because i'm very new in WPF.
i need way to do that using ZAM3D or blend.

i trayed to write thatcode but it didn't work well
the output cube has a just a mask on one of it's sides

that is my code:

<Window

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

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

xmlns:local="clr-namespace:_3DTools;assembly=3DTools"

x:Class="cubezame.Window1"

x:Name="Window"

Title="Window1"

Width="640" Height="480" Background="{x:Null}" AllowsTransparency="True" WindowStyle="None">

<Grid Width="400" Height="300">

<local:TrackballDecorator>

<local:Interactive3DDecorator Debug="true">

<Viewport3D xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/expression/interactivedesigner/2006" xmlns:c="http://schemas.openxmlformats.org/markup-compatibility/2006" c:Ignorable="d" x:Name="ZAM3DViewport3D" ClipToBounds="true" Width="400" Height="300">

<Viewport3D.Resources>

<ResourceDictionary>

<Grid Width="200" Height="50" x:Key="grid">

<Grid.ColumnDefinitions>

<ColumnDefinition Width="*" />

<ColumnDefinition Width="Auto" />

<ColumnDefinition Width="*" />

</Grid.ColumnDefinitions>

<Grid.RowDefinitions>

<RowDefinition Height="Auto" />

<RowDefinition Height="*" />

</Grid.RowDefinitions>

<TextBox Text="2" />

<TextBlock Text="+" Grid.Column="1" HorizontalAlignment="Center"/>

<TextBox Text="2" Grid.Column="2" />

<Button Content="=" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center"

Padding="5,2"/>

<TextBlock Grid.Row="1" Grid.Column="2"

VerticalAlignment="Center" TextAlignment="Center" />

</Grid>


<MaterialGroup x:Key="ER__DefaultMaterialMR1" >

<DiffuseMaterial>

<DiffuseMaterial.Brush>

<SolidColorBrush Color="#7F7F92" Opacity="1.000000"/>

</DiffuseMaterial.Brush>

</DiffuseMaterial>

<SpecularMaterial SpecularPower="64">

<SpecularMaterial.Brush>

<SolidColorBrush Color="#DBDBDB" Opacity="1.000000"/>

</SpecularMaterial.Brush>

</SpecularMaterial>

</MaterialGroup>

<Transform3DGroup x:Key="SceneTR8" >

<TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0"/>

<ScaleTransform3D ScaleX="1" ScaleY="1" ScaleZ="1"/>

<RotateTransform3D>

<RotateTransform3D.Rotation>

<AxisAngleRotation3D Angle="0" Axis="0 1 0"/>

</RotateTransform3D.Rotation>

</RotateTransform3D>

<TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0"/>

</Transform3DGroup>

<Transform3DGroup x:Key="Box01OR10TR9" >

<TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0"/>

<ScaleTransform3D ScaleX="0.700115" ScaleY="0.700115" ScaleZ="0.700115"/>

<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D Angle="1.136688352" Axis="0 0 1"/>
</RotateTransform3D.Rotation>
</RotateTransform3D>
<TranslateTransform3D OffsetX="0.0246282" OffsetY="0.143237" OffsetZ="-0.0163579"/>
</Transform3DGroup>
<MeshGeometry3D x:Key="Box01OR10GR11"
TriangleIndices="0,1,2 2,3,0 "
Normals="0,0,1 0,0,1 0,0,1 0,0,1 "
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 "
/>
<MeshGeometry3D x:Key="Box01OR10GR12"
TriangleIndices="0,1,2 2,3,0 "
Normals="0,0,-1 0,0,-1 0,0,-1 0,0,-1 "
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 "
/>
<MeshGeometry3D x:Key="Box01OR10GR13"
TriangleIndices="0,1,2 2,3,0 "
Normals="-1,0,0 -1,0,0 -1,0,0 -1,0,0 "
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 "
/>
<MeshGeometry3D x:Key="Box01OR10GR14"
TriangleIndices="0,1,2 2,3,0 "
Normals="1,0,0 1,0,0 1,0,0 1,0,0 "
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 "
/>
<MeshGeometry3D x:Key="Box01OR10GR15"
TriangleIndices="0,1,2 2,3,0 "
Normals="0,1,0 0,1,0 0,1,0 0,1,0 "
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 "
/>
<MeshGeometry3D x:Key="Box01OR10GR16"
TriangleIndices="0,1,2 2,3,0 "
Normals="0,-1,0 0,-1,0 0,-1,0 0,-1,0 "
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 "
/>
<Storyboard Duration="Forever" FillBehavior="HoldEnd" BeginTime="0:0:0" x:Key="OnLoaded" dtoryboardName="OnLoaded">
<Rotation3DAnimationUsingKeyFrames RepeatBehavior="Forever" BeginTime="0:0:0" Duration="0:0:3.75" Storyboard.TargetName="Box01OR10" Storyboard.TargetProperty="(Model3DGroup.Transform).(Transform3DGroup.Children)2.(RotateTransform3D.Rotation)">
<LinearRotation3DKeyFrame KeyTime="0:0:0">
<LinearRotation3DKeyFrame.Value>
<AxisAngleRotation3D Angle="1.13668835163116" Axis="0 0 1"/>
</LinearRotation3DKeyFrame.Value>
</LinearRotation3DKeyFrame>
<LinearRotation3DKeyFrame KeyTime="0:0:0.875">
<LinearRotation3DKeyFrame.Value>
<AxisAngleRotation3D Angle="45.01360849406304" Axis="-0.009916471462460458 -0.9996642021279469 0.02394047989555782"/>
</LinearRotation3DKeyFrame.Value>
</LinearRotation3DKeyFrame>
<LinearRotation3DKeyFrame KeyTime="0:0:1.83333">
<LinearRotation3DKeyFrame.Value>
<AxisAngleRotation3D Angle="1.136688351631159" Axis="-1.748834620593388e-016 1.019515932724052e-014 1"/>
</LinearRotation3DKeyFrame.Value>
</LinearRotation3DKeyFrame>
<LinearRotation3DKeyFrame KeyTime="0:0:2.79167">
<LinearRotation3DKeyFrame.Value>
<AxisAngleRotation3D Angle="45.01360849406314" Axis="0.009916471462460443 0.9996642021279469 0.02394047989555776"/>
</LinearRotation3DKeyFrame.Value>
</LinearRotation3DKeyFrame>
<LinearRotation3DKeyFrame KeyTime="0:0:3.75">
<LinearRotation3DKeyFrame.Value>
<AxisAngleRotation3D Angle="1.13668835163116" Axis="-2.623251930890082e-016 -1.019925815838253e-014 1"/>
</LinearRotation3DKeyFrame.Value>
</LinearRotation3DKeyFrame>
</Rotation3DAnimationUsingKeyFrames>
</Storyboard>
</ResourceDictionary>
</Viewport3D.Resources>
<Viewport3D.Triggers>
<EventTrigger RoutedEvent="Viewport3D.Loaded">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource OnLoaded}" />
</EventTrigger.Actions>
</EventTrigger>
</Viewport3D.Triggers>
<Viewport3D.Camera>
<PerspectiveCamera x:Name="PerspectiveOR7" FarPlaneDistance="10" LookDirection="1.702,-0.206,-1.663" UpDirection="-0.233,0.946,0.228" NearPlaneDistance="1" Position="-1.675,0.315,1.663" FieldOfView="39.5978" />
</Viewport3D.Camera>
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup x:Name="Scene" Transform="{DynamicResource SceneTR8}">
<!-- Scene (XAML Path = ) -->
<AmbientLight Color="#333333" />
<DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
<DirectionalLight Color="#FFFFFF" Direction="0.612372,-0.5,-0.612372" />
<Model3DGroup x:Name="Box01OR10" Transform="{DynamicResource Box01OR10TR9}">
<!-- Box01 (XAML Path = (Viewport3D.Children)0.(ModelVisual3D.Content).(Model3DGroup.Children)3) -->
<GeometryModel3D x:Name="right" Geometry="{DynamicResource Box01OR10GR11}" Material="{DynamicResource ER__DefaultMaterialMR1}" BackMaterial="{DynamicResource ER__DefaultMaterialMR1}"/>
<GeometryModel3D x:Name="Box01OR10GR12" Geometry="{DynamicResource Box01OR10GR12}" Material="{DynamicResource ER__DefaultMaterialMR1}" BackMaterial="{DynamicResource ER__DefaultMaterialMR1}"/>
<GeometryModel3D x:Name="Box01OR10GR13" Geometry="{DynamicResource Box01OR10GR13}" Material="{DynamicResource ER__DefaultMaterialMR1}" BackMaterial="{DynamicResource ER__DefaultMaterialMR1}"/>
<GeometryModel3D x:Name="Box01OR10GR14" Geometry="{DynamicResource Box01OR10GR14}" Material="{DynamicResource ER__DefaultMaterialMR1}" BackMaterial="{DynamicResource ER__DefaultMaterialMR1}"/>
<GeometryModel3D x:Name="Box01OR10GR15" Geometry="{DynamicResource Box01OR10GR15}" Material="{DynamicResource ER__DefaultMaterialMR1}" BackMaterial="{DynamicResource ER__DefaultMaterialMR1}"/>
<GeometryModel3D x:Name="Box01OR10GR16" Geometry="{DynamicResource Box01OR10GR16}" Material="{DynamicResource ER__DefaultMaterialMR1}" BackMaterial="{DynamicResourceER__DefaultMaterialMR1}"/>
</Model3DGroup>
</Model3DGroup>
</ModelVisual3D.Content>
<local:InteractiveVisual3D Geometry="{DynamicResource Box01OR10GR11}" Visual="{DynamicResource grid}">
<local:InteractiveVisual3D.Transform>
<Transform3DGroup>
<TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0"/>
<ScaleTransform3D ScaleX="1" ScaleY="1" ScaleZ="1"/>
<RotateTransform3D d:EulerAngles="0,0,0"/>
<TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0"/>
<TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0"/>
</Transform3DGroup>
</local:InteractiveVisual3D.Transform>
</local:InteractiveVisual3D>
</ModelVisual3D>
</Viewport3D>
</local:Interactive3DDecorator>
</local:TrackballDecorator>
</Grid>
</Window>

Sep 30, 2007 at 8:58 PM
hmm..

Im not clear what you are trying to actually do.

download 3.5 and then try to use blend.

should be fairly simple at the point.

Cider doesnt support local:

the tags are pretty easy to implement AIUI,

HTH

si.