error adding Assimp64.dll reference
#11
The first sample in the samples project (SceneEditor) shows how to create simple box and sphere objects. How to move them around and also how to select a few positions and move individual positions around.

To get a better understanding of the WPF 3D objects I also recommend checking some of the web pages from the links page: https://www.ab4d.com/Links.aspx
Andrej Benedik
#12
I understand how create a sphere or a box, but is not my question.

I have a STL file with many meshes inside and i have to manipulate (rotate, move, change material) them, not create a new mesh.
I don't find any examples on existing mesh manipulation

Is it possible?

I can't attach my stl file because it's too big... (7000kb)
#13
There is no such sample yet. But you can get some pieces from multiple samples.

First you need to read the stl in code so you will get better access to the hierarchy of objects - using Model3DGroup (see link that I posted last time to get known with the WPF 3D objects).

Then show the 3D model (create a ModelVisual3D object, add your Model3DGroup to its Content and then add ModelVisual3D to Viewport3D.Children).

Because user can select any individual part of the 3D object, it is not good to use EventManager3D. Instead subscribe to MouseDown (or LeftMouseDown) and MouseUp events on Viewport3D (or event better on parent Border - see samples where usually Viewport3D is a child of a Border). In MouseDown handler use standard WPF hit testing:

var hitTestResult = VisualTreeHelper.HitTest(MainViewport, mousePosition) as RayMeshGeometry3DHitTestResult;

(if you want to skip some hit results, you can also use the HitTest method that takes hitTestCallback). Search the samples for ".HitTest" to get some sample code.

In the hitTestResult check which GeomeryModel3D is hit. 

Now you can decide what to do: 
- there are many options on how to select this part (change material, show WireBoxVisual3D, ... - see samples for options).
- if you want to move this part around, see ModelMover samples in the Utilities section. 

To correctly position selection box or ModelMover, you will need to get the correct transformation of the selected object - in case when the selected object is deep in the objects hierarchy, you can get the total transformation with using Ab3d.Utilities.TransformationsHelper.GetModelTotalTransform method.

This should be your basic plan.
Andrej Benedik
#14
I tried...
the problem is that I have an STL file with inside a cube and a sphere.

I read STL file and I add it to a viewport here is the code:

                Dim readmodel3d As New Model3DGroup

                Dim assimpWpfImporter As New AssimpWpfImporter
                readmodel3d.Children.Add(assimpWpfImporter.ReadModel3D(mfile))
                Dim modelarray = New ModelVisual3D
                modelarray.Content = readmodel3d
                myview.Children.Add(modelarray)

I added an handler but when i click on the sphere and apply a trasformation the transformation is applied on shere and on cube.

So i can hint the single object.

Where I,m wrong?
#15
(11-14-2019, 10:56 PM)abenedik Wrote: There is no such sample yet. But you can get some pieces from multiple samples.

First you need to read the stl in code so you will get better access to the hierarchy of objects - using Model3DGroup (see link that I posted last time to get known with the WPF 3D objects).

Then show the 3D model (create a ModelVisual3D object, add your Model3DGroup to its Content and then add ModelVisual3D to Viewport3D.Children).

Because user can select any individual part of the 3D object, it is not good to use EventManager3D. Instead subscribe to MouseDown (or LeftMouseDown) and MouseUp events on Viewport3D (or event better on parent Border - see samples where usually Viewport3D is a child of a Border). In MouseDown handler use standard WPF hit testing:

var hitTestResult = VisualTreeHelper.HitTest(MainViewport, mousePosition) as RayMeshGeometry3DHitTestResult;

(if you want to skip some hit results, you can also use the HitTest method that takes hitTestCallback). Search the samples for ".HitTest" to get some sample code.

In the hitTestResult check which GeomeryModel3D is hit. 

Now you can decide what to do: 
- there are many options on how to select this part (change material, show WireBoxVisual3D, ... - see samples for options).
- if you want to move this part around, see ModelMover samples in the Utilities section. 

To correctly position selection box or ModelMover, you will need to get the correct transformation of the selected object - in case when the selected object is deep in the objects hierarchy, you can get the total transformation with using Ab3d.Utilities.TransformationsHelper.GetModelTotalTransform method.

This should be your basic plan.

I tried...
the problem is that I have an STL file with inside a cube and a sphere.

I read STL file and I add it to a viewport here is the code:

                Dim readmodel3d As New Model3DGroup

                Dim assimpWpfImporter As New AssimpWpfImporter
                readmodel3d.Children.Add(assimpWpfImporter.ReadModel3D(mfile))
                Dim modelarray = New ModelVisual3D
                modelarray.Content = readmodel3d
                myview.Children.Add(modelarray)

I added an handler but when i click on the sphere and apply a trasformation the transformation is applied on shere and on cube.

So i can hint the single object.

Where I,m wrong?
#16
Your 3D objects are probably organized in a hierarchical way - when you apply a transformation to a parent object, it will also transform all the child objects.

To get an overview of how your 3D objects are organized, I would recommend you to put a breakpoint after a line when you read the 3D object from file. Then start your application and when breakpoint is hit, open the Visual Studio Immediate window and then start the following:

readmodel3d.DumpHierarchy()

This will show you the hierarchy of the objects defined in the file.


Btw. why do you create the readmodel3d as Model3DGroup? 
You could just use: 
Code:
Dim readModel3D = assimpWpfImporter.ReadModel3D(mfile)
modelarray.Content = readModel3D
Andrej Benedik
#17
(12-04-2019, 12:14 PM)abenedik Wrote: Your 3D objects are probably organized in a hierarchical way - when you apply a transformation to a parent object, it will also transform all the child objects.

To get an overview of how your 3D objects are organized, I would recommend you to put a breakpoint after a line when you read the 3D object from file. Then start your application and when breakpoint is hit, open the Visual Studio Immediate window and then start the following:

readmodel3d.DumpHierarchy()

This will show you the hierarchy of the objects defined in the file.


Btw. why do you create the readmodel3d as Model3DGroup? 
You could just use: 
Code:
Dim readModel3D = assimpWpfImporter.ReadModel3D(mfile)
modelarray.Content = readModel3D

I'tried, but the immediate window says 'DumpHierarchy() is not a member of Model3d' !!
HELP!
#18
DumpHierarchy is defined as an extension method for Model3D (in Ab3d namespace).
So to use it, the code that is executing should have "using Ab3d" or and other namespace under Ab3d defined.

You can also use the longer way to get the dump string (in c#):
string infoText = Ab3d.Utilities.Dumper.GetObjectHierarchyString(model3D);
System.Diagnostics.Debug.WriteLine(infoText);
Andrej Benedik
#19
(12-04-2019, 04:15 PM)abenedik Wrote: DumpHierarchy is defined as an extension method for Model3D (in Ab3d namespace).
So to use it, the code that is executing should have "using Ab3d" or and other namespace under Ab3d defined.

You can also use the longer way to get the dump string (in c#):
string infoText = Ab3d.Utilities.Dumper.GetObjectHierarchyString(model3D);
System.Diagnostics.Debug.WriteLine(infoText);

Ok I've done. This is the writeline:
GeometryModel3D ("__STL_BINARY_")   Material: color: #FFC0C0C0 |  Geometry: Positions: 144; TriangleIndices: 144 (48 triangles); Normals: 144; TextureCoordinates: 0  |  Center: 7.6 -3.6 -5.4  |  Size: 30.3 x 13.3 x 19.8

but i don't see any Hierarchy!
#20
(12-04-2019, 04:15 PM)abenedik Wrote: DumpHierarchy is defined as an extension method for Model3D (in Ab3d namespace).
So to use it, the code that is executing should have "using Ab3d" or and other namespace under Ab3d defined.

You can also use the longer way to get the dump string (in c#):
string infoText = Ab3d.Utilities.Dumper.GetObjectHierarchyString(model3D);
System.Diagnostics.Debug.WriteLine(infoText);

abenedik!

Ok I've done. This is the writeline:
GeometryModel3D ("__STL_BINARY_")   Material: color: #FFC0C0C0 |  Geometry: Positions: 144; TriangleIndices: 144 (48 triangles); Normals: 144; TextureCoordinates: 0  |  Center: 7.6 -3.6 -5.4  |  Size: 30.3 x 13.3 x 19.8

but i don't see any Hierarchy!
  


Forum Jump:


Users browsing this thread:
1 Guest(s)