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.

Newcomers DBPro Corner / Using sparky's dll with dbc

Author
Message
Lucifer
18
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 31st Dec 2006 04:05 Edited at: 31st Dec 2006 04:14
I'm sorry for asking another question about collision please dont get pissed

I am just trying to experiment with sparky's collision dll and there is something i dont understand, i find it very hard to find something that answers my question, dont think i didnt search... please (if anyone knows about a tutorial/Code that shows me how this works please dont flame me tell me about the link, when i searched i only found stuff that explained how sparky's dll 2 for dbpro worked).. Now, i made this code: just to experiment with it and trying to learn..



From how i understand it, (i am sure i am wrong) intersectobjectdbc is like the object collision(2, 1)???.

if anyone wants to show me how this works i will be very happy because i will learn from it, i am not asking random questions.

i did check out ruccus dll resource post and tdk's post on collision but i didnt find anything that explained what i'm trying to learn. the only thing i found at ruccus'es post was that sliding collision thingy, but it only works with dbpro..


Me+indi... yes...
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 31st Dec 2006 18:58
Raycasting (what the intersect object command does) is pretty simple. Think of it as a laser. You specify the laser's starting and ending coordinates, and the laser is then projected between those 2 points. This laser constantly checks if any polygons of the model you specify pass through the laser. If a polygon is hit, the laser bounces back and returns the distance to the point of collision.

Why's raycasting good? Using the object hit and object collision commands aren't polygonal, all they do is use either spheres or boxes that are wrapped around each object, and then the computer checks if these two collision boxes/spheres overlap.

Sparky's intersect object command goes like this;

SC_intersectObject(object, x1, y1, z1, x2, y2, z2)

object is the object you want to detect for intersection.

x1/y1/z1 is the starting location of the laser.

x2/y2/z2 is the ending location of the laser.


Here's a simple program showing how the system works. Press the up/down key to move backward/forward. When you run into the laser, the words "HIT" will appear in the top left of the screen.



Raycasting has tonnes of uses. Project a ray from the user's old position to their new position, and you can detect if theyve hit any polygons on a complex map object. Shoot a ray from their gun to a point infront of their gun, and you can check if theyve shot anyone, or better yet, get the polygon they shot on the wall, and position a decal of a bullet hole there. Setup a bunch of lasers spinning randomly in a room detecting if the user touches a ray, if so tell them theyve failed their mission.

Hope that helps a bit,
- RUC'

Lucifer
18
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 31st Dec 2006 19:40
hey thanks ruccus, i fixed the code so it works for dbc, but there is one thing i cant seem to figure out..


at the intersectObjectDBC(1,-100,0,50,100,0,50) i get an error saying "Syntax error. Parameters differ between function call and call decloration at line 90.. any ideas?


i like pancakes..
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 31st Dec 2006 20:32
My guess is you've left out a needed parameter for the DBC version to work. Not sure what though. In DBP if you use an extra param or not enough params in a function call, you get an error along the lines of "Syntax doesnt match: "with a list of the function syntax. I guess in DBC the error is different.

If I could see the functions.dba I could help more.

Lucifer
18
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 31st Dec 2006 21:33
here it is




i like pancakes..
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 31st Dec 2006 21:36
Yeah, see the function intersectObjectDBC takes a last parameter called ExcludeObject. Put an additional 0 for the last parameter and it'll work.

Lucifer
18
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 31st Dec 2006 22:51
no it still gives me the same error message


i like pancakes..
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 1st Jan 2007 01:12
Sorry, theres another parameter I missed called groupFlag. Id show you how to fix it, but you need to understand this.

Lets say we made a function called add, and it returned the sum of 2 numbers.



So far so good. Now, we call the function;


Which would make answer equal 7, right?

So far so good, because we gave the required parameters. Now, what if we did this?



You'd get the error youre getting now. Do you see why? Its because we only gave one parameter, when the function calls for 2.

Again, you'd get the error if you gave too many parameters;



Because the function doesnt know what to do with the last parameter.


So, if you look in that functions.dba file, and you find the intersectObjectDBC command, you'll see this is all of it's parameters;

(objNum,groupFlag,oldx#,oldy#,oldz#,x#,y#,z#,excludeObj)

Now its just a matter of filling in the data. Right now, you're calling the function without providing a groupFlag number. The groupFlag number tells the system if you want to check for intersection with an entire group, or just 1 object. In our case its just 1 object, so we set the groupFlag to 0. So, the final command should go like this;



On a side note, I recognize these commands from sparky's old dll. Have you tried using his later version 2 release? Im pretty sure right now you're not, but I could be wrong, as Im using the dbp version.

For version 2 just search for collision and click on the thread titled "DBP Collision Plugin v2" (or something like that).

- RUC'

Lucifer
18
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 1st Jan 2007 02:02 Edited at: 1st Jan 2007 02:02
thanks for explaining that ruccus..

i think that the v2 dll is only for dbpro i will check it out and see if there is a dbc version..

and this is weird.. i get the same error message, even with the new code.. huh.. me dont understand why..


i like pancakes..
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 1st Jan 2007 03:49
Thats weird... you might wana make a seperate post about that or head over to IRC for help, I cant see any other reason that it shouldnt be working. Make a post in the DBC Board titled something like "DBC Parameter Mismatch with Sparky's Dll" explaining the problem, a link to this thread, and you're current code, and you might get some help there.

Lucifer
18
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 1st Jan 2007 04:20
ok, i'll make a post in the dbc boards tomorrow explaining the problem and stuffz.. thanks for all your help ruccus..

love ya....


i like pancakes..
Robot
20
Years of Service
User Offline
Joined: 27th May 2004
Location:
Posted: 8th Jan 2007 08:22
If this has already been answered somewhere then ignore me but I think the error is arising from trying to give the function an integer where it expects a float. If you put a ".0" on all the 3D world co-ordinates then I think it should work.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 9th Jan 2007 02:12
That mightve been it, I dont have DBC so I dont know how strictly it handles function parameters, in DBP passing an integer for a float is fine though. Chances are thats the case, they need to be decimals.

Login to post a reply

Server time is: 2024-09-25 15:30:32
Your offset time is: 2024-09-25 15:30:32