Ejemplo n.º 1
0
        void renderTargetUserControl1_Render( RenderTargetUserControl sender, Camera camera )
        {
            //update camera
            if( Map.Instance != null )
            {
                Vec3 position;
                Vec3 forward;
                Degree fov;

                MapCamera mapCamera = Entities.Instance.GetByName( "MapCamera_1" ) as MapCamera;
                if( mapCamera != null )
                {
                    position = mapCamera.Position;
                    forward = mapCamera.Rotation * new Vec3( 1, 0, 0 );
                    fov = mapCamera.Fov;
                }
                else
                {
                    position = Map.Instance.EditorCameraPosition;
                    forward = Map.Instance.EditorCameraDirection.GetVector();
                    fov = Map.Instance.Fov;
                }

                if( fov == 0 )
                    fov = Map.Instance.Fov;

                renderTargetUserControl1.CameraNearFarClipDistance = Map.Instance.NearFarClipDistance;
                renderTargetUserControl1.CameraFixedUp = Vec3.ZAxis;
                renderTargetUserControl1.CameraFov = fov;
                renderTargetUserControl1.CameraPosition = position;
                renderTargetUserControl1.CameraDirection = forward;
            }
        }
Ejemplo n.º 2
0
 public int GetViewIndexByControl( RenderTargetUserControl control )
 {
     for( int n = 0; n < views.Length; n++ )
     {
         if( views[ n ].Control == control )
             return n;
     }
     return -1;
 }
Ejemplo n.º 3
0
		void renderTargetUserControl1_Tick( RenderTargetUserControl sender, float delta )
		{
			RenderTargetUserControl control = sender;

			//moving free camera by keys
			if( Map.Instance != null && freeCameraEnabled )
			{
				float cameraVelocity = 20;

				Vec3 pos = freeCameraPosition;
				SphereDir dir = freeCameraDirection;

				float step = cameraVelocity * delta;

				if( control.IsKeyPressed( Keys.W ) ||
					control.IsKeyPressed( Keys.Up ) )
				{
					pos += dir.GetVector() * step;
				}
				if( control.IsKeyPressed( Keys.S ) ||
					control.IsKeyPressed( Keys.Down ) )
				{
					pos -= dir.GetVector() * step;
				}
				if( control.IsKeyPressed( Keys.A ) ||
					control.IsKeyPressed( Keys.Left ) )
				{
					pos += new SphereDir(
						dir.Horizontal + MathFunctions.PI / 2, 0 ).GetVector() * step;
				}
				if( control.IsKeyPressed( Keys.D ) ||
					control.IsKeyPressed( Keys.Right ) )
				{
					pos += new SphereDir(
						dir.Horizontal - MathFunctions.PI / 2, 0 ).GetVector() * step;
				}
				if( control.IsKeyPressed( Keys.Q ) )
					pos += new Vec3( 0, 0, step );
				if( control.IsKeyPressed( Keys.E ) )
					pos += new Vec3( 0, 0, -step );

				freeCameraPosition = pos;
			}
		}
Ejemplo n.º 4
0
        private void renderTargetUserControl1_RenderUI(RenderTargetUserControl sender, GuiRenderer renderer)
        {
            string text = "NeoAxis 3D Engine " + EngineVersionInformation.Version;
            renderer.AddText(text, new Vec2(.01f, .01f), HorizontalAlign.Left,
                VerticalAlign.Top, new ColorValue(1, 1, 1));

            renderer.AddText("Camera control: W A S D, right mouse", new Vec2(.99f, .99f),
                HorizontalAlign.Right, VerticalAlign.Bottom, new ColorValue(1, 1, 1));
        }
Ejemplo n.º 5
0
        private void renderTargetUserControl1_Render(RenderTargetUserControl sender, Camera camera)
        {
            //update camera
            if (Map.Instance != null)
            {
                Vec3 position;
                Vec3 forward;
                Vec3 up;
                Degree fov;

                if (!freeCameraEnabled)
                {
                    //usual camera

                    position = Vec3.Zero;
                    forward = new Vec3(1, 0, 0);
                    up = Vec3.ZAxis;
                    fov = Map.Instance.Fov;

                    //MapCamera mapCamera = Entities.Instance.GetByName( "MapCamera_0" ) as MapCamera;
                    //if( mapCamera != null )
                    //{
                    //   position = mapCamera.Position;
                    //   forward = mapCamera.Rotation * new Vec3( 1, 0, 0 );
                    //   fov = mapCamera.Fov;
                    //}
                }
                else
                {
                    //free camera

                    position = freeCameraPosition;
                    forward = freeCameraDirection.GetVector();
                    up = Vec3.ZAxis;
                    fov = Map.Instance.Fov;
                }

                renderTargetUserControl1.CameraNearFarClipDistance = Map.Instance.NearFarClipDistance;
                renderTargetUserControl1.CameraFixedUp = up;
                renderTargetUserControl1.CameraFov = fov;
                renderTargetUserControl1.CameraPosition = position;
                renderTargetUserControl1.CameraDirection = forward;
            }

            //update sound listener
            if (SoundWorld.Instance != null)
                SoundWorld.Instance.SetListener(camera.Position, Vec3.Zero, camera.Direction, camera.Up);

            //if( Map.Instance != null && !renderTargetUserControl1.MouseRelativeMode )
            //   RenderEntityOverCursor( camera );
        }
Ejemplo n.º 6
0
        private void renderTargetUserControl1_Tick(RenderTargetUserControl sender, float delta)
        {
            //update network status
            NetworkConnectionStatuses status = NetworkConnectionStatuses.Disconnected;
            if (GameNetworkClient.Instance != null)
                status = GameNetworkClient.Instance.Status;
            labelNetworkStatus.Text = status.ToString();

            //moving free camera by keys
            if (Map.Instance != null && freeCameraEnabled)
            {
                float cameraVelocity = 20;

                Vec3 pos = freeCameraPosition;
                SphereDir dir = freeCameraDirection;

                float step = cameraVelocity * delta;

                if (renderTargetUserControl1.IsKeyPressed(Keys.W) ||
                    renderTargetUserControl1.IsKeyPressed(Keys.Up))
                {
                    pos += dir.GetVector() * step;
                }
                if (renderTargetUserControl1.IsKeyPressed(Keys.S) ||
                    renderTargetUserControl1.IsKeyPressed(Keys.Down))
                {
                    pos -= dir.GetVector() * step;
                }
                if (renderTargetUserControl1.IsKeyPressed(Keys.A) ||
                    renderTargetUserControl1.IsKeyPressed(Keys.Left))
                {
                    pos += new SphereDir(
                        dir.Horizontal + MathFunctions.PI / 2, 0).GetVector() * step;
                }
                if (renderTargetUserControl1.IsKeyPressed(Keys.D) ||
                    renderTargetUserControl1.IsKeyPressed(Keys.Right))
                {
                    pos += new SphereDir(
                        dir.Horizontal - MathFunctions.PI / 2, 0).GetVector() * step;
                }
                if (renderTargetUserControl1.IsKeyPressed(Keys.Q))
                    pos += new Vec3(0, 0, step);
                if (renderTargetUserControl1.IsKeyPressed(Keys.E))
                    pos += new Vec3(0, 0, -step);

                freeCameraPosition = pos;
            }
        }
 public ViewRenderTargetListener(RenderTargetUserControl owner)
 {
     this.owner = owner;
 }
 public ViewRenderTargetListener(RenderTargetUserControl owner)
 {
     this.owner = owner;
 }
Ejemplo n.º 9
0
        public void SetViewsConfiguration( Rect[] rectangles )
        {
            DestroyViews();

            views = new View[ rectangles.Length ];

            for( int viewIndex = 0; viewIndex < views.Length; viewIndex++ )
            {
                RenderTargetUserControl control = new RenderTargetUserControl();
                Controls.Add( control );

                View view = new View( this, rectangles[ viewIndex ], control );
                views[ viewIndex ] = view;

                view.UpdateControlLocationSize();

                if( viewIndex == 0 )
                    view.Control.Tick += Control_Tick;
                view.Control.Render += Control_Render;
                view.Control.RenderUI += Control_RenderUI;
            }
        }
Ejemplo n.º 10
0
 internal View( MultiViewRenderTargetControl owner, Rect rectangle, RenderTargetUserControl control )
 {
     this.owner = owner;
     this.rectangle = rectangle;
     this.control = control;
 }
Ejemplo n.º 11
0
 void Control_Tick( RenderTargetUserControl sender, float delta )
 {
     if( Tick != null )
         Tick( this, delta );
 }
Ejemplo n.º 12
0
 void Control_RenderUI( RenderTargetUserControl sender, GuiRenderer renderer )
 {
     if( RenderUI != null )
     {
         int viewIndex = GetViewIndexByControl( sender );
         if( viewIndex != -1 )
             RenderUI( this, viewIndex, renderer );
     }
 }
Ejemplo n.º 13
0
 void Control_Render( RenderTargetUserControl sender, Camera camera )
 {
     if( Render != null )
     {
         int viewIndex = GetViewIndexByControl( sender );
         if( viewIndex != -1 )
             Render( this, viewIndex, camera );
     }
 }