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.

3 Dimensional Chat / finding a point on a cubes surface ?

Author
Message
simonuk74
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 20th Nov 2002 01:36
ok, heres one for ya...

from the center of a cube, theres a line, that could be ANY variable angle, in all 3 dimensions..
say that the center of the cube ( also the origin of the line ) is X0,Y0,Z0, given any angles in xyz for the line, what would be the xyz co-ordinates of where the line meets the surface of the cube?
simonuk74
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 23rd Nov 2002 19:32
ok, heres another way of putting it...

if I have a line going through the center of a sphere, I can work out the co-ordinates of where the line crosses the surface of the sphere by using sin/cosine maths.
but to do the same with a cube instead of a sphere is a little more challenging.
I need it for a simple collision detection system, where the program needs to know where about the cube was hit.
I hope that is a little more clearer.

Simon

Luke
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location: United States
Posted: 23rd Nov 2002 21:43
So, lemme get the question straight, you want to get a x/y/z position relative to the world x/y/z? right ok, so first you can forget bout the z rotation of the plain or line, because that wouldn't change the direction of it. then asuming that it is a perfect cube, you can have some ifs:



so, now it will do a different calculation depending on which side it heading into.
Now you can do:


this should get the Xpos# and Zpos# relative to the object's position. If you still need help then I'd be happy to make a completely working function for you. I haven't tested the above code, it's the idea that counts!

www.CyberLuke.com
Luke
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location: United States
Posted: 23rd Nov 2002 22:43
Ok, so here's a demo thing, with a nice function, Hope this was what you're looking for! Positions any obejct at any other object, with the angle and cube stuff. Fully Remmed so I hope you'll understand it!



www.CyberLuke.com
Luke
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location: United States
Posted: 24th Nov 2002 00:10
this way might be more useful!
press upkey for a bit to get the cube on top of the other object, that is how to do the get ground height off an object. The control's are the same, both cubes are spining, and they never crash!


www.CyberLuke.com
Luke
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location: United States
Posted: 24th Nov 2002 00:24
for the collision system, I normally use:
set object collision on num
set object collision to polygons num
returnvalue=object collision(num1,num2)
set object collision off num

you need to be careful when the collision is set to polygons, it slows a game down quickly (sounds like an oxymoron!) when two many objects are all checking collisions. so at the very least only chech collisions when the objects are in a reasonable distance (object size(num1)+object size(num2)). But then again, there might not be collisi9on commands in DBP, if that's what you're using.

www.CyberLuke.com
simonuk74
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 25th Nov 2002 01:45
Thanks, Cyberluke
I think I figured out how your code with the cube&line works, thats just about what I need!
as for the two cubes, I still need to look over the code to see how its working, but it looks very cool lol

thanks very much,

simon

simonuk74
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 25th Nov 2002 01:50
oh, I`m using DB 1.3 at the moment..

and I usually try to write my own collision, if I can due to DB having probs with the slow down.
but I still need to perfect my collision detection, as its very basic, and it only works in 2 planes ( x/y,x/z,y/z), but not all 3 yet, but as it works on an array, which contains a `replica` of the game world, - where it works on if a co-ordinate has a certain value, it`s a solid/slowdown/kill zone.
It currently works very well, with no slowdown, and I`m sure by adding a 3rd dimension to the array, wont be that difficult, just that in the game I was using it on, it wasnt needed.

thanks again, simon

Login to post a reply

Server time is: 2024-03-29 01:14:43
Your offset time is: 2024-03-29 01:14:43