Exemplo n.º 1
0
    static void Main(string[] args)
    {
      navigationMatrix = new Matrix3D();
      navigationMatrix.Translate(new Vector3D(0, 100, 110));
      navigationMatrix.Scale(new Vector3D((double)1 / 5, (double)1 / 5, (double)1 / 5));

      displayProfile = new Bin[Bin.RANGEL, Bin.RANGEA, Bin.RANGEB];
      for (int l = 0; l < Bin.RANGEL; l++)
        for (int a = 0; a < Bin.RANGEA; a++)
          for (int b = 0; b < Bin.RANGEB; b++)
            displayProfile[l, a, b] = new Bin(l, a, b);

      PopulateProfile(displayProfile, navigationMatrix);

      String path = Environment.CurrentDirectory + PATH_TO_VIDEO;
      if (!System.IO.File.Exists(path))
        return;


      //Opens the movie file
      capture = new Capture(path);
      double fps = capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS);

      //Reads frame by frame
      Timer timer = new Timer(1000 / fps);
      timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
      timer.Start();

      Console.Read();
    }
Exemplo n.º 2
0
        internal override void Append(ref Matrix3D matrix)
        {
            Vector3D scale = new Vector3D(_cachedScaleXValue, _cachedScaleYValue, _cachedScaleZValue);

            if (_cachedCenterXValue == 0.0 && _cachedCenterYValue == 0.0 && _cachedCenterZValue == 0.0)
            {
                matrix.Scale(scale);
            }
            else
            {
                matrix.ScaleAt(scale, new Point3D(_cachedCenterXValue, _cachedCenterYValue, _cachedCenterZValue));
            }
        }
Exemplo n.º 3
0
        public static IMatrix3D FromIDictionary(IDictionary source, IFactory factory_in)
        {
            IFactory factory = factory_in;
            if (factory == null) factory = Node.Net.Factories.Deprecated.Factory.Default;
            var matrix3D = new Matrix3D();
            var irotations = factory.Create<IRotations>(source,null);
            if (irotations == null) irotations = Node.Net.Factories.Deprecated.Factory.Default.Create<IRotations>(source,null);
            var iscale = factory.Create<IScale>(source,null);
            //if (iscale == null) iscale = Node.Net.Factories.Factory.Default.Create<IScale>(source);
            var itranslation = factory.Create<ITranslation>(source,null);
            if (itranslation == null) itranslation = factory.Create<ITranslation>(source,null);
            if (irotations != null)
            {
                matrix3D = RotateXYZ(new Matrix3D(), irotations.RotationsXYZ);
            }
            if (iscale != null) matrix3D.Scale(iscale.Scale);
            if (itranslation != null) matrix3D.Translate(itranslation.Translation);

            if (!matrix3D.IsIdentity)
            {
                return new ConcreteMatrix3D { Matrix3D = matrix3D };
            }
            return new ConcreteMatrix3D();
        }
Exemplo n.º 4
0
        protected virtual void NewTransform()
        {
            if (lockCount != 0)
                return;

            Matrix3D m = new Matrix3D();
            m.Scale(new Vector3D(ScaleX, ScaleY, ScaleZ));
            m.Rotate(Rotation1);
            m.Rotate(Rotation2);
            m.Translate(new Vector3D(Position.X, Position.Y, Position.Z));
            m.Rotate(Rotation3);
            Transform = new MatrixTransform3D(m);
        }
Exemplo n.º 5
0
        /// <summary>
        /// パーティクルの描画設定をまとめて行います。
        /// </summary>
        public override void RenderParticles(IEnumerable<Particle> particles)
        {
            base.RenderParticles(particles);

            foreach (var particle in particles)
            {
                if (particle.Brush != null)
                {
                    var opacity = (double)((particle.Color >> 24) & 0xFF) / 255.0;

                    particle.Brush.Opacity = EffectObject.InheritedOpacity * opacity;
                }

                if (particle.Material != null)
                {
                    var em = particle.Material as EmissiveMaterial;
                    if (em != null)
                    {
                        em.Color = ToColor(particle.Color);
                    }
                    else
                    {
                        var dm = particle.Material as DiffuseMaterial;
                        if (dm != null)
                        {
                            dm.Color = ToColor(particle.Color);
                        }
                    }
                }

                // 行列変換
                var m = new Matrix3D();

                if (particle.Scale != 1.0)
                {
                    m.Scale(new Vector3D(particle.Scale, particle.Scale, 1.0));
                }

                if (particle.Rotation != 0.0)
                {
                    double rot = MathEx.ToDeg(particle.Rotation);
                    m.Rotate(new Quaternion(new Vector3D(0, 0, 1), rot));
                }

                m.Translate(new Vector3D(particle.X, particle.Y, -15.0));

                particle.Model.Transform = new MatrixTransform3D(m);
            }
        }
        internal override void Append(ref Matrix3D matrix)
        {
            Vector3D scale = new Vector3D(_cachedScaleXValue, _cachedScaleYValue, _cachedScaleZValue);

            if (_cachedCenterXValue == 0.0 && _cachedCenterYValue == 0.0 && _cachedCenterZValue == 0.0)
            {
                matrix.Scale(scale);
            }
            else
            {
                matrix.ScaleAt(scale, new Point3D(_cachedCenterXValue, _cachedCenterYValue, _cachedCenterZValue));
            }
        }
Exemplo n.º 7
0
        public void UpdateOrCreateJoint(Joint joint)
        {
            int segments = 5;
            double jointRadius = 0.07;
            double boneRadius = 0.03;

            int jointId = (int)joint.ID;
            int connectedToJoint = SkeletonMetadata.BoneConnectionMapping[jointId];
            _jointPositions[jointId] = new Vector3D(joint.Position.X, joint.Position.Y, joint.Position.Z);

            // Create new 3d cube for the joint if not yet existing
            GeometryModel3D model;
            if (_joints[jointId] != null)
            {
                model = _joints[jointId];
            }
            else
            {
                model = Model3DFactory.CreateNormalizedSphere(defaultMaterial, segments);
                _environment.Children.Add(model);
                _joints[jointId] = model;

                if (connectedToJoint >= 0)
                {
                    GeometryModel3D cylinder = Model3DFactory.CreateNormalizedCylinder(defaultMaterial, segments);
                    _environment.Children.Add(cylinder);
                    _bones[jointId] = cylinder;
                }
            }

            // Performance improvement: not using a transformation group, but multiply
            // matrices first and use a single MatrixTransform3D
            var matrix = new Matrix3D();
            matrix.Scale(new Vector3D(jointRadius, jointRadius, jointRadius));
            matrix.Translate(new Vector3D(joint.Position.X, joint.Position.Y, joint.Position.Z));

            // Update position and the material/color (based on current tracking state), color right shoulder blue
            if (joint.ID == JointID.ShoulderRight)
                model.Material = rightShoulderIndicatorMaterial;
            else
                model.Material = _trackingStateMaterials[joint.TrackingState];
            model.Transform = new MatrixTransform3D(matrix);

            if (connectedToJoint >= 0)
            {
                GeometryModel3D bone = _bones[jointId];
                Vector3D boneStart = _jointPositions[jointId];
                Vector3D boneEnd = _jointPositions[connectedToJoint];
                Vector3D boneCenter = (boneStart + boneEnd) / 2;
                Vector3D boneVector = boneEnd - boneStart;

                // Again, compute a single transformation matrix and apply it to each bone
                var boneMatrix = new Matrix3D();
                boneMatrix.Scale(new Vector3D(boneRadius, boneRadius, boneVector.Length));
                boneMatrix.Rotate(GetQuaternionFromVectors(new Vector3D(0, 0, 1), boneVector));
                boneMatrix.Translate(boneCenter);

                bone.Material = _trackingStateMaterials[joint.TrackingState];
                bone.Transform = new MatrixTransform3D(boneMatrix); ;
            }
        }
Exemplo n.º 8
0
		/// <summary>
		/// Build the scene
		/// </summary>
		private void BuildScene()
		{
            tree = null;
            Facts facts = DataContext as Facts;

            dimensionSize = ( facts != null )
                ? Math.Max( Math.Max( facts.What.Count, facts.Where.Count ), facts.When.Count )
                : 8;

            double scale = ( 1d / ( dimensionSize - 1 ) ) * 0.9;

            Matrix3D scaleMatrix = new Matrix3D();
            scaleMatrix.Scale( new Vector3D( scale, scale, scale ) );

            Random rand = new Random();
            MeshGeometry3D cubeMesh = Resources[ "cubeMesh" ] as MeshGeometry3D;

            List<IBSPItem> items = new List<IBSPItem>();

            for ( int whatIndex = 0; whatIndex < dimensionSize; ++whatIndex )
            {
                double x = ( (double)whatIndex / ( dimensionSize - 1 ) ) - 0.5d;

                for ( int whereIndex = 0; whereIndex < dimensionSize; ++whereIndex )
                {
                    double y = ( (double)whereIndex / ( dimensionSize - 1 ) ) - 0.5d;

                    for ( int whenIndex = 0; whenIndex < dimensionSize; ++whenIndex )
                    {
                        double z = ( (double)whenIndex / ( dimensionSize - 1 ) ) - 0.5d;
                        bool valid = true;
                        double materialOffset;
						Facts.FactRow fact = null;

                        if ( facts != null )
                        {
                            valid = ( whatIndex < facts.What.Count )
                                && ( whereIndex < facts.Where.Count )
                                & ( whenIndex < facts.When.Count );

							if ( valid )
							{
								fact = facts.Fact.FindByWhatWhereWhen(
									facts.What[ whatIndex ].ID,
									facts.Where[ whereIndex ].ID,
									facts.When[ whenIndex ].ID );

								valid = ( fact != null );
							}

                            materialOffset = valid ? 0.4 : 0.55;
                        }
                        else
                        {
							double alpha = ( 0.4 + ( rand.NextDouble() * 0.6 ) );

                            // Negative for red, positive for blue
                            materialOffset = ( ( rand.Next( 5 ) == 2 ) ? -alpha : alpha ) * 0.5 + 0.5;
                        }

                        Matrix3D matrix = scaleMatrix;
                        matrix.Translate( new Vector3D( x, y, z ) );

						string uri = ( fact != null ) ? fact.ThumbnailUrl : null;

                        items.Add( new BSPCube( matrix, materialOffset, cubeMesh, uri ) );
                    }
                }
            }

            tree = new BSPTree( items, new BSPTree.PartitionHandler( TreePartition ) );
		}