0

using Caliburn MVVM

Anonymous 10 years ago 0
This discussion was imported from CodePlex

AQSRanck wrote at 2014-03-17 15:09:

Hi, I am just getting started with Helix - it looks great! I already use Caliburn Micro.

In one of the older sample projects, there is a little Red house with a gable roof. I'd like to do this in the Mvvm Project.

All I really need is an example of the code for the view model to add the rectangular box representing the house and then the code to add the triangular roof. It would help if the two objects had different colors. Add more detail if you wish, but this will be a great help in getting me started.

Thanks

AQSRanck wrote at 2014-03-18 14:31:

OK I found the answer myself to the easy part - All I need now is to understand how to add the triangular object on top of the box, The code to add the box itself is, shown below.
(Objects is an Observable Collection which is bound to the ItemsSource of the HelixViewport3D) and this works just fine.
        public void AddFigure()
        {
            Objects.Clear();
            if (Objects.Count == 0) {
                Objects.Add(new SunLight());
            }           

               BoxVisual3D housebox1 = new BoxVisual3D();
            housebox1.Width = 35;
            housebox1.Length = 25;
            housebox1.Height = 8;
            housebox1.Fill = Brushes.DarkGray;
            housebox1.Center = new Point3D(0, 0, -8);
            Objects.Add(housebox1);
               }
Obviously, Helix does not have a "RoofVisual3D" so the question is how do you build this triangular solid element to add to the Objects collection? All I am trying to understand is how to construct the code to build a custom triangular solid element element to add to the collection.

AQSRanck wrote at 2014-03-21 03:28:

I was able to add a triangular roof module to the top of my housebox with the ExtrudedVisual3D.
ExtrudedVisual3D Gable = new ExtrudedVisual3D();
PointCollection sect = new PointCollection();
sect.Add(new Point(0, 15));
sect.Add(new Point(17.5, 4));
sect.Add(new Point(-17.5, 4));
Gable.Section = sect;
Gable.Path.Add(new Point3D(-12.5, 0, 0));
Gable.Path.Add(new Point3D(12.5, 0, 0));
Gable.SectionXAxis = new Point3D(0, 1, 0);
Gable.Fill = Brushes.SaddleBrown;
Gable.IsPathClosed = true;
Gable.IsSectionClosed = true;
Objects.Add(Gable);
However, this is obviously not the right solution. The triangle is open on both ends and you can see right through it. At first, I thought of adding end caps to the extrusion but my sense is that I really need a geometry mesh. Also, as I move from a simple Gable to a more complex Hip Roof, the ExtrudedVisual is clearly wrong. So if someone could help with a geometry mesh, I would be grateful. Here are the points for a simple Hip roof. An earlier post in this forum shows how to add a 2D mesh, but I still don't have a clue for the syntax for a 3D mesh in Helix. A Hip Roof has four slopes, If I don't use Helix toolkit, I can divide the roof up into 6 Triangles and determine indices, and calculate normal. What I need help with is: How do I use Helix tools to achieve the same results? All I need is the code that would precede the line below.

Objects.Add(Roof1);

The first four points are the perimeter - - - and the final two points represent the two points in the middle of a hip roof.
Pt0=(0,0,0)
Pt1=(0,35,0)
Pt2=(35,25,0)
Pt3=(0,25,0)
Pt4=(5,12.5,5)
Pt5=(5,22.5,5)

Thank you