Formulas, resources for DirectX?

This is a discussion on Formulas, resources for DirectX? within the Game Programming forums, part of the General Programming Boards category; Well, I've successfully gone through some tutorials on direct X, after going over some math with a friend that knows ...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    16

    Question Formulas, resources for DirectX?

    Well, I've successfully gone through some tutorials on direct X, after going over some math with a friend that knows trig, and I dont. I've learned some key concepts and opened a door to what I feel will be a enjoyable learning experence. In both math and programming. I of course have so much more to learn, and go over before I can get this memorized in my head. Anyways to the point, I was wondering if there is any resources that teach adding features like moving a object with arrow keys. Making a chase-camera, controlling the camera with the mouse or/and keys FPS style. Gravity, effects, and just learning some good concepts to help get the skills to build a simple crappy fps engine with no effects but hte basics :P If anyone could give me some tips on getting into this more that would be great.. ... wow I typed a lot.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Well go to www.amazon.com and get some books. For good suggestions of books go to www.gamedev.net and look at the books section.

    BTW AFAIK there is no such thing as a simple FPS engine. You will encounter many challenging problems to tackle while building any 3D engine. It's not hard, but an understanding of the concepts is key.

    I will address a few of the 'simple' issues you addressed in your post.

    I was wondering if there is any resources that teach adding features like moving a object with arrow keys.
    These are two separate ideas. Direct3D is just that - 3D. DirectX however is the whole enchilada - complete with input, sound, multi-play, etc. For moving an object in Direct3D you need to understand translation. But given you have a model this will get the job done in Direct3D.

    Code:
    bool Object::Render(float fTimeDelta)
    {
      D3DXMATRIX Translation;
      D3DXMATRIX Rotation;
      D3DXMATIRX Scaling;
      D3DXMATRIX World;
    
      D3DXMatrixTranslation(&Translation,m_pPosition.x,m_pPosition.y,m_pPosition.z);
      D3DXMatrixRotationYawPitchRoll(&Rotation,m_pRotation.x,m_pRotation.y,m_pRotation.z);
      D3DXMatrixScaling(&Scaling,m_pScale.x,m_pScale.y,m_pScale.z);
    
      World=Scaling*Translation*Rotation;
    
      if (m_pDevice)
      {
        m_pDevice->SetTransform(D3DTS_WORLD,&World);
      } else return false;
      //
      //Render your object here 
      //
    
      return true;
    }
    I really cannot show you the DirectInput code because you need to set it up correctly and diving into that would probably confuse you. I do have a framework up and running but unless you are familiar with DirectX it will confuse you. Slow down a bit.

    Making a chase-camera, controlling the camera with the mouse or/and keys FPS style. Gravity, effects, .....
    A chase camera is a camera that has been translated to be behind the actual 'player' or 'object' the camera normally represents. You must use a flag to tell your renderer to actually render the 3D object so that you are effectively looking at it from behind it. But you must also cause the camera to move with the object using smooth interpolations from one rotation to the next - this most likely will require the use of quaternions since it is nearly impossible to smoothly interpolate using euler angles.

    Gravity falls under the realm of physics programming and there are several books out there on this topic. I could not even begin to touch the subject here.

    Effects fall into the billboarding category. Essentially you render a an alpha-blended quadrilateral that always faces the camera and you change the texture over time to produce animation. The alpha blending allows you to blend in smoke and other effects and you must also disable the z buffer so that Direct3D won't think the effect is opaque. This can be done via IDirect3DSprite or it can be done using point sprites, which I don't recommend.

    I don't want to discourage you but trust me you are going way too fast. Buy some books on how to get Direct3D up and running and then dive into each area as your skills progress.
    None of the topics you have mentioned are really that basic or that simple. An engine is a complex beast.

    If you need help, show some code here, and I'll gladly assist you in any way I can. What I cannot do is explain all of DirectX or Direct3D or 3D mathematics here.


    Get some books.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    16
    Ok, I get the message. Its all about manuplating the world to view what you want viewed. I would like to see your frame work. I do have a small framework set up and I do have a book on the beginning to DirectX which Im trying to memorize some of the handlers and techniques in the book. I have been successful in setting up a cube, which the book taught me how to do. As well as the camera, and Direct Input. Im going to try to make a simple paddle game, with 3d blocks, a 3d ball, and a 3d paddle with no camera movement. Just a simple collision code and life, score, etc.

    Since I already know how to do this in 2d, I think Ill try to tackle it in 3d as well. I was having a problem with this code though:
    Code:
                sprite_handler->Begin(D3DXSPRITE_ALPHABLEND);
    
    			D3DXVECTOR3 position((float)welcome_txt.x, (float)welcome_txt.y, 0);
    
                sprite_handler->Draw(
    				    welcome_txt_image,
    					NULL,
    					NULL,
    					&position,
    					D3DCOLOR_XRGB(255,255,255));
    I keep getting these errors :
    Code:
    error C2065: 'D3DXSPRITE_ALPHABLEND' : undeclared identifier
    error C2660: 'Draw' : function does not take 5 parameters

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Make sure your installed DirectX version matches that of your SDK. Make sure you are including d3dx9.h as well.

    According to my refs, draw does take 5 parameters and D3DXSPRITE_ALPHABLEND is a valid identifier.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    16
    Ok , well I did all of that, and I still have the problem. Everything is in correct order. Im using Visual C++ 6.0... just so you know. I was wondering if I could contact you by messenger? Since I do have a couple of questions. Very strange error...

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Make sure you have downloaded BASETSD.h - it's stickied at the top of this forum's main page. You must have that as well.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Resources
    By abraham2119 in forum C Programming
    Replies: 5
    Last Post: 04-20-2009, 07:29 PM
  2. measuring system resources used by a function
    By Aran in forum C Programming
    Replies: 1
    Last Post: 03-13-2006, 04:35 PM
  3. Storing resources into a single file
    By LuckY in forum Game Programming
    Replies: 20
    Last Post: 08-14-2004, 11:28 PM
  4. "Patenting" math formulas or something like that
    By deltabird in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 02-26-2003, 03:47 AM
  5. Adding resources
    By nima_ranjbar in forum Windows Programming
    Replies: 0
    Last Post: 04-14-2002, 11:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21