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 / Problem with SC_ObjectCollision

Author
Message
Ondrej
16
Years of Service
User Offline
Joined: 18th Apr 2008
Location: Slovakia
Posted: 10th May 2008 01:42
SC_ObjectCollision always return 0, why?
This is snippet of my simple program:


cout << sorry for my bad english;
Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 10th May 2008 01:45
First of all you are not starting collision in main function... put SC_Start(); at the top...
You are also not updating the objects position... put SC_UpdateObject (ObjNum); for each object you want to check collisions against in your loop...

~~It's not who you are underneath, but what you do that defines you.~~
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th May 2008 01:48
Start with mock up code I helped someone else with:




BTW a simple BOX is hardly a "Complex" object. Look up the SC_SetupObject function, and the parameter where you specify box, sphere, or poly.

Terrain is a good example of a complex object.

Ondrej
16
Years of Service
User Offline
Joined: 18th Apr 2008
Location: Slovakia
Posted: 10th May 2008 03:17
thanks and thanks for a mock up code. helped me.

cout << sorry for my bad english;
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th May 2008 03:43
Excellent! Glad to have been of help! Good Luck!

R3path
16
Years of Service
User Offline
Joined: 25th May 2008
Location:
Posted: 26th May 2008 04:56
So I've just been trying to run the mock code you wrote to see how colliding even works, but every time I run it it just gives me an

error LNK2005: "void __cdecl DarkGDK(void)" (?DarkGDK@@YAXXZ) already defined in Main.obj

and I Have no idea what it means

Any help would be appreciated
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 26th May 2008 05:36
TRY opening your SC_Collision.h file and inserting as the FIRST line:

#pragma once


Report back

R3path
16
Years of Service
User Offline
Joined: 25th May 2008
Location:
Posted: 26th May 2008 05:56 Edited at: 26th May 2008 18:00
Thanks, So it works, I am now wondering if there is a possibility of having the cube go thru a model file that I made, ill try to include the code to the code I have so far made (Just a heads up if
I totally screw this post up , its because I am just in the learning phase and this is my first time posting a forum message.


Heres the model I have made (I tried to attach it Castel.X file)

Attachments

Login to view attachments
R3path
16
Years of Service
User Offline
Joined: 25th May 2008
Location:
Posted: 26th May 2008 17:59
Well totally ignore the last post i messed up on the Code Snippet and i figured out how to add a movable cube(Player), the only question i have is how to i run the cube thru an object(Direct.x) that has openings where I should be able to walk, The boundaries just blocked the whole object even the door ways(Openings).
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 26th May 2008 18:43
Well.. There is a call to display Sparky's "Object Bounds" (Wire frames where the collision will occur.

Second, there is 3 types of setup, (four if you consider complex object another one... ) Sphere, Cube, and Poly Collision. I figure "complex objects" are an "optimized for big stuff" version of the poly coliision.

If using sphere sliding collision, remember your "radius" needs to be small enough to fit through doorway... and the poly collision (or complex for a level with doors maybe) needs to be on so you can in fact go through doors.


Good Luck!

R3path
16
Years of Service
User Offline
Joined: 25th May 2008
Location:
Posted: 26th May 2008 18:56
Well thanks for the info, I found my out how to do it, using SC_SetupObject(1,1,0) Making it a Polygon Count allows it to collide only where there we're polygons, as for the floor lol, I made my direct .x file position at(0,-1,0) So my player doesn't hit floors(B/c their lower that the actual map itself), he just kinda floats over them but it looks like hes on the floor. Now I added Jumping and I was wondering how you would add Gravity, because he can jump alright but he keeps going up.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 26th May 2008 21:39
so you don't get flamed - do some searches in the DBPro forums to see how people do it there - that question is posted alot - and people get bent when they are asked to answer the same questin over and over....

I knows DBPro is NOT Gdk - but you should get a few ideas!

And congradulations on your collision successes so far! Good Show!

RG Fred
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 26th May 2008 23:07
Hi there,

I am new here and I'am wondering where can I get "SC_Collision.h".
When I look in my include folder there is no such file.

Fred
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 26th May 2008 23:36
-Paul Johnson's (Sparky's) Collision DLL - aka Sparky's:
http://forum.thegamecreators.com/?m=forum_view&t=74762&b=5

Download the GDK Collisions file, unzip... I recommend copying the SC_Collision.h to your c:\program files\the game creators\darkgdk\include directory

and the *.lib file Paul (Sparky) provides to c:\program files\the game creators\darkgdk\lib\ directory.

R3path
16
Years of Service
User Offline
Joined: 25th May 2008
Location:
Posted: 29th May 2008 04:19
Well, I know I might get flamed for asking but I need to know how to set up gravity, Ive tried for like 5 hours already with variables that would turn on and off making the object go down
if(R == 0)
{
dbMoveObjectDown(2, Y * 0.07);
};

Ive tried placing a Box around a complex object (Stair) so the R value would be disabled so the gravity wouldn't work, but then when you'd fall off the stairs you would just keep falling, then tried to make the object add a bit of a value to Y(height), but as soon as Collision free the object falls again making an vibrating camera that gets really annoying until the screen messes up.
SC_UpdateObject(2);
SC_UpdateObject(4);
iCollideID = SC_ObjectCollision(4,2);
if(iCollideID>0)
{
dbPositionObject(2, ox, oy + 15, oz);
dbRotateObject(2, oax, oay, oaz);
R = 1;
};

So basically these are just some things ive tried, Ive tried reading the dbpro but like you said DBPro is not DGDK and I have just started to program a week ago. So How do you add Gravity with Height changes
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 29th May 2008 05:01
Ok... Good Effort.

Well,
Your question is a loaded question because I have no "real project" to go on for what you have working and where you're trying to get your gravity working.

There are typically 2 things you need to know first:

1: How to get your variable Groundheight

2: How to Apply the "up" and "Down" formula

There is always ground collision, via poly, but I personally use sparky's ray casting for "Ground Height" over terrain. However, if you are using the GDK "Stock" terrain system, it has a ground height function that simplifies things.

If you are loading a mesh terrain (some *.x file or something) you might consider Raycasting for calculating ground height. Raycasting is typically done by "setting up" the terrain in sparky's as a complex object. Then you Ray cast from DIRECTLY OVERHEAD... start further up than your highest terrain altitude. (Can find out by display your cam coords to the screen and flying over your terrain's highest peak.

You use the X and Z of the "spot" (usually where your actor and/or player is) and the Y of this "Highest point" and you shoot the ray down to the SAME X,Z position of your actor/player, and the Y LOWER than your lowest terrain point. (Could be less than zero.). (You shooting a laser from the sky straight down to the ground. You basically can get a ground height from reading the raycast results like this:



This function returns ZERO for alititude if you're not over the ground. i.e.: raycast doesn't hit anything.

Ok... So now you in theory can get the height of the ground thing working... where gravity has done its duty, and you can in theory stop falling because you hit something.

Note, you need to work out things carefully if you want gravtiy in building. Cheap way? Make the ground height "Group" be just your "earth" and building be in another group (for wall collision) and keep "building floors" even with ground. Alternatively, you could have Poly collision with the ground versus ray casting.. so floors in buildings don't need to jive with the earth outside... but thats getting thick. (Told you it was a loaded questions.. raycasts will stop if they hit a roof.. if you're not careful! think how silly when you character keeps climping buildings in a single bound LOL )

the next bridge to cross... is the gravity itself.

Your actor should have a variable associated with "him" "her" "it" whatever... that is an indicator of their UPWARD SPEED. I Say upward... because if your "jumping up" this value is positive typically, and when you fall.. this "speed" is going negative.. e.g. you are moving the character either positive or negative on the Y axis.

Ok... so gravity is down to a number... positive up, negative down.

Next... user presses a jump button - this should set a positive number... and you should in turn move your actor up accordingly... but gravity will need to take over.. and make them fall right? So you need a way to gradually make this "upspeed" variable get smaller and smaller... to zero (Zero gravity LOL) and then begin going negative... and you can't let this number get TOO negative (to fast!) You also don't need to keep "decrementing" this variable if they are on the ground. (zero is ok when on ground I suppose).


To make gravity work.. each loop just subtract a tiny amount (the sweet spot - where it looks right.. is a tricky thing to find - lots of trial and error usually) ...subtract a tiny amount from the "upwardspeed" variable. (Make sure its a float)

Then, depending on this "upwardspeed" variable - you...:



I hope this get's you started on homemade gravity. Keep me posted. If you need more specifics, I'll try to get some time in to make you a demo.

R3path
16
Years of Service
User Offline
Joined: 25th May 2008
Location:
Posted: 30th May 2008 00:22
Well I hit a problem every time I put in Float GroundHeight it gives me an error GroundHeight' : local function definitions are illegal
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
R3path
16
Years of Service
User Offline
Joined: 25th May 2008
Location:
Posted: 30th May 2008 03:58
Alright Sorry if I am really annoying you with this btw... and Thanks so far for the help

here it is( and theres a lot of unrelated codes in there like Particles that I was just messing around with)





Thanks in Future
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 30th May 2008 04:10
(Zip up your Media and code together so I see what you see. I have no interest in using your media.) If you don't want others to see your media.. email me... I can make provisions for you to upload to my server directly... via an account... I'll look at it, see if I can't help, then I'll notify you, and you pull back down the finished work. Then I delete your account

If you want to go this route. Just email me. (Email button below)

No promises btw - back up your work in case you don't like mine

R3path
16
Years of Service
User Offline
Joined: 25th May 2008
Location:
Posted: 30th May 2008 05:05
Well, I just sent you an email, please just confirm when you get it
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 30th May 2008 05:21
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 31st May 2008 15:31
I can't email you bro - micrsoft keep rejecting my ISP or the fact that my email comes from my ISP, but the email address is from my email service provider which is different. I think it thinks I have "spam" characteristics. I HATE %$@#%@#$% EMAIL SPAMMERS!!!!! Now a guy like me sending legitimate mail pays a consequence!!!!!

I did some clean up – I couldn’t resolve the buffer overrun issue, I couldn’t get to the gravity – I’m sorry – I don’t have any more time to spare. I have business issues I must resolve.

I do think you want to think about how you’re using groups in sparky. You might just have it how you do “for know” or you might not get what they are about.

If set multiple objects into the same group – you can write code to react to ANY COLLISION for that group – so you can have all your “level” of solid things like building walls in one group, ALL stairs in another, all bad guys in another – so you can write code to handle each “Type” of thing in simpler terms.

Now I found quite a few things out of place or ayre… I tried to put some comments here and there without mangling your code. I’m sorry I don’t have the time I thought I might have to help more on this.

I do think you need to consider raycasting from the "head" of your player to straight down to see if the ground or stairs are beneath him/her. I think that will solve your indoors problem. Use Collision to prevent going through stuff.. like walls.. or rendering "inside" stairs. For gravity, do the ray cast or sphere sliding collision.

--Jason

R3path
16
Years of Service
User Offline
Joined: 25th May 2008
Location:
Posted: 31st May 2008 18:01
Thank You for the help, I'll go look at all the things you've said

Login to post a reply

Server time is: 2024-09-29 21:15:22
Your offset time is: 2024-09-29 21:15:22