For bugs and new features, use the issue tracker located at GitHub.
Also try the chat room!
Two questions on Manipulator
damianoslebo wrote at 2013-02-12 01:36:
CubeVisual3D box = new CubeVisual3D();
box.Center = new Point3D(x, y, z);
CombinedManipulator boxManipulator = new CombinedManipulator();
boxManipulator.Position = box.Center;
boxManipulator.Pivot = box.Center;
boxManipulator.CanRotateX = false;//true;
boxManipulator.CanRotateY = false;// true;
boxManipulator.CanRotateZ = false;// true;
boxManipulator.CanTranslateX = false;// true;
boxManipulator.CanTranslateY = false;// true;
boxManipulator.CanTranslateZ = true;
boxManipulator.Bind(box);
vp.Children.Add(boxManipulator);
vp.Children.Add(box);
globalManipulatorList.Add(boxManipulator);
I can get the manipulator to work in the x and y and all rotation directions, however the Z translate direction does not show up on the viewport. I don't know why the other directions work but Z does not work.The second question is what event can invoke when using a transparent bounding volume to detect a mouse left button down on the manipulator? I have been using the VisualTreeHelper.HitTest method to ignore transparent geometry before now but I don't know what method can be invoked once a manipulator is found by the VisualTreeHelper.HitTest method.
Thanks for the help,
Damian
objo wrote at 2013-03-12 11:41:
1: Thanks for the notice - I see some change had broken the TranslateManipulator. I removed the default value of the Direction property, now it seems to work again.
2: Sorry, I don't quite understand the problem here. Please make an example that we can debug!
Manipulators to stretch and move box
christianw42 wrote at 2013-06-17 14:03:
i have a little problem with adding manipulators to an visual via code, in my case a BoxVisual3D.
I define a box an two manipulators, one for moving, one for resizing:
var volumeBox = new BoxVisual3D();
volumeBox.Center = new Point3D(0, 0, 0);
volumeBox.Length = 0.3;
volumeBox.Width = 0.3;
volumeBox.Height = 0.3;
volumeBox.Material = MaterialHelper.CreateMaterial(Colors.SkyBlue, 0.3);
var xManipulator = new TranslateManipulator();
xManipulator.Color = Colors.Red;
xManipulator.Length = 0.4;
xManipulator.Diameter = 0.02;
xManipulator.Position = new Point3D(0, 0, 0);
xManipulator.Direction = new Vector3D(-1, 0, 0);
xManipulator.Offset = new Vector3D(-1, 0, 0);
xManipulator.Bind(volumeBox);
var xStretchManipulator = new TranslateManipulator();
xStretchManipulator.Color = Colors.SpringGreen;
xStretchManipulator.Length = 0.3;
xStretchManipulator.Diameter = 0.02;
xStretchManipulator.Position = new Point3D(0, 0, 0);
xStretchManipulator.Direction = new Vector3D(-1, 0, 0);
xStretchManipulator.Offset = new Vector3D(0, 0, 0);
//xStretchManipulator.Bind(volumeBox);
var binding = BindingOperations.SetBinding(
xStretchManipulator, TranslateManipulator.ValueProperty, new Binding("Length") { Source = volumeBox, Converter = new LinearConverter { M = 0.5 }});
binding.UpdateTarget();
//var targetBinding = BindingOperations.SetBinding(
// xStretchManipulator, TranslateManipulator.TransformProperty, new Binding("Transform") { Source = volumeBox });
//targetBinding.UpdateTarget();
//var targetTransformBinding = BindingOperations.SetBinding(
// xStretchManipulator, TranslateManipulator.TargetTransformProperty, new Binding("Transform") { Source = volumeBox });
//targetTransformBinding.UpdateTarget();
The code above works fine for resizing and moving the box, but the manipulator for resizing (xStretchManipulator) does not move with the box. When I add the transform-bindings to the xStretchManipulator, it moves with the box, but position is always in the
center of the box and when you stretch to much, manipulator is inside the box. Does anyone have an idea how to define and bind the manipulators, so that it works correctly?
Thanks a lot for any help or ideas!
christian
Monster memory leak on window resize for SharpDX build.
noemata wrote at 2014-03-19 20:28:
Strangely the leak appears to accumulates on a TextBlock control.
objo wrote at 2014-04-29 10:52:
Simple sample to make objects in code
mentalarray wrote at 2012-03-27 03:13:
Hi well done for such a great project...
I just wondred whethr there is a sample to add/make objects from scratch in code, i have seen the Mvvm demo but was interested in another more simpler way
Much thanks...
murray_b wrote at 2012-03-27 05:21:
How simple?
In the MVVM example it creates a observable collection
�public ObservableCollection Objects { get; set; }
Binds it to the itemsource of the Viewport
then adds objects to it in code. Ie Objects.Add( new #any of the Visual3d objects#)
objects.add (new TubeVisual3D
{
Path = polygonPoints,
Material = MaterialHelper.CreateMaterial(tubeColor),
BackMaterial = MaterialHelper.CreateMaterial(tubeColor),
Diameter = 0.1
});
Does that help? Let me know if that doesn't make sense
or do you want a non-mvvm. If so just add objects in code behind to the itemsource
mentalarray wrote at 2012-03-27 17:20:
Oh brill thanks murray_b just what i needed
Port to Winform and SharpGL?
tingspain wrote at 2013-04-25 02:55:
First of all, I would like to say that GREAT JOB. I have checked the demo apps and it is very impresive work.
I was wondering if it is possible to easy port this library to Winform and SharpGL?
I dont know too much about WPF.
Thanks in advance.
objo wrote at 2013-04-25 11:31:
Sorry, there are no plans to port to Windows forms and OpenGL.
RobPerkins wrote at 2013-04-25 18:07:
przem321 wrote at 2013-04-25 23:16:
objo wrote at 2013-04-26 00:01:
Keep up the good work on the sharpdx fork, Przem!
tingspain wrote at 2013-04-26 01:02:
I looked around very fast the source code of Helix 3D toolkit, and I found get my lest a little lost. I am not familiar with WPF. Do you think that it will be very hard to port to Winform + SharpGL or SharlpDX?
Maybe I can start the porting the code.
objo wrote at 2013-04-26 22:19:
tingspain wrote at 2013-04-27 04:38:
objo wrote at 2013-05-08 15:48:
Feel free to start a fork on this! I wish I had time to follow up, but I'm focusing on other tasks at the moment.
RobPerkins wrote at 2013-06-18 19:47:
Does the architecture make sense in terms of Helix?
objo wrote at 2013-06-18 22:20:
I think performance is important for the mesh generating code. I think this means that platform specific data types (e.g. point, quaternions, transformations) should be used as much as possible, but it is possible that the platform specific data types do not need to be exposed in the public interfaces.
RobPerkins wrote at 2013-06-18 23:16:
namespace ExtensionMethods
{
public static class MyExtensions
{
public static int WordCount(this String str)
{
return str.Split(new char[] { ' ', '.', '?' },
StringSplitOptions.RemoveEmptyEntries).Length;
}
}
}
Which is then used by declaring using ExtensionMethods and:string s = "Hello Extension Methods";
int i = s.WordCount();
I note that you have four such classes in the code base which I have (privately) forked for my own use.
What strikes me as interesting is that almost every 3D implementation uses a unique type name for its points, quaternions, and transformations, but the actual structure of the structs or class data have to be identical or nearly so. For games, performance of mesh generators is not vital; under the only architectures I can think of, most of those are loaded or preloaded before a high framerate is needed in the game. For engineering use cases, a high triangle count plus a relatively low framerate (mouse gesture animations, mostly) are the order of the day.
Frankly, for most mesh generation, I'm writing my own code against my data models and emitting the WPF formatted arrays and assigning them to the various Visual3Ds I use from the Helix library. So what I'm thinking about is extension methods like "ToOpenGL--structure--" or "ToSharpDX--whatever--" which would take the WPF structures native to Helix and emit the ones compatible with the other libraries. With a modern i5 or i7 and TPL it wouldn't even be computationally time consuming to execute such functions unless the facet counts were in the millions.
For my engineering based low-frame-rate, medium-delay-tolerant use cases, such an approach would not be so bad. I may give this more thought; the OpenTk stuff looks very, very compelling for non-WPF reasons.
Manipulators in code
ChrisKerridge wrote at 2012-04-30 10:52:
First off, great toolkit.
I want to be able to dynamically add objects to a 3D scene and be able to move them with manipulators using code similar to:
var builder = new MeshBuilder(true, true); var position = new Point3D(0, 0, 0); builder.AddSphere(position, 1); var geom = new GeometryModel3D(builder.ToMesh(), Materials.Red); var visual = new ModelVisual3D(); visual.Content = geom; var manipulator = new TranslateManipulator(); manipulator.Bind(visual); manipulator.Position = position; manipulator.Direction = new Vector3D(0, 0, 1); manipulator.Offset = new Vector3D(0, 0, 1); manipulator.Color = Colors.Blue; vp.Children.Add(manipulator); vp.Children.Add(visual);
This gives me a sphere and an arrow pointing upwards (great), but dragging the arrow up and down has no affect on the sphere. How can I get the manipulator to affect the sphere?
Thanks a lot
objo wrote at 2012-05-02 21:36:
I found a bug in the code - the Manipulator.Bind method should not use CombinedManipulator.TargetTransformProperty, but its own. I will submit the fix soon. Thanks for providing the code that made it easy to find the error.
Also, move your code line
manipulator.Bind(visual);
Sorry there is no more documentation than the XML comments and the example on these features - it was experimental code that seemed to work well, so I just put it into the library...
christianw42 wrote at 2013-06-06 11:13:
is there still anything broken in the toolkit? Here you can see my code, I can see the box and the manipulator, but when i click the manipulator, nothing happens.
var volumeBox = new BoxVisual3D();
volumeBox.Center = new Point3D(0, 0, 0);
volumeBox.Length = 0.3;
volumeBox.Width = 0.3;
volumeBox.Height = 0.3;
volumeBox.Material = MaterialHelper.CreateMaterial(Colors.SkyBlue, 0.3);
var manipulator = new TranslateManipulator();
manipulator.Color = Colors.Red;
manipulator.Length = 0.4;
manipulator.Diameter = 0.02;
manipulator.Position = new Point3D(0, 0, 0);
manipulator.Direction = new Vector3D(1, 0, 0);
manipulator.Bind(volumeBox);
this.VolumeBoxModel.Children.Add(volumeBox);
this.VolumeBoxModel.Children.Add(manipulator);
Thanks a lotchristianw42 wrote at 2013-06-06 11:30:
Workaround: add the following two lines after the code above.
this.HelixViewport.Visibility = Visibility.Collapsed;
this.HelixViewport.Visibility = Visibility.Visible;
Thanks for a great framework!
LinesVisual3D Aren't Rendering
jrhokie1 wrote at 2013-01-24 15:09:
I have a WPF app, with my HelixViewport3D's ModelVisual3D Content property bound to a Model3DGroup-type property. I create some EllipsoidVisual3D objects, and add them to my model group by
modelGroup.Children.Add(ev3.Model);
Now I want to create some line segments. I do this
LinesVisual3D lv3d = new LinesVisual3D();
Point3D p1 = new Point3D(...);
lv3d.Points.Add(p1);
Point3D p2 = new Point3D(...);
lv3d.Points.Add(p2);
lv3d.Thickness = 20;
modelGroup.Children.Add(lv3d.Content);
But my lines aren't visible. Setting IsRendering to true doesn't help.
I'm doing MVVM, so I don't want to directly add a visual to my viewport, as is done in the Points and Lines sample. I know I'm using it wrong, I just can't figure out where. Any help will be appreciated.
Thanks.
-reilly.
jrhokie1 wrote at 2013-01-24 16:01:
Never mind. I found and used MeshBuilder. Works like a champ.
Seriously, objo, you should put a PayPal "Donate" button up here. I don't know how much they skim off the top, but I would pay you for your work.
objo wrote at 2013-02-04 15:26:
I added an Amazon wish list link at the home page, if you feel for donating a book! :)
jrhokie1 wrote at 2013-02-04 16:25:
[FYI, I'm working on a tool to extract statistics from 50 micron scans of coupons which have been subjected to corrosive environments. We read the scan data and visualize it in 3D. The tool provides controls to process the image, detect corroded pits, and extract their statistics for use in modeling. I used Helix to show and annotate the data. It couldn't have been easier.]
Please keep up the good work.
Regards,
-reilly.
objo wrote at 2013-02-05 08:55:
Regarding the code - it seems like you are 'stealing' the Model3D from the LinesVisual3D instance. The screen space visuals must be updated every time the camera or transforms are changed, currently this is handled by the CompositionTarget.Rendering event. I guess there was no updating going on in your case where you had disconnected the LinesVisual3D from the visual tree.
Billboard rendering problem
jdek wrote at 2013-08-08 16:30:
The Billboard is working well, but sometimes it has additional dashes at its bottom and right sides. Here is how the Billboard looks for me :
Behold my code used to initialized the Billboard :
new BillboardTextVisual3D { Text = "1800", Position = new Point3D(0, 0, 0) };
May be this is due to antialiasing... If somebody has a solution...
objo wrote at 2013-08-08 16:42:
jdek wrote at 2013-08-08 16:55:
But I found a workaround :
Set this property on the HelixViewport3D :
RenderOptions.BitmapScalingMode="Fant"
"HighQuality" is working too. May be it is a lack of precision of my graphic card because this doesn't appear if I switch from one to another (laptop with Nvidia Optimus).objo wrote at 2013-08-08 17:03:
3dfx_IceFire wrote at 2014-02-28 08:32:
See the following picture as an example:
I fould out that this happens only if the background is not set to transparent.
See my cource code:
variant 1
labelTextGroup = new BillboardTextGroupVisual3D()
{
Background = Brushes.White,
Items = null
};
[...]
var labelTextItems = new List<BillboardTextItem>();
labelTextItems.Add(new BillboardTextItem()
{
Text = current.ToString(),
Position = (Point3D)((double)i * Direction + (FontSize * 0.07) * DesciptionOrientation),
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center
});
labelTextGroup.Items = labelTextItems;
variant 2
BillboardTextVisual3D label = new BillboardTextVisual3D()
{
Text = current.ToString(),
FontFamily = new FontFamily("Courier New"),
FontSize = this.fontSize,
Background = new SolidColorBrush(Color.FromRgb(255, 255, 255)),
Position = (Point3D)((double)i * Direction + (FontSize * 0.07) * DesciptionOrientation),
};
Besides that I cannot find a BitmapScalingMode property in the HelixViewport3D. Was there a change in the HelixViewport3D class?
VRML Importer version
michaeldjackson wrote at 2012-11-19 16:48:
If I download the latest version Oct 2012, will it containthe VRML importer feature? If not, how do I get the version with VRML importer?
objo wrote at 2012-11-19 16:58:
You find the vrml import fork on http://helixtoolkit.codeplex.com/SourceControl/network/forks/glgweeke/vrmlImport
This fork has not been merged into the default branch yet.
michaeldjackson wrote at 2012-11-19 18:35:
I'm trying to import a simple wrl model using the VRML reader. It fails with the following exception:
System.FormatException was unhandled
HResult=-2146233033
Message=Input string was not in a correct format.
Source=mscorlib
StackTrace:
at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
at System.Double.Parse(String s, IFormatProvider provider)
at HelixToolkit.Wpf.VrmlReader.GetValues(Double[]& result)
at HelixToolkit.Wpf.VrmlReader.ReadGeometry(Model3DGroup model3DGroup)
at HelixToolkit.Wpf.VrmlReader.DoShapeNode(Int32 level, Model3DGroup model3DGroup)
at HelixToolkit.Wpf.VrmlReader.ReadTransform(Model3DGroup model3DGroup, Int32 level)
at HelixToolkit.Wpf.VrmlReader.DoGroupNode(Int32 level, Model3DGroup model3DGroup)
at HelixToolkit.Wpf.VrmlReader.ReadTransform(Model3DGroup model3DGroup, Int32 level)
at HelixToolkit.Wpf.VrmlReader.Read(Stream s)
at HelixToolkit.Wpf.VrmlReader.Read(String path)
at VRMLImportTest.MainViewModel.LoadModel() in c:\CPG Dev Projects\VRMLImportTest\VRMLImportTest\MainViewModel.cs:line 26
at VRMLImportTest.MainWindow.btnRun_Click_1(Object sender, RoutedEventArgs e) in c:\CPG Dev Projects\VRMLImportTest\VRMLImportTest\MainWindow.xaml.cs:line 42
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at VRMLImportTest.App.Main() in c:\CPG Dev Projects\VRMLImportTest\VRMLImportTest\obj\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
michaeldjackson wrote at 2012-11-20 12:58:
Not sure how to attach file to reply.
glgweeke wrote at 2012-11-21 11:34:
Hi,
you can create a new issue and attach a file.
Max. 4MB. (use Zip)
objo wrote at 2012-11-21 11:55:
I would suggest sharing by a service like
http://www.filedropper.com
http://www.filefactory.com
http://fileden.com/
or for source files
http://pastebin.com
etc.
michaeldjackson wrote at 2012-11-21 13:37:
Link to my troublesome .wrl file.
http://www.filefactory.com/file/6lpoznkjny8d/n/AF1_wrl
The AF1.wrl file is an export from Flac3D 5.0 from Itasca, and represents a rectilinear grid.
I used MeshLab (free, opensource) to view the file to ensure it is not corrupted.
glgweeke wrote at 2012-11-21 22:04:
In the vrml import fork i make some bugfixes. Now you can import the file.
Currently i do not support texture mapping.
But it will be possible to add this feature in near future.
michaeldjackson wrote at 2012-11-29 19:50:
I have uploaded a .png to http://www.filefactory.com/file/5dmq1jc0ulgv/n/VRMLInMeshLab_PNG which represents the AF1.wrl file that I sent you previously for your testing purposes being viewed in MeshLab. Is is possible to get this type of view from your VRML importer? In MeshLab, this view is obtained by clicking the "WireFrame" button.
glgweeke wrote at 2012-12-04 18:39:
Hi,
in WPF it is not possible to draw a real line in 3D.
Your .WRL-File is using IndexedLineSet which need this feature.
This Helix-Toolkit creates a line with 2 Triangles which what a real size. Not only one pixel on every viewpoint.
To do what you like,
pease patch the following to lines in the VRMLReader.cs file.
1.) Line 734:
if (FindNode("IndexedFaceSet"))
replace
if (false)
2.) Line 949:
mesh.Positions = lg.CreatePositions(linePoints, 0.001);
replace
mesh.Positions = lg.CreatePositions(linePoints, 0.1);
This importer is not stable not finished and not perfect.
Customer support service by UserEcho