This is the discussion forum for Helix Toolkit.
For bugs and new features, use the issue tracker located at GitHub.
Also try the chat room!
0

Programmatic model transform not working

Michael Powell 11 years ago updated 11 years ago 1
I know that Xaml transforms are working, quite well as a matter of fact. I can ScaleTransform3D about axes to achieve simple mirroring, and it works very well. Such as this, mirrors left/right about the Y plane.
<h:RectangleVisual3D>
    <h:RectangleVisual3D.Transform>
        <ScaleTransform3D ScaleY="-1" />
    </h:RectangleVisual3D.Transform>
</h:RectangleVisual3D>
However, I am trying something similar via code behind, and it doesn't seem to be working quite as well; okay, not at all:
return new RectangleVisual3D
{
    Origin = new Point3D {X = 10d},
    LengthDirection = new Vector3D {X = 1d},
    Normal = new Vector3D {Z = 1d},
    Transform = new Transform3DGroup
    {
        Children = {new ScaleTransform3D(new Vector3D {X = -1d}),}
    }
};
My first guess is that perhaps there is some Xaml / Binding magic that is going on behind the scenes. First and a half guess, possibly something about initializing the Transform.Children is causing some problems.

I have also tried initializing RectangleVisual3D.Transform to a new ScaleTransform3D, at first; but then thought that perhaps it needed to be a Transform3DGroup instead, as per some of the example code I've seen listed.

Any other insights would be welcome, however.

Thank you...
0

Extent of OBJ importer (how finished is it) ?

Anonymous 11 years ago updated by anonymous 6 years ago 2
This discussion was imported from CodePlex

Rogad wrote at 2014-02-20 15:52:

Hi Objo !

I'm still playing with the OBJ importer.

Could you please tell me what parts of the material file are working at the momemt ?

For example, what parts of this example actually get used :

newmtl 3_SkinForearm
d 1
Ns 1
Ni 0
Ka 0.858824 0.92549 0.937255
Kd 0.901961 1 0.996078
Ks 0.866667 0.929412 0.945098
Km 0.00252632
map_Kd Maps/RMDelphL.jpg
map_Bump Maps/RMDelphLBp.jpg

So is the bump map used, is Ns and Ni used and so on ?

I don't know what all these do, but I do get some strange results some times and I have to remove things from the material file.

It would be good to remove things that are not implemented yet, I just need to know what they are.

Many thanks :)

objo wrote at 2014-02-20 20:36:

The materials in the 3D model of WPF are quite limited, bump maps are not supported and I have not found a way to include the ambient components easily.
You can see the implementation in the MaterialDefinition.CreateMaterial method in the ObjReader
https://helixtoolkit.codeplex.com/SourceControl/latest#Source/HelixToolkit.Wpf/Importers/ObjReader.cs
I agree it would be a good idea to create an overview of what is supported and not.
Note that the importers are also included in the refactoring task
https://helixtoolkit.codeplex.com/workitem/10023

Also consider Assimp.NET for a proven .obj importer. Has anyone found a good WPF adapter for it?

Rogad wrote at 2014-02-20 21:19:

I did look at Assimp.NET but there is no documentation for C#. Since I am still learning C# I can't get into that directly. Maybe in time..

From the ObjReader.cs to me it looks it does parse all the settings but in the end it supports Diffuse, Ambient and Specular and also the texture map.

So really, if you could confirm... this is the current state :

newmtl 3_SkinForearm
d 1 <- used (translated to Opacity)
Ns 1 <- used
Ni 0 <- ignored
Ka 0.858824 0.92549 0.937255 <- ignored
Kd 0.901961 1 0.996078 <- used
Ks 0.866667 0.929412 0.945098 <-used
Km 0.00252632 <- ignored
map_Kd Maps/RMDelphL.jpg <- used
map_Bump Maps/RMDelphLBp.jpg <- ignored
map_D <- ignored

Is that correct ?

Cheers :)

objo wrote at 2014-02-20 22:40:

the following should be corrected
d <- used (translated to Opacity)
Ns <- used
Ka <- ignored
Km <- ignored

full spec at http://paulbourke.net/dataformats/mtl/

Rogad wrote at 2014-02-20 23:35:

OK that's been corrected, I thought I probably did not get that right.

Thanks for the link to the specification.

Rogad wrote at 2014-02-20 23:36:

It goes to show how much work you have done :)

Rogad wrote at 2014-02-21 15:52:

Regarding the bump map - I have found comments that this might be possible with a Pixel Shader. But I have not found any example code as yet.

Rogad wrote at 2014-02-21 18:16:

I added that map_D is also ignored for now.

What about map_Ks ?

Rogad wrote at 2014-02-27 19:33:

I'm a bit confused about Ns too. Wikipedia has this page : http://en.wikipedia.org/wiki/Wavefront_.obj_file#Basic_materials

It says :
Ns 10.000 # ranges between 0 and 1000
My models from Daz have things like : Ns 0.5

Also I tried changing Ns of some of my model parts for example :

Ns 1000

And when viewed in the Helix model viewer there is no difference.

Also this page : http://people.sc.fsu.edu/~jburkardt/data/mtl/mtl.html
Ns s
defines the shininess of the material to be s. The default is 0.0;
So one would have thought that changing Ns to 1000 would make it shiny, but it doesn't.

So I am left wondering...

Rogad wrote at 2014-02-28 17:53:

Rogad wrote:
What about map_Ks ?
0

Issues with Multiple LinesVisual3D

Anonymous 11 years ago 0
This discussion was imported from CodePlex

mcrxb wrote at 2012-02-24 20:51:

Hi,

I'm using LinesVisual3D to produce an outline which works great. The problem I'm running into is having multiple outlines on screen with different properties (thickness, color, etc.). Both LineVisual3Ds are using the points from each other and creating overlapping lines. Here's a code sample:

TaperMillMainViewport.Children.Clear();

LinesVisual3D centerline = new LinesVisual3D();
centerline.Color = Colors.Gray;
centerline.Thickness = 1;
centerline.Points.Add(new Point3D(0, 0, 0));
centerline.Points.Add(new Point3D(0, 2, 0));
TaperMillMainViewport.Children.Add(centerline);
            
LinesVisual3D profile = new LinesVisual3D();
profile.Color = Colors.DarkGreen;
profile.Thickness = 2;
profile.Points.Add(new Point3D(0, 0, 0));
profile.Points.Add(new Point3D(.25, 0, 0));
profile.Points.Add(new Point3D(.25, 2, 0));
profile.Points.Add(new Point3D(0, 2, 0));
TaperMillMainViewport.Children.Add(profile);


objo wrote at 2012-03-10 15:36:

thanks for the bug report! There was a bug in the initialization of the Points dependency property - it should be corrected now. 

Also note that the Points list should contain pairs of coordinates - for each line segment. Your "profile" element will only contain two line segments.

0

Multiple Plane Grid lines ??

Anonymous 11 years ago 0
This discussion was imported from CodePlex

ManyMiles wrote at 2012-05-21 18:26:

I am very new at the Helix 3D Toolkit, and I'm excited to learn more about it.

I would like to have multiple sets of gridlines. Currently I'm just trying to get 2 sets to show, but it seems like it will only register one.  I'm trying with 1 grid in the X-Y Plane and 1 in the X-Z plane.  Is it possible to include multiple GridLinesVisual3D elements in the view?  What is an easy way to do it?  

Currently I have this declared in the MainWindow method ...

var model = new ModelVisual3D();
model.Children.Add(new GridLinesVisual3D() { Center = new Point3D(-0.5, -0.5, -0.5), Normal = new Vector3D(1, 0, 1), Width = 20, Length = 20, MinorDistance = 1, MajorDistance = 10, Thickness = 0.04, Fill = Brushes.Green });
model.Children.Add(new GridLinesVisual3D() { Center = new Point3D(-0.5, -0.5, -0.5), Width = 20, Length = 20, MinorDistance = 1, MajorDistance = 10, Thickness = 0.04, Fill = Brushes.Red });
view1.Children.Add(model);

But it seems to only show the second Grid.  Thanks for your help.


objo wrote at 2012-05-26 08:55:

Try to set LengthDirection = new Vector3D(0,1,0) on your first set of grid lines.

The 'WidthDirection' is calculated as the cross product of Normal and LengthDirection. In your code you end up with the same length and width directions in both cases.

See the GridLinesVisual3D.Tessellate method how it works.


ManyMiles wrote at 2012-05-29 01:39:

Thanks very much.  Setting the Normal and LengthDirection attributes got exactly the desired result I needed.

0

Is there a way to create extruded 3d solid from planar figure?

Anonymous 11 years ago 0
This discussion was imported from CodePlex

alessio83 wrote at 2013-09-12 11:10:

I need to create a solid 3d figure starting from a planar path (that represent the section on 3d figure)

How can i do? I'm trying to use meshBuilder.AddExtrudedGeometry but i don't understand how it works and if this is the right way.

See this image for understand what i need... I have the geometry of the 2D figure (A) and i want to obtain the 3D figure B...


thanks

Alessio

a5r wrote at 2013-09-16 11:31:

There's an example "Mesh Visuals Demo" in the example browser. In that example there's a tab "Extruded". The example shows a triangular section extruded over some path.

alessio83 wrote at 2013-09-16 16:07:

I see such example, but there is no example for "generic geomerty", there only pre-programmed type, i.e RectangleVisual3D, or PieSliceVisual3D ecc, no generic 2D geometry, extrudede in 3D.

a5r wrote at 2013-09-16 16:41:

Locate in the xaml file the helix:ExtrudedVisual3D and see that Section is set to "0 0 0.45 0 0.45 0.45 0 0.45". Now change it to whatever you like.

alessio83 wrote at 2013-09-16 17:05:

But in such sample, the path is composed by 3d point, and in my case the "known path" is a 2d path... may be i don't understand something...!?

objo wrote at 2013-09-17 00:17:

Yes, the Path is a Point3DCollection and the Section is a PointCollection. The 2D section is extruded along the 3D path. Use the SectionXAxis property to define the initial orientation of the section.
0

How to make a group out of several objects

Anonymous 11 years ago 0
This discussion was imported from CodePlex

afra89 wrote at 2011-12-23 12:17:

I have several CubeVisual3D objects. Can I somehow make them a single group and then I rotate that group so all of the cubes rotate. Is this possible?



afra89 wrote at 2011-12-23 12:41:

Thanks for quick answer, it works.
The problem is that I want to rotate them in the center of the whole modelgroup. 

This is my code:

RotateTransform3D rt;         
AxisAngleRotation3D ar;           
Transform3DGroup grp;

rt = new RotateTransform3D();           
ar = new AxisAngleRotation3D();                       
ar.Axis = new Vector3D(1, 0, 0);           
ar.Angle = x;           

rt.Rotation = ar;           
rt.CenterX = *Here i need center of the group X*       
rt.CenterY = *Here i need center of the group Y*           
rt.CenterZ = *Here i need center of the group Z*

grp = new Transform3DGroup();           
grp.Children.Add(rt); 
                     
cubes.Transform = grp; 


objo wrote at 2011-12-23 12:50:

here is a great book on 3D programming with WPF:

http://www.amazon.com/Programming-Windows-Three-Dimensional-Presentation-Foundation/dp/0735623945

the mathematics behind transformations is well covered here!

0

ZoomExtents on model changed

Anonymous 11 years ago 0
This discussion was imported from CodePlex

Jano42 wrote at 2013-03-27 14:10:

Hello,

My app is showing a 3d model which is loaded from xaml.

When my HelixViewport3D is Loaded (with event) I execute ZoomExtents, then my model is ocrrectly centred on display.

But my app is also able to change the model at runtime from Binding.
But I can not receive any event which told me when to ZoomExtent.
If I catch PropertyChange on CurrentModel, it seems that my ZoomExtents is done too early.
 <helix:HelixViewport3D x:Name="_helixView" Loaded="HelixViewLoaded" >
            <helix:DefaultLights/>
            <ModelVisual3D x:Name="_helixModel3D" Content="{Binding CurrentModel}"/>
...
What to do to ZoomExtent when a children change ?
0

draw a cube with mouse in helix3D

Anonymous 11 years ago updated by Kumaran M 11 years ago 1
This discussion was imported from CodePlex

Elementu wrote at 2012-01-17 10:24:

Hello ,

I am using the Helix 3d toolkit to develop my solution.

What I need and have not yet managed to develop properly is the drawing of a cube, or for that matter any other figure, with the mouse.

So when I press the left click I need the cube to begin drawing , as I keep dragging the mouse the cube should increase in size until I release the mouse button. at which moment the drawing should stop and the cube should be completed.

Unfortunately when drawing the cube i use the "HelixToolkit.Wpf.CubeVisual3D" which only has the center property and the size(width, height, depth) properties. so I am having problems drawing like any 3d program would , that is when when starting the drawing one corner should be fixed and the other points should mode until the drawing is complete. I thought of making the cube out of lines but that only applies to the cube and I also need to draw cylinders polygons   and others.

One more problem I am facing is that I assigned the rotation of the camera to the left click instead of the right click as it is usually. So that works for me only that when I select a figure to draw the left click should be used to draw and not to rotate the camera anymore until the selected button with the figure to draw is deselected then the left click is assigned back tot the rotation function.

Can anyone please point me in a right direction in order to solve this problems?

Thanks in advance.


objo wrote at 2012-01-17 11:33:

CubeVisual3D: right, you have to change the center point when you want to keep one corner (P1) fixed:

Center = P1 + new Vector3D(1,1,1) * SideLength * 0.5;

Rotate/draw modes: Can you set the RotateGesture to a MouseGesture(MouseAction.None) while you are in the draw mode?

I will add a box-drawing example when I get time :)


elementu wrote at 2012-01-17 12:36:

Thank you for your quick reply, i have tried to move the center instead of keeping it fixed but whatever I tried failed because the cube was still growing in both directions so i did not get the fixed corner I was hopping . I will try this too.

Another thing is that I get the mouse position like this HelixViewport.CurrentPosition to get a Point3D object in order to check how much the position of the mouse has changed . But if I cross an object that I already have loaded in the viewport the coordinates I get from the "CurrentPosition" property are very different and I barely move the mouse this is most visible when I have the grid lines loaded and i pas over the lines. What could be the nature of this problem ?

I will try to set the gesture to MouseAction.None when in draw mode. Actually I have thought of doing this before but wanted to modify as little as I could in the Helix code so that I don't have conflicts in other parts of the toolkit. So i tried to catch the mouse down event outside but the handler I was using was not getting triggered. the mouse up and move events were triggered i user it like this :

<h:HelixViewport3D
                           MouseLeftButtonDown="viewport_MouseLeftButtonDown"
                           MouseLeftButtonUp="viewport_MouseLeftButtonUp"
                           MouseMove="viewport_MouseMove"/>

0
Under review

Replace ViewCube

Khalid A. 9 years ago updated by datadeal Sedr 4 years ago 101

At the moment it seems that the ViewCube is a fixed Element of the HelixViewPort, that gets built up in the Code with the "AddCubeFaces" methods, etc.

It would be really nice to be able to replace the whole ViewCube with any model the user wants. That would allow us to have some kind of "MiniMap".


0

Camera View Setting

Anonymous 11 years ago 0
This discussion was imported from CodePlex

msankarsingh wrote at 2012-12-14 16:58:

Hi, 

Awesome toolkit. I am new to WPF and 3D.

I am trying to implement camera setting similar to this project  http://carvisualizer.plus360degrees.com/away3d/ any suggestion on how to implement it. Thanks in advance for your help.