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 / Beam Between 2 Objects

Author
Message
Codger
23
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 30th Apr 2003 08:39
[b]I am trying to create a line between 2 3d objects. The beat I have so far is to use the triangle object but it is a very lame effect. See the code snipet.


Can anyone provide code to define a cyclinder between 2 3d objects using the objects current x,y,z position

Thanks in advance
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 30th Apr 2003 14:44
Use a ghosted plain with an animated texture on (of a wave-like beam).

Current Project: TANK MELÉE [Artwork] , DBPro Windows GUI Plugin [Slow but steady ]

Joke of the Month: "Why drink and drive when you can smoke a spliff and fly?"
kfoong
23
Years of Service
User Offline
Joined: 28th Jan 2003
Location: Australia
Posted: 30th Apr 2003 15:44
Well you cant do it with a cylinder since DB only only allows you to define the cylinder size not the radius and the length. So you might have to do it with boxes or plains.

Now to do that firstly you need to find the distance between the two objects. I cant remember the distance formula.

And to find the angle from object one to two you have to use the sine, cosine or tangent things and i cant be bothered to think of that at the moment

--------
http://www.stellarblue.vze.com/
Dr DooMer
23
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 30th Apr 2003 16:13 Edited at: 30th Apr 2003 16:13
Well, actually, you can do it with cylinders. I'll explain:

First of all, create a cylinder with size 100 and texture/colour/ghost/whatever it. Now, position it in the centre of the two objects - you'd use a basic (xpos_1# + xpos_2#) / 2.0 for each of x, y and z to get this. Now, use the point command and point the cylinder towards one of the objects, it doesn't matter which.

Then comes the trickier part - you need to calculate the distance. Because I'm such a generous guy, here's a distance function that I've written that'll save you from having to figure it out yourself:



It's probably a good idea for you to try to figure out what it does; it's really just two instances of Pythagoras calculations - one to find a 2D distance in the X and Z axis, and then another to calculate a 3D distance by using this value and the Y axis.

Anyway, once you've got the distance, it's time to do some scaling! Set the scaling of the cylinder to X=1, Y=Distance and Z=1. This will make the cylinder very tall and thin, although you might like to fiddle with the two 1's until you get a thickness that you like.

Hope this helps!

"I am a living, thinking entity who was created in the sea of information."
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 30th Apr 2003 16:16
In my experience cylinders look a bit cheap, I find that a textured plain gives a much better impression of varying intensity within the beam.

Current Project: TANK MELÉE [Artwork] , DBPro Windows GUI Plugin [Slow but steady ]

Joke of the Month: "Why drink and drive when you can smoke a spliff and fly?"
Dr DooMer
23
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 30th Apr 2003 17:53
Yeah, he's right - a plain, or multiple plains, with a laser texture and ghosting enabled make a much better looking effect. If you like, I can provide you with a volumetric (two crossed plains) object that I use for this sort of thing and a laser texture to go with it.

"I am a living, thinking entity who was created in the sea of information."
ZomBfied
23
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 1st May 2003 02:54
I use like 100 or so ghosted plains placed at regular intervals between the objects. It works pretty darn good. Check out the line in the astro-nav screen in Captain Zero

Codger
23
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 1st May 2003 23:34
Thanks for the help guys

I combined the ideas and got the effect I was loking for, I was nit after a Laser beam effect more like a rope between 2 stationary objects.

The image below is from the media that came with DBP but any image will work



kfoong
23
Years of Service
User Offline
Joined: 28th Jan 2003
Location: Australia
Posted: 2nd May 2003 03:22
dr doomer you are right ofcourse, and i did not think of it that way. It looks like i need a few more years of programming . But you missed out one thing. How would you find the angle of the cylinder if the Ys' of the two objects are not the same? Like i said before you might need to do some sin, cos, and tan things

--------
http://www.stellarblue.vze.com/
Dr DooMer
23
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 2nd May 2003 15:31
What do you mean, if the Y's are not the same? Do you mean the Y position?

It's easy - you use the point object command to point the cylinder towards one of the two objects, and hence set the angles regardless of how the two objects are positioned. Since it's scaled to be exactly the same length as the distance between the two objects, it should then appear to be touching each of the origins of the objects.

Although, there is actually one problem - when you create a cylinder, the 'front' of it is actually on a curved part, not one of the caps. There is a way to fix this, though: after creating the cylinder, zrotate it by 90 degrees, so it's on it's side, and then run the fix object pivot command on it. That should now make either the top or bottom of the front.

Heh, it's so easy to miss little things like that while your typing.

"I am a living, thinking entity who was created in the sea of information."

Login to post a reply

Server time is: 2026-07-11 09:30:28
Your offset time is: 2026-07-11 09:30:28