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 / Dark Basic and Laser Ray Tracing

Author
Message
JohnFP
20
Years of Service
User Offline
Joined: 5th Feb 2004
Location: Maryland
Posted: 5th Feb 2004 18:20
Hi, I am new to the board and new to Dark Basic. I bought it to get my son (10 yrs) introduced to programming. He loves it and the tutorials are easy to follow.

I have some basic programming experience and am pretty good in math and physics but not an expert. Here is what I would like to know. I would like to write code such that I can build a table and have a laser on it. Then I would like to be able to drop a mirror on the table in the path of the laser beam and see where it reflects when I change the angle of the mirror. I would then like to be able to put a lens with known physical properties in the path and view how it would diffract the beam, that is, see how it causes the beam to diverge or converge.

Is this all possible with dark basic? Is there anyone out there that is doing a similar program that would not mind advising me?

Thank you in advance and have a good day!

John
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 6th Feb 2004 03:49
Hi JohnFP,
That's awesome that you're introducing your son to programming. I don't know of anybody who is doing that sort of thing (but heck, I don't know very many people so there's bound to be someone).

First I must ask, are you planning on doing this using 2d or 3d graphics? Just for kicks I'll write down concepts for both.

3D:
Your first step would probably be to make your table, mirror, lens, and laser generator thing (if you want that in there) in a modelling program like JTEdit or Milkshape3d. There are many expensive programs that do this, but then again for what you want to do you can probably use just free modellers.

To create your laser beam, you just use one of the primitive object commands in DB like MAKE OBJECT BOX, or if there is a 3d line commands that would work as well. You have your beam extend from its starting point and continue until you detect collision with the mirror. Then you put some of your physics knowledge to work and figure out how the beam would reflect. Then you just perform the same checks in loops and add input controls to change the angle of the mirror. When the beam goes through the lens, you must have either a new graphic or set of code that acts up when the beam goes through the lens.

To make the calculating of angles and all that easier you could use Nuclear Glory's collision .dlls. These add on to DarkBASIC's somewhat mediocre collision commands and has features like gravity, multiple object collision, ray casting, and angles of collision (pretty much does reflection for you). This costs $15, and there is a fully functioning demo from [href]http://nuclearglory.com]/href] that works for about 2 or 3 minutes.

To achieve this effect in 2d would be easier, just think in two dimensions, NuclearGlory dlls won't help here, and you can do all your graphics in something like MS Paint. There is also the LINE command which could make your beam.

Start by creating all the graphics you'll need. Then work on getting the laser to reflect off the mirror. After you grasp how that works, then work on controls for the mirror, and changing the reflection as the mirror moves. Finally, add the lens and plunk through the diffraction algorithms.

Hardware and programming languages have a distinct set of features and routines. The tough part is combining these different features and routines to create the effect that you want.

Good luck, and keep posting,
Crazy Donuts

p.s.3d Modellers

JTEdit- Nice and free, doesn't have all the fancy features, but definitely delivers. Animation support

DeleD- Mainly a level editor, haven't fully explored it though. Don't know about animation support.

Wings3d-Freeware modeller version .98. No animation support

Gmax- free, you'll need to download some exporter tools for this, but it's worth it if you don't want animation.

Blender3d- free, Plenty of features including animation, just really hard to use.

Milkshape- Shareware, $25. The cheapest that gives you the features you need to make games and other things.

Juvenile Industries
Current Project: KillZone(FPS)
Soon to come:An rts, and a snowball fight game
JohnFP
20
Years of Service
User Offline
Joined: 5th Feb 2004
Location: Maryland
Posted: 9th Feb 2004 22:56
Thanks for taking the time to respond. I want to do it in 3d as I think that would be more life like. Yes I beleive the modeling programs will suit my needs in the creation of the differt "objects" I want and reflection off the mirror will problably not be impossible. But diffraction may prove difficult.

Peace!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Feb 2004 05:28
For the laser, it would be easier to create an object with a pivot origin at the end of the object, rather than the middle like DB primitives are. It'll make it easier to position and rotate and scale the laser. All you gotta do is find angle of reflection off of the lens, then position the laser object to the lens and point it in the right direction. I've made a small demo of a laser in the showcase. Only difference is you point the laser rather than it reflecting.

"eureka" - Archimedes
JohnFP
20
Years of Service
User Offline
Joined: 5th Feb 2004
Location: Maryland
Posted: 10th Feb 2004 15:53
Is the small demo you mention in the showcase accessible? Can I review it? How do I find it?

I guess it would be only fair to give you some background. I make holograms as a hobby and there are no real nice ray tracing programs out there. What I envision is creating a holographic table in DB that the player can walk around. He will be as big as the mirror mounts. He can drag the mirror in the laser beam and reflect it to where he wants it to go. He can also put a lens in the beam to expand it to the holographic plate. Other optics would be beam splitters, polarizers, cylindrical lenses, spatial filters etc. This would be a great tool for figuring out the next geometric table lay out.

I know this will be a lengthy project but half the fun is the challenge.

Thanks in advance,


John
JohnFP
20
Years of Service
User Offline
Joined: 5th Feb 2004
Location: Maryland
Posted: 10th Feb 2004 16:54
Ok, I think I found it. It is a laser etching program where you write on metal with a laser. Looks very good but I cannot get it to execute. I do not have DB on this computer at all. First I received an error that d3d9.dll was missing. I downloaded it from the internet. Now I get "The procedure entry point DbEntry10 could not be located in the dynamic link library DDRAW.dll".

Would you mind sharing the source code? If not don't worry. I have created the Holographic table and will create the laser (which will not move) and the first mirror soon.
JohnFP
20
Years of Service
User Offline
Joined: 5th Feb 2004
Location: Maryland
Posted: 10th Feb 2004 17:39
Ok, I just downloaded Anim8or modeling program and created a laser. But it seems the only way I can save the file is as an .an8 file. Now, I have to wait till I get home to see if I can import this file somehow as an object.
Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 10th Feb 2004 18:19
For the dll problems, you probably need directx9, go here... http://www.microsoft.com/directx. For animator, there is often an export option in the file menu where you can export to .x/.3ds. Otherwise there are probably convertors somewhere, I know lithunwrap is one but I can't find a site that has it.

Do you bite your thumb at me sir?
The Basics of DBPro Tutorial, on my site now!
Athelon XP 1600 Plus (1.4ghz) - ATI Radeon 9600 Pro - 256mb RAM
Keeling
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 10th Feb 2004 18:25
Go under Object and Export it as a 3d Studio Max (.3ds) file.
JohnFP
20
Years of Service
User Offline
Joined: 5th Feb 2004
Location: Maryland
Posted: 10th Feb 2004 20:01
Thank you, thank you, thank you!!!

Yup, that does it. Here I was going to use DB simple objects as I assumed creating custom objects was very difficult. Because this forum has been so helpful I am really excited about my project. This forum is great. As I progress I will post and share what I am doing, although it may be a little slow to start. I have two computers at home so I can do my work while my sons plays with DB also but I seemed to have misplaced the original CD. So my first quest is to find that confounded CD. I installed the evaluation copy on the second computer and only used it for a day (months ago) and it has expired already. No worries though, if I cannot find the CD I will have to talk my son into building the Holographic table with me. Now where is my old college Geometry and Physics text from the 80's I used to have...Hehe!!!

Peace to you all!!!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Feb 2004 01:56
DBP source for my laser demo.



"eureka" - Archimedes
JohnFP
20
Years of Service
User Offline
Joined: 5th Feb 2004
Location: Maryland
Posted: 11th Feb 2004 15:12
Great, I cannot run it. I believe you must have created it with pro but I can look at your code and get some ideas on the laser beam. Thanks!!!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Feb 2004 23:44
I have source code for classic as well. It's a little bit messier though cause it was the first version. I'll look for it when I get home tonight.

"eureka" - Archimedes

Login to post a reply

Server time is: 2024-11-26 03:43:57
Your offset time is: 2024-11-26 03:43:57