Delta Engine
»
Support
»
Rendering
»
GetRayFromScreenPoint
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. Давайте делать игры в команде. Идет набор. |
|
|
|
Medals:  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
|
|
|
|
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)  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 Thanks for your help  . No automatically  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. Давайте делать игры в команде. Идет набор. |
|
|
|
Delta Engine
»
Support
»
Rendering
»
GetRayFromScreenPoint
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.