Inheritance: System.Windows.Media.Media3D.AffineTransform3D
Ejemplo n.º 1
0
		void MotionWindow_Loaded(object sender, RoutedEventArgs e)
		{
			Transform3DGroup gp = new Transform3DGroup();
			uBase.Load(@"3DModules\upper.xaml");
			ScaleTransform3D sc = new ScaleTransform3D(12, 12, 1, 0, 0, 0);
			TranslateTransform3D tt = new TranslateTransform3D(0, 0, -15.5);
			gp.Children.Add(sc);
			gp.Children.Add(tt);
			uBase.Transform = gp;
			uPlatform.Load(@"3DModules\platform.xaml");
			upper.Load(@"3DModules\upper.xaml");
			AbsoluteVisual.AddLight(Colors.Wheat, new Vector3D(-1, -1, -1), Colors.Gray);
			vpMain.PlaceCamera(
				new Point3D(0, 0, 500),
				new Vector3D(0, 0, -1),
				new Vector3D(0, 1, 0),
				45
			);
			AbsoluteVisual.Children.Add(uBase);
			AbsoluteVisual.Children.Add(uPlatform);
			AbsoluteVisual.Children.Add(upper);
			ca = new EventCameraAgent(vpMain);
			ca.MouseLockRelPos = new Point(1, 1);
			ca.BindEventTo(this);
			ca.OnCameraStatusChange += new CameraAgent.CameraTransformHandler(ca_OnCameraStatusChange);
		}
Ejemplo n.º 2
0
        public GeometryModel3D ConvertOne( EngineViewModel engine )
        {
            var white = Color.FromRgb(255, 255, 255);
            var whiteBrush = new SolidColorBrush(white);
            var model = new GeometryModel3D(GetGeometry(), new DiffuseMaterial(whiteBrush));

            var transform = new Transform3DGroup();
            var scaleTransform = new ScaleTransform3D();
            var translateTransform = new TranslateTransform3D();

            transform.Children.Add(scaleTransform);
            transform.Children.Add(translateTransform);

            scaleTransform.ScaleX = 3;
            scaleTransform.ScaleY = 3;

            var powerBinding = new Binding("Power") {Mode = BindingMode.OneWay, Source = engine};
            BindingOperations.SetBinding(
                scaleTransform,
                ScaleTransform3D.ScaleZProperty,
                powerBinding);

            translateTransform.OffsetX = engine.OffsetX;
            translateTransform.OffsetY = engine.OffsetY;

            model.Transform = transform;

            return model;
        }
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var scale     = (float)values[0];
            var transform = (Numerics.Matrix4x4)values[1];

            var tGroup = new Media3D.Transform3DGroup();

            if (scale != 1)
            {
                var tform = new Media3D.ScaleTransform3D(scale, scale, scale);

                tform.Freeze();
                tGroup.Children.Add(tform);
            }

            if (!transform.IsIdentity)
            {
                var tform = new Media3D.MatrixTransform3D(transform.ToMatrix3D());

                tform.Freeze();
                tGroup.Children.Add(tform);
            }

            tGroup.Freeze();
            return(tGroup);
        }
Ejemplo n.º 4
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.rbOrthographic = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 2:
                this.rbPerspective = ((System.Windows.Controls.RadioButton)(target));
                return;

            case 3:
                this.tbScaleX = ((System.Windows.Controls.TextBox)(target));
                return;

            case 4:
                this.tbScaleY = ((System.Windows.Controls.TextBox)(target));
                return;

            case 5:
                this.tbScaleZ = ((System.Windows.Controls.TextBox)(target));
                return;

            case 6:
                this.tbAngle = ((System.Windows.Controls.TextBox)(target));
                return;

            case 7:
                this.tbAxis = ((System.Windows.Controls.TextBox)(target));
                return;

            case 8:
                this.btnApply = ((System.Windows.Controls.Button)(target));

            #line 73 "..\..\CombineTransformation.xaml"
                this.btnApply.Click += new System.Windows.RoutedEventHandler(this.btnApply_Click);

            #line default
            #line hidden
                return;

            case 9:
                this.myViewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 10:
                this.myCameraMatrix = ((System.Windows.Media.Media3D.MatrixCamera)(target));
                return;

            case 11:
                this.scaleTransform = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;

            case 12:
                this.rotateTransform = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 5
0
        public CellNet(INetwork network, ModelVisual3D mophology, Dictionary<Guid, ICell> cells, Dictionary<Guid, ICellNet> childcellnet)
        {
            this.network = network;
            this.mophology = mophology;
            this.cells = cells;
            this.childcellnet = childcellnet;
            IsPushing = true;

            var transforms = new Transform3DGroup();
            Rotate = new RotateTransform3D(new QuaternionRotation3D());
            Translate = new TranslateTransform3D(network.Position.X, network.Position.Y, network.Position.Z);
            Scale = new ScaleTransform3D();
            transforms.Children.Add(Rotate);
            transforms.Children.Add(Translate);
            transforms.Children.Add(Scale);
            Mophology.Transform = transforms;

            var binding = new Binding()
            {
                Source = network,
                Path = new PropertyPath("Position"),
                Mode = BindingMode.OneWay
            };
            BindingOperations.SetBinding(this, CellNet.PositionProperty, binding);
        }
Ejemplo n.º 6
0
 public Plant()
 {
     var x = new Vector3D(1, 0, 0);
     var r1 = new RotateTransform3D(new AxisAngleRotation3D(x, 80));
     var r2 = new RotateTransform3D(new AxisAngleRotation3D(x, -70));
     var r3 = new RotateTransform3D(new AxisAngleRotation3D(x, -10));
     var t1 = new TranslateTransform3D(0, 0, 0.5);
     var t2 = new TranslateTransform3D(0, 0, 0.7);
     var t3 = new TranslateTransform3D(0, 0, 1.0);
     var s1 = new ScaleTransform3D(0.5, 0.5, 0.5);
     var s2 = new ScaleTransform3D(0.3, 0.3, 0.3);
     var s3 = new ScaleTransform3D(0.8, 0.8, 0.8);
     var m1 = new Transform3DGroup();
     m1.Children.Add(r1);
     m1.Children.Add(s1);
     m1.Children.Add(t1);
     var m2 = new Transform3DGroup();
     m2.Children.Add(r2);
     m2.Children.Add(s2);
     m2.Children.Add(t2);
     var m3 = new Transform3DGroup();
     m3.Children.Add(r3);
     m3.Children.Add(s3);
     m3.Children.Add(t3);
     T1 = m1;
     T2 = m2;
     T3 = m3;
 }
Ejemplo n.º 7
0
Archivo: Cell.cs Proyecto: babaq/Soul
        public Cell(INeuron neuron, ModelVisual3D mophology, Imaging imager)
        {
            this.neuron = neuron;
            this.mophology = mophology;
            this.imager = imager;
            neuron.Updated += OnUpdated;
            neuron.Hillock.Spike += OnSpike;
            IsPushing = true;

            var transforms = new Transform3DGroup();
            Rotate = new RotateTransform3D(new QuaternionRotation3D());
            Translate = new TranslateTransform3D(neuron.Position.X, neuron.Position.Y, neuron.Position.Z);
            Scale = new ScaleTransform3D();
            transforms.Children.Add(Rotate);
            transforms.Children.Add(Translate);
            transforms.Children.Add(Scale);
            Mophology.Transform = transforms;

            var binding = new Binding()
            {
                Source = neuron,
                Path = new PropertyPath("Position"),
                Mode = BindingMode.OneWay
            };
            BindingOperations.SetBinding(this, Cell.PositionProperty, binding);
        }
Ejemplo n.º 8
0
        private Tuple <Material, Media3D.Transform3D> LoadBeetle()
        {
            var    data = ReadDat("stagbeetle208x208x123.dat", out var width, out var height, out var depth);
            var    m    = new VolumeTextureDiffuseMaterial();
            ushort max  = data.Max();

            uint[] histogram = new uint[max + 1];

            float[] fdata = new float[data.Length];

            for (int i = 0; i < data.Length; ++i)
            {
                fdata[i] = (float)data[i] / max;
                histogram[data[i]]++;
            }
            var transferMap = GetTransferFunction(histogram, data.Length, 1, 0.0001f);
            var gradients   = VolumeDataHelper.GenerateGradients(fdata, width, height, depth, 1);

            VolumeDataHelper.FilterNxNxN(gradients, width, height, depth, 3);
            m.Texture = new VolumeTextureGradientParams(gradients, width, height, depth);
            m.Color   = new Color4(0, 1, 0, 0.4f);
            var transform = new Media3D.ScaleTransform3D(1, 1, 1);

            transform.Freeze();
            m.Freeze();
            return(new Tuple <Material, Media3D.Transform3D>(m, transform));
        }
Ejemplo n.º 9
0
 //Create a scaling transformation. The first argument scales in x, the next in y and the last in z:
 public static ScaleTransform3D makeScaleTransform(double xScale, double yScale, double zScale)
 {
     ScaleTransform3D myScaleTransform3D = new ScaleTransform3D();
     myScaleTransform3D.ScaleX = xScale;
     myScaleTransform3D.ScaleY = yScale;
     myScaleTransform3D.ScaleZ = zScale;
     return myScaleTransform3D;
 }
Ejemplo n.º 10
0
        private static void ScaleZPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ScaleTransform3D target = ((ScaleTransform3D) d);

            target._cachedScaleZValue = (double)e.NewValue;

            target.PropertyChanged(ScaleZProperty);
        }
Ejemplo n.º 11
0
        public ModelVisual3D Render()
        {
            _blocks = new GeometryModel3D[_dimension, _dimension, _dimension];

            Model3DGroup group = new Model3DGroup();

            double space = 0.03;
            double w = (1 - space * (_dimension - 1)) / _dimension;
            double slot = w + space;

            ScaleTransform3D scaling = new ScaleTransform3D(w, w, w);

            for (int i = 0; i < _dimension * _dimension * _dimension; i++)
            {
                int x = i % _dimension;
                int y = (int)(i / _dimension) % _dimension;
                int z = (int)(i / (_dimension * _dimension));

                GeometryModel3D c = CreateMiniCube();
                _blocks[x, y, z] = c;

                TranslateTransform3D pos = new TranslateTransform3D((slot * x), (slot * y), -(slot * z));

                Transform3DGroup tgroup = new Transform3DGroup();
                tgroup.Children.Add(scaling);
                tgroup.Children.Add(pos);

                c.Transform = tgroup;

                group.Children.Add(c);
            }

            Transform3DGroup cubeTransGroup = new Transform3DGroup();

            TranslateTransform3D cubePos = new TranslateTransform3D(-0.5, -0.5, 0.5);
            cubeTransGroup.Children.Add(cubePos);

            // Animation
            _spinTransform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 0));

            //Vector3DAnimation myVectorAnimation = new Vector3DAnimation(new Vector3D(0, 0, -1), new Duration(TimeSpan.FromMilliseconds(5000)));
            //myVectorAnimation.RepeatBehavior = RepeatBehavior.Forever;
            //myRotateTransform.Rotation.BeginAnimation(AxisAngleRotation3D.AxisProperty, myVectorAnimation);

            //myRotateTransform.Rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, doubleAnim);

            cubeTransGroup.Children.Add(_spinTransform);

            // Animation end

            group.Transform = cubeTransGroup;

            ModelVisual3D model = new ModelVisual3D();
            model.Content = group;

            return model;
        }
Ejemplo n.º 12
0
        public Cube(Viewport3D myViewport3D, float obesity)
        {

            this.up = ((PerspectiveCamera)myViewport3D.Camera).UpDirection;
            this.trans = new Transform3DGroup();
            this.scale = new ScaleTransform3D();
            this.translation = new TranslateTransform3D();
            this.rotation = new RotateTransform3D();
            this.axis = new AxisAngleRotation3D();

            this.obesity = obesity;   
            this.cube = new Model3DGroup();

            Point3D p0 = new Point3D(-1, -1, -1);
            Point3D p1 = new Point3D(1, -1, -1);
            Point3D p2 = new Point3D(1, -1, 1);
            Point3D p3 = new Point3D(-1, -1, 1);
            Point3D p4 = new Point3D(-1, 0, -1);
            Point3D p5 = new Point3D(1, 0, -1);
            Point3D p6 = new Point3D(1, 0, 1);
            Point3D p7 = new Point3D(-1, 0, 1);

            //front side triangles
            cube.Children.Add(CreateTriangleModel(p3, p2, p6));
            cube.Children.Add(CreateTriangleModel(p3, p6, p7));
            //right side triangles
            cube.Children.Add(CreateTriangleModel(p2, p1, p5));
            cube.Children.Add(CreateTriangleModel(p2, p5, p6));
            //back side triangles
            cube.Children.Add(CreateTriangleModel(p1, p0, p4));
            cube.Children.Add(CreateTriangleModel(p1, p4, p5));
            //left side triangles
            cube.Children.Add(CreateTriangleModel(p0, p3, p7));
            cube.Children.Add(CreateTriangleModel(p0, p7, p4));
            //top side triangles
            cube.Children.Add(CreateTriangleModel(p7, p6, p5));
            cube.Children.Add(CreateTriangleModel(p7, p5, p4));
            //bottom side triangles
            cube.Children.Add(CreateTriangleModel(p2, p3, p0));
            cube.Children.Add(CreateTriangleModel(p2, p0, p1));

            this.model = new ModelVisual3D();
            this.model.Content = cube;
            this.myDirectionalLight = new DirectionalLight();
            this.myDirectionalLight.Color = Colors.Green;
            this.myDirectionalLight.Direction = new Vector3D(-2, -3, 1);
            this.cube.Children.Add(myDirectionalLight);
            myViewport3D.Children.Add(model);

            trans.Children.Add(scale);
            trans.Children.Add(rotation);
            trans.Children.Add(translation);

            this.cube.Transform = trans;
        }
Ejemplo n.º 13
0
        private Tuple <Material, Media3D.Transform3D> LoadNoise()
        {
            var m = new VolumeTextureDDS3DMaterial();

            m.Texture = LoadFileToMemory("NoiseVolume.dds");
            m.Color   = new Color4(1, 1, 1, 0.01f);
            m.Freeze();
            var transform = new Media3D.ScaleTransform3D(1, 1, 1);

            transform.Freeze();
            return(new Tuple <Material, Media3D.Transform3D>(m, transform));
        }
Ejemplo n.º 14
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.mainViewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 2:
                this.camera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 3:
                this.MyModel = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 4:
                this.scale = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;

            case 5:
                this.rotateY = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 6:
                this.rotateX = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 7:
                this.translate = ((System.Windows.Media.Media3D.TranslateTransform3D)(target));
                return;

            case 8:
                this.model3DGroup = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 9:
                this.geometryModel = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 10:
                this.meshMain = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 11:
                this.meshBack = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Add a 3D model to the instance
        /// </summary>
        private void Init()
        {
            Model3DGroup group = ((Model3DGroup)Core.Instance.Models["point"]).Clone();
            MeshGeometry3D mesh = ((MeshGeometry3D)Core.Instance.Models["pointMesh"]).Clone();
            //Model3DGroup g2 = group.Clone();

            SolidColorBrush b = new SolidColorBrush(Color.FromArgb(255, 255, 255, 0));
            DiffuseMaterial material = new DiffuseMaterial(b);
            GeometryModel3D model2 = new GeometryModel3D(mesh, material);

            ScaleTransform3D scale = new ScaleTransform3D();
            TranslateTransform3D move = new TranslateTransform3D();
            TranslateTransform3D move2 = new TranslateTransform3D();
            AxisAngleRotation3D rotate = new AxisAngleRotation3D();
            Transform3DGroup t = new Transform3DGroup();
            double factor = 3;
            Console.WriteLine(_Point.X + "  " + _Point.Y);
            move.OffsetX = (1 / factor) * _Point.X;
            move.OffsetZ = 0.5;//;// new Random().NextDouble();
            move.OffsetY = -(1 / factor) * _Point.Y;//Y*factor;

            move2.OffsetY = -2;

            rotate.Axis = new Vector3D(1, 0, 0);
            rotate.Angle = 270;

            scale.ScaleX = factor;
            scale.ScaleY = factor;
            scale.ScaleZ = factor;
            t.Children.Add(move);
            t.Children.Add(scale);
            t.Children.Add(new RotateTransform3D(rotate));
            t.Children.Add(move2);
            t.Children.Add(_Scale);
            group.Transform = t;
            this.Content = group;// (Model3DGroup)Core.Instance.Models["side"];

            ColorAnimation da = new ColorAnimation(Color.FromArgb(150, 255, 255, 0), Color.FromArgb(255, 255, 255, 0),  new Duration(new TimeSpan(0, 0, 1)));
            da.RepeatBehavior = RepeatBehavior.Forever;
            da.AutoReverse = true;
            GeometryModel3D m1 = (GeometryModel3D)group.Children[0];
            GeometryModel3D m2 = (GeometryModel3D)group.Children[0];
            ((DiffuseMaterial)m1.Material).BeginAnimation(DiffuseMaterial.ColorProperty, da);
            ((DiffuseMaterial)m2.Material).BeginAnimation(DiffuseMaterial.ColorProperty, da);
            //model2.Material.colo
            //move2.BeginAnimation(TranslateTransform3D.OffsetYProperty, da);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Add a 3D model to the instance
        /// </summary>
        private void Init()
        {
            MeshGeometry3D m1 = (MeshGeometry3D)Core.Instance.Models["Road"];
            SolidColorBrush b = new SolidColorBrush(Color.FromArgb(255, 255, 255, 0));
            DiffuseMaterial material = new DiffuseMaterial(b);
            GeometryModel3D model1 = new GeometryModel3D(m1, material);
            Model3DGroup group = new Model3DGroup();
            group.Children.Add(model1);
            this.Content = group;
            ScaleTransform3D scale = new ScaleTransform3D();
            TranslateTransform3D move = new TranslateTransform3D();
            TranslateTransform3D move2 = new TranslateTransform3D();
            AxisAngleRotation3D rotate = new AxisAngleRotation3D();
            AxisAngleRotation3D rotate2 = new AxisAngleRotation3D();
            Transform3DGroup t = new Transform3DGroup();

            double angle = 0;

            switch (_Location.Direction)
            {
                case ESideDirection.SlopeDown: angle = 60; break;
                case ESideDirection.UpDown: angle = 0; break;
                case ESideDirection.SlopeUp: angle = -60; break;
            }
            scale.ScaleZ = 1.2;
            scale.ScaleX = 3;

            move.OffsetX = _Point.X;
            move.OffsetZ = _Point.Y;
            move.OffsetY = 0.5;

            rotate.Axis = new Vector3D(0, 1, 0);
            rotate.Angle = angle;

            t.Children.Add(scale);
            t.Children.Add(new RotateTransform3D(rotate));
            t.Children.Add(move);
            t.Children.Add(_Scale);

            ColorAnimation da = new ColorAnimation(Color.FromArgb(255, 255, 255, 0), Color.FromArgb(150, 255, 255, 0), new Duration(new TimeSpan(0, 0, 1)));
            da.RepeatBehavior = RepeatBehavior.Forever;
            da.AutoReverse = true;
            material.BeginAnimation(DiffuseMaterial.ColorProperty, da);

            this.Transform = t;
        }
Ejemplo n.º 17
0
        public WorkShop()
        {
            InitializeComponent();

            var network = new Network();
            var solver = new ODESolver();
            var recorder = new Recorder(Simulator, RecordType.None, "Soul");
            Simulator = new Simulator(0.01, 50, network, solver, recorder);
            IsReportProgress = true;
            CellNet = new CellNet(network);
            IsImaging = true;

            var transformGroup = new Transform3DGroup();
            TranslateTransform = new TranslateTransform3D();
            RotateTransform = new RotateTransform3D(new QuaternionRotation3D());
            ScaleTransform = new ScaleTransform3D();
            transformGroup.Children.Add(TranslateTransform);
            transformGroup.Children.Add(RotateTransform);
            transformGroup.Children.Add(ScaleTransform);
            ModelVisual.Transform = transformGroup;

            ActionType = ActionType.None;
            MouseLeftButtonDown += WorkShop_MouseLeftButtonDown;
            MouseLeftButtonUp += WorkShop_MouseLeftButtonUp;
            MouseRightButtonDown += WorkShop_MouseRightButtonDown;
            MouseRightButtonUp += WorkShop_MouseRightButtonUp;
            MouseMove += WorkShop_MouseMove;
            MouseWheel += WorkShop_MouseWheel;

            var n = new LI(-50, -48, 5, 2, -55);
            var net0 = Proliferation.Division(n, new Point3D(1, 10, 10), "InitPotential", new Randomizer(new RNG(), dimyend: 9, dimzend: 9, mean: -50.0, std: 5));
            net0.ReSet();
            //net0.ReShape(new Point3D(2, 10, 5));
            var net1 = Proliferation.Division(n, new Point3D(1, 10, 10), "InitPotential", new Randomizer(new RNG(), dimyend: 9, dimzend: 9, mean: -50.0, std: 10));
            net1.ReSet();
            Projection.From_To(net0, net1, new WeightSynapse(null, 1), ProjectionType.OneToOne, 1.0);
            Projection.From_To(net0, net0, new WeightSynapse(null, -0.4), ProjectionType.AllToAll, 0.3);
            Projection.From_To(net1, net0, new WeightSynapse(null, -0.1), ProjectionType.AllToAll, 0.5);
            Projection.From_To(net1, net1, new WeightSynapse(null, 0.1), ProjectionType.OneToOne, 0.8);
            var net = new Network();
            net.ChildNetworks.Add(net0.ID, net0);
            net.ChildNetworks.Add(net1.ID, net1);
            LoadNetwork(net);
            CellNet.ChildCellNet[net0.ID].Position = new Point3D(-15, 0, 15);
        }
Ejemplo n.º 18
0
        private void Init()
        {
            MeshGeometry3D m1 = (MeshGeometry3D)Core.Instance.Models["mesh_0"];
            MeshGeometry3D m2 = (MeshGeometry3D)Core.Instance.Models["mesh_1"];
            SolidColorBrush b = new SolidColorBrush(_Color);
            DiffuseMaterial material = new DiffuseMaterial(b);
            GeometryModel3D model1 = new GeometryModel3D(m1, material);
            GeometryModel3D model2 = new GeometryModel3D(m2, material);
            Model3DGroup group = new Model3DGroup();
            group.Children.Add(model1);
            group.Children.Add(model2);
            this.Content = group;
            ScaleTransform3D scale = new ScaleTransform3D();
            TranslateTransform3D move = new TranslateTransform3D();
            TranslateTransform3D move2 = new TranslateTransform3D();
            AxisAngleRotation3D rotate = new AxisAngleRotation3D();
            AxisAngleRotation3D rotate2 = new AxisAngleRotation3D();
            Transform3DGroup t = new Transform3DGroup();

            move2.OffsetX = 0;
            move2.OffsetY = -1.7;

            double factor = .012;

            move.OffsetX = (1 / factor) * _Point.X;
            move.OffsetZ = 1;
            move.OffsetY = -(1 / factor) * _Point.Y;

            rotate.Axis = new Vector3D(1, 0, 0);
            rotate.Angle = 270;

            rotate2.Axis = new Vector3D(0, 0, 1);
            rotate2.Angle = 45;

            scale.ScaleX = factor;
            scale.ScaleY = factor;
            scale.ScaleZ = factor;
            t.Children.Add(new RotateTransform3D(rotate2));
            t.Children.Add(move);
            t.Children.Add(scale);
            t.Children.Add(move2);
            t.Children.Add(new RotateTransform3D(rotate));

            this.Transform = t;
        }
Ejemplo n.º 19
0
        private void Init()
        {
            MeshGeometry3D m1 = (MeshGeometry3D)Core.Instance.Models["City1"];
            MeshGeometry3D m2 = (MeshGeometry3D)Core.Instance.Models["City2"];

            DiffuseMaterial material =
                new DiffuseMaterial(new SolidColorBrush(_Color));

            GeometryModel3D model1 = new GeometryModel3D(m1, material);
            GeometryModel3D model2 = new GeometryModel3D(m2, material);

            Model3DGroup group = new Model3DGroup();
            group.Children.Add(model1);
            group.Children.Add(model2);
            this.Content = group;

            ScaleTransform3D scale = new ScaleTransform3D();
            TranslateTransform3D move = new TranslateTransform3D();
            TranslateTransform3D move2 = new TranslateTransform3D();
            AxisAngleRotation3D rotate = new AxisAngleRotation3D();
            AxisAngleRotation3D rotate2 = new AxisAngleRotation3D();
            Transform3DGroup t = new Transform3DGroup();

            move2.OffsetX = 0;
            move2.OffsetY = -1.7;

            move.OffsetX = _Point.X - 2;
            move.OffsetZ = _Point.Y;
            move.OffsetY = 0;

            rotate.Axis = new Vector3D(1, 0, 0);
            rotate.Angle = 270;

            rotate2.Axis = new Vector3D(0, 0, 1);
            rotate2.Angle = 45;

            double scaleFactor = 35;
            scale.ScaleX = scaleFactor;
            scale.ScaleY = scaleFactor;
            scale.ScaleZ = scaleFactor;
            t.Children.Add(scale);
            t.Children.Add(move);

            this.Transform = t;
        }
Ejemplo n.º 20
0
        private void Init()
        {
            MeshGeometry3D m1 = (MeshGeometry3D)Core.Instance.Models["Ship1"];
            MeshGeometry3D m2 = (MeshGeometry3D)Core.Instance.Models["Ship2"];
            SolidColorBrush b = new SolidColorBrush(_Color);
            DiffuseMaterial material = new DiffuseMaterial(b);
            GeometryModel3D model1 = new GeometryModel3D(m1, material);
            GeometryModel3D model2 = new GeometryModel3D(m2, material);
            Model3DGroup group = new Model3DGroup();
            group.Children.Add(model1);
            group.Children.Add(model2);
            this.Content = group;
            ScaleTransform3D scale = new ScaleTransform3D();
            TranslateTransform3D move = new TranslateTransform3D();
            TranslateTransform3D move2 = new TranslateTransform3D();
            AxisAngleRotation3D rotate = new AxisAngleRotation3D();
            AxisAngleRotation3D rotate2 = new AxisAngleRotation3D();
            Transform3DGroup t = new Transform3DGroup();

            double angle = 0;

            switch (_Location.Direction)
            {
                case ESideDirection.SlopeDown: angle = 150; break;
                case ESideDirection.UpDown: angle = 90; break;
                case ESideDirection.SlopeUp: angle = -150; break;
            }
            double factor = 25;
            scale.ScaleZ = factor;
            scale.ScaleY = factor;
            scale.ScaleX = factor;

            move.OffsetX = _Point.X;
            move.OffsetZ = _Point.Y;
            move.OffsetY = 0;

            rotate.Axis = new Vector3D(0, 1, 0);
            rotate.Angle = angle;

            t.Children.Add(scale);
            t.Children.Add(new RotateTransform3D(rotate));
            t.Children.Add(move);

            this.Transform = t;
        }
Ejemplo n.º 21
0
        public Mineral(MineralType mineralType, Point3D position, double volumeInCubicMeters, World world, int materialID, SharedVisuals sharedVisuals, double densityMult = 1d, double scale = 1d, decimal credits = 0m)
        {
            this.MineralType = mineralType;
            this.VolumeInCubicMeters = volumeInCubicMeters;
            this.Scale = scale;
            this.Credits = credits;

            this.Model = GetNewVisual(mineralType, sharedVisuals, scale);

            // Model Visual
            ModelVisual3D visual = new ModelVisual3D();        // this is the expensive one, so as few of these should be made as possible
            visual.Content = this.Model;

            this.Density = GetSettingsForMineralType(mineralType).Density * densityMult;

            #region Physics Body

            Transform3DGroup transform = new Transform3DGroup();
            transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRandomRotation())));
            transform.Children.Add(new TranslateTransform3D(position.ToVector()));

            ScaleTransform3D scaleTransform = new ScaleTransform3D(scale, scale, scale);
            Point3D[] hullPoints = UtilityWPF.GetPointsFromMesh((MeshGeometry3D)sharedVisuals.GetMineralMesh(mineralType), scaleTransform);

            using (CollisionHull hull = CollisionHull.CreateConvexHull(world, 0, hullPoints))
            {
                this.PhysicsBody = new Body(hull, transform.Value, this.Density * volumeInCubicMeters, new Visual3D[] { visual });
                this.PhysicsBody.MaterialGroupID = materialID;
                this.PhysicsBody.LinearDamping = .01f;
                this.PhysicsBody.AngularDamping = new Vector3D(.01f, .01f, .01f);

                //this.PhysicsBody.ApplyForce += new BodyForceEventHandler(Body_ApplyForce);
            }

            #endregion

            // Calculate radius
            Point3D aabbMin, aabbMax;
            this.PhysicsBody.GetAABB(out aabbMin, out aabbMax);
            this.Radius = (aabbMax - aabbMin).Length / 2d;

            this.CreationTime = DateTime.UtcNow;
        }
Ejemplo n.º 22
0
        public void VoxelConvertToVolmeticOdd()
        {
            SpaceEngineersCore.LoadDefinitions();
            var materials = SpaceEngineersCore.Resources.VoxelMaterialDefinitions;

            var stoneMaterial = materials.FirstOrDefault(m => m.Id.SubtypeName.Contains("Stone"));
            Assert.IsNotNull(stoneMaterial, "Stone material should exist.");

            var modelFile = @".\TestAssets\Sphere_Gold.3ds";
            var scale = new ScaleTransform3D(5, 5, 5);
            var rotateTransform = MeshHelper.TransformVector(new System.Windows.Media.Media3D.Vector3D(0, 0, 0), 0, 0, 0);
            var traceType = SEToolbox.Interop.Asteroids.TraceType.Odd;
            var traceCount = SEToolbox.Interop.Asteroids.TraceCount.Trace5;
            var traceDirection = SEToolbox.Interop.Asteroids.TraceDirection.XYZ;

            var asteroidFile = @".\TestOutput\test_sphere_odd.vx2";

            var model = MeshHelper.Load(modelFile, ignoreErrors: true);
            var meshes = new List<SEToolbox.Interop.Asteroids.MyVoxelRayTracer.MyMeshModel>();
            foreach (var model3D in model.Children)
            {
                var gm = (GeometryModel3D)model3D;
                var geometry = gm.Geometry as MeshGeometry3D;

                if (geometry != null)
                    meshes.Add(new MyVoxelRayTracer.MyMeshModel(new[] { geometry }, stoneMaterial.Id.SubtypeName, stoneMaterial.Id.SubtypeName));
            }

            var voxelMap = MyVoxelRayTracer.ReadModelAsteroidVolmetic(model, meshes, scale, rotateTransform, traceType, traceCount, traceDirection,
                ResetProgress, IncrementProgress, null, CompleteProgress);
            voxelMap.Save(asteroidFile);

            Assert.IsTrue(File.Exists(asteroidFile), "Generated file must exist");

            var voxelFileLength = new FileInfo(asteroidFile).Length;
            Assert.AreEqual(2133, voxelFileLength, "File size must match.");
            Assert.AreEqual(new Vector3I(64, 64, 64), voxelMap.Size, "Voxel Bounding size must match.");
            Assert.AreEqual(new Vector3I(25, 25, 25), voxelMap.BoundingContent.SizeInt() + 1, "Voxel Content size must match.");

            var voxCells = voxelMap.SumVoxelCells();
            Assert.AreEqual(2031782, voxCells, "Voxel cells must match.");
        }
Ejemplo n.º 23
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.myRoot = ((IdentityMine.Avalon.Controls.Rotater3DTransition)(target));

            #line 6 "..\..\Rotater3DTransition.xaml"
                this.myRoot.Loaded += new System.Windows.RoutedEventHandler(this.OnLoaded);

            #line default
            #line hidden
                return;

            case 2:

            #line 11 "..\..\Rotater3DTransition.xaml"
                ((System.Windows.Media.Animation.Storyboard)(target)).CurrentStateInvalidated += new System.EventHandler(this.OnRotateStoryboard);

            #line default
            #line hidden
                return;

            case 3:
                this.myViewport3D = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 4:
                this.MainScale = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;

            case 5:
                this.MainRotation = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 6:
                this.MainTranslate = ((System.Windows.Media.Media3D.TranslateTransform3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 24
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.myViewport3D = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 2:
                this.myScale = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;

            case 3:
                this.myRotate = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 4:
                this.myRotate2 = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 25
0
        private void Init()
        {
            MeshGeometry3D m1 = (MeshGeometry3D)Core.Instance.Models["Ship1"];
            MeshGeometry3D m2 = (MeshGeometry3D)Core.Instance.Models["Ship2"];
            SolidColorBrush b = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
            DiffuseMaterial material = new DiffuseMaterial(b);
            GeometryModel3D model1 = new GeometryModel3D(m1, material);
            GeometryModel3D model2 = new GeometryModel3D(m2, material);
            Model3DGroup group = new Model3DGroup();
            group.Children.Add(model1);
            group.Children.Add(model2);
            this.Content = group;
            ScaleTransform3D scale = new ScaleTransform3D();
            TranslateTransform3D move = new TranslateTransform3D();
            AxisAngleRotation3D rotate = new AxisAngleRotation3D();
            AxisAngleRotation3D rotate2 = new AxisAngleRotation3D();
            Transform3DGroup t = new Transform3DGroup();

            double angle = 0;

            double factor = 25;
            scale.ScaleZ = factor;
            scale.ScaleY = factor;
            scale.ScaleX = factor;

            move.OffsetX = _Point.X;
            move.OffsetZ = _Point.Y;
            move.OffsetY = 0;

            rotate.Axis = new Vector3D(0, 1, 0);
            rotate.Angle = angle;

            t.Children.Add(scale);
            t.Children.Add(new RotateTransform3D(rotate));
            t.Children.Add(move);
            t.Children.Add(_Move);

            this.Transform = t;
        }
Ejemplo n.º 26
0
        // Updates the matrices of the slaves using the rotation quaternion.
        private void UpdateServants(Quaternion q, double s)
        {
            var rotation = new RotateTransform3D(); //IB: changed this


            var quatRotation = new QuaternionRotation3D(q);
            rotation.Rotation = quatRotation;
            //rotation.Rotation = new Rotation3D(q);
            rotation.CenterX = _center.X;
            rotation.CenterY = _center.Y;

            var scale = new ScaleTransform3D(new Vector3D(s, s, s));
            var rotateAndScale = new Transform3DCollection {scale, rotation};

            //IB: moved out of the constructor above


            if (_servants != null)
            {
                foreach (var i in _servants)
                {
                    // Note that we don't copy constantly here, we copy the first time someone tries to
                    // trackball a frozen Models, but we replace it with a ChangeableReference
                    // and so subsequent interactions go through without a copy.
                    /* mijacobs: commenting out
					if (i.Models.Transform.IsFrozen)
					{
						Model3DGroup mutableCopy = i.Models.Copy();
						//mutableCopy.StatusOfNextUse = UseStatus.ChangeableReference; IB: no longer necessary I need to architect this out if time permits
						i.Models = mutableCopy;
					}*/

                    var myTransformGroup = new Transform3DGroup {Children = rotateAndScale}; //IB: added transformGroup

                    // mijacobs old: i.Models.Transform = myTransformGroup;
                    ((Model3DGroup) ((ModelVisual3D) i.Children[0]).Content).Transform = myTransformGroup;
                }
            }
        }
            private Media3D.Transform3D GetTransform(float scale, Matrix4x4 transform)
            {
                var tGroup = new Media3D.Transform3DGroup();

                if (scale != 1)
                {
                    var tform = new Media3D.ScaleTransform3D(scale, scale, scale);

                    tform.Freeze();
                    tGroup.Children.Add(tform);
                }

                if (!transform.IsIdentity)
                {
                    var tform = new Media3D.MatrixTransform3D(transform.ToMatrix3D());

                    tform.Freeze();
                    tGroup.Children.Add(tform);
                }

                tGroup.Freeze();
                return(tGroup);
            }
Ejemplo n.º 28
0
        //TODO: Rewrite this.  Make it look like a cave, or sea shell - something organic with an opening
        private Model3DGroup CreateGeometry(bool isFinal)
        {
            ScaleTransform3D scaleTransform = new ScaleTransform3D(SCALE, SCALE, SCALE);

            Model3DGroup retVal = new Model3DGroup();

            GeometryModel3D geometry;
            MaterialGroup material;
            DiffuseMaterial diffuse;
            SpecularMaterial specular;

            Transform3DGroup transformGroup = new Transform3DGroup();
            transformGroup.Children.Add(scaleTransform);

            #region Outer Shell

            geometry = new GeometryModel3D();
            material = new MaterialGroup();

            diffuse = new DiffuseMaterial(new SolidColorBrush(WorldColors.SwarmBay));
            this.MaterialBrushes.Add(new MaterialColorProps(diffuse, WorldColors.SwarmBay));
            material.Children.Add(diffuse);

            specular = WorldColors.SwarmBaySpecular;
            this.MaterialBrushes.Add(new MaterialColorProps(specular));
            material.Children.Add(specular);

            if (!isFinal)
            {
                EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
                material.Children.Add(selectionEmissive);
                base.SelectionEmissives.Add(selectionEmissive);
            }

            geometry.Material = material;
            geometry.BackMaterial = material;

            transformGroup = new Transform3DGroup();
            transformGroup.Children.Add(scaleTransform);
            transformGroup.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRandomRotation())));

            geometry.Geometry = UtilityWPF.GetSphere_Ico(.5, 0, false);
            geometry.Transform = transformGroup;

            retVal.Children.Add(geometry);

            #endregion
            #region Line

            BillboardLine3D line = new BillboardLine3D();
            line.Color = WorldColors.SwarmBay;
            line.Thickness = .05 * SCALE;
            line.IsReflectiveColor = false;
            line.FromPoint = new Point3D(0, 0, 0);
            line.ToPoint = new Point3D(0, 0, .55 * SCALE);

            retVal.Children.Add(line.Model);

            #endregion

            // Transform
            retVal.Transform = GetTransformForGeometry(isFinal);

            // Exit Function
            return retVal;
        }
Ejemplo n.º 29
0
        private Model3DGroup CreateGeometry(bool isFinal)
        {
            const double INSIDEPOINTRADIUS = .45d;

            ScaleTransform3D scaleTransform = new ScaleTransform3D(SCALE, SCALE, SCALE);

            Model3DGroup retVal = new Model3DGroup();

            GeometryModel3D geometry;
            MaterialGroup material;
            DiffuseMaterial diffuse;
            SpecularMaterial specular;

            Transform3DGroup transformGroup = new Transform3DGroup();
            transformGroup.Children.Add(scaleTransform);

            #region Insides

            if (!isFinal)
            {
                Model3D[] insideModels = CreateInsideVisuals(INSIDEPOINTRADIUS, this.MaterialBrushes, base.SelectionEmissives, scaleTransform);
                retVal.Children.AddRange(insideModels);
            }

            #endregion

            #region Lights

            // Neat effect, but it makes my fan spin up, and won't slow back down.  Need to add an animation property to the options
            // class (and listen for when it toggles)

            //if (!isFinal)
            //{
            //    int numLights = 1 + this.Options.Random.Next(3);

            //    for (int cntr = 0; cntr < numLights; cntr++)
            //    {
            //        PointLight light = new PointLight();
            //        light.Color = Colors.Black;
            //        light.Range = SCALE * INSIDEPOINTRADIUS * 2d;
            //        light.LinearAttenuation = 1d;

            //        transformGroup = new Transform3DGroup();
            //        transformGroup.Children.Add(new TranslateTransform3D(Math3D.GetRandomVectorSpherical(this.Options.Random, INSIDEPOINTRADIUS)));
            //        transformGroup.Children.Add(scaleTransform);
            //        light.Transform = transformGroup;

            //        retVal.Children.Add(light);

            //        ColorAnimation animation = new ColorAnimation();
            //        animation.From = UtilityWPF.ColorFromHex("CC1266");
            //        animation.To = Colors.Black;
            //        animation.Duration = new Duration(TimeSpan.FromSeconds(1d + (this.Options.Random.NextDouble() * 5d)));
            //        animation.AutoReverse = true;
            //        animation.RepeatBehavior = RepeatBehavior.Forever;
            //        animation.AccelerationRatio = .5d;
            //        animation.DecelerationRatio = .5d;

            //        light.BeginAnimation(PointLight.ColorProperty, animation);
            //    }
            //}

            #endregion

            #region Outer Shell

            geometry = new GeometryModel3D();
            material = new MaterialGroup();
            Color shellColor = WorldColors.Brain;
            if (!isFinal)
            {
                shellColor = UtilityWPF.AlphaBlend(shellColor, Colors.Transparent, .75d);
            }
            diffuse = new DiffuseMaterial(new SolidColorBrush(shellColor));
            this.MaterialBrushes.Add(new MaterialColorProps(diffuse, shellColor));
            material.Children.Add(diffuse);

            specular = WorldColors.BrainSpecular;
            this.MaterialBrushes.Add(new MaterialColorProps(specular));
            material.Children.Add(specular);

            if (!isFinal)
            {
                EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
                material.Children.Add(selectionEmissive);
                base.SelectionEmissives.Add(selectionEmissive);
            }

            geometry.Material = material;
            geometry.BackMaterial = material;

            transformGroup = new Transform3DGroup();
            transformGroup.Children.Add(scaleTransform);
            transformGroup.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRandomRotation())));		// this is just so it's not obvious that the brains are shared visuals

            geometry.Geometry = SharedVisuals.BrainMesh;		// SharedVisuals keeps track of which thread made the request
            geometry.Transform = transformGroup;

            retVal.Children.Add(geometry);

            #endregion

            // Transform
            retVal.Transform = GetTransformForGeometry(isFinal);

            // Exit Function
            return retVal;
        }
Ejemplo n.º 30
0
        internal static Model3D[] CreateInsideVisuals(double radius, List<MaterialColorProps> materialBrushes, List<EmissiveMaterial> selectionEmissives, ScaleTransform3D scaleTransform)
        {
            List<Point3D[]> insidePoints = new List<Point3D[]>();
            for (int cntr = 0; cntr < 3; cntr++)
            {
                GetLineBranch(insidePoints, Math3D.GetRandomVector_Spherical(radius).ToPoint(), radius, radius * .8d, .33d, 4);
            }

            Random rand = StaticRandom.GetRandomForThread();

            List<Model3D> retVal = new List<Model3D>();

            foreach (Point3D[] lineSegment in insidePoints)
            {
                GeometryModel3D geometry = new GeometryModel3D();
                MaterialGroup material = new MaterialGroup();

                Color color = WorldColors.BrainInsideStrand;		// storing this, because it's random
                DiffuseMaterial diffuse = new DiffuseMaterial(new SolidColorBrush(color));
                materialBrushes.Add(new MaterialColorProps(diffuse, color));
                material.Children.Add(diffuse);

                SpecularMaterial specular = WorldColors.BrainInsideStrandSpecular;
                materialBrushes.Add(new MaterialColorProps(specular));
                material.Children.Add(specular);

                //if (!isFinal)
                //{
                EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
                material.Children.Add(selectionEmissive);
                selectionEmissives.Add(selectionEmissive);
                //}

                geometry.Material = material;
                geometry.BackMaterial = material;

                Vector3D line = lineSegment[1] - lineSegment[0];
                double lineLength = line.Length;
                double halfLength = lineLength * .5d;
                double widestWidth = lineLength * .033d;

                List<TubeRingBase> rings = new List<TubeRingBase>();
                rings.Add(new TubeRingPoint(0, false));
                rings.Add(new TubeRingRegularPolygon(halfLength, false, widestWidth, widestWidth, false));
                rings.Add(new TubeRingPoint(halfLength, false));

                Quaternion zRot = new Quaternion(new Vector3D(0, 0, 1), 360d * rand.NextDouble()).ToUnit();
                Quaternion rotation = Math3D.GetRotation(new Vector3D(0, 0, 1), line).ToUnit();

                Transform3DGroup transformGroup = new Transform3DGroup();
                transformGroup.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Quaternion.Multiply(rotation, zRot))));
                transformGroup.Children.Add(new TranslateTransform3D(lineSegment[0].ToVector()));
                transformGroup.Children.Add(scaleTransform);

                geometry.Geometry = UtilityWPF.GetMultiRingedTube(3, rings, true, false, transformGroup);

                retVal.Add(geometry);
            }

            return retVal.ToArray();
        }
Ejemplo n.º 31
0
        public Creature(Point3D position, Creature mother, Creature father)
        {
            Mother = mother;
            Father = father;
            Gender = randomizer.Next(2) == 0 ? Gender.Male : Gender.Female;

            Position = position;

            Heading = 0;
            Speed = 0;
            AngularSpeed = 0;
            Acceleration = 0;
            BirthTime = GetRandom(5, 3);
            ChildhoodDuration = GetRandom(20, 10);
            LifeTime = GetRandom(90, 30);
            PrivacyDist = 2.5;
            double bmiMean = 25;
            double maxSpeedMean = 3;
            double heightMean = 1.75;
            if (mother != null)
            {
                heightMean = (Mother.GrownupHeight + Father.GrownupHeight) / 2;
                bmiMean = (Mother.BMI + Father.BMI) / 2;
                maxSpeedMean = (Mother.MaxSpeed + Father.MaxSpeed) / 2;
            }
            BMI = GetRandom(bmiMean, bmiMean / 2);
            GrownupHeight = GetRandom(heightMean, 0.5);
            MaxSpeed = Gender == Gender.Male ? GetRandom(maxSpeedMean + 2, 1) : GetRandom(maxSpeedMean, 1);
            Agility = GetRandom(15, 10);
            Fitness = GetRandom(1, 0.5);
            Energy = 1;

            model = new GeometryModel3D();

            translation = new TranslateTransform3D();
            scale = new ScaleTransform3D();
            var rotationT = new RotateTransform3D();
            rotation = new AxisAngleRotation3D(new Vector3D(0, 0, 1), 0);
            rotationT.Rotation = rotation;

            scale.ScaleX = 1;
            scale.ScaleY = 1;
            scale.ScaleZ = 1;

            var tg = new Transform3DGroup();
            tg.Children.Add(scale);
            tg.Children.Add(rotationT);
            tg.Children.Add(translation);
            model.Transform = tg;

            Content = model;
        }
Ejemplo n.º 32
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.menu = ((System.Windows.Controls.Menu)(target));
                return;

            case 2:

            #line 12 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Checked += new System.Windows.RoutedEventHandler(this.MenuItem_Checked);

            #line default
            #line hidden

            #line 12 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Unchecked += new System.Windows.RoutedEventHandler(this.MenuItem_Unchecked);

            #line default
            #line hidden
                return;

            case 3:

            #line 13 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Checked += new System.Windows.RoutedEventHandler(this.MenuItem_Checked_1);

            #line default
            #line hidden

            #line 13 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Unchecked += new System.Windows.RoutedEventHandler(this.MenuItem_Unchecked_1);

            #line default
            #line hidden
                return;

            case 4:

            #line 14 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Checked += new System.Windows.RoutedEventHandler(this.MenuItem_Checked_2);

            #line default
            #line hidden

            #line 14 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Unchecked += new System.Windows.RoutedEventHandler(this.MenuItem_Unchecked_2);

            #line default
            #line hidden
                return;

            case 5:
                this.viewport1 = ((System.Windows.Controls.Viewport3D)(target));

            #line 20 "..\..\MainWindow.xaml"
                this.viewport1.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.viewport1_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 20 "..\..\MainWindow.xaml"
                this.viewport1.MouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.viewport1_MouseRightButtonDown);

            #line default
            #line hidden

            #line 20 "..\..\MainWindow.xaml"
                this.viewport1.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.viewport1_MouseRightButtonUp);

            #line default
            #line hidden

            #line 20 "..\..\MainWindow.xaml"
                this.viewport1.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.MouseDown);

            #line default
            #line hidden

            #line 20 "..\..\MainWindow.xaml"
                this.viewport1.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.viewport1_MouseWheel);

            #line default
            #line hidden

            #line 20 "..\..\MainWindow.xaml"
                this.viewport1.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.viewport1_MouseLeftButtonUp);

            #line default
            #line hidden

            #line 20 "..\..\MainWindow.xaml"
                this.viewport1.MouseMove += new System.Windows.Input.MouseEventHandler(this.viewport1_MouseMove);

            #line default
            #line hidden
                return;

            case 6:
                this.map = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 7:
                this.Bottom = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 8:
                this.Front = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 9:
                this.translacija = ((System.Windows.Media.Media3D.TranslateTransform3D)(target));
                return;

            case 10:
                this.skaliranje = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;

            case 11:
                this.myHorizontalRTransform = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 12:
                this.myHorizontalRotation = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 13:
                this.myVerticalRTransform = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 14:
                this.myVerticalRotation = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 15:
                this.myHorizontalRTransform2 = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 16:
                this.myHorizontalRotation2 = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 33
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 5 "..\..\MainWindow.xaml"
                ((Processes_Manage.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden
                return;

            case 2:

            #line 9 "..\..\MainWindow.xaml"
                ((System.Windows.Media.Animation.Storyboard)(target)).Completed += new System.EventHandler(this.zoomInStoryboardCompleted);

            #line default
            #line hidden
                return;

            case 3:

            #line 33 "..\..\MainWindow.xaml"
                ((System.Windows.Media.Animation.Storyboard)(target)).Completed += new System.EventHandler(this.zoomOutStoryboardCompleted);

            #line default
            #line hidden
                return;

            case 4:
                this.newTask_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 67 "..\..\MainWindow.xaml"
                this.newTask_MenuItem.Click += new System.Windows.RoutedEventHandler(this.newTask_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 5:
                this.quit_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 69 "..\..\MainWindow.xaml"
                this.quit_MenuItem.Click += new System.Windows.RoutedEventHandler(this.quit_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 6:
                this.topmost_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 73 "..\..\MainWindow.xaml"
                this.topmost_MenuItem.Click += new System.Windows.RoutedEventHandler(this.topmost_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 7:
                this.set_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 77 "..\..\MainWindow.xaml"
                this.set_MenuItem.Click += new System.Windows.RoutedEventHandler(this.set_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 8:
                this.about_MenuItem = ((System.Windows.Controls.MenuItem)(target));

            #line 80 "..\..\MainWindow.xaml"
                this.about_MenuItem.Click += new System.Windows.RoutedEventHandler(this.about_MenuItem_Click);

            #line default
            #line hidden
                return;

            case 9:
                this.FirstPageRadioButton = ((System.Windows.Controls.RadioButton)(target));

            #line 88 "..\..\MainWindow.xaml"
                this.FirstPageRadioButton.Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 10:

            #line 89 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 11:

            #line 90 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 12:

            #line 91 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 13:

            #line 92 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);

            #line default
            #line hidden
                return;

            case 14:
                this.myViewport3D = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 15:
                this.myPlane = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
                return;

            case 16:
                this.myGeometry = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
                return;

            case 17:
                this.myHorizontalRotation = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 18:
                this.MyHorizontalAxisAngleRotation3D = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 19:
                this.MyScaleTransform3D = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;

            case 20:
                this.scrollViewerBorder = ((System.Windows.Controls.Border)(target));
                return;

            case 21:
                this.myScrollViewer = ((System.Windows.Controls.ScrollViewer)(target));
                return;

            case 22:
                this.mainFrame = ((System.Windows.Controls.Frame)(target));

            #line 182 "..\..\MainWindow.xaml"
                this.mainFrame.ContentRendered += new System.EventHandler(this.frameContentRendered);

            #line default
            #line hidden
                return;

            case 23:
                this.processesNums_Now = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 24:
                this.cpu_Rate = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 25:
                this.memory_Rate = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 26:
                this.gpu_temperature = ((System.Windows.Controls.TextBlock)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 34
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 9 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Grid)(target)).ManipulationDelta += new System.EventHandler <System.Windows.Input.ManipulationDeltaEventArgs>(this.OnDeltaChange);

            #line default
            #line hidden

            #line 9 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Grid)(target)).TouchUp += new System.EventHandler <System.Windows.Input.TouchEventArgs>(this.OnTouch);

            #line default
            #line hidden

            #line 9 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Grid)(target)).MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.Grid_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 9 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Grid)(target)).MouseMove += new System.Windows.Input.MouseEventHandler(this.Grid_MouseMove);

            #line default
            #line hidden

            #line 9 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Grid)(target)).MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.Grid_MouseLeftButtonUp);

            #line default
            #line hidden

            #line 9 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Grid)(target)).MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.Zoom);

            #line default
            #line hidden
                return;

            case 2:
                this.BackgroundImage = ((System.Windows.Controls.Image)(target));
                return;

            case 3:
                this.viewport = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 4:
                this.Light = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 5:
                this.light = ((System.Windows.Media.Media3D.AmbientLight)(target));
                return;

            case 6:
                this.Earth = ((EarthViewerWPF.Sphere)(target));
                return;

            case 7:
                this.transformGroup = ((System.Windows.Media.Media3D.Transform3DGroup)(target));
                return;

            case 8:
                this.scaleTransform = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;

            case 9:
                this.sphereRec = ((System.Windows.Shapes.Rectangle)(target));
                return;

            case 10:
                this.InfoTextBox = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 11:
                this.InfoScale = ((System.Windows.Media.ScaleTransform)(target));
                return;

            case 12:
                this.TouchLine = ((System.Windows.Shapes.Line)(target));
                return;

            case 13:
                this.detailsContainer = ((System.Windows.Controls.Label)(target));
                return;

            case 14:
                this.countryLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 15:
                this.countryText = ((System.Windows.Controls.Label)(target));
                return;

            case 16:
                this.capitalLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 17:
                this.capitalText = ((System.Windows.Controls.Label)(target));
                return;

            case 18:
                this.languageLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 19:
                this.languageText = ((System.Windows.Controls.Label)(target));
                return;

            case 20:
                this.populationLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 21:
                this.populationText = ((System.Windows.Controls.Label)(target));
                return;

            case 22:
                this.areaLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 23:
                this.areaText = ((System.Windows.Controls.Label)(target));
                return;

            case 24:
                this.anthemLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 25:
                this.currencyLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 26:
                this.currencyText = ((System.Windows.Controls.Label)(target));
                return;

            case 27:
                this.gdpLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 28:
                this.gdpText = ((System.Windows.Controls.Label)(target));
                return;

            case 29:
                this.religionLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 30:
                this.religionText = ((System.Windows.Controls.Label)(target));
                return;

            case 31:
                this.anthemButton = ((System.Windows.Controls.Button)(target));

            #line 72 "..\..\MainWindow.xaml"
                this.anthemButton.Click += new System.Windows.RoutedEventHandler(this.anthemButton_Click);

            #line default
            #line hidden
                return;

            case 32:
                this.anthemButtonStop = ((System.Windows.Controls.Button)(target));

            #line 73 "..\..\MainWindow.xaml"
                this.anthemButtonStop.Click += new System.Windows.RoutedEventHandler(this.anthemButtonStop_Click);

            #line default
            #line hidden
                return;

            case 33:
                this.bottomBarContainer = ((System.Windows.Controls.Label)(target));
                return;

            case 34:
                this.gamesBg = ((System.Windows.Controls.Label)(target));
                return;

            case 35:
                this.gamesIcon = ((System.Windows.Controls.Image)(target));

            #line 78 "..\..\MainWindow.xaml"
                this.gamesIcon.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.gamesIcon_MouseDown);

            #line default
            #line hidden

            #line 78 "..\..\MainWindow.xaml"
                this.gamesIcon.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.gamesIcon_MouseUp);

            #line default
            #line hidden
                return;

            case 36:
                this.settingsBg = ((System.Windows.Controls.Label)(target));
                return;

            case 37:
                this.settingsIcon = ((System.Windows.Controls.Image)(target));

            #line 80 "..\..\MainWindow.xaml"
                this.settingsIcon.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.settingsIcon_MouseDown);

            #line default
            #line hidden

            #line 80 "..\..\MainWindow.xaml"
                this.settingsIcon.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.settingsIcon_MouseUp);

            #line default
            #line hidden
                return;

            case 38:
                this.highScoresBg = ((System.Windows.Controls.Label)(target));
                return;

            case 39:
                this.highScoresIcon = ((System.Windows.Controls.Image)(target));

            #line 82 "..\..\MainWindow.xaml"
                this.highScoresIcon.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.highScoresIcon_MouseDown);

            #line default
            #line hidden

            #line 82 "..\..\MainWindow.xaml"
                this.highScoresIcon.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.highScoresIcon_MouseUp);

            #line default
            #line hidden
                return;

            case 40:
                this.powerBttn = ((System.Windows.Controls.Image)(target));

            #line 83 "..\..\MainWindow.xaml"
                this.powerBttn.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.powerBttn_MouseDown);

            #line default
            #line hidden

            #line 83 "..\..\MainWindow.xaml"
                this.powerBttn.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.powerBttn_MouseUp);

            #line default
            #line hidden
                return;

            case 41:
                this.usernameLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 42:
                this.settingsReset = ((System.Windows.Controls.Image)(target));

            #line 85 "..\..\MainWindow.xaml"
                this.settingsReset.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.settingsReset_MouseDown);

            #line default
            #line hidden

            #line 85 "..\..\MainWindow.xaml"
                this.settingsReset.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.settingsReset_MouseUp);

            #line default
            #line hidden
                return;

            case 43:
                this.ControlCheckBox = ((System.Windows.Controls.CheckBox)(target));
                return;

            case 44:
                this.RotationResetButton = ((System.Windows.Controls.Button)(target));

            #line 89 "..\..\MainWindow.xaml"
                this.RotationResetButton.Click += new System.Windows.RoutedEventHandler(this.RotationResetButton_Click);

            #line default
            #line hidden
                return;

            case 45:
                this.textureComboBox = ((System.Windows.Controls.ComboBox)(target));

            #line 90 "..\..\MainWindow.xaml"
                this.textureComboBox.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.ComboBox_SelectionChanged);

            #line default
            #line hidden
                return;

            case 46:
                this.sensitivitySlider = ((System.Windows.Controls.Slider)(target));
                return;

            case 47:
                this.sensitivityLabel = ((System.Windows.Controls.Label)(target));
                return;

            case 48:
                this.gameButton = ((System.Windows.Controls.Button)(target));

            #line 104 "..\..\MainWindow.xaml"
                this.gameButton.Click += new System.Windows.RoutedEventHandler(this.gameButton_Click);

            #line default
            #line hidden
                return;

            case 49:
                this.countryGText = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 50:
                this.timerText = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 51:
                this.recentScore1 = ((System.Windows.Controls.Label)(target));
                return;

            case 52:
                this.scoreLabel1 = ((System.Windows.Controls.Label)(target));
                return;

            case 53:
                this.game2Button = ((System.Windows.Controls.Button)(target));

            #line 109 "..\..\MainWindow.xaml"
                this.game2Button.Click += new System.Windows.RoutedEventHandler(this.game2Button_Click);

            #line default
            #line hidden
                return;

            case 54:
                this.game2RecentScore = ((System.Windows.Controls.Label)(target));
                return;

            case 55:
                this.game3Button = ((System.Windows.Controls.Button)(target));

            #line 111 "..\..\MainWindow.xaml"
                this.game3Button.Click += new System.Windows.RoutedEventHandler(this.game3Button_Click);

            #line default
            #line hidden
                return;

            case 56:
                this.game3RecentScore = ((System.Windows.Controls.Label)(target));
                return;

            case 57:
                this.placeNameImage = ((System.Windows.Controls.Image)(target));

            #line 113 "..\..\MainWindow.xaml"
                this.placeNameImage.MouseEnter += new System.Windows.Input.MouseEventHandler(this.placeNameImage_MouseEnter);

            #line default
            #line hidden

            #line 113 "..\..\MainWindow.xaml"
                this.placeNameImage.MouseLeave += new System.Windows.Input.MouseEventHandler(this.placeNameImage_MouseLeave);

            #line default
            #line hidden
                return;

            case 58:
                this.skipImage = ((System.Windows.Controls.Image)(target));

            #line 114 "..\..\MainWindow.xaml"
                this.skipImage.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.skipImage_MouseDown);

            #line default
            #line hidden

            #line 114 "..\..\MainWindow.xaml"
                this.skipImage.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.skipImage_MouseUp);

            #line default
            #line hidden
                return;

            case 59:
                this.leftSideDivider = ((System.Windows.Controls.Label)(target));
                return;

            case 60:
                this.rightSideDivider = ((System.Windows.Controls.Label)(target));
                return;

            case 61:
                this.gameModeLabelHs = ((System.Windows.Controls.Label)(target));
                return;

            case 62:
                this.usernameLabelHs = ((System.Windows.Controls.Label)(target));
                return;

            case 63:
                this.scoreLabelHs = ((System.Windows.Controls.Label)(target));
                return;

            case 64:
                this.gameMode1 = ((System.Windows.Controls.Label)(target));
                return;

            case 65:
                this.gamemode2 = ((System.Windows.Controls.Label)(target));
                return;

            case 66:
                this.gameMode3 = ((System.Windows.Controls.Label)(target));
                return;

            case 67:
                this.player1 = ((System.Windows.Controls.Label)(target));
                return;

            case 68:
                this.player2 = ((System.Windows.Controls.Label)(target));
                return;

            case 69:
                this.player3 = ((System.Windows.Controls.Label)(target));
                return;

            case 70:
                this.score1 = ((System.Windows.Controls.Label)(target));
                return;

            case 71:
                this.score2 = ((System.Windows.Controls.Label)(target));
                return;

            case 72:
                this.score3 = ((System.Windows.Controls.Label)(target));
                return;

            case 73:
                this.settingsReset_Copy = ((System.Windows.Controls.Image)(target));

            #line 131 "..\..\MainWindow.xaml"
                this.settingsReset_Copy.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.settingsReset_MouseDown);

            #line default
            #line hidden

            #line 131 "..\..\MainWindow.xaml"
                this.settingsReset_Copy.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.settingsReset_MouseUp);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 35
0
		///<summary>Rotate not included yet.  Completely overrides existing instead of any additive effect.</summary>
		public void SetTransform(string objName,Vector3D offset,Vector3D scale) {
			if(!objectNames.Contains(objName)) {
				return;
			}
			GeometryModel3D geometryModel3D=(GeometryModel3D)_model3Dgroup.Children[objectNames.IndexOf(objName)];
			TranslateTransform3D translateTransform3D=new TranslateTransform3D(offset);
			ScaleTransform3D scaleTransform3D=new ScaleTransform3D(scale);
			Transform3DGroup transform3DGroup=new Transform3DGroup();
			transform3DGroup.Children.Add(translateTransform3D);
			transform3DGroup.Children.Add(scaleTransform3D);
			geometryModel3D.Transform=transform3DGroup;
		}
Ejemplo n.º 36
0
            public TreeMap3DElement(int index, int count)
            {
                this.Visual3DModel = GenerateTreeMap3DModel(index, count);

                m_translate = new TranslateTransform3D();
                m_scale = new ScaleTransform3D();
                Transform3DGroup t3DGroup = new Transform3DGroup();
                t3DGroup.Children.Add(m_scale);
                t3DGroup.Children.Add(m_translate);
                base.Transform = t3DGroup;
            }
Ejemplo n.º 37
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.viewport1 = ((System.Windows.Controls.Viewport3D)(target));

            #line 10 "..\..\MainWindow.xaml"
                this.viewport1.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.viewport1_MouseLeftButtonDown);

            #line default
            #line hidden

            #line 11 "..\..\MainWindow.xaml"
                this.viewport1.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.viewport1_MouseLeftButtonUp);

            #line default
            #line hidden

            #line 11 "..\..\MainWindow.xaml"
                this.viewport1.MouseMove += new System.Windows.Input.MouseEventHandler(this.viewport1_MouseMove);

            #line default
            #line hidden

            #line 12 "..\..\MainWindow.xaml"
                this.viewport1.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.viewport1_MouseWheel);

            #line default
            #line hidden

            #line 12 "..\..\MainWindow.xaml"
                this.viewport1.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.Viewport1_MouseDown);

            #line default
            #line hidden

            #line 12 "..\..\MainWindow.xaml"
                this.viewport1.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Viewport1_MouseUp);

            #line default
            #line hidden
                return;

            case 2:
                this.modelGroup = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 3:
                this.rotateTransform = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 4:
                this.rotate = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 5:
                this.rotateTransformX = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 6:
                this.rotateX = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 7:
                this.translacija = ((System.Windows.Media.Media3D.TranslateTransform3D)(target));
                return;

            case 8:
                this.skaliranje = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 38
0
        private Model3DGroup CreateGeometry(bool isFinal)
        {
            int domeSegments = isFinal ? 2 : 10;
            int cylinderSegments = isFinal ? 6 : 35;

            Model3DGroup retVal = new Model3DGroup();

            GeometryModel3D geometry;
            MaterialGroup material;
            DiffuseMaterial diffuse;
            SpecularMaterial specular;

            #region Insides

            if (!isFinal)
            {
                ScaleTransform3D scaleTransform = new ScaleTransform3D(HEIGHT, HEIGHT, HEIGHT);

                //TODO: This caps them to a sphere.  It doesn't look too bad, but could be better
                Model3D[] insideModels = BrainDesign.CreateInsideVisuals(.4, this.MaterialBrushes, base.SelectionEmissives, scaleTransform);

                retVal.Children.AddRange(insideModels);
            }

            #endregion
            #region Outer Shell

            geometry = new GeometryModel3D();
            material = new MaterialGroup();
            Color shellColor = WorldColors.Brain;
            if (!isFinal)
            {
                shellColor = UtilityWPF.AlphaBlend(shellColor, Colors.Transparent, .75d);
            }
            diffuse = new DiffuseMaterial(new SolidColorBrush(shellColor));
            this.MaterialBrushes.Add(new MaterialColorProps(diffuse, shellColor));
            material.Children.Add(diffuse);

            specular = WorldColors.BrainSpecular;
            this.MaterialBrushes.Add(new MaterialColorProps(specular));
            material.Children.Add(specular);

            if (!isFinal)
            {
                EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
                material.Children.Add(selectionEmissive);
                base.SelectionEmissives.Add(selectionEmissive);
            }

            geometry.Material = material;
            geometry.BackMaterial = material;

            List<TubeRingBase> rings = new List<TubeRingBase>();

            rings.Add(new TubeRingRegularPolygon(0, false, RADIUSPERCENTOFSCALE_NARROW, RADIUSPERCENTOFSCALE_NARROW, true));
            rings.Add(new TubeRingRegularPolygon(HEIGHT, false, RADIUSPERCENTOFSCALE_WIDE, RADIUSPERCENTOFSCALE_WIDE, true));

            geometry.Geometry = UtilityWPF.GetMultiRingedTube(cylinderSegments, rings, true, true);

            retVal.Children.Add(geometry);

            #endregion

            retVal.Transform = GetTransformForGeometry(isFinal);

            return retVal;
        }
Ejemplo n.º 39
0
        private void UpdateModels()
        {
            var group = new Model3DGroup();
            Models = new GeometryModel3D[FrequencyColumns, TimeColumns];
            ScaleTransforms = new ScaleTransform3D[FrequencyColumns, TimeColumns];

            for (int j = 0; j < TimeColumns; j++)
            {
                for (int i = 0; i < FrequencyColumns; i++)
                {
                    Material material = MaterialHelper.CreateMaterial(ColorHelper.HsvToColor(0.6 * i / (FrequencyColumns - 1), 1, 1));
                    ScaleTransforms[i, j] = new ScaleTransform3D(1, 1, 1);

                    var translation = new TranslateTransform3D((i - (FrequencyColumns - 1) * 0.5) * Distance, -j * Distance, 0);
                    var tg = new Transform3DGroup();
                    tg.Children.Add(ScaleTransforms[i, j]);
                    tg.Children.Add(translation);
                    Models[i, j] = new GeometryModel3D(Geometry, material) { Transform = tg };
                    group.Children.Add(Models[i, j]);
                }
            }

            Content = group;
        }
Ejemplo n.º 40
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     
     #line 5 "..\..\MainWindow.xaml"
     ((Processes_Manage.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);
     
     #line default
     #line hidden
     return;
     case 2:
     
     #line 9 "..\..\MainWindow.xaml"
     ((System.Windows.Media.Animation.Storyboard)(target)).Completed += new System.EventHandler(this.zoomInStoryboardCompleted);
     
     #line default
     #line hidden
     return;
     case 3:
     
     #line 33 "..\..\MainWindow.xaml"
     ((System.Windows.Media.Animation.Storyboard)(target)).Completed += new System.EventHandler(this.zoomOutStoryboardCompleted);
     
     #line default
     #line hidden
     return;
     case 4:
     this.newTask_MenuItem = ((System.Windows.Controls.MenuItem)(target));
     
     #line 67 "..\..\MainWindow.xaml"
     this.newTask_MenuItem.Click += new System.Windows.RoutedEventHandler(this.newTask_MenuItem_Click);
     
     #line default
     #line hidden
     return;
     case 5:
     this.quit_MenuItem = ((System.Windows.Controls.MenuItem)(target));
     
     #line 69 "..\..\MainWindow.xaml"
     this.quit_MenuItem.Click += new System.Windows.RoutedEventHandler(this.quit_MenuItem_Click);
     
     #line default
     #line hidden
     return;
     case 6:
     this.topmost_MenuItem = ((System.Windows.Controls.MenuItem)(target));
     
     #line 73 "..\..\MainWindow.xaml"
     this.topmost_MenuItem.Click += new System.Windows.RoutedEventHandler(this.topmost_MenuItem_Click);
     
     #line default
     #line hidden
     return;
     case 7:
     this.set_MenuItem = ((System.Windows.Controls.MenuItem)(target));
     
     #line 77 "..\..\MainWindow.xaml"
     this.set_MenuItem.Click += new System.Windows.RoutedEventHandler(this.set_MenuItem_Click);
     
     #line default
     #line hidden
     return;
     case 8:
     this.about_MenuItem = ((System.Windows.Controls.MenuItem)(target));
     
     #line 80 "..\..\MainWindow.xaml"
     this.about_MenuItem.Click += new System.Windows.RoutedEventHandler(this.about_MenuItem_Click);
     
     #line default
     #line hidden
     return;
     case 9:
     this.FirstPageRadioButton = ((System.Windows.Controls.RadioButton)(target));
     
     #line 88 "..\..\MainWindow.xaml"
     this.FirstPageRadioButton.Checked += new System.Windows.RoutedEventHandler(this.pageSelected);
     
     #line default
     #line hidden
     return;
     case 10:
     
     #line 89 "..\..\MainWindow.xaml"
     ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);
     
     #line default
     #line hidden
     return;
     case 11:
     
     #line 90 "..\..\MainWindow.xaml"
     ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);
     
     #line default
     #line hidden
     return;
     case 12:
     
     #line 91 "..\..\MainWindow.xaml"
     ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);
     
     #line default
     #line hidden
     return;
     case 13:
     
     #line 92 "..\..\MainWindow.xaml"
     ((System.Windows.Controls.RadioButton)(target)).Checked += new System.Windows.RoutedEventHandler(this.pageSelected);
     
     #line default
     #line hidden
     return;
     case 14:
     this.myViewport3D = ((System.Windows.Controls.Viewport3D)(target));
     return;
     case 15:
     this.myPlane = ((System.Windows.Media.Media3D.GeometryModel3D)(target));
     return;
     case 16:
     this.myGeometry = ((System.Windows.Media.Media3D.MeshGeometry3D)(target));
     return;
     case 17:
     this.myHorizontalRotation = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
     return;
     case 18:
     this.MyHorizontalAxisAngleRotation3D = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
     return;
     case 19:
     this.MyScaleTransform3D = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
     return;
     case 20:
     this.scrollViewerBorder = ((System.Windows.Controls.Border)(target));
     return;
     case 21:
     this.myScrollViewer = ((System.Windows.Controls.ScrollViewer)(target));
     return;
     case 22:
     this.mainFrame = ((System.Windows.Controls.Frame)(target));
     
     #line 182 "..\..\MainWindow.xaml"
     this.mainFrame.ContentRendered += new System.EventHandler(this.frameContentRendered);
     
     #line default
     #line hidden
     return;
     case 23:
     this.processesNums_Now = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 24:
     this.cpu_Rate = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 25:
     this.memory_Rate = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 26:
     this.gpu_temperature = ((System.Windows.Controls.TextBlock)(target));
     return;
     }
     this._contentLoaded = true;
 }
Ejemplo n.º 41
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 29 "..\..\Container3DView.xaml"
                ((HeuristicLab.Problems.BinPacking.Views.Container3DView)(target)).MouseMove += new System.Windows.Input.MouseEventHandler(this.Container3DView_MouseMove);

            #line default
            #line hidden

            #line 29 "..\..\Container3DView.xaml"
                ((HeuristicLab.Problems.BinPacking.Views.Container3DView)(target)).MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.Container3DView_MouseDown);

            #line default
            #line hidden

            #line 29 "..\..\Container3DView.xaml"
                ((HeuristicLab.Problems.BinPacking.Views.Container3DView)(target)).MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.Container3DView_MouseUp);

            #line default
            #line hidden

            #line 30 "..\..\Container3DView.xaml"
                ((HeuristicLab.Problems.BinPacking.Views.Container3DView)(target)).MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.Container3DView_OnMouseWheel);

            #line default
            #line hidden

            #line 31 "..\..\Container3DView.xaml"
                ((HeuristicLab.Problems.BinPacking.Views.Container3DView)(target)).MouseEnter += new System.Windows.Input.MouseEventHandler(this.Container3DView_OnMouseEnter);

            #line default
            #line hidden
                return;

            case 2:
                this.viewport3D1 = ((System.Windows.Controls.Viewport3D)(target));
                return;

            case 3:
                this.camMain = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 4:
                this.dirLightMain = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 5:
                this.MyModel = ((System.Windows.Media.Media3D.ModelVisual3D)(target));
                return;

            case 6:
                this.scale = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;

            case 7:
                this.rotateX = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 8:
                this.rotateY = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 9:
                this.scaleZoom = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;
            }
            this._contentLoaded = true;
        }
Ejemplo n.º 42
0
      public void InitializeViewer()
      {
         ///////////////////////////////////////////
         // Camera Initialize
         ///////////////////////////////////////////
         PerspectiveCamera PanoramaCamera = new PerspectiveCamera();
         PanoramaCamera.Position = new Point3D(0, -0.0, 0);
         PanoramaCamera.UpDirection = new Vector3D(0, 1, 0);
         PanoramaCamera.LookDirection = new Vector3D(0, 0, 1);
         PanoramaCamera.FieldOfView = 80;
         this.Camera = PanoramaCamera;

         FieldOfView = 80;

         ///////////////////////////////////////////
         // Light Initialize
         ///////////////////////////////////////////
         ModelVisual3D LightModel = new ModelVisual3D();
         LightModel.Content = new DirectionalLight(Colors.White, new Vector3D(0, 0, 1));
         this.Children.Add(LightModel);

         ///////////////////////////////////////////
         // Panorama Object Initialize
         ///////////////////////////////////////////

         PanoramaObject = new ModelVisual3D();
         PanoramaGeometry = new GeometryModel3D();
         PanoramaGeometry.Geometry = CreateGeometry();
         PanoramaObject.Content = PanoramaGeometry;

         RotateTransform3D RotateTransform = new RotateTransform3D();

         double x = 1.0;
         ScaleTransform3D ScaleTransform = new ScaleTransform3D()
         {
            ScaleX = x*1,
            ScaleY = x*1.65,
            ScaleZ = x*1
         };

         Transform3DGroup Group = new Transform3DGroup();
         PanoramaRotation = new QuaternionRotation3D();
         Group.Children.Add(ScaleTransform);
         Group.Children.Add(RotateTransform);

         RotateTransform.Rotation = PanoramaRotation;
         PanoramaObject.Transform = Group;

         this.Children.Add(PanoramaObject);
      }
Ejemplo n.º 43
0
        public void AttachModelList(List <Object3D> objs)
        {
            for (int i = 0; i < objs.Count; ++i)
            {
                var ob        = objs[i];
                var vertColor = new Color4((float)i / objs.Count, 0, 1 - (float)i / objs.Count, 1);
                ob.Geometry.Colors = new HelixToolkit.Wpf.SharpDX.Core.Color4Collection(Enumerable.Repeat(vertColor, ob.Geometry.Positions.Count));
                ob.Geometry.UpdateOctree();
                ob.Geometry.UpdateBounds();

                context.Post((o) =>
                {
                    var scaleTransform = new Media3D.ScaleTransform3D(15, 15, 15);
                    var s = new MeshGeometryModel3D
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Transform        = scaleTransform
                    };

                    var diffuseMaterial     = new DiffuseMaterial();
                    PBRMaterial pbrMaterial = null;
                    if (ob.Material is PhongMaterialCore p)
                    {
                        var phong = p.ConvertToPhongMaterial();
                        phong.RenderEnvironmentMap   = true;
                        phong.RenderShadowMap        = true;
                        phong.RenderSpecularColorMap = false;
                        s.Material = phong;
                        diffuseMaterial.DiffuseColor = p.DiffuseColor;
                        diffuseMaterial.DiffuseMap   = p.DiffuseMap;
                        pbrMaterial = new PBRMaterial()
                        {
                            AlbedoColor          = p.DiffuseColor,
                            AlbedoMap            = p.DiffuseMap,
                            NormalMap            = p.NormalMap,
                            RMAMap               = p.SpecularColorMap,
                            RenderShadowMap      = true,
                            RenderEnvironmentMap = true,
                        };
                    }
                    //if (ob.Transform != null && ob.Transform.Count > 0)
                    //{
                    //    s.Instances = ob.Transform;
                    //}
                    this.Model1.Add(s);

                    Model2.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = NormalMaterial,
                        Transform        = scaleTransform
                    });

                    ModelNormalVector.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = NormalVectorMaterial,
                        Transform        = scaleTransform
                    });
                    Model3.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = diffuseMaterial,
                        Transform        = scaleTransform
                    });

                    Model4.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = PositionMaterial,
                        Transform        = scaleTransform
                    });

                    Model5.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = VertMaterial,
                        Transform        = scaleTransform
                    });

                    Model6.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = ColorStripeMaterial,
                        Transform        = scaleTransform
                    });

                    Model7.Add(new MeshGeometryModel3D
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Transform        = scaleTransform,
                        Material         = pbrMaterial
                    });
                }, null);
            }
        }
Ejemplo n.º 44
0
        private bool BuildEntity()
        {
            var filenamepart = Path.GetFileNameWithoutExtension(Filename);
            var filename = MainViewModel.CreateUniqueVoxelStorageName(filenamepart + MyVoxelMap.V2FileExtension);

            double multiplier;
            if (IsMultipleScale)
            {
                multiplier = MultipleScale;
            }
            else
            {
                multiplier = MaxLengthScale / Math.Max(Math.Max(OriginalModelSize.Height, OriginalModelSize.Width), OriginalModelSize.Depth);
            }

            var scale = new ScaleTransform3D(multiplier, multiplier, multiplier);
            var rotateTransform = MeshHelper.TransformVector(new System.Windows.Media.Media3D.Vector3D(0, 0, 0), -RotateRoll, RotateYaw - 90, RotatePitch + 90);
            SourceFile = TempfileUtil.NewFilename(MyVoxelMap.V2FileExtension);

            var model = MeshHelper.Load(Filename, ignoreErrors: true);

            var meshes = new List<MyVoxelRayTracer.MyMeshModel>();
            var geometeries = new List<MeshGeometry3D>();
            foreach (var model3D in model.Children)
            {
                var gm = (GeometryModel3D)model3D;
                var geometry = gm.Geometry as MeshGeometry3D;

                if (geometry != null)
                    geometeries.Add(geometry);
            }
            meshes.Add(new MyVoxelRayTracer.MyMeshModel(geometeries.ToArray(), InsideStockMaterial.Value, InsideStockMaterial.Value));

            #region handle dialogs and process the conversion

            var doCancel = false;

            var progressModel = new ProgressCancelModel { Title = "Processing...", SubTitle = "Processing...", DialogText = "Time remaining: Calculating..." };
            var progressVm = new ProgressCancelViewModel(this, progressModel);
            progressVm.CloseRequested += delegate(object sender, EventArgs e)
            {
                doCancel = true;
            };

            var cancelFunc = (Func<bool>)delegate
            {
                return doCancel;
            };

            var completedAction = (Action)delegate
            {
                progressVm.Close();
            };

            MyVoxelMap voxelMap = null;

            var action = (Action)delegate
            {
                voxelMap = MyVoxelRayTracer.ReadModelAsteroidVolmetic(model, meshes, scale, rotateTransform, TraceType, TraceCount, TraceDirection,
                    progressModel.ResetProgress, progressModel.IncrementProgress, cancelFunc, completedAction);
            };

            if (RunInLowPrioity)
                System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.Idle;

            _dialogService.ShowDialog<WindowProgressCancel>(this, progressVm, action);

            if (RunInLowPrioity)
                System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.Normal;

            #endregion

            if (doCancel || voxelMap == null)
            {
                IsValidEntity = false;
                NewEntity = null;
            }
            else
            {
                voxelMap.ForceShellMaterial(OutsideStockMaterial.Value, (byte)OutsideMaterialDepth);
                voxelMap.Save(SourceFile);

                var position = VRageMath.Vector3D.Zero;
                var forward = Vector3.Forward;
                var up = Vector3.Up;

                if (IsAbsolutePosition)
                {
                    position = Position.ToVector3();
                }
                else if (IsInfrontofPlayer)
                {
                    // Figure out where the Character is facing, and plant the new construct centered in front of the Character, but "BuildDistance" units out in front.
                    var lookVector = (VRageMath.Vector3D)_dataModel.CharacterPosition.Forward.ToVector3();
                    lookVector.Normalize();
                    VRageMath.Vector3D? boundingIntersectPoint = voxelMap.BoundingContent.IntersectsRayAt(voxelMap.BoundingContent.Center, -lookVector * 5000d);

                    if (!boundingIntersectPoint.HasValue)
                    {
                        boundingIntersectPoint = voxelMap.BoundingContent.Center;
                    }

                    var distance = VRageMath.Vector3D.Distance(boundingIntersectPoint.Value, voxelMap.BoundingContent.Center) + (float)BuildDistance;
                    VRageMath.Vector3D vector = lookVector * distance;
                    position = VRageMath.Vector3D.Add(_dataModel.CharacterPosition.Position, vector) - voxelMap.BoundingContent.Center;
                }

                var entity = new MyObjectBuilder_VoxelMap(position, filename)
                {
                    EntityId = SpaceEngineersApi.GenerateEntityId(IDType.ASTEROID),
                    PersistentFlags = MyPersistentEntityFlags2.CastShadows | MyPersistentEntityFlags2.InScene,
                    StorageName = Path.GetFileNameWithoutExtension(filename)
                };

                entity.PositionAndOrientation = new MyPositionAndOrientation
                {
                    Position = position,
                    Forward = forward,
                    Up = up
                };

                IsValidEntity = voxelMap.BoundingContent.Size.Volume > 0f;

                NewEntity = entity;

                if (BeepWhenFinished)
                    System.Media.SystemSounds.Asterisk.Play();
            }

            return !doCancel;
        }
Ejemplo n.º 45
0
        private static void BuildLinkVisual(ref Model3DGroup posLines, ref DiffuseMaterial posDiffuse, ref Model3DGroup negLines, ref DiffuseMaterial negDiffuse, Point3D from, Point3D to, double weight, double[] brainChemicals, ItemColors colors)
        {
            const double GAP = .05d;
            const double CHEMSPACE = .01d;

            double thickness = Math.Abs(weight) * .003d;

            #region Shorten Line

            // Leave a little bit of gap between the from node and the line so the user knows what direction the link is
            Vector3D line = from - to;
            double length = line.Length;
            double newLength = length - GAP;
            if (newLength > length * .75d)		// don't shorten it if it's going to be too small
            {
                line = line.ToUnit() * newLength;
            }
            else
            {
                newLength = length;		// doing this here so the logic below doesn't need an if statement
            }

            Point3D fromActual = to + line;

            #endregion

            GeometryModel3D geometry = null;

            #region Draw Line

            if (weight > 0)
            {
                if (posLines == null)
                {
                    posLines = new Model3DGroup();
                    posDiffuse = new DiffuseMaterial(new SolidColorBrush(colors.Link_Positive));
                }

                geometry = new GeometryModel3D();
                geometry.Material = posDiffuse;
                geometry.BackMaterial = posDiffuse;
                geometry.Geometry = UtilityWPF.GetLine(fromActual, to, thickness);

                posLines.Children.Add(geometry);
            }
            else
            {
                if (negLines == null)
                {
                    negLines = new Model3DGroup();
                    negDiffuse = new DiffuseMaterial(new SolidColorBrush(colors.Link_Negative));
                }

                geometry = new GeometryModel3D();
                geometry.Material = negDiffuse;
                geometry.BackMaterial = negDiffuse;
                geometry.Geometry = UtilityWPF.GetLine(fromActual, to, thickness);

                negLines.Children.Add(geometry);
            }

            #endregion

            if (brainChemicals != null)
            {
                #region Draw Brain Chemicals

                #region Calculations

                double workingLength = newLength - GAP;
                if (Math1D.IsNearValue(length, newLength))
                {
                    // Logic above didn't use a gap, so don't do one here either
                    workingLength = length;
                }

                double totalChemSpace = (brainChemicals.Length - 1) * CHEMSPACE;

                double chemSpace = CHEMSPACE;
                if (totalChemSpace > workingLength)
                {
                    chemSpace = workingLength / (brainChemicals.Length - 1);		// shouldn't get divide by zero
                }

                Vector3D chemOffset = line.ToUnit() * (chemSpace * -1d);

                RotateTransform3D rotTrans = new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRotation(new Vector3D(0, 0, 1), line)));

                #endregion

                // Place the chemicals
                for (int cntr = 0; cntr < brainChemicals.Length; cntr++)
                {
                    Transform3DGroup transform = new Transform3DGroup();
                    transform.Children.Add(rotTrans);
                    transform.Children.Add(new TranslateTransform3D((fromActual + (chemOffset * cntr)).ToVector()));

                    double scale = .0062d * Math.Abs(brainChemicals[cntr]);
                    ScaleTransform3D scaleTransform = new ScaleTransform3D(scale, scale, scale);

                    if (brainChemicals[cntr] > 0)
                    {
                        if (posLines == null)
                        {
                            posLines = new Model3DGroup();
                            posDiffuse = new DiffuseMaterial(new SolidColorBrush(colors.Link_Positive));
                        }

                        geometry = new GeometryModel3D();
                        geometry.Material = posDiffuse;
                        geometry.BackMaterial = posDiffuse;
                        geometry.Geometry = UtilityWPF.GetCircle2D(5, scaleTransform, Transform3D.Identity);
                        geometry.Transform = transform;

                        posLines.Children.Add(geometry);
                    }
                    else
                    {
                        if (negLines == null)
                        {
                            negLines = new Model3DGroup();
                            negDiffuse = new DiffuseMaterial(new SolidColorBrush(colors.Link_Negative));
                        }

                        geometry = new GeometryModel3D();
                        geometry.Material = negDiffuse;
                        geometry.BackMaterial = negDiffuse;
                        geometry.Geometry = UtilityWPF.GetCircle2D(5, scaleTransform, Transform3D.Identity);
                        geometry.Transform = transform;

                        negLines.Children.Add(geometry);
                    }
                }

                #endregion
            }
        }
Ejemplo n.º 46
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.tulbar = ((System.Windows.Controls.ToolBar)(target));
                return;

            case 2:

            #line 15 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.CheckBox)(target)).Checked += new System.Windows.RoutedEventHandler(this.prviChecked);

            #line default
            #line hidden

            #line 15 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.CheckBox)(target)).Unchecked += new System.Windows.RoutedEventHandler(this.prviUnchecked);

            #line default
            #line hidden
                return;

            case 3:

            #line 16 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.CheckBox)(target)).Checked += new System.Windows.RoutedEventHandler(this.drugiChecked);

            #line default
            #line hidden

            #line 16 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.CheckBox)(target)).Unchecked += new System.Windows.RoutedEventHandler(this.drugiUnchecked);

            #line default
            #line hidden
                return;

            case 4:

            #line 17 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.CheckBox)(target)).Checked += new System.Windows.RoutedEventHandler(this.treciChecked);

            #line default
            #line hidden

            #line 17 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.CheckBox)(target)).Unchecked += new System.Windows.RoutedEventHandler(this.treciUnchecked);

            #line default
            #line hidden
                return;

            case 5:
                this.vjuport = ((System.Windows.Controls.Viewport3D)(target));

            #line 19 "..\..\MainWindow.xaml"
                this.vjuport.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.panMouseLeftButtonUp);

            #line default
            #line hidden

            #line 19 "..\..\MainWindow.xaml"
                this.vjuport.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.zoomMouseWheel);

            #line default
            #line hidden

            #line 19 "..\..\MainWindow.xaml"
                this.vjuport.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.panMouseLeftButtonDown);

            #line default
            #line hidden

            #line 19 "..\..\MainWindow.xaml"
                this.vjuport.MouseMove += new System.Windows.Input.MouseEventHandler(this.panMouseMove);

            #line default
            #line hidden

            #line 19 "..\..\MainWindow.xaml"
                this.vjuport.MouseDown += new System.Windows.Input.MouseButtonEventHandler(this.rotacijaWheel);

            #line default
            #line hidden

            #line 19 "..\..\MainWindow.xaml"
                this.vjuport.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.rotacijaWheelUp);

            #line default
            #line hidden
                return;

            case 6:
                this.kamera = ((System.Windows.Media.Media3D.PerspectiveCamera)(target));
                return;

            case 7:
                this.mapaPoZ = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 8:
                this.mapaPoX = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 9:
                this.translacija = ((System.Windows.Media.Media3D.TranslateTransform3D)(target));
                return;

            case 10:
                this.skaliranje = ((System.Windows.Media.Media3D.ScaleTransform3D)(target));
                return;

            case 11:
                this.elementiPoZ = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 12:
                this.elementiPoX = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 13:
                this.grupica = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 14:
                this.prveLinijePoZ = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 15:
                this.prveLinijePoX = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 16:
                this.prveLinije = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 17:
                this.drugeLinijePoZ = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 18:
                this.drugeLinijePoX = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 19:
                this.drugeLinije = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;

            case 20:
                this.treceLinijePoZ = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 21:
                this.treceLinijePoX = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 22:
                this.treceLinije = ((System.Windows.Media.Media3D.Model3DGroup)(target));
                return;
            }
            this._contentLoaded = true;
        }