AB4D Forum

Full Version: Wireframe Model
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I current add my model to the viewport using code.

XAML is
Code:
<!--Landscape Model-->
<ModelVisual3D>
    <ModelVisual3D.Content>
        <Model3DGroup x:Name="LandScapeModelGroup">
            <AmbientLight Color="DarkGray"/>
        </Model3DGroup>
    </ModelVisual3D.Content>
</ModelVisual3D>

C#
Code:
// add model to landscape group
LandScapeModelGroup.Children.Add(mGeometry);

What is the best setup if I want to show a Wireframe version of the model?

I already tried this

XAML

Code:
<visuals:WireframeVisual3D WireframeType="WireframeWithOriginalSolidModel" >
    <GeometryModel3D x:Name="WireframeModel">
    </GeometryModel3D>
</visuals:WireframeVisual3D>

C#

Code:
WireframeModel = mGeometry;

But the above did not showing anything.

Please help ;)
The WireframeVisual3D does not automatically regenerate the wireframe when the model is changed. To regenerate wireframe you need to call the RecreateWireframeModel method.

If you set the WireframeModel after the WireframeVisual3D is loaded, then you need to call the RecreateWireframeModel method.
I must be missing something here.

XML

Code:
<visuals:WireframeVisual3D x:Name="WireframeVisual" WireframeType="WireframeWithOriginalSolidModel" >
    <GeometryModel3D x:Name="WireframeModel" />
</visuals:WireframeVisual3D>

C#

Code:
// create 3D model using mesh and material
mGeometry = new GeometryModel3D(Mesh, Material);

// set 3D model back material
mGeometry.BackMaterial = BackMaterial;

// add model to landscape group
//LandScapeModelGroup.Children.Add(mGeometry);

// create wire frame model using models mesh
WireframeModel = Ab3d.Models.WireframeFactory.CreateWireframe(Mesh, 1, Colors.Aquamarine, MainViewport);

// refresh wireframe visual
WireframeVisual.RecreateWireframeModel();

Still not displaying??

Can you give me XAML/Code example or correct mine please.

I'm very new to your API, will purchase, but need to get basics sorted first.

Thanks

Jason

Sorted!

Used the following :-

Code:
// create wire frame model using models mesh
LandScapeModelGroup.Children.Add(Ab3d.Models.WireframeFactory.CreateWireframe(Mesh, 1, Colors.Aquamarine, MainViewport));

Thanks

Jason
Now I see where was the problem:
You have changed the WireframeModel reference from the object defined in XAML to another object created in code (mGeometry). This did not change the WireframeModel defined in XAML - it still remained empty.

To fix your code you have two options:

1)
Set OriginalModel property on WireframeVisual3D to your new Model3d:

Code:
WireframeVisual.OriginalModel = mGeometry;

Note that the content of WireframeVisual3D that is defined in XAML is also set to OriginalModel property.

2)
Update the WireframeModel and call RecreateWireframeModel method:

Code:
WireframeModel.Geometry = mGeometry.Geometry;
WireframeModel.Material = mGeometry.Material;

WireframeVisual3D.RecreateWireframeModel();


It is also possible to use the Ab3d.Models.WireframeFactory.CreateWireframe method and add that directly to your scene.

Though I would recommend using the WireframeVisual3D because it gives you more options on how to show wireframe.
(05-19-2015, 03:47 PM)abenedik Wrote: [ -> ]Now I see where was the problem:
You have changed the WireframeModel reference from the object defined in XAML to another object created in code (mGeometry). This did not change the WireframeModel defined in XAML - it still remained empty.

To fix your code you have two options:

1)
Set OriginalModel property on WireframeVisual3D to your new Model3d:

Code:
WireframeVisual.OriginalModel = mGeometry;

Note that the content of WireframeVisual3D that is defined in XAML is also set to OriginalModel property.

2)
Update the WireframeModel and call RecreateWireframeModel method:

Code:
WireframeModel.Geometry = mGeometry.Geometry;
WireframeModel.Material = mGeometry.Material;

WireframeVisual3D.RecreateWireframeModel();


It is also possible to use the Ab3d.Models.WireframeFactory.CreateWireframe method and add that directly to your scene.

Though I would recommend using the WireframeVisual3D because it gives you more options on how to show wireframe.

I've used CreateWireframe and added it to scene, but like you say I don't have as much control over options so might change it to WireframeVisual instead.

Thanks for help!