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

ZoomExtents on model changed

Anonymous 10 years ago 0
This discussion was imported from CodePlex

Jano42 wrote at 2013-03-27 14:10:

Hello,

My app is showing a 3d model which is loaded from xaml.

When my HelixViewport3D is Loaded (with event) I execute ZoomExtents, then my model is ocrrectly centred on display.

But my app is also able to change the model at runtime from Binding.
But I can not receive any event which told me when to ZoomExtent.
If I catch PropertyChange on CurrentModel, it seems that my ZoomExtents is done too early.
 <helix:HelixViewport3D x:Name="_helixView" Loaded="HelixViewLoaded" >
            <helix:DefaultLights/>
            <ModelVisual3D x:Name="_helixModel3D" Content="{Binding CurrentModel}"/>
...
What to do to ZoomExtent when a children change ?
0

draw a cube with mouse in helix3D

Anonymous 10 years ago updated by Kumaran M 10 years ago 1
This discussion was imported from CodePlex

Elementu wrote at 2012-01-17 10:24:

Hello ,

I am using the Helix 3d toolkit to develop my solution.

What I need and have not yet managed to develop properly is the drawing of a cube, or for that matter any other figure, with the mouse.

So when I press the left click I need the cube to begin drawing , as I keep dragging the mouse the cube should increase in size until I release the mouse button. at which moment the drawing should stop and the cube should be completed.

Unfortunately when drawing the cube i use the "HelixToolkit.Wpf.CubeVisual3D" which only has the center property and the size(width, height, depth) properties. so I am having problems drawing like any 3d program would , that is when when starting the drawing one corner should be fixed and the other points should mode until the drawing is complete. I thought of making the cube out of lines but that only applies to the cube and I also need to draw cylinders polygons   and others.

One more problem I am facing is that I assigned the rotation of the camera to the left click instead of the right click as it is usually. So that works for me only that when I select a figure to draw the left click should be used to draw and not to rotate the camera anymore until the selected button with the figure to draw is deselected then the left click is assigned back tot the rotation function.

Can anyone please point me in a right direction in order to solve this problems?

Thanks in advance.


objo wrote at 2012-01-17 11:33:

CubeVisual3D: right, you have to change the center point when you want to keep one corner (P1) fixed:

Center = P1 + new Vector3D(1,1,1) * SideLength * 0.5;

Rotate/draw modes: Can you set the RotateGesture to a MouseGesture(MouseAction.None) while you are in the draw mode?

I will add a box-drawing example when I get time :)


elementu wrote at 2012-01-17 12:36:

Thank you for your quick reply, i have tried to move the center instead of keeping it fixed but whatever I tried failed because the cube was still growing in both directions so i did not get the fixed corner I was hopping . I will try this too.

Another thing is that I get the mouse position like this HelixViewport.CurrentPosition to get a Point3D object in order to check how much the position of the mouse has changed . But if I cross an object that I already have loaded in the viewport the coordinates I get from the "CurrentPosition" property are very different and I barely move the mouse this is most visible when I have the grid lines loaded and i pas over the lines. What could be the nature of this problem ?

I will try to set the gesture to MouseAction.None when in draw mode. Actually I have thought of doing this before but wanted to modify as little as I could in the Helix code so that I don't have conflicts in other parts of the toolkit. So i tried to catch the mouse down event outside but the handler I was using was not getting triggered. the mouse up and move events were triggered i user it like this :

<h:HelixViewport3D
                           MouseLeftButtonDown="viewport_MouseLeftButtonDown"
                           MouseLeftButtonUp="viewport_MouseLeftButtonUp"
                           MouseMove="viewport_MouseMove"/>

0
Under review

Replace ViewCube

Khalid A. 9 years ago updated by datadeal Sedr 3 years ago 101

At the moment it seems that the ViewCube is a fixed Element of the HelixViewPort, that gets built up in the Code with the "AddCubeFaces" methods, etc.

It would be really nice to be able to replace the whole ViewCube with any model the user wants. That would allow us to have some kind of "MiniMap".


0

Camera View Setting

Anonymous 10 years ago 0
This discussion was imported from CodePlex

msankarsingh wrote at 2012-12-14 16:58:

Hi, 

Awesome toolkit. I am new to WPF and 3D.

I am trying to implement camera setting similar to this project  http://carvisualizer.plus360degrees.com/away3d/ any suggestion on how to implement it. Thanks in advance for your help.

0

How to get a 2d bitmap of 3d control

Anonymous 10 years ago 0
This discussion was imported from CodePlex

mcab21 wrote at 2013-11-26 13:57:

Hi,

Im looking to take a snap shot of whats in the helix HelixViewport3D control by clicking a button. Has anyone done this before? Any advice appreciated!

Thanks!

tbd2 wrote at 2013-11-27 14:41:

something like this should do the work (helix is your HelixViewport3D):


Bitmap RenderBitmapAndSaveToFile(int width, string fileName)
{
double scale = width / helix.ActualWidth;

int height = (int)(helix.ActualHeight * scale);

RenderTargetBitmap bmp = new RenderTargetBitmap( width, height, 96 * scale, 96 * scale, PixelFormats.Pbgra32);

// draw the bitmap Background
Rectangle vRect = new Rectangle();
vRect.Width = bmp.Width;
vRect.Height = bmp.Height;
vRect.Fill = helix.Background;
vRect.Arrange(new Rect(0, 0, vRect.Width, vRect.Height));
bmp.Render(vRect);

bmp.Render(helix.Viewport);

PngBitmapEncoder aEncoder = new PngBitmapEncoder();
aEncoder.Frames.Add(BitmapFrame.Create(bmp));

Directory.CreateDirectory(System.IO.Path.GetDirectoryName(fileName));

using (Stream stm = File.Create(fileName))
{
aEncoder.Save(stm);
}
}

regads,
Joachim
0

context menu when right clicking on objects in 3d view

Anonymous 10 years ago 0
This discussion was imported from CodePlex

mihaipruna wrote at 2014-01-06 20:32:

I would like to have a context menu to pop up when I right click on an object.
Two questions:
1) does Helix have any functions to create menus?
2) right click seems to control the camera, is there a way to override that? or switch camera control to a combination of left and right click buttons together?

AnotherBor wrote at 2014-01-07 05:27:

I don't know it Helix has GUI functions - although you could just pop a menu by the cursor using system API.
About how to control the camera, you can select which button (gesture) does what like this for example:
v3d.RotateGesture = new System.Windows.Input.MouseGesture(MouseAction.LeftClick);
where v3d is HelixViewport3D type.

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

1) Use a standard WPF ContextMenu
2) Yes, change the gesture as AnotherBor suggests

mihaipruna wrote at 2014-01-09 17:28:

Thank you!
0

How to correctly load .obj and .3ds in an HelixViewPort3D?

Anonymous 10 years ago 0
This discussion was imported from CodePlex

zoras1986 wrote at 2013-06-05 16:59:

Hello everyone,
i know that this has been a solved issue, but i cannot get out of this mess.
I have tried all the possibilities that i found over internet, but i cannot figure out why some objects are loaded well and some others not. I tried three different ways...I post some code:
FileModelVisual3D Mymodel= new FileModelVisual3D();
Mymodel.source = MODELS[i]; //where MODELS[i] is a string with the path of the model, let's //say C:/fish.obj
view1.Children.Add(Mymodel);//where view1 is my helixviewport3d
so i try:
Model3DGroup modelGroup = ModelImporter.Load(MODELS[i]);
GeometryModel3D Mymodel = (GeometryModel3D)modelGroup.Children[0];
newVisual = new ModelVisual3D { Content = MyModel }; //or Content = modelGroup;
view1.Children.Add(newVisual);//where view1 is my helixviewport3d
then i try:
var reader = new StudioReader();
Model3D MyModel = reader.Read(path); //where path is the object path
newVisual = new ModelVisual3D { Content = MyModel };
view1.Children.Add(newVisual);//where view1 is my helixviewport3d
i tried also:
ObjReader reader2 = new ObjReader();
Model3DGroup modelGroup = reader2.Read(MODELS[i]);
GeometryModel3D _objRead = (GeometryModel3D)modelGroup.Children[0];
newVisual = new ModelVisual3D { Content = _objRead};
view1.Children.Add(newVisual);//where view1 is my helixviewport3d
and obviously i'have tried also the loading directly from xaml, without any significant results :(
also i tried what have been described here https://helixtoolkit.codeplex.com/discussions/354077, meaning the loading from stream, but without any success...

No one of this method is working for me :( i cannot see well all the models that i find both in the helix samples both on internet. The best result that i've obtained, till now, is with the use of the second method (create a ModelGroup3D and show it through the use of a ModelVisual3D, that will be the helixViewPort children...

Can someone told me what i'm doing wrong? Could someone give me a piece of code that is actually working? because i've searched over the internet and all i read is that everyone could get this fantastic tool to work but me :'(

have a nice day and thanks in advance...:)

objo wrote at 2013-06-08 07:30:

Do you have lights in your scene? I think your code using ModelVisual3D looks ok.
I recommend setting a breakpoint on line 527 in StudioReader.cs, then you can check if the texture is loaded correctly!
Textures are not supported when loading from a stream.
0

rotation

Anonymous 10 years ago 0
This discussion was imported from CodePlex

sebastienjouhans wrote at 2013-07-30 11:04:

Hi,

Instead of using the mouse to rotate around an object I want to use some buttons.

is it the AddRotateForce method I should use to do this where x and y would be the coordinate in world around the object?

Thanks
Seb

objo wrote at 2013-08-08 08:29:

No, the arguments are relative to the screen coordinate system. See the usage by the arrow keys!
0

UIElement Visual3DModel behaves differently than MeshGeometryVisual3D

Domvs Phi 10 years ago updated by ไอยดา สุรีวงค์ 4 years ago 2
Hello. I am testing HelixToolKit and I am trying to achieve a simple task:
Create a revolve object and display it on the 3D view port. Since I need the object to be clickable, I am adding it using the UIElement example (changed it to have the rotation instead of the sphere). This is partially achieved, this is, the object displays and I can click on it (and have a desired event), but the object does not render well as the MeshGeometryVisual3D.

See image. Blue glass was added with UIElement, while the red one with MeshGeometryVisual3D. The red one is ok - it is what I want to obtain, while the blue presents parts transparent. If I rotate the camera those parts turn solid, but others transparent. I do not believe that is a question of light as I tested several. The blue glass is half the size of the red one on propose.
In resume red glass is perfect, blue glass is defected.

Image 10

Relevant WPF code:

 <h:HelixViewport3D x:Name="view1">
<h:SunLight/>
<h:GridLinesVisual3D Center="6 0 -0.5" Fill="Gray" Visible="True"/>
<local:Demo2Element3D></local:Demo2Element3D>
<h:MeshGeometryVisual3D Transform="{h:Translate -5,0,0}" MeshGeometry="{Binding GlassGeometry}" Fill="Red" Visible="True"/>
</h:HelixViewport3D>

Demo2Element3D construction (Blue glass):

 public class Demo2Element3D : UIElement3D {
public Demo2Element3D()
{
var gm = new GeometryModel3D();
var mb = new MeshBuilder();

var profile = new[] { new Point(0, 0), new Point(0, 0.4), new Point(0.06, 0.36), new Point(0.1, 0.1), new Point(0.34, 0.1), new Point(0.4, 0.14), new Point(0.5, 0.5), new Point(0.7, 0.56), new Point(1, 0.46) };
mb.AddRevolvedGeometry(profile, null, new Point3D(0, 0, 0), new Vector3D(0, 0, 1), 200);
gm.Geometry = mb.ToMesh();
gm.Material = Materials.Blue;
Visual3DModel = gm;
}

Red glass:

 public MeshGeometry3D GlassGeometry {
get
{
var builder = new MeshBuilder(true, true);
var profile = new[] { new Point(0 * 2, 0.4 * 2), new Point(0.06 * 2, 0.36 * 2), new Point(0.1 * 2, 0.1 * 2), new Point(0.34 * 2, 0.1 * 2), new Point(0.4 * 2, 0.14 * 2), new Point(0.5 * 2, 0.5 * 2), new Point(0.7 * 2, 0.56 * 2), new Point(1 * 2, 0.46 * 2) };
builder.AddRevolvedGeometry(profile, null, new Point3D(0, 0, 0), new Vector3D(0, 0, 1), 100);
return builder.ToMesh(true);
}
}

Any information is helpful as I am very new to Helix and even to WPF.
Thank you
0

Drag & drop behaviour changing between HelixToolkit and HelixToolkit.Wpf

Anonymous 10 years ago 0
This discussion was imported from CodePlex

psteclik wrote at 2013-09-27 20:04:

I have moved my project from helixtoolkit to helixtoolkit.wpf and found some difference with drag & drop behaviour. When dragging over HelixViewport3D and its children (i.e. some 3D models in it) I'm getting a lot of DragEnter/DragLeave events. Both events are connected to HelixViewport3D (new version) and HelixView3D (old version).

objo wrote at 2013-09-29 09:20:

I am not aware of any changes related to drag/drop in the HelixViewport3D control.
Can you reproduce the behaviour in a small example?