New to game making

This is a discussion on New to game making within the Game Programming forums, part of the General Programming Boards category; K, the first one I got, but lets take these others a bit slower. Originally Posted by Bubba This is ...

  1. #31
    Registered User
    Join Date
    Mar 2008
    Posts
    65
    K, the first one I got, but lets take these others a bit slower.
    Quote Originally Posted by Bubba View Post
    This is a simple vector operation. You can do this several ways. One way is to raycast the bullet instead of having it become an actual object in the world. The raycast is the simple parametric form of a line or P(final) = P(origin) + shoot_vector * distance. Normally you could use the shoot vector to perform a ray intersection test with the bounding volume of your object. Once that passed you would then do a triangle intersection test on the mesh itself to see which ray the triangle hit. Once you computed that you would then compute the barycentric coordinates of the ray intersection within the triangle. From there you would then fire off some type of 'hit' message which would then deduct health, etc.
    The terms raycast and parametric mean nothing to me. Vectors I get, but how would I calculate the Shoot_Vector? Other than that, this also makes sense.

    Quote Originally Posted by Bubba View Post
    In an engine this is handled by the camera class. The player's gun is pointing down the look vector of the camera. To translate the gun to the correct world position you would have a vector in local space that represented the location of the gun relative to the local origin. Then you would multiply the inverse world transpose matrix of the object with the local translation matrix of the gun to move it to the correct location.
    Vectors agian? Okay, this is starting to come together! So how does my mouse affect the vector?
    The rest I can tackle after theese two.

  2. #32
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    The terms raycast and parametric mean nothing to me. Vectors I get, but how would I calculate the Shoot_Vector? Other than that, this also makes sense.
    A 2D raycast is:

    Code:
    float final_x = start_x + cosf(angle) * distance;
    float final_y = start_y + sinf(angle) * distance;
    A 3D raycast in vector form:

    Code:
    Vector3 final = start + unit_vector * distance;
    A unit vector is a vector that has range 0.0f to 1.0f in all three components. This is also known as a normalized vector. You could test final for collision however this is not all that accurate. Actually all you need to do is determine if the unit_vector intersects the bounding volume of the target. Remember that a vector stretches from infinity to infinity so the intersection math works just fine regardless of the magnitude of the vector. If you want to make the bullet 'fly' along the shoot vector you simply normalize the shoot vector and and then multiply it by a distance scalar. The distance traveled is good old distance = rate * time where rate is the speed of the bullet and time is the frame delta or the time it took to render the frame. Keep in mind if you want to 'fly' the bullet to the target you will have to do a completely different collision test to determine if the bullet could hit target X in time interval T. If the interval is infinite then you know the bullet did not hit the target.

    Vectors agian? Okay, this is starting to come together! So how does my mouse affect the vector?
    The rest I can tackle after theese two.
    One way to do it:
    Code:
    m_pCamera->Yaw(m_pMouse->GetX() * reduction_factor);
    m_pCamera->Pitch(m_pMouse->GetY() * reduction_factor);
    DirectInput will return mouse coordinates in relative by default so this works fine. If your particular mouse driver or API returns them in absolute you will have to derive the relative via a simple subtraction from the last known mouse x and y.


    There are other more sophisticated methods such as converting the mouse x,y to spherical coordinates or mapping them to a unit sphere and then adjusting the up, look, and right vectors accordingly.
    Last edited by VirtualAce; 04-17-2008 at 10:33 PM.

  3. #33
    Registered User
    Join Date
    Mar 2008
    Posts
    65
    Okay, I'll see where this gets me and get back to you.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 20q game problems
    By Nexus-ZERO in forum C Programming
    Replies: 24
    Last Post: 12-17-2008, 05:48 PM
  2. beach bar (sims type game)
    By DrKillPatient in forum Game Programming
    Replies: 1
    Last Post: 03-06-2006, 01:32 PM
  3. PC Game project requires c++ programmers
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 02-22-2006, 12:23 AM
  4. Game Engine Link Prob
    By swgh in forum Game Programming
    Replies: 2
    Last Post: 01-26-2006, 12:14 AM
  5. Lets Play Money Making Game
    By ggs in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 09-04-2001, 09:36 PM

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