0 registered members (),
1,459
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Open WMB file
#476666
03/20/19 22:19
03/20/19 22:19
|
Joined: Mar 2019
Posts: 4
QuartzLoop
OP
Guest
|
OP
Guest
Joined: Mar 2019
Posts: 4
|
Hello, I really like the lighting WED does and would love to find any way to extract level geometry & lightmaps from WMB in any useful 3D format. Only thing I found is this: https://forum.unity.com/threads/importing-wmb-files-from-3dgs.36300...but it didn't really work. I don't use Unity, I would only like to have model lightmapped in WED so I can open it in Blender/use it on SketchFab website.
|
|
|
Re: Open WMB file
[Re: QuartzLoop]
#476671
03/21/19 15:55
03/21/19 15:55
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
You could dig through the WMB documentation and write an extractor: http://www.conitec.net/beta/prog_mdlhmp.htmIf you already have the lightmaps extracted you could use ent_buffers on level_ent and read mesh information from blocks (in particular DirectX vertices with 2 UV sets). Or maybe even try ent_getmesh on level_ent, not sure if that works. You can then save the directX mesh as a file, or write your own OBJ exporter (the most simple model format). However... it's probably the better idea to just learn lighting in another program, I bet Blender can do that just as fine/ much better.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: Open WMB file
[Re: QuartzLoop]
#476674
03/21/19 22:37
03/21/19 22:37
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
Oh, I never realized that ent_getmesh is specifically intended (among others) to be used for level blocks: http://www.conitec.net/beta/ent_mesh.htm
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <windows.h>
#include <d3d9.h>
///////////////////////////////
HRESULT WINAPI
D3DXSaveMeshToXA(
char* pFilename,
LPD3DXMESH pMesh,
void* pAdjacency,
void* pMaterials,
void* pEffectInstances,
DWORD NumMaterials,
DWORD Format
);
#define D3DXF_FILEFORMAT_BINARY 0
#define D3DXF_FILEFORMAT_TEXT 1
#define D3DXF_FILEFORMAT_COMPRESSED 2
char *cTextureFile = "someFile.tga";
D3DXMATERIAL d3dmaterial[2];
void wmbSaveAllBlocksToFiles()
{
d3dmaterial[0].pTextureFilename = cTextureFile;
d3dmaterial[1].pTextureFilename = cTextureFile;
int blockNum = 0;
while(1)
{
LPD3DXMESH mesh = ent_getmesh(NULL,blockNum ,0);
if(!mesh) break;
STRING *str = str_printf(NULL,"export\block%d.x",blockNum);
D3DXSaveMeshToXA(str->chars, mesh, NULL, d3dmaterial, NULL, 2, D3DXF_FILEFORMAT_BINARY);
blockNum++;
}
}
void main()
{
fps_max = 60;
video_mode = 10;
level_load("deathMountain.wmb");
wait(1);
wmbSaveAllBlocksToFiles();
}
Just gave it a quick shot, almost worked immediately. You need to supply a material so it exports the UVs as well. Apparently sadly though, only the first UV map is saved. Might be wrong though. (The model shows up as black in MED because I did not fully set up the d3dmaterial.) MED has some sort of skin mapping import and export. Maybe you could look at it, then write a basic code that outputs the 2nd UV map in the correct format (to a text file) and import in MED. Could work but might not be that easy.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: Open WMB file
[Re: Superku]
#476681
03/22/19 12:53
03/22/19 12:53
|
Joined: Mar 2019
Posts: 4
QuartzLoop
OP
Guest
|
OP
Guest
Joined: Mar 2019
Posts: 4
|
Thank you for the code, I tried it but unfortunately nothing happened. My steps:
I build my level with lights (wmb was created). Clicked Publish, engine asked for script, I've chosen Empty Script. I've opened SED and added your script plus: Copied all c and h files from engine's 'include' folder in folder where EXE is. Placed 32bit TGA texture (1024/1024) in folder where EXE is, changed the name in script: char *cTextureFile = "oldbricks1tga.tga"; Changed level name to my wmb name: level_load("Kata20old.wmb"); Started EXE file, everything went fine, level started, I was able to look around after clicking 0, closed the app.
Folder 'export' was not created by the engine, so I've created it manually in the EXE folder, started everything again, closed everything, looked inside manually created 'export' folder, still nothing there.
I'm not sure what I'm doing wrong?
Last edited by QuartzLoop; 03/22/19 13:05.
|
|
|
|