Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a wire-frame 3D cube

Tags:

wpf

xaml

3d

I have this code which draws a cube in WPF Viewport3D:

        <Viewport3D Name="viewport3D1">
            <Viewport3D.Camera>
                <PerspectiveCamera x:Name="camMain" Position="6 5 4" LookDirection="-6 -5 -4">
                </PerspectiveCamera>
            </Viewport3D.Camera>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <DirectionalLight x:Name="dirLightMain" Direction="-1,-1,-1">
                    </DirectionalLight>
                </ModelVisual3D.Content>
            </ModelVisual3D>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <GeometryModel3D>
                        <GeometryModel3D.Geometry>
                            <MeshGeometry3D x:Name="meshMain"
                                Positions="0 0 0  1 0 0  0 1 0  1 1 0  0 0 1  1 0 1  0 1 1  1 1 1"
                                TriangleIndices="2 3 1  2 1 0  7 1 3  7 5 1  6 5 7  6 4 5  6 2 0  2 0 4  2 7 3  2 6 7  0 1 5  0 5 4">
                            </MeshGeometry3D>
                        </GeometryModel3D.Geometry>
                        <GeometryModel3D.Material>
                            <DiffuseMaterial x:Name="matDiffuseMain">
                                <DiffuseMaterial.Brush>
                                    <SolidColorBrush Color="Red"/>
                                </DiffuseMaterial.Brush>
                            </DiffuseMaterial>
                        </GeometryModel3D.Material>
                    </GeometryModel3D>
                </ModelVisual3D.Content>
            </ModelVisual3D>
        </Viewport3D>

This gives the following result:

How to make render as a wire frame?

like image 434
finder_sl Avatar asked Jun 08 '12 08:06

finder_sl


People also ask

How do you make a 3D cube in Python?

Step 1: Import libraries. Step 2: In this step, we are selecting the 3D axis of the dimension X =5, Y=5, Z=5, and in np. ones() we are passing the dimensions of the cube. Step 3: In this step, we are selecting color opacity as alpha = 0.9 ( vary from 0.0 – 1.0 ).


1 Answers

Have a look at the LinesVisual3D class in the (free) Helix 3D Toolkit (https://github.com/helix-toolkit). This is a version of the 'screen space lines' that allow you to draw wireframes like your example.

I highly recommend the Helix 3D Toolkit if you are doing any WPF 3D work.

like image 196
Govert Avatar answered Nov 15 '22 20:11

Govert