Interactive content on cube

Topics: Developer Forum, User Forum
Feb 20, 2007 at 9:19 PM
Hello,

I tried to modify a Channel9Demo. I created a "part of cube" mesh (two sides).

<MeshGeometry3D x:Key="CubeMesh" Positions="-1,1,0 -1,-1,0 1,-1,0 1,1,0 -1,1,-2 -1,-1,-2 -1,-1,0 -1,1,0" TextureCoordinates="0,0 0,1 1,1 1,0 0,0 0,1 1,1 1,0" TriangleIndices="0 1 2 0 2 3 4 5 6 4 6 7"/>

I would like to make a simple demo applicaton. On the first side of "part of cube" is login form. If the login is successfull, cube will rotate to its second side, where are some other controls...

Is there any way, how to have different interactive content on every side of cube?

Thank you.

RostaB
Coordinator
Feb 20, 2007 at 9:45 PM
Yeah, you'll just want to make each face of the cube a different InteractiveVisual3D.
Feb 21, 2007 at 9:12 AM

kurtb wrote:
Yeah, you'll just want to make each face of the cube a different InteractiveVisual3D.


Yes. But how to do it? How to tell in XAML: This face has this visual, the other one has the other visual...?

I solved it with two transfomrs of PlaneMesh (the first one has Angle="{Binding Path=Value, ElementName=Slider5, Mode=Default}", the second one
<AxisAngleRotation3D.Angle>
<Binding ElementName="Slider5" Path="Value" Converter="{StaticResource arithConvertor}" ConverterParameter="-90"/>
</AxisAngleRotation3D.Angle>

<MeshGeometry3D x:Key="PlaneMesh" Positions="-1,1,1 -1,-1,1 1,-1,1 1,1,1" TextureCoordinates="0,0 0,1 1,1 1,0" TriangleIndices="0 1 2 0 2 3"/>

But with the CubeMesh it would be more "elegant", I think :-)


RostaB
Feb 27, 2007 at 1:50 PM
here's a cube that works for you. First ModelVisual3D contains one ModelVisual3D that contains all the 6 planes and a TranslateTransform3D so that you can position your cube. The MV3D inside the first MV3D contains 3 transforms that you can use to spin the cube around on it's palce

<ModelVisual3D x:Class="UniveRss.Controls.FeedModel3D"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tools3D="clr-namespace:_3DTools;assembly=3DTools"
xmlns:c="clr-namespace:UniveRss.Controls"
>


<ModelVisual3D.Transform>
<Transform3DGroup>
<TranslateTransform3D x:Name="translateTransform3D" />
</Transform3DGroup>
</ModelVisual3D.Transform>

<ModelVisual3D>

<!-- Side 1 -->
<tools3D:InteractiveVisual3D x:Name="Side1">
<tools3D:InteractiveVisual3D.Geometry>
<MeshGeometry3D
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"
TriangleIndices="0 1 2 2 3 0"
Normals="0,0,1 0,0,1 0,0,1 0,0,1"
TextureCoordinates="0,1 1,1 1,0 0,0" />
</tools3D:InteractiveVisual3D.Geometry>
<tools3D:InteractiveVisual3D.Visual>
<TextBox Text="Side1" />
</tools3D:InteractiveVisual3D.Visual>
</tools3D:InteractiveVisual3D>

<!-- Side 2 -->
<tools3D:InteractiveVisual3D x:Name="Side2">
<tools3D:InteractiveVisual3D.Geometry>
<MeshGeometry3D
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"
TriangleIndices="0 1 2 2 3 0"
Normals="1,0,0 1,0,0 1,0,0 1,0,0"
TextureCoordinates="1,1 1,0 0,0 0,1" />
</tools3D:InteractiveVisual3D.Geometry>
<tools3D:InteractiveVisual3D.Visual>
<TextBox Text="Side2" />
</tools3D:InteractiveVisual3D.Visual>
</tools3D:InteractiveVisual3D>

<!-- Side 3 -->
<tools3D:InteractiveVisual3D x:Name="Side3">
<tools3D:InteractiveVisual3D.Geometry>
<MeshGeometry3D
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"
TriangleIndices="0 1 2 2 3 0"
Normals="0,0,-1 0,0,-1 0,0,-1 0,0,-1"
TextureCoordinates="1,1 1,0 0,0 0,1" />
</tools3D:InteractiveVisual3D.Geometry>
<tools3D:InteractiveVisual3D.Visual>
<TextBox Text="Side3" />
</tools3D:InteractiveVisual3D.Visual>
</tools3D:InteractiveVisual3D>

<!-- Side 4 -->
<tools3D:InteractiveVisual3D x:Name="Side4">
<tools3D:InteractiveVisual3D.Geometry>
<MeshGeometry3D
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"
TriangleIndices="0 1 2 2 3 0"
Normals="-1,0,0 -1,0,0 -1,0,0 -1,0,0"
TextureCoordinates="0,0 0,1 1,1 1,0" />
</tools3D:InteractiveVisual3D.Geometry>
<tools3D:InteractiveVisual3D.Visual>
<TextBox Text="Side4" />
</tools3D:InteractiveVisual3D.Visual>
</tools3D:InteractiveVisual3D>

<!-- Side 5 -->
<tools3D:InteractiveVisual3D x:Name="Side5">
<tools3D:InteractiveVisual3D.Geometry>
<MeshGeometry3D
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"
TriangleIndices="0 1 2 2 3 0"
Normals="0,1,0 0,1,0 0,1,0 0,1,0"
TextureCoordinates="0,1 1,1 1,0 0,0" />
</tools3D:InteractiveVisual3D.Geometry>
<tools3D:InteractiveVisual3D.Visual>
<TextBox Text="Side5" />
</tools3D:InteractiveVisual3D.Visual>
</tools3D:InteractiveVisual3D>

<!-- Side 6 -->
<tools3D:InteractiveVisual3D x:Name="Side6">
<tools3D:InteractiveVisual3D.Geometry>
<MeshGeometry3D
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"
TriangleIndices="0 1 2 2 3 0"
Normals="0,-1,0 0,-1,0 0,-1,0 0,-1,0"
TextureCoordinates="1,0 0,0 0,1 1,1" />
</tools3D:InteractiveVisual3D.Geometry>
<tools3D:InteractiveVisual3D.Visual>
<TextBox Text="Side6" />
</tools3D:InteractiveVisual3D.Visual>
</tools3D:InteractiveVisual3D>

<ModelVisual3D.Transform>
<Transform3DGroup x:Name="ContentTransform">
<RotateTransform3D x:Name="RotateTransformY">
<RotateTransform3D.Rotation>
<AxisAngleRotation3D x:Name="AxisAngleRotationY" Axis="0,1,0" Angle="0" />
</RotateTransform3D.Rotation>
</RotateTransform3D>

<RotateTransform3D x:Name="RotateTransformX">
<RotateTransform3D.Rotation>
<AxisAngleRotation3D x:Name="AxisAngleRotationX" Axis="1,0,0" Angle="0" />
</RotateTransform3D.Rotation>
</RotateTransform3D>

<RotateTransform3D x:Name="RotateTransformZ">
<RotateTransform3D.Rotation>
<AxisAngleRotation3D x:Name="AxisAngleRotationZ" Axis="0,0,1" Angle="0" />
</RotateTransform3D.Rotation>
</RotateTransform3D>
</Transform3DGroup>
</ModelVisual3D.Transform>
</ModelVisual3D>

</ModelVisual3D>
Mar 6, 2007 at 4:43 PM
Hi,

I've tried using this code, with the trackball method but i keep getting a black cube
which i can rotate but i cannot see the textbox or anything else.

i have two questions:

1. how to make this work, see the writing or any other visual?
2. how do i use the transform? i would like to make the user rotate only on the Y axis

Thanks!
Mar 13, 2007 at 9:03 AM
You will need lights, something like the following (taken from the demo and augmented)

<ModelVisual3D>
<ModelVisual3D.Content>
<!-- Light pointing down the Z-axis-->
<DirectionalLight Color="#FFFFFFFF" Direction="0,0,-1"/>

<!-- Light pointing towards the negative side of the X-axis-->
<DirectionalLight Color="#FFFFFFFF" Direction="-1,0,0"/>

<!-- Light pointing towards the positive side of the X-axis-->
<DirectionalLight Color="#FFFFFFFF" Direction="1,0,0"/>
</ModelVisual3D.Content>
</ModelVisual3D>