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

Transforming a ModelVisual3D vs transforming a GeometryModel3D

Anonymous 11 years ago updated by ไอยดา สุรีวงค์ 4 years ago 1
This discussion was imported from CodePlex

Vicente wrote at 2010-08-03 20:00:

I'm working currently on a 3D project and I'm using Helix for the cameras and the viewport (great work :)). I have noticed a strange behavior that I don't understand much regarding the camera, the movement of the camera and the ZoomToFit method.

For the first part of the project I was working with GeometryModel3D objects, creating the geometry by hand (positions, triangle indices,...) and assigning them their transforms. Everything worked right. Now I have refactored the code base and I have started using ModelVisual3D and I assign the transform there instead of transforming the GeometryModel3D. Now the ZoomToFit doesn't catch the object, the camera moves strangely and when that transform is big enough, everything starts doing pretty weird things.

I have looked at Helix samples and the behavior is similar to the one in the Simple Demo, in the Transformed Model tab. So I suppose that is by design, but I don't really understand the difference or what's happening behind the scenes :)

Could you give me an explanation of why are both things giving so different results? Regards!

Vicente


objo wrote at 2010-08-04 09:02:

hi Vicente! It is good to hear you find the toolkit useful! I just added support for transforms in the ZoomToFit method, and an example in the SimpleDemo. Make sure that your viewport control is loaded before calling the ZoomToFit method. It seems to behave correct now :) Also note that you can use mouse double right click to set the camera LookAt point.


objo wrote at 2010-08-05 00:54:

I corrected a bug in the transform calculation. It should work now, also for combinations of transformations :)


Vicente wrote at 2010-08-06 18:52:

Hi objo!

thanks a lot for the changes :) I have been playing more with the transformations and I have hit another weird thing. It seems the camera translation (middle mouse button) depends on the translation of the object, rotation and zoom. For example, if you have a translation in the object of (200, 150, 100), sometimes moving the mouse to the left will move the object to the left, but depending on the zoom, in some other cases it will move the object to the right, as if the axis got inverted. It's easy to see in the Zoom to Fit tab in the Simple Demo. Also, if the translations are bigger, the camera starts behaving very strangely, and double clicking with the middle mouse button doesn't seem to work correctly.

It looks like a bug to me, but not sure, if you need more information on how to reproduce it let me know. Regards!

Vicente


Vicente wrote at 2010-08-07 03:18:

By the way, I have found also another strange camera behavior. If you try using ZoomToFit with an empty scene, the camera will get "not a number" values in the Position property, and from there it will go crazy, it will never work again. If you try ZoomToFit again after that, it will crash in CameraHelper.cs line 115. If you have an scene with something, then empty it and you try ZoomToFit you get the exception in the same place but related to the newPosition value.

Hope it helps :) Regards!

Vicente


objo wrote at 2010-08-12 09:56:

I corrected the bug when using ZoomToFit on an empty scene. If the bounding box is empty, it will do nothing. I will have a look at the strange camera panning behaviour later (the panning should only depend on the camera position/direction - it uses the Unproject method).

Vicente wrote at 2010-08-13 14:30:

Great news :)

ReedCopsey wrote at 2010-10-21 03:19:

objo,

 

Any progress on the strange camera behavior with panning?  This has been causing us grief lately.

 

Thanks,

Reed

 


objo wrote at 2010-10-21 06:58:

hi Reed,

no, I have not had any progress on that problem. It could be a problem in the Ray3D.PlaneIntersection algorithm... I'll add this to the issue tracker.

I just corrected a similar problem with the zoom - when scrolling very fast you might end up on the 'other side' of the object. The solution there was to clamp the zoom factor.

cheers objo 

0
Under review

manipulator disable/enable

jason-he 10 years ago updated by Øystein Bjørke 10 years ago 1
Helix toolkit looks so great, I am trying to use it for my work assignment.

Helix toolkit WFP shows some examples. One of them is ManipulatorDemo. Displaying the rotators and translators are useful for a user. But I want some flexibility for a user to disable/enable them, so I added a name to cube1's CombinedManipulator, called Cube1Rotator, also added a double-click event to ht:HelixViewport3D (called ManipulatorViewport3D) to allow a user to toggle CanRotateY, CanRotateX, CanRotateZ. Here is the double-click event,

ManipulatorViewport3D_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
Cube1Rotator.CanRotateX = !Cube1Rotator.CanRotateX;
Cube1Rotator.CanRotateY = !Cube1Rotator.CanRotateY;
Cube1Rotator.CanRotateZ = !Cube1Rotator.CanRotateZ;
}

When I tested it, the rotators were displayed or hidden correctly. However, once double-clicking the mouse, I couldn't rotate or translate the cube1 anymore, even they were displayed.

Any idea?

Thanks in advance


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"/>