For bugs and new features, use the issue tracker located at GitHub.
Also try the chat room!
Rectangles are not drawn of specified Colors !!!!
terry_513 wrote at 2014-01-29 11:16:
private void DrawSections()
{
double x = 0, y = 0;
int i=0;
SolidColorBrush[] brushes = new SolidColorBrush[]{Brushes.Red, Brushes.Purple, Brushes.Gold, Brushes.Green, Brushes.YellowGreen, Brushes.Turquoise, Brushes.Wheat, Brushes.Pink, Brushes.PaleVioletRed, Brushes.Olive};
foreach (Section sec in areasList_Scaled)
{
RectangleVisual3D rect = new RectangleVisual3D();
rect.Origin = new Point3D(x, y, 0);
rect.Length = 120;
rect.Width = sec.Length; // myRect.Width;
//rect.Fill = Brushes.Lavender; // new SolidColorBrush(Colors.LightCoral);
rect.Material = new DiffuseMaterial(brushes[i]);
i++;
Console.Write("RECT LEN = " + sec.Length);
y += sec.Length;
wellViewport.Children.Add(rect);
}
}
With this code, I get rectangles, but not of the specified colors - instead of black & white colors. The Length of each sections is like
RECT LEN = 12.2586666666667RECT LEN = 0.202133333333333RECT LEN = 11.5825333333333RECT LEN = 0.157333333333333RECT LEN = 19.9297333333333RECT LEN = 0.15733333333333RECT LEN = 17.8796666666667RECT LEN = 0.157399999999992
I know I have set rect.Width = sec.Length which sould be set for rect.Length. But with that setting, I was getting rectangle vertically long the length is smaller than width. I couldn't get why was getting that results also.
Any idea, why the rectangles are not shown of specified colors and of black & white colors !!!!
This is mainly to get the background effect. Each section tells something different.
Any help is highly appreciated.
Thanks
objo wrote at 2014-01-29 19:49:
terry_513 wrote at 2014-01-30 06:55:
Added lights and now it shows properly.
I need to add background to rectangles of image. Can you suggest any link or article that can help me or you provide an example for the same.
Thanks a lot.
Simplest way to draw a new RectangularVisual3d
ronnyek wrote at 2012-05-10 17:07:
I am looking at creating a plane that when in the overhead view, I'd like to be able to draw a rectangle to represent selection. (like what you might see when lasso'ing a bunch of icons in windows.
I'm struggling to find out a way to draw a rectanglularvisual... and was hoping perhaps someone can point me in the correct direction.
I've got the mouse down/move/up events setting upper left and lower right of a rectangle, but seeing as rectangularvisual 3d uses origin etc, I cant just plug those values in.
ondown, check mouse buttons, findnearestpoint set variable to that if there is a value
onmove, if dragging, create rectangular visual if not null, and then set its origin to x-x/2 and y-y/2. (z dimension shouldnt really matter in this case.
Is there an easier way to do this? (I couldnt get this to work anyway)
objo wrote at 2012-05-10 22:07:
yes, the RectangleVisual3D is defined by Origin, Width and Length.
If you want to draw a rectangle aligned with the X and Y axes in the z=0 plane, e.g. from P1=Point3D(x1,y1,0) to P2=Point3D(x2,y2,0), you could set
Normal = new Vector3D(0,0,1) LengthDirection = new Vector3D(1,0,0) Origin = P1+(P2-P1)*0.5 Length = Math.Abs(P2.X-P1.X) Width = Math.Abs(P2.Y-P1.Y)
CornelRo wrote at 2012-11-07 09:03:
Thanks for the code above, I am also trying to make a selection box by creating a RectangleVisual3D to always face the camera regardless of the camera position. With the above code I made this possible, but only if the camera is in the standard views(F,B,L,R,U,D).
Does anybody know how to calculate the Normal & LengthDirection of the RectangleVisual3D depending on the Camera settings?
objo wrote at 2012-11-07 09:20:
see Source\HelixToolkit.Wpf\Visual3Ds\ScreenSpaceVisuals\BillboardVisual3D.cs
Camera Settings
SagarDabas wrote at 2013-02-10 06:08:
- the camera rotation should be done programmatically not mouse.
- the camera rotates along only y-axis.
- the axis of rotation can be changed.
Please, it's really very urgent. And thank you for such an awesome product.
objo wrote at 2013-02-10 16:11:
Maybe animations of the camera properties can help in your case, see msdn.
The CameraController is null until the control template is applied. Should not be null after that. Maybe you try to access the property too early?
SagarDabas wrote at 2013-02-11 15:07:
I solved my first problem by simulating mouse inputs ... but I am still not able to understand when should I try to access property ....
This was the code
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
CameraController controller = this.myViewPort3D.CameraController;
if(controller == null) Console.WriteLine("Controller is null");
DataContext = this;
}
}
and the output is "controller is null". When should I access this property , I am just a beginner. I am not able to figure out whether ControlTemplate is applied or not . Please answerobjo wrote at 2013-02-11 16:52:
http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.loaded.aspx
SagarDabas wrote at 2013-02-11 17:42:
Model3d Hit Testing
cobra18t wrote at 2011-12-13 16:12:
I am trying to follow your Voxel example to highlight a 3D model in the viewport when the user mouses over it. I have multiple Model3D objects in the viewport and the hit testing works fine until I start adding transforms to the Model3Ds. Even if the model is transformed to say (100,20,0), the hit testing reports a Model3D that is positioned at its original location, (0,0,0). I tried to determine which model was moused over by the bounding box of the orignal model and the bounding box of the hit result, but this only worked for some of the models. Any ideas? should I be using a different object type?
cobra18t wrote at 2011-12-13 17:33:
Additionally, hits.First().Position is reporting a position that is scaled with the same scale transformation of the model that is moused over. So when mousing over a model so that the mouse is hitting point (1,1,1) on the surface of the model, Position reports (5,5,5) as the hit point since the model is scaled by 5 in each dimension. Is there a way to apply the transformation permanently to avoid these discrepancies?
objo wrote at 2011-12-13 18:38:
have a look at HelixToolkit.Wpf.Viewport3DHelper.GetTransform to get the total transforms applied to the Visual3Ds and Model3Ds in your hits.
Also see the Viewport3DHelper.FindNearestPoint method!
valdis1987 wrote at 2013-08-15 14:07:
Can't get necessary results.
Can someone help me? I think this question is a problem to others also.
So lets say i have:
<Helix3D:HelixViewport3D x:Name="Mainviewport">
..Camera
<Helix3D:HelixVisual3D x:Name="Scene">
..Inside is <Helix3D:HelixVisual3D.Content><Model3DGroup> with deep tree with Model3dGroup[...]
</<Helix3D:HelixVisual3D>
<Helix3D:HelixVisual3D x:Name="Obje1"/>
<Helix3D:HelixVisual3D x:Name="Obje2"/>
<Helix3D:HelixVisual3D x:Name="Obje3"/>
<Helix3D:HelixVisual3D x:Name="Obje4"/>
</Helix3D:HelixViewport3D>
Inside HelixViewport3D all items have transforms( ScaleTransform3D,RotateTransform3D,TranslateTransform3D)
Now how I can get notice that Obje1 have hit Scene? Or Obje1 have hit Obje2?
I done a lot of try's to get result but no success.
Can someone give me a couple tips how to accomplish my target?
Thanks.
How to Draw a Post Cap
AQSRanck wrote at 2014-06-28 04:12:
I can draw all sorts of assemblies that derive from Box, Pipe, Cylinder, Cone etc. But now I have a new challenge. How would I approach drawing a more complex structure, In a similar fashion to SiloVisual3D, suppose I have a PostCapVisual3D. Could you suggest what elements to use to draw the Post Cap pictured below. I don't care about the textured finish, I'm more interested in your suggestion of which tools to use to draw the shape.
Bob
link to picture of Post Cap
objo wrote at 2014-07-02 13:19:
AQSRanck wrote at 2014-07-02 15:21:
I will keep that in mind when I need holes. In fact I these holes are to be filled with Nails, so I tried the example you used in Legos (with short pipes) to represent the nail heads and while the results were OK the code for the illustration and its placement became way too complicated. I decided to abandon it for more important issues. There are actually hundreds of different connectors like the one that I linked to in the first post and they are available in 2D form. The real solution for the larger issue here is to someday find a way to edit and convert from .DXF or .DWG files to simple Helix illustrations.
Thank you again,
Bob
mouse capture in viewport
alexalthauser wrote at 2013-04-03 23:43:
I'm trying to show the x,y,z position of the mouse within the helix3d viewport. I was wondering if there are any examples or samples, that show how to do this?
I'm building a 3D level editor, with a 3D grid, used for positioning objects. When the mouse moves through the grid, I want transparent planes to light up each side of the cube which the mouse is over, within the grid.
So far I have the X & Y mouse coordinates of the HelixViewport3D. I forget how to get the z coords. It's Camera lookat direction multiplied by something.. Arg, can't remember. Help!
Thanks,
Alex
objo wrote at 2013-04-15 12:22:
CurrentPosition
property in the HelixViewport3D
control.
Or use the
Viewport3DHelper.Point2DToRay3D
function. You can then find the intersection of the
Ray3D
and a Plane3D
. See also the "VoxelDemo" in the "ExampleBrowser".
kinect - Trackball [Solved]
MrNikito wrote at 2013-09-12 17:01:
I am new here and in kinect world, and I have a simple question. (I guess)
Using Helix3D I can zoom, rotate, etc by mouse. But is it possible using kinect?
Because I use:
<helix:HelixViewport3D CameraRotationMode="Trackball" ZoomExtentsWhenLoaded="False">
<helix:HelixViewport3D.Camera>
<PerspectiveCamera Position="0,0,0" LookDirection="0,6,0" UpDirection="0,0,1" NearPlaneDistance="0.01" FarPlaneDistance="1000" FieldOfView="57"/>
</helix:HelixViewport3D.Camera>
<helix:SunLight/>
<ModelVisual3D Content="{Binding Model}"/>
</helix:HelixViewport3D>
And Kinect did not recognize. Then I thought: "I need execute any code", but I was not able to find anything about this.
Can you help me?
Thanks
MrNikito wrote at 2013-09-25 17:15:
I get 2 ways to resolve my problem and I finished with the regular and the best way, using HelixViewport3D.CameraController.
But I completelly forget close this topic...
Well, thanks very much, because this tool is very simple to use.
karunakarreddy123 wrote at 2014-06-10 16:07:
We also facing same issue. Can you please give more details how you resolved the issue, if possible can you share code snippet for the same.
ThanksMrNikito wrote at 2014-09-01 06:51:
Well, I hope that you've already solved the problem.
But... here is my explanation:
As I needed finish the project quickly I just think: "Well I can rotate/move (Control) the Camera to solve my problem"
So I use this code to rotate the camera, where vector is a Vector3D calculated by Kinect Joints Position
helixViewport.CameraController.AddRotateForce(vector.X, vector.Y);
And I use that code to zoom in/zoom out the camera, where force is a double value that I calculated by hands distance...helixViewport.CameraController.AddZoomForce(force);
I hope that you solve your problem and my sincere apologies again (by the wait time).Error using Meshbuilder.AddRevolvedGeometry
mcrxb wrote at 2012-02-09 17:51:
I'm receiving the following error when trying to add a revolved geometry:
Cannot implicitly convert type 'void' to 'System.Windows.Media.Media3D.Geometry3D'
My code looks like this:
private IList<Point> profile = new List<Point>();
private MeshBuilder mb = new MeshBuilder();
profile.Add(new Point(0, 0));
profile.Add(new Point(ShankRadius, 0));
profile.Add(new Point(ShankRadius, ShankLength - ChamferOffset));
GeometryModel3D ShankGeometry = new GeometryModel3D();
ShankGeometry.Geometry = mb.AddRevolvedGeometry(profile, new Point3D(0, 0, 0), new Vector3D(0, 1, 0), 30);
ShankGeometry.Material = Materials.Hue;
ShankGeometry.BackMaterial = Materials.Hue;
vc.Add(ShankGeometry);
I get the error on the ShankGeometry.Geometry line. Any help would be greatly appreciated!
objo wrote at 2012-02-13 20:06:
try
mb.AddRevolvedGeometry(profile, new Point3D(0, 0, 0), new Vector3D(0, 1, 0), 30); ShankGeometry.Geometry = mb.ToMesh();
mcrxb wrote at 2012-02-21 14:10:
That worked perfect, thank you. One follow up question: I'm adding the revolves to a Model3D collection and want to set a different color for each revolved geometry (say I have two cylinders stacked on top of each other, one red and one blue) but for some reason it only uses the material of the last object added to the collection...do I need to clear this somehow? Should I be creating a new MeshBuilder for every revolve?
objo wrote at 2012-02-21 14:22:
you need a new GeometryModel3D to define objects with different materials. Geometry can be reused, but I think it is necessary to freeze (use the freeze argument in the MeshBuilder.ToMesh method).
mcrxb wrote at 2012-02-21 14:28:
I'm creating a new GeometryModel3D every time I add to the collection:
points.Add(new Point(0, 0)); points.Add(new Point(0, 1)); points.Add(new Point(1, 1)); mb.AddRevolvedGeometry(points, new Point3D(0, 0, 0), new Vector3D(0, 1, 0), 50); vc.Add(new GeometryModel3D(mb.ToMesh(), Materials.Gray)); points.Clear();
points.Add(new Point(0, 0)); points.Add(new Point(0, 2)); points.Add(new Point(2, 2)); mb.AddRevolvedGeometry(points, new Point3D(0, 0, 0), new Vector3D(0, 1, 0), 50); vc.Add(new GeometryModel3D(mb.ToMesh(), Materials.Blue)); points.Clear();
objo wrote at 2012-02-21 20:47:
I think you should also create a new MeshBuilder every time - the add methods are not clearing the existing mesh in the MeshBuilder.
Fix to STL binary reader
MattyBoy wrote at 2014-04-09 17:17:
this.Header = System.Text.ASCIIEncoding.ASCII.GetString(reader.ReadBytes(80)).Trim();
ReadChars(80) doesn't work in a binary file with nulls, etc...
objo wrote at 2014-04-29 10:29:
objo wrote at 2014-04-29 10:32:
MattyBoy wrote at 2014-05-01 19:38:
objo wrote at 2014-05-05 14:56:
Alt 2. Make the file available for download somewhere. Dropbox, OneDrive, etc.
Materials won't load
sion005 wrote at 2011-10-26 17:49:
Greetings, I'm using Helix in an application to view 3d models, however, when I import the model, it's all black, with no materials. I tried several models, including the ones used on the Studio example, but the result was the same. Probably I'm doing some newbie mistake, but i would appreciate some tips to solve this.
Here is the code that I use to load the model:
// Fields
private TerrainCreator tc;
private Model3D CurrentModel;
private ModelVisual3D render;
public MainWindow()
{
this.InitializeComponent();
this.render = new ModelVisual3D();
this.CurrentModel = ModelImporter.Load("C:\\Users\\Pedro\\Desktop\\Helix\\HelixToolkit-Examples\\StudioDemo\\Models\\Ferarri40.3ds");
this.render.Content = this.CurrentModel;
this.view.Add(render); // this is the HelixView3D
}
objo wrote at 2011-10-26 20:43:
hi Pedro! a simple question first: did you add lights to your scene? Helix toolkit has a couple of light visuals, and also a 'headlight' in the HelixViewport3D control.
sion005 wrote at 2011-10-31 15:49:
Problem solved. I didn't had any lights! Thanks a lot!
Customer support service by UserEcho