Example #1
0
        /// <summary>
        /// Truncate a vertex by building a pentagon
        /// </summary>
        /// <param name="p0"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="p3"></param>
        /// <param name="p4"></param>
        /// <param name="p5"></param>
        private void BuildPentagon(Point3D p0, Point3D p1, Point3D p2, Point3D p3, Point3D p4, Point3D p5)
        {
            Vector3D v1  = Point3D.Subtract(p1, p0);
            Point3D  p1a = Point3D.Add(p0, Vector3D.Multiply(v1, _truncRate));

            Vector3D v2  = Point3D.Subtract(p2, p0);
            Point3D  p2a = Point3D.Add(p0, Vector3D.Multiply(v2, _truncRate));

            Vector3D v3  = Point3D.Subtract(p3, p0);
            Point3D  p3a = Point3D.Add(p0, Vector3D.Multiply(v3, _truncRate));

            Vector3D v4  = Point3D.Subtract(p4, p0);
            Point3D  p4a = Point3D.Add(p0, Vector3D.Multiply(v4, _truncRate));

            Vector3D v5  = Point3D.Subtract(p5, p0);
            Point3D  p5a = Point3D.Add(p0, Vector3D.Multiply(v5, _truncRate));

            this.Points.Add(p1a);
            this.Points.Add(p2a);
            this.Points.Add(p3a);
            this.Points.Add(p4a);
            this.Points.Add(p5a);

            PolygonSculptor pv = new PolygonSculptor(p1a, p2a, p3a, p4a, p5a);

            pv.BuildTriangles();
            foreach (Point3DTriplet tpl in pv.Triangles)
            {
                this.Triangles.Add(tpl);
            }
            this._pentagonList.Add(pv);
        }
        /// <summary>
        /// Return the OTA position wrt the dome centre
        /// X is to the N,
        /// Y is to the W,
        /// Z is up
        /// Currently assumes the Nothern hemisphere
        /// </summary>
        /// <param name="ha">hour angle in degrees</param>
        /// <param name="isPierWest"></param>
        private Point3D OtaPosition(double ha, bool isPierWest)
        {
            // Get the position of the mount

            Point3D p1 = _scopeOffset;

            p1.Y = -p1.Y;                                 // Change the sign of the y direction to match the WPF coordinate system

            Vector3D os = new Vector3D(0, _otaOffset, 0); // OTA offset is along the dec axis

            if (_otaOffset > 0.00001)
            {
                if (_isGem && isPierWest)
                {
                    // Reverse the dec OTA offset

                    os.Y = -os.Y;
                }

                // Rotate by Ha

                os = Rotate(os, new Point3D(-1, 0, 0), ha);

                // Rotate by latitude

                os = Rotate(os, new Point3D(0, -1, 0), Math.Abs(_siteLatitude));
            }

            Point3D retval = Point3D.Add(p1, os);

            //Debug.WriteLine( "OtaPosition X:" + retval.X + ", Y:" + retval.Y + ", Z:" + retval.Z );

            return(retval);
        }
Example #3
0
        public static URPose Add(URPose pose, URVector vector)
        {
            var newPosition = Point3D.Add(pose.Position, vector.PoseVector);
            var newRotation = Point3D.Add(pose.Rotation, vector.RotationVector);

            return(new URPose(newPosition, newRotation));
        }
Example #4
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var rect3d     = (Rect3D)value;
            var lineLength = (rect3d.SizeX + rect3d.SizeY + rect3d.SizeZ) / 3 / 2;
            var pointX     = Point3D.Add(rect3d.Location, new Vector3D(rect3d.SizeX, 0, 0));
            var pointY     = Point3D.Add(rect3d.Location, new Vector3D(0, rect3d.SizeY, 0));
            var pointZ     = Point3D.Add(rect3d.Location, new Vector3D(0, 0, rect3d.SizeZ));

            var pointXZ = new Point3D((pointX.X + pointZ.X) / 2, (pointX.Y + pointZ.Y) / 2, (pointX.Z + pointZ.Z) / 2);
            var pointXY = new Point3D((pointX.X + pointY.X) / 2, (pointX.Y + pointY.Y) / 2, (pointX.Z + pointY.Z) / 2);
            var pointZY = new Point3D((pointZ.X + pointY.X) / 2, (pointZ.Y + pointY.Y) / 2, (pointZ.Z + pointY.Z) / 2);

            return(new Point3DCollection(new[] {
                pointXZ,
                Point3D.Subtract(pointXZ, new Vector3D(0, lineLength, 0)),
                pointXY,
                Point3D.Subtract(pointXY, new Vector3D(0, 0, lineLength)),
                pointZY,
                Point3D.Subtract(pointZY, new Vector3D(lineLength, 0, 0)),
                Point3D.Add(pointXZ, new Vector3D(0, rect3d.SizeY, 0)),
                Point3D.Add(pointXZ, new Vector3D(0, rect3d.SizeY + lineLength, 0)),
                Point3D.Add(pointXY, new Vector3D(0, 0, rect3d.SizeZ)),
                Point3D.Add(pointXY, new Vector3D(0, 0, rect3d.SizeZ + lineLength)),
                Point3D.Add(pointZY, new Vector3D(rect3d.SizeX, 0, 0)),
                Point3D.Add(pointZY, new Vector3D(rect3d.SizeX + lineLength, 0, 0))
            }));
        }
Example #5
0
 public void FilterFile(double step)
 {
     for (int index = 0; index < data.Count; index++)
     {
         var dat = data[index];
         List <KeyValuePair <double, Point3D> > newLocList = new List <KeyValuePair <double, Point3D> >();
         double t = step;
         dat.Sort((x, y) => x.Key.CompareTo(y.Key));
         int i = 1;
         while (i < dat.Count - 1)
         {
             while (t < dat[i].Key)
             {
                 var slope = Point3D.Subtract(dat[i].Value, dat[i - 1].Value);
                 Vector3D.Divide(slope, (dat[i].Key - dat[i - 1].Key));
                 Vector3D.Multiply(slope, t - dat[i - 1].Key);
                 newLocList.Add(new KeyValuePair <double, Point3D>(t, Point3D.Add(dat[i - 1].Value, slope)));
                 t += step;
             }
             if (t == dat[i].Key)
             {
                 newLocList.Add(new KeyValuePair <double, Point3D>(t, dat[i].Value));
                 t += step;
             }
             if (t > dat[i].Key)
             {
                 i++;
             }
         }
         data[index] = newLocList;
     }
 }
        public CollisionSimplifiedScenario Simplify(
            LinearDisplacement objectA,
            LinearDisplacement objectB
            )
        {
            Point3D SecondObjectCenter = Point3D.Add(new Point3D(0, 0, 0), objectB.StartingPosition - objectA.StartingPosition);

            LinearDisplacement EffectiveLinearDisplacement =
                new LinearDisplacement
                (
                    objectB.Velocity - objectA.Velocity,
                    SecondObjectCenter,
                    objectA.DeltaTime
                );

            if (
                EffectiveLinearDisplacement.Velocity == Zero &&
                SecondObjectCenter != Center
                )
            {
                return(null);
            }
            else
            {
                CollisionSimplifiedScenario simplifiedScenario =
                    new CollisionSimplifiedScenario(
                        objectA.PhysicObject.GetColliderShape(),
                        objectB.PhysicObject.GetColliderShape(),
                        EffectiveLinearDisplacement
                        );

                return(simplifiedScenario);
            }
        }
Example #7
0
        // viewport -> kanvas (kruzic selekcije)
        /// <summary>
        /// Vraca projekciju 3D tocke viewporta na kanvas.
        /// Inverzna funkcija od Koord3dViewportViaKanvas2dKoord.
        /// </summary>
        /// <param name="_viewport3DKoord">Koordinata 3D tocke koju se zeli projicirati na kanvas.</param>
        /// <param name="_aktivnaPerspektiva">Staviti "True" ako je perspektivna kamera aktivna (uracunava i njezinu deformaciju).</param>
        /// <returns></returns>
        public Point Projektor_2DKanvasVia3DViewport(Point3D _viewport3DKoord, bool _aktivnaPerspektiva)
        {
            Point3D p3d = Point3D.Add(_viewport3DKoord, -KameraPozicijaVektor);

            //Point3D p3d = _viewport3DKoord;

            p3d = (Point3D)(RotMatricaZXY_i * (Vector3D)p3d);

            /*
             * p3d = prostorneRotacije.ZXY_inverz(
             *      new Point3D(p3d.X, p3d.Y, p3d.Z),
             *      KameraRotacijaKuteviXYZ_dp.Z,
             *      KameraRotacijaKuteviXYZ_dp.X,
             *      KameraRotacijaKuteviXYZ_dp.Y);
             */
            Point p2d = new Point(p3d.X, p3d.Z);

            if (_aktivnaPerspektiva)
            {
                double udaljenostSelObjodKamere = Projektor_OrtoUdaljenostTockeOdKamere(_viewport3DKoord);

                if (udaljenostSelObjodKamere != 0)
                {
                    p2d.X = p2d.X * KameraZoom_dp / (udaljenostSelObjodKamere * 2 * prostorneRotacije.tngStu(KamPer.FieldOfView / 2));
                    p2d.Y = p2d.Y * KameraZoom_dp / (udaljenostSelObjodKamere * 2 * prostorneRotacije.tngStu(KamPer.FieldOfView / 2));
                }
            }

            return(p2d);
        }
        /// <summary>
        /// calculates a ray to indicate where a body points. The vector
        /// is calculated with the right elbow and right wrist
        /// </summary>
        /// <param name="bodyNr">the number of the body the ray should be calculated for </param>
        /// <param name="rightElbow">the point of the right elbow of the body</param>
        /// <param name="rightWrist">the point of the right wrist of the body </param>
        private void makeBodyRay(int bodyNr, Point3D rightElbow, Point3D rightWrist)
        {
            skelRayList[bodyNr].Point1 = rightElbow;
            Vector3D vec = new Vector3D((rightWrist.X - rightElbow.X), (rightWrist.Y - rightElbow.Y), (rightWrist.Z - rightElbow.Z));

            skelRayList[bodyNr].Point2 = Point3D.Add(rightElbow, Vector3D.Multiply(10, vec));
            mainViewport.Children.Remove(skelRayList[bodyNr]);
            mainViewport.Children.Add(skelRayList[bodyNr]);
        }
Example #9
0
        public void addCentroid(Point3D centroid)
        {
            int numberOfPoints = points.Count;

            for (int i = 0; i < numberOfPoints; i++)
            {
                points[i] = Point3D.Add(points[i], (Vector3D)centroid);
            }
        }
Example #10
0
        /// <summary>
        /// Initializes the Points and Triangles collections.
        /// Called By Sculptor.BuildMesh()
        /// </summary>
        protected override void CreateTriangles()
        {
            IsocahedronSculptor sculptor = new IsocahedronSculptor();

            sculptor.BuildMesh();
            foreach (Point3DTriplet tpl in sculptor.Triangles)
            {
                Point3D p1 = tpl.Points[0];
                Point3D p2 = tpl.Points[1];
                Point3D p3 = tpl.Points[2];

                // troncature des sommets du triangle => 1 hexagone (= 4 triangles)
                Vector3D v1 = Point3D.Subtract(p2, p1);
                Point3D  pA = Point3D.Add(p1, Vector3D.Multiply(v1, _truncRate));
                Point3D  pB = Point3D.Add(p1, Vector3D.Multiply(v1, 1 - _truncRate));

                Vector3D v2 = Point3D.Subtract(p3, p2);
                Point3D  pC = Point3D.Add(p2, Vector3D.Multiply(v2, _truncRate));
                Point3D  pD = Point3D.Add(p2, Vector3D.Multiply(v2, 1 - _truncRate));

                Vector3D v3 = Point3D.Subtract(p1, p3);
                Point3D  pE = Point3D.Add(p3, Vector3D.Multiply(v3, _truncRate));
                Point3D  pF = Point3D.Add(p3, Vector3D.Multiply(v3, 1 - _truncRate));

                this.Points.Add(pA);
                this.Points.Add(pB);
                this.Points.Add(pC);
                this.Points.Add(pD);
                this.Points.Add(pE);
                this.Points.Add(pF);

                PolygonSculptor hv = new PolygonSculptor(pA, pB, pC, pD, pE, pF);
                hv.BuildTriangles();
                foreach (Point3DTriplet tpl2 in hv.Triangles)
                {
                    this.Triangles.Add(tpl2);
                }
                _hexagonList.Add(hv);
            }

            BuildPentagon(sculptor.P1a, sculptor.P3a, sculptor.P2d, sculptor.P1d, sculptor.P2a, sculptor.P3d);
            BuildPentagon(sculptor.P1b, sculptor.P3a, sculptor.P3d, sculptor.P2b, sculptor.P1c, sculptor.P2c);
            BuildPentagon(sculptor.P1c, sculptor.P3b, sculptor.P2c, sculptor.P1b, sculptor.P2b, sculptor.P3c);
            BuildPentagon(sculptor.P1d, sculptor.P1a, sculptor.P2d, sculptor.P3b, sculptor.P3c, sculptor.P2a);

            BuildPentagon(sculptor.P2a, sculptor.P1a, sculptor.P1d, sculptor.P3c, sculptor.P2b, sculptor.P3d);
            BuildPentagon(sculptor.P2b, sculptor.P3d, sculptor.P2a, sculptor.P3c, sculptor.P1c, sculptor.P1b);
            BuildPentagon(sculptor.P2c, sculptor.P2d, sculptor.P3a, sculptor.P1b, sculptor.P1c, sculptor.P3b);
            BuildPentagon(sculptor.P2d, sculptor.P3a, sculptor.P2c, sculptor.P3b, sculptor.P1d, sculptor.P1a);

            BuildPentagon(sculptor.P3a, sculptor.P2c, sculptor.P2d, sculptor.P1a, sculptor.P3d, sculptor.P1b);
            BuildPentagon(sculptor.P3b, sculptor.P2d, sculptor.P2c, sculptor.P1c, sculptor.P3c, sculptor.P1d);
            BuildPentagon(sculptor.P3c, sculptor.P2b, sculptor.P2a, sculptor.P1d, sculptor.P3b, sculptor.P1c);
            BuildPentagon(sculptor.P3d, sculptor.P1a, sculptor.P2a, sculptor.P2b, sculptor.P1b, sculptor.P3a);
        }
Example #11
0
        private Vector3D GetForce(IList <Creature> creatures)
        {
            var total = new Vector3D(0, 0, 0);

            if (State == CreatureState.Egg || State == CreatureState.Dead)
            {
                return(total);
            }


            Point3D totPos = new Point3D();

            foreach (var c in creatures)
            {
                Point3D.Add(totPos, new Vector3D(c.Position.X, c.Position.Y, c.Position.Z));
            }
            int    n      = creatures.Count();
            var    center = new Point3D(totPos.X / n, totPos.Y / n, totPos.Z / n);
            var    cdir   = Point3D.Subtract(center, Position);
            double cf     = 10 * cdir.LengthSquared;

            cdir.Normalize();
            //total += cdir;


            foreach (var c in creatures)
            {
                if (c == this)
                {
                    continue;
                }
                var    dir             = Point3D.Subtract(c.Position, Position);
                double distance        = dir.Length;
                double distanceSquared = dir.LengthSquared;

                if (distance < 1e-6)
                {
                    continue;
                }

                dir.Normalize();
                double attraction = GetAttraction(c);

                if (distance < PrivacyDist && !Attack(c) && !Loves(c))
                {
                    attraction = -100;
                }
                ProximityCheck(c, distance);

                var f     = 100 * attraction / Math.Sqrt(distanceSquared);
                var force = dir * f;
                total += force;
            }
            return(total);
        }
Example #12
0
 private void Window_MouseWheel(object sender, MouseWheelEventArgs e)
 {
     if (e.Delta > 0)
     {
         // Zoom in
         camMain.Position = Point3D.Add(camMain.Position, zoomDelta);
     }
     else
     {
         // Zoom out
         camMain.Position = Point3D.Subtract(camMain.Position, zoomDelta);
     }
 }
Example #13
0
        public void AddSubOperations()
        {
            Point3D  point3D1       = new Point3D();
            Point3D  point3D2       = new Point3D(5, 6, 7);
            Vector3D vector3D1      = new Vector3D(10, 15, 25);
            Point3D  point3DResult  = new Point3D();
            Vector3D vector3DResult = new Vector3D();

            // Assigning x,y,z values to Point3D1
            point3D1.X = 10;
            point3D1.Y = 12;
            point3D1.Z = 15;

            // Add a Vector3D and a Point3D using the overloaded + operator
            // Returns a Point3D

            point3DResult = vector3D1 + point3D1;
            // point3DResult is equal to

            // Add a Point3D and a Vector3D using the static Add method
            // Returns a Point3D

            point3DResult = Point3D.Add(point3D1, vector3D1);
            // point3DResult is equal to

            // Subtract a Vector3D from a Point3D using the overloaded - operator
            // Returns a Point3D

            point3DResult = point3D1 - vector3D1;
            // point3DResult is equal to

            // Subtracts a Point3D from a Point3D using the overload - operator
            // Returns a Vector3D

            vector3DResult = point3D1 - point3D2;
            // vector3DResult is equal to


            // Subtracts a Vector3D from a Point3D using the static Subtract method
            // Returns a Point3D

            point3DResult = Point3D.Subtract(point3D1, vector3D1);
            // point3DResult is equal to

            // Subtracts a Point3D from a Point3D
            // Returns a Vector3D

            vector3DResult = Point3D.Subtract(point3D1, point3D2);
            // vector3Dresult is equal to
        }
Example #14
0
        private void viewport3D1_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (!radCamera1.IsChecked.Value)
            {
                return;
            }

            //_camera1.Position = new Point3D(_camera1.Position.X, _camera1.Position.Y, _camera1.Position.Z - e.Delta / 100D);

            Vector3D delta = _camera1.LookDirection;

            delta.Normalize();
            delta = Vector3D.Multiply(delta, e.Delta / 100d);

            _camera1.Position = Point3D.Add(_camera1.Position, delta);
        }
        public void addCentroidTest()
        {
            Point3D    point1 = new Point3D(0, 0, 0);
            Point3D    point2 = new Point3D(100, 100, 100);
            PointCloud cloud  = new PointCloud();

            cloud.addPoint(point1);
            cloud.addPoint(point2);

            Point3D centroid = cloud.getCentroid();

            cloud.addCentroid();

            Assert.IsTrue(cloud.getPoint(0) == Point3D.Add(point1, (Vector3D)centroid) &&
                          cloud.getPoint(1) == Point3D.Add(point2, (Vector3D)centroid));
        }
        private void ProcessModelScale()
        {
            if (IsValidModel)
            {
                if (IsMaxLengthScale)
                {
                    var factor = MaxLengthScale / Math.Max(Math.Max(OriginalModelSize.Height, OriginalModelSize.Width), OriginalModelSize.Depth);

                    NewModelSize.Height = (int)(factor * OriginalModelSize.Height);
                    NewModelSize.Width  = (int)(factor * OriginalModelSize.Width);
                    NewModelSize.Depth  = (int)(factor * OriginalModelSize.Depth);
                }
                else if (IsMultipleScale)
                {
                    NewModelSize.Height = (int)(MultipleScale * OriginalModelSize.Height);
                    NewModelSize.Width  = (int)(MultipleScale * OriginalModelSize.Width);
                    NewModelSize.Depth  = (int)(MultipleScale * OriginalModelSize.Depth);
                }

                double vectorDistance  = BuildDistance;
                double scaleMultiplyer = 1;

                switch (ClassType)
                {
                case ImportModelClassType.SmallShip: scaleMultiplyer = MyCubeSize.Small.ToLength(); break;

                case ImportModelClassType.SmallStation: scaleMultiplyer = MyCubeSize.Small.ToLength(); break;

                case ImportModelClassType.LargeShip: scaleMultiplyer = MyCubeSize.Large.ToLength(); break;

                case ImportModelClassType.LargeStation: scaleMultiplyer = MyCubeSize.Large.ToLength(); break;

                case ImportModelClassType.Asteroid: scaleMultiplyer = 1; break;
                }
                vectorDistance += NewModelSize.Depth * scaleMultiplyer;
                NewModelScale   = new BindablePoint3DModel(NewModelSize.Width * scaleMultiplyer, NewModelSize.Height * scaleMultiplyer, NewModelSize.Depth * scaleMultiplyer);

                // Figure out where the Character is facing, and plant the new construct right in front, by "10" units, facing the Character.
                var vector = new BindableVector3DModel(_dataModel.CharacterPosition.Forward).Vector3D;
                vector.Normalize();
                vector   = Vector3D.Multiply(vector, vectorDistance);
                Position = new BindablePoint3DModel(Point3D.Add(new BindablePoint3DModel(_dataModel.CharacterPosition.Position).Point3D, vector));
                Forward  = new BindableVector3DModel(_dataModel.CharacterPosition.Forward);
                Up       = new BindableVector3DModel(_dataModel.CharacterPosition.Up);
            }
        }
Example #17
0
        // camera update when panning
        private void panUpdate(object sender, MouseEventArgs e)
        {
            var p = Mouse.GetPosition(this.Scene);

            this.navigationVectorVisual.X2 = p.X;
            this.navigationVectorVisual.Y2 = p.Y;
            if (!this.Scene.Children.Contains(this.navigationVectorVisual))
            {
                this.Scene.Children.Add(this.navigationVectorVisual);
            }
            // displacement on the scene
            Vector3D translationOn2DScene = new Vector3D(p.X - this.navigationVectorStart.X, p.Y - this.navigationVectorStart.Y, 0);
            Vector3D direction            = this.navigationMat.Transform(translationOn2DScene);

            direction            = direction - Vector3D.DotProduct(this.camera.LookDirection, direction) * this.camera.LookDirection;
            direction            = UnitConversion.Convert(0.1, Length_Unit_Types.FEET, _host.BIM_To_OSM.UnitType) * direction;
            this.camera.Position = Point3D.Add(this.initialCameraPosition, direction);
        }
Example #18
0
        private void ProcessFilename(string filename)
        {
            IsBusy = true;

            if (File.Exists(filename))
            {
                // TODO: validate file is a real image.

                // TODO: read image properties.

                if (_sourceImage != null)
                {
                    _sourceImage.Dispose();
                }

                _sourceImage      = Image.FromFile(filename);
                OriginalImageSize = new Size(_sourceImage.Width, _sourceImage.Height);

                NewImageSize = new BindableSizeModel(_sourceImage.Width, _sourceImage.Height);
                NewImageSize.PropertyChanged += (sender, e) => ProcessImage();

                // Figure out where the Character is facing, and plant the new constrcut right in front, by "10" units, facing the Character.
                var vector = new BindableVector3DModel(_dataModel.CharacterPosition.Forward).Vector3D;
                vector.Normalize();
                vector   = Vector3D.Multiply(vector, 10);
                Position = new BindablePoint3DModel(Point3D.Add(new BindablePoint3DModel(_dataModel.CharacterPosition.Position).Point3D, vector));
                Forward  = new BindableVector3DModel(_dataModel.CharacterPosition.Forward).Negate();
                Up       = new BindableVector3DModel(_dataModel.CharacterPosition.Up);

                ClassType = ImportImageClassType.SmallShip;
                ArmorType = ImportArmorType.Light;

                IsValidImage = true;
            }
            else
            {
                IsValidImage      = false;
                Position          = new BindablePoint3DModel(0, 0, 0);
                OriginalImageSize = new Size(0, 0);
                NewImageSize      = new BindableSizeModel(0, 0);
            }

            IsBusy = false;
        }
Example #19
0
        public static bool DoesIntersect(Point3D p0, Point3D p1, Point3D q0, Point3D q1)
        {
            var u  = p1.Subtract(p0);
            var v  = q1.Subtract(q0);
            var w0 = p0.Subtract(q0);

            double a = u.Dot(u);
            double b = u.Dot(v);
            double c = v.Dot(v);
            double d = u.Dot(w0);
            double e = v.Dot(w0);

            double sc, tc;

            double eps = 1e-6;

            double denum = a * c - b * b;

            if (Math.Abs(denum) > eps)
            {
                sc = (b * e - c * d) / denum;
                tc = (a * e - b * d) / denum;
            }
            else
            {
                sc = 0;
                tc = d / b;
            }

            Point3D pc = p0.Add(u.MultiplyScalar(sc));
            Point3D qc = q0.Add(v.MultiplyScalar(tc));

            Point3D result = pc.Subtract(qc);

            if (result.Length() < 1e-6)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public void SetRenderMeshes(params Mesh[] meshes)
        {
            Models.Children.Clear();
            bool        firstMesh = true;
            BoundingBox bb        = new BoundingBox();

            _centerOfMass     = new Point3D();
            _centerOfGeometry = new Point3D();
            foreach (var mesh in meshes)
            {
                var bakedMesh = ResourceCache.GetModel(mesh);
                Models.Children.Add(bakedMesh.Mesh);
                _centerOfMass = Point3D.Add(_centerOfMass, bakedMesh.CenterOfMass.ToVector3D());
                if (firstMesh)
                {
                    bb        = bakedMesh.BoundingBox;
                    firstMesh = false;
                }
                else
                {
                    bb = BoundingBox.Merge(bb, bakedMesh.BoundingBox);
                }
                //bb = BoundingBox.Merge(bb, mesh.BoundingBox.ToSharpDxBoundingBox());
            }

            if (meshes.Length > 0)
            {
                _centerOfMass.X /= meshes.Length;
                _centerOfMass.Y /= meshes.Length;
                _centerOfMass.Z /= meshes.Length;
            }

            ClampBoundingBox(ref bb);
            _modelBoundingBox = bb;
            _centerOfGeometry = _modelBoundingBox.Center.ToPoint3D();
            ReferenceScale    = CalculateReferenceScale(_modelBoundingBox);
            //UpdateGridLines(bb);

            RaisePropertyChanged("Models");
            RefocusCenter();
            RaisePropertyChanged("ReferenceScale");
        }
Example #21
0
        public static void DebugLine(Creature creature, Point3D start, Point3D end)
        {
            const int iterations = 3;

            Point3D vector = Geom.GetNormal(Geom.GetHeading(start, end))
                             .Multiple((float)(start.DistanceTo(end) / (iterations - 1)));

            for (int i = 0; i < iterations; i++)
            {
                DropItem(creature, 20000001, 0, start.ToWorldPosition(), true);
                start.Add(vector);
            }

            Player player = creature as Player;

            if (player != null)
            {
                player.Visible.Update();
            }
        }
Example #22
0
        /// <summary>
        /// Vraca 3D koordinatu za viewport preko 2D koordinate kanvasa.
        /// 3D tocka je ortogonalno udaljena od kamere za neku vrijednost
        /// </summary>
        /// <param name="_kanvas2DKoordinata">2D koordinata neke tocke kanvasa (ne proslijediti Mouse.GetPosition()).</param>
        /// <param name="_udaljenostOdKamere">Fiksna ortogonalna udaljenost od kamere na kojoj se nalazi 3D tocka.</param>
        /// <returns></returns>
        public Point3D Projektor_3DViewportVia2DKanvas(Point _kanvas2DKoordinata, double _udaljenostOdKamere)
        {
            // tocka na plohi u koju gleda kamera, ploha prolazi kroz centar sustava

            Point3D p3d = (Point3D)
                          (RotMatricaZXY * new Vector3D(_kanvas2DKoordinata.X, 0, _kanvas2DKoordinata.Y));

            /*
             * Point3D p3d = prostorneRotacije.ZXY(
             *      new Point3D(_kanvas2DKoordinata.X, 0, _kanvas2DKoordinata.Y),
             *      KameraRotacijaKuteviXYZ_dp.Z,
             *      KameraRotacijaKuteviXYZ_dp.X,
             *      KameraRotacijaKuteviXYZ_dp.Y);
             */
            // tocka se translatira prema kameri na odredjenu udaljenost od nje
            Vector3D vektorTranslacije = KameraTranslacija_dp + KamRotacijaVektor * (KameraZoom_dp - _udaljenostOdKamere);

            p3d = Point3D.Add(p3d, vektorTranslacije);

            return(p3d);
        }
Example #23
0
        //orbit camera
        private void orbitUpdate(object sender, MouseEventArgs e)
        {
            var p = Mouse.GetPosition(this.Scene);

            this.navigationVectorVisual.X2 = p.X;
            this.navigationVectorVisual.Y2 = p.Y;
            if (!this.Scene.Children.Contains(this.navigationVectorVisual))
            {
                this.Scene.Children.Add(this.navigationVectorVisual);
            }
            // displacement on the scene
            Vector3D translationOn2DScene = new Vector3D(p.X - this.navigationVectorStart.X, p.Y - this.navigationVectorStart.Y, 0);
            Vector3D direction            = this.navigationMat.Transform(translationOn2DScene);

            direction  = direction - Vector3D.DotProduct(this.initialCameraLookDirection, direction) * this.initialCameraLookDirection;
            direction *= UnitConversion.Convert(1.0d, Length_Unit_Types.FEET, this._host.BIM_To_OSM.UnitType);
            if (direction.Length != 0)
            {
                Point3D  pn1 = Vector3D.Add(direction, this.initialCameraPosition);
                Vector3D fromTargetToCamera = Point3D.Subtract(pn1, this.targetPoint);
                Vector3D translation        = fromTargetToCamera * (this.distanceToTargetPoint / fromTargetToCamera.Length);
                //getting new camera position
                Point3D newCamPos = Point3D.Add(targetPoint, translation);
                //getting new camera look direction
                var newCamDir = -1 * fromTargetToCamera;
                newCamDir.Normalize();
                //getting new camera up direction
                Vector3D helper = Vector3D.CrossProduct(newCamDir, this.initialCameraUpDirection);
                Vector3D newUp  = Vector3D.CrossProduct(helper, newCamDir);
                if (newUp.LengthSquared != 0)
                {
                    newUp.Normalize();
                }
                this.camera.UpDirection   = newUp;
                this.camera.Position      = newCamPos;
                this.camera.LookDirection = newCamDir;
            }
        }
Example #24
0
        // kanvas2D -> viewport3D
        /// <summary>
        /// Vraca 3D koordinatu za viewport preko 2D koordinate kanvasa.
        /// 3D tocka se nalazi na plohi koja prolazi kroz ishodiste sustava i zarotirana je prema kameri.
        /// </summary>
        /// <param name="_kanvas2DKoordinata">2D koordinata neke tocke kanvasa (ne proslijediti Mouse.GetPosition()).</param>
        /// <returns></returns>
        public Point3D Projektor_3DViewportVia2DKanvas(Point _kanvas2DKoordinata)
        {
            // tocka na plohi u koju gleda kamera, ploha prolazi kroz centar sustava

            Point3D p3d = (Point3D)
                          (RotMatricaZXY * new Vector3D(_kanvas2DKoordinata.X, 0, _kanvas2DKoordinata.Y));

            /*
             * Point3D p3d = prostorneRotacije.ZXY(
             *      new Point3D(_kanvas2DKoordinata.X, 0, _kanvas2DKoordinata.Y),
             *      KameraRotacijaKuteviXYZ_dp.Z,
             *      KameraRotacijaKuteviXYZ_dp.X,
             *      KameraRotacijaKuteviXYZ_dp.Y);
             */
            Vector3D vektorPozicijeKam = KameraTranslacija_dp + KamRotacijaVektor * KameraZoom_dp;
            // udaljenost centralne plohe od kamere (ploha u koju kamera gleda a prolazi kroz (0,0,0)
            double udaljenostOdKamere = Vector3D.DotProduct(vektorPozicijeKam, KamRotacijaVektor);

            Vector3D vektorTranslacije = KameraTranslacija_dp + KamRotacijaVektor * (KameraZoom_dp - udaljenostOdKamere);

            p3d = Point3D.Add(p3d, vektorTranslacije);

            return(p3d);
        }
Example #25
0
        internal MeshGeometry3D AutoSnake(MeshGeometry3D mesh, ref MeshBuilder newmbP)
        {
            //Dictionary<Int32, SmileEdge> neighbours = SmileVisual3D.findNeighbours(mesh);

            Point3DCollection positions       = mesh.Positions;
            Int32Collection   triangleIndices = mesh.TriangleIndices;
            Mesh3D            m3d             = new Mesh3D(positions, triangleIndices);

            Vector3DCollection t          = new Vector3DCollection(positions.Count);
            Vector3DCollection b          = new Vector3DCollection(positions.Count);
            Vector3DCollection n          = new Vector3DCollection(positions.Count);
            double             eThreshold = -0.5;
            double             nThreshold = 0.8;
            double             minEnergy  = 10;
            double             alpha      = 1;
            double             betha      = 1;
            double             ballon     = 1;
            double             lambda     = 1;
            Vector3DCollection e          = new Vector3DCollection(positions.Count);
            Vector3DCollection eInt       = new Vector3DCollection(positions.Count);
            Vector3DCollection eExt       = new Vector3DCollection(positions.Count);

            Vector3DCollection delta = new Vector3DCollection(positions.Count);
            Vector3DCollection f     = new Vector3DCollection(positions.Count);
            Vector3DCollection tETF  = new Vector3DCollection(positions.Count);

            //Vector3DCollection k = new Vector3DCollection();
            //DoubleCollection kH = new DoubleCollection();
            Dictionary <int, Double> kH = new Dictionary <int, double>();
            MeshBuilder newmbD          = new MeshBuilder(false, false);

            for (int i = 0; i < triangleIndices.Count; i += 3)
            {
                for (int a = 0; a < 3; a++)
                {
                    int vi = triangleIndices[i + a];

                    if (!kH.ContainsKey(vi))
                    {
                        double kHi = _MeanCurvature(m3d, vi);
                        kH.Add(vi, kHi);
                    }
                    //Console.WriteLine("start mean");
                    //kH.Add(kHi);
                    //Console.WriteLine("end mean");
                    if (a == 2)
                    {
                        int    vi1 = triangleIndices[i + a - 1];
                        int    vi2 = triangleIndices[i + a - 2];
                        double kH3 = 0;
                        kH.TryGetValue(vi, out kH3);
                        double kH2 = 0;
                        kH.TryGetValue(vi1, out kH2);
                        double kH1 = 0;
                        kH.TryGetValue(vi2, out kH1);

                        if ((kH3 < eThreshold || kH2 < eThreshold || kH1 < eThreshold))
                        {
                            newmbD.Positions.Add(positions[vi]);
                            newmbD.Positions.Add(positions[vi1]);
                            newmbD.Positions.Add(positions[vi2]);
                            newmbD.TriangleIndices.Add(i + a);
                            newmbD.TriangleIndices.Add(i + a - 1);
                            newmbD.TriangleIndices.Add(i + a - 2);
                        }
                        if ((kH3 > nThreshold || kH2 > nThreshold || kH1 > nThreshold))
                        {
                            newmbP.Positions.Add(positions[vi]);
                            newmbP.Positions.Add(positions[vi1]);
                            newmbP.Positions.Add(positions[vi2]);
                            newmbP.TriangleIndices.Add(i + a);
                            newmbP.TriangleIndices.Add(i + a - 1);
                            newmbP.TriangleIndices.Add(i + a - 2);
                        }
                    }

                    int[] nbrs            = m3d.GetNeighbourVertices(vi);
                    Vector3DCollection N  = new Vector3DCollection(positions.Count);
                    Point3D            pi = positions[vi];
                    int i0 = triangleIndices[i + a];
                    if (i + a - 1 >= 0)
                    {
                        i0 = triangleIndices[i + a - 1];
                    }
                    Point3D pi0 = positions[i0];
                    int     i1  = vi;
                    if (i + a + i < triangleIndices.Count)
                    {
                        i1 = triangleIndices[i + a + 1];
                    }
                    Point3D pi1 = positions[i1];

                    t.Insert(vi, (pi1 - pi0) / (Point3D.Subtract(pi1, pi0).Length));
                    //t[i] = (pi1 - pi0) / Math.Sqrt((Point3D.Subtract(pi1, pi0).Length));
                    n.Insert(vi, SmileVisual3D.CalculateNormal(pi0, pi, pi1));
                    b.Insert(vi, Vector3D.CrossProduct(t[vi], n[vi]));

                    Vector3D eIntV        = new Vector3D(); //eInt[vi];
                    Vector3D eExtV        = new Vector3D(); //eExt[vi];
                    Vector3D eV           = new Vector3D(); //e[vi];
                    Vector3D sumDeltaNbrs = new Vector3D();
                    Vector3D sumFNbrs     = new Vector3D();
                    int      maxNbrs      = (nbrs.Length > 2 ? 2 : nbrs.Length);
                    for (int j = 0; j < maxNbrs; j++)
                    {
                        Point3D nbj = positions[nbrs[j]];
                        N.Add(nbj.ToVector3D());
                    }
                    double determinantVi = determinant(N);
                    double kv            = 0;
                    kH.TryGetValue(vi, out kv);
                    double  jminEnergy = minEnergy;
                    Point3D tempNbj    = pi;
                    for (int j = 0; j < maxNbrs; j++)
                    {
                        Point3D nbj = positions[nbrs[j]];

                        double ku = 0;
                        kH.TryGetValue(nbrs[j], out ku);
                        sumDeltaNbrs += Vector3D.Multiply((kv - ku), Vector3D.Divide(Point3D.Subtract(nbj, pi), (Point3D.Subtract(nbj, pi).Length)));
                        delta.Insert(vi, (1 / determinantVi) * sumDeltaNbrs);
                        f.Insert(vi, Vector3D.Multiply((1 - lambda), Vector3D.Multiply((1 / determinantVi), new Vector3D())) + Vector3D.Multiply(lambda, delta[vi]));
                        double eIntj   = alpha * (Point3D.Subtract(pi0, nbj).Length) + betha * (Point3D.Subtract(pi0, Point3D.Add(pi1, (Vector3D)nbj)).Length);                    //TODO: crosscheck
                        double eFaej   = ballon * (-(f[vi].Length) - Vector3D.DotProduct((f[vi] / f[vi].Length), (Point3D.Subtract(nbj, pi) / Point3D.Subtract(nbj, pi).Length))); //TODO: crosscheck
                        double ePressj = ballon * Vector3D.DotProduct(b[vi], (Point3D.Subtract(pi0, nbj) / Point3D.Subtract(pi0, nbj).Length));
                        double eExtj   = eFaej + ePressj;
                        double ej      = eIntj + eExtj;

                        if (j == 0)
                        {
                            eIntV.X = eIntj;
                            eExtV.X = eExtj;
                            eV.X    = ej;
                        }
                        if (j == 1)
                        {
                            eIntV.Y = eIntj;
                            eExtV.Y = eExtj;
                            eV.Y    = ej;
                        }
                        if (j == 2)
                        {
                            eIntV.Z = eIntj;
                            eExtV.Z = eExtj;
                            eV.Z    = ej;
                        }

                        if (ej < jminEnergy)
                        {
                            jminEnergy = ej;
                            tempNbj    = nbj;
                            //TODO: snake movement
                            //AddSnakeElement(nbj);
                        }
                    }
                    AddSnakeElement(tempNbj);

                    eInt.Insert(vi, eIntV);
                    eExt.Insert(vi, eExtV);
                    e.Insert(vi, eV);

                    //delta.Insert(vi,  (1 / determinant(N[vi])) * sumDeltaNbrs); //TODO:implemenet
                    //f.Insert(vi, n[vi]);// (1 - lambda) * (1 / (Math.Abs(nbrs.Count))) + lambda *delta[i]; //TODO:implemenet

                    tETF.Insert(vi, Vector3D.CrossProduct(delta[vi], n[vi]));
                }
            }
            return(newmbD.ToMesh());

/*
 *          for (int i = 0; i < positions.Count; i++)
 *          {
 *              Int32Collection nbrs = neighbours[i].neighbours;
 *
 *              Point3D pi = positions[i];
 *              int i0 = i;
 *              if (i - 1 >= 0) i0 = i - 1;
 *              Point3D pi0 = positions[i0];
 *              int i1 = i;
 *              if (i + i < triangleIndices.Count) i = i + 1;
 *              Point3D pi1 = positions[i1];
 *
 *              t[i] = (pi1 - pi0) / (Point3D.Subtract(pi1, pi0).Length);
 *              //t[i] = (pi1 - pi0) / Math.Sqrt((Point3D.Subtract(pi1, pi0).Length));
 *              n[i] = SmileVisual3D.CalculateNormal(pi0, pi, pi1);
 *              b[i] = Vector3D.CrossProduct(t[i], n[i]);
 *
 *
 *              Vector3D eIntV = eInt[i];
 *              Vector3D eExtV = eExt[i];
 *              Vector3D eV = e[i];
 *              int maxNbrs = (nbrs.Count > 2 ? 2 : nbrs.Count);
 *              for (int j = 0; j < maxNbrs; j++)
 *              {
 *                  Point3D nbj = positions[nbrs[j]];
 *                  double eIntj = alpha * (Point3D.Subtract(pi0, nbj).Length) + betha * (Point3D.Subtract(pi0, Point3D.Add(pi1, (Vector3D)nbj)).Length); //TODO: crosscheck
 *
 *
 *                  delta[i] = n[i];// 1 / determinant(N[i]); //TODO:implemenet
 *                  f[i] = n[i];// (1 - lambda) * (1 / (Math.Abs(nbrs.Count))) + lambda *delta[i]; //TODO:implemenet
 *
 *
 *                  double eFaej = ballon * (-(f[i].Length) - Vector3D.DotProduct((f[i] / f[i].Length), (Point3D.Subtract(nbj, pi) / Point3D.Subtract(nbj, pi).Length))); //TODO: crosscheck
 *                  double ePressj = ballon * Vector3D.DotProduct(b[i], (Point3D.Subtract(pi0, nbj) / Point3D.Subtract(pi0, nbj).Length));
 *                  double eExtj = eFaej + ePressj;
 *                  double ej = eIntj + eExtj;
 *
 *                  if (j == 0)
 *                  {
 *                      eIntV.X = eIntj;
 *                      eExtV.X = eExtj;
 *                      eV.X = ej;
 *                  }
 *                  if (j == 1)
 *                  {
 *                      eIntV.Y = eIntj;
 *                      eExtV.Y = eExtj;
 *                      eV.Y = ej;
 *                  }
 *                  if (j == 2)
 *                  {
 *                      eIntV.Z = eIntj;
 *                      eExtV.Z = eExtj;
 *                      eV.Z = ej;
 *                  }
 *
 *                  if (ej < minEnergy)
 *                  {
 *                      minEnergy = ej;
 *                      //TODO: snake movement
 *                      AddSnakeElement(nbj);
 *                  }
 *
 *                  eInt[i] = eIntV;
 *                  eExt[i] = eExtV;
 *                  e[i] = eV;
 *              }
 *
 *              tETF[i] = Vector3D.CrossProduct(delta[i], n[i]);
 *
 *          }
 * */
        }
Example #26
0
        //ref: Snake-Based Segmentation of Teeth from Virtual Dental Casts
        //pLane located manually, set of verteks D and P from manual cutting plane
        //the plan is: teeth and gum separated then teeth segmented using snake below
        public static void snake(MeshGeometry3D mesh)
        {
            Dictionary <Int32, SmileEdge> neighbours = SmileVisual3D.findNeighbours(mesh);
            Point3DCollection             pos        = mesh.Positions;
            Int32Collection    ind        = mesh.TriangleIndices;
            Vector3DCollection t          = new Vector3DCollection();
            Vector3DCollection b          = new Vector3DCollection();
            Vector3DCollection n          = new Vector3DCollection();
            double             eThreshold = -0.3;
            double             nThreshold = 0.8;
            double             minEnergy  = 10;
            double             alpha      = 1;
            double             betha      = 1;
            double             ballon     = 1;
            double             lambda     = 1;
            Vector3DCollection e          = new Vector3DCollection();
            Vector3DCollection eInt       = new Vector3DCollection();
            Vector3DCollection eExt       = new Vector3DCollection();

            Vector3DCollection        delta = new Vector3DCollection();
            List <Vector3DCollection> N     = new List <Vector3DCollection>();
            Vector3DCollection        f     = new Vector3DCollection();
            Vector3DCollection        tETF  = new Vector3DCollection();

            Vector3DCollection k    = new Vector3DCollection();
            Vector3DCollection kH   = new Vector3DCollection();
            Vector3DCollection kMin = new Vector3DCollection();
            Vector3DCollection kMax = new Vector3DCollection();

            for (int i = 0; i < ind.Count; i++)
            {
                Point3D pi = pos[i];
                //kij =  2ni ยท (pi - pj)/|pi- pj |2
                kH[i] = (kMin[i] + kMax[i]) / 2;
            }

            for (int i = 0; i < ind.Count; i++)
            {
                Int32Collection nbrs = neighbours[i].neighbours;

                Point3D pi = pos[i];
                int     i0 = i;
                if (i - 1 >= 0)
                {
                    i0 = i - 1;
                }
                Point3D pi0 = pos[i0];
                int     i1  = i;
                if (i + i < ind.Count)
                {
                    i = i + 1;
                }
                Point3D pi1 = pos[i1];

                t[i] = (pi1 - pi0) / (Point3D.Subtract(pi1, pi0).Length);
                //t[i] = (pi1 - pi0) / Math.Sqrt((Point3D.Subtract(pi1, pi0).Length));
                n[i] = SmileVisual3D.CalculateNormal(pi0, pi, pi1);
                b[i] = Vector3D.CrossProduct(t[i], n[i]);


                Vector3D eIntV   = eInt[i];
                Vector3D eExtV   = eExt[i];
                Vector3D eV      = e[i];
                int      maxNbrs = (nbrs.Count > 2 ? 2 : nbrs.Count);
                for (int j = 0; j < maxNbrs; j++)
                {
                    Point3D nbj   = pos[nbrs[j]];
                    double  eIntj = alpha * (Point3D.Subtract(pi0, nbj).Length) + betha * (Point3D.Subtract(pi0, Point3D.Add(pi1, (Vector3D)nbj)).Length); //TODO: crosscheck


                    delta[i] = n[i]; // 1 / determinant(N[i]); //TODO:implemenet
                    f[i]     = n[i]; // (1 - lambda) * (1 / (Math.Abs(nbrs.Count))) + lambda *delta[i]; //TODO:implemenet


                    double eFaej   = ballon * (-(f[i].Length) - Vector3D.DotProduct((f[i] / f[i].Length), (Point3D.Subtract(nbj, pi) / Point3D.Subtract(nbj, pi).Length))); //TODO: crosscheck
                    double ePressj = ballon * Vector3D.DotProduct(b[i], (Point3D.Subtract(pi0, nbj) / Point3D.Subtract(pi0, nbj).Length));
                    double eExtj   = eFaej + ePressj;
                    double ej      = eIntj + eExtj;

                    if (j == 0)
                    {
                        eIntV.X = eIntj;
                        eExtV.X = eExtj;
                        eV.X    = ej;
                    }
                    if (j == 1)
                    {
                        eIntV.Y = eIntj;
                        eExtV.Y = eExtj;
                        eV.Y    = ej;
                    }
                    if (j == 2)
                    {
                        eIntV.Z = eIntj;
                        eExtV.Z = eExtj;
                        eV.Z    = ej;
                    }

                    if (ej < minEnergy)
                    {
                        minEnergy = ej;
                        //TODO: snake movement
                        AddSnakeElement(nbj);
                    }

                    eInt[i] = eIntV;
                    eExt[i] = eExtV;
                    e[i]    = eV;
                }

                tETF[i] = Vector3D.CrossProduct(delta[i], n[i]);
            }
        }
Example #27
0
        /// <summary>
        /// Block face constructor
        /// </summary>
        /// <param name="Block">Parent Block</param>
        /// <param name="FaceNo">Face number</param>
        /// <param name="FaceColor">Initial face color</param>
        public BlockFace3D
        (
            Block3D Block,
            int FaceNo,
            int FaceColor
        )
        {
            // save face number
            this.FaceNo = FaceNo;

            // set current color
            CurrentColor = FaceColor;

            // initialize some geometric variables
            Point3D  Point0 = new Point3D();
            Point3D  Point1 = new Point3D();
            Point3D  Point2 = new Point3D();
            Point3D  Point3 = new Point3D();
            Vector3D Normal = new Vector3D();

            switch (FaceColor)
            {
            case Cube.WhiteFace:
                Point0 = new Point3D(Block.OrigX, Block.OrigY, Block.OrigZ);
                Point1 = new Point3D(Block.OrigX, Block.OrigY + Cube3D.BlockWidth, Block.OrigZ);
                Point2 = new Point3D(Block.OrigX + Cube3D.BlockWidth, Block.OrigY + Cube3D.BlockWidth, Block.OrigZ);
                Point3 = new Point3D(Block.OrigX + Cube3D.BlockWidth, Block.OrigY, Block.OrigZ);
                Normal = new Vector3D(0, 0, -1);
                break;

            case Cube.BlueFace:
                Point0 = new Point3D(Block.OrigX, Block.OrigY + Cube3D.BlockWidth, Block.OrigZ + Cube3D.BlockWidth);
                Point1 = new Point3D(Block.OrigX, Block.OrigY + Cube3D.BlockWidth, Block.OrigZ);
                Point2 = new Point3D(Block.OrigX, Block.OrigY, Block.OrigZ);
                Point3 = new Point3D(Block.OrigX, Block.OrigY, Block.OrigZ + Cube3D.BlockWidth);
                Normal = new Vector3D(-1, 0, 0);
                break;

            case Cube.RedFace:
                Point0 = new Point3D(Block.OrigX, Block.OrigY, Block.OrigZ + Cube3D.BlockWidth);
                Point1 = new Point3D(Block.OrigX, Block.OrigY, Block.OrigZ);
                Point2 = new Point3D(Block.OrigX + Cube3D.BlockWidth, Block.OrigY, Block.OrigZ);
                Point3 = new Point3D(Block.OrigX + Cube3D.BlockWidth, Block.OrigY, Block.OrigZ + Cube3D.BlockWidth);
                Normal = new Vector3D(0, -1, 0);
                break;

            case Cube.GreenFace:
                Point0 = new Point3D(Block.OrigX + Cube3D.BlockWidth, Block.OrigY, Block.OrigZ + Cube3D.BlockWidth);
                Point1 = new Point3D(Block.OrigX + Cube3D.BlockWidth, Block.OrigY, Block.OrigZ);
                Point2 = new Point3D(Block.OrigX + Cube3D.BlockWidth, Block.OrigY + Cube3D.BlockWidth, Block.OrigZ);
                Point3 = new Point3D(Block.OrigX + Cube3D.BlockWidth, Block.OrigY + Cube3D.BlockWidth, Block.OrigZ + Cube3D.BlockWidth);
                Normal = new Vector3D(1, 0, 0);
                break;

            case Cube.OrangeFace:
                Point0 = new Point3D(Block.OrigX + Cube3D.BlockWidth, Block.OrigY + Cube3D.BlockWidth, Block.OrigZ + Cube3D.BlockWidth);
                Point1 = new Point3D(Block.OrigX + Cube3D.BlockWidth, Block.OrigY + Cube3D.BlockWidth, Block.OrigZ);
                Point2 = new Point3D(Block.OrigX, Block.OrigY + Cube3D.BlockWidth, Block.OrigZ);
                Point3 = new Point3D(Block.OrigX, Block.OrigY + Cube3D.BlockWidth, Block.OrigZ + Cube3D.BlockWidth);
                Normal = new Vector3D(0, 1, 0);
                break;

            case Cube.YellowFace:
                Point0 = new Point3D(Block.OrigX, Block.OrigY + Cube3D.BlockWidth, Block.OrigZ + Cube3D.BlockWidth);
                Point1 = new Point3D(Block.OrigX, Block.OrigY, Block.OrigZ + Cube3D.BlockWidth);
                Point2 = new Point3D(Block.OrigX + Cube3D.BlockWidth, Block.OrigY, Block.OrigZ + Cube3D.BlockWidth);
                Point3 = new Point3D(Block.OrigX + Cube3D.BlockWidth, Block.OrigY + Cube3D.BlockWidth, Block.OrigZ + Cube3D.BlockWidth);
                Normal = new Vector3D(0, 0, 1);
                break;
            }

            // hidden black faces
            if (FaceNo < 0)
            {
                DiffuseMaterial BlackMaterial = new DiffuseMaterial(Brushes.Black);
                Block.Children.Add(CreateTriangle(Point0, Point1, Point2, Normal, BlackMaterial));
                Block.Children.Add(CreateTriangle(Point0, Point2, Point3, Normal, BlackMaterial));
                return;
            }

            // calculate points to separate block edge and block face
            Vector3D Diag02 = Point3D.Subtract(Point2, Point0);
            Point3D  Point4 = Point3D.Add(Point0, Vector3D.Multiply(0.04, Diag02));
            Point3D  Point6 = Point3D.Add(Point0, Vector3D.Multiply(0.96, Diag02));

            Vector3D Diag13 = Point3D.Subtract(Point3, Point1);
            Point3D  Point5 = Point3D.Add(Point1, Vector3D.Multiply(0.04, Diag13));
            Point3D  Point7 = Point3D.Add(Point1, Vector3D.Multiply(0.96, Diag13));

            // gray edge
            DiffuseMaterial GrayMaterial = new DiffuseMaterial(Brushes.DarkGray);

            Block.Children.Add(CreateTriangle(Point0, Point1, Point5, Normal, GrayMaterial));
            Block.Children.Add(CreateTriangle(Point0, Point5, Point4, Normal, GrayMaterial));

            Block.Children.Add(CreateTriangle(Point1, Point2, Point6, Normal, GrayMaterial));
            Block.Children.Add(CreateTriangle(Point1, Point6, Point5, Normal, GrayMaterial));

            Block.Children.Add(CreateTriangle(Point2, Point3, Point7, Normal, GrayMaterial));
            Block.Children.Add(CreateTriangle(Point2, Point7, Point6, Normal, GrayMaterial));

            Block.Children.Add(CreateTriangle(Point3, Point0, Point4, Normal, GrayMaterial));
            Block.Children.Add(CreateTriangle(Point3, Point4, Point7, Normal, GrayMaterial));

            // block face color
            DiffuseMaterial ColorMaterial = Cube3D.Material[FaceColor];

            Block.Children.Add(CreateTriangle(Point4, Point5, Point6, Normal, ColorMaterial, 1));
            Block.Children.Add(CreateTriangle(Point4, Point6, Point7, Normal, ColorMaterial, 2));
            return;
        }
Example #28
0
        // This method performs the Point3D operations
        //<SnippetMil3DPoints3DN1>
        private void PerformOperation(object sender, RoutedEventArgs e)
        {
            RadioButton li = (sender as RadioButton);

            // Strings used to display the results
            String syntaxString, resultType, operationString;

            // The local variables point1, point2, vector2, etc are defined in each
            // case block for readability reasons. Each variable is contained within
            // the scope of each case statement.
            switch (li.Name)
            {               //begin switch
            //</SnippetMil3DPoints3DN1>
            case "rb1":
            {
                //<SnippetMil3DPoints3DN3>
                // Translates a Point3D by a Vector3D using the overloaded + operator.
                // Returns a Point3D.

                Point3D  point1      = new Point3D(10, 5, 1);
                Vector3D vector1     = new Vector3D(20, 30, 40);
                Point3D  pointResult = new Point3D();

                pointResult = point1 + vector1;
                // point3DResult is equal to (30, 35, 41)

                // Displaying Results
                syntaxString    = "pointResult = point1 + vector1;";
                resultType      = "Point3D";
                operationString = "Adding a 3D Point and a 3D Vector";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN3>
                break;
            }

            case "rb2":
            {
                //<SnippetMil3DPoints3DN4>
                // Translates a Point3D by a Vector3D using the static Add method.
                // Returns a Point3D.

                Point3D  point1      = new Point3D(10, 5, 1);
                Vector3D vector1     = new Vector3D(20, 30, 40);
                Point3D  pointResult = new Point3D();

                pointResult = Point3D.Add(point1, vector1);
                // pointResult is equal to (30, 35, 41)

                // Displaying Results
                syntaxString    = "pointResult = Point3D.Add(point1, vector1);";
                resultType      = "Point3D";
                operationString = "Adding a 3D Point and a 3D Vector";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN4>
                break;
            }

            case "rb3":
            {
                //<SnippetMil3DPoints3DN5>
                // Subtracts a Vector3D from a Point3D using the overloaded - operator.
                // Returns a Point3D.

                Point3D  point1      = new Point3D(10, 5, 1);
                Vector3D vector1     = new Vector3D(20, 30, 40);
                Point3D  pointResult = new Point3D();

                pointResult = point1 - vector1;
                // pointResult is equal to (-10, -25, -39)

                // Displaying Results
                syntaxString    = "pointResult = point1 - vector1;";
                resultType      = "Point3D";
                operationString = "Subtracting a Vector3D from a Point3D";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN5>
                break;
            }

            case "rb4":
            {
                //<SnippetMil3DPoints3DN6>
                // Subtracts a Vector3D from a Point3D using the static Subtract method.
                // Returns a Point3D.

                Point3D  point1      = new Point3D(10, 5, 1);
                Vector3D vector1     = new Vector3D(20, 30, 40);
                Point3D  pointResult = new Point3D();

                pointResult = Point3D.Subtract(point1, vector1);
                // pointResult is equal to (-10, -25, -39)

                // Displaying Results
                syntaxString    = "pointResult = Point3D.Subtract(point1, vector1);";
                resultType      = "Point3D";
                operationString = "Subtracting a Vector3D from a Point3D";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN6>
                break;
            }

            case "rb5":
            {
                //<SnippetMil3DPoints3DN7>
                // Subtracts a Point3D from a Point3D using the overloaded - operator.
                // Returns a Vector3D.

                Point3D  point1       = new Point3D(10, 5, 1);
                Point3D  point2       = new Point3D(15, 40, 60);
                Vector3D vectorResult = new Vector3D();

                vectorResult = point1 - point2;
                // vectorResult is equal to (-5, -35, -59)

                // Displaying Results
                syntaxString    = " vectorResult = point1 - point2;";
                resultType      = "Vector3D";
                operationString = "Subtracting a Point3D from a Point3D";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN7>
                break;
            }

            case "rb6":
            {
                //<SnippetMil3DPoints3DN8>
                // Subtracts a Point3D from a Point3D using the static Subtract method.
                // Returns a Vector3D.

                Point3D  point1       = new Point3D(10, 5, 1);
                Point3D  point2       = new Point3D(15, 40, 60);
                Vector3D vectorResult = new Vector3D();

                vectorResult = Point3D.Subtract(point1, point2);
                // vectorResult is equal to (-5, -35, -59)

                // Displaying Results
                syntaxString    = "vectorResult = Point3D.Subtract(point1, point2);";
                resultType      = "Vector3D";
                operationString = "Subtracting a Point3D from a Point3D";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN8>
                break;
            }

            case "rb7":
            {
                //<SnippetMil3DPoints3DN9>
                // Offsets the X, Y and Z values of a Point3D.

                Point3D point1 = new Point3D(10, 5, 1);

                point1.Offset(20, 30, 40);
                // point1 is equal to (30, 35, 41)

                // Note: This operation is equivalent to adding a point
                // to vector with the corresponding X,Y, Z values.

                // Displaying Results
                syntaxString    = "point1.Offset(20, 30, 40);";
                resultType      = "Point3D";
                operationString = "Offsetting a Point3D";
                ShowResults(point1.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN9>
                break;
            }

            case "rb8":
            {
                //<SnippetMil3DPoints3DN10>
                // Multiplies a Point3D by a Matrix.
                // Returns a Point3D.

                Point3D  point1      = new Point3D(10, 5, 1);
                Point3D  pointResult = new Point3D();
                Matrix3D matrix1     = new Matrix3D(10, 10, 10, 0, 20, 20, 20, 0, 30, 30, 30, 0, 5, 10, 15, 1);

                pointResult = point1 * matrix1;
                // pointResult is equal to (235, 240, 245)

                // Displaying Results
                resultType      = "Point3D";
                syntaxString    = "pointResult = point1 * matrix1;";
                operationString = "Multiplying a Point3D by a Matrix3D";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN10>
                break;
            }

            case "rb9":
            {
                //<SnippetMil3DPoints3DN11>
                // Multiplies a Point3D by a Matrix.
                // Returns a Point3D.

                Point3D  point1      = new Point3D(10, 5, 1);
                Point3D  pointResult = new Point3D();
                Matrix3D matrix1     = new Matrix3D(10, 10, 10, 0, 20, 20, 20, 0, 30, 30, 30, 0, 5, 10, 15, 1);

                pointResult = Point3D.Multiply(point1, matrix1);
                // pointResult is equal to (235, 240, 245)

                // Displaying Results
                resultType      = "Point3D";
                syntaxString    = "pointResult = Point3D.Multiply(point1, matrix1);";
                operationString = "Multiplying a Point3D by a Matrix";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN11>
                break;
            }

            case "rb10":
            {
                //<SnippetMil3DPoints3DN12>
                // Checks if two Point3Ds are equal using the overloaded equality operator.

                Point3D point1 = new Point3D(10, 5, 1);
                Point3D point2 = new Point3D(15, 40, 60);
                Boolean areEqual;

                areEqual = (point1 == point2);
                // areEqual is False

                // Displaying Results
                syntaxString    = "areEqual = (point1 == point2);";
                resultType      = "Boolean";
                operationString = "Checking if two 3D points are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN12>
                break;
            }


            case "rb11":
            {
                //<SnippetMil3DPoints3DN13>
                // Checks if two Point3D structures are equal using the static Equals method.

                Point3D point1 = new Point3D(10, 5, 1);
                Point3D point2 = new Point3D(15, 40, 60);
                Boolean areEqual;

                areEqual = Point3D.Equals(point1, point2);
                // areEqual is False

                //Displaying Results
                syntaxString    = "areEqual = Point3D.Equals(point1, point2);";
                resultType      = "Boolean";
                operationString = "Checking if 3D two points are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN13>
                break;
            }

            case "rb12":
            {
                //<SnippetMil3DPoints3DN14>
                // Compares an Object and a Point3D for equality using the non-static Equals method.

                Point3D point1 = new Point3D(10, 5, 1);
                Point3D point2 = new Point3D(15, 40, 60);
                Boolean areEqual;

                areEqual = point1.Equals(point2);
                // areEqual is False.  point2 is a Point3D structure, but it is not equal to point1.


                // Displaying Results
                syntaxString    = "areEqual = point1.Equals(point2);;";
                resultType      = "Boolean";
                operationString = "Checking if two 3D points are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN14>
                break;
            }


            case "rb13":
            {
                //<SnippetMil3DPoints3DN15>
                // Converts a string representation of a 3-D point into a Point3D structure.

                Point3D pointResult = new Point3D();

                pointResult = Point3D.Parse("1,3,5");
                // pointResult is equal to (1,3,5)

                // Displaying Results
                syntaxString    = "ointResult = Point3D.Parse(\"1,3,5\");";
                resultType      = "Matrix";
                operationString = "Converting a string into a Point3D structure.";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN15>
                break;
            }

            case "rb14":
            {
                //<SnippetMil3DPoints3DN16>
                // Checks if two Point3Ds are not equal using the overloaded inequality operator.

                Point3D point1 = new Point3D(10, 5, 1);
                Point3D point2 = new Point3D(15, 40, 60);
                Boolean areNotEqual;

                areNotEqual = (point1 != point2);
                // areNotEqual is True

                // Displaying Results
                syntaxString    = "areNotEqual = (point1 != point2);";
                resultType      = "Boolean";
                operationString = "Checking if two 3D points are not equal";
                ShowResults(areNotEqual.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN16>
                break;
            }

            case "rb15":
            {
                //<SnippetMil3DPoints3DN17>
                // Point3D Subtraction

                // instantiate variables
                Point3D  point1       = new Point3D();
                Point3D  point2       = new Point3D(15, 40, 60);
                Vector3D vector1      = new Vector3D(20, 30, 40);
                Point3D  pointResult  = new Point3D();
                Vector3D vectorResult = new Vector3D();

                // defining x,y,z of point1
                point1.X = 10;
                point1.Y = 5;
                point1.Z = 1;

                vectorResult = Point3D.Subtract(point1, point2);
                // vectorResult is equal to (-5, -35, -39)

                vectorResult = point2 - point1;
                // vectorResult is equal to (5, 35, 59)

                //pointResult = Point3D.Subtract(point1, vector1);
                //  pointResult is equal to (-10, -25, -39)

                pointResult = vector1 - point1;
                //  pointResult is equal to (10, 25, 39)


                // Displaying Results
                syntaxString    = "areNotEqual = (point1 != point2);";
                resultType      = "Boolean";
                operationString = "Checking if two 3D points are not equal";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN17>
                break;
            }

            default:
                break;
                //<SnippetMil3DPoints3DN2>
            } //end switch
        }
Example #29
0
        public MyObjectBuilder_EntityBase BuildEntity()
        {
            var asteroidCenter = new VRageMath.Vector3D();
            var asteroidSize   = new Vector3I();

            string originalFile = null;

            if (IsStockVoxel)
            {
                var stockfile = StockVoxel.SourceFilename;

                if (StockMaterial == null || StockMaterial.Value == null)
                {
                    SourceFile   = stockfile;
                    originalFile = SourceFile;
                    var asteroid = new MyVoxelMap();
                    asteroid.Load(stockfile);
                    asteroidCenter = asteroid.BoundingContent.Center;
                    asteroidSize   = asteroid.BoundingContent.Size + 1; // Content size
                }
                else
                {
                    var asteroid = new MyVoxelMap();
                    asteroid.Load(stockfile);
                    asteroid.ForceBaseMaterial(SpaceEngineersCore.Resources.GetDefaultMaterialName(), StockMaterial.Value);
                    SourceFile = TempfileUtil.NewFilename(MyVoxelMap.V2FileExtension);
                    asteroid.Save(SourceFile);

                    originalFile   = StockVoxel.SourceFilename;
                    asteroidCenter = asteroid.BoundingContent.Center;
                    asteroidSize   = asteroid.BoundingContent.Size + 1; // Content size
                }
            }
            else if (IsFileVoxel)
            {
                originalFile = SourceFile;

                var asteroid = new MyVoxelMap();
                asteroid.Load(SourceFile);
                asteroidCenter = asteroid.BoundingContent.Center;
                asteroidSize   = asteroid.BoundingContent.Size + 1; // Content size

                if (StockMaterial != null && StockMaterial.Value != null)
                {
                    asteroid.ForceBaseMaterial(SpaceEngineersCore.Resources.GetDefaultMaterialName(), StockMaterial.Value);
                    SourceFile = TempfileUtil.NewFilename(MyVoxelMap.V2FileExtension);
                    asteroid.Save(SourceFile);
                }
            }
            else if (IsSphere)
            {
                byte materialIndex;
                if (StockMaterial?.MaterialIndex != null)
                {
                    materialIndex = StockMaterial.MaterialIndex.Value;
                }
                else
                {
                    materialIndex = SpaceEngineersCore.Resources.GetDefaultMaterialIndex();
                }

                string materialName = SpaceEngineersCore.Resources.GetMaterialName(materialIndex);

                originalFile = string.Format("sphere_{0}_{1}_{2}{3}", materialName.ToLowerInvariant(), SphereRadius, SphereShellRadius, MyVoxelMap.V2FileExtension);

                var asteroid = MyVoxelBuilder.BuildAsteroidSphere(SphereRadius > 32, SphereRadius, materialIndex, materialIndex, SphereShellRadius != 0, SphereShellRadius);
                // TODO: progress bar.
                asteroidCenter = asteroid.BoundingContent.Center;
                asteroidSize   = asteroid.BoundingContent.Size + 1; // Content size
                SourceFile     = TempfileUtil.NewFilename(MyVoxelMap.V2FileExtension);
                asteroid.Save(SourceFile);
            }

            // automatically number all files, and check for duplicate filenames.
            Filename = MainViewModel.CreateUniqueVoxelStorageName(originalFile);

            // Figure out where the Character is facing, and plant the new constrcut right in front.
            // Calculate the hypotenuse, as it will be the safest distance to place in front.
            double distance = Math.Sqrt(Math.Pow(asteroidSize.X, 2) + Math.Pow(asteroidSize.Y, 2) + Math.Pow(asteroidSize.Z, 2)) / 2;

            var vector = new BindableVector3DModel(_dataModel.CharacterPosition.Forward).Vector3D;

            vector.Normalize();
            vector   = System.Windows.Media.Media3D.Vector3D.Multiply(vector, distance);
            Position = new BindablePoint3DModel(Point3D.Add(new BindablePoint3DModel(_dataModel.CharacterPosition.Position).Point3D, vector));
            //Forward = new BindableVector3DModel(_dataModel.CharacterPosition.Forward);
            //Up = new BindableVector3DModel(_dataModel.CharacterPosition.Up);
            Forward = new BindableVector3DModel(Vector3.Forward);  // Asteroids currently don't have any orientation.
            Up      = new BindableVector3DModel(Vector3.Up);

            var entity = new MyObjectBuilder_VoxelMap
            {
                EntityId               = SpaceEngineersApi.GenerateEntityId(IDType.ASTEROID),
                PersistentFlags        = MyPersistentEntityFlags2.CastShadows | MyPersistentEntityFlags2.InScene,
                StorageName            = Path.GetFileNameWithoutExtension(Filename),
                PositionAndOrientation = new MyPositionAndOrientation
                {
                    Position = Position.ToVector3D() - asteroidCenter,
                    Forward  = Forward.ToVector3(),
                    Up       = Up.ToVector3()
                }
            };

            return(entity);
        }
        public MyObjectBuilder_CubeGrid BuildTestEntity()
        {
            var entity = new MyObjectBuilder_CubeGrid
            {
                EntityId        = SpaceEngineersApi.GenerateEntityId(IDType.ENTITY),
                PersistentFlags = MyPersistentEntityFlags2.CastShadows | MyPersistentEntityFlags2.InScene,
                Skeleton        = new System.Collections.Generic.List <BoneInfo>(),
                LinearVelocity  = new VRageMath.Vector3(0, 0, 0),
                AngularVelocity = new VRageMath.Vector3(0, 0, 0),
                GridSizeEnum    = MyCubeSize.Large
            };

            var blockPrefix       = entity.GridSizeEnum.ToString();
            var cornerBlockPrefix = entity.GridSizeEnum.ToString();

            entity.IsStatic    = false;
            blockPrefix       += "BlockArmor"; // HeavyBlockArmor|BlockArmor;
            cornerBlockPrefix += "BlockArmor"; // HeavyBlockArmor|BlockArmor|RoundArmor_;

            // Figure out where the Character is facing, and plant the new constrcut right in front, by "10" units, facing the Character.
            var vector = new BindableVector3DModel(_dataModel.CharacterPosition.Forward).Vector3D;

            vector.Normalize();
            vector   = Vector3D.Multiply(vector, 6);
            Position = new BindablePoint3DModel(Point3D.Add(new BindablePoint3DModel(_dataModel.CharacterPosition.Position).Point3D, vector));
            Forward  = new BindableVector3DModel(_dataModel.CharacterPosition.Forward);
            Up       = new BindableVector3DModel(_dataModel.CharacterPosition.Up);

            entity.PositionAndOrientation = new MyPositionAndOrientation
            {
                Position = Position.ToVector3D(),
                Forward  = Forward.ToVector3(),
                Up       = Up.ToVector3()
            };

            // Large|BlockArmor|Corner
            // Large|RoundArmor_|Corner
            // Large|HeavyBlockArmor|Block,
            // Small|BlockArmor|Slope,
            // Small|HeavyBlockArmor|Corner,

            var blockType              = (SubtypeId)Enum.Parse(typeof(SubtypeId), blockPrefix + "Block");
            var slopeBlockType         = (SubtypeId)Enum.Parse(typeof(SubtypeId), cornerBlockPrefix + "Slope");
            var cornerBlockType        = (SubtypeId)Enum.Parse(typeof(SubtypeId), cornerBlockPrefix + "Corner");
            var inverseCornerBlockType = (SubtypeId)Enum.Parse(typeof(SubtypeId), cornerBlockPrefix + "CornerInv");

            entity.CubeBlocks = new System.Collections.Generic.List <MyObjectBuilder_CubeBlock>();

            //var smoothObject = true;

            // Read in voxel and set main cube space.
            //var ccubic = TestCreateSplayedDiagonalPlane();
            //var ccubic = TestCreateSlopedDiagonalPlane();
            //var ccubic = TestCreateStaggeredStar();
            var ccubic = Modelling.TestCreateTrayShape();
            //var ccubic = ReadModelVolmetic(@"..\..\..\..\..\..\building 3D\models\Rhino_corrected.obj", 10, null, ModelTraceVoxel.ThickSmoothedDown);

            var fillObject = false;

            //if (smoothObject)
            //{
            //    CalculateAddedInverseCorners(ccubic);
            //    CalculateAddedSlopes(ccubic);
            //    CalculateAddedCorners(ccubic);
            //}

            Modelling.BuildStructureFromCubic(entity, ccubic, fillObject, blockType, slopeBlockType, cornerBlockType, inverseCornerBlockType);

            return(entity);
        }