Important alert: (current site time 7/16/2013 3:15:27 AM EDT)
 

winzip icon

VoxelSpace - Realtime 3D using Native VB

Email
Submitted on: 4/19/2001 9:41:46 AM
By: Wolfgang Kienreich  
Level: Intermediate
User Rating: By 22 Users
Compatibility: VB 6.0
Views: 29704
author picture
(About the author)
 
     VoxelSpace is a 3D demo based on classical voxel rendering algorithms. VoxelSpace features 3D terrain rendering using 24bit depth, texture mapping, dynamic lighting, atmosphere effect, animated water, semitranslucent overlays and more. VoxelSpace has been developed in pure Visual Basic, though some external library calls to the win32 api have been un- avoidable. System Requirements: The faster your machine, the faster a framerate you will get. No OS restriction (works fine with NT), no libraries (forget DirectX, OpenGL or someone elses dlls). No display restrictions. Runs at 20+ fps on a P266. Note: Always evaluate the compiled executable, running the application from within the VisualBasic environment is too slow and guarantees frustration! Note: ALWAYS RUN IN 24bit OR 32bit COLOR MODE!

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 5 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

4/19/2001 10:13:12 AMMike Canejo

Now this is a good piece of work bro. Good job...
(If this comment was disrespectful, please report it.)

 
4/19/2001 11:09:20 AMEric Tomlinson

This keeps crashing under NT 4.0 WS service pack 6.0a. It crashes in the Render sub on the last line of code on the copy from memory. It seems like a viable system but I do not know enough about graphics programming (yet >. Please let me know what could possible be crashing this. I am very interested in learning more. Thanks
(If this comment was disrespectful, please report it.)

 
4/19/2001 11:16:42 AMAlmar Joling

Hehe, what a coincidence, I just started my own project yesterday, and downloaded tons of source code, about bilinear filtering and heightmapping, and now I see this?!

Thanks for sharing
Almar.

(If this comment was disrespectful, please report it.)

 
4/19/2001 1:54:16 PMSimon Price

That's amazing! NLS keeps coming out with the best stuff! These are the best graphics I've ever seen in pure VB code. Just to back up what you already said: everyone make sure you run in 24 or 32 bit color, otherwise it looks very very different and starts writing into invalid memory as I found out the hard way...
(If this comment was disrespectful, please report it.)

 
4/19/2001 2:25:59 PMAlmar Joling

On my Win2k it didn't start, until I changed from 16bit to 32bit... so I know what you mean =-)

(If this comment was disrespectful, please report it.)

 
4/19/2001 6:05:26 PMElvir Bahtijaragic

Sorry mine says, Sub-script not found. Any thoughts?
(If this comment was disrespectful, please report it.)

 
4/19/2001 6:44:24 PMDerek

Great stuff
(If this comment was disrespectful, please report it.)

 
4/19/2001 8:53:16 PMMarkS

I'm in the same boat as Eric re the crashing in NT 4 with SP6a.

Any ideas?
(If this comment was disrespectful, please report it.)

 
4/20/2001 12:44:12 AMRobert Rayment

Yes works fine (the subscript error is because not in 24 bit color), I've written some David Brebner stuff myself but you've managed to add some nice effects 5/5

(If this comment was disrespectful, please report it.)

 
4/20/2001 3:16:14 AMNLS - Nonlinear Solutions

Hi there,

let me first thank you for the positive feedback. I felt that David Brebners original voxel code could use some updating, as modern machines can easily handle bigger viewport, full color depth and advanced effects. In addition, his code has been too close to C++ for my taste, this is not how VB is ment to be used, imho. Again, glad you like it.

For the color mode problems, I can only emphasise YOU HAVE TO USE MORE THAN 16BIT COLORS. 16 bit mode would be next to impossible to handle, all the bit extractions necessary and the various subformats would take up much too much frametime. And remember, for the gfx card, 16 bit is actually slower than 24 bit.

Have fun with VoxelSpace

Wolfgang Kienreich
NLS - Nonlinear Solutions
(If this comment was disrespectful, please report it.)

 
4/20/2001 3:26:47 AMCodeChief

Runs nice on my machine, under NT. Could you make some solid objects appear in the scene?
(If this comment was disrespectful, please report it.)

 
4/20/2001 6:38:07 AMHayati TASTAN

Very good job! Runs on Win2K w/SP-1.
(If this comment was disrespectful, please report it.)

 
4/20/2001 8:43:28 AMmagic

When I started your program I got the following error message.

The instruction at "0x77f64d8a" reference memory at "0x043afffd".
The memory could not be "read".

I'm still new to VB. Could you please advise?
magic1521@hotmail.com
(If this comment was disrespectful, please report it.)

 
4/20/2001 8:46:25 AMSteve Henning

Great Code!!!!
For those of you getting a memory exception error, do the following.

Open the Forms code, goto the Render Sub.

Select & Cut the line:-
Dim L_bytDat() as Byte

Goto the top of the code, and paste the line below the Option Explicit

The reason why the program is crashing is that the L_bytDat if left in the Render sub has not be initialised, it is actually intialised in Form_Load, as to why the VB compiler is not complaing about it not being declared is a mystery as Option Explicit is there.

Save the file and run the program.
You may get an exception when exiting the program (by pressing ESC)

I compiled it and did not get any memory exceptions even when exiting, it also runs faster as an .exe
(If this comment was disrespectful, please report it.)

 
4/20/2001 8:46:39 AMMel Grubb II

It doesn't work for me at all. I get a subscript out of range error on line 151 of frmV. Graphics settings don't seem to make any difference. I'm running on NT4 sp6.
(If this comment was disrespectful, please report it.)

 
4/20/2001 9:56:13 AMPooh

Excellent job!

5 Big ones from me as well!
(If this comment was disrespectful, please report it.)

 
4/20/2001 11:15:55 AMNLS - Nonlinear Solutions

Hi again!

Let me first ask those of you who have NT4 SP6 to search for the error ... obviously VoxelSpace is not working under this OS, and I cannot figure out why. Any help would be appreciated!

Second, let me note that the solution Steve Henning is offering above is not valid. The declaration of L_bytDat in FORM_MAIN is unnecessary, I just forgot to remove it. And L_bytDat doesnt have to be initialised in sub RENDER ... its filled by that array-points-to-memory trick, not by VB. Strange it made any difference for Steve.

Hope this helps,

Wolfgang Kienreich
NLS - Nonlinear Solutions
(If this comment was disrespectful, please report it.)

 
4/20/2001 1:12:45 PMMercior

This doesnt work in 32 bit color and for some reason my geforce aint giving me the option to use 24 bit color. any help?
(If this comment was disrespectful, please report it.)

 
4/21/2001 7:38:51 AMMike Canejo

I got this to work and it is really great. Good job. Oh and for simon price, your directx 8 tutorial is very good! well, time to sleep ;]
(If this comment was disrespectful, please report it.)

 
4/21/2001 7:39:46 AMMike Canejo

reupdated my excellent vote ;]
(If this comment was disrespectful, please report it.)

 
4/22/2001 5:44:26 AMNiall Mooney

Excellent GFX demo!
(If this comment was disrespectful, please report it.)

 
4/23/2001 2:57:47 AMThushan Fernando

Non Linear Solutions always makes Awesome engines... Congrats.... YET AGAIN..!! Awesome!
(If this comment was disrespectful, please report it.)

 
5/5/2001 10:01:31 PMTerry Smith - Clarion Clipper and Visual Basic

Ok - it wont run in the ide with my NT sp 6 but it does run compiled when i set graphics up to truecolour... thanks for a fine bit o work
(If this comment was disrespectful, please report it.)

 
5/6/2001 3:56:05 AMXnipher

NLS, is the best when it comes to 3D Graphics Applications. The TrueVision3D is a no match to NLS. All of NLS Sample Codes is very easy to learn and actually works unlike the Samples of TrueVision which is definitely a non-working code and very complicated to learn. To NLS 5/5 Globes for you!!!
(If this comment was disrespectful, please report it.)

 
5/11/2001 6:08:05 AMAlastair Vance

I get a "Subscript Out Of Range" on
' Translate into altitude
For L_lngIndex = 0 To UBound(I_bytAlt)
I_bytAlt(L_lngIndex) = L_bytTmp(L_lngIndex * 3)
Next
(If this comment was disrespectful, please report it.)

 
5/11/2001 6:10:24 AMAlastair Vance

Forgot to mention, I'm using Windows 2000 professional.
(If this comment was disrespectful, please report it.)

 
5/23/2001 4:28:19 PMRyan

im running windows me and it doesn't work. got subscript out of range error
(If this comment was disrespectful, please report it.)

 
5/24/2001 9:38:51 AMPhil

I think the problem with the NT4 O/S is because the program may be writing into areas reserved by NT4, so it depends on your NT4 setup. Works a beaut on '98 2nd edition tho'.
(If this comment was disrespectful, please report it.)

 
5/29/2001 3:26:35 PMgridrun

yea dude. it wont work. subscript out of range while translating something into altitude data. its mentioned above. *sup wif that dood???* =P
(If this comment was disrespectful, please report it.)

 
8/5/2001 3:40:22 AMADI BARDA

NO LESS THAN AMAZING!!! i program directx7 in c++ and i must tell your demo is just great! It works very good and the coding standard is very high. Cheers! adi barda israel
(If this comment was disrespectful, please report it.)

 
8/5/2001 7:13:28 AMCoyote

Win 2K sp2 - VB6 sp5 - 32 bit Would not run for me. Crashed... HOWEVER- compiled it and it ran great..Until.. I noticed no way to end it except thru Task Manager.
(If this comment was disrespectful, please report it.)

 
8/5/2001 9:05:28 PMaustin agarwal

it dont work under windows 2k sp2. It makes vb crash.
(If this comment was disrespectful, please report it.)

 
5/22/2002 12:37:48 PMChad Bjorklund

Uhh, this is probably a bad idea but for those of you with the memory problems, if you want a quick glimpse of the program, just add "on error resume next" right above the line that contains the out of bounds error. For me, the program ran a few seconds then vb went up in smoke but the little I saw was pretty cool. Good luck.
I wish I was as smart as NLS, then I would be cool
(If this comment was disrespectful, please report it.)

 
12/9/2002 11:41:47 PMAkshay Peshave

I think Wolfgang is really a genius !
(If this comment was disrespectful, please report it.)

 
11/23/2003 9:43:18 PMPatrick Weber

Very slow and pointless...
(If this comment was disrespectful, please report it.)

 
3/9/2004 2:13:21 PMMathieu Chartier

Patrick What r u smoking?, this is great i got 7 fps in IDE which is AWSOME, compiled i would get like 120
(If this comment was disrespectful, please report it.)

 
7/23/2005 6:51:47 AMSPY-3

This is the first project i have seen so far tha thas 3D without the use of directX great work and it would be nice to have more objects to test it out like trees and such. Still great work 5 globes!!
(If this comment was disrespectful, please report it.)

 
9/24/2008 1:26:12 PMFurkan

Keep crashing on Windows Vista even the DWM (Desktop Window Manager a.ka. Aero) turned off with 32bit color.
(If this comment was disrespectful, please report it.)

 
5/4/2010 5:31:34 AMadel elkabany

wow , well done
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.