The Blitz3D 'Export Project' wants YOU!

Blitz3D Forums/Blitz3D Programming/The Blitz3D 'Export Project' wants YOU!

D4NM4N(Posted 2007) [#1]
Prehaps this can be stickied?!?

Possible community project

What i am trying to do:
Compile an entire suite of SOLID, reliable exporters for b3d together in one place(here?) for tools developers (theyre a bit spread out in the codearcs & not all are fully functional).

Im after ones that can save images etc. and mesh ones that can not only simply save a mesh, but export everything exactly 'as is' from a mesh with children, all attached to a parent pivot, complete with as many supported features (all surfs, textures, uvs, normals, color, alpha, blend, fx, specular etc.) as possible/are supported by the format.

If anyone has complete Static & animated exporters for X, OBJ, B3D, COB, LWO, or any others and they work in the way described above, please add, stating the limitations/functions.

Please put all improvement posts/comments in the relevent codearcs pages to keep the topic clean

Importers are also welcome :)

The list so far:
-----------------------------------------------------------
TYPE: STATIC DIRECTX(Complete mesh hierachy) by dan at D-Grafix
www.blitzbasic.com/codearcs/codearcs.php?code=1906

It saves a complete mesh hierachy with texture refs, meshnames, colors, alpha, normals, MT Matricies etc. (cant get rid of specular shininess though (dont know which one it is and shine appears black!)
(thanks to shambler, i used your file template code for a guide to the X format:) Note for blender, remove all texture refs and giles doesnt seem to like the vertex color section (may cause vertex color 'rainbows')

------------------------------------------------------
TYPE: ANIMATED DIRECTX by B32
www.blitzbasic.com/codearcs/codearcs.php?code=1740

Limitations are: meshes don't work without using LoadAnimMesh, because the static versions are all placed at 0,0,0.
Another thing is, that it sometimes exports 'NAN' as a float, and some importers can't deal with it, so they have to be replaced with zeros
And, Blender doesn't load this file, because the Materials tag is incomplete. saves surfs, textures, uvs, normals
doesn't save: color, alpha, blend, fx, specular

-----------------------------------------------------
TYPE STATIC B3D (Single Mesh) by JFK
www.melog.ch/dl/saveb3d_2007a.zip

Can save only one mesh at a time, may be modified (parallel nodes in file). Due to the nature of it, it isn't SOLID nor ROBUST, nor CLEAN or BUGFREE at all, use at your own risk :) At least, it used to save a big map that was exported by giles "AS IS". The source also contains some info on how to save lights that can be read by giles.
There may be a problem with redundant texture references. I doubt it causes a memory leak, but if it does then I'd be glad if somebody's gonna help to debug it. (the problem is mentioned in the code) Make sure to read the notes in the source.


------------------------------------------------------------
TYPE: X & B3D import/export By Devils Child
dc.chat-blitz.de/upload/files/Devils%20Child/[x]port.zip
its a framework with 3ds/b3d/x import and x export.



------------------------------------------------------
OTHERS (Not reported on/sorted yet) thankx b32:


These were all the links I could find in the archives:
Save X
www.blitzbasic.com/codearcs/codearcs.php?code=1906
Save 3DS
www.blitzbasic.com/codearcs/codearcs.php?code=1815
Save Anim B3D
www.blitzbasic.com/codearcs/codearcs.php?code=1794
SaveAnimFile
www.blitzbasic.com/codearcs/codearcs.php?code=1740
SingleFile
www.blitzbasic.com/codearcs/codearcs.php?code=1500
ASC saver
www.blitzbasic.com/codearcs/codearcs.php?code=1033
Save B3D
www.blitzbasic.com/codearcs/codearcs.php?code=866
ASE->B3D
www.blitzbasic.com/codearcs/codearcs.php?code=707
Save .X multisurface
www.blitzbasic.com/codearcs/codearcs.php?code=631
Save .X single surface
www.blitzbasic.com/codearcs/codearcs.php?code=111
Animb3D
www.blitzbasic.com/codearcs/codearcs.php?code=1764
B3D->XML->B3D
www.blitzbasic.com/codearcs/codearcs.php?code=665
import .cob/.scn
www.blitzbasic.com/codearcs/codearcs.php?code=335
Save DDS
www.blitzbasic.com/codearcs/codearcs.php?code=1813
Import OBJ
www.blitzbasic.com/codearcs/codearcs.php?code=1323
Load Giles .gls
www.blitzbasic.com/codearcs/codearcs.php?code=1134
Convert .X/.3DS->.B3D
www.blitzbasic.com/codearcs/codearcs.php?code=342
Save .TGA
www.blitzbasic.com/codearcs/codearcs.php?code=1
Save Stevies format :)
www.blitzbasic.com/Community/posts.php?topic=26973#283228
Save FLE
www.blitzbasic.com/toolbox/toolbox.php?tool=167
Save 3DS
www.blitzforum.de/forum/viewtopic.php?t=20214&sid=9a9fdb3fe33470707f7c5c86e7b63b82
DX8->B3D
www.blitzbasic.com/toolbox/toolbox.php?tool=64




D4NM4N(Posted 2007) [#2]
.


b32(Posted 2007) [#3]
I made an .x exporter too, with animation support:
http://www.blitzbasic.com/codearcs/codearcs.php?code=1740
Limitations are: meshes don't work without using LoadAnimMesh, because the static versions are all placed at 0,0,0.
Another thing is, that it sometimes exports 'NAN' as a float, and some importers can't deal with it, so they have to be replaced with zeros
And, Blender doesn't load this file, because the Materials tag is incomplete.
I have worked on this, but I made it fit my own program. However it would be nice to update it sometime.
saves surfs, textures, uvs, normals
doesn't save: color, alpha, blend, fx, specular


jfk EO-11110(Posted 2007) [#4]
You know it's pretty easy to write a B3D mesh file. It's much harder to obtain information about a brush (fx, alpha, blendmode etc.) or about a texture (blend, flags, scale, rotation...) wich is required when you want to save a mesh that is stored in memory as a blitz mesh entity.

In this thread:
http://www.blitzbasic.com/Community/posts.php?topic=66551
I have released all my current "wisdom" about B3D export in Blitz3D. Based on those infos I used to write a static B3D exporter that actually works well. It is woven deeply into my app code, right now I ain't got the nerves to extract it, maybe later.


b32(Posted 2007) [#5]
I was thinking about writing an .OBJ exporter (lightwave). That format is pretty basic. It would be handy, because there are a lot of programs that can import it. However, it doesn't support much more than basic vertex/triangle information.
And I would like to make a more complete version of the animated .x exporter. Entityshininess/mesh color support would be nice. And maybe use the binary .x format instead of the text version.
Another idea would be making an importer, that converts other formats into .b3d before loading. I believe the newer versions of the .x format support vertex weights? Maybe it is possible to first convert such a file into a .b3d and then load it?
For my own project, the .obj exporter and the animated .x exporter would be handy, so I would mainly like to focus on those.


D4NM4N(Posted 2007) [#6]
sounds a good idea binary would be great to save on huge filesize, but is difficult to debug.

"OBJ (lightwave)"
i though obj was wavefront and lwo was lightwave. could be wrong.


Ross C(Posted 2007) [#7]
Well, i think the main pain about writing a .b3d exporter, was as jfk says, the brushes and textures. I also found a problem with finding the scaling and rotation of textures applied to a mesh. You can obviously read a .b3d file from the hard disc and find it's texture scale and rotation, but it would be a bit hard to read .x and .3ds files for this information.

You would also need the user to store his information, if he's coding an editor, in a certain way, so it can be retreived, because some information cannot be taken from meshes just using the blitz3d commands. Good luck and i'll try and help out when i get home.


b32(Posted 2007) [#8]
I have updated the animated .x exporter. The transform matrix was not exported correctly. So, now the files can be loaded with LoadMesh as well.
www.blitzbasic.com/codearcs/codearcs.php?code=1740


jfk EO-11110(Posted 2007) [#9]
Ross - yes you may read scaling and rotation etc. directly from the file, but I think it' smuch more handy to get them from the loaded entity, this way you can use all the powerful commands, like AddMEsh and so on, and then finally save the entity as it is displayed onscreen (see the thread I mentioned, scale and rotation can be retrieved)


Ross C(Posted 2007) [#10]
I agree jfk. I can at present save a supposed unlimited number of meshes to a .b3d file. BUT, the big problem is the texture list. When saving a .b3d file, you must list all the textures and brushes at the beginning of the file. SO, you'd need to first of all scan through every mesh, grab the brush's and texture's, and store them, then proceed to save.

The actual saving of the mesh(es) is easy and could be easily done with a recursive function. The hardest part is the textures/brushes.

I don't have much of an interest for saving animated entities. You would need the bones and weightings, which are currently not possible to get from the entity structure.


Ross C(Posted 2007) [#11]
Another thought. I remember Beaker mentioning, parenting everything to a parent. Now, upon saving, you simply perform a recursive function, using FindChild. You should be able to search every entity without the use of types.


jfk EO-11110(Posted 2007) [#12]
I think it's possible to save multiple meshes in one B3D file using multiple (nested?) Nodes. Not sure if you can access the meshes as children. I guess you'd have to load them with LoadAnimMesh. Parsing the hierarchy recursively would also allow to seperate pivots from meshes using the EntityClass$(). Not sure if you have to/can nest the nodes.

Personally I never use this, because my editors first use AddMesh to unify the map to a single mesh with an optimized number of surfaces. a modified version of the SaveB3D from the code archives is used. Basicly the addition is little, just obtain the brush and tedxture properties as mentioned and use them instead of the static values of the example.

yes brush and texture was the hardest part, but finally it's done and it works with everything but DDS. when a dds texture is detected, the flags must be set manually cause I would need the TextureBuffer to retrieve the current flags, and that TextureBuffer is always zero with DDS textures.


jfk EO-11110(Posted 2007) [#13]
Ok, here's mine, latest B3D exporter. Can save only one mesh at a time, may be modified (parallel nodes in file). Due to the nature of it, it isn't SOLID nor ROBUST, nor CLEAN or BUGFREE at all, use at your own risk :) At least, it used to save a big map that was exported by giles "AS IS". The source also contains some info on how to save lights that can be read by giles.
There may be a problem with redundant texture references. I doubt it causes a memory leak, but if it does then I'd be glad if somebody's gonna help to debug it. (the problem is mentioned in the code)

http://www.melog.ch/dl/saveb3d_2007a.zip
Make sure to read the notes in the source.

Now, since this thread is sticky and everything, how about somebody collects all links to export sources found in the archives and elsewhere, and lists them here, preferably in the very first post? Thanks.


D4NM4N(Posted 2007) [#14]
Nice one(added it to list above), unfortunately havent had the time to look at it yet :(


b32(Posted 2007) [#15]
He Dan, I updated my exporter, now it is compatible with LoadMesh and I added a Nan removal function.


jfk EO-11110(Posted 2007) [#16]
Oh just realized there's a bug in my code. In the BRUS writing section a brush named lo_bru is created (Using GetSurfaceBrush()). This should be freed after processing, at the corresponding loop end. I'll update the zip, later. :-°


b32(Posted 2007) [#17]
These were all the links I could find in the archives:
Save X
http://www.blitzbasic.com/codearcs/codearcs.php?code=1906
Save 3DS
http://www.blitzbasic.com/codearcs/codearcs.php?code=1815
Save Anim B3D
http://www.blitzbasic.com/codearcs/codearcs.php?code=1794
SaveAnimFile
http://www.blitzbasic.com/codearcs/codearcs.php?code=1740
SingleFile
http://www.blitzbasic.com/codearcs/codearcs.php?code=1500
ASC saver
http://www.blitzbasic.com/codearcs/codearcs.php?code=1033
Save B3D
http://www.blitzbasic.com/codearcs/codearcs.php?code=866
ASE->B3D
http://www.blitzbasic.com/codearcs/codearcs.php?code=707
Save .X multisurface
http://www.blitzbasic.com/codearcs/codearcs.php?code=631
Save .X single surface
http://www.blitzbasic.com/codearcs/codearcs.php?code=111
Animb3D
http://www.blitzbasic.com/codearcs/codearcs.php?code=1764
B3D->XML->B3D
http://www.blitzbasic.com/codearcs/codearcs.php?code=665
import .cob/.scn
http://www.blitzbasic.com/codearcs/codearcs.php?code=335
Save DDS
http://www.blitzbasic.com/codearcs/codearcs.php?code=1813
Import OBJ
http://www.blitzbasic.com/codearcs/codearcs.php?code=1323
Load Giles .gls
http://www.blitzbasic.com/codearcs/codearcs.php?code=1134
Convert .X/.3DS->.B3D
http://www.blitzbasic.com/codearcs/codearcs.php?code=342
Save .TGA
http://www.blitzbasic.com/codearcs/codearcs.php?code=1
Save Stevies format :)
http://www.blitzbasic.com/Community/posts.php?topic=26973#283228
Save FLE
http://www.blitzbasic.com/toolbox/toolbox.php?tool=167
Save 3DS
http://www.blitzforum.de/forum/viewtopic.php?t=20214&sid=9a9fdb3fe33470707f7c5c86e7b63b82
DX8->B3D
http://www.blitzbasic.com/toolbox/toolbox.php?tool=64


jfk EO-11110(Posted 2007) [#18]
Wow, thanks! Finally, that's a lot!


Stevie G(Posted 2007) [#19]

Save Stevies format :)
www.blitzbasic.com/Community/posts.php?topic=26973#283228



What a useless piece of crap that format is! Did it's job for me back in the day though ;)


D4NM4N(Posted 2007) [#20]
Great list, thx


bytecode77(Posted 2007) [#21]
i've been thinking about something like that previously, so i would like to make the framework!

in a few days or today, i will show a demo where we can develop on...

i think we need a name. how about "[x]port"?


bytecode77(Posted 2007) [#22]
http://dc.chat-blitz.de/upload/files/Devils%20Child/[x]port.zip


jfk EO-11110(Posted 2007) [#23]
Before I download (sitting at a linux box here) What exactly is it?

There's also some news about my new AS-IS B3D exporter (see prev. post): Although it saves redundant textures (eg: the lightmap textures may be the same for many brushes, noless it's indexed multiple times), this doesn't seem to be a problem since Blitz will auto-optimize VRam usage, not only when you load a texture by code multiple times with the same flags and settings, but also if it's referenced multiple times in a mesh file.

The point is, a brush is described by texture indexes, so this makes the whole approach somewhat more compicated (or maybe there's a simple solution and I just don't see it right now, however).

I can save myself a lot of debugging work and forget about this. After all, a 2 MB map mesh is only a few kb bigger with this unoptimized texture list, and VRam usage is the same.

At least (unless I made a mistake), it seems to me that's the way it is. Confirmations welcome.


bytecode77(Posted 2007) [#24]
its a framework with 3ds/b3d/x import and x export.
i'm sitting here and implementing more exports!

ps: updated: dc.chat-blitz.de/upload/files/Devils%20Child/[x]port.zip


ShadowTurtle(Posted 2007) [#25]
Hey, jfk EO-11110. You forgot one thing: another 3D engines does not optimize all Object/Mesh/Textures directly after loading. At moment only Genesis3D, the Unreal-Engine (1-3) and Blitz3D does this.


jfk EO-11110(Posted 2007) [#26]
You're right, but then again Blitz3D is the target render Engine for this B3D exporter. I'd like to know how UU3D handles this. Giles for example would not optimize it, but this isn't a desaster since we usually import meshes without lightmaps in giles. After all, this allows to easily export a scene "AS IS" (with all visual fx such as blendmodes, vertex settings etc.) from within Blitz3D. I think currently there's no sustitute for it.

You are however welcome to add a texture list optimizer to the function :) (Index references in the brushes must be altered correspondingly)

DC - sounds good! Keep it up!


D4NM4N(Posted 2007) [#27]
oooh more stuff, cool

added and looking now :)

A real asset would be a dx92b3d bones. this would complement my spriteforge app nicely :)


IPete2(Posted 2007) [#28]
It's funny how threads suddenly get your attention - great work going on here, what a great idea.

IPete2.


bytecode77(Posted 2007) [#29]
here: i've been working on:
http://www.dc.chat-blitz.de/upload/files/Devils%20Child/[x]port.zip


Barliesque(Posted 2007) [#30]
Great work, Devil! :)


D4NM4N(Posted 2007) [#31]
added it :)


Alienforce(Posted 2007) [#32]
Does anyone have any code for bvh ??


jfk EO-11110(Posted 2007) [#33]
There was a release, I named it "bvhdemo_bb.zip" when I downloaded it, not sure if this is the original name.

If you use the advanced search options of yahoo and search for "bvh" on the specific page www.blitzbasic.com then you'll find a lot of bvh discussion topics.

EDIT done some research, the 1st and second host has vanished, so I uploaded the blitz bvh demo here:
http://www.melog.ch/dl/bvhdemo.zip

Not much, a walking guy, using a "walk.bvh" file. (Not by me, BTW)


Alienforce(Posted 2007) [#34]
Thanks jfk.


D4NM4N(Posted 2007) [#35]
Has anyone got ones for avi, gif or mpeg? This would be fantastic if there is such code :D


jfk EO-11110(Posted 2007) [#36]
avi export is in the code archives, in userlibs section.


Leon Drake(Posted 2008) [#37]
i made an XMF/CMF cal3d importer exporter. i have yet to submit it.


Play(Posted 2008) [#38]
Can somobody reupload the Devils Child's [x]port ? ;)


Guy Fawkes(Posted 2013) [#39]
Sorry to bring up an old topic but just because I got sick & tired of seeing the B3D2PMK / PMK2B3D example not working correctly, I decided to fix it for a project I'm working on because I needed animated B3D files exported.

Anyway, without further delay... The code..

b3dfile.bb:



PMK2B3D_example1.bb:



I hope you enjoy!

To use, simply change the location of "file1$" & "file2$".

"file1$" is the location of the mesh you wish to create an exported, animated B3D mesh FROM.
"file2$" is the location AND NEW file name of the exported B3D animated mesh.

NOTE 1: If the textures are not embedded WITHIN the model, do NOT forget to add ALL relevant texture files to the same folder as both the "file1$" anim B3D file, & the "file2$" anim B3D file.

NOTE 2: Milkshape exported, animated B3D models MAY or MAY NOT load. If not, the program will crash. So far, however, I have NOT experienced a crash after fixing this.


Happy Sammy(Posted 2013) [#40]
(bookmarked)


Guy Fawkes(Posted 2013) [#41]
Attention all. After about 5 hours of testing today with the help of a GREAT friend, I have discovered that the function "DumpChunks()" has a HUGE memory leak. After only saving ONE 3D animated, multi-textured dwarf B3D file, we were FINALLY able to narrow the memory leak down to the function, "DumpChunks()". This is a HUGE problem, because the amount of memory for 1 dwarf to be exported is ~ 300/320 MB processing memory. Which is NOT good at all. If anyone could locate, confirm, and destroy this bug, that would be GREAT. I've been at this problem for 5 hours, probably going on another 10 tomorrow.

Thank you all!

Guy Fawkes


RemiD(Posted 2013) [#42]
Ahahah, always the same thing with you, "i have improved the code of another coder, but now there is a problem".
Debuglog("")
Flushkeys()
Waitkey()
are your friends if you need to find a bug.


Guy Fawkes(Posted 2013) [#43]
Worked on it some more yesterday, making very little headway. Anyone care to chime in?


RemiD(Posted 2013) [#44]
Are you sure that this is a memory leak and not simply the dim arrays or banks which take so much memory ?

Have you tried to import, then to analyze (surfaces, triangles per surface, vertices per surface, materials, textures, etc...), then to export a simple mesh, like a cube ?

I have not tried the code but this is what i would do. It can be very difficult to see where is the problem with a complex mesh. I would try to debug step by step with a simple mesh first.

Good luck


Guy Fawkes(Posted 2013) [#45]
Yea, I did try that. I found out that the problem lies inside the "DumpChunks()" function. I used multiple "Stops" as well as multiple "DebugLogs".


Guy Fawkes(Posted 2013) [#46]
I even made my own DLL to check the exact amount of bytes that my current blitzcc file was using, and still to no avail. Alls I know, is the bug is DEFINITELY in "DumpChunks()".

I've tried Stop(). I've tried DebugLog.. I've gone line by line and added a stop, I've used the debug stepper mode... I've tried everything. and something is causing it to memory leak and wrack up on almost 1 GB of memory usage..


_PJ_(Posted 2013) [#47]
There's GIF routines in the code arcs too...
If I don't find the links I have the code saved somewhere...


Guy Fawkes(Posted 2013) [#48]
I'm not after a 2D image strip animation. I just want to destroy this memory leak and move on with life.


Guy Fawkes(Posted 2013) [#49]
Ok, so after a rather long & boring process, my friend and I were able to isolate which functions in memory might be causing the memory leak.

Here is a list of total sizes:



As you can clearly see, I get a megabyte memory usage total just after saving only "1" "dwarf1.b3d" mesh, of "336 megabytes, approximately". This should NOT happen.

Also, ".NODE" is being called "41 times", which most likely ALSO should NOT be happening.

So this memory leak has SOMETHING to do with the " Case "Node" " section inside the function, "DumpChunks()".


RemiD(Posted 2013) [#50]
How many surfaces has your mesh ?
How many vertices per surface has your mesh ?
How many triangles per surface has your mesh ?
How many materials has your mesh ?
How many joints has your mesh ?
How many animation frames has your mesh ?
Do the routines use arrays or banks to store the datas ?

Knowing this you can calculate an estimation of the maximum memory it should take.


Guy Fawkes(Posted 2013) [#51]
What program is free that I can use to get these values?


RemiD(Posted 2013) [#52]
You can retrieve these infos with Blitz3d.
or
Try the demo version of Fragmotion
http://www.fragmosoft.com/downloads/

Why do you think it is a memory leak ? The code may use a lot of memory space without being necessarily a memory leak.

PS : i have not read the code...


Guy Fawkes(Posted 2013) [#53]
Memory leak function:



How many surfaces? Don't know.
How many vertices per surface? Don't know.
How many triangles per surface? Don't know.
How many materials? Approx. 3 materials.
How many joints? Don't know.
How many animation frames? Approx. 400 frames.
Do the routines use arrays or banks to store the data? It uses a bit of both CreateBank() AND Dim().


For the 'Don't know' answers, how do I use fragmotion to get each of those?

Thanks!


RemiD(Posted 2013) [#54]
Open fragmotion
Load the .b3d file

At left there is tabwindow named "Model"
Here you can see infos about the mesh
Below "Material" you can see each surface and each material properties
If you double click on a surface, that selects the corresponding faces and vertices
Once you have selected the faces and vertices of a surface, you can click on "Mesh" to see the selected vertices count and selected faces count

At left there is a tabwindow named "Skeleton"
Here you can see infos about the skeleton with all joints

At left there is tabwindow "Animation"
Here you can see infos about the animation sequences and the frames for each sequence
double click on the animation to see infos about the frames


Guy Fawkes(Posted 2013) [#55]
I tried that.

Anyways, it's the good dwarf model that was created by Psionic. So I HIGHLY doubt it has anything wrong with it.


Guy Fawkes(Posted 2013) [#56]
So I've finally found where the bug is coming from, but do NOT know how to stop it.

It's coming from function "DumpChunks()", specifically,



How do I stop this so I can move on with my life?

Thank You!