[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

09/10/2009 at 04:39AM PDT, ID: 24720954
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.4

WPF texture mapping problem

Asked by MareiAlgarni in WPF and Silverlight, .NET, Microsoft Visual C#.Net

Tags: WPF 3D texture mapping

Hello,

In my XAML code below I have six triangles of MeshGeometry3D which has been displayed OK. The problem is that when I want to map a DrawingBrush (EllipseGeometry) to my material and ImageBrush to back material they can just be mapped to the first two triangles only on each side as shown on pictures attached here. I want actually to map them so they will appear as one ellipse and one picture on each side (one picture stretched  on the six triangles as back material and one ellipse stretched on the six triangles as material).

Note that you may need to reference the well known 3D tools library from http://www.codeplex.com/3DTools and change picture path to run code correctly.

I apprciate all help.

Thanks,
Marei
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:tools="clr-namespace:_3DTools;assembly=3DTools"
    Title="Window1" Height="500" Width="700">
    <Grid Background="Black">
        <tools:TrackballDecorator Name="tb1">
            <Viewport3D Name="viewport3D1">
                <Viewport3D.Camera>
                    <PerspectiveCamera x:Name="camera1" 
                                       Position="3 3 3" 
                                       LookDirection="-3 -3 -3"
                                       UpDirection="0,1,0"
                                       FieldOfView="45"
                                       >
                    </PerspectiveCamera>
                </Viewport3D.Camera>
 
                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <DirectionalLight x:Name="directionalLight1" Direction="-3,-3,-3"/>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
 
                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <DirectionalLight x:Name="directionalLight2" Direction="3,3,3"/>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
 
                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <DirectionalLight x:Name="directionalLight3" Direction="-3,3,0"/>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <GeometryModel3D>
                            <GeometryModel3D.Geometry>
                                <MeshGeometry3D x:Name="geometryModel3D1"  
                                    Positions="-1,1,0 -1,-1,0 1,-1,0 1,1,0
                                                -1,-1,0 -1,-1,-2 1,-1,-2 1,-1,0
                                                 -1,-1,-2 -1,-3,-2 1,-3,-2 1,-1,-2"
                                    TriangleIndices="0 1 2 0 2 3             
                                                     4 5 6 4 6 7
                                                     8 9 10 8 10 11"                                               
                                    TextureCoordinates="0,0 0,1 1,1 1,0">
                                </MeshGeometry3D>
                            </GeometryModel3D.Geometry>
 
                            <GeometryModel3D.Material>
                                <DiffuseMaterial>
                                    <DiffuseMaterial.Brush>
                                        <DrawingBrush TileMode="Tile" Viewport="0 0 1 1" Stretch="Fill">
                                            <DrawingBrush.Drawing>
                                                <DrawingGroup>
                                                    <GeometryDrawing Brush="Green">
                                                        <GeometryDrawing.Geometry>
                                                            <RectangleGeometry Rect="0 0 10 10" />
                                                        </GeometryDrawing.Geometry>
                                                    </GeometryDrawing>
                                                    <GeometryDrawing Brush="Red">
                                                        <GeometryDrawing.Geometry>
                                                            <EllipseGeometry Center="5 5" RadiusX="2.5" RadiusY="2.5" />
                                                        </GeometryDrawing.Geometry>
                                                    </GeometryDrawing>
                                                </DrawingGroup>
                                            </DrawingBrush.Drawing>
                                        </DrawingBrush>
                                    </DiffuseMaterial.Brush>
                                </DiffuseMaterial>
                            </GeometryModel3D.Material>
 
 
                            <GeometryModel3D.BackMaterial>
                                <DiffuseMaterial>
                                    <!--<DiffuseMaterial.Brush>
                                        <SolidColorBrush Color="Red"/>
                                    </DiffuseMaterial.Brush>-->
                                    <DiffuseMaterial.Brush>
                                        <ImageBrush Stretch="Fill" ImageSource="C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\Sample Pictures\\Sunset.jpg" />
                                    </DiffuseMaterial.Brush>
 
                                </DiffuseMaterial>
                            </GeometryModel3D.BackMaterial>
 
                        </GeometryModel3D>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
 
            </Viewport3D>
        </tools:TrackballDecorator>
 
    </Grid>
 
</Window>
Attachments:
 
DrawingBrush for GeometryModel3D.Material (appears only on the first two triangles). I need it to stretched on the six triangles available.
DrawingBrush for GeometryModel3D.Material (appears only on the first two triangles). I need it to stretched on the six triangles available.
 
 
ImageBrush for GeometryModel3D.BackMaterial (appears only on the first two triangles). I need it to stretched on the six triangles available.
ImageBrush for GeometryModel3D.BackMaterial (appears only on the first two triangles). I need it to stretched on the six triangles available.
 
[+][-]09/10/09 10:26 PM, ID: 25306859

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: WPF and Silverlight, .NET, Microsoft Visual C#.Net
Tags: WPF 3D texture mapping
Sign Up Now!
Solution Provided By: MareiAlgarni
Participating Experts: 0
Solution Grade: A
 
 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625