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 / [LOCKED] Sparky's Collision Problem

Author
Message
Tv Xxx
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location: Behind You!
Posted: 25th Feb 2008 23:26
Now, Im Normally Really Good At Fixing My Own Problems, But This One... Well Its Doing My Tree In. So...
Im Making A Pool Game "Zero Pool", I Have Made A Pool Table and A Pool Room and A CueBall
I Was Going To Use DarkPhysics For This Project, But Then Thought, Sparky's Has So Much More Options Avaluable. So I Started Coding ... As You Do. Then Boom, Collision Problems The Problem Is...

Even Tho The Ball Is Like 50 units above The Table, It Still Says A Collision Has Happened Any Ideas People?

Full Source With Media Included

Attachments

Login to view attachments
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 26th Feb 2008 18:46 Edited at: 26th Feb 2008 18:47
hmm... I'm no expert on 3D but...
If your table is a single object and the playing surface is sunk below the cushions (like a normal table), if you haven't set the table's collision to polygons it will return a collision if the ball is within the box/sphere that outlines the table's extremities.

How the hell do I know this when I never use 3D??

Tv Xxx
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location: Behind You!
Posted: 26th Feb 2008 18:48
It Is Set To Polygons Though

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 26th Feb 2008 18:49
Oh, I'll download and have a look...

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 26th Feb 2008 19:04
Your code is kind of confusing me, you don't include the files but they still work???

The only thing that caught my eye is you don't seem to have assigned a variable to "cueball#" (which doesn't need to be a float), therefore I think the program is looking at collisions like this:


IF OBJECT COLLISION(0[any object],Table#) THEN text 10,10, "COLLISION"


So if any object is colliding with the table it will return a collision. Either that or seeing as true=1, if the table is colliding with object 1 it will return a collision.

However that doesn't explain why if you move off the table the collision stops

Tv Xxx
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location: Behind You!
Posted: 26th Feb 2008 20:13
the var CueBall# Is Assigned To Object 16,
This Part If Code Is Under The Balls Source

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 26th Feb 2008 20:48
Have you tried posting on the DBP board?
It seems to me like the problem is something like what I suggested but I don't know how DBP can be structured.

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 26th Feb 2008 22:18
@Tv Xxx

I can't seem to download any attachments from the forums lately, not sure why - only if they are posted in a link that's not on the tgc server. Anyway, not being able to look at your code I'll guess at a couple of things that may or may not apply.

I think sparky's collision is entirely based on projecting a ray from a start point to an end point and checking for when the ray intersects a plane (when the ray passes through a mesh). Every iteration, whenever you reposition, scale, or rotate your objects, the objects are made into a mesh, loaded into a memblock, a pointer from the memblock is sent to the dll, and the intersection calculation is performed.

So the important things are that:
1. you are calling the update function from sparky's library regularly whenever your objects are changing position/rotation
2. you are using an approriate collision method = sphere/box/poly
3. you have groups and individual items set up properly for detection
4. And you are casting the ray from the right place to the right place.

For number 4
The following example shows a ray using sparkys dll being cast from inside a cube. If you move the arrow keys, left or right, you will change the start position and length of the ray. Whether there is collision or not will be displayed. If your pool game has objects that would end up in between where this ray is cast (including the table) or if one object is made of two object on top of or next to each other and the ray passes through one of them, the collision detection will flag positive.
I put the example together just so you can get a visual. Sometimes it helps just to see the process.


Enjoy your day.
LBFN
18
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 27th Feb 2008 02:41 Edited at: 27th Feb 2008 02:44
You're not using Sparky's for the actual collision check, you are using the built in DBP commands.

If you impliment Sparky's and still have the problem, I would change the ball's radius in the Sparky's collision check. Just curious, why is the ball positioned way up there in the first place?

LB


[ ** EDIT ** I just realized that this must be a DBPro program. This is posted in the Darkbasic forum.]
Tv Xxx
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location: Behind You!
Posted: 27th Feb 2008 09:17
The Ball Is Way Up There Just To Show That I Get A Collision Even Though The Ball Is No Were Near The Table ;p

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th Feb 2008 17:11

Login to post a reply

Server time is: 2025-06-04 01:52:27
Your offset time is: 2025-06-04 01:52:27