Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline bfox  
#1 Posted : Sunday, November 27, 2011 10:09:56 PM(UTC)
bfox

Joined: 8/22/2011(UTC)
Posts: 170
Location: Moscow

Thanks: 3 times
Was thanked: 2 time(s) in 2 post(s)
Hi.

Need some help.
I want to take the point value on Grid (on z=0)
if start test point OnGrid -is correct. If i zoom camera ..
cam.FarPlane += -0.001f; dont work. I can not understand why the camera is not updated


Code:

		[Test]
		public static void Test2()
		{
            BaseCamera cam = new LookAtCamera(new Vector(0,0 , 10));
            cam.FieldOfView = MathHelper.DegreeToRadians(90);
		    cam.NearPlane = 1;  //work
            cam.FarPlane = 10;   //work
			Vector halfSize = new Vector(3, 3, 3);

			Application.Start(delegate
			{
				Grid.Draw();
				Point input = Input.Mouse.Position;
				Ray screenRay = ScreenSpace.GetRayFromScreenPoint(input);
				Vector OnGrid =(screenRay.Position + screenRay.Direction);
			    
				Font.Default.DrawCentered("input=" + input +
				                          "\nscreenRay=" + screenRay +
                                          "\n OnGrid=" + OnGrid + " " + cam.FarPlane,
					new Point(0.5f, 0.3f));

                if(Input.Keyboard.SpaceIsPressed)
                {
                    cam.Position += new Vector(0,0,-0.001f);
                    cam.FarPlane += -0.001f; //dont work ???
                }
			});
		}


i need it for my 2d game =)

Edited by user Sunday, November 27, 2011 10:11:51 PM(UTC)  | Reason: Not specified

Russian game developer.
Давайте делать игры в команде. Идет набор.

Wanna join the discussion?! Login to your forum accountregister a new account. Or Connect via Facebook Twitter Google

Offline Benjamin  
#2 Posted : Sunday, November 27, 2011 11:17:37 PM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Hi BFox,

you should be able to see the code in Delta.Rendering.Cameras. If you check out BaseCamera, you can see that setting FarPlane has no effect because it is only used in the UpdateProjectionMatrix method, which is only called once in the constructor.

So to make it work in your code, you need to update the projection matrix of your camera explicitly after changing some setup values (like FarPlane). Do you think we should maybe do this automatically when changing properties like FarPlane, NearPlane, FieldOfView, etc.?

Code:

			camera.FarPlane = 2000;
			camera.UpdateProjectionMatrix();


Hope that helps Cool
Offline bfox  
#3 Posted : Monday, November 28, 2011 4:59:44 AM(UTC)
bfox

Joined: 8/22/2011(UTC)
Posts: 170
Location: Moscow

Thanks: 3 times
Was thanked: 2 time(s) in 2 post(s)
Originally Posted by: Benjamin Nitschke (DeltaEngine) Go to Quoted Post
Hi BFox,

you should be able to see the code in Delta.Rendering.Cameras. If you check out BaseCamera, you can see that setting FarPlane has no effect because it is only used in the UpdateProjectionMatrix method, which is only called once in the constructor.

So to make it work in your code, you need to update the projection matrix of your camera explicitly after changing some setup values (like FarPlane). Do you think we should maybe do this automatically when changing properties like FarPlane, NearPlane, FieldOfView, etc.?

Code:

			camera.FarPlane = 2000;
			camera.UpdateProjectionMatrix();


Hope that helps Cool


Thanks for your helpThumpUp . No automatically Smile camera.FarPlane = ; will always be used with camera.UpdateProjectionMatrix(); but No =) if i use FarPlane, NearPlane, FieldOfView in one time => will be 2 unnecessary run camera.UpdateProjectionMatrix()
Russian game developer.
Давайте делать игры в команде. Идет набор.
Rss Feed  Atom Feed
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
This page was generated in 0.045 seconds.