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

Helixtoolkit BoxVisual3D

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

Irfan_Maulana wrote at 2014-01-07 14:37:

hi everyone i want to create cubes that represented as point3D(x,y,z) and the value is represented as color..
I have tried to create some cubes with height=21cube width = 21 cube and length 21 cube, but the result is not quite good
because when I navigate the cubes, the motion of the cubes is so lag, (the code is shown below).
public MainWindow()
        {
            InitializeComponent();
            
            // Upper 
            for (double i = -10; i <= 12; i = i + 1.1)
            {
                for (double j = -10; j <= 12; j = j + 1.1)
                {

                    BoxVisual3D box = new BoxVisual3D() { Center = new Point3D() { X = i, Y = j, Z = 12 }, Fill = Brushes.DarkKhaki };
                    view3DHelix.Children.Add(box);
 

                }
            }
            //Bottom 
            for (double i = -10; i <= 12; i = i + 1.1)
            {
                for (double j = -10; j <= 12; j = j + 1.1)
                {

                    BoxVisual3D box = new BoxVisual3D() { Center = new Point3D() { X = i, Y = j, Z = -10 }, Fill = Brushes.DarkKhaki };
                    view3DHelix.Children.Add(box);
                }
            }

            //Right
            for (double i = -10; i <= 12; i = i + 1.1)
            {
                for (double k = -8.9; k <= 12; k = k + 1.1)
                {

                    BoxVisual3D box = new BoxVisual3D() { Center = new Point3D() { X = i, Y = 12, Z = k }, Fill = Brushes.DarkKhaki };
                    view3DHelix.Children.Add(box);
                }
            }
            //Left
            for (double i = -10; i <= 12; i = i + 1.1)
            {
                for (double k = -8.9; k <= 10.9; k = k + 1.1)
                {

                    BoxVisual3D box = new BoxVisual3D() { Center = new Point3D() { X = i, Y = -10, Z = k }, Fill = Brushes.DarkKhaki };
                    view3DHelix.Children.Add(box);
                }
            }
            //Front
            for (double j = -8.9; j <= 10.9; j = j + 1.1)
            {
                for (double k = -8.9; k <= 12; k = k + 1.1)
                {

                    BoxVisual3D box = new BoxVisual3D() { Center = new Point3D() { X = 12, Y = j, Z = k }, Fill = Brushes.DarkKhaki };
                    view3DHelix.Children.Add(box);
                }
            }
            //Behind
            for (double j = -8.9; j <= 10.9; j = j + 1.1)
            {
                for (double k = -8.9; k <= 12; k = k + 1.1)
                {

                    BoxVisual3D box = new BoxVisual3D() { Center = new Point3D() { X = -10, Y = j, Z = k }, Fill = Brushes.DarkKhaki };
                    view3DHelix.Children.Add(box);
                }
            }

        }
anyone have any idea for a better result?

objo wrote at 2014-01-07 22:51:

You can improve performance by grouping all cubes that share the same material in a GeometryModel3D. Use the HelixToolkit.Wpf.MeshBuilder to create a MeshGeometry3D of the cubes. You can then group all the models in a Model3DGroup and add it to a ModelVisual3D.

I also recommend reading
http://msdn.microsoft.com/en-us/library/bb613553(v=vs.110).aspx
http://blogs.msdn.com/b/johngossman/archive/2005/10/13/480748.aspx

AnotherBor wrote at 2014-01-10 07:51:

Something just came to my mind.
What if I add cubes (by add rectangular mesh or other method) to one MeshBuilder, add a linear gradient brush based material to the model and assign texture coordinates to every single cube in a way to apply the color I need?
It all would then count as one mesh, but "separate" cubes could have different colors.
I wonder if that would work?

objo wrote at 2014-01-10 09:03:

Yes, this works and I think performance should be much better. I have not tested if there is a performance hit related to assigning texture coordinates or not and gradient brush vs. solid color brush - that would be interesting to know!

AnotherBor wrote at 2014-01-10 09:15:

If it really works nice, maybe adding single texture coordinate to all convenience calls as optional parameter would be a nice way to assign different colors to elements belonging to the same mesh?

Then we would have calls like MeshBuilder.AddTube( {point1, point2}, width, segments, cap, uniformTextureCoordForTheWholeTubeMesh) , what do you think?

objo wrote at 2014-01-10 09:38:

Yes, I think this is a good idea. Can you add an issue on this?

AnotherBor wrote at 2014-01-10 09:54:

Sure, will do.
0

SharpDX fork no BackMaterial property in MeshGeometryModel3D

Anonymous 11 years ago 0
This discussion was imported from CodePlex

Lolipedobear wrote at 2014-03-05 14:27:

Didn't find BackMaterial property in MeshGeometryModel3D. Back side of the polygon is black - is there any solution to apply texture to it? Tried to add additional points with inversed normals, but polygons overlap when displayed, so that color from the back side of polygon is also visible.

geoarsal wrote at 2014-03-12 18:49:

Today I face the same issue with meshbuilder and following is the code I used to create duplicate triangles. Here mb is the meshbuilder class.
            var copytri = new int[mb.TriangleIndices.Count];
            mb.TriangleIndices.CopyTo(copytri);
            Array.Reverse(copytri);

            var copynorm = new Vector3[mb.Normals.Count];
            for (int i = 0; i < copynorm.Length; i++)
                copynorm[i] = -1 * mb.Normals[i];
            
            mb.Append(mb.Positions.ToArray(), copytri, copynorm, mb.TextureCoordinates.ToArray());

Lolipedobear wrote at 2014-03-14 06:23:

Thanks for your reply. I tried to do the same thing manually. Sometimes polygons overlaps and scene glitches when i try to scale or rotate. In WPF branch i had the same problem and it was resolved by setting NearPlaneDistance in camera. Possible, I made a mistake. Did you try your solution for large scenes (1000 or more units)?

geoarsal wrote at 2014-03-14 08:07:

I had used that approach to render mesh surface consisiting of more than 200,000 triangles, and I haven't faced the overplap issue. However for some cases, i have to reverse the original normals prior to creating their copy, may be thats the issue your facing. Also, i had set NearPlaneDistance to 0.5 and FarPlaneDistance to 10000.
var copynorm = new Vector3[mb.Normals.Count];
for (int i = 0; i < copynorm.Length; i++)
{
         mb.Normals[i] *= -1;
         copynorm[i] = -1 * mb.Normals[i];
}
Hope that will help you with your issue.

P.S. Reversing the original normal was required when your building triangles using Right Hand Rule (WPF approach) instead of using Left Hand Rule (DirectX/SharpDX approach)
0

Demo Of a 3D Editor Using Helix Tookit + Augmented Reality

Anonymous 11 years ago 0
This discussion was imported from CodePlex

Raathigesh wrote at 2013-04-18 14:41:

Hi Everyone,
I'm Raathigeshan Kugarajan following a Software Engineering (BEng) degree program conducted by Informatics Institute of Technology affiliated with University of Westminster, UK.
I am currently in the progress of evaluating a tool targeting desktop devices which helps novice users to create 3D visuals and present them using marker-less augmented reality.

Your feedback and comments on this research will help to improve it further.

Video Demonstration Of the Prototype - http://www.youtube.com/watch?v=TH5LD4FMK68

Feedback Form - http://edu.surveygizmo.com/s3/1220975/User-Evaluation

objo wrote at 2013-04-18 15:01:

Great demo! It's exciting to see that you based it on the helix toolkit. Nice user interface!
Is the application also available for testing?
ps. The earth texture seems to be flipped!

Raathigesh wrote at 2013-04-18 20:39:

Thank You for your feedback and the wonderful helix toolkit. Unfortunately the application is still not available for testing. I'll update you once the application is available for testing. Thank you for pointing out the texture issue. I will correct it.

Best Regards,
Raathigeshan.

detp wrote at 2013-12-12 19:56:

Hi Raathigeshan

How is the project going? Nice user interface, did you base it on something currently in the market?
Is it ready for testing?

Regards
0

Import Model From FileStream or Stream... [Solved]

Anonymous 11 years ago 0
This discussion was imported from CodePlex

ysinotelodigo wrote at 2012-05-01 03:11:

Hey,

I want to load or import model from stream in C#... I have played with this library and I did it.

 

        <helix:HelixViewport3D Background="AliceBlue"  ShowViewCube="False" Name="Pantallazo">
                <helix:DefaultLights/>
          <helix:FileModelVisual3D Source="Ferarri40.3ds" >
                <helix:FileModelVisual3D.Transform>
                    <ScaleTransform3D ScaleY="0.01" ScaleX="0.01" ScaleZ="0.01"/>
                </helix:FileModelVisual3D.Transform>
            </helix:FileModelVisual3D>
        </helix:HelixViewport3D>

In code-behind is this...

FileModelVisual3D a = new FileModelVisual3D();
a.Source = "Ferarri40.3ds";
ScaleTransform3D b = new ScaleTransform3D(0.05, 0.05, 0.05);
a.Transform = b;
Pantallazo.Children.Add(a);
//Pantallazo is the name of HelixViewPort3D
 

But I need read the 3ds from stream because the model will come from DataBase I did it...
But I don't know how I go on...

FileStream c = new FileStream("Ferarri40.3ds", FileMode.Open, FileAccess.Read, FileShare.Read);  
FileModelVisual3D d = new FileModelVisual3D();
d.Source = ¿¿?? //HELP!!
Pantallazo.Children.Add(d);

 

This library is nice!


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

The FileModelVisual3D cannot be bound to a stream.

Create a "StudioReader" instance, and use the Read(Stream) method. The result is a Model3D you can bind to the Content of a ModelVisual3D!

http://msdn.microsoft.com/en-us/library/system.windows.media.media3d.modelvisual3d.content.aspx


ysinotelodigo wrote at 2012-05-06 19:01:

Hello,

Thank you, very much for your answer. But I have several questions, I'm sorry for I am new and I don't speak english well.

My final objective is that my application can put and remove 3d model. This model will be in 3ds or obj format. (Perphaps en 3ds because it has a texture). So that I decided add and remove children...

I understand that I have create a "StudioReader" class with a method called Read(stream) for example. And the result will be a System.Windows.Media.Media3D.Model3D But, How could I transform this stream (in 3ds) to Model3D?

Thank you!


objo wrote at 2012-05-07 17:57:

Yes, you have to create an instance of the StudioReader class, and use the read method.

If your 3d viewport contains the following element (defined in xaml)

<ModelVisual3D Content="{Binding MyModel}"/>

you can import your stream by

var reader = new StudioReader();
this.MyModel = reader.Read(myStream);

this requires the MyModel property to be defined in your data context (ViewModel)

public Model3D MyModel { get; set; }

Your data context (ViewModel) should also implement INotifyPropertyChanged, then you can simply write

this.MyModel = null;

 to remove the model again.

http://msdn.microsoft.com/en-us/library/system.windows.media.media3d.modelvisual3d.aspx

http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspx


objo wrote at 2012-05-07 17:58:

Note that if you want to use textures, the StudioReader only supports reading these from files at the moment - not from streams...


ysinotelodigo wrote at 2012-05-16 00:36:

Sorry to disturb again.

I tried to follow your instrutions but I don't know how i go on...

I created this .xaml

 

<Window x:Class="WpfApplication7.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:local="clr-namespace:WpfApplication7"
        Title="MainWindow" Height="350" Width="525">
    <Window.DataContext>
        <local:MainWindowViewModel/>
    </Window.DataContext>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Label Content="{Binding Texto}"/>
        <Viewport3D Name="myViewport" Grid.Row="1">
            <Viewport3D.Camera>
                <PerspectiveCamera Position="0,0,500" />
            </Viewport3D.Camera>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <DirectionalLight Color="#FFFffFFF" Direction="-3,-4,-5" />
                </ModelVisual3D.Content>
            </ModelVisual3D>
            <ModelVisual3D Content="{Binding MyModel}"/>
        </Viewport3D>

    </Grid>
</Window>

 

And this ViewModel:

 

using System.Text;
using System.Windows.Media.Media3D;
using HelixToolkit;
using System.IO;

namespace WpfApplication7
{
    class MainWindowViewModel
    {
        public MainWindowViewModel()
        {
           Texto = "Prueba";

           var reader = new StudioReader();
           // This works well.
           //MyModel = reader.Read("Ferarri40.3ds");

           // But, I need that (Stream come from DataBase)
           // Why does it work?
            Stream myStream = new FileStream("Ferarri40.3ds", FileMode.Open, FileAccess.Read, FileShare.Read);
            MyModel = reader.Read(myStream);
        }

        public String Texto { set; get; }
        public Model3D MyModel { get; set; }
    }
}

 

I don´t know why it doesn't work?

I want to add that my application has to add and remove several model... I''ve been learned MVVM... if you could say the steps, I would appreciate it.

Thank you very much



objo wrote at 2012-05-31 22:35:

I see, the reader didn't know where to look for the textures and was throwing an exception since TexturePath was null. Add the following line

            reader.TexturePath = @"directoryofyour3dsmodel";

I am checking in a fix! 


ysinotelodigo wrote at 2012-06-01 11:07:

Thank you, very much!

Your indications have been userful.

Here, I have copied my code for other persons....

MainWindows.xaml

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:helix="clr-namespace:HelixToolkit;assembly=HelixToolkit"
        xmlns:local="clr-namespace:WpfApplication1"
        Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
    <Window.DataContext>
        <local:MainWindowViewModel/>
    </Window.DataContext>
    <Grid>
        <helix:HelixViewport3D Background="AliceBlue"  ShowViewCube="False" Name="Pantallazo">
            <helix:DefaultLights/>
            <ModelVisual3D Content="{Binding MyModel}">
                <ModelVisual3D.Transform>
                    <ScaleTransform3D ScaleY="0.05" ScaleX="0.05" ScaleZ="0.05"/>
                </ModelVisual3D.Transform>
            </ModelVisual3D>
        </helix:HelixViewport3D>
    </Grid>
</Window>

MainWindowViewModel.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PFG;
using System.Windows.Media.Media3D;
using System.IO;
using HelixToolkit;

namespace WpfApplication1
{
    public class MainWindowViewModel : BaseINPC
    {
        public MainWindowViewModel()
        {
            FileStream c = new FileStream("Ferarri40.3ds", FileMode.Open, FileAccess.Read, FileShare.Read);
            var reader = new StudioReader();
            reader.TexturePath = ".";
            MyModel = reader.Read(c);
        }

        private Model3D mymodel;
        public Model3D MyModel
        {
            get
            {
                return mymodel;
            }
            set
            {
                mymodel = value;
            OnPropertyChanged("MyModel");
            }
        }
    }
}

Sorry to be disturb.

 

0

Importing Mesh & Calculating Normals

Anonymous 11 years ago 0
This discussion was imported from CodePlex

alexalthauser wrote at 2012-04-07 02:36:

I am loading a model with borrowed code from the Helix Modelviewer example. The imported 3D model is called _currentModel. How would I go about getting the normals from the vertices in this new model?

Thanks,

-Alex


objo wrote at 2012-04-08 01:13:

you have to traverse the Model3D hierarchy and find all GeometryModel3D objects. Then read the Normals property from the MeshGeometry3D objects referenced in the Geometry properties. See the HelixToolkit.Wpf.Visual3DHelper.Traverse methods, this should make it very easy to traverse the model. 


alexalthauser wrote at 2012-04-12 01:57:

I'm trying to use the traverse method, but I'm not sure how it works. I tried:

Visual3DHelper.Traverse<T>(model3d);

with no success.  is there a tutorial somewhere?

So far I have the importer working like a charm, but I need to get to the vertex, triangle indexes, and normal information. It's strange that such useful data wouldn't be readily accessible from an imported model. I suppose there's a good reason for it?


alexalthauser wrote at 2012-04-12 21:12:

I came across this code while searching the web, it seems to do the trick.

GeometryModel3D gm3d = ModelVisualObjects.Content as GeometryModel3D;
MeshGeometry3D mesh = gm3d.Geometry as MeshGeometry3D;


objo wrote at 2012-04-14 00:05:

Right, you'll get the mesh as you show in the last posting.

You need to pass an Action<GeometryModel3D,Transform3D> to the Traverse methods, the following example should show how you could access the Positions collection of all meshes in the model:

int countVertices = 0;
Visual3DHelper.TraverseModel<GeometryModel3D>(yourModel, (geometryModel,transform) => 
  { 
    var mesh = (MeshGeometry3D)geometryModel.Geometry;
    countVertices += mesh.Positions.Count; 
  });

alexalthauser wrote at 2012-04-14 00:31:

I spoke too soon. Actually,

GeometryModel3D gm3d = ModelVisualObjects.Content as GeometryModel3D;
MeshGeometry3D mesh = gm3d.Geometry as MeshGeometry3D;

returns null.

 

// Open document
                string filename = dlg.FileName;
                // Load 3DModel
                CurrentModel = ModelImporter.Load(filename); //loads as a modelgroupobject
                modelgroupobjects.Children.Add(CurrentModel);
                ModelVisualObjects.Content = modelgroupobjects;
                
                GeometryModel3D gm3d = ModelVisualObjects.Content as GeometryModel3D;
                MeshGeometry3D mesh = gm3d.Geometry as MeshGeometry3D;

and I tried the code you posted

int countVertices = 0;
                Visual3DHelper.TraverseModel(CurrentModel, (geometryModel, transform) =>
                {
                    var mesh = geometryModel.Content as GeometryModel3D;
                    countVertices += mesh.Positions.Count;
                }); 

and I get an error underlying Visual3DHelper.TraverseModel that states: Error 2 The type arguments for method 'HelixToolkit.Visual3DHelper.TraverseModel (System.Windows.Media.Media3D.Model3D, System.Action)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

I appreciate your help.


objo wrote at 2012-04-14 00:49:

Sorry for the bugs in the example (I corrected the code).

Here is a unit test that works:

        [Test]
        public void Load_Test_ValidNumberOfVertices()
        {
            var model = ModelImporter.Load(@"Models\obj\test.obj");
            int countVertices = 0;
            Visual3DHelper.TraverseModel<GeometryModel3D>(
                model,
                (geometryModel, transform) =>
                {
                    var mesh = (MeshGeometry3D)geometryModel.Geometry;
                    countVertices += mesh.Positions.Count;
                });

            Assert.AreEqual(8, countVertices);
        }

alexalthauser wrote at 2012-04-14 01:13:

Works Great, Thanks!

              ( o )o)
             ( o )o )o)
           (o( ~~~~~~~~~o
           ( )' ~~~~~~~~'
           ( )|)        |-.
             o|         |-. \
             o|         |  \ \
              |         |
             o|         |  / /
              |         |." "
              |         |- '
              .=========. 
0

ElementSortingHelper.cs help

Anonymous 11 years ago 0
This discussion was imported from CodePlex

Rogad wrote at 2014-02-23 02:08:

I'm having some issues with overlapping transparent layers.

After a long search I eventually found that I need to order my rendering.

Objo, I found this ElementSortingHelper.cs file and it's similar to other scripts I have seen.

I was wondering if this was a stab at ordering the rendering so that transparent textures get rendered in the right order.

Could you give me an example of how to use it please if that is what it does ?

I see this in the code :
public static void AlphaSort(Point3D cameraPosition, Model3DCollection models, Transform3D worldTransform)
I am stuck on what to use for 'worldTransform'.

My Helix Viewport is called 'myView' and I can get as far as :
Visual3DCollection mymodels = (Visual3DCollection)myView.Children;
ElementSortingHelper.AlphaSort(myView.Camera.Position, mymodels, ???)
But what should go in the '???'

Thanks for taking a look :)

Rogad wrote at 2014-02-23 14:58:

In case it helps here is my code for my Helix View port...
        <Grid HorizontalAlignment="Left" Height="517" Margin="241,10,0,0" VerticalAlignment="Top" Width="559">
            <HelixToolkit:HelixViewport3D x:Name="myView" ZoomExtentsWhenLoaded="True" Margin="10" Grid.RowSpan="2">
                <HelixToolkit:HelixViewport3D.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FF4987D3" Offset="0.993"/>
                        <GradientStop Color="White" Offset="0.007"/>
                    </LinearGradientBrush>
                </HelixToolkit:HelixViewport3D.Background>
                <!-- Remember to add light to the scene -->
                <HelixToolkit:SunLight/>
                <ModelVisual3D x:Name="scene"/>
                <!-- You can also add elements here in the xaml -->
                <HelixToolkit:GridLinesVisual3D Width="8" Length="8" MinorDistance="1" MajorDistance="1" Thickness="0.01"/>
            </HelixToolkit:HelixViewport3D>
        </Grid>

objo wrote at 2014-02-23 21:39:

The 'world' transform should be the total transform of the Visual3D containing the models. Note that the second argument should be a Model3DCollection.
In your case, I think you can use Transform3D.Identity for the transform.

Rogad wrote at 2014-02-23 22:16:

Thanks Objo,

Hmm how would I do the Model3DCollection then ?

Rogad wrote at 2014-02-24 00:30:

I think I figured out the model thing. I only have one model in my scene called 'current'. So I did this :
        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            Model3DCollection mymodels = new Model3DCollection();
            mymodels.Add(current);     
            ElementSortingHelper.AlphaSort(myView.Camera.Position, mymodels, Transform3D.Identity);    
        }
It does nothing, but I am not entirely sure if my usage is correct.
0

2 Questions: mesh export and adding controls

Anonymous 11 years ago 0
This discussion was imported from CodePlex

ChevyCP wrote at 2011-11-22 18:52:

Hi,

     First off, awesome code!  Very well done!  Using the "subdivision demo", I played with the options and found a cube I like.  I recreated it in a new project with just the options neccessary.  My question is what is the best way to export that mesh.  I'm thinking of using it as a windows resource so I can view VS design mode as well as in blend.

 

     My next question is what is the best way to put controls on that cube.  Basically I have an app that has different menus, but instead of boring pop-ups I want to have a cube spin around to the appropriate side.  I have this working using viewport2dvisual3d panels as in the example here:

http://archive.msdn.microsoft.com/wpf3dcubewindow

 

     The difference is instead of a cube with sharp corners, I want one with round corners.  So my thinking is I use your tools to create the 3d cube I'm after and wrap my controls around it.  Any info would be much appreciated!

Thanks.,

 

 

Viewport2DVisual3D

objo wrote at 2011-11-23 06:45:

hi ChevyCP, note that the subdivided cube is not containing texture coordinates. It could, but that has to be added into the subdivision algorithm. Sorry I have not used the Viewport2DVisual3D panels, so cannot give you any input there.

Use the XamlExporter if you want to use the subdivided cube in Blend!


ChevyCP wrote at 2011-11-29 16:32:

Thanks.  I'm giving that a try, but get the following error: "Cannot serialize a generic type 'System.Collections.Generic.List`1[System.Int32[]]'."   Here is my code where "Cube" is the name of my MeshVisual3D:

XamlExporter exporter = new XamlExporter("C:\\directory\\myExport.xaml");
exporter.CreateResourceDictionary = true;
exporter.Export(Cube);
exporter.Close();


objo wrote at 2011-12-03 12:04:

I think you can only use built-in Windows.Media.Media3D Visual3D when using the XamlExporter.

Otherwise you need to register the custom types with the XamlWriter - I have not checked this.

0

DisableUpdates() & EnableUpdates() in MeshElement3D

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

phichaikid wrote at 2011-11-07 11:34:

Hallo,

I am developing a visualizer of multi-body system simulation. There are components, which bump into each other during the simulation. I can compute the bumping pressure and visualize it with ArrowVisual3D. In an animation, there can be 100 - 1000 of ArrowVisual3D to update during each frame (time point). I plug the update of ArrowVisual3D in CompositionTarget.Rendering. I have to update .Point1, .Point2 (direction of pressure), .HeadLength, .Diameter (for better visualization).

Till change set 70988, there is DisableUpdates() & EnableUpdates() in MeshElement3D, which I use in the update process of ArrowVisual3D, because I have to update 4 properties but do not want the program to update ArrowVisual3D 4 times. After the change set 70988, there aren't DisableUpdates() & EnableUpdates() anymore. Is there any ways to achieve the same effect i.e. ArrowVisual3D is updated only 1 time in each frame, even though, I want to update 4 properties. Or should I copy this DisableUpdates() & EnableUpdates() to the newer release?

I did some searchs in google but did not find anything useful from .net framework. Or do you perhaps implement other method in Helix 3D Toolkit, which yields the same effect?

Thanks in advanced,

Chatdanai.

 

 

 


objo wrote at 2011-11-07 12:43:

hi Chatdanai, I made two changes that could help. Get the latest source and try

myArrow.BeginEdit();
// do your changes
myArrow.EndEdit();

or

myArrow.Diameter = 0;
// change the points and head length
myArrow.Diameter = arrowDiameter;


phichaikid wrote at 2011-11-07 13:23:

Hallo objo,

Thank you very much for the super fast response.

I have tried both approaches. The 2nd one works perfectly. But the 1st one updates the ArrowVisual3D only if I change another property after call to EndEdit(). Is it intentionally? I think you mean I should change properties within calls to BeginEdit() & EndEdit().

Anyway, it is working for me now. Thanks a lot.

Best regards,

Chatdanai.


objo wrote at 2011-11-07 13:40:

I checked in a correction. The first solution should hopefully also work now. Please verify!


phichaikid wrote at 2011-11-07 14:44:

Hallo objo,

verified. Both works perfectly now.

Thanks again,

Chatdanai.

0

HelixView3D cannot catch MouseWheel event

Anonymous 11 years ago 0
This discussion was imported from CodePlex

Flanfl wrote at 2011-06-17 17:14:

Hi,

I'm doing a project where I have to do a panorama application and I'm using the great sample that you provided. However, I need to handle mouse event and I've issue with the MouseWheel event which is never fired. I tried it in my code and in your sample as follow:

 

<ht:HelixView3D x:Name="view1" ShowViewCube="False" ShowCameraTarget="False" CameraMode="FixedPosition" RotationSensitivity="0.1" 
ShowCoordinateSystem="True" ShowFieldOfView="True" ShowFrameRate="True" MouseWheel="view1_MouseWheel">

 

The code behind is:

 

private void view1_MouseWheel(object sender, MouseWheelEventArgs e) 
{

	int i = 0;
}

 

If I put a break point on the line int i = 0, nothing hapen when I scroll. I've tried another mouse event: MouseMove and it is working fin. MouseWheel is also working fine with other components. I'm guessing that you are handling the MouseEvent (or else it would not be possible to zoom) but I cannot find where. I would like to overload it to continue to use your functionalities and to add mine on it.

Do you have any idea of where I should look at?

Thanks!


objo wrote at 2011-06-19 12:31:

hi Flanfl, you find the mouse wheel handling in the CameraController code. It is setting Handled to true as you noticed.

Do you want to disable mouse wheel zooming? That could be a feature to add!

I suggest adding a MouseWheelAction { None, Zoom } or a EnableMouseWheelZooming property.

Will this work for you?


Flanfl wrote at 2011-06-21 12:38:

Hi, 

Thanks for the answer, I saw the CameraController class but when I created a HelixView3D object, the property CameraController is always null (I tried in the panorama test sample as well) and it is a read only property. 

I think I do not understand something but I don't know what. 

I do not want to disable the zooming function I just want to know how much a user zoom in/out so I can know how "close" he is from the picture, they might be already a property that can tell me that but I didn't find it ^^

So what I'am doing wrong?

Thanks! 


objo wrote at 2011-06-22 10:28:

The CameraController of the HelixView3D is set when the template is applied. HelixView3D is not supporting custom camera controllers (I try to keep it simple), so you are right - it is only gettable.

Did you try calculating the distance from the Camera.LookDirection.Length or Camera.FieldOfView (for 'FixedPosition' camera controller)?


Flanfl wrote at 2011-06-22 16:02:

Hi Objo,

I already tried LookDirection.Length but it was not really useful, but I didn't thought about FieldOfView! That's what I needed :) 

Thanks a lot!

0

Camera Default Settings

Anonymous 11 years ago 0
This discussion was imported from CodePlex

przem321 wrote at 2012-01-15 07:03:

Hi,

one more issue: it would be nice to provide a way to set up own defaults for the camera which can be then called by the ResetCamera function. Of course, one can write an own Reset function just by setting the camera Props. So far so good, nice, but since the CameraResetGesture always calls the CameraHelper.ResetCamera(...) and these values are hard coded, there is no way to use the gesture for an own default camera. Or am I wrong and there is a way to do that?


ddklo wrote at 2012-01-15 12:07:

I'm not that familiar with the Gestures, but currently we are solving this by removing all input bindings from the CameraController class and adding our own in code (for some reason mouse wheel scrolling is still active). You can find the default ones in the Generic.xaml resource dictionary. Not sure if there is a better way, but it appears to be working.


przem321 wrote at 2012-01-15 22:39:

Well, removing all bindings and adding own functions is a solution... which causes a lot of overhead to a in general very well defined camera. I wish one could replace particular bindings, such like that:

            view.CameraController.CommandBindings.RemoveAt(5);
            view.CameraController.CommandBindings.Add(new CommandBinding(CameraController.ResetCameraCommand,
             (s, ea) =>
             {
                 view.Camera.Position = new Point3D(4, 2, 16);
                 view.Camera.LookDirection = new Vector3D(-4, -2, -16);
                 view.Camera.UpDirection = new Vector3D(0, 1, 0);
             }
             ));

This only works well if one replaces the binding for CameraController.ResetCameraCommand, but in order to do so one has to know that it is at index #5 in the list. Well, this is not the nicest solution I guess... Is there any way to do it better?

 


objo wrote at 2012-01-16 05:55:

Should find a solution where it is not necessary to change the command bindings.

Idea: could we add a "DefaultCamera" property in the CameraController and HelixViewport3D. The Reset command could then copy the properties of the "DefaultCamera" to the current camera (or clone the default camera and assign it to the current camera).

do you see other solutions?


przem321 wrote at 2012-01-16 07:43:

Yes, a DefaultCamera property was the first thing I was thinking about too. This is a reasonable solution. 

On the other hand, replacing bindings might be also a useful solutions for those who really know what they are doing and wish to customize their camera controller. But I am not enough into the commanding to say how to do that properly. I will first need to read all this stuff here: http://msdn.microsoft.com/en-us/library/ms752308.aspx which I have no time for at the moment. 


objo wrote at 2012-01-16 08:39:

the current implementation makes it easy to change the gestures, but more work to change the command bindings.  

Let us know if you can find a better architecture/pattern to use here!


objo wrote at 2012-01-19 11:01:

added a "DefaultCamera" property in the HelixViewport3D. If this is defined, it will be used for the initial camera position and to reset the camera.