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

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
tireswing
Posts: 6
Joined: Wed Aug 29, 2007 3:19 pm

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

Post 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.
Last edited by tireswing on Mon Jan 12, 2009 6:54 pm, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Where does 3dw and smf come from? I coldn't find a useful link with google on the first try.
tireswing
Posts: 6
Joined: Wed Aug 29, 2007 3:19 pm

Post by tireswing »

.3DW is a 3D World Studio file.
.SMF stands for Simple Mesh Format (created by Leadwerks?) for static meshes.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Oh, damn it. I did not read the headline :oops:
Looks interesting!
tireswing
Posts: 6
Joined: Wed Aug 29, 2007 3:19 pm

Post 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
Last edited by tireswing on Wed Sep 12, 2007 7:33 pm, edited 1 time in total.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Cool stuff :)
I'm surprised by the lack of replies, I thought a few more people here used 3DWS
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
FlowPX2
Posts: 7
Joined: Wed Sep 26, 2007 11:58 am

Post by FlowPX2 »

thx thx thx ^^ i love it!!! :wink:
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

love this loader

Post 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.
FlowPX2
Posts: 7
Joined: Wed Sep 26, 2007 11:58 am

Post by FlowPX2 »

Only .png, .tga, .jpg :wink:

Hmm... Have anybody an idea for collision in this loader with the camera animation!?!?! ^^.
TheMiss
Posts: 14
Joined: Sun Apr 15, 2007 6:46 pm

Post by TheMiss »

Most people like to export to other file format such as .BSD.

But this is very COOL and look INTERESTING!
8)
tireswing
Posts: 6
Joined: Wed Aug 29, 2007 3:19 pm

Post 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
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post 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); 
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

So is it going into irrlicht?
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Post 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);
									};
};

WarShattrith
Posts: 6
Joined: Wed Oct 17, 2007 5:07 pm

Post by WarShattrith »

Hi,
It's very interesting. When will it supports multiple layers ? (Terrain painting)
Post Reply