Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Yet another Freeflight program, but wait...

Author
Message
Twilight zone
20
Years of Service
User Offline
Joined: 25th Dec 2003
Location: San Angelo, Texas
Posted: 26th Dec 2003 03:23
I originally wrote this little flight sim a while back using DB. I was having trouble with rotations and gimbal lock, so came up with this workaround. I know that there are probably easier ways of doing this but this works for me. If any of you find this usefull I could port it to a DLL, but the best solution is that similiar methods of rotation get added to the DarkBasic.

Features:
Basic Flight simulator (no physics)
Basic flight simulation AI (waypoint following and stalking)
Includes arbitruary axis rotations by manipulating mesh data via
arbAxisRotation(x,y,x,angle) command.

Uses no outside media (but could easily do so)
Problems:
Texturing objects is basic at best.
Speed concerns of its math intensive manipulation of the meshes, basically taking away from the 3D acceleration done by video card.
Programming:
Twilightzone: Everything but quaternion and matrix functions
Various Sources(books and web sites): quaternion and matrix functions
Was written originally for DB has been adapted for DBPro ver 5.2

Merry Christmas
Lewiji
20
Years of Service
User Offline
Joined: 25th Dec 2003
Location:
Posted: 26th Dec 2003 14:10
Very nice, but no collision, I'll try and fix some collision and repost (if I can be bothered)

<intelligent, witty comment here>
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 26th Dec 2003 18:23
thats nice, the planes shake when they get near to waypoints though


GO TO THE ETERNAL DESTINY FORUMS!!! http://forums.eternaldestinyonline.com
Do it now!!!
Twilight zone
20
Years of Service
User Offline
Joined: 25th Dec 2003
Location: San Angelo, Texas
Posted: 26th Dec 2003 20:19
Im sorry for the confusion. This was just an experiment in building a simple flight simulator, so no collision was added. As far as the waypoint fluttering it is because of the digital nature of the controls for player and AI. I guess I didn't want the AI to have an advantage over the player, but I realize that was kinda dumb of me.
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 27th Dec 2003 22:00
it would be really good if you made a game of this!


GO TO THE ETERNAL DESTINY FORUMS!!! http://forums.eternaldestinyonline.com
Do it now!!!
Twilight zone
20
Years of Service
User Offline
Joined: 25th Dec 2003
Location: San Angelo, Texas
Posted: 28th Dec 2003 00:21
Thanks for the encouragement, I started out a couple years ago, wanting to write a remake of 'Carrier Command' that came out in 1988. Still alot of fun to play, even today. But I was having some severe difficulties with the flight sim part. The Euler method of rotating objects just simply would not cut it, due to gimbal lock. So I wrote this little experiment to test quaternion method of rotating objects and apply it to a flight sim. The project was sheleved shortly after that, due to lack of interest.

However the point of this post was to give you guys an alternative to using Euler rotations. I've read several posts descibing the problems I was originally having, but I saw no answers that really had a working solution with an example. One particular post that comes to mind is the one titled "DarkBASIC Pro / Tokamak and ODE Physics Engines - almost working with DBPro". My solution is no where near ideal, but I believe it could be easily adapted to the Tokamak physics engine. And could eventually be adapted for better physics in racing, FPS, and "real" flight simulation.

I really wish the developers would add an alternative to Euler and give easier access to the model data.

So as far as this game goes, it will probably canaballized for other projects and then off to the recycling bin. If you guys want to use it be my guest.
ReElectro
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location:
Posted: 28th Dec 2003 08:03
Would it be possible to acually convert the code to make it work in DB V1.1?
Twilight zone
20
Years of Service
User Offline
Joined: 25th Dec 2003
Location: San Angelo, Texas
Posted: 28th Dec 2003 15:28
I don't remember which version of DarkBasic implemented access to mesh data which this program relies on. This program started life in DB classic. In fact I have an older version written in Db classic is still on my HD. The major differences are in the format that the mesh data is stored and there also appears to be in a bug in the command 'make mesh from object'. If you don't have this command my program will never work.

I've been tinkering with a less intrusive method of rotation by taking a Quaternion and converting it to Euler. Its only semi functional. If I ever get it to work properly I'll post it.

There maybe other approaches to the rotation problem. Possibly attaching your object as limb to a dummy object. Rotating your dummy object on one axis, and then rotating limb on the other two axis. I have not fully explored this solution, so It may work well or not at all. And also you still have to use meshes when you do this.
Twilight zone
20
Years of Service
User Offline
Joined: 25th Dec 2003
Location: San Angelo, Texas
Posted: 30th Dec 2003 03:09
Sorry to bring it up again, but not being satisfied with the AI having digital controls as the player. I gave them Analog contol, which allow smoother flight between waypoints. And the stalker plane seems to be more accurate.

Sorry still no collisions, but wouldn't the real challenge be in collision avoidance for the AI. Maybe my next upload.

Questions and/or Comments?
Lewiji
20
Years of Service
User Offline
Joined: 25th Dec 2003
Location:
Posted: 30th Dec 2003 22:12 Edited at: 30th Dec 2003 22:15
"#100044: Cannot find structure 'control_plane:plane#' in local declaration at line 210" It still runs, but the screen flickers as you climb and the other planes seem to fly way out of the level in random directions.

<intelligent, witty comment here>
Twilight zone
20
Years of Service
User Offline
Joined: 25th Dec 2003
Location: San Angelo, Texas
Posted: 30th Dec 2003 23:50
My apologies, apparently the code slightly corrupted during the copy and paste.


Try this.

Happy New Year!

Login to post a reply

Server time is: 2024-11-23 23:16:21
Your offset time is: 2024-11-23 23:16:21