1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Basic Car

Discussion in 'HTML, Graphics & Programming' started by FredFlint, May 16, 2018.

  1. FredFlint

    Wise Guy

    Joined: Feb 1, 2006

    Posts: 1,845

    Hi, I was board so I coded a basic car:



    It's coded in c++ using OpenGL for graphics.
    Link to test App:here

    VS 2017 source code:here

    Added Xbox controller support for D-Pad, buttons and triggers, not done analog sticks yet.
    Added AABB collision detection, not done collision response yet.

    left,right,up,down= left,right,throttle, brake.
    W,A,S,D,Z,X = camera movement.
    N,M = Camera rotate.
    R,T = Wireframe,Solid.
    Q= shader on/off.
    C= console on/off.
    I,K,L,J=move light.
    F=show node box.
    V,B= cycle selected node.
    G= show calculated rotation points.
    1,2,3,4 = show/hide bounding volumes.
     
    Last edited: Jun 25, 2018
  2. AHarvey

    Sgarrista

    Joined: Mar 6, 2008

    Posts: 8,929

    Location: Stoke area

    now make it self-driving ;)

    Looks impressive. Wouldn't even know where to start with this!
     
  3. jsmoke

    Soldato

    Joined: Jun 17, 2012

    Posts: 5,854

    Source or fake.
     
  4. FredFlint

    Wise Guy

    Joined: Feb 1, 2006

    Posts: 1,845

    I would not know how to do AI driving but I am thinking of adding some obstacles and basic collision. The hardest part so far was the steering, making it go forward and backwards was easy but the steering took some work, ended up implementing Ackerman steering to make it look correct. It still has a few miner issues but overall it looks and drives OK.
     
  5. touch

    Capodecina

    Joined: Oct 28, 2006

    Posts: 10,530

    Location: Sufferlandria

    Very impressive. Are you controlling the movement (with arrow keys or something)? Or is it pre-set animation?


    I think it's fake. If you look closely at 0:27 you can see the model turns to wireframe - real cars dont do that!
     
  6. Mynight

    Soldato

    Joined: Jun 16, 2013

    Posts: 5,322

    That's pretty cool.

    Any chance you're sharing source I would love to see how that's achieved.
     
  7. FredFlint

    Wise Guy

    Joined: Feb 1, 2006

    Posts: 1,845

    I use the up/down for throttle/brake and left/right to turn. @0:27 I hit the wireframe key, I added it as it can help with debugging. I might upload the code at some point but its a bit of a mess as not used c++ in over 10 years and I used a lot of classes I did back when I first started coding in c++. It's a real nightmare to drive, like a remote control car. I added code to lock the camera at the back of the car but it looks bad(easier to drive through), need to play a car game to work out where to put the camera:)
     
  8. FredFlint

    Wise Guy

    Joined: Feb 1, 2006

    Posts: 1,845

    If anyone wants to give the app a try, I have added a link to the first post.
     
    Last edited: May 24, 2018
  9. D.P.

    Caporegime

    Joined: Oct 18, 2002

    Posts: 28,371

    When I was in my late teens/early 20s I did a lot of OpenGL gmae engine stuff. At thew time recreating Quake3 was popular (the ncie thing being the art assets were just in a zip file) and I had a pretty good replica, albeit a lot slower. I really like dopen world games so made some cool landscape engines.

    I loved working at a low level, making my own lighting models and light maps, collision detection, physics etc.
     
  10. FredFlint

    Wise Guy

    Joined: Feb 1, 2006

    Posts: 1,845

    Just updated the demo app: changed it so the wheels go straight when the left/right keys are released, makes driving easier.
    Also, some of the keys are:
    left,right,up,down= left,right,throttle, brake.
    W,A,S,D,Z,X = camera movement.
    N,M = Camera rotate.
    R,T = Wireframe,Solid.
    Q= shader on/off.
    C= console on/off.
    I,K,L,J=move light.
    F=show node box.
    V,B= cycle selected node.
    G= show calculated rotation points.

    mouse buttons also move camera but its a bit wrong, will fix at some point.
     
  11. FredFlint

    Wise Guy

    Joined: Feb 1, 2006

    Posts: 1,845

    I have added a link to the source code in the first post, use at your own risk and remember I don't use C++ much and this was just me experimenting so the code is not the best and not many comments. Have fun and if you try it please let me know how it goes, thanks.
     
    Last edited: Jun 25, 2018