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 Professional Discussion / Basic intersect help

Author
Message
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 16th Sep 2011 12:21
Hey guys, I just need a quick guide to finding x,y and z collisions points using the built in intersect function.. Just something simple and explanatory.

Thanks

bchaos101
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 16th Sep 2011 13:29 Edited at: 16th Sep 2011 13:30
You are the red ball, and the blue one is your enemy. All objects in 3D space have a coord x,y,z.

Intersec commnad check if among both objects exist any intersection .





Cheers.

I'm not a grumpy grandpa
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 16th Sep 2011 23:03
Nice nice nice. What about for collision?

bchaos101
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 16th Sep 2011 23:49
Quote: "Nice nice nice. What about for collision?"


Sorry, but I didn't know that you need an example code. Here it is. You can make tests with your level ,and attached the complete example.



Cheers.

I'm not a grumpy grandpa
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 17th Sep 2011 02:53
Dude is that your code?(rhetorical) I mean freaking SWEET! Hands down

What name should I mention in my game's credits?

bchaos101
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 17th Sep 2011 03:02
Quote: "Dude is that your code?"


Yes this is one of my codes before I decide using Sparky's. You can add more intersect check to make it more realistic. This is my present for you, so use it as you need.


Cheers.

I'm not a grumpy grandpa
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 17th Sep 2011 03:10
Thank you master yoda I need to learn how to use ray-casts and intersect fluently any advise on where to look? I ask because i've been using db for a while now and i need to get onto the more advance stuff...

bchaos101
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 17th Sep 2011 03:16
Quote: "Thank you master yoda"

You are welcome !!

Intersect is easy to use, and we can use it to know if we can shot our enemy or if the enemy can see us. You can make all Question you need here in the forum, and you'll find all help you need.

Cheers.

I'm not a grumpy grandpa
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 17th Sep 2011 03:37
[/quote]
x=object position x(pj):y=object position y(pj):z=object position z(pj)

` collision with X
if INTERSECT OBJECT(esn,x,y,z,x+v,y,z)>0 then x=x-(v-INTERSECT OBJECT(esn,x,y,z,x+v,y,z))
if INTERSECT OBJECT(esn,x,y,z,x-v,y,z)>0 then x=x+(v-INTERSECT OBJECT(esn,x,y,z,x-v,y,z))

` collision with Z
if INTERSECT OBJECT(esn,x,y,z,x,y,z+v)>0 then z=z-(v-INTERSECT OBJECT(esn,x,y,z,x,y,z+v))
if INTERSECT OBJECT(esn,x,y,z,x,y,z-v)>0 then z=z+(v-INTERSECT OBJECT(esn,x,y,z,x,y,z-v))

`collision with Y
if INTERSECT OBJECT(esn,x,y,z,x,y-v,z)>0 then y=y+(v-INTERSECT OBJECT(esn,x,y,z,x,y-v,z))/3

`Gravity
if INTERSECT OBJECT(esn,x,y,z,x,y-v,z)=0 then gravedad#=0.8 else gravedad#=0.25

`camera movements
gr=wrapvalue(gr+mousemovex()/2)
gr2=wrapvalue(gr2+mousemovey()/2)
rotate camera gr2,0,0
yrotate camera gr
`camera rotation limits
if gr2<=290 and gr2>180 then gr2=290
if gr2>=70 and gr2<180 then gr2=70


`player movements
if upkey()=1 THEN x=NEWXVALUE(x,gr,c#):if upkey()=1 then z=NEWZVALUE(z,gr,c#)
if downkey()=1 THEN x=NEWXVALUE(x,gr,-c#):if downkey()=1 then z=NEWZVALUE(z,gr,-c#)

`slide left
if leftkey()=1 THEN x=NEWXVALUE(x,gr-90,c#):if leftkey()=1 then z=NEWZVALUE(z,gr-90,c#)
`slide right
if rightkey()=1 THEN x=NEWXVALUE(x,gr-90,-c#):if rightkey()=1 then z=NEWZVALUE(z,gr-90,-c#)

`camera and player position
position object pj, x, y-gravedad#, z
position camera x,2+y-gravedad#,z

[quote]

How would i increase or decrease the move speed in this code?

Thanks again,

bchaos101
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 17th Sep 2011 03:52
Also mind if I ask how long u have been coding chafari?

bchaos101
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 17th Sep 2011 12:05 Edited at: 17th Sep 2011 12:06
Quote: "How would i increase or decrease the move speed in this code?"



Hi again. You can increase speed, just changing var c#=0.2 in fourth line of that code. You can incrase it aswell if you increase the sync rate higher than 60. I have been coding for nearly 30 years, but other kind of programmming .

Cheers.

I'm not a grumpy grandpa
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 17th Sep 2011 15:44
Wow 30 year So what draws you to DBPro? also what about the fall speed?

bchaos101
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 17th Sep 2011 19:11
Worked out my gravity problem thanks

bchaos101
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 17th Sep 2011 19:50
Quote: "So what draws you to DBPro?"


I'm just a 3D modeler; I'm not an expert programmer but I can do little things

Are you making test with my collision engine? Ì'm glad it can help you.

Cheers.

I'm not a grumpy grandpa
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 18th Sep 2011 01:58
Yer I am(Doing tests). I was coding a level builder for about 3 month on & off. I was packing it with all the DB built-in functions(Visually adding models,numbering them, textured, creating basic object etc.) which w with a test live mode.

This way I would be able to churn out games with ease...

But it failed because of collisions not working. I was prob 75 percent complete.

Quote: "

I'm just a 3D modeler; I'm not an expert programmer but I can do little things

"


Wow a modeler that can code . Maybe we can help each other?

bchaos101
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 18th Sep 2011 02:51
Check my test vid..
http://www.youtube.com/watch?v=4MLQSS3tBQk

bchaos101
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Sep 2011 03:14
Quote: " Maybe we can help each other?"


Maybe. I'm retired, and I have plenty of time

Take a look to one of my attempts of level editor.

http://www.youtube.com/watch?v=OCY8xCR-pz4

Cheers.

I'm not a grumpy grandpa
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 18th Sep 2011 04:14
Very nice Do you have any examples of models that you have made?

bchaos101
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Sep 2011 12:10 Edited at: 18th Sep 2011 12:16
I'll have a look what can I find I my old PC.Meanwhile take a look at this piece of code ...modeling by hand.







Cheers.

I'm not a grumpy grandpa
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 18th Sep 2011 16:48
Very impressed How long did those two pieces take??

bchaos101
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Sep 2011 19:35
Quote: " How long did those two pieces take??"


About one hour the first and three the second. You have to think first how to make up the object, and how animate it.

Cheers.

I'm not a grumpy grandpa
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 18th Sep 2011 23:05
What did u study?(University)

bchaos101
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Sep 2011 23:29
I went to school until I was 18 then I had to go to the army. I've studied several languages, photography, photorealistic, 3D modeling etc.I've also done some basic programming for my students. Now I make all this just for fun.

What about you? are you perhaps a police?

Cheers.

I'm not a grumpy grandpa
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 19th Sep 2011 00:28
Quote: "What about you? are you perhaps a police? "

Why do you ask I am a computer science 1st year student atm

bchaos101
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 19th Sep 2011 02:00
Quote: " I am a computer science 1st year student atm"


That's good . When I was young I couldn't study such a science, so I went to the army to young.


Cheers.

I'm not a grumpy grandpa
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 20th Sep 2011 15:03
Ok, I'm gonna need your help on adding collisions to my editor. Copy and pasting the whole code here would be a bit much because its 2600 lines.

Basically when the level loads there is a test button, when the button is hit a new Do.. Loop is entered and a sphere object is created as the character object.

bchaos101
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 20th Sep 2011 18:34
I'm here trying to help everybody I'll help you if I can.

Cheers.

I'm not a grumpy grandpa

Login to post a reply

Server time is: 2026-07-10 17:19:22
Your offset time is: 2026-07-10 17:19:22