Thread: Hovercraft program

  1. #31

    Join Date
    May 2005
    Posts
    1,042
    Hit the 'T' key before you fall off the cliff!! lol

    The t key kills your momentum.

    'R' kills the momentum of the dummy hovercraft.

    Well, I'm glad that it worked for a bunch of people. I have *no* clue why its saying that your radeon 9800 doesn't have the proper OpenGL extensions...the *only* extensions I use currently are for the multitexturing. Maybe it's too old? Gah...I used to be using an extension to count the number of pixels written to the depth buffer when rendering, for occlusion tests, but I took that out ages ago.

    Fugaz.

    Thanks for the feedback dudes.

    EDIT:
    I just wanted to re-iterate what the controls are!!!!


    Up Arrow = Forward
    Down Arrow = Reverse

    (rotates in place, unless also hitting forward/backward)
    Right Arrow = Rotate Right
    Left Arrow = Rotate Left

    'A' = Strafe left
    'D' = Strafe right

    'T' = Kill your momentum
    'R' = Kill dummy's momentum

    Last edited by BobMcGee123; 12-30-2006 at 04:04 PM.
    I'm not immature, I'm refined in the opposite direction.

  2. #32
    Registered User IdioticCreation's Avatar
    Join Date
    Nov 2006
    Location
    Lurking about
    Posts
    229
    Hmm, I tried to re download it, but it still didn't work. 1gb ram, 2.7 ghz, ATI x700

    It said the error was caused by debug assertion. Just out of curiosity, what is that?

  3. #33

    Join Date
    May 2005
    Posts
    1,042
    The debug assertion that you speak of is just a hook put in there by the programmer to check the memory after various operations to make sure that nothing fugs up. It's a debugging tool (the executable was built under debug mode in vc6).

    If you include crt.h and call crtcheckmemory() after setting the right conditions then that initiates a macro which does a whole bunch of (expensive) system calls to check to see if the memory has been fuxed. I honestly do not know what is causing it, and I am sorry that you cannot run my program. Trust me, you arent' missing much.
    I'm not immature, I'm refined in the opposite direction.

  4. #34
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Sorry, Bob I didn't read the thread enough. Just downloaded it and it works fine.

    Some key issues/suggestions:

    • Screen flickers. My eye is catching the refresh rate which probably means you are in the 60hz range or you are using an off the wall refresh rate. Might I suggest using the default desktop refresh rate since that is what most games do?
    • The skybox cube looks great and no seams which is cool. I have a program which will enable you to create six textures from one flat one...and it will auto-distort the images so you don't have to mess with it. So you can make any image your skybox with no seams.
    • Third person camera. I know you said you don't want to do it but it is not much more code. Just test the camera variable and if it's third person simply translate out from the object first and then render as normal.


    Core render function
    Code:
    void CObjectMgr::Render()
    {
      
      CGameObject *pObject=m_vObjects[m_dwCameraObject];
      
      
      D3DXMatrixIdentity(&pObject->m_matWorld);
      
      D3DXMATRIX matView;
      D3DXMATRIX matInvView;
      
      int iViewMode=pObject->m_spMyCamera->GetViewMode();
      
      
      if (iViewMode==COCKPIT || iViewMode==CHASE)
      {
        pObject->m_bInFlyBy=false;
        m_spDevice->GetTransform(D3DTS_VIEW,&matView);
        D3DXMatrixInverse(&matInvView,NULL,&matView);
        
        
        if (iViewMode==COCKPIT)
        {
          D3DXMATRIX matTrans;
          D3DXMatrixTranslation(&matTrans,0.0f,-2.0f,0.0f);
          pObject->m_matWorld=matTrans*matInvView;
        }
        
        if (iViewMode==CHASE)
        {
          D3DXMATRIX matTrans;
          D3DXMatrixTranslation(&matTrans,0.0f,-7.0f,25.0f);
          pObject->m_matWorld=matTrans*matInvView;
        }
        
      
      }
    
       
      //Third person camera or flyby camera
      if (iViewMode==OBJECT || iViewMode==FLYBY)
      {
          
          
        D3DXMATRIX matRot;    
        pObject->m_pOrient->GetViewMatrix(&matRot);
        D3DXVECTOR3 vecPos;
        pObject->m_pOrient->GetPosition(&vecPos);
            
        D3DXMATRIX matTrans;
        D3DXMatrixTranslation(&matTrans,vecPos.x,
                                        vecPos.y,
                                        vecPos.z);
        
        pObject->m_matWorld=matRot*matTrans;
        
      }
        
    
      
      //If we are in FLYBY we also need a new matrix
      //Compute new matrix and offset camera randomly from ship velocity vector for flyby effect
      if (iViewMode==FLYBY)
      {
        if (pObject->m_bInFlyBy==false)
        {
          pObject->m_bInFlyBy=true;
          
          D3DXVECTOR3 vecCamPos,vecRight,vecLook,vecUp;
          vecCamPos=pObject->m_pOrient->GetPosition();
                
          //Translate along right vector just a bit
          float m_fX=0.0f,m_fY=0.0f;
          
          
          vecRight=pObject->m_pOrient->GetRight();
          vecUp=pObject->m_pOrient->GetUp();
          int iNum=rand()%50;
          
          if (iNum<25)
          {
            vecCamPos+=vecRight*14.0f;
          } else vecCamPos+=(-vecRight*14.0f);
          
          iNum=rand()%50;
          
          if (iNum<25)
          {
            vecCamPos+=vecUp*7.0f;
          } else vecCamPos+=(-vecUp*7.0f);
          
          
          //Translate camera ahead of the ship along it's look vector
          vecLook=pObject->m_pOrient->GetLook();
          
          //If object is not moving, translate away a bit so camera is not inside of object
          if (pObject->m_fSpeed==0.0f)
          {
            vecCamPos+=vecLook*(10.0f);
          } else vecCamPos+=vecLook*(pObject->m_fSpeed*4.0f);
                
          pObject->m_spMyCamera->SetPosition(&vecCamPos);
          
        }
       }  
    }
    All you need is the OBJECT code section for third person camera. Don't ask me to make the model though cuz I suck.

    I like the hovercraft app Bob and the physics are very cool. Hope to see you do more with it. I'm sorta burn out on my app right now so I know how it gets.

    And how are you skinning the jeep with that texture? I need to texture my models but am having lots of troubles.
    Last edited by VirtualAce; 12-31-2006 at 04:37 AM.

  5. #35

    Join Date
    May 2005
    Posts
    1,042
    Sorry it took me so long to reply.

    The texturing is simply done with the modeling program, you can adjust the coordinates to get what you want, but there's also a generic 'fit' function which wraps the texture around the defined surface. Ultimately, it's the program that is generating texture coordinates, not me

    I haven't addressed the flickering problem yet. I noticed it too. I will follow up on your suggestions.

    I made a '3rd person' camera, although this was just a matter of changing a couple of variables. It follows directly behind the hovercraft. I included a screenshot, and uploaded another exe with the change.

    Here is a link to the new exe:
    ihatenature.thejefffiles.com/3PHovertank.exe



    I am still trying to decide what, exactly I want to do with the software, and the knowledge I've attained while writing it. The biggest problem isn't a matter of learning how to implement something, it's deciding where I should focus my efforts. I could easily make a simple game, add some graphics effects and start making a gaming portfolio...but I'm not really interested in game programming anymore. I like the problem solving and the thought challenges, but little else about gaming (the only games I play right now are starcraft and rise of nations). I know this sounds horrible, but I'm also just concerned about making $$$. I actually think that one of these days I'll end up in a design type job for some naval shipyard doing computer work that is about half as challenging but pays an infinite amount more than game programming.
    Last edited by BobMcGee123; 01-05-2007 at 05:15 PM.
    I'm not immature, I'm refined in the opposite direction.

  6. #36
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Oh my god hurry up with that recording
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM