Page 1 of 3

3D World Studio loader now w/Terrain splatting (Irrlicht1.5)

Posted: Thu Sep 06, 2007 1:47 pm
by tireswing
UPDATED Jan. 2009 for Irrlicht 1.5.

I looked around and didn't find anything like it, so here's my attempt at a 3DW loader.
I wrote some code to load a .3DW file directly into Irrlicht.
It reads the complete file and parses it.

It implements loading of brush geometry in Irrlicht with textures and lightmaps. It also loads and places referenced meshes in .X and .SMF format. (.MD3 might work but I haven't tested it yet). This code includes a custom loader for .SMF meshes.

It's not required, but if you improve this code, I'd like a copy of the improved code.

Download: 3DWSLoader.zip

Screenshot:
Image
(click picture for larger picture)

UPDATE:
Don't know how many still use 3DWS, but I'm starting a new project so I updated the loader to Irrlicht 1.5 and added support for terrain texture splatting.

Posted: Thu Sep 06, 2007 2:42 pm
by hybrid
Where does 3dw and smf come from? I coldn't find a useful link with google on the first try.

Posted: Thu Sep 06, 2007 2:51 pm
by tireswing
.3DW is a 3D World Studio file.
.SMF stands for Simple Mesh Format (created by Leadwerks?) for static meshes.

Posted: Thu Sep 06, 2007 4:17 pm
by hybrid
Oh, damn it. I did not read the headline :oops:
Looks interesting!

Posted: Tue Sep 11, 2007 7:11 pm
by tireswing
Updated my importer. It now imports terrain created with 3D World Studio.

To download, see the original post.

Screenshots:
Image
Image
Image
Image

Thanks,
Joe

Posted: Tue Sep 11, 2007 9:08 pm
by bitplane
Cool stuff :)
I'm surprised by the lack of replies, I thought a few more people here used 3DWS

Posted: Sun Sep 30, 2007 7:07 pm
by FlowPX2
thx thx thx ^^ i love it!!! :wink:

love this loader

Posted: Wed Oct 03, 2007 12:00 am
by Seven
I have to say that I love this loader. It is exactly what I have been looking for. With that said, I am have trouble with loading the textures from the world studio file and could use some help if this thread is still active.

Posted: Wed Oct 03, 2007 2:39 am
by FlowPX2
Only .png, .tga, .jpg :wink:

Hmm... Have anybody an idea for collision in this loader with the camera animation!?!?! ^^.

Posted: Wed Oct 03, 2007 8:25 am
by TheMiss
Most people like to export to other file format such as .BSD.

But this is very COOL and look INTERESTING!
8)

Posted: Wed Oct 03, 2007 1:35 pm
by tireswing
I'm glad some people find it useful.
I am have trouble with loading the textures from the world studio file and could use some help if this thread is still active.
The demo levels use textures in .STF format, which is a proprietary format used by Leadwerks. For the purposes of loading the Complex.3dw level, I created a loader for .STF, but I will not distribute that without permission from Leadwerks. But I'm not sure how important that is, since Leadwerks has not given anyone a license to use those textures, and it is a fairly inefficient way of storing textures.
Hmm... Have anybody an idea for collision in this loader with the camera animation!?!?! ^^.
Well, my demo doesn't use collision for the camera, but it shouldn't be too hard to add. Just use a MetaTriangleSelector to combine the triangleSelectors from the terrain scene node and the level scene node created by the loader and then use that MetaTriangleSelector as your source for the collision animator on the camera.

-Joe

Posted: Thu Oct 04, 2007 7:53 pm
by christianclavet
For the collision you could surely adapt the code in this thread to it. (You will not need to load the IRR file simply). http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=23707

The code check the scene and add all OCCTREES to the metaselector that is then applied to the camera Response animator. The only thing you will have to do is create occtree from your meshes.

For this you could use the function like that after loaded your mesh:

Code: Select all

selector = smgr->createOctTreeTriangleSelector(YourMesh->getMesh(0), YourNode, 128); 

Posted: Wed Oct 10, 2007 3:38 pm
by MasterGod
So is it going into irrlicht?

Posted: Sun Oct 14, 2007 2:41 pm
by Seven
Sometimes a programmer will create his own scenemanager instead of defaulting to the device->scenemanager, this was the case for me as I load multiple worlds simultaneously and then swap between which smgr I want to render. Each level creates it's own scenemanager and then only draws that one. It makes short work of loading and destroying menus and levels. Anyhow, the point to this rambling is that I modified the loader code to take a smgr as a parameter and then saved it in the C3DWScene class.

Code: Select all

class	C3DWScene
{
public:
	C3DWScene();
	virtual ~C3DWScene();

< code removed for simplicity>

	ISceneManager*					m_Smgr;
	C3DW_File					   *m_pSceneFile;
	stringc							m_strFileName;
	stringc							m_strTextureRoot;
	stringc							m_strModelRoot;
};


bool	C3DWScene::load(IrrlichtDevice *pDevice, ISceneManager* Smgr, c8 *szFileName, bool bCreateMeshes, bool bCreateLights, c8 *szTextureRoot, c8 *szModelRoot)
{
	m_Smgr = Smgr;

	c8	 *pData;
	s32	nFileSize;

< code removed for simplicity>


it is then used something like this

Code: Select all

#pragma once

#include "ZApp.h"
#include "GlobalData.h"
#include "3DWLoader.h"

// a simple level to use
class ZLevel_Demo14 : public ZLevel
{
public:
	ICameraSceneNode* m_Camera;
	scene::IAnimatedMeshSceneNode* m_Node; 
	C3DWScene* m_c3dw;

	ZLevel_Demo14(void)				{	Initialize();						};
	virtual ~ZLevel_Demo14(void)	{	Cleanup();							};

	virtual void Initialize()		{	
										Z_INIT(m_Camera);
										Z_INIT(m_Node);
										Z_INIT(m_c3dw);
									};

	virtual bool Create(ZApp* App)	{	
										ZLevel::Create(App);	
										m_Camera = m_Smgr->addCameraSceneNodeFPS();
										m_Camera->setPosition(irr::core::vector3df(0,0,0));

										ISceneNode *SkyBox = m_Smgr->addSkyBoxSceneNode(
											m_App->GetEngine()->m_Driver->getTexture("media\\textures\\skybox\\pos_y.png"),
											m_App->GetEngine()->m_Driver->getTexture("media\\textures\\skybox\\neg_y.png"),
											m_App->GetEngine()->m_Driver->getTexture("media\\textures\\skybox\\neg_x.png"),
											m_App->GetEngine()->m_Driver->getTexture("media\\textures\\skybox\\pos_x.png"),
											m_App->GetEngine()->m_Driver->getTexture("media\\textures\\skybox\\neg_z.png"),
											m_App->GetEngine()->m_Driver->getTexture("media\\textures\\skybox\\pos_z.png"));

										m_c3dw = new C3DWScene();											
										m_c3dw->load(m_App->GetEngine()->m_Device, m_Smgr, "media\\testworld\\track.3dw", true, true);

										return true;	
									};

	virtual bool Cleanup()			{	Initialize();		Z_SAFE_DELETE(m_c3dw);	return false;			};
	virtual void Frame()			{	ZLevel::Frame();	m_Smgr->drawAll();								};

	virtual bool OnEvent(SEvent event)
									{
										if (m_Camera->OnEvent(event)) return true;

										// do global application level message handling here
										switch(event.EventType)
										{
											case EET_MOUSE_INPUT_EVENT :
												{
													switch (event.MouseInput.Event)
													{
														case EMIE_RMOUSE_PRESSED_DOWN : 
															{
																m_Camera->setInputReceiverEnabled(!m_Camera->isInputReceiverEnabled());
																m_App->m_Engine->m_Device->getCursorControl()->setVisible(!m_Camera->isInputReceiverEnabled());
															};	break;
													}
												} break;
										}

										// we did not want this message
										return false;
									};

	virtual void UnLoad()			{	ZLevel::UnLoad();					};
	virtual void Load()				{	
										m_App->m_Engine->m_Driver->setFog(SColor(0,0,0,0), true, 1400.0, 5600.0); 

										// stuff for the application to use
										m_GUIElements[1] = m_App->m_Engine->m_Gui->addButton(rect<s32>(10,10,100,40), 0, ID_MAINMENU, L"MainMenu");
										m_Camera->setInputReceiverEnabled(true);
										m_App->m_Engine->m_Device->getCursorControl()->setVisible(true);
									};
};


Posted: Sat Oct 27, 2007 2:08 pm
by WarShattrith
Hi,
It's very interesting. When will it supports multiple layers ? (Terrain painting)