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

Camera Changing Position Events

Anonymous 11 years ago 0
This discussion was imported from CodePlex

pupunussi wrote at 2012-09-13 15:57:

Hello,

Is there a way to get an event fired every time the viewport starts and ends changing the position of the camera? GotMouseCapture and LostMouseCapture events of CameraController kinda work but not for zooming with mouse wheel.

I have a surface displayed with a high level of detail. What I am trying to do is to decrease the level of detail whenever the user tries to manipulate the camera in order to sustain high enough FPS to keep the program usable.

So far I build two surface with high and low levels of detail and replace one with another and then back on GotMouseCapture and LostMouseCapture events.

I'm pretty sure it's not the best way to achieve the results I need.

Is there a better way to do it?

Thanks!

0

None critical but annoying Bug

Anonymous 11 years ago 0
This discussion was imported from CodePlex

kwcoffee1 wrote at 2014-07-10 00:51:

Hi,

This is a very good 3D toolkit, thank you.

But I noticed the follow flaw:

If the ModelUpDirection property is set to say (0,0,-1) then the viewcube control does not show up in the viewport box.

Again, Thanks,
King

objo wrote at 2014-07-11 21:44:

0

Billboard dynamic size mode?

Anonymous 11 years ago 0
This discussion was imported from CodePlex

robzhu wrote at 2013-07-17 07:07:

First of all, awesome framework. This is all stuff I wish had been included in WPF. Has anyone come up with an easy way to make a billboard scale in size as the camera moves? (i.e. it still always faces the camera, just that it would grow smaller/larger along with the models around it).

objo wrote at 2013-08-08 16:57:

You find the calculation in BillboardGeometryBuilder.GetPositions.
I think you don't need to transform to/from screen space, so this case will be easier.
Use the camera up direction and look direction to find "up" and "right" vectors for the billboard rectangle. Then scale the unit normals by desired width/height in your world space.

PhilDotC wrote at 2014-04-15 08:45:

Robzhu, did you ever get this working as I am struggling with the same task? If so, what is the trick? Or has anyone any additional help they can post.

objo wrote at 2014-04-29 10:28:

We should create an example. I added https://helixtoolkit.codeplex.com/workitem/10040

aueit wrote at 2014-08-15 18:05:

Did someone resolved this problem? PhilDotC, robzhu? I'm trying to do this for weeks, but I can't understand the calculations inside GetPositions.
0

Help Calculating Normals - Sample Code?

Anonymous 11 years ago 0
This discussion was imported from CodePlex

GilbertF wrote at 2012-10-03 22:10:

first thanks for this amaizing tool , i am using mesh builder to create an object made of quads i am passing to the function four points in counter clock  order, this is a laser scanner and i am reading contour to recreated an object, now i have data and an object but it looks bumpy or facet not smooth i need to calculate normals to make it look better,  any help wil be appreciated.

thanks

Gilbert figueroa

orlando, fl


objo wrote at 2012-10-03 22:41:

You don't have to calculate normals, just share vertices for adjacent panels where you want a smooth surface. You will not share vertices when you use the AddQuad method, try to use AddRectangularMesh (if your surface is a 'rectangular mesh') or set the positions and triangle indices yourself!


GilbertF wrote at 2012-10-13 07:49:

Hi Objo

thanks for your last replay i still stock trying to get  a smooth surface im trying to use the addrectangularmesh but no results i was wondering where i can find sample code of the type of data i need to pass to the method it saids it is IList<Point3D>? sample code or sample will be appreciated.

 

thanks

gilbert


objo wrote at 2012-10-14 15:54:

Use "Find usages" function (Shift-F12?) in Visual Studio to find two examples of AddRectangularMesh. The points should be specified 'row by row' and you have to specify the number of 'columns'. Note that the front side of the geometry is defined by the order of the points (reversing the order should reverse the normals).


GilbertF wrote at 2012-10-14 22:54:

Hi Objo and thanks for the replay
Let me add a little more information about what I'm trying to accomplish with the HelixToolkit.

I'm building an application that needs to detect the contour or shape of a hand or foot. This application uses a laser to draw a line on a surface, a hand in this case. We move the laser to a position, then take a snapshot with a camara, analyze the image to detect the X,Y coordinates of the detected red laser line. Then we command the laser to advance a certain distance to a new 'row' (Y coordinate).

What we end up with is a List of rows, technically a List<List<Point3D>>. Our image might be 380 cols by 480 rows. But this list does not contains all the 380x480 points, it just contains the X,Y,Z coordinates of the 'red' laser pixels it detected. As we are advancing the laser 5 or 10 rows at a time we most rows are missing in this collection. Also there can be undetected pixels in each of the rows. So what we have is not a complete collection of X,Y coordinates. And each row might be a different size, etc.

In order to display a more realistic image of the scanned object I'm trying to take this collection of points and plot a smooth surface that interpolates all the missing points from the pixel points we collected from the images.

Below is an excerpt of the different approaches I have taken so far.

First I create the meshBuilder:
MeshBuilder meshBuilder = new MeshBuilder(true, false);

Then we create our points collection and fill it with the data vaules:
List<List<Point3D>> pointsList = new List<List<Point3D>>();
[some code here to fill in the collection]

A- This approach plots a series of small cubes that resemble our scaned hand:
foreach (List<Point3D> pointsRow in pointsList)
foreach (Point3D point in pointsRow)
meshBuilder.AddBox(point, 1, 1, 1);

So that indicates that our points collection is not that far off.

So I'm trying to create a mesh with this points collection by doing this:

Approach #1: (where matrix.maxCols is the width of our image)
meshBuilder.CreateNormals = true;
foreach (List<Point3D> pointsRow in pointsList) {
meshBuilder.AddRectangularMesh(pointsRow, matrix.maxCols);
}

Approach #2: (this will feed a maxCols x maxRows points array with the undertemined values = (0,0,0)
Point3D[,] pointsArray = new Point3D[matrix.maxCols, matrix.maxRows];
foreach (List<Point3D> pointsRow in pointsList)
foreach (Point3D point in pointsRow)
pointsArray[(int)point.X, (int)point.Y] = point;
meshBuilder.AddRectangularMesh(pointsArray);

None of these 2 approaches seems to be working for me and I can't figure out what I'm doing wrong here.
I think it complains about not having the correct number of Normals.
I have also tried to find some examples that uses AddRectangularMesh but no luck so far.
 
Any examples or help in this regard will be greatly appreciated as I'm in an URGENT need to move past this stumble block in order to complete this application.

Thanks in advance!
0

how to read triangle indices from imported model

Anonymous 11 years ago 0
This discussion was imported from CodePlex

jasna100 wrote at 2014-05-20 14:34:

I imported 3d model with helix toolkid. The model is from kinect sensor. The 3d model have parts that are not connected . The object that I scan with the sensor and parts of other objects and the background. How can I read the points and the triangle indices so I can check if they are connected to each other and then create new model just for the object I like.

Any ideas and suggestions?

thanks
0

Beginners Question

Anonymous 11 years ago updated by anonymous 5 years ago 3
This discussion was imported from CodePlex

Patpop01 wrote at 2014-03-22 08:41:

Hi all,

I just downloaded and was trying my first program.

But I have some issues...

I have written following code
<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:helix="http://helixtoolkit.codeplex.com"
    Title="Prova" Height="378" Width="605" 
    WindowStartupLocation="CenterScreen">
    <Grid>
        <helix:HelixView3D IsViewportHitTestVisible="True">
            <helix:HelixView3D.Camera>
                <PerspectiveCamera LookDirection="-10,-10,-10" Position="10,10,10" UpDirection="0,0,1"/>
            </helix:HelixView3D.Camera>
        </helix:HelixView3D>
    </Grid>
</Window>
But I am always getting errors stating :

__The name "HelixView3D" does not exist in the namespace "http://helixtoolkit.codeplex.com".__
__The tag 'HelixView3D' does not exist in XML namespace 'http://helixtoolkit.codeplex.com'.__
The type 'helix:HelixView3D' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
The attachable property 'Camera' was not found in type 'HelixView3D'.

In the project props I added a reference to HelixToolkit and alle HelixToolkit.wpf items.
I am using VS Express 2012 and have the latest Helix 3D Toolkit.

When I use the code of (Wiki Link: [discussion:459092] ) the code builds, but I still get the
__The name "HelixViewport3D" does not exist in the namespace "http://helixtoolkit.codeplex.com".__ error.

Any ideas?

Thx

Mrme wrote at 2014-03-25 10:27:

Hi , use this line instead :
xmlns:helix="clr-namespace:HelixToolkit.Wpf;assembly=HelixToolkit.Wpf"

Patpop01 wrote at 2014-03-26 06:43:

Hi Thanks for the response... But I did already tried that.

However I finally got it working...

First I tried the install the Nuget on VS2012 express... but that didn't work.
I downloaded the source files using the SVN link on the documentation/install page and tried to build, but I always got an error stating the helixtoolkit.csproj was not compatible with my current version.

So Uninstalled the VS2012 and installed the VS2013 express.
Still the same problem when trying to build myself...
But under VS2013 the Nuget worked. Since then I am enjoying this toolkit.

Now my code does not give me any warning or error.
Thx


tdiethe wrote at 2014-05-01 13:06:

FAQ page is empty??

objo wrote at 2014-05-05 14:57:

cache problem? The FAQ page should contain 3 questions.
0

Just need a quick overview

Anonymous 11 years ago 0
This discussion was imported from CodePlex

Rogad wrote at 2013-11-30 16:32:

Hi there,

I'm just starting with WPF and am wanting to work on animating a 3D avatar with morph targets probably. At this stage I am not even sure if WPF is the way to go, but it looks interesting. Previously I have been working on a 2D system that switches frames around to get an animation, but it's a bit limited so I am looking at 3D.

Basically my avatar with be a human head or similar and I would want to animate mouth movements, eyes and things like blinks/smiles. I have the head already built and all the morph targets too.

So my question is, do you think WPF + Helix 3D is going to be worth attempting for my project idea please ?

I see some of your documentation is still in progress. How busy is the project ? I only ask as I fear I may have a lot of questions !

Also in my mind I have an idea forming on a simple morph target system (read that as I found some tutorials and am now ahead of myself!) so I would need to manipulate individual points on a model. This sounds interesting to me to at least try and learn something as I do not know much about coding for 3D manipulation.

Does Helix turn say an .OBJ model into XAML ? How would you control the points/vertices and so on are just a couple of the questions in my mind.

Anyway I have rambled enough, I'd appreciate any of your experienced thoughts on this. Many thanks for your time :)

P.S. on Stackoverflow is where I heard of you...

http://stackoverflow.com/questions/3127753/displaying-3d-models-in-wpf

One of the people there mentioned a tool called 'Deep Exploration' - but I have not been able to find it anywhere on Google, do you happen to know anything about it ?

Thanks !

objo wrote at 2013-12-02 19:52:

  1. Yes, I think you should try WPF3D first, then consider DirectX if performance is not good enough or you need more control over the gpu (shaders, physics etc).
    I like WPF3D because it is so simple and well integrated with WPF, and performance is good enough for most of my needs.
  2. Documentation is high priority, but I don't have any available time to write it myself at the moment...
  3. Yes, this library can read most .obj models and create standard WPF GeometryModel3D objects. You can modify the vertices of the MeshGeometry3D after the model has been loaded
  4. I recommend stackoverflow for general WPF 3D questions, and this forum only for questions about the toolkit. stackoverflow also contains a lot of questions related to this toolkit too, see http://stackoverflow.com/questions/tagged/helix-3d-toolkit?sort=newest
  5. Sorry I don't know anything about Deep Exploration (but google shows: SAP Visual Enterprise Author (formerly Deep Exploration from Right Hemisphere))

Rogad wrote at 2013-12-03 20:07:

I just wanted to say thanks for your reply and that it helps me a lot. I’ll try 3D in WPF and see how it goes. Whatever happens it seems like a good way to learn how to use 3D.

I've had a play with a couple of the demos in Visual Studio 2013. I noticed some did not work, but that could well be me at fault. The two I was really interested in work fine.
0

is there any way to serialize geometries to hard disk?

Anonymous 11 years ago 0
This discussion was imported from CodePlex

behnam263 wrote at 2014-07-21 08:19:

I'm looking for a way to serialize geometries to hard or maybe network. Are there any built in method to do this. should i have another class to serialize geometries?

behnam263 wrote at 2014-07-27 10:06:

I found voxels sample have kind of serialization for models
0

Viewport2DVisual3D Transparency problem

Anonymous 11 years ago 0
This discussion was imported from CodePlex

milosgregor wrote at 2013-08-25 01:51:

Hi. I have one problem. I try to create in code my model. This model consist from three TruncatedConeVisual3D objects (wells) and three Viewport2DVisual3D objects (profiles between wells). See image (https://docs.google.com/file/d/0B5uL6M71wyn4OWx5eGhqWmU5UWs/edit?usp=sharing):



I have problem with the transparency of Viewport2DVisual3D objects. As you see on picture the Viewport2DVisual3D between well PK-1 and PK-2 have the same background color as the background color of HelixViewport3D (white).

the Visual of Viewport2DVisual3D consist from canvas in that are plotted only polygons. The background of canvas and material of Viewport2DVisual3D are set to transparent.

Why is not visible the part of section between well PK-3 and PK-2? How to set it? Here is code for creating the section between wells:
Dim we As New Viewport2DVisual3D
Dim mesh = New MeshGeometry3D()
Dim pos As New Point3DCollection
pos.Add(New Point3D(Well1.X, Well1.Y, Zmax))
pos.Add(New Point3D(Well1.X, Well1.Y, Zmin))
pos.Add(New Point3D(Well2.X, Well2.Y, Zmin))
pos.Add(New Point3D(Well2.X, Well2.Y, Zmax))
mesh.TriangleIndices = New Int32Collection(New Integer() {0, 1, 2, 0, 2, 3})
mesh.TextureCoordinates = New PointCollection(New Point() {New Point(0, 0), New Point(0, 1), New Point(1, 1), New Point(1, 0)})
mesh.Positions = pos
we.Geometry = mesh
Dim material = New DiffuseMaterial(New SolidColorBrush(Colors.Transparent))
Viewport2DVisual3D.SetIsVisualHostMaterial(material, True)
we.Material = material
Dim SectionCanvas As New Canvas
SectionCanvas.Width = (Math.Sqrt(((Well2.X - Well1.X) * (Well2.X - Well1.X)) + ((Well2.Y - Well1.Y) * (Well2.Y - Well1.Y)))) * ScalingFactor
SectionCanvas.Height = (Zmax - Zmin) * ScalingFactor
SectionCanvas.Background = New SolidColorBrush(Colors.Transparent)
For geo As Integer = 0 To Sections3DDefinition(i).Section.SectionSegments.Count - 1
            Dim pol As New System.Windows.Shapes.Polygon
            pol.Stroke = New SolidColorBrush(Colors.Black)
            pol.ToolTip = Sections3DDefinition(i).Section.SectionSegments(geo).GeoID & " - " & Sections3DDefinition(i).Section.SectionSegments(geo).GeoName
            pol.StrokeThickness = 1
            pol.Fill = imgBrush
            For k As Integer = 0 To Sections3DDefinition(i).Section.SectionSegments(geo).TopPoints.Count - 1
                pol.Points.Add(New Point(Sections3DDefinition(i).Section.SectionSegments(geo).TopPoints(k).X * SectionCanvas.Width, Sections3DDefinition(i).Section.SectionSegments(geo).TopPoints(k).Y * SectionCanvas.Height))
   Next
            For k As Integer = 0 To Sections3DDefinition(i).Section.SectionSegments(geo).BottomPoints.Count - 1
                pol.Points.Add(New Point(Sections3DDefinition(i).Section.SectionSegments(geo).BottomPoints(k).X * SectionCanvas.Width, Sections3DDefinition(i).Section.SectionSegments(geo).BottomPoints(k).Y * SectionCanvas.Height))
            Next
        Next
        we.Visual = SectionCanvas
        my3D.Children.Add(we)

objo wrote at 2013-09-05 08:14:

I am not sure if this can be a problem with the Viewport2DVisual3D - but try to use a mesh with an image material instead.
Also note that the sections must be depth-sorted to get transparency (almost) right when rotating the model.
0

Performance

Anonymous 11 years ago updated by anonymous 5 years ago 0
This discussion was imported from CodePlex

stfx wrote at 2012-03-03 07:44:

Hey there, long time no see ;)

You have been doing some great work here though I didnt check the code in detail yet.

One thing that has always been an issue though, not just with this awesome toolkit but rather WPF 3D in general, is performance (atleast compared to directx). Thats why we really need to optimize the code.

Like in HelixViewport3D.cs you should remove the this.Viewport.Children.Contains check in the Add(), Clear(), Remove() functions as this is something which should be checked by the overlaying code. In fact I would even remove them completely since we already have access to Viewport.Children and can add/remove/clear them just as easy (in windowsforms.listview you also add the items like listview1.items.add(...) and not listview1.add(...)).

Also it might we worth considering in general which code should be in the library and which could be added to the examples. For example the headlight seems like a really seldom used feature which slows the viewer down a bit. Probably not noticable but still why not add an handler for camerachanged and export it to the example code. Although I guess its easy enough for anyone to remove it from the code if they so wish.

There are probably more places where performance could be optimized - maybe its even possible that the models that use the same models could somehow not redundantly save the mesh .

Thanks and keep up the good work

 

EDIT: Just out of curiosity how do you compare the performance of the first revs to the current one? Also is your screen line implementation also quite slow compared to usual DirectX line drawings? This was always bothering me with WPF actually. Btw were there any improvements in .net 4.0 for WPF 3D?

EDIT2: I need to have a scene with many models and emissive simple meshes (sphere, box, plane) which can be seen on a screen here: http://code.google.com/p/freelancermodstudio/ which need to be selected (display a bounding box) and then translated, scaled, rotated. I know for a fact that its possible with this toolkit but Would you say using directX approach might be more suitable as in performance?


objo wrote at 2012-03-10 16:02:

Thanks for the feedback! I think you are right, the Add,Clear and Remove methods are not needed. See changelist a79030ea7c0e.

I have not run a profiler on this library lately, but I don't think the 'headlight' feature has any noticable performance impact. 

Using the HelixViewport3D to calculate the total number of triangles will have a performance impact, so this should be used with care.

The line implementation (LinesVisual3D) in this library is of course slow compared to using DirectX LineList primitive, but it should be faster that the other two WPF3D implementations shown in the PointsAndLinesDemo.

If you need to draw a lot of lines (more than 1000 segments) or more control of the shaders, I think you should go for DirectX. The SlimDX library includes a WPF example! 


stfx wrote at 2012-03-11 00:23:

Thanks for your answer.

Btw before I forget:

  • HelixViewport3D:OnApplyTemplate() ... last assert is incorrectly the same as the previous one
  • Viewport3DHelper:FindNearest() ... the 5 lines after
    // first transform the Model3D hierarchy
    
    seem to break correct detection of clicked visual for me

 

  • Also Resharper notices some small coding issues which might be worth looking into

 

Right now I am struggling to correctly use the LinesVisual3D class (cant seem to find out the correct points). I was delighted when I first noticed the  BoundingBoxVisual3D.cs file thinking that this one would create those screen space lines around an object until I found out that its just some tubes being aranged like a boundingbox :D


objo wrote at 2012-03-11 20:46:

OnApplyTemplate fixed, thanks!

Let me know if you find the bug in Viewport3DHelper:FindNearest!

Yes, I try to keep the Resharper/Stylecop status on 'green'. Viewport3DHelper and HelixViewport3D seems to be ok, but I am sure there are warnings in other classes. Please report if you see some bugs.

Yes, BoundingBoxVisual3D is using cylinders - I made that class before making the LinesVisual3D. Should add a property where you can select between lines or cylinders.


stfx wrote at 2012-03-11 22:23:

Well commenting out the 5 lines after that comment fixed the FindNearest function for me ;)

Hm I would rather replace the functionality in BoundingBoxVisual3D as I think nobody would use cylinders for something like that :P

Other than that I only found some code styling issues which dont affect anything like why are your comments in the functions in MeshBuilder.cs commented out twice? Also in MeshBuilder.AddTriangeStrip() the  wikipedia link exists twice.


objo wrote at 2012-04-05 02:08:

Could the error be in GetTransform(Visual3D, Model3D)? Can you create a small example model where the current implementation fails?

I have tested with the stick figure in ExportDemo (this contains lots of Model3D transforms), and it seems to work ok here (double click on the 'fingers', and you see the target point will be set correctly).

Bounding box with lines - I added this issue http://helixtoolkit.codeplex.com/workitem/9950

Thanks, the MeshBuilder wiki-link comments will be fixed in the next code push. I use "////" when I don't want resharper to reformat comment 'figures'.


peterthesaint wrote at 2014-07-25 12:44:

Hello !!!

It is my first post here. Thanks for your great work !!!

Previously in my model I was using ScreenLinesVisual3d.
Now I noticed new Helix version allows LinesVisual3d and I was wondering whether you have implemented changes suggested in this link:
http://www.ericsink.com/wpf3d/1_ScreenSpaceLines3D_Performance.html

Regard,
Peter