XNA Creators Club Online
Page 1 of 2 (26 items) 1 2 Next >
Sort Posts: Previous Next

A Tale of 6 Cameras

Last post 6/8/2009 10:09 PM by DS9490. 25 replies.
  • 5/26/2007 9:14 PM

    A Tale of 6 Cameras

    Well I had a rush of blood last night and finally finished a sample that shows how to switch between a Fixed, Tracking, First Person and ThirdPerson Camera. It had been sitting on my HD for a few months now as I didn't know how to set up the 3D things correctly. Then suddenly last night some things became clear.



    The sample is based on the 3rd 3D Tutorial series and I originally thought it would make a good 4th Tutorial, but it seems the XNA team have something else planned for that.

    I hope I'm not speaking too soon by saying, I think I may be starting to understand this 3D mumbo jumbo :).

    Anyway here is the zip file that contains the C# projects/code as well as the Chrome ( Free Command Line compiler ) code and both executables incase you want to see if there are any differences between the 2 compilers.

    Instructions
    -------------
    Toggle Camera Modes = Tab or Left Shoulder Button
    Steer = Left & Right Arrow keys or Left Thumbstick
    Accelerate = Up Arrow key or Right Trigger
    Reset = A Button or Spacebar

    All feedback welcome on how this could be improved as I have a lot to learn.

    PS. as I don't have an Xbox, maybe someone could confirm that it works as advertised on there as well.


    There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
    -= Paulo Coelho =-
  • 5/27/2007 12:13 AM In reply to

    Re: A Tale of 4 Cameras

    Very nice. Only one thing to improve it... add in the spring based case camera from the new sample http://creators.xna.com/Headlines/developmentaspx/archive/2007/01/01/Chase-Camera-Sample.aspx and you will have pretty much all the types of camera in one sample.
    Playtest Kissy Poo - a game for 4 year olds on Xbox and windows
    The ZBuffer
    News and information for XNA
      Follow The Zman on twitter, Email me
        Please read the forum FAQs - Bug/Feature reporting
          Don't forget to mark good answers and good playtest feedback when you see it!!!
  • 5/27/2007 4:25 AM In reply to

    Re: A Tale of 4 Cameras

    I'm not sure what kind of feedback you want. For the cameras or like.. "the next thing to do"?

    For the camera part I'd like to see multiple fixed cameras and have the application switch between the cameras depending on in which one the ship is actually visible in.

    Then it might be a good idea to put up obstacles and see if you'd need adjust the cameras depending on the obstacles (mostly a problem with 3rd person cameras).

    Also the third person camera isn't working as I thought it'd do cause it's basically looking into the ground.

    Very nice sample though :)
  • 5/27/2007 6:26 AM In reply to

    Re: A Tale of 4 Cameras

    Nice work there, mate!

    Little offtopic here, but this post clearly shows that community can create quality samples, so adding ability "upload your sample" would be awesome if you ask me!

    Cheers
  • 5/27/2007 1:30 PM In reply to

    Re: A Tale of 4 Cameras

    Hi all,
      Firstly thanks all for your comments. It's always good to know that someone has found the time to look at your stuff, even though it may not be the most eye opening or ground breaking stuff out there.

    @ZMan : Yes I plan to add the spring system to ThirdPerson demo when I have a bit more time. Thanks for mentioning the sample on your blog. Though I noticed a slight typo... "4 kids" should be "4 kinds".

    @Kawe : The sort of feedback I'm looking for is if there is anything in my code that could be improved, be written more effeciently or elegantly. Or if it works or does not work on an XBox. I'm mainly an Object Pascal developer with only about a year of C# commercial experience, so anything that would improve my C# coding skills would be usefull and would also enhance my prospects of getting a C# job ;-).

    Your suggestion of multiple fixed cameras sounds quite interesting and I may look into including it. Is there an easy way to check if an object is within a certain field of view? I suppose I could always work out the distance to each camera and switch to the one that is closest. Is there a better way of implementing this? I also like the camera collision idea, but think it may be too complex for this sample. I really wanted to keep it as simple as possible so that others like me, who are new to 3D, don't get too over whelmed with information.

    @XNAProgrammer : I agree, a central samples repository would be very usefull for all the new XNA developers out there. Maybe have a separate section for community content, so that it is separate from the offical content. If Microsoft could spare a resource to moderate the uploads, that would avoid duplicates and keep the quality of samples at a particular level.
    Would also look good on the CV to have had a sample accepted :).


    There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
    -= Paulo Coelho =-
  • 5/27/2007 3:46 PM In reply to

    Re: A Tale of 4 Cameras

    Oh, right. I wasn't sure about what kind of feedback you wanted. But for the purpose of a sample I think what ZMan said is enough.

    My suggestions are just suggestions. I'm just like you, learning things. So I just made up things that I thought would be nice and that were missing. I honestly don't know how to do those things effciently.

    About switching between fixed cameras.. I think most games solve it by just putting up a big box that says "if you are here, use this camera.. otherwise use this one". Nothing too fancy.

    But yea, keep the sample simple and then make another one with what I suggested :) That'd be reall nice.
  • 5/27/2007 8:52 PM In reply to

    Re: A Tale of 4 Cameras

    Damn it! Someone beat me to it :)

    Nice work BTW.

    I've actually been working on releasing a similar demo for my site. My demo implements first person, spectator, flight sim, and orbit/third person camera types and I also support switching between the types. Mine differs in that I've used quaternions throughout.

    I'll post a link when it's done. Stay tuned!
  • 5/28/2007 6:47 AM In reply to

    Re: A Tale of 4 Cameras

    Hi Happy,
      Sounds like your demo is more advanced than mine. I have not even begun to get my head around quaternions. The only thing I know is that it's supposed to stop this evil guy called Gimbal Lock. So much to learn, so little time.
    There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
    -= Paulo Coelho =-
  • 5/28/2007 6:51 AM In reply to

    Re: A Tale of 4 Cameras

    Kawe:

    Also the third person camera isn't working as I thought it'd do cause it's basically looking into the ground.


    I forgot to mention that if you change the ThirdPerson declaration to

    Vector3 cameraThirdPersonPosition = new Vector3( 0.0f, 1550.0f, 5000.0f );

    Then it has a better 3rd Person look.
    There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
    -= Paulo Coelho =-
  • 5/31/2007 8:17 PM In reply to

    Re: A Tale of 4 Cameras

    I've released my quaternion camera game component. See here.
  • 6/11/2007 5:49 AM In reply to

    Re: A Tale of 4 Cameras

    I've not had the time to look at adding the spring system to the cameras, but I just added 2 top-down camera views to the sample, in light of the recent Tutorial 4 ( Make a game in 60 minutes ). The 2 cameras are Top Down Fixed and Top Down Centered. Hopefully the names are self explanitory.
    There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
    -= Paulo Coelho =-
  • 6/19/2007 2:40 AM In reply to

    Re: A Tale of 4 Cameras

    Chrome code does indeed work on the Xbox 360. One of the guys from the UK XNA forum tested it out for me. The thread in question is...
    http://xna-uk.net/forums/t/285.aspx
    And a screen shot of it will be available soon.

    I actually think it may be possible to get it working on the XBox without the C# wrapper. That will be my next test.
    There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
    -= Paulo Coelho =-
  • 6/22/2007 10:40 AM In reply to

    Re: A Tale of 4 Cameras

    Hey,

    Thanks for the work.  This is a great tutorial, and I've actually started buliding my game with your code as a base.  Things have changed over the days, and things are hardly noticeable anymore, but this is a great starting point for new developers.

    What I'm trying to do is animate camera transitions between the various cameras, and I'm having a little bit of trouble wrapping my head around this.  For instance, how would one animate between the 3rd person camera and 1st person camera.  My first thought was to simply find the difference between the position vectors, and then "travel" a certain amount (picked by the developer) each frame/update call.  However, since the ship would potentially continue to move throughout this process, I have trouble getting to the correct location.  Also, I seem to be having some rounding problems - if I get close to the 1st person position, I never get exactly there.  I'm not quite sure how to make it so that I can hit the position coordinates exactly.

    If you know how to go about doing this, that'd be fantastic.  If not, I'll make a topic about it for searching purposes of new users.

    Thanks.
  • 6/23/2007 5:31 AM In reply to

    Re: A Tale of 4 Cameras

    Hi Geoff,
      Great to see that someone has found this code usefull.

    For switching the camera from one position to another may I suggest you look at the "How to: Script the Camera to Follow a Curve" either in the Help file or online. I believe this will give you the most flexible way of transitioning from one perspective to another and you can specify how long you want it to take and it shows how to set up your camera to follow a curve while looking in a particular direction.

    I've recently written my own version of this "follow a curve" example so that I can use it for scripting Waypoints for patrolling enemies in my 2D game and the tests so far look quite good. I hope this helps.
    There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
    -= Paulo Coelho =-
  • 6/29/2007 7:13 AM In reply to

    Re: A Tale of 4 Cameras

    Just a quick update, I've finally added the spring system from the ChaseCamera example to this tutorial's 3rd person Camera.
    The code has also been refactored slightly to make things neater and I think a little easier to understand.

    Btw, "A" toggles the spring on and off, just like in the ChaseCamera sample.
    There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
    -= Paulo Coelho =-
  • 6/29/2007 7:10 PM In reply to

    Re: A Tale of 4 Cameras

    Somersault:
    Chrome code does indeed work on the Xbox 360. One of the guys from the UK XNA forum tested it out for me.

    Yes, Indeed I did. Oh, @Somersault btw the ground.x model is missing from the project content\models. Anyone wanting to run on Xbox360 will need to add it or wait for a refresh.

    Ant.
  • 7/2/2007 5:59 AM In reply to

    Re: A Tale of 4 Cameras

    Hi Antony,
      I just looked at the latest zip file, which now includes the spring camera, and "Ground.x" is there. Could it be be a case sensitive issue on the XBox 360? I also had someone else here in the office test out the pure Chrome version, no C# wrapper, on their Xbox 360 and that worked fine as well last night.
    There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
    -= Paulo Coelho =-
  • 7/2/2007 7:14 AM In reply to

    Re: A Tale of 4 Cameras

    I have three suggestions:

    When the left trigger or the down arrow key is pressed, move the ship (for now) backwards for driving/racing games.

    When the right stick is moved up or down, move the ship up and down like an airplane flying up from the ground or flying down to the ground.

    Add camera mode for driving/racing games and flying games with the camera attached to 3D model of vehicle or aircraft. This camera mode is similar to first person camera mode.

  • 7/2/2007 8:34 AM In reply to

    Re: A Tale of 4 Cameras

    @Somersault I can only say that the version I downloaded using the XBox360 project had the ground.x missing and I added it in order for it to run. I will download the latest tonight. I'll let you know the outcome.
    Ant.
  • 7/2/2007 10:56 AM In reply to

    Re: A Tale of 4 Cameras

    @Antony : You were right. I just realised that I never added the ground resource to the Xbox C# project. It has been added now and the new zip should now work on both Win32 and 360. Let me know if it does not.
    There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
    -= Paulo Coelho =-
  • 10/16/2007 12:56 PM In reply to

    Re: A Tale of 4 Cameras

    Hi there,

    I just ran into this thread while fiddling with some camera stuff.
    Your camera tutorial sounds like just what it need - but the link to file is no longer working.

    Would it be possible for someone to repost this?

    Cheers,
    Ronzan

  • 10/19/2007 4:57 PM In reply to

    Re: A Tale of 4 Cameras

    Hi Ronzan,
      I've updated the link above to point to the correct location. The zip file contains both C# and Chrome code. I hope you find it usefull.
    There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
    -= Paulo Coelho =-
  • 10/28/2007 1:24 AM In reply to

    Re: A Tale of 4 Cameras

    Thanks a bunch Somersault, I've been trying to wrap my head around 3D matrices and cameras for a some time now. This is a great help, appreciated.

    /Ronzan

  • 7/23/2008 3:27 PM In reply to

    Re: A Tale of 4 Cameras

    I would like to stay that this sample is also really helpful.


  • 8/8/2008 1:46 PM In reply to

    Re: A Tale of 4 Cameras

    Thanks for letting me know. It is always nice to know that someone has found your code useful and more so, since it has been a year since I posted it.
    There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
    -= Paulo Coelho =-
Page 1 of 2 (26 items) 1 2 Next > Previous Next