View Full Version : New modules in development?
Michael Hartlef
09-09-2007, 14:08
Hi folks,
are you working on new modules for thinBASIC?
Just to let you know, I started to work on a new module that let you calculate
paths on a user defined grid. The nodes of this grid can have 3D positions and don't
have to be ordered in a regular shape.
Development is going steady and it is another proof that thinBASIC's module concept
is the best thing since sliced bread. ;D Ok, I overdid it here but I'm allways amazed
how easy someone can create new functionality for thinBasic.
Cheers
Michael
Petr Schreiber
09-09-2007, 14:26
This is perfect Mike!
I am sure in cooperation with TBDI and TBGL it will help to create very interesting scripts !
I think you said you have experience with it already, so I am sure it will be another great module.
Bye,
Petr
Michael Hartlef
09-09-2007, 14:46
Yes, it is a much more enhanced version from the days I was developing it for the IBP 2D pak. It will be quite an arsenal of functions to get/set node properties, calculate the cheapest route, calculate costs(distance for an example) between nodes, get the closes node to a position, load, save, etc.!
ErosOlmi
09-09-2007, 15:11
Hey, this is a great surprise !
Wow! I'm really looking forward to seeing this! This will be a great addition to thinBasic, especially for the game developers.
I've implemented the A* (A-Star) path-finding algorithm in a number of languages to gauge the speed of the language, and because I find the algorithm very interesting. I've started developing the same application in thinBasic to see how the speed compares, but since this is my first thinBasic program, it is progressing slowly.
I'm really excited you are developing this module!
I'm also very interested in this type of programming: Steering Behaviors For Autonomous Characters (http://www.red3d.com/cwr/steer/) and OpenSteer (http://opensteer.sourceforge.net/).
I believe your new module will make this type of programming easier.
Thank you, thank you, thank you.
Randall
Michael Hartlef
09-09-2007, 17:41
Hi Randall, thank you!
But don't stop working on a A* implementation as mine isn't A* implementation. I think I based it on Dijkstra's algorithm. It so long since I first worked on it, that I can't remember 100%.
Here is a wikipedia collection of algo's if someone is interested:
http://en.wikipedia.org/wiki/Shortest_path_problem#Algorithms
ErosOlmi
09-09-2007, 22:02
Randall,
for such algo we usually tend to write compiled modules due to necessity to have high speed.
In any case, if you produce something like that in thinBasic, I will be very curious to see results.
In any case, thanks a lot for your contribution here.
Ciao
Eros
Thanks Mike, a paths module, well almost I would call it an ai module is really great news!!
Mike are you allowing for future hooks or tie ins to reacting or setting off triggers? I just wanted to mention it now, as a feature request.
Even thought we don't have a trigger system, it might be nice to plan for one and setup future modules at this level of ai to tie into it.
Anyways thanks for taking on this project. Sounds like it will be very robust and awesome to use!!
...for such algo we usually tend to write compiled modules due to necessity to have high speed.
I can appreciate that. When I first started playing around with the A* algorithm, I created a simple maze solving application using the "C" language. It had a timing feature so I could see how long it took to find the best path through the maze. Later, I created the same application using Visual Basic 6.0. The VB6 application would take 10 times as long as the "C" application to solve the same maze. I then created the same application using Javascript, which took 100 times as long as the "C" application to solve the same maze.
In any case, if you produce something like that in thinBasic, I will be very curious to see results.
I'll be working on it, but it will take some time. After working my full time day job, and working on an old house I am restoring, I don't have too much time for working on it. I'll let you know when I have something to show.
In any case, thanks a lot for your contribution here.
I wish I could do more to help... perhaps in time I can contribute more.
Randall
Michael Hartlef
10-09-2007, 07:39
@Kent: What do you mean by triggers? Remember, you can't run script functions from within a module.
@Randall: Don't worry about contributing. Even your suggestions and ideas are a big help for the ones who work on modules and thinBasic itself. That is what makes this community so special. For an example, take the recent topic about creating textures from memory. A lot of ideas were brought up and I'm sure it will end up in a great addition to TBGL!
Michael Clease
10-09-2007, 09:04
IF i get some time i might look into writing a gfx file format module
jpg to RGB
png to RGBA
...
no point listing all of them.
Just thinking PB or C++, i will only say it make take some time.
ErosOlmi
10-09-2007, 09:42
Abraxas,
that would be a great addition!
Thanks a lot
Eros
Petr Schreiber
10-09-2007, 10:04
Only good messages from tB world :D
That would be great Abraxas,
good luck with your project !
Petr
Michael Clease
11-09-2007, 21:14
What does anyone know about http://freeimage.sourceforge.net/
would that be worth looking at?
ErosOlmi
12-09-2007, 02:30
Yes, of course.
And Mr. Josè Roca (as usual) has already developed Power Basic wrappers: http://www.jose.it-berater.org/smfforum/index.php?topic=82.0
I think FreeImage.inc file produced by Josè can be used in thinBasic quite out of the box. Maybe few changes are needed like define RGB QUAD type and remove the WIN32API.INC include file that is Power Basic related.
Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Maybe someone with some (well, a lot of) free time can have a look ;) and produce some script example.
The biggest problem I see is that FreeImage lib uses callbacks and callbacks are not possible in thinBasic due to its interpreted nature and structure. So a wrapper module is needed.
Ciao
Eros
Michael Hartlef
12-09-2007, 23:04
Abraxas, yeah Kent would like to see such a module for sure. So go for it!
Here is the current commandset for the Path module:
TPath_NodeExist
TPath_AddNode
TPath_DeleteNode
TPath_GetChildCount
TPath_GetChildNode
TPath_AddChildNode
TPath_DeleteChildNode
TPath_GetChildCost
TPath_SetChildCost
TPath_GetNodeCount
TPath_SetNodeActive
TPath_SetNodeX
TPath_SetNodeY
TPath_SetNodeZ
TPath_GetNodeActive
TPath_GetNodeX
TPath_GetNodeY
TPath_GetNodeZ
TPath_GetDist2D
TPath_GetDist3D
TPath_SaveNodes
TPath_LoadNodes
TPath_Init
Now of to the path calucation function, some path retrieving stuff and then documenting everything. That I like the most, NOT! ;) And of course, writing some
sample scripts.
Thanks Mike, I have never worked with pathing commands before, but it looks like a nice list of commands, thanks for the preview list!
Yes, an image handling module would be fantastic Abraxas!
Petr Schreiber
13-09-2007, 08:32
Hi,
path module sounds really cool !
Such a wide command set is promising indeed !
Abraxas, your module idea looks good, only possible trouble is that just FreeImage is over 1 MB DLL, so this could expand size of applications a lot. This is why my implementation of JPG and PNG loader is not here, as I wanted to code it on my own to keep size down. Sadly, currently I have no time resources to do it.
Thanks,
Petr
Michael Clease
13-09-2007, 09:37
I will dig out my file format book and start reading up when i get time which doesnt look too good at the moment.
i was thinking of bmp,jpg,tga,tiff,png.gif.
ErosOlmi
13-09-2007, 14:28
Abraxas, your module idea looks good, only possible trouble is that just FreeImage is over 1 MB DLL, so this could expand size of applications a lot. This is why my implementation of JPG and PNG loader is not here, as I wanted to code it on my own to keep size down. Sadly, currently I have no time resources to do it.
Petr,
why not using GDI+?
OK, it is not defaulted present in OS before Win2K but it will not require any new lib.
If you use dynamic linking (and not static) you will be able to determine if GDI+ is present or not. And consider GDI+ can be downloaded from Microsoft to be used also on Win9X OSs.
Also you only need to make few function just to load JPG (for example) images and convert on the fly to BMP buffers in memory.
The GdipCreateBitmapFromFile seems what you need. Example:
'...
LOCAL hStatus AS LONG
LOCAL pBitmap AS DWORD
strFileName = UCODE$("Any.jpg") ' <-- change
hStatus = GdipCreateBitmapFromFile(strFileName, pBitmap)
'...
What do you think?
PS: as usual, Josè forum is the source of those info: http://www.jose.it-berater.org/smfforum/index.php?topic=259.0
Ciao
Eros
Petr Schreiber
13-09-2007, 15:15
Hi Eros,
you are right, I think José put here some link to GDIPLUS.DLL designed to be bundled.
I will check it, thanks :)
Petr
Michael Hartlef
12-10-2007, 13:36
High folks,
last night I found out that my path module grown some serious problems which I don't understand right now. So please consider it not comming so soon. :-\ I'm very sorry if I made anyone hopes up, but I dicovered a serious showstopper in the algo I created. I'm not sure if I made a mistake in the implementation or if the algo just doesn't work like I think it would. I let you all knwo when I get some clues about it.
Again, I'm very sorry and disappointed :-[
Michael
Petr Schreiber
12-10-2007, 14:05
Are you doing it in IBASIC ?
In PB there is interesting PROFILE statement for quick search of bottleneck procedure ( lists number of calls and time spend in proc ). I am not sure if it works for DLLs, but for EXE for sure.
I am sorry to hear that, I think best is to take a pause now and then try to look at it again after some time. This works for me in most ( worst :) ) cases.
Petr
Michael Hartlef
12-10-2007, 14:14
Its not the bottleneck problem, it calculate the path completely wrong in some cases. But you are right, a little pause might be good. Also studying some more about pathfinding.
Michael Hartlef
12-10-2007, 14:15
And yes, IBasic Pro.
ErosOlmi
12-10-2007, 14:19
Petr,
I can confirm PROFILE command works also for DLLs.
I use it to optimize code. It give you the list of the functions/sub called, how many times and for how long.
In any case I supsect here Mike is talking about something different. It is not time or slow down but some problem in the logic or how the logic is implemented.
I'm just gessing so I can be 100% wrong.
Ciao
Eros
ADDED:
Mike, I wrote reply at same time.