The goal of this project is to create an easy to use, class-based, .Net compatible version of Voxlap.
This version already includes a big amount of useful voxlap functions.
The VisualBasic.Net sourcecode of two simple demo games is included in this archive.
Please check it out and post all problems, bugs or suggestions here.
You'll need to have the .Net Framework 1.1 and DirectX 9.0c installed to run this Demo! Look at the readme.txt for more detailed information.
Download the Voxlap.Net Alpha1 HERE!
Modifications since the Demo1 release:
- Collision detection
- An Object class to define position and rotation of objects in the voxel world
- Sprite and SpriteObject Classes (for VoxelSprite support)
- More control over the voxel color through custom drawstyles
- A default Weapon class to make weapon-creation easier (you don't have to use it)
- Sound (in Demo2)
- Full Visual Basic .Net 2003 Project of a second, ego-shooter like game included
- And many more minor things...
I've ported my old particle-based 2d physics system to 3d to use it with voxlap and it already works, but due to some nasty bugs i've decided not to include in in this release. Maybe next time.
I'm thinking about switching this project to VB.Net2005, 'cause you can download and register VB.Net 2005 Express for free (!!!) at http://msdn.microsoft.com/vstudio/express/vb/. I'm still a little sceptical about it (especially performance-wise). What do you think about it? [EDIT] Voxlap.Net is already compatible to the new .Net 2.0 languages. Just my Sound Engine is not. If you want to use it with one of the Visual Studio 2005 Express Editions just tell me and i'll upload a working version.
Voxlap DLL Demo
Okay, to make Raedwulf a happy man: I've uploaded the full Sourcecode (a MSVC 2005 Project) of a working Voxlap DLL.
All modification made since the original voxlap code:
- WinMain function splittet up into a bunch of functions to get the MainLoop out of the DLL. (those functions are at the same location in winmain.cpp)
- Added some __stdcall's to export the functions
- Added a dll_core.cpp containing all other needed (or helpful) functions. It is based on game.c
A simple MSVB 2005 Project that is using the resulting DLL is included in this Archive to demonstrate the usage.
This DLL exports only the most basic Voxlap functions, but adding more functions yourself shouldn't be a problem.
Try to compile and use the DLL before modifying it, to make debugging easier for you!
WARNING: The functions added by me instead of WinMain are without any Input or Sound code! Therefore it will only work when using NOINPUT and NOSOUND options! If you want to reactivate Voxlap's Input or Sound functions you'll have to compare my functions with the original WinMain function and copy all missing Input and Sound stuff to my functions. Remove the NOINPUT and NOSOUND options afterwards.
You can download it HERE!
Edited at
Maximus at
WOW!
Good effort! I'm glad some one has released something! Tis an iteresting choice, using VB.Net, but like you say it should encourage people to do more 'stuff' with VOXAP. Will give it a good going over when get some free time.
One last thing, have/will you incorporate any threaded tech? I'd really like to see how this might improve the performance of VOXAP. Thing is what do you put in the seperate threads? I can think of three suited to your code :
1 - Drawing
2 - VB interface
3 - Low level management... memory, physics
Hazard at
Ah, nice to see that anyone cares. :)
IMO it's more fun to play around with Voxlap using a class-based VB.Net environment. It's more intuitive for non-professionals 'cause you don't need to care about Voxlap's internal functions.
BTW: You can use Voxlap.Net with any other .Net language (like C#), too.
Multithreading isn't on my ToDo list for now. Maybe later. At the moment my priority is to get a stable and function-rich version of Voxlap.Net done.
I'll release a second (more complex and advanced) demo in the next days inclunding a many times more powerful version of Voxlap.Net
Raedwulf at
Hey cool :)
I'll have a look at it...how did you implement it?....
My dll kept getting into a endless loop...I haven't managed to get back to itso far.
Hazard at
The Winmain function contains the voxlap main loop. i moved the loop to my vb.net class and splitted the WinMain function into Init, StartFrame and EndFrame functions that get called from my own VB loop.
Use the DllMain function to get the InstanceHandle (ghinst) so you don't have to pass it from VB to the DLL.
Raedwulf at
Ahhh i see....so you didn't port winmain.cpp - you just wrapped that as well into a dll?
I'll have to get back home and test with your wrapped dlls... I don't have my code here - in college...damn :P.
Hazard at
Yes, winmain.cpp cointains all the Window, DirectX and drawing routines. Rewriting all this in VB would be very time consuming and would surely result in very crappy framerates. just wrap all (!!!) the voxlap code in a DLL. I've even included game.c 'cause it is easier to port all code to VB this way and it already has some very useful functions in it like the handling routines for falling objects.
Raedwulf at
hehe ok
Just curious - did I send you a copy of my voxlap.dll(I can't remember) or did you compile it - a weird coincidence is that both my dll and your dll are of the exactly same size - however I used msvc 2005 - but perhaps they generate similar executables anyway.
Hmmm im not sure if the framerates would suffer too much but I might just wrap it into a dll anyway. However I wanted to rewrite it because I couldn't get the sound working. But nvm Ill try what you did.
Hazard at
No, i've compiled the DLL myself based on a modyfied version of voxlap (as said before).
The same size? Very strange. The exact same number of bytes? I don't think MSVC uses a default DLL size. I've used MSVC 2003, btw.
The Sound didn't work for me too. But i'm using my own code for Input and Sound functions. Voxlap.Net is "only" used for Voxel handling and graphics output.
Raedwulf at
Could you post your voxlap.dll code for me - or send it to me via email(tcmreastwood 'at' ntlworld.com ) because I can't seem to get mine working. It works so far but it seems to hang with loadvxl. If you could - that'll be great :)
Cheers
Hazard at
Posting all the code wouldn't help you much, but here are the core functions to replace WinMain with. After calling InitVoxlap2 you should be able to call all voxlap functions like loadvxl.
[EDIT]None of the Input and Sound code is left in this sample. You could copy these parts from WinMain or use the compiler options NOSOUND and NOINPUT to get this running.
/* *** VB.Net Test Loop Sample ***
Public Sub TestLoop()
If vDLL.InitVoxlap2() Then
vDLL.InitWindow(1024, 768, 32, 0)
Do While isRunning
If vDLL.StartFrame() Then
' Custon VB drawing functions
vDLL.EndFrame()
End If
vDLL.DoActions()
'Custom VB movement functions
Loop
End If
End Sub
DllExport int __stdcall InitWindow(int width, int height, int colorbits, int isFullscreen){
xres=width;
yres=height;
colbits=colorbits;
fullscreen=isFullscreen;
cputype = getcputype();
if (cputype&((1<<0)+(1<<4)) != ((1<<0)+(1<<4)))
{ MessageBox(0,"Sorry, this program requires FPU&RDTSC support (>=Pentium)",prognam,MB_OK); return(-1); }
Well I was hoping for an email-attachment of the project for recompiling the dll...:)
But anyways - I have time to mess around with it now i can work at it at college
Cheers
Raedwulf at
Ken - could you shed some light on this mystery for me?
I compiled a dll and it keeps getting a loopin the loadvxl function
However, I'm not too sure about the cause of this - it seems to get stuck in this loop
for(i=0;i<VSID*VSID;i++)
{
sptr[i] = v;
while (v[0]) v += (((long)v[0])<<2);
v += ((((long)v[2])-((long)v[1])+2)<<2);
}
Actually in the -
while (v[0]) v += (((long)v[0])<<2);
I know it works in the normal exe version of your project - but with my modified dll version (though I think I haven't changed anything here) - it gets into an endless loop.
Do you know of any possible cause for this?
Cheers.
Awesoken at
That looks like a problem with signed char vs. unsigned char. In this case, v must be unsigned char *. Ever since my Watcom C days, I got used to the convention of char defaulting to unsigned. Nowadays, I usually put /J on the Visual C command line and forget about it.
Raedwulf at
Thanks KEN!!! :) It works with no problem now! :) You're a genius. :)
Hmmmmm....
Cheers!
yuriks at
ACtually i would say that Ken is a coder with bad habits ^_^
Raedwulf at
Bad habits with good intentions make a good coder :).......hmmm does that make sense?
Raedwulf at
Oh well...ill wrap winmain.cpp in a dll as well - a lot more quicker to implement everything that way :)
Hazard at
I've uploaded a new version of Voxlap.Net including two little demo projects. Look at the first post in this thread for further information.
Raedwulf at
Hi Ken - messing things up with my voxlap dll again :)
I get an error in opticast -
gstartv = (char *)*(long *)gpixy;
so, gstartv is = 0
So there is a memory error trying to read from 0 at the line
if (glipos.z >= gstartv[1])
I was wondering what sptr points to (is it the screen buffer? - is it related to frameptr?)
Cheers....hopefully my voxlap dll will work eventually :)
Awesoken at
Voxlap supports variable size columns. In order to support this, I have a 1024x1024 array of pointers that point to the start of each x-y column. This is the sptr array. The voxel data is stored in the 64MB vbuf array.
Either you didn't load a voxel file, or your position (gipos) is out of bounds. My guess is you forgot to call setcamera() to set the position before opticast().
Raedwulf at
Thanks, Ill check that when I get home :)
I think I might not have called setcamera properly - if so I'll be happy to say that I've exported probably all the functionality of the voxlap engine in a dll :).
Unlike Hazard - I'm leaving out the game code because I feel its more appropriate to write a game from 'scratch' rather than borrowing your game code.
I only consented to using your winmain.cpp code because I'm have little idea how to do dx code - and the tutorials i was reading didn't seem to have what i needed to duplicate your winmain.cpp.
Hazard at
Raedwulf said
Unlike Hazard - I'm leaving out the game code because I feel its more appropriate to write a game from 'scratch' rather than borrowing your game code.
Well, i chose this way to make it easier. At first i had the whole game in the DLL to ensure that it at least runs. Afterwards i took more and more functions, implemented them im VB.Net and removed them from the DLL. Now, all game related code is in VB.Net and all stuff of it left in the DLL are the more-or.less timecritical things like debris und falling code.
Raedwulf at
Ahhh ok :)
I just rewrite simple.c to test whether it runs :) Btw...have you got sound working ? - my sound still doesn't work for me.
Hazard at
No, i used my own DirectX9 Sound Engine. I'm a fan of a modular engine design (one module for each purpose like sound, graphics, physics, inputdevices, etc.) and therefore i've removed all input and sound code from voxlap.net .
Raedwulf at
ok i see :).
Hazard at
Okay, to make Raedwulf a happy man: I've uploaded the full Sourcecode (a MSVC 2005 Project) of a working Voxlap DLL.
All modification made since the original voxlap code:
- WinMain function splittet up into a bunch of functions to get the MainLoop out of the DLL. (those functions are at the same location in winmain.cpp)
- Added some __stdcall's to export the functions
- Added a dll_core.cpp containing all other needed (or helpful) functions. It is based on game.c
A simple MSVB 2005 Project that is using the resulting DLL is included in this Archive to demonstrate the usage.
This DLL exports only the most basic Voxlap functions, but adding more functions yourself shouldn't be a problem.
Try to compile and use the DLL before modifying it, to make debugging easier for you!
WARNING: The functions added by me instead of WinMain are without any Input or Sound code! Therefore it will only work when using NOINPUT and NOSOUND options! If you want to reactivate Voxlap's Input or Sound functions you'll have to compare my functions with the original WinMain function and copy all missing Input and Sound stuff to my functions. Remove the NOINPUT and NOSOUND options afterwards.
You can download it HERE!
Raedwulf at
Thanks mate :).... - it'll help me work out whats wrong witrh my version :).
Cheers.
Raedwulf at
Hmmm interesting - i've made my dll export everything...so once i've figured out my dll problems - ill upload mine :).
Maximus at
Is this thread still alive?
Are you still improving the .NET solution to the voxel engine?
I do hope so!!! I really want to get your code working on my machine (no luck on first test) so that I can just start producing lots of quick demos with the voxel engine. Having the .NET modular system will lend itself to this, so that I don't have to remove code that I start for an idea that is then dropped.
I'm not nearly focussed enough to keep to one project and your code may be the solution... ... ...
Hazard at
Maximus said
Is this thread still alive?
I'm not working on this anymore, but you may post some details of your problems so we can try to solve them. Which Visual Studio version do you use?
Maximus at
Visual Studio .NET 2003 Pro - We got a free copy from our computer science degree program :)
I did just realise that I don't have the VB option installed... so this is probably my problem... ... :oops: