Setting up first person camera

I'm making a first person shooter game and I'm using this code
// Initializes view parameters when the window size changes.
void Game::CreateWindowSizeDependentResources()
m_miscConstants.ViewportHeight = m_deviceResources->GetScreenViewport().Height;
m_miscConstants.ViewportWidth = m_deviceResources->GetScreenViewport().Width;
m_graphics.UpdateMiscConstants(m_miscConstants);
m_graphics.GetCamera().SetOrientationMatrix(m_deviceResources->GetOrientationTransform3D());
Size outputSize = m_deviceResources->GetOutputSize();
// Setup the camera parameters for our scene.
m_graphics.GetCamera().SetViewport((UINT)outputSize.Width, (UINT)outputSize.Height);
m_graphics.GetCamera().SetPosition(XMFLOAT3());
m_graphics.GetCamera().SetLookAt(XMFLOAT3(0.0f, 0.0f, 0.0f));
float aspectRatio = outputSize.Width / outputSize.Height;
float fovAngleY = 70.0f * XM_PI / 180.0f;
if (aspectRatio < 1.0f)
// Portrait or snap view
m_graphics.GetCamera().SetUpVector(XMFLOAT3(1.0f, 0.0f, 0.0f));
fovAngleY = 120.0f * XM_PI / 180.0f;
else
// Landscape view.
m_graphics.GetCamera().SetUpVector(XMFLOAT3(0.0f, 1.0f, 0.0f));
m_graphics.GetCamera().SetProjection(XM_PI / 2, 1.0f, 0.01f, 100.0f);
// Setup lighting for our scene.
static const XMVECTORF32 s_vPos = { 5.0f, 5.0f, -2.5f, 0.f };
XMFLOAT4 dir;
DirectX::XMStoreFloat4(&dir, XMVector3Normalize(s_vPos));
m_lightConstants.ActiveLights = 1;
m_lightConstants.Ambient = XMFLOAT4(0.3f, 0.3f, 0.3f, 1.0f);
m_lightConstants.IsPointLight[0] = false;
m_lightConstants.LightColor[0] = XMFLOAT4(0.8f, 0.8f, 0.8f, 1.0f);
m_lightConstants.LightDirection[0] = dir;
m_lightConstants.LightSpecularIntensity[0].x = 2;
m_graphics.UpdateLightConstants(m_lightConstants);
How do I set the cameras position to first person?

What does setting the cameras position to first person mean?
Talk through the answer to that question and then think about how to implement that in code.
For example, if you define a first person camera as:
"A first person camera is positioned at head height and moves around with the player, aiming in the direction the user looking."
Then you need to set two properties on the camera:
The match the player's position, at head height
The direction it is looking: to match the direction the player is looking
And if you look at the Camera you'll see it has functions to set each of these, so as the user moves you can call SetPosition and SetLookAt to match the player's position and direction.

Similar Messages

  • The voice that was on when I first set up my ipad came back on and now I have to double click to get into my apps and can't use my apps because her voice is always talking.  How do I make her voice go away and my IPAD work like it should.

    The voice that was on when I first set up my ipad came back on and now I have to double click to get into my apps and can't use my apps because her voice is talking.  How do I make the voice stop and my IPAD work again. 

    If you've turned VoiceOver on then see if triple-clicking the home button turns it off, and then change what Settings > General > Accessibility > Triple-Click Home is set to.
    Otherwise, via 'the touch to select double-tap to activate' process you need to go into Settings > General > Accessibility > VoiceOver and turn it off
    The manual (http://support.apple.com/manuals/#ipad) also says that you should be able to switch voice-over off by connecting to your computer's iTunes :
    Turn VoiceOver on or off in iTunes: Select iPad in the iTunes sidebar. In the Options section of the Summary pane, click Configure Universal Access. Select VoiceOver, then click OK.
    So select Configure Universal Access at the bottom of the Summary tab and set Seeing to Neither

  • How to set the default person to the person lov

    Dear all
    i have 2 lov's 1.Customer Lov 2.Person Lov
    person lov depend on customer lov9person name should be based on customer id)
    in my requirement is i have customer-X is there in these customer i have 10 persons are there
    in 10 persons only one primary person is there remaining 9 are not primary persons
    when i select the customer X from customer lov at the same time i need to set the primary person to the person lov
    if user need to change he will click on person lov he can change the person
    in my case companyid and personid's are both unique
    how can i proceed
    Thnaks & Regards
    Sreekanth

    Hi Sree,
    As per our discussion, you can take following steps:
    1. create required LOVs
    2. in PFR of the co(base page Co), handle event of first LOV
    3. on the basis of the value selected by LOV, run a query to get required Primary Person and assign it to second LOV field.
    Hope this will give you some clue.
    Regards,
    Reetesh Sharma

  • HT204023 Can you set up a personal hotspot between a smartphone and ipad?

    How can you set up a personal hot spot between a smartphone and an ipad?

    First your smartphone, plan and carrier have to support personal hotspot or tethering. The turn it on and select the network it creates in the iPad's Settings/WiFi.

  • Unable to set up a personal email account

    I just got my first blackberry and am already having problems!
    I am trying to set up a personal email account, but when i go to Email Setup in the Setup Wizard, the only option i get is to set up an email acount with an Enterprise Server, which is understand is work-related email accounts.
    I'd be really grateful for any help with this!
    Thanks!

    See this FAQ for guidance:
    http://www.blackberryfaq.com/index.php/What_do_I_need_a_Data_Plan_for%3F
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Unable to set up my personal hotspot

    i am trying to set up my personal hotspot and its telling me to contact the carrier abd when i do they stated that its an apple issue...now i dont know what to do. i am using the iOS 7.0.4 device apple 5s

    The carrier has to support Personal Hotspot and your account has to be provisioned for Hotspot. Check back with your carrier and make sure those things are in order first. If they are, then check this support document. http://support.apple.com/kb/TS2756

  • Are there any native single-player first person shooters available?

    Hi there!
    I'm searching for a good first person shooter that runs natively on my Arch64 system.
    I know that there are several good first person shooters for Linux available, but i found nothing that gives me something different than deathmatch (well, there ARE several variants of it but in the end all variants are "a bunch of players is in an arena or something like that doing something like killing the other team members or destroying their base, steal their flag etc.").
    But i want a single player FPS like Half-Life was. Or like the recently released "Stalker - Call of Pripyat".
    Are there any? (FLOSS would be nice but is no must).
    TIA!
    Dirk

    I've been looking for a good native FPS for a few weeks now too. I did try Sauerbraten. It was very impressive, but a little... odd. Of course the graphics and sound were great. The story and narrative impressed me, and reminded me of playing the intro to Half-Life 2.
    But the odd thing was... little things. Like, I had the game on the "easy" setting, but still got my butt kicked really quickly. (which caused me to lose items and ammo, and therefore became harder) And the enemies were extremely aggressive, but sometimes would just... stand there, looking at me. It was a little eerie. And I died on the map I was playing in places that I probably shouldn't have, simply because it was confusing. (I saw the "Danger - Electricity" signs as I was landing on the platform with dangerous electricity) And I got stuck in a "hole" that was really hard to get out of. (I had to move a box, jump out of it, and try over and over to jump out) And I spent a lot of time trying to figure out where to go next, and I was just in the first 10 minutes of the level. And enemies seem to take a ton of bullets to kill.
    So, to summarize, the graphics and sound and narrative and the "running and shooting" were all very good. But the level design and enemy design and difficulty level were a little off.
    I uninstalled it and have been playing Assault Cube for a few days. The only "single player" mode is against bots in an arena, but I'm liking it because it is pretty simple (pretty much just running and gunning) and it is not a "twitch" shooter - people actually move a little more like they do in real life, as compared to something like Quake. I get my butt kicked in both Assault Cube and Quake, but at least I get my butt kicked slower in Assault Cube.
    EDIT: I've been thinking about trying Marathon (Aleph One). http://aur.archlinux.org/packages.php?ID=6111 It's a complete FPS. I haven't tried it yet. It's old, but age isn't a problem for me. I still love and play Doom to death.
    Last edited by drcouzelis (2009-12-11 22:17:06)

  • First person perspective room

    What is the feasibility of creating a first person
    perspective room in flash/as? My company has a requirement to
    create a virtual branch (I work for a bank) and have a client go in
    and use the arrow keys to move around the room, approach a teller
    and interact with a 3d model with sequenced animation. I am so new
    at flash I dont know what is possible, but I have seen 3D worlds
    where you can walk around (albeit simplistic) with object
    collision. The only drawback was that the coding was complicated.
    Has anyone done this and or has any ideas as to where I
    should be looking to find out more on how to do this
    project?

    I'm doing something similar but I'm building the room/space
    in Cinema4D and using, ultimately, flv files. I would think you
    could film the simple sequences in the bank with a basic digital
    camera and then use a form of rotoscoping or just tracing keyframes
    of the video with vector lines.
    But, you'll have to create animations of the teller which
    isn't easy to do unless you do that sort of thing. Maybe buying
    pre-existing models would be easier to do.
    Sounds like it might be quite a bit to chew for a
    beginner!

  • Setting the first day of the week

    Hi,
    Is there any other place in Mac OS X where I could set system's first day of the week, except iCal? In iCal it's set to Sunday, but in OmniFocus mini calendars show Monday as the first day of the week, although even there in OmniFocus preferences I've set it to use Sunday as the first day of the week. Developer says that OmniFocus is using system's settings, but nowhere in my system (except iCal) I can find where I could set the first day of the week. I have set English as the default language and order of list sorting in the International settings. Any ideas or suggestions?

    Unless it is set with the Country in the International preferences, I don't think their tech support knows what they are talking about. However, if that is where it would be set, you should be able to override it with the custom settings, but you can't.
    I'd ask them to tell you where that gets set, or is stored. Ask them what system call is used to get that value. My guess is they won't be able to tell you.

  • How do i get all my data and info from my old iphone onto my new one without access to the original itunes that i set my first iphone up on? my partners itunes keeps telling me that its going to replace all my apps and data with his stuff

    how do i get all my data and info from my old iphone onto my new one without access to the original itunes that i set my first iphone up on? my partners itunes keeps telling me that its going to replace all my apps and data with his stuff

    ok so i have my own i tunes library - how do i get all my old apps onto my new library?

  • I can't be the first person to have thought about this but...would n't it be nice if instead of having to naviagte with your mouse to go back a page in Safari, wouldn't it make sense to just have a keyboard stroke to do that?

    I can't be the first person to have thought about this but...wouldn't it be nice if instead of having to naviagte with your mouse to go back a page in Safari, or any browser,  wouldn't it make sense to just have a keyboard stroke to do that? It comes to mind as I sit here with my hand bandaged in a splint after surgery.

    Try Command + [
    Allan

  • Setting the first page in a mobi file

    Hello,
    I am exporting from indesign cs5 to mobi through a plugin. I was wondering if it's possible to manually set the first page that the document opens to. I'd like it to be the cover or the TOC, but my kindle just skips all that and goes straight to the editor's note. I am using a manually created TOC in the indesign document, so that could be why my kindle is skipping it, but I'd like to change that "default" if at all possible. Thanks SO much for your help!

    If you want to use the Acrobat SDK, which is a tool for automating
    Acrobat, you need to buy and install Acrobat on each client.
    Adobe's PDF Library, which doesn't require Acrobat and has a different
    (negotiated) licensing model based on royalties might be a better fit.
    In either case, this would be written in C/C++.
    Aandi Inston

  • I bought iphone 5 with there box and accesaries by third hand now i dont now the icloud id which first person put it now the iphone 5 stuck on icloud activation page. it is not teaft

    i bought iphone 5 with there box and accessories by third hand now i dont now the icloud id which first person put it now the iphone 5 stuck on icloud activation page. it is not theft

    are you stupend or clown,because how and the word he is gonna find the first person when i am pretty sure he doesnt even keep in touch with the person who he purch in the first place...Nabeel that is a lot of suck and i know whats that i am stuck in the same situation to...and i celled apple sopurt and they asked for a lot information and when i sent to them they just said to me that they not able to help me with that...i have spake with to many people in apple and the funny part is that everone has diffrent answer..

  • Help with setting up a Personal Hotspot on iPhone 4

    I have been trying to set up a Personal Hotspot on my iPhone 4 updated to IOS7. I can connect to WiFi ok but not cellular data.

    Yes. They are trying to tell me it is an Apple problem to do with settings. However, I have established that other users have a similar problem and one suggestion is that the problem can be solved by using a Nano Sim with a carrier adaptor. I am checking this out. Thanks for your reply.

  • Help needed setting-up a Y-Cam on a WRT54GS

    Has anybody set up a Y-Cam Knight surveillance camera using a WRT54GS router. I have set one up on my network. All my PC’s see it ok, the problem is I should be able it remotely access it from anywhere in the World with no PC’s on as it has a built in server, but I can’t nor can anybody else that I give my ip address (not the network address) to. I (and others) can access it using my ip address when I have the PC on and I run a third party program WebCamXP 5. It sends out a “movement detected” warning  e-mail to me ok with no PC on, I have done all the setup as directed, static address, port forwarding ect .Has anybody got any ideas on the settings so I can remotely access it.

    In order to Access camera remotely you need to forward ports for your camera on the router . And also make sure that the wanip address on router should be public.

Maybe you are looking for