Posted: 7th Nov 2003 23:06
As far as I have found, you can only call the intersect object function about 25 times per loop without seeing a massive FPS hit. For most games using 8-way X-Z detection and 1 for height works out great. It's not perfect, but it allows you to play.

-Kensupen
Posted: 12th Nov 2003 23:30
Since this is a collision topic, you might also try a collision system I've been working on for some time. I formerly worked with Sonic on it, and the first release got dubbed as "Sonic's DLL".

About a month ago we release v2.0 which is designed specifically for DBPro and includes a powerful set of automatic functions and is designed to be upgraded with minimum hassle. An new upgrade is coming out in 1-2 weeks including a powerful new set of functions and some minor fixes over the current 2.0 release.

The link to download is: http://www.nuclearglory.com
Posted: 22nd Nov 2003 3:58
Great, will give it a try. One or two 'complete' examples of FPS and 3rdPerson would be helpful to show how it works..

gbuilder.
Posted: 22nd Nov 2003 5:12
A 3rd person example is planned for the upcoming release. It will demo a lot of the power/features of the collision system.

Some of these features include:

- Ellipsoid to mesh support
- Moving ellipsoid to moving mesh support
- Moving ellipsoid to moving ellipsoid support
- Enhanced mesh collision routines
to glide over edges and around corners
- Automatic handling
of all of your collision objects
- Definition system
easily setup and define collision objects
- Ray-Intersect
intersect ellips and/or meshes that will return the position, angle, normal, and distance of collision
- Collision responses
Stick, Slide, Sliding but not down slopes, Sliding without fighting gravity while going uphill, and no response (great for hotzones)
- Dynamic collision responses:
no-response, normal response to moving mesh, locking response to moving mesh (so if the platform won't move out from under you if you're standing on it)
- Feedback system
cycle through the collisions an object went through and get their exact contact points, normals, etc...
- Internal optimizations
to quickly skip meshes/objects that are out of range
- Activate/Deactivate system
you can quickly disable objects for collision entirely (very useful for disabling objects out of range in large worlds) and re-activate them when you need
- 5 concave modes
used to make collision fast/stable in tight corners. Different modes available so you can select the mode that produces the best results for your style game

It will have an example set and 3rd person demo.

Some of these are reserved for the shareware copy of the system. The shareware copy will cost a one-time flat fee of $15, it can be used unlimitedly and on team projects at no extra charge, and will come with DBPro, DB Classic, and blitz compatible packages. So if you decide to use a different engine you won't have to pay again.

Quite a bit was covered quickly. Feel free to post if you have any questions
Posted: 23rd Nov 2003 19:29
That DLL sounds like a dream come true. Im gonna get it when I can. Sounds like it solves all DBPro's collision problems in one tasty package, and its cheap, works out at about a tenner in the UK. Which is good for a one off payment. And especially good as youre then entitled to the updates aswell. Pure class.
Posted: 26th Nov 2003 17:21
This is where I am at as far as placing colz charactor on a cshop
map. Still needs work but I don't know if I'm capable of doing.
Use Kensupens map or your own x file but it won't work with matrix
floor. I can get it to work good but like I said with a few things
needing work. don't change charht# cause it don't matter the way
it's set-up. just position object inside your x-files room
(with x-position and z-position)and boom! your sucked to the floor or should be anyway. I put the "checks and dims) in the subroutine
cause I get more fps. Also have camera collision, the smoothing in set camera to follow has to be 10 or higher so it will reposition
itself after hitting a wall. any lower and camera collision gets a little buggy. Can someone else work out the problems? Be my quest!
Dugzilla
Posted: 26th Nov 2003 17:32
The source code I listed last is incorrect, Try this one below.
Dugzilla
Posted: 26th Nov 2003 17:37
For some reason when I hightlight all of my code it cuts out
a section in the middle. So the code I posted will not work! I'm going to try this in two parts. there is the first part below....
dugzilla
Posted: 26th Nov 2003 17:39
Here is the second and final part.
Dugzilla
Posted: 26th Nov 2003 17:48
Still cut out code. Lets try this,
Dugzilla
sync
center text screen width()/2,screen height()/2,"LOADING"
sync
sync rate 100
sync on
color backdrop 0
set ambient light 100
set camera range 0,1,5000
````````````````````````````````````````````````````````````````````
load object "land.x",1
position object 1,0,0,0
yrotate object 1,180
````````````````````````````````````````````````````````````````````
load object "colonel z\colz.x",2
rotate object 2,-90,0,0
position object 2,0,0,-2000
set object speed 2,20000
scale object 2,75,75,75
fix object pivot 2
````````````````````````````````````````````````````````````````````
do
set cursor 1,1
print "Fps=",screen fps()
gosub player_control
gosub camera_and_collision
gosub collision_and_ramp
sync
loop
````````````````````````````````````````````````````````````````````
player_control:
if spacekey()=1 then position object 2,0,0,0
if upkey()=1 then move object 2,+7 : loop object 2,26700,32100
if upkey()=0 then loop object 2,1,9000
if downkey()=1 then move object 2,-7
if rightkey()=1
yrotate object 2,wrapvalue(object angle y(2)+5)
loop object 2,26700,32100
endif
if leftkey()=1
yrotate object 2,wrapvalue(object angle y(2)-5)
loop object 2,26700,32100
endif
return
````````````````````````````````````````````````````````````````````
collision_and_ramp:
radius#=30.0
checks=8
if checks<8 then checks=8
if checks>8 then checks=8
angwidth=360/checks
dim ang#(checks-1,2)
dim sort#(checks-1,2)
for x=0 to checks-1
chx#=newxvalue(x#,x*angwidth,100)
chz#=newzvalue(z#,x*angwidth,100)
ang#(x,1)=intersect object(1,x#,y#+50,z#,chx#,y#,chz#)
if ang#(x,1)=0 then ang#(x,1)=999999
ang#(x,2)=x*angwidth
sort#(x,1)=ang#(x,1)
sort#(x,2)=ang#(x,2)
next x
for x=0 to checks-2
for y=x+1 to checks-1
if ang#(x,1)>ang#(y,1)
temp#=ang#(x,1)
temp2#=ang#(x,2)
ang#(x,1)=ang#(y,1)
ang#(x,2)=ang#(y,2)
ang#(y,1)=temp#
ang#(y,2)=temp2#
endif
next x
next y
print "Player Distance to Wall=",ang#(0,1)
prev=wrapvalue(ang#(0,2)-90)/angwidth
nxt=wrapvalue(ang#(0,2)+90)/angwidth
newd#=radius#-ang#(0,1)
newa#=wrapvalue(ang#(0,2)-180)
newd1#=radius#-sort#(prev,1)
newa1#=wrapvalue(sort#(prev,2)-180)
newd2#=radius#-sort#(nxt,1)
newa2#=wrapvalue(sort#(nxt,2)-180)
if ang#(0,1)<radius# and ang#(0,1)>0.0
repx#=newxvalue(x#,newa#,newd#)
repz#=newzvalue(z#,newa#,newd#)
position object 2,repx#,y#,repz#
endif
x#=object position x(2)
z#=object position z(2)
if sort#(prev,1)<radius# and sort#(prev,1)>0.0
repx1#=newxvalue(x#,newa1#,newd1#)
repz1#=newzvalue(z#,newa1#,newd1#)
position object 2,repx1#,y#,repz1#
endif
x#=object position x(2)
z#=object position z(2)
if sort#(nxt,1)<radius# and sort#(nxt,1)>0.0
repx2#=newxvalue(x#,newa2#,newd2#)
repz2#=newzvalue(z#,newa2#,newd2#)
position object 2,repx2#,y#,repz2#
endif
charht#=130
x#=object position x(2)
y#=object position y(2)
z#=object position z(2)
sub#=intersect object(1,x#,y#+125,z#,x#,y#-(charht#*2),z#)
ht#=(y#+charht#)-sub#
if sub#=0 then ht#=charht#
grav#=grav# -2
if y#+grav#<ht#
grav#=0.0
position object 2,x#,ht#,z#
else
ht#=y#+grav#
position object 2,x#,ht#,z#
endif
return
````````````````````````````````````````````````````````````````
camera_and_collision:
x#=object position x(2)
y#=object position y(2)
z#=object position z(2)
a#=object angle y(2)
d#=150
h#=130
s#=20
set camera to follow 0,x#,y#,z#,a#,d#,h#,s#,0
radius#=10.0
checks=4
if checks<4 then checks=4
if checks>4 then checks=4
angwidth=360/checks
dim ang#(checks-1,2)
dim sort#(checks-1,2)
cx#=camera position x()
cy#=camera position y()
cz#=camera position z()
for x=0 to checks-1
chx#=newxvalue(cx#,x*angwidth,100)
chz#=newzvalue(cz#,x*angwidth,100)
ang#(x,1)=intersect object(1,cx#,cy#+50,cz#,chx#,cy#,chz#)
if ang#(x,1)=0 then ang#(x,1)=999999
ang#(x,2)=x*angwidth
sort#(x,1)=ang#(x,1)
sort#(x,2)=ang#(x,2)
next x
for x=0 to checks-2
for y=x+1 to checks-1
if ang#(x,1)>ang#(y,1)
temp#=ang#(x,1)
temp2#=ang#(x,2)
ang#(x,1)=ang#(y,1)
ang#(x,2)=ang#(y,2)
ang#(y,1)=temp#
ang#(y,2)=temp2#
endif
next x
next y
print "Camera Distance to Wall=",ang#(0,1)
prev=wrapvalue(ang#(0,2)-90)/angwidth
nxt=wrapvalue(ang#(0,2)+90)/angwidth
newd#=radius#-ang#(0,1)
newa#=wrapvalue(ang#(0,2)-180)
newd1#=radius#-sort#(prev,1)
newa1#=wrapvalue(sort#(prev,2)-180)
newd2#=radius#-sort#(nxt,1)
newa2#=wrapvalue(sort#(nxt,2)-180)
if ang#(0,1)<radius# and ang#(0,1)>0.0
repx#=newxvalue(cx#,newa#,newd#)
repz#=newzvalue(cz#,newa#,newd#)
position camera repx#,cy#,repz#
endif
cx#=camera position x()
cz#=camera position z()
if sort#(prev,1)<radius# and sort#(prev,1)>0.0
repx1#=newxvalue(cx#,newa1#,newd1#)
repz1#=newzvalue(cz#,newa1#,newd1#)
position camera repx1#,cy#,repz1#
endif
cx#=camera position x()
cz#=camera position z()
if sort#(nxt,1)<radius# and sort#(nxt,1)>0.0
repx2#=newxvalue(cx#,newa2#,newd2#)
repz2#=newzvalue(cz#,newa2#,newd2#)
position camera repx2#,cy#,repz2#
endif
return
````````````````````````````````````````````````````````````````
Posted: 26th Nov 2003 19:53
Not Bad,
I used kensupens original mslevel.x level and the Colz.x character. Camera collision is working and the Character collision is working.
There are a couple of anomalies.. The Character can jump backwards onto the ramp and when it gets jammed in a corner, it vibrates like hell. I get 45 to 48 fps.
Keep at it...

gbuilder.
Posted: 26th Nov 2003 22:38
Okay, we've got a demo up.

It's posted in the "Work in Progress" section.

Here's the link:
http://darkbasicpro.thegamecreators.com/?m=forum_view&t=20816&b=8

It has screens as well as 3rd person camera control in the demo.

Edit: Our system does have 6 different concave modes designed specifically to handle corners without jitter. And you can select the mode that best works for you. For an FPS game a mode of 3 works well, and for a free-flight space game of sorts you might want a higher mode.

Go ahead and jam the soldier into corners in the demo above
Posted: 27th Nov 2003 10:07
Since I don't have a lot of time to work on coding anymore, I'm going to work with the Nuclerglory team and let them try to advance my code and hopefully give them ideas to make their DLL better. I figure trying to create competition is a waste of energy, I'd rather work with them to make better code. (Besides, they are better coders than I) Hope you will use our code/DLL in your games.

-Kensupen
Posted: 27th Nov 2003 10:46
What a fine idea. Good luck
Posted: 27th Nov 2003 20:27
EDIT: sorry posted this in the wrong section
Posted: 28th Nov 2003 16:09
ummm... can some1 help me with kensupen's code, when I move my camera with greater speed I go trough walls, why is that? and is there a solution for it?
Posted: 28th Nov 2003 20:15
I suggest you post your code or a link to download your project... it could be a number of things..

gbuilder.
Posted: 29th Nov 2003 4:00
I know exactly what is going on. (Or at least have a good theory) The collision code is checking to see if you are <20 units from a wall, if you are then push you away. If the camera moves at > 20 units/loop then you can pass right through the walls.

Example:
Say your camera is 20.87 units away from the wall. If you move the camera 21 units, the camera will then be 0.13 units past the wall and it will push you the direction you are facing to 20 units from the opposite side of the wall. Hence you go through it.

-Kensupen
Posted: 30th Nov 2003 18:06
I thought so to, but is there noting to do about it? like checking where the normal of the polygon is pointing to and the position the camera on that side
Posted: 1st Dec 2003 7:29
It would take a lot of coding and tricks to make it a lot better than what I have now. I'm trying to find time to work on it again and make some massive updates to it for better accuracy. Right now, I don't have the time.

-Kensupen