Gamestudio Links
Zorro Links
Newest Posts
What are you working on?
by Ayumi
8 minutes 11 seconds ago
Performance report on the imported trades
by OptimusPrime
15 minutes 30 seconds ago
Possible to return character vector from R bridge?
by JamesHH
Today at 18:59
Help with Wine on Linux
by AndrewAMD
Today at 16:59
Stock Splits
by AndrewAMD
Today at 16:23
Linux - Help with setting up with Wine and Zorro
by michaelj
Today at 04:49
How to expand Zorro to work with other broker ( like Tradovate )
by AndrewAMD
Today at 02:12
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online
12 registered (AndrewAMD, Ayumi, JamesHH, ChrstphFr, michaelj, Akow, jenGs, Bill_Lin_Fang, alibaba, 1 invisible), 165 Guests and 8 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
Bill_Lin_Fang, michaelj, ThePituLegend, kankan, Nofip
18207 Registered Users
Topic Options
Rate This Topic
#476666 - 03/20/19 23:19 Open WMB file
QuartzLoop Offline
Guest

Registered: 03/20/19
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.

Top
#476670 - 03/21/19 14:37 Re: Open WMB file [Re: QuartzLoop]
QuartzLoop Offline
Guest

Registered: 03/20/19
Posts: 4
...small update, I've tried DX3DRipper and NinjaRipper, DX3D was terrible, all my geometry was distorted & half was missing. Ninja was a bit better but also had missing geometry and only lightmaps with no textures.
However both programs did extract lightmaps so I guess it's at least possible. If I could get lightmap UV's they could be manually applied in MED and then all is left is importing lightmap-texture files extracted with DX3D or Ninja.

Top
#476671 - 03/21/19 16:55 Re: Open WMB file [Re: QuartzLoop]
Superku Offline
Senior Expert

Registered: 09/13/03
Posts: 6834
Loc: Kiel (Germany)
You could dig through the WMB documentation and write an extractor:
http://www.conitec.net/beta/prog_mdlhmp.htm

If 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

Top
#476673 - 03/21/19 18:54 Re: Open WMB file [Re: Superku]
QuartzLoop Offline
Guest

Registered: 03/20/19
Posts: 4
The ent_getmesh sounds great but unfortunately my coding is extremely limited. Can this be done in SED with some sort of on_click event? Can I find ent_getmesh & ent_savemesh in documentation?

I really like the way WED does lights because it creates a nice retro-Quake-Wolfenstein-CBsUndying style that I was unable to do in Blender. The closest program with similar lights that I used is DeleD but he is handling bigger geometry very badly. Also I like the fact that both DeleD and WED are automatically creating lightmap UV/size calculations. In Blender I have to manually unwrap parts of the model for second UV & maps usually have visible seams because of the margins or too much faces so I have to go back, further separate model parts, unwrap new parts again... it becomes very tedious very fast.

Top
#476674 - 03/21/19 23:37 Re: Open WMB file [Re: QuartzLoop]
Superku Offline
Senior Expert

Registered: 09/13/03
Posts: 6834
Loc: 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

Code:
///////////////////////////////
#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

Top
#476681 - 03/22/19 13:53 Re: Open WMB file [Re: Superku]
QuartzLoop Offline
Guest

Registered: 03/20/19
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?


Edited by QuartzLoop (03/22/19 14:05)

Top
#476682 - 03/22/19 15:34 Re: Open WMB file [Re: QuartzLoop]
Superku Offline
Senior Expert

Registered: 09/13/03
Posts: 6834
Loc: Kiel (Germany)
Hmmmm. Some things:

Don't "publish" your script or level.
Just create a new text file, rename it to someScript.c, paste my code.
Change the level name.
Do not copy over any files from GStudio include folder. It finds them automatically (copying them over will break stuff should you ever update your GStudio installation).
Just start the script from SED, for example with the left-most triangle/ play button.

If your GStudio installation is in a subfolder of Program Files, well, that's bad, it shouldn't (I just have it in C:GStudio8 for example). Otherwise it will not be allowed to create files because if missing rights.
_________________________
"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

Top


Moderator:  HeelX, rvL_eXile 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de