3D World Studio loader now w/Terrain splatting (Irrlicht1.5)
3D World Studio loader now w/Terrain splatting (Irrlicht1.5)
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:
(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.
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:
(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.
love this loader
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.
I'm glad some people find it useful.
-Joe
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.I am have trouble with loading the textures from the world studio file and could use some help if this thread is still active.
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.Hmm... Have anybody an idea for collision in this loader with the camera animation!?!?! ^^.
-Joe
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
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:
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);
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.
it is then used something like this
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);
};
};
-
- Posts: 6
- Joined: Wed Oct 17, 2007 5:07 pm