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.

Dark GDK / Flight sim help

Author
Message
Ace_Lightning
13
Years of Service
User Offline
Joined: 17th Mar 2011
Location:
Posted: 17th Mar 2011 20:24
Hi I am trying to develop a 3D flight sim in dark GDK for my uni module so far I have a plane a skybox a terrain and a sphere (placeholder for an asteroid) falling down. I'm trying to get collision detection on the terrain so that when either the asteroid or the player collide with the terrain they get destroyed. I have used the dbObjectCollision command on my player and asteroid and it works fine but when I use it on the terrain the asteroid vanishes.

Thanks.
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 17th Mar 2011 23:18
I use Sparkys collision at the moment which allows you to setup levels or terrain as a complex object for collision detection. It will also give you the normal values from your terrain for slopes. Always worth a look.

Warning! May contain Nuts!
DeadTomGC
13
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 17th Mar 2011 23:20
For the terrain you will need to call this command before you enter the main loop:
dbSetObjectCollisionToPolygons ( int iObject )

Ace_Lightning
13
Years of Service
User Offline
Joined: 17th Mar 2011
Location:
Posted: 18th Mar 2011 13:35
Thanks for the help guys the dbSetObjectCollisionToPolygons command helped. I had some problems with sparkys collision which is why I try and avoid using it. Another thing I am trying to work on is spawning multiple asteroids using the same code from my asteroid class. I want a new asteroid to spawn every 5 seconds until they reach a limit of 15 and then a new asteroid spawns after a previous one is destroyed. Below is the code from my Asteroid class if it helps.



thanks
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 18th Mar 2011 17:13
Quote: "I had some problems with sparkys collision which is why I try and avoid using it."


You should never avoid sparkys, quite the opposite, you should run towards it every chance you get.

If what you have is working for you though then stick with it, but for any serious game you should use sparkys collision.


I would suggest you have an Astroid class, like you do, but it should handle one astroid only. Then create a class which takes care of creating/deleting asteroids. This new class would handle spawn times/limits.

Good luck with this project.

Ace_Lightning
13
Years of Service
User Offline
Joined: 17th Mar 2011
Location:
Posted: 18th Mar 2011 17:23
Quote: "You should never avoid sparkys, quite the opposite, you should run towards it every chance you get."


I have heard its pretty good but I don't have the first clue about how to use it which is why I try to avoid it because deadlines are coming up so I want to finish my assignment ASAP.

About the seperate class that creates the asteroids how would I go about making that would I have to use dbMakeObjectSphere() multiple times like I have done already or would I have to handle it another way and how to I implement spawn times and limits.

Sorry I'm a total noob at this.

P.S thanks for getting back to me
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 18th Mar 2011 20:54 Edited at: 18th Mar 2011 22:06
Do not try to run this code, I wrote it here just to demonstrate what it might look like, it is also incomplete.

If there is too much in there you don't understand then you are best doing it the way you were doing before.

If you go this route and have any problems just ask. You would need to look at how they are destroyed, this also could be in the asteroid handler class, or a collision class of some sort.



Ace_Lightning
13
Years of Service
User Offline
Joined: 17th Mar 2011
Location:
Posted: 19th Mar 2011 13:21
Hi I'm running into some problems because I'm not sure what is going on in the asteroid factory update method. If you could give me a hand in explaining what the method is doing I might be able to implement it into my code.

thanks
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 19th Mar 2011 14:29
I will presume you mean these two lines, let me know if its something else:


You will need to know a little about pointers and containers.

Pointers can be very confusing if you are new to them, perhaps a solution without pointers would be better for you?

When using classes it is usual for many classes to have access to the same objects, this is why we hold a pointer to the object and not the object itself. If we have more than one object we can keep all our pointers in a container, a container is just like an array but with lots more functionality.

You could keep your Asteroids in an array, if this sounds better then just ignore the vector container and the pointers and try an array.

One of the hardest parts of helping out here is that there is many solutions to any given problem, I would say the solution I explore above is pretty typical once you have a good understanding of C++, but it might not be right for you at this time.

Ace_Lightning
13
Years of Service
User Offline
Joined: 17th Mar 2011
Location:
Posted: 20th Mar 2011 14:12
Thanks for that I'l do a bit of research on arrays but I would like to learn about pointers do you know the best place to learn.
Ace_Lightning
13
Years of Service
User Offline
Joined: 17th Mar 2011
Location:
Posted: 22nd Mar 2011 15:54
Sorry for the late reply but I've run into some problems while trying to implement the code. Heres my Asteroid class;


Heres the AsteroidFactory class;
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 22nd Mar 2011 17:11
These should not be global:

They should be members of the asteroid factory class.

I would forget collision for now as it may be complicating the matter. You just want a system that creates asteroids for you at given intervals for a given limit of asteroids.

Since the asteroid factory class depends on the asteroid class it is important that you test the asteroid class and get it working on its own.

Luckily its a pretty simple class right now so should be easy to test. Forget the asteroid factory class and test the asteroid class.

Could look something like this:

Call update() on them all in your loop and be sure everything is working properly.

You could try putting dbDeleteObject(ID) in the destructor then doing the following:

Should also delete the sphere.

Login to post a reply

Server time is: 2024-06-27 21:56:04
Your offset time is: 2024-06-27 21:56:04