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

Orthographic Camera - Undesired Clipping on Zoom In (Near Plane Issues?)

Anonymous 12 years ago 0
This discussion was imported from CodePlex

ezolotko wrote at 2013-08-02 04:28:

Hi,

Thank you for the great library.
I have successfully used the orthographic camera to display my scene, but with one problem:
when I zoom in my scene by moving the mouse wheel forward, I encounter the polygons clipping like it is shown in the picture:


I tried to reduce the camera near plane distance, but with no noticeable effect. Here is my camera definition:
            Camera = new OrthographicCamera
            {
                LookDirection = new Vector3D(-398.987, -42.626, -19.482),
                UpDirection = new Vector3D(-0.049, -0.001, 0.999),
                Position = new Point3D(398.987, 42.626, 19.482),
                Width = 235,
            };
Am I doing anything wrong?

ezolotko wrote at 2013-08-05 03:03:

My latest experiments showed that if I use "Zoom to mouse point" selection method, and there is a polygon under the mouse pointer, the issue seem to stop reproducing. I think this somehow may be related to use of GetNearestPoint method to calculate the camera target in this case, so the camera view matrix gets recalculated in more suitable way. Still have no exact thoughts how to fix the issue concisely.

ezolotko wrote at 2013-08-06 04:03:

Finally, I ended up using CameraHelper.LookAt to position the camera and OrthographicCamera.Width to zoom - manually, it doesn't produce the effects the CameraController does.

Mrme wrote at 2013-08-06 10:09:

So , are there any changes to be submitted to the source code ?

ezolotko wrote at 2013-08-06 10:17:

@Mrme: no, I just used the library the other way to workaround my issue.

ShadesJeff wrote at 2013-09-24 23:02:

I can recreate this issue with the Camera example shipped with the toolkit. It happens with both zoom and rotation.

To reproduce, open the Camera demo, then switch to the Orthographic mode. Do some random zooming and rotating and you should be able to get it into a mode where the clipping is incorrect. In my trials, it seems that the incorrect clipping only affects the top and bottom regions, it does not appear to clip incorrectly on the left or right.

Sometimes the incorrect clipping is dynamic, e.g. the clipping line will move as you rotate the model whereas other times it is fixed.

objo wrote at 2013-09-25 08:59:

Did you try changing the NearPlaneDistance?
The near plane distance should not be changed when zooming or rotating.
Currently the near plane distance is copied when the user change from perspective to orthographic, maybe this code should be removed.

objo wrote at 2013-09-26 22:40:

The problem could also being related to the Position of the camera being too close to the model. The camera controller uses Position+LookDirection to define the target point that the camera rotates around. Maybe the problem is related to the length of LookDirection being changed when toggling between perspective and orthographic camera...
Set ShowCameraInfo = true on the HelixViewport3D to review the settings of the camera.

ShadesJeff wrote at 2013-09-26 22:47:

Hi objo,

That's essentially was the problem - I had universally specified my look directions as unit vectors, when in fact they need to be scaled to world units in order for the view to function correctly. I still think there is an issue when changing between orthographic and perspective projections (field of view explodes), but I cannot reliably recreate it.

objo wrote at 2013-09-27 11:12:

In orthographic mode try to press "S" to move away from the target, or "W" to move closer.
Maybe zooming in orthographic mode should change the CameraPosition and LookDirection in the same way as for perspective camera.

rinaldin wrote at 2013-10-03 22:14:

@objo and @ezolotko
so what's the solution? Pressing "S" in my case solved the problem, but I just want to prevent the clipping happening.
From this:
Finally, I ended up using CameraHelper.LookAt to position the camera and OrthographicCamera.Width to zoom - manually, it doesn't produce the effects the CameraController does.
How can I leave the default mouse control and ovverride the Zoom function? Sorry, but it is not clear to me.

Giovanni

rinaldin wrote at 2013-10-25 22:27:

I finally solved changing the Helix source code in the file ZoomHandles.cs at line:
var newRelativePosition = relativePosition * (1 + delta);
changing it to:
var newRelativePosition = relativePosition * (1.1 + delta);
No more clipping and no need to use LookAt.

wangzh wrote at 2014-07-24 04:56:

rinaldin wrote:
I finally solved changing the Helix source code in the file ZoomHandles.cs at line:
var newRelativePosition = relativePosition * (1 + delta);
changing it to:
var newRelativePosition = relativePosition * (1.1 + delta);
No more clipping and no need to use LookAt.
rinaldin,

I have the same issue when I use the latest Helix version. I checked the source codes and didn't find the ZoomHandles.cs file. Only ZoomHandler.cs found. Is it same file? Also, I didn't find the code
var newRelativePosition = relativePosition * (1 + delta); 
in the file ZoomHandler.cs.


Any comment and suggestion to resolve the problem?


Thanks in advance!

rinaldin wrote at 2014-07-24 19:46:

Yes, the file is ZoomHandler.cs, it was a typing mistake. Anyway, I noticed that in the later version of Helix Toolkit that code changes and it is written in a different way. I used the version helixtoolkit_f5a96293a071.

wangzh wrote at 2014-07-25 02:42:

rinaldin wrote:
Yes, the file is ZoomHandler.cs, it was a typing mistake. Anyway, I noticed that in the later version of Helix Toolkit that code changes and it is written in a different way. I used the version helixtoolkit_f5a96293a071.
rinaldin,

Thanks for your reply. I found the latest revision changed from:
 var newRelativePosition = relativePosition * (1 + delta);
 var newRelativeTarget = relativeTarget * (1 + delta);
to
 var f = Math.Pow(2.5, delta);
 var newRelativePosition = relativePosition * f;
 var newRelativeTarget = relativeTarget * f;
The latest version still has the same issue. It is a great library. However, I am stuck in this step. Since I am new in WPF, I am wondering if you could send me correct HelixToolkit.Wpf.dll to me it will be greatly appreciated.
my email: wangzh2000@yahoo.com

wangzh wrote at 2014-07-25 15:49:

I finally figured out the problem in other way as follows:
 public MainWindow()
        {
            InitializeComponent();
            resetZoom();
         }
Then write resetZoom()
private void resetZoom()
        {
            OrthographicCamera myOCamera = new OrthographicCamera(new Point3D(0, 0, 0), new Vector3D(100000, 100000, -100000), new Vector3D(0, 0, 1), 5000);
            ViewPort.Camera = myOCamera;
            
        }
Each time, when creating a model, using ZoomExtents() at the end of method, for instance:
double z1 = 0;
double h = 500;
        private void cylinder_Click(object sender, RoutedEventArgs e)
        {
            PipeVisual3D pipe = new PipeVisual3D();
            pipe.Point1 = new Point3D(0, 0, z1);
            pipe.Point2 = new Point3D(0, 0, z1+h);
            pipe.Material = Materials.LightGray;
            pipe.Diameter = 1200;
            pipe.InnerDiameter = 1180;
            z1 += h;
            SolidModels.Children.Add(pipe);
            ViewPort.ZoomExtents();
        }
I am a green bee in WPF and C#, any education and new simple way in the issue sharing will be greatly appreciated.

This WPF library package is great. Thanks objo for this work!!!


Cheers,
0

CREATE CURVED PANELS

Anonymous 12 years ago 0
This discussion was imported from CodePlex

esi wrote at 2013-10-18 15:30:

Hi,
I would like to create a curved surface to join two Cube faces together.
is this possible with helix3dToolKit?
I tried with AddExtrudedGeometry and AddLoftedGeometry but I didn't understand the right way to use them.

Did someone used those methods?

Thank You in advance for help

Regards
0

how do i use doublekeydictionary in my unity project?

Thomas Clifton Olivent 12 years ago 0
I've downloaded the master file, but aside from that, I have no idea where to place it or what to do with it.
0

How to get a element/object and then rotate it?

Anonymous 12 years ago 0
This discussion was imported from CodePlex

musicxpg wrote at 2013-03-20 04:35:

I made a 3d model in 3dmax. There is a fan in the model. I want to rotate the fan. There are some questions:
  1. How can I get handler of the fan? I named the fan in the 3ds file. Can I get the handler?
  2. How can I rotate it? There are two examples in Helix, however, the elements were generated in the examples, other than from 3ds file.
  3. How can I change the color of the fan using Helix?
Thanks again for this amazing toolkit. And many many thanks to Objo!

Regards,
Young
0

Manipulation Events on a HelixViewport3D

Anonymous 12 years ago 0
This discussion was imported from CodePlex

JohnSourcer wrote at 2012-12-10 12:50:

Hi All,

I've created a HelixViewport3D which contains a SphereVisual3D. I'm trying to capture manipulation events on it. Does anybody know if this is supported?

HV3D.ZoomExtentsWhenLoaded = true;
HV3D.Viewport.IsManipulationEnabled = true;
HV3D.Viewport.ManipulationStarting += Viewport_ManipulationStarting;
Never fires but TouchDown events fire on HV3D. Does anyone have any guidance on this?


JohnSourcer wrote at 2012-12-10 13:32:

Apols, this has something to do with it being in a Scatterview.


nsousa wrote at 2013-04-04 18:47:

I have the same problem.

Manipulation events don't work inside a ScatterViewItem.

Anyone has a solution to this problem?

objo wrote at 2013-04-15 12:47:

Is this related to the Surface SDK? Do I need Surface hardware to reproduce this?

nsousa wrote at 2013-04-15 12:54:

Yes, it's related to the Surface SDK.

No, you don't need to have Surface hardware.
You can use the Input Simulator (available in the Surface SDK) to reproduce it.

http://msdn.microsoft.com/en-us/library/ff727911.aspx
0

Is it possible to find distance between camera and a mesh?

Anonymous 12 years ago 0
This discussion was imported from CodePlex

behnam263 wrote at 2014-07-25 21:00:

I need to know that is it possible to measure distance between camera position and mesh position?(for example camera position to center of mesh)

BogusException wrote at 2014-07-25 21:31:

@behname263,

If you mean the center of the mesh, there has to be at least 2 ways to use the mesh center as origin and camera position in 3d in a simple trig function... as in this example...

Or are you talking about the nearest point/vertices to the camera?

This may help as well, not knowing the actual issue: Fitting view with perspective camera
0

How to limite camera zoom In/Out

Anonymous 12 years ago 0
This discussion was imported from CodePlex

Moez_rebai wrote at 2014-07-18 12:24:

I'm trying to visualize a mesh using Helix 3D, it works fine, the only problem i got is how to limite the HelixViewport3D camera zoom. In fact, sometimes my model disappear when i zoom in or out.

Before Zoom :


After Zoom


Any idea how can i solve that issue
Regards,

everytimer wrote at 2014-07-18 20:54:

Have you tried PerspectiveCamera instead of Orthographic one?
0

How to control the trackball via code?

Anonymous 12 years ago 0
This discussion was imported from CodePlex

zoras1986 wrote at 2013-04-21 23:25:

Hello everyone,
i'm starting my project from the contour demo samples of this awesome tool, but i cannot figure out how to control the trackball (don't know if is right call it like this, i mean the cude with the face "L, B, U, R, S..") by code in a wpf application (so c#). i can't figure out if it's something about the camera (view1.SetView(...)). or the model (model1.transform(...))
can someone help me?
a little piece of code
   <ht:HelixViewport3D x:Name="view1" Camera="{ht:PerspectiveCamera 5.3,-12.3,3.3,-6.3,11,-6.6}" CameraChanged="view1_cameraChanged" ShowCameraInfo="True"  Margin="0,71,0,0">
        <ht:SunLight/>
        <ht:FileModelVisual3D x:Name="model1" Source="D:/MARCO/Onthebrain/WPF - 3D - Kinect/Contour sample di Helix/Contour_demo/Contour_demo/bin/Debug/Astronaut.3ds"/>
    </ht:HelixViewport3D>
inside a grid...
in the .cs file i want to simulate the "right mouse click + mouse movement" input, as in the example, but in code...
thanks!
0

GridLinesVisual3D

Anonymous 12 years ago 0
This discussion was imported from CodePlex

murray_b wrote at 2012-05-10 04:35:

Hi Objo

Can I please request you make widthDirection propery public on this class like the lengthDirection.

I would like to use it for placement of labels at all the grid intersections.

Thanks

Murray


murray_b wrote at 2012-05-10 05:01:

Actually don't worry. Another day of stupidity for me

I just found your code

 this.widthDirection = Vector3D.CrossProduct(this.Normal, this.lengthDirection);



0

How to Draw a Funnel

Anonymous 12 years ago 0
This discussion was imported from CodePlex

AQSRanck wrote at 2014-06-25 02:38:

I wonder if anyone could suggest an approach to drawing a funnel?

objo wrote at 2014-06-25 09:55:

See the usage of MeshBuilder.AddSurfaceOfRevolution in the example Source\Examples\WPF\ExampleBrowser\Examples\BuildingDemo\SiloVisual3D.cs, I think a similar approach can be used to model a funnel.

AQSRanck wrote at 2014-06-25 13:59:

Thank you very much. I have been using Helix for several months in an application that is designed for the residential construction market. I would rather not publish the results yet but if you would send me a direct email, I will share a number of screen shots with you. I am most grateful for your work and "brag" about both Caliburn Micro and Helix (which are both in the same class of excellence) at each of the Microsoft meetings that I attend.

Bob

AQSRanck wrote at 2014-06-26 04:15:

Hello objo,

Thank you for your suggestion, I should not have much trouble creating a FunnelVisual3D. But I have hit a real snag. I work in VB rather than C# so I need to write my own version of theSiloVisual3D. However, I don't understand the lambda contained in the Dependency property, shown below.
public static readonly DependencyProperty DiameterProperty =
      DependencyPropertyEx.Register<double, SiloVisual3D>("Diameter", 40, (s, e) => s.AppearanceChanged());
My version for VB will look about like this: (However the lambda is not quite right)
Public Shared ReadOnly DiameterProperty As DependencyProperty =
     DependencyPropertyEx.Register(Of Double, SiloVisual3D)("Diameter", 40, Function(s, e) s.AppearanceChanged())
I'm not asking for you to fix my code, but rather to help me understand the C# version, so that I can fix the VB version myself.

Once I master SiloVisual3D (in VB) I fully expect to create an entire library of specialized visuals for my needs, so getting past this snag is kind of important for me.
Now that I see this example from Building Demo, the funnel shape should not be to hard.

Bob

objo wrote at 2014-06-26 05:43:

Sorry I don't know how to write the lambda in VB.
But you could change to standard dependency property registration with DependencyProperty.Register, see http://msdn.microsoft.com/en-us/library/ms750428(v=vs.110).aspx
Make sure you add the property changed calback to the metadata.

RobPerkins wrote at 2014-06-26 17:15:

Bob,

Try:
Public Shared ReadOnly DiameterProperty As DependencyProperty =
     DependencyPropertyEx.Register(Of Double, SiloVisual3D)("Diameter", 40, Sub(s, e) s.AppearanceChanged())
(because the lambda is supposed to be a function returning "void" (in C# terms) and in VB, that's represented with a Sub() lambda instead of a Function() )

AQSRanck wrote at 2014-06-26 17:45:

DOH!
Would you believe that I spent the better part of a day because I forgot that rule.
Thank you very much Rob