Click here to Skip to main content
15,887,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

XML
<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

1 solution

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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900