• ### Question

• is there a formula or a way to get a line trough a predefined corner of an object, so you can connect all the endpoints to get a shadow?
like this here:

and then create the shadow with those points:

and here a perfect version of how the shadow should look like:

Live for nothing, OR CODE FOR SOMETHING!
• Edited by Sunday, August 30, 2009 10:46 AM
Saturday, August 29, 2009 10:14 PM

i.e following vectors from a light source to objects.  If the geometry is very simple, then the ray tracing can be simplified like Fremy's equivalent triangles, but then when you extend it you need to revert to the underlying principles of ray tracing.

No answers that are simple and general.  Either general (ray tracing and vectors) or simple (equivalent triangles for example).

Ray tracing is the true solution. Here's the principe of ray tracing applied to a polygon. Dudeson, if you want to work with other kind of surfaces like circles or ellipses, you'll need to consider them as polygons with many faces (let's say, a polygon with 30 faces). You can then apply the same idea as in the document here : http://cid-201f3835d49587fe.skydrive.live.com/self.aspx/Public/Small%20Basic/Shadows.pdf

If you want true ray tracing, you'll need to draw a lot of lines. The prinicipe is very simple. It's like this image.
http://cid-201f3835d49587fe.skydrive.live.com/self.aspx/Public/Small%20Basic/raytracing.jpg
Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
Monday, August 31, 2009 9:16 AM

### All replies

• See my previous post on how to calculate the equation of a line passing through 2 points.  There are no magic answers, just relatively simple 2D geometry.

To post an image it must first be uploaded somewhere on the web, say MS skydrive or your website.  Then use the HTML editor option of the post edit to do the following.

Sunday, August 30, 2009 9:51 AM
• These kind of models use 'ray tracing' i.e. following the path of light with vectors, reflecting, adsorbing and transmitting according to objects and their properties in their path.

While you can do this in SmallBasic for simple cases, in general it will be too slow and not the best environment for all but the simplest cases.  It is however a good place to 'get to grips' with the geometry and maths as a learning exercise.  But for a SmallBasic game I would avoid these complexities and concentrate on good gameplay, using good images and sounds and smooth play.

Other alternatives for games development using such as DirectX or GDI, or software libraries for graphics (Dark, VTK etc) have big learning curves.  I suggest you continue with your SmallBasic zombie project, but as a side line also look at one of the MS Express2008 languages, VB, C# or C++.  These are all similar as a starting point (big and confusing), but there is plenty of support and books available (much more than Small Basic for example).  Perhaps check out the support forums (MS and others) and books before choosing.  With your enthusiasm and interest to experiment I am sure you will make good progress.

Scratch->SmallBasic->MS Express->?.
Sunday, August 30, 2009 7:52 PM
• hehehehe, thx! but i didnt want to actually make raytracing.. just the shadows... ^^ but is there a way to code something like that??
Live for nothing, OR CODE FOR SOMETHING!
Sunday, August 30, 2009 8:00 PM

i.e following vectors from a light source to objects.  If the geometry is very simple, then the ray tracing can be simplified like Fremy's equivalent triangles, but then when you extend it you need to revert to the underlying principles of ray tracing.

No answers that are simple and general.  Either general (ray tracing and vectors) or simple (equivalent triangles for example).
Sunday, August 30, 2009 8:08 PM

i.e following vectors from a light source to objects.  If the geometry is very simple, then the ray tracing can be simplified like Fremy's equivalent triangles, but then when you extend it you need to revert to the underlying principles of ray tracing.

No answers that are simple and general.  Either general (ray tracing and vectors) or simple (equivalent triangles for example).

Ray tracing is the true solution. Here's the principe of ray tracing applied to a polygon. Dudeson, if you want to work with other kind of surfaces like circles or ellipses, you'll need to consider them as polygons with many faces (let's say, a polygon with 30 faces). You can then apply the same idea as in the document here : http://cid-201f3835d49587fe.skydrive.live.com/self.aspx/Public/Small%20Basic/Shadows.pdf

If you want true ray tracing, you'll need to draw a lot of lines. The prinicipe is very simple. It's like this image.
http://cid-201f3835d49587fe.skydrive.live.com/self.aspx/Public/Small%20Basic/raytracing.jpg
Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
Monday, August 31, 2009 9:16 AM
• Here a true Ray Tracing program made in Small Basic. Please note it's NOT optimised. I should have been used Controls.GetAllShapes and the walked only zone where it's possible to have a shadow, but my code run relatively fast (5/10 seconds to generate all shadows on my computer) and is only here to show what's the Ray Tracing method.

Check here : GKQ375

BTW, please note you'll need the latest version of my extension (v2.2) to have this sample to work.
Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
Monday, August 31, 2009 12:40 PM
• Here a true Ray Tracing program made in Small Basic. Please note it's NOT optimised. I should have been used Controls.GetAllShapes and the walked only zone where it's possible to have a shadow, but my code run relatively fast (5/10 seconds to generate all shadows on my computer) and is only here to show what's the Ray Tracing method.

Check here : GKQ375

BTW, please note you'll need the latest version of my extension (v2.2) to have this sample to work.
Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
sry, but i dont have your extenstion...

Live for nothing, OR CODE FOR SOMETHING!
Tuesday, September 1, 2009 9:27 AM