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.

DarkBASIC Discussion / 3D collision question

Author
Message
HenryTj
20
Years of Service
User Offline
Joined: 2nd Nov 2005
Location:
Posted: 8th Jul 2006 05:31
The game is a relatively simple space flicght simulation demo. The players space craft can fly amoungst several irregularrly shaped tumbling asteroids. The game is 3-d but all the action is limited to 2d (except for the tumbling of the asteroids.) Working pretty good so far. (thanks to everyone on the help with my previous posts.)

I am doing polygon collision detection. I am using "Object Hit" (BTW, what is the difference between Object Hit and Object Collision commands?) I seem to be detecting collision okay. (Next I have to work out rebounding off the asteroid.)

Anyway, my question is this. AT first I have been turning off collisions for asteroid objects that are not on the screen. Do I need to do this at all? Can I turn on collision for all objects and leave it on? If Object Hit is checking for overlapping polygons for only the two objects in the parameter list, does it matter at all of off screen objects still have the collision turned on?

(THis is more of desire to understand how this works, than to fix a problem.)

Thanks again,
Henry
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 8th Jul 2006 13:22 Edited at: 8th Jul 2006 13:24
object hit() returns a 1 only 1 loop. (So doesn't keep returning a 1 if the 2 objects stay overlapped)
object collision() keeps returning a one if they are overlapping.

To answer on your second question:
You can turn this on/off as you like, that shouldn't make much difference, but it's the detection that is slow. So it would matter if you only check collision with the asteroids that are on the screen.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
HenryTj
20
Years of Service
User Offline
Joined: 2nd Nov 2005
Location:
Posted: 8th Jul 2006 13:58
Thanks again Sven. The difference between the hit and collision commands is the type of good information that should be in the documentation.

Okay, on part two. That is what I had hoped that I could just turn on collision for everything and just leave it on. Then just check for collisions on what is on screen. But that has given me another worry. If I am checking for the objects to be on screen every loop, that could degrade the performance if the number of objects goes up. So I should check if objects are onscreen only if they are close enough, or put the objects into an array and loop the array one step each loop of the game. In that way only one object (instead of many) are checked to be on screen each game loop. Right now I assume that I am having the game engine do too many things for me.

BTW, I am having some problems with the collision detection. Surprisingly it seems to be mostly if the objects collide slowly with the first object being under (screen wise), or to the left. I read on another thread where someone found they get different results depending on the order the objects are listed in the collision checking command. Maybe I need to check both ways.

Henry
NeX the Fairly Fast Ferret
21
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 8th Jul 2006 14:26
You could use distance formulas.

<OMG></OMG>
NeX, you cant be serious - CattleRustler.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 8th Jul 2006 14:28 Edited at: 8th Jul 2006 14:29
It is true that DBC has some troubles with collision. I also noticed from other people (I'm over a year on this DBC forum) that there are some problems with which object should be put first in object collision(). But hey, DBC is getting old .

I'd do something like:

the variables should point themselves out.

Quote: "You could use distance formulas."

sqrt() is a slow command.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
HenryTj
20
Years of Service
User Offline
Joined: 2nd Nov 2005
Location:
Posted: 8th Jul 2006 17:05
Yes, that is a simplification of about what I am using. Right now I am avoiding too much efficentcy in order to get it to work and to make sure that I know what it is doing and why. The old strategy, first get it to work, then make it efficient.

For example, if this were a real game I would use higher poly object to show, and invisible lower poly objects for collision detection. My objects are irregularly shaped so simple distance or box colision would not do what I want.

But I also only had about 10 days to do all this.

Henry
HenryTj
20
Years of Service
User Offline
Joined: 2nd Nov 2005
Location:
Posted: 8th Jul 2006 17:09
BTW, you dont have to Sqrt the distance if you can use the distance squared.

I might add box colisions as well to use for a "proximity alert" warning light on the "display."

The game is rather slow motion and lame. Its more to demonstrate how to do some things with DBC, than it is meant to be a real game.

Henry
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 8th Jul 2006 18:38
Maybe post your game, and we can do an attempt at optimizing your code...

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
HenryTj
20
Years of Service
User Offline
Joined: 2nd Nov 2005
Location:
Posted: 9th Jul 2006 03:29
I wasn'n asking anyone to optimize it for me. I was just trying to converse. I guess that is not done in these forums. Anyway I guess I could post it if someone wants to take a look. But I would like to clean it up some more first, and it might have to wait until after the course is over. I have to start typing up some handouts for Monday's first class.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 9th Jul 2006 20:05
Don't forget your remarks

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.

Login to post a reply

Server time is: 2026-07-06 18:36:50
Your offset time is: 2026-07-06 18:36:50