For bugs and new features, use the issue tracker located at GitHub.
Also try the chat room!
Automatically move manipulator
With the three manipulators I can move the axis of the robot.
But I'm looking for a way to move the manipulators when the robot moves.
So when axis 1 of the robot moves you see all the 'stacked' objects moving but not the manipulators.
How can I achieve this?
Here is my source code:
SphereVisual3D sphereAxis1 = new SphereVisual3D();
sphereAxis1.Fill = new SolidColorBrush(Colors.Blue);
sphereAxis1.Center = new System.Windows.Media.Media3D.Point3D(0, 0, 0);
sphereAxis1.Radius = 1.0;
hvpMain.Children.Add(sphereAxis1);
RotateManipulator manipulatorAxis1 = new RotateManipulator();
manipulatorAxis1.Color = Colors.Blue;
manipulatorAxis1.Bind(sphereAxis1);
manipulatorAxis1.Axis = new System.Windows.Media.Media3D.Vector3D(0, 0, 1);
manipulatorAxis1.Diameter = 3.5;
manipulatorAxis1.InnerDiameter = 2.5;
hvpMain.Children.Add(manipulatorAxis1);
PipeVisual3D pipe1 = new PipeVisual3D();
pipe1.Fill = new SolidColorBrush(Colors.Orange);
pipe1.Diameter = 5.0;
pipe1.Point1 = new System.Windows.Media.Media3D.Point3D(0, 0, -1);
pipe1.Point2 = new System.Windows.Media.Media3D.Point3D(0, 0, 0);
sphereAxis1.Children.Add(pipe1);
PipeVisual3D pipe2 = new PipeVisual3D();
pipe2.Fill = new SolidColorBrush(Colors.Orange);
pipe2.Diameter = 2.0;
pipe2.Point1 = new System.Windows.Media.Media3D.Point3D(0, 0, 0);
pipe2.Point2 = new System.Windows.Media.Media3D.Point3D(0, 0, 2);
pipe1.Children.Add(pipe2);
SphereVisual3D sphereAxis2 = new SphereVisual3D();
sphereAxis2.Fill = new SolidColorBrush(Colors.Blue);
sphereAxis2.Center = new System.Windows.Media.Media3D.Point3D(0, 0, 2);
sphereAxis2.Radius = 1.0;
pipe2.Children.Add(sphereAxis2);
RotateManipulator manipulatorAxis2 = new RotateManipulator();
manipulatorAxis2.Pivot = new System.Windows.Media.Media3D.Point3D(0, 0, 2);
manipulatorAxis2.Axis = new System.Windows.Media.Media3D.Vector3D(0, 1, 0);
manipulatorAxis2.Color = Colors.Green;
manipulatorAxis2.Bind(sphereAxis2);
manipulatorAxis2.Position = new System.Windows.Media.Media3D.Point3D(0, 0, 2);
manipulatorAxis2.Diameter = 3.5;
manipulatorAxis2.InnerDiameter = 2.5;
hvpMain.Children.Add(manipulatorAxis2);
PipeVisual3D pipe3 = new PipeVisual3D();
pipe3.Fill = new SolidColorBrush(Colors.Orange);
pipe3.Diameter = 2.0;
pipe3.Point1 = new System.Windows.Media.Media3D.Point3D(0, 0, 2);
pipe3.Point2 = new System.Windows.Media.Media3D.Point3D(0, 0, 7);
sphereAxis2.Children.Add(pipe3);
SphereVisual3D sphereAxis3 = new SphereVisual3D();
sphereAxis3.Fill = new SolidColorBrush(Colors.Blue);
sphereAxis3.Center = new System.Windows.Media.Media3D.Point3D(0, 0, 7);
sphereAxis3.Radius = 1.0;
pipe3.Children.Add(sphereAxis3);
RotateManipulator manipulatorAxis3 = new RotateManipulator();
manipulatorAxis3.Pivot = new System.Windows.Media.Media3D.Point3D(0, 0, 7);
manipulatorAxis3.Axis = new System.Windows.Media.Media3D.Vector3D(0, 1, 0);
manipulatorAxis3.Color = Colors.Green;
manipulatorAxis3.Bind(sphereAxis3);
manipulatorAxis3.Position = new System.Windows.Media.Media3D.Point3D(0, 0, 7);
manipulatorAxis3.Diameter = 3.5;
manipulatorAxis3.InnerDiameter = 2.5;
hvpMain.Children.Add(manipulatorAxis3);
PipeVisual3D pipe4 = new PipeVisual3D();
pipe4.Fill = new SolidColorBrush(Colors.Orange);
pipe4.Diameter = 2.0;
pipe4.Point1 = new System.Windows.Media.Media3D.Point3D(0, 0, 7);
pipe4.Point2 = new System.Windows.Media.Media3D.Point3D(7, 0, 7);
sphereAxis3.Children.Add(pipe4);
Kind regards,
Arjan
DataTemplate3D for custom ModelVisual3D Xml/View
I am studying the WPF DataTemplate example, and it is interesting, data template acts as a kind of bridge into the 3D model?
I'm not sure what CreateItem is all about, except possibly a convention integrating with the sister ItemsVisual3D?
I wouldn't have such a thing in my model. In fact, I'm not sure I would potentially have one data template per model in the view, the content of which is the view instance?
It's making some sense grasping the connecting tissue.
Thank you...
How to render grass and chalk lines easily
I am taking a look at some options how to render grass, for instance as a texture, overlaid on a model, like a RectangleVisual3D and/or polygonal-surface, for instance, then in such a way that I can also render chalk lines, identify some material, etc, that simulates chalk lines, in both lines (or small rectangles themselves), and for font-materials (if there were such a thing? haven't done the research there, yet...).
I've found some tutorials how to work through apps like Paint.NET, GIMP, etc, in order to crank out some grass textures. Basically what's I would consider low to low/medium end quality. Not really looking for medium/high to high end quality at this point for this purpose, nothing even remotely like a Cinema 4D, for instance.
I am also taking a look at Unity3D for potential options there, they can generate grass, but this looks more like a full-fledged game-style development environment. Which might be along the lines what I'd like to do, especially with simulation for sprites, physics, etc. I'm not positive, SharpDX an analog to Unity3D, but it came up looking for grass and related effects.
Anyhow, for now, looking for the configuration aspects and what I can accomplish with a simpler-generated model.
Thank you...
Best regards,
Michael
ModelViewer Example
xion wrote at 2012-04-04 00:26:
Hi Objo,
fine work all the Helix stuff! Keep it up, please!
I've noticed differences in displaying .obj files, exported from 3dsmax, between the downloadable compiled example of ModelViewer(Nov2011) and the example in the current source dowload package.
The already compiled version displays the .obj file pretty well, including transparency.
The non-compiled recommended source version fails to display some objects correctly.
There's a bunch of code commented out. When I remove the comments some of the code is buggy (list1, fileModelVisual3D.Children)
Could you please give a feedback on it?
Thanks and regards, xion.
objo wrote at 2012-04-05 01:32:
hi xion, can you provide some simple .obj test files that renders incorrectly? We have tried to solve some texture/transparency bugs since the november version, but there is probably some work left... Also, some features of the .obj format (smoothing groups?) are not yet supported.
xion wrote at 2012-04-06 17:29:
Yes I can provide the .obj file. Send you a p.m. with a downloadlink.
objo wrote at 2012-04-07 23:13:
Thanks, I think I found the bug - the "Tr" setting in the material file should set the material opacity to 1-Tr.
xion wrote at 2012-04-08 00:35:
Thats interesting! Is it a buggy .mtl file? I used the latest 3dsmax design to export the file.
Expression Blend (MS) has the same problems on import these obj/mtl files.
objo wrote at 2012-04-08 00:39:
sorry, I thought the error was in the helix interpreter, but then I checked the spec:
objo wrote at 2012-04-08 01:08:
I have added a "SkipTransparencyValues" property to the "ObjReader". I also added support for smoothing groups.
xion wrote at 2012-04-08 11:44:
Thank you! 2012.2.2.1.46 shows all materials correctly. Thats great!
In 3dsmax the transparency value is called Opacity, which is set to 100% if the material is non-transparent. Maybe here's the clue.
objo wrote at 2012-04-08 13:05:
Good!
Opacity 100% should be exported as d = 1.0 or Tr = 1.0 if the wikipedia spec is correct. I think the exporter you are using will export d=1.0 and Tr=0.0.
TubeVisual3D and Material
jacobya wrote at 2012-01-12 23:19:
Hi,
Let me first start off by saying thank you very much for your efforts and for sharing this code, it is a tremendous piece of software and exceptionally well written. I'm wondering if you can give me your advice on how to accomplish the following:
I'm using the TubeVisual3D class to represent a pipe and what I'd like to do is draw a colored circle at a specific location on the surface of the pipe. Any suggestions on how this could be done, is there something in the existing library that would allow me to do this? I'm currently looking at using the Material attribute of the TubeVisual3D to accomplish this, but I'm not sure if this is the best approach.
Again, thanks very much, great work.
Jason
objo wrote at 2012-01-13 19:47:
You could do this by a rendering the circle to a bitmap and use that as a texture. But the edge of the circle will not look very sharp when zooming close, and it could be challenging to calculate the right texture coordinates.
I think it would be better to render the circle(s) as a separate mesh slightly outside the tube, but then the challenge is to calculate the 3D coordinates... Look at how the tangents and normals are calculated in the tube implementation, I hope this can help!
jacobya wrote at 2012-01-13 20:56:
Hi objo,
Thanks for the advice, I will look at rendering the circle as a separate mesh slightly outside the tube. I seem to be having difficulty applying a Material to the TubeVisual3D class. Am I doing something wrong here? In this case the tube shows up completely green:
<Window x:Class="PipeDemo.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ht="clr-namespace:HelixToolkit.Wpf;assembly=HelixToolkit.Wpf" Title="Pipe Demo" Height="480" Width="640"> <Window.Resources> <MaterialGroup x:Key="dm1"> <DiffuseMaterial> <DiffuseMaterial.Brush> <LinearGradientBrush StartPoint="0, 0.5" EndPoint="1, 0.5"> <LinearGradientBrush.GradientStops> <GradientStop Color="Yellow" Offset="0" /> <GradientStop Color="Red" Offset=".25" /> <GradientStop Color="Blue" Offset=".50" /> <GradientStop Color="LimeGreen" Offset=".75" /> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </DiffuseMaterial.Brush> </DiffuseMaterial> </MaterialGroup> </Window.Resources> <Grid> <ht:HelixViewport3D ZoomExtentsWhenLoaded="True" PanGesture="LeftClick" > <ht:SunLight /> <ht:GridLinesVisual3D/> <ht:TubeVisual3D Path="{Binding Pipe}" Diameter="5" IsPathClosed="False" Material="{StaticResource dm1}" BackMaterial="{StaticResource dm1}" /> </ht:HelixViewport3D> </Grid> </Window>
and my code:
public IList<Point3D> Pipe { get; set; } public Window1() { InitializeComponent(); Pipe = this.CreatePath(); DataContext = this; } private IList<Point3D> CreatePath() { List<Point3D> list = new List<Point3D>(); for (int i = -5; i < 5; i++) { list.Add(new Point3D(i * 10, 0, 5)); } return list; }
objo wrote at 2012-01-13 21:10:
I see the TubeVisual3D is not currently supporting texture coordinates.
I will add a Values property where you can set the texture X (u) coordinates. The Y value (around the tube) is difficult to define and will simply be linear from 0 to 1.
You can also create the tube geometry by MeshBuilder.AddTube (where you also can specify the diameters along the tube).
jacobya wrote at 2012-01-19 03:53:
Hi objo,
Thanks for adding the TextureCoordinates property to the TubeVisual3D class, I also see that you added a Diameters property as well. I'm still not sure how to apply a texture to a TubeVisual3D though, would it be possible for you to give me a very simple example? I basically want to apply a RadialGradientBrush to a TubeVisual3D, any advice you can provide is greatly appreciated.
Thanks
objo wrote at 2012-01-19 10:53:
see the "StreamLinesDemo" example. It is currently using MeshBuilder.AddTube, but could now be rewritten to use the TubeVisual3D. The example uses a linear gradient brush (hue colours) in the material, and uses the streamline velocities (scaled to [0,1]) as "values" (first texture coordinate). It is difficult to control the position of the texture around the tube (second texture coordinate) (unless we specify a normal direction for each point of the path), so I am currently only using "1-dimensional" textures.
Using MeshBuilder for bounding box in MVVM
ahmad_luqman wrote at 2013-04-02 15:06:
My ViewModel has this:
var size = 6000;
var axesMeshBuilder = new HelixToolkit.Wpf.MeshBuilder();
var bb = new Rect3D(-1 * size / 2, -1 * size / 2, -1*size, size, size, size);
axesMeshBuilder.AddBoundingBox(bb, 10);
Box = axesMeshBuilder.ToMesh();
Which sets the Geometry3d type Box property in ViewModel:public Geometry3D Box { get; set; }
And the Xaml View has: <h:HelixViewport3D>
<h:SunLight />
<ModelVisual3D>
<ModelVisual3D.Content>
<GeometryModel3D Geometry="{Binding Box}" Material="{h:Material Black}"/>
</ModelVisual3D.Content>
</ModelVisual3D>
</h:HelixViewport3D>
This works but unit tests on ViewModel fails with exception:System.ServiceModel.CommunicationObjectAbortedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it has been Aborted.
This is because I am setting the MeshBuilder in View Model. Ideally this logic should be in Xaml View.
Can you suggest how can I move the MeshBuilder logic to XAML and bind to Rect3d?Something like this:
<h:HelixViewport3D>
<h:SunLight />
<ModelVisual3D>
<ModelVisual3D.Content>
<GeometryModel3D Material="{h:Material Black}">
<!--Mesh Builder logic here -->
<GeometryModel3D />
</ModelVisual3D.Content>
</ModelVisual3D>
</h:HelixViewport3D>
In case if the above answer is no we can't do that, alternatively how can we draw similar bounding box following MVVM?ahmad_luqman wrote at 2013-04-02 15:40:
This works:
<h:BoundingBoxVisual3D Diameter="10" BoundingBox="{Binding Box}" Fill="White"/>
Thanks for the cool library.importing Geometry3D
medecai wrote at 2012-04-23 17:56:
Hey there,
first of all, i want to thank you for providing such an awesome Toolkit!
Second I have a question concerning the ModelImporter. I was using the beta (helixToolkit-release) for some time now and it was possible to import Geometry3D data by:
private Geometry3D LoadGeoFromFile(string objPath) { Model3DGroup group = ModelImporter.Load(objPath); GeometryModel3D model = group.Children[0] as GeometryModel3D; return model.Geometry; }
I could afterwards bind the Geometry in Wpf like
<helix:HelixViewport3D> <ModelVisual3D> <helix:DefaultLights/> <ModelVisual3D.Content> <GeometryModel3D Geometry="{Binding TestFile}" Changed="GeometryModel3D_Changed"> <GeometryModel3D.Material> <DiffuseMaterial> <DiffuseMaterial.Brush> <SolidColorBrush Color="Gray"/> </DiffuseMaterial.Brush> </DiffuseMaterial> </GeometryModel3D.Material> </GeometryModel3D> </ModelVisual3D.Content> </ModelVisual3D> </helix:HelixViewport3D>
and was therefore able to display the geometry just with a plain brush (to improve performance). Right now I tried
the newest source code (to check if loading times etc. improved) but the described procedure isn't working anymore.
The ViewPort only shows parts of the whole model at best.
Did something substantial change which could forbid this way of doing it or is it just a minor thing which I am not seeing ('cause
I am still starting to learn programming)?
Cheers
Mede
objo wrote at 2012-04-25 07:08:
What kind of file are you importing? It should still be possible to extract the geometry from the returned Model3D, but I don't think you should depend on this being in Children[0] (an imported file could contain more than one GeometryModel3D).
medecai wrote at 2012-04-25 13:19:
Obj.-Files exportet by blender. And you are, of course, completely right concerning the number of geometries in the file. Which is most likely the problem of most models not be shown correctly . For me it seemed to be the easiest way to include lots of models/geometries and be able to transform them in relation to each other by binding (in Wpf), like moving an arm for example. Somehow it was working just fine for the beta-release of helix toolkit.
Seems that I have to find out how I can bind to different models and transform them the correct way =)
EDIT: I found a workaround:
private Geometry3D LoadFromFile(string objPath) { Model3DGroup group = ModelImporter.Load(objPath); MeshBuilder TestMesh = new MeshBuilder(false, false); foreach (var m in group.Children) { var mGeo = m as GeometryModel3D; var mesh = (MeshGeometry3D)((Geometry3D)mGeo.Geometry); if (mesh!=null) TestMesh.Append(mesh); } return TestMesh.ToMesh(); }
Seems to work fine. Or am I again missing something?
Btw. Again: this toolkit is just great! Whenever I think I just don't now how the hell I should accomplish something I find again some nice method to help. =)
How to clone a Helix UIElement...?
BogusException wrote at 2014-08-22 20:08:
Right now I get
Value of type 'Helixtoolkit.Wpf.CubeVisual3D' cannot be converted to 'System.Windows.UIElement'. ...which makes sense. Any thoughts?
- To Be Clear: I don't want to change the cube's type at all, but merely be able to clone it in the way below, returning the correct UIElement equivalent in the Helix namespace...*
Public Function CloneElement(ByVal orig As UIElement) As UIElement
If orig Is Nothing Then
Return (Nothing)
End If
Dim s As String = System.Windows.Markup.XamlWriter.Save(orig)
Dim stringReader As New StringReader(s)
Dim xmlReader As XmlReader = XmlTextReader.Create(stringReader, New XmlReaderSettings())
Return CType(System.Windows.Markup.XamlReader.Load(xmlReader), UIElement)
End Function
The call to this function looks like this (pardon this editor's formatting):Task.Factory.StartNew(
Function() {
Dispatcher.BeginInvoke(New Action(Sub()
Dim clone As CubeVisual3D = CType(CloneElement(cube1), CubeVisual3D)
Messenger.Default.Send(Of HelixToolkit.Wpf.CubeVisual3D)(cube1) ' sends to AddAChildMvvm()
End Sub))})
It's a threading problem, and the Function creates an instance of the cube in thsi thread, not the thread it was originally created under/in.Thanks!
pat
:)
Problem loading .3ds file with texture
bdeldri wrote at 2014-08-13 22:09:
I am trying to load a simple .3ds file with a texture that I exported from Blender. It appears to read some garbage into the texture image name here (StudioReader.cs):
case ChunkID.MAT_MAP:
texture = this.ReadMatMap(reader, size - 6);
break;
Then when it tries to load the image, it borks with "System.ArgumentException: Illegal characters in path".
I'm not familiar enough with the .3ds format to know if this is a problem with the reader or with the model, but it does seem to load fine in the OpenSceneGraph viewer.
I have the file and texture available if that would help, but I'm not sure how to attach them to this discussion (if that is even possible).
Thanks!
HelixToolkit.Wpf.SharpDX - Transparency and Sorting
eonxxx wrote at 2014-06-26 22:56:
anyone knows something about transparency and sorting with the sharpdx fork?
In the Helix3D lib there's an container object called HelixToolkit.Wpf.SharpDX. It is sorting faces/models related to their camera position. It's quite a bit slow on huge amount of faces. Thats why I'm switched to try the sharpdx fork.
With no sorting, models in the back of the transparent model are often invisible, what destroys the effect of transparency.
In the sharpdx fork, there's no equivalent on the first sight. If it is coded managed, I'd like to say it's same kind of slow. (what is ok for lower count of faces)
Is there a "natural" way of sharpdx, even the use of shaders, for sorting / natural looking transparency / see-through?
Anyone knows?
Thanks in advance!
eon
objo wrote at 2014-07-02 13:21:
eonxxx wrote at 2014-07-06 10:59:
// model materials
this.RedMaterial = PhongMaterials.Red;
var diffColor = this.RedMaterial.DiffuseColor;
diffColor.Alpha = 0.5f;
...a material thing. But sorting is the problem. I'll gonna try a shader approach.
Thank you...
objo wrote at 2014-07-11 21:58:
http://en.wikipedia.org/wiki/Order-independent_transparency
eonxxx wrote at 2014-08-09 22:46:
How to bind in a custom shader to my HELIX app?
Customer support service by UserEcho