Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF 3D
Hello,
I wonder if it is possible to change one or more points of a 3D object after it has been rendered. I tried it using XAML and C#.
 
I want to influence one of the points using a slider. This is the XAML-code that explains how I wanted to achieve a manipulation of the Y-dimension of the first point:
 
<Grid>
 <Viewport3D>
  <Viewport3D.Camera>
  <PerspectiveCamera Position="0.5, 0.5, 4" LookDirection="0,0,-1"/>
  </Viewport3D.Camera>
  <Viewport3D.Children>
  <ModelVisual3D>
  <ModelVisual3D.Content>
   <DirectionalLight Color="White" Direction="0,0,-1" />
  </ModelVisual3D.Content>
  </ModelVisual3D>
  <ModelVisual3D>
  <ModelVisual3D.Content>
   <GeometryModel3D>
   <GeometryModel3D.Geometry>
   <MeshGeometry3D Positions="0, {Binding ElementName=PunktSlider, Path=Value} ,1 , 1,0,1 , 1,1,1 , 0,1,1
       0,0,0 , 1,0,0 , 1,1,0 , 0,1,0"
     TriangleIndices="0 1 2, 2 3 0,
        1 5 6, 6 2 1,
        5 4 7, 7 6 5,
        4 0 3, 3 7 4,
        2 6 7, 7 3 2,
        0 4 5, 5 1 0" />
   </GeometryModel3D.Geometry>
   <GeometryModel3D.Transform>
   <RotateTransform3D>
    <RotateTransform3D.Rotation>
    <AxisAngleRotation3D Axis="1,1,1" Angle="{Binding ElementName=RotationSlider, Path=Value}" />
    </RotateTransform3D.Rotation>
   </RotateTransform3D>
   </GeometryModel3D.Transform>
   <GeometryModel3D.Material>
   <DiffuseMaterial Brush="OrangeRed" />
   </GeometryModel3D.Material>
   </GeometryModel3D>
  </ModelVisual3D.Content>
  </ModelVisual3D>
  </Viewport3D.Children>
 </Viewport3D>
 <Slider x:Name="RotationSlider" Minimum="0" Maximum="360" Value="0"/>
 <Slider x:Name="PunktSlider" Minimum="0" Maximum="1" Value="0"/>
 </Grid>
 
Does anyone have an idea how to do this?
 
Thanks in advance for every idea...
Posted 17-Jun-11 5:26am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Why not? What is your object you want to change? MeshGeometry3D?
 
Just give this object a name in XAML and do the changes programmatically.
See http://msdn.microsoft.com/en-us/library/system.windows.media.media3d.meshgeometry3d.aspx[^].
This CodeProject article explains manipulating mesh: WPF 3D Primer[^].
 
Have fun!
 
—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 5,170
1 DamithSL 4,357
2 Maciej Los 3,750
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,851


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 17 Jun 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100