Made a B3D Loader

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Luke
Admin
Posts: 449
Joined: Fri Jul 14, 2006 7:55 am
Location: Australia
Contact:

Post by Luke »

Wow nice meshes, anyway thanks, I try a fix the bugs (thinking of possible ones now, like the [LIGHT] bit at the end of the file, and more than one mesh chunk is being used, maybe the vertex ID's are local within the mesh chunk?), and I'll also fix the loading of textures so alpha/multiply blending, scale, etc are used.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

cooooooooool! 8)

let there be light all over! :D hope the models help you kill all those damn bugs!

ps. Sorry to ask again, have you got an MSVC project as well?
Luke
Admin
Posts: 449
Joined: Fri Jul 14, 2006 7:55 am
Location: Australia
Contact:

Post by Luke »

Ha Ha, I fixed it, with more than one mesh chunk is being used, the vertex ID's are local within the mesh chunk, and I also had to apply the nodes global matrix to the mesh.

I meshes don’t look as good as blitz3d yet, because texture info is being skipped, so alpha stuff is black. Also I have not got vertex lighting to work yet, not much of a problem with lightmapped meshes. If someone fixed these problems I would not mind.


I can load all 3 of your meshes now, thanks.

Here is CAnimatedMeshB3d.cpp and CAnimatedMeshB3d.h.

http://www.uploading.com/?get=0KEFBT2K

“have you got an MSVC project as well”, I’m using code blocks if that’s what your asking (edit:) I can compile in codeblocks with Microsoft Visual C++ 2005, but yeah I’ve been using GCC
Last edited by Luke on Sat Jul 22, 2006 3:55 pm, edited 2 times in total.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

great news! thanks! trying them out immediately.

Yup, I used your codeblocks project but you're using Gcc. I meant if you had a project file using an MSVC compiler like msvc toolkit 2003, which is also supported by codeblocks. :wink: I'd also like to compile a dll to use with MSVC compilers but I tried converting your codeblocks project including the adequate headers and libs for msvc but got a /w error and couldn't compile it. So I thought you had an msvc project around to import into Codeblocks, heheheh.

Thanks for the fixes. I'll let you know how it goes.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

It's working great! It's a very fast format!

Too bad transparency is not supported yet. Hope someone can give you a hand on that one.

What's that "B3d TRIS chunk" message that shows repeatedly in the console? Your loader reading the mesh chunks?

superb work.

@Vermeer: You knew this was a bait I couldn't resist, didn't you? :wink:

oh yes, here's a shot:
Image

It looks a bit darker than the blitz3d version (previous page) but it's very cool to have this power in Irrlicht anyway!
Last edited by afecelis on Sat Jul 22, 2006 4:51 pm, edited 2 times in total.
Luke
Admin
Posts: 449
Joined: Fri Jul 14, 2006 7:55 am
Location: Australia
Contact:

Post by Luke »

Thanks

"B3d TRIS chunk" message was just to help me debug it, you can comment out that line,

and also comment out:
#include <iostream>
using namespace std;


Transparency is next on my list, but any help would be great.

Night
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

you can comment out that line
which line? where?

NP with commenting out the include and namespace you mentioned, but got no idea where to comment out the "B3d TRIS chunk" thing. Is it in your corrected source files?

EDITED: nevermind, just found it in your source files. Thanks a lot!
I wish I could help out with transparency but programming is not my main strength :( I'll ask Paul Jan from the deled team to see if he can give us a hand.
I can compile in codeblocks with Microsoft Visual C++ 2005
Using your same codeblocks project? Which settings did you change to get it to work?
Last edited by afecelis on Sat Jul 22, 2006 6:08 pm, edited 1 time in total.
vermeer
Posts: 2017
Joined: Wed Jan 21, 2004 3:22 pm
Contact:

Post by vermeer »

afe.... ;)

Yup, looks nice...
But u know, he's also giving support for animated characters...so, if this ends up as a fully working level/animated character solution, man, the days of pain (and posts about x tuts from my side) at irrlicht in the artwork side, will have ended...

Well... is important, as is all compact, in a single format. Quite interesting...

But also as there's a huge load of lightmappers exporting to b3d...LMmaker( freeware), Deled, Giles, Slimshady(free)...
but also, as it tends to work great for characters...

I hope Luke u can get help in coding with the transparency stuff as well as the spline in animation stuff...

Ppl: please...help him.

Luke, you know, Afe is an artist (with some strong love for level editing) , and me too (character animation) We're no programmers...he may be a bit of a programmer...

@Hybrid

Go to the page :
http://www.uploading.com/en/?get=V7TUVLGG

click on the button which says "FREE"
it says now up there "Enter"...then a graphic of a colored number of several numbers....Type that number in the box besides..."and press" "Start Download" button.

It says now, in that same area ...·"please wait 39 seconds" (or whatever the seconds)
-..just wait now...

It will appear a text saying :

" Click here to download
Download will start during 5-30 seconds after click."

Click where says click here to download, is a blue link. All is appearing where it said before "enter number..."

well, in my case, the download Firefox dialog appeared instantly, I have downloaded the patch.


:)
Finally making games again!
http://www.konekogames.com
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

yup, Vermeer, I know. The dwarves in his test app simply look amazing. B3d format would unify everything!!! hehehe, funny.. ppl wanted an Irr format file and so far it seems like we'll be borrowing blitz3d's :wink:

So I know you're tasting the same flavors with characters as I am with levels (tho characters are also grabbing my attention strongly, BTW I wonder if there's an export script to b3d for blender animated characters?). Hehehe, you also bit this hook!!! :wink:
(here's one of my latest bastards, hehehe:)
http://www.danielpatton.com/afecelis/Blender/kiddo.jpg

@luke: I fixed your codeblocks project, removed all the gcc stuff and added the required msvc stuff. It started compiling , but I'm getting these errors:
Image

any ideas?

Finally, Vermeer is right! PPl, if any of you got experience with the missing features in Luke's exporter plz plz plz give him a hand!!! :D
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, I finally got the patch by mail and intergated into SVN, though not committed, yet. I think I got the old version which crashes on many meshes. I'll wait until tomorrow if I get a better version and will commit then. I guess enough team members had a look at it :wink:
@vermeer: Although it took some time to find this damn small download button I managed it before (otherwise I couldn't have said to prefer a shorter version than one with full source code), but the patch wasn't accessible, I always got timeouts.
Luke
Admin
Posts: 449
Joined: Fri Jul 14, 2006 7:55 am
Location: Australia
Contact:

Post by Luke »

Could someone make a patch, for me, I don't have much experience with C++ IDEs, and none with SVN. And hybrd, I don’t think that patch I sent you works, or complies as it has some bugs in it, sorry.

afecelis: I got Codeblock’s nightly build and it automatically finds it.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

I got Codeblock’s nightly build and it automatically finds it
Thanks luke. You mean, it's just a matter of opening the same project you got for Gcc and switching the compiler to an MSVC one?

grabbing latest nightly build available.
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

GCC is a bit leniant on the things

i just had that 0 size array a few minute a go on a placeholder array i was using before i switched compiler

quite weird to have empty arrays?

if u post some code we can check if this array can be removed or if it has dynamic allocations later on

yeah and another one is that the ms toolkit complains if an int member doesnt have a return statement
Luke
Admin
Posts: 449
Joined: Fri Jul 14, 2006 7:55 am
Location: Australia
Contact:

Post by Luke »

afecelis:
I have never build the loader with anything other than GCC so far


omaremad/afecelis:

I think I fixed that array thing, and the other errors were just needed casts

Code: Select all

bool CAnimatedMeshB3d::ReadChunkVRTS(io::IReadFile* file, B3dChunk *B3dStack, s16 &B3dStackSize, SB3dNode *InNode, SB3DMeshBuffer *MeshBuffer,s32 Vertices_Start)
{

	//os::Printer::log("B3d VRTS Chunk"); //for debuging

	//cout << "B3d VRTS Chunk size:" << B3dStack[B3dStackSize].remaining_length << endl;


	s32 flags, tex_coord_sets, tex_coord_set_size;

	file->read(&flags, sizeof(flags));
	file->read(&tex_coord_sets, sizeof(tex_coord_sets));
	file->read(&tex_coord_set_size, sizeof(tex_coord_set_size));

	#ifdef PPC
		flags = OSReadSwapInt32(&flags,0);
		tex_coord_sets = OSReadSwapInt32(&tex_coord_sets,0);
		tex_coord_set_size = OSReadSwapInt32(&tex_coord_set_size,0);
	#endif

	if (tex_coord_sets>=3 || tex_coord_set_size>=4)//Something is wrong
	{
		os::Printer::log("tex_coord_sets or tex_coord_set_size too big", file->getFileName(), ELL_ERROR);
		return false;
	}

	//cout << "tex_coord_sets:" << tex_coord_sets << endl;
	//cout << "tex_coord_set_size:" << tex_coord_set_size << endl;

	while(B3dStack[B3dStackSize].startposition + B3dStack[B3dStackSize].length>file->getPos()) //this chunk repeats
	{


		f32 x,y,z;
		f32 nx=0;
		f32 ny=0;
		f32 nz=0;
		f32 red=1;
		f32 green=1;
		f32 blue=1;
		f32 alpha=1;
		f32 tex_coords[3][4];

		file->read(&x, sizeof(x));
		file->read(&y, sizeof(y));
		file->read(&z, sizeof(z));

		if (flags&1)
		{
		file->read(&nx, sizeof(nx));
		file->read(&ny, sizeof(ny));
		file->read(&nz, sizeof(nz));
		}

		if (flags&2)
		{
		file->read(&red, sizeof(red));
		file->read(&green, sizeof(green));
		file->read(&blue, sizeof(blue));
		file->read(&alpha, sizeof(alpha));
		}

		for (s32 i=0;i<tex_coord_sets;i++)
			for (s32 j=0;j<tex_coord_set_size;j++)
				file->read(&tex_coords[i][j], sizeof(f32));

		#ifdef PPC //Never been tested
			x = OSReadSwapFloat32(&x,0);
			y = OSReadSwapFloat32(&y,0);
			z = OSReadSwapFloat32(&z,0);

			if (flags&1)
			{
			nx = OSReadSwapFloat32(&nx,0);
			ny = OSReadSwapFloat32(&ny,0);
			nz = OSReadSwapFloat32(&nz,0);
			}

			if (flags&2)
			{
			red = OSReadSwapFloat32(&red,0);
			green = OSReadSwapFloat32(&green,0);
			blue = OSReadSwapFloat32(&blue,0);
			alpha = OSReadSwapFloat32(&alpha,0);
			}

			for (s32 i=0;i<=tex_coord_sets-1;i++)
				for (s32 j=0;j<=tex_coord_set_size-1;j++)
					tex_coords[i][j] = OSReadSwapFloat32(&tex_coords[i][j],0);
		#endif

		f32 tu=0;
		f32 tv=0;



		if (tex_coord_sets>=1 && tex_coord_set_size>=2)
		{
			tu=tex_coords[0][0];
			tv=tex_coords[0][1];
		}


		f32 tu2=0;
		f32 tv2=0;

		if (tex_coord_sets>=2 && tex_coord_set_size>=2)
		{
			tu2=tex_coords[1][0];
			tv2=tex_coords[1][1];
		}



		irr::video::S3DVertex2TCoords *Vertex=new irr::video::S3DVertex2TCoords
					(x, y, z, video::SColorf(red, green, blue, alpha).toSColor(), tu, tv, tu2, tv2);

		Vertex->Normal=core::vector3df(nx, ny, nz);


		irr::core::matrix4 VertexMatrix;
		VertexMatrix.setTranslation(Vertex->Pos);

		VertexMatrix=InNode->GlobalMatrix*VertexMatrix;


		Vertices_GlobalMatrix.push_back(VertexMatrix);


		Vertex->Pos=VertexMatrix.getTranslation();


		Vertices.push_back(Vertex);

		Vertices_Moved.push_back(false);


		AnimatedVertices_VertexID.push_back(-1);
		AnimatedVertices_MeshBuffer.push_back(0);


	}

	B3dStackSize--;

	return true;
}
jam
Posts: 409
Joined: Fri Nov 04, 2005 3:52 am

Post by jam »

Hey, Luke thanks for your work on the B3D loader!

I changed the font size on your code snippet though, size 4 font is just a wee bit small for some of us with poor vision. :wink:
system-independent, adj.:
Works equally poorly on all systems.
-- unknown
Post Reply