Import help
Blitz3D Forums/Blitz3D Beginners Area/Import help
| ||
Hi! I have to import some files while the main loop is running. Is there any command for starting the import/load window, or is there someway to code a new in Blitz3D? Right now i write a string ( file directory ) to load the files i need, and that is kind of a pain in the neck :( Any help is appreciated |
| ||
What files do you need to import? Is it just data you need to read? or do you need to use Execfile? or Include? |
| ||
I need 3d files *.3ds, *.b3d |
| ||
could you not pr-load and hide them, then show them when there needed? |
| ||
I'm not sure if Blitz3D can use .3ds (can it???) but for the .b3d... LoadMesh("[pathname]\[Filename].b3d") You need to load these during the main loop? unless you have a staggering number, can't they be loaded in prior to the loop, and then just select those that you need. Sorry - I'm just not sure what you actually want to do. Can you be a bit more specific and explain what you actually want to achieve. Maybe even post some code? If you need to use the same mesh many times, CopyEntity or CopyMesh is the best option. |
| ||
I'm not sure if Blitz3D can use .3ds (can it???) If it couldn't, I'd be screwed. ;) |
| ||
"Is there any command for starting the import/load window" What import/load window? And what's such a hassle about writing the filenames of the files you're loading? As mentioned above, please be more specific about what you are trying to do. Malice, loading files from within the main game loop is a standard task for most games (indeed, most software in general.) As with any other task you only want to do once, as opposed to over and over every frame, create a variable to keep track of that task. In your loop check that variable. If the variable is in one state (eg. True) skip that section of code. If the variable is false (or 0 or whatever) execute your loading function, within which files are loaded and the variable is set to true. |
| ||
Uh...Blitz3D supports .bsp, .3ds, .x, .b3d, and .md2 up front, no hassle. There is even a simple library you can download to support .md3's Maybe you should read more over the docs, help and whatnot. Make sure you've downloaded the help/docs pack. |
| ||
For example if you want to load a 3D model into Wings 3D you click File->Load then a new window appears wich lets you search your harddrive for 3D files. That import/load window i mean. Yes i could load all the files from the beginning but that takes more video memory compared to load them when they are needed. |
| ||
This for an editor or something i assume? With regards to the directory structure view, you need to build that your self, but blitz does have commands that easily allow you to do this :) |
| ||
Oh, what you want is a GUI system. This is not built into Blitz3D, but many GUI libraries are available. I use BBGui for my level editors, although I don't know where that is available from now. The Toolbox lists a few. |
| ||
Okey thanks :) i'll try to find a GUI library that suits my program. If i dont find it i'll try write my own. |
| ||
Jippi! i made this "C: Explorer thing" that i will use for importing stuff in my program. It works pretty good i think :); Title AppTitle "Cermit Explorer" Const screen_x = 640, screen_y = 480, bit = 16, mode = 2 ; Graphics Graphics screen_x, screen_y, bit, mode SetBuffer BackBuffer() ; Import Type Type import Field import_nr, import_name$ End Type ; Globals Global current_dir$ = "C:\";Games\";CurrentDir$ Global first_s = 3 ; First Slash In Current_Dir$ String Global lasta_s = 3 ; Last Slash In Current_Dir$ String Global list_y = 0 ; List Top In Current_Dir$ Global list_select = 5 ; Selected File In Current_Dir$ Global list_nr = 0 ; Number Of Files In Current_Dir$ Gosub get_file ; Read Current Dir ; The Code Is Obvious If You Understand What The Variables Are For :) ; Main Program While KeyHit(1) = False ; Move List If KeyHit(200) Then list_select = list_select - 1 list_y = list_select - 5 If list_select < 0 Then list_select = 0 If list_y > list_nr - 10 Then list_y = list_nr - 10 If list_y < 0 Then list_y = 0 EndIf If KeyHit(208) Then list_select = list_select + 1 list_y = list_select - 5 If list_select > list_nr - 1 Then list_select = list_nr - 1 If list_y > list_nr - 10 Then list_y = list_nr - 10 If list_y < 0 Then list_y = 0 EndIf ; Sub Dir If KeyHit(28) Then For i.import = Each import If i\import_nr = list_select Then ; If Dir If FileType(current_dir$ + i\import_name$) = 2 Then current_dir$ = current_dir$ + i\import_name$ + "\" Gosub get_file list_select = 2 list_y = 0 Exit EndIf ; If File If FileType(current_dir$ + i\import_name$) = 1 Then ExecFile(current_dir$ + i\import_name$) Exit EndIf EndIf Next EndIf ; Above Dir If KeyHit(14) Then list_select = 2 list_y = 0 For x = 1 To Len(current_dir$) If Mid$( current_dir$, x, 1 ) = "\" Then first_s = lasta_s : lasta_s = x Next current_dir$ = Left$( current_dir$, first_s ) Gosub get_file EndIf ; Clear Screen Cls ; Draw Import For i.import = Each import For y = 0 To 9 If i\import_nr => y + list_y And i\import_nr <= list_y + 9 If list_select = i\import_nr Then Color 255, 0, 0 Rect (screen_x / 2) - ((Len( i\import_name) / 2 * 10)), 16 + (i\import_nr - list_y) * 12, Len( i\import_name$ ) * 10, 12, 1 EndIf Color 0, 255, 0 Text screen_x / 2, 16 + (i\import_nr - list_y) * 12, i\import_name$, 1 EndIf Next Next ; Current Dir Text screen_x / 2, screen_y / 2, current_dir$, 1 ; Flip Flip ; Program End Wend End ; Get Import List .get_file For i.import = Each import : Delete i : Next dir = ReadDir( current_dir$ ) list_nr = 0 .read_again file$ = NextFile$( dir ) If Len(file$) > 0 Then i.import = New import i\import_nr = list_nr i\import_name$ = file$ list_nr = list_nr + 1 Goto read_again EndIf Return Maybe not the best but it works :) Press Enter To Open a Folder or File Press Backspace To 'Go Back' Scroll List By Pressing Up or Down Cursor |