stownend

Members
  • Content count

    2
  • Joined

  • Last visited

Community Reputation

100 Neutral

About stownend

  • Rank
    Newbie
  1. Hi Hyu, Success! I had already been working through most of the issues that you mentioned (eg. Kinect not being at screen centre). I actually place my Kinect across the room, at my rght hand side. That allows it to track me right up to the screen. I obviously had to swap around the x,y,z values and incorporate the various offsets but the end result was good. Regarding my main issue of the model appearing approx half as big as it should, I originally got around this by scaling my model by a factor of 2. This seemed ok until I was into the fine-tuning stage. Then I noticed that I had to move me head twice as far in x or y in order to get a specific view on the screen. I noticed this when trying to look straight down the edge of the room - I should have had my head in line with the edge of the screen for this but had to have it half as far away again. This was clearly related to the scaling that I had done to the model. After a lot of head scratching and scribbled calculations I was struggling until I looked at the following document very closely ([url="http://www.cs.ubc.ca/labs/imager/PROCAMS2011/0008.pdf"]http://www.cs.ubc.ca/labs/imager/PROCAMS2011/0008.pdf[/url]). In section 5.2 they present a formula for the projection matrix that is so similar to the one that you presented above. The key difference is that they were using a half of the screen/model width and a half of the screen/model height. When I modified your projection matrix I found that I no longer needed to scale my model by 2 and the viewing angles were now correct when trying to look down the edge of the room/screen. So, using my screen of 0.38M wide by 0.3M high with a model of the same size, my projection matrix becomes:- [CODE] left = nearPlane * ((-.38f / 2) - cameraPosition.X) / cameraPosition.Z; right = nearPlane * ((.38f / 2) - cameraPosition.X) / cameraPosition.Z; bottom = nearPlane * ((-.3f / 2) - cameraPosition.Y) / cameraPosition.Z; top = nearPlane * ((.3f /2 ) - cameraPosition.Y) / cameraPosition.Z; [/CODE] Thanks for all your help. All I need to do now is do some decent models with textures and my demo will be complete. I will try to remember to post a video when it is finished. Steve
  2. Hi Hyu, I have been struggling with the issue of head tracking and the associated projection matrix for few days now. Your posting has really helped. I am using Microsoft's own Kinect SDK but, like you, am using the keyboard to simulate head movement until I can get the viewing correct. Here are some basic facts about my box/room:-[list] [*]I am using units of 1M as thats what Kinect reports [*]My box/room is 0.38 * 0.3 as that is my screen size in Meters [/list] I am having difficulty deciding on a few things:-[list] [*]Where to place the centre of the open-end of the box/room in the world. I have tried it at 0,0,0 [*]Assuming the above, where to place the camera - I have it at 0.34 [/list] This is what I see when the game first loads:- [img]https://public.sn2.livefilestore.com/y1p5l3MaPUGC8o1UmiM2dKlQ3t9-hgEH0Ht_pCgtjF_GF-HlUeFhZINbOdyOtef5mwX1eD-lL0aK_SMU-lruECm0A/InitialScreen.JPG?psid=1[/img] As you can see it does not fill the screen. If I the move the camera to the right, the perspective seems to change correctly and the open face of the room stays put:- [img]https://public.sn2.livefilestore.com/y1pS-xEDPIuCOe-ChZStYwOh95bmUHAkalq73CEsIjawkB73qI-sgA4gw8balzyNtVh422cl0Ehm6Gk1aNuagmDfQ/CameraXChange.JPG?psid=1[/img] Moving the camera in Z merely alters the perceived depth of the room, it does not change its position:- [img]https://public.sn2.livefilestore.com/y1pdOZSTT2A3srYETvEzj6OGaaqomr7qawGVAAyH6TfS-S_plkrSERI3NQJBJXVhx6hnlwecBdn_9BYZ9aPTjfb0A/CameraZChange.JPG?psid=1[/img] If I move the model so that it fills more of the screen (eg. Z=0.08) then move the camera in any direction, the image perspective is ok but the open face of the room has moved to the left as it appears to be rotating the room around world (0,0,0):- [img]https://public.sn2.livefilestore.com/y1ppQ91z5AdC6DsorKjD96w_E3qB3rye36B4mIo6V0B87ZX8tsqnRMONZDHpfBq3lDp7KHPNwZUcoQQKeAYB6LXUQ/ModelMovePlusCameraXChange.JPG?psid=1[/img] Have you any idea where I am going wrong? It feels so close.[list] [*]I would like to fill the screen with the open face of the room [*]Once in position, I want camera movements to affect the perspective of the view but leave the open face in place [*]I would expect Z movement of the camera would affect perspective but would not zoom the image. Does that make sense and how did you achieve it? [*]Would your camera position directly correlate with the head position as reported by Kinect or would you be doing some manipulation to keep the distance from head to screen center constant (some kind of orbital camera movement)? [/list] Here is my draw code in case I have something wrong there:- [CODE] matView = Matrix.CreateLookAt(cameraPosition, new Vector3(cameraPosition.X, cameraPosition.Y, 0.0f), Vector3.Up); // from http://www.gamedev.net/topic/597564-view-and-projection-matrices-for-vr-window-using-head-tracking/ //Create a perspective off center //near and far planes are 0.05f & 500f float nearPlane = 0.05f; float farPlane = 500f; float left = nearPlane * (-.38f - cameraPosition.X) / cameraPosition.Z; float right = nearPlane * (.38f - cameraPosition.X) / cameraPosition.Z; float bottom = nearPlane * (-.3f - cameraPosition.Y) / cameraPosition.Z; float top = nearPlane * (.3f - cameraPosition.Y) / cameraPosition.Z; matProjection = Matrix.CreatePerspectiveOffCenter(left, right, bottom, top, nearPlane, farPlane); // Draw the model. A model can have multiple meshes, so loop. foreach (ModelMesh mesh in myModel.Meshes) { // This is where the mesh orientation is set, as well as our camera and projection. foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY(0.0f) * Matrix.CreateTranslation(modelPosition); effect.View = matView; effect.Projection = matProjection; } // Draw the mesh, using the effects set above. mesh.Draw(); } [/CODE] I would be very interested to see the results that you achieved or the source code. I will gladly share mine once I am done. Regards, Steve