Basic Car

Soldato
Joined
1 Feb 2006
Posts
3,622
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:
now make it self-driving ;)

Looks impressive. Wouldn't even know where to start with this!
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.
 
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!
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:)
 
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.
 
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.
 
That's pretty cool.

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

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:
Back
Top Bottom