Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gameTime"></param>
        /// <param name="stereoEye"></param>
        protected override void Draw(GameTime gameTime, StereoEye stereoEye)
        {
            CBData cbData = new CBData();

            var cam = GetService <Camera>();

            GraphicsDevice.ClearBackbuffer(Color.CornflowerBlue, 1, 0);


            foreach (var e in space.Entities)
            {
                Box box = e as Box;
                if (box != null)                   // this won't create any graphics for an entity that isn't a box
                {
                    if (box.IsDynamic)             // draw only dynamic boxes
                    {
                        // fill world matrix
                        Fusion.Mathematics.Matrix matrix = new Fusion.Mathematics.Matrix(box.WorldTransform.M11, box.WorldTransform.M12, box.WorldTransform.M13, box.WorldTransform.M14,
                                                                                         box.WorldTransform.M21, box.WorldTransform.M22, box.WorldTransform.M23, box.WorldTransform.M24,
                                                                                         box.WorldTransform.M31, box.WorldTransform.M32, box.WorldTransform.M33, box.WorldTransform.M34,
                                                                                         box.WorldTransform.M41, box.WorldTransform.M42, box.WorldTransform.M43, box.WorldTransform.M44);
                        cbData.Projection = cam.GetProjectionMatrix(stereoEye);
                        cbData.View       = cam.GetViewMatrix(stereoEye);
                        cbData.World      = matrix;
                        cbData.ViewPos    = new Vector4Fusion(cam.GetCameraMatrix(stereoEye).TranslationVector, 1);
                        Color c = (Color)box.Tag;
                        cbData.Color = c.ToVector4();

                        constBuffer.SetData(cbData);

                        GraphicsDevice.PipelineState = factory[0];

                        GraphicsDevice.PixelShaderConstants[0]  = constBuffer;
                        GraphicsDevice.VertexShaderConstants[0] = constBuffer;
                        GraphicsDevice.PixelShaderSamplers[0]   = SamplerState.AnisotropicWrap;
                        GraphicsDevice.PixelShaderResources[0]  = texture;

                        // setup data and draw box
                        GraphicsDevice.SetupVertexInput(vb, ib);
                        GraphicsDevice.DrawIndexed(36, 0, 0);
                    }
                }
            }

            base.Draw(gameTime, stereoEye);
        }
Пример #2
0
 //_________________________________________________________________________
 void CBDataSave()
 {
     if (bCBData_TextChanged)
     {
         bCBData_TextChanged = false;
         if (Properties.Settings.Default.asData.Contains(CBData.Text + ";") == false)
         {
             Properties.Settings.Default.asData += ";" + CBData.Text;
             CBData.Items.Add(CBData.Text);
             int iPosNewVal = CBData.FindString(CBData.Text);
             if (iPosNewVal == -1)
             {
                 Properties.Settings.Default.iData = CBData.Items.Count - 1;
             }
             else
             {
                 Properties.Settings.Default.iData = iPosNewVal;
             }
         }
     }
 }
Пример #3
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="gameTime"></param>
		/// <param name="stereoEye"></param>
		protected override void Draw (GameTime gameTime, StereoEye stereoEye)
		{
			CBData cbData = new CBData();

			var cam = GetService<Camera>();

			GraphicsDevice.ClearBackbuffer(Color.CornflowerBlue, 1, 0);


			foreach ( var e in space.Entities ) {
				Box box = e as Box;
				if ( box != null ) // this won't create any graphics for an entity that isn't a box
				{
					if ( box.IsDynamic ) // draw only dynamic boxes
					{
						// fill world matrix
						Fusion.Mathematics.Matrix matrix = new Fusion.Mathematics.Matrix(box.WorldTransform.M11, box.WorldTransform.M12, box.WorldTransform.M13, box.WorldTransform.M14,
																									box.WorldTransform.M21, box.WorldTransform.M22, box.WorldTransform.M23, box.WorldTransform.M24,
																									box.WorldTransform.M31, box.WorldTransform.M32, box.WorldTransform.M33, box.WorldTransform.M34,
																									box.WorldTransform.M41, box.WorldTransform.M42, box.WorldTransform.M43, box.WorldTransform.M44);
						cbData.Projection = cam.GetProjectionMatrix(stereoEye);
						cbData.View = cam.GetViewMatrix(stereoEye);
						cbData.World = matrix;
						cbData.ViewPos = new Vector4Fusion(cam.GetCameraMatrix(stereoEye).TranslationVector, 1);
						Color c = (Color) box.Tag;
						cbData.Color =  c.ToVector4();

						constBuffer.SetData(cbData);
						
						GraphicsDevice.PipelineState = factory[0];

						GraphicsDevice.PixelShaderConstants[0] = constBuffer;
						GraphicsDevice.VertexShaderConstants[0] = constBuffer;
						GraphicsDevice.PixelShaderSamplers[0] = SamplerState.AnisotropicWrap;
						GraphicsDevice.PixelShaderResources[0] = texture;

						// setup data and draw box
						GraphicsDevice.SetupVertexInput(vb, ib);
						GraphicsDevice.DrawIndexed( 36, 0, 0);
					}
				}
			}

			base.Draw(gameTime, stereoEye);
		}