2 registered members (Imhotep, opm),
785
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Save as .wmb
#392065
01/18/12 21:43
01/18/12 21:43
|
Joined: Jul 2007
Posts: 619 Turkey, Izmir
Emre
OP
User
|
OP
User
Joined: Jul 2007
Posts: 619
Turkey, Izmir
|
Hello all, I got some help from here and I've completed it. if you have an editor like Sivan's Map Builder and if you want to save your level as .wmb while engine is open, you can use this code. Note: That code works with only models&terrain. Map entities, path, attached etc. are not supported.
//////////////////////////////
// save as wmb (18/01/2012)
//////////////////////////////
// Created by Emre SASMAZ
// pantharay@gmail.com
// blog.pantharay.com
// sayha.pantharay.com
//////////////////////////////
#include <stdio.h>
//$$w hex code
char bufferforwad[12] = {0x57, 0x41, 0x44, 0x37, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00};
//expalette.pcx hexcode
char bufferforpalette[954] =
{
0x0A, 0x05, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x12, 0x00, 0x48, 0x00, 0x48, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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27, 0x33, 0x2F, 0x2F, 0x3F, 0x37, 0x37, 0x4B, 0x3F, 0x3F, 0x57, 0x47,
0x47, 0x67, 0x4F, 0x4F, 0x73, 0x5B, 0x5B, 0x7F, 0x63, 0x63, 0x8B, 0x6B, 0x6B, 0x97, 0x73, 0x73,
0xA3, 0x7B, 0x7B, 0xAF, 0x83, 0x83, 0xBB, 0x8B, 0x8B, 0xCB, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00,
0x0B, 0x0B, 0x00, 0x13, 0x13, 0x00, 0x1B, 0x1B, 0x00, 0x23, 0x23, 0x00, 0x2B, 0x2B, 0x07, 0x2F,
0x2F, 0x07, 0x37, 0x37, 0x07, 0x3F, 0x3F, 0x07, 0x47, 0x47, 0x07, 0x4B, 0x4B, 0x0B, 0x53, 0x53,
0x0B, 0x5B, 0x5B, 0x0B, 0x63, 0x63, 0x0B, 0x6B, 0x6B, 0x0F, 0x07, 0x00, 0x00, 0x0F, 0x00, 0x00,
0x17, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x27, 0x00, 0x00, 0x2F, 0x00, 0x00, 0x37, 0x00, 0x00, 0x3F,
0x00, 0x00, 0x47, 0x00, 0x00, 0x4F, 0x00, 0x00, 0x57, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x67, 0x00,
0x00, 0x6F, 0x00, 0x00, 0x77, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x13, 0x13, 0x00, 0x1B, 0x1B, 0x00,
0x23, 0x23, 0x00, 0x2F, 0x2B, 0x00, 0x37, 0x2F, 0x00, 0x43, 0x37, 0x00, 0x4B, 0x3B, 0x07, 0x57,
0x43, 0x07, 0x5F, 0x47, 0x07, 0x6B, 0x4B, 0x0B, 0x77, 0x53, 0x0F, 0x83, 0x57, 0x13, 0x8B, 0x5B,
0x13, 0x97, 0x5F, 0x1B, 0xA3, 0x63, 0x1F, 0xAF, 0x67, 0x23, 0x23, 0x13, 0x07, 0x2F, 0x17, 0x0B,
0x3B, 0x1F, 0x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F, 0x1B, 0x1B, 0x2F, 0x13, 0x13, 0x1F, 0x0B, 0x0B, 0x0F, 0x2B, 0x00, 0x00, 0x3B, 0x00, 0x00,
0x4B, 0x07, 0x00, 0x5F, 0x07, 0x00, 0x6F, 0x0F, 0x00, 0x7F, 0x17, 0x07, 0x93, 0x1F, 0x07, 0xA3,
0x27, 0x0B, 0xB7, 0x33, 0x0F, 0xC3, 0x4B, 0x1B, 0xCF, 0x63, 0x2B, 0xDB, 0x7F, 0x3B, 0xE3, 0x97,
0x4F, 0xE7, 0xAB, 0x5F, 0xEF, 0xBF, 0x77, 0xF7, 0xD3, 0x8B, 0xA7, 0x7B, 0x3B, 0xB7, 0x9B, 0x37,
0xC7, 0xC3, 0x37, 0xE7, 0xE3, 0x57, 0x7F, 0xBF, 0xFF, 0xAB, 0xE7, 0xFF, 0xD7, 0xFF, 0xFF, 0x67,
0x00, 0x00, 0x8B, 0x00, 0x00, 0xB3, 0x00, 0x00, 0xD7, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xF3,
0x93, 0xFF, 0xF7, 0xC7, 0xFF, 0xFF, 0xFF, 0x9F, 0x5B, 0x53
} ;
STRING* temp_str="#25";
var wmb_handle;
#define ifiselse(var) if(is(you,var)){str_cat(temp_str,"1");}else{str_cat(temp_str,"0");}
#define skipline file_asc_write (wmb_handle, 13);file_asc_write (wmb_handle, 10)
#define obrackets file_str_write (wmb_handle,"{")
#define cbrackets file_str_write (wmb_handle,"}")
long entflags[32];
void flags_startup()
{
entflags[1]=0;
entflags[2]=0;
entflags[3]=0;
entflags[4]=0;
entflags[5]=0;
entflags[6]=POLYGON;
entflags[7]=0;//Local
entflags[8]=0;
entflags[9]=CAST;
entflags[10]=METAL;
entflags[11]=BRIGHT;
entflags[12]=NOFOG;
entflags[13]=0;
entflags[14]=SHADOW;
entflags[15]=UNLIT;
entflags[16]=NOFILTER;
entflags[17]=0;//Flare
entflags[18]=ZNEAR;
entflags[19]=SPOTLIGHT;
entflags[20]=OVERLAY;
entflags[21]=0;
entflags[22]=TRANSLUCENT;
entflags[23]=PASSABLE;
entflags[24]=INVISIBLE;
entflags[25]=FLAG8;
entflags[26]=FLAG7;
entflags[27]=FLAG6;
entflags[28]=FLAG5;
entflags[29]=FLAG4;
entflags[30]=FLAG3;
entflags[31]=FLAG2;
entflags[32]=FLAG1;
}
void set_flags(var flag16)
{
str_cpy(temp_str,"");
if(flag16>0)
{
str_cat(temp_str,"0");//-?
str_cat(temp_str,"0");//-?
str_cat(temp_str,"0");
str_cat(temp_str,"0");//-?
str_cat(temp_str,"0");//-?
ifiselse(POLYGON)//6
str_cat(temp_str,"0");//LOCAL//7
str_cat(temp_str,"0");//8
ifiselse(CAST)//9
ifiselse(METAL)//10
ifiselse(BRIGHT)//11
ifiselse(NOFOG)//12
str_cat(temp_str,"0");//13
ifiselse(SHADOW)
ifiselse(UNLIT)
ifiselse(NOFILTER)
}
str_cat(temp_str,"0");//17
ifiselse(ZNEAR)//18
ifiselse(SPOTLIGHT)//-?//19
ifiselse(OVERLAY)//20
str_cat(temp_str,"0");//17
ifiselse(TRANSLUCENT)//21
ifiselse(PASSABLE)//22
ifiselse(INVISIBLE)//23
ifiselse(FLAG8)//24
ifiselse(FLAG7)//25
ifiselse(FLAG6)//26
ifiselse(FLAG5)//28
ifiselse(FLAG4)//29
ifiselse(FLAG3)//30
ifiselse(FLAG2)//31
ifiselse(FLAG1)//32
file_str_write (wmb_handle,temp_str); skipline;
}
void save_wmb()
{
//variables
var num = 0;
ENTITY* ent;
char* funcname;
var yourtype;
var say=0;
int i;
//Remove $$m & $$w & expalette.pcx
remove("export.$$M");
remove("export.$$w");
remove("expalette.pcx");
wait(-0.5);
//Create $$w file (wad7)
FILE *myfile = fopen("export.$$w", "wb");
int i=0;
for(i=0;i<12;i++)
{
putc(bufferforwad[i], myfile);
}
fclose(myfile);
//Create expalette.pcx file (wad7)
FILE *myfile = fopen("expalette.pcx", "wb");
int i=0;
for(i=0;i<954;i++)
{
putc(bufferforpalette[i], myfile);
}
fclose(myfile);
//Create $$m
wmb_handle = file_open_append("export.$$M");
file_str_write (wmb_handle,"version 711"); skipline;
//level
obrackets;file_str_write (wmb_handle," //level"); skipline;
file_var_write (wmb_handle,0);skipline;
file_str_write (wmb_handle,"export.$$w"); skipline;
file_str_write (wmb_handle,"expalette.pcx"); skipline;
cbrackets;skipline;
//sun
obrackets;file_str_write (wmb_handle," //sun"); skipline;
file_var_write (wmb_handle,5);skipline;
file_var_write (wmb_handle,sun_angle.tilt);skipline;
file_var_write (wmb_handle,sun_angle.pan);skipline;
cbrackets;skipline;
var myflag16=0;
//entities
you = ent_next(NULL);
while (you)
{
draw_text("PLEASE WAIT",10,10,COLOR_RED);
obrackets;file_str_write (wmb_handle," //model"); skipline;
#ifndef ent_id
#define ent_id
yourtype=0;
/*
from sdk:
'wmpio_ModelEntity * model; // id == 3 (7, for model-ex)'
SO CHECK IF EX OR NOT (if has a material or string1-2 or has a action it's 7 else it's 3)
*/
//if(your.materialtype!=NULL)
if(your.material!=mat_model&&your.material!=NULL&&your.material!=mat_terrain)
{
yourtype+=1;
}
//if(your.string1||string2!=NULL)
if(str_len(your.string1)>0||str_len(your.string2)>0)
{
yourtype+=1;
}
num = 0;
say=0;
//Check Entity has an action or not.
for(num = 0; engine_gettaskinfo(num,&funcname,&ent); num++)
{
if(ent == you)
{
yourtype+=1;
break;
}
}
//
if(yourtype>0)
{
file_var_write (wmb_handle,7);skipline;//model-ex
}
else
{
file_var_write (wmb_handle,3);skipline;//model
}
#endif
//xyz
file_var_write (wmb_handle,you.x);
file_var_write (wmb_handle,you.y);
file_var_write (wmb_handle,you.z);skipline;
//pan-tilt-roll
file_var_write (wmb_handle,you.pan);
file_var_write (wmb_handle,you.tilt);
file_var_write (wmb_handle,you.roll);skipline;
//scale
file_var_write (wmb_handle,you.scale_x);
file_var_write (wmb_handle,you.scale_y);
file_var_write (wmb_handle,you.scale_z);skipline;
//Entitiy file name
str_for_entfile(temp_str,you);
file_str_write (wmb_handle,temp_str); skipline;
//Ent name
str_for_entname(temp_str,you);
file_str_write (wmb_handle,temp_str); skipline;
num = 0;
say=0;
//Get action name of Entity (Thanks to MasterQ32&JustSid for tip)
for(num = 0; engine_gettaskinfo(num,&funcname,&ent); num++)
{
if(ent == you)
{
file_str_write (wmb_handle,_str(funcname)); skipline;
say=1;
break;
}
}
//if entity has no action, put ndef
if(say==0)
{
file_str_write (wmb_handle,"ndef"); skipline;
}
//skills
file_var_write (wmb_handle,you.skill1);
file_var_write (wmb_handle,you.skill2);
file_var_write (wmb_handle,you.skill3);
file_var_write (wmb_handle,you.skill4);
file_var_write (wmb_handle,you.skill5);
file_var_write (wmb_handle,you.skill6);
file_var_write (wmb_handle,you.skill7);
file_var_write (wmb_handle,you.skill8);
if(yourtype>0)//type==7
{
file_var_write (wmb_handle,you.skill9);
file_var_write (wmb_handle,you.skill10);
file_var_write (wmb_handle,you.skill11);
file_var_write (wmb_handle,you.skill12);
file_var_write (wmb_handle,you.skill13);
file_var_write (wmb_handle,you.skill14);
file_var_write (wmb_handle,you.skill15);
file_var_write (wmb_handle,you.skill16);
file_var_write (wmb_handle,you.skill17);
file_var_write (wmb_handle,you.skill18);
file_var_write (wmb_handle,you.skill19);
file_var_write (wmb_handle,you.skill20);
}skipline;
//flags
myflag16=0;
i=0;
for(i=1;i<17;i++)
{
if (is(you,entflags[i]))
{
myflag16=1;
}
}
set_flags(myflag16);
file_var_write (wmb_handle,your.ambient);skipline;
//Get material name of Entity
if(your.material!=mat_model&&your.material!=NULL&&your.material!=mat_terrain)
{ file_var_write (wmb_handle,your.albedo);skipline;
file_var_write (wmb_handle,0);skipline; //path
file_var_write (wmb_handle,0);skipline; //attach
str_cpy(temp_str,_chr(your.material.link.name));
file_str_write (wmb_handle,temp_str); skipline;
}
else
{
if(yourtype>0)
{
file_var_write (wmb_handle,your.albedo);skipline;
file_var_write (wmb_handle,0);skipline;//path
file_var_write (wmb_handle,0);skipline;//attach
file_str_write (wmb_handle,"ndef"); skipline; // if no material put ndef
}
}
//string1 string2
if(str_len(your.string1)>0)
{
str_cpy(temp_str,_chr(your.string1));
file_str_write (wmb_handle,temp_str); skipline;
}
if(str_len(your.string2)>0)
{
str_cpy(temp_str,_chr(your.string2));
file_str_write (wmb_handle,temp_str); skipline;
}
cbrackets;skipline;
you = ent_next(you);
wait(1);
}
file_close(wmb_handle);
wait(-1);
//build it with default
exec("%EXE_DIR%\\wwmp2wmb.exe","export.$$M -pal expalette.pcx
-az 10 -el 60
-sunrgb 100 100 100
-ambrgb 100 100 100
-noportals
-hiprec
-writelog
-close
-nodetail
-threads 2
-gamma 1.50
-phongangle 120
-lmambient 50
-sizeshaded 236
-litres 1.00
-litcomp 0.50
-litmax 196
-litscale 0.50
-radsubdiv 64
-radbounce 0
-bound 56000
-fat 64 48 8
-narrow 32 32 0 ");
//exec("%EXE_DIR%\\wwmp2wmb.exe","export.$$M -pal palette.pcx -close");
}
void on_enter_event()
{
save_wmb();
}
Last edited by Emre; 01/19/12 23:58. Reason: i corrected the code
|
|
|
Re: Save as .wmb
[Re: Emre]
#392071
01/18/12 22:29
01/18/12 22:29
|
Joined: Mar 2006
Posts: 1,993 Karlsruhe
PadMalcom
Serious User
|
Serious User
Joined: Mar 2006
Posts: 1,993
Karlsruhe
|
Wow nice! ... except the part with "wmp2wmb.exe" but that's not your fault Thanks for the code!
|
|
|
Re: Save as .wmb
[Re: Emre]
#392116
01/19/12 13:31
01/19/12 13:31
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
Emre, congratulation! I test it immediately, and integrate into MapBuilder, if works fine, and if you don't mind. Questions: - map enities are planned to be integrated? (or do they result in too strange structure? I mean wmb within wmb) - sprites are not mentioned: are they excluded? Thanks!
|
|
|
Re: Save as .wmb
[Re: sivan]
#392120
01/19/12 14:01
01/19/12 14:01
|
Joined: Jul 2007
Posts: 619 Turkey, Izmir
Emre
OP
User
|
OP
User
Joined: Jul 2007
Posts: 619
Turkey, Izmir
|
i'm glad if that helps to your project. Feel free to use. map enities are planned to be integrated? (or do they result in too strange structure? I mean wmb within wmb) Structure is same as model. The problem is i can't find them with "ent_next". sprites are not mentioned: are they excluded? I forgot to mention. Sprites are supported too.
|
|
|
Re: Save as .wmb
[Re: Emre]
#392126
01/19/12 15:34
01/19/12 15:34
|
Joined: May 2009
Posts: 1,816 at my pc (duh)
darkinferno
Serious User
|
Serious User
Joined: May 2009
Posts: 1,816
at my pc (duh)
|
how does it handle assigned actions though? is it possible to save the wmb with actions attached? if yes, how would it determine how an action is assigned?reading over the code, it seems it does save actions but again, if i have a model created through ent_create running a function, that function will be the name of the assigned action ? sorry if i didnt look into the code too much, i plan to test it all soon anyway very good contribution
|
|
|
Re: Save as .wmb
[Re: darkinferno]
#392133
01/19/12 16:27
01/19/12 16:27
|
Joined: Jul 2007
Posts: 619 Turkey, Izmir
Emre
OP
User
|
OP
User
Joined: Jul 2007
Posts: 619
Turkey, Izmir
|
Hello Darkinferno, Here are my answers for clear understanding; This is structure from $$m;
{ //model
7
85 -85 -8
0 0 0
1 1 1
GRIBIRD.BMP
gribird_bmp_013
ndef
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00000000000000000000000000000000
0
50
0
0
mat_sprite
adasdasdasdads
asddasdasdasdasd
}
it means;
{ //model
ent id
xyz
pan tilt roll
scale_xyz
file name
ent name
action name
skills
flags
ambient
albedo
path
attached entity
material
string1
string2
}
So, if your entity has a running action mean;
action test_act()
{
while(1)
{
my.skill+=1;
wait(1);
}
}
it will be saved with action's name. if your entity hasn't running action like that;
action test_act(){my.skill1=10;}
it won't be saved with action's name but ent.skill1 will be saved as 10; if i have a model created through ent_create running a function, that function will be the name of the assigned action ? The same situation is valid for "ent_create." if your model that you created with ent_create hasn't action, it will be saved as "ndef". Otherwise, it will be saved with action's name.
|
|
|
Re: Save as .wmb
[Re: sivan]
#392196
01/19/12 23:54
01/19/12 23:54
|
Joined: Jul 2007
Posts: 619 Turkey, Izmir
Emre
OP
User
|
OP
User
Joined: Jul 2007
Posts: 619
Turkey, Izmir
|
Okay. Please try this one for flag problem.
#include <stdio.h>
//$$w hex code
char bufferforwad[12] = {0x57, 0x41, 0x44, 0x37, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00};
//expalette.pcx hexcode
char bufferforpalette[954] =
{
0x0A, 0x05, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x12, 0x00, 0x48, 0x00, 0x48, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xCF, 0xD3, 0x00, 0xCF, 0xD3, 0x00, 0xCF, 0xD3, 0x00, 0xCF, 0xD3, 0x00, 0xCF, 0xD3, 0x00, 0xCF,
0xD3, 0x00, 0xCF, 0xD3, 0x00, 0xCF, 0xD3, 0x00, 0xCF, 0xD3, 0x00, 0xCF, 0xD3, 0x00, 0xCF, 0xD3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, 0x00, 0x1B, 0x1B, 0x00, 0x23, 0x23, 0x00, 0x2B, 0x2B, 0x07, 0x2F,
0x2F, 0x07, 0x37, 0x37, 0x07, 0x3F, 0x3F, 0x07, 0x47, 0x47, 0x07, 0x4B, 0x4B, 0x0B, 0x53, 0x53,
0x0B, 0x5B, 0x5B, 0x0B, 0x63, 0x63, 0x0B, 0x6B, 0x6B, 0x0F, 0x07, 0x00, 0x00, 0x0F, 0x00, 0x00,
0x17, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x27, 0x00, 0x00, 0x2F, 0x00, 0x00, 0x37, 0x00, 0x00, 0x3F,
0x00, 0x00, 0x47, 0x00, 0x00, 0x4F, 0x00, 0x00, 0x57, 0x00, 0x00, 0x5F, 0x00, 0x00, 0x67, 0x00,
0x00, 0x6F, 0x00, 0x00, 0x77, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x13, 0x13, 0x00, 0x1B, 0x1B, 0x00,
0x23, 0x23, 0x00, 0x2F, 0x2B, 0x00, 0x37, 0x2F, 0x00, 0x43, 0x37, 0x00, 0x4B, 0x3B, 0x07, 0x57,
0x43, 0x07, 0x5F, 0x47, 0x07, 0x6B, 0x4B, 0x0B, 0x77, 0x53, 0x0F, 0x83, 0x57, 0x13, 0x8B, 0x5B,
0x13, 0x97, 0x5F, 0x1B, 0xA3, 0x63, 0x1F, 0xAF, 0x67, 0x23, 0x23, 0x13, 0x07, 0x2F, 0x17, 0x0B,
0x3B, 0x1F, 0x0F, 0x4B, 0x23, 0x13, 0x57, 0x2B, 0x17, 0x63, 0x2F, 0x1F, 0x73, 0x37, 0x23, 0x7F,
0x3B, 0x2B, 0x8F, 0x43, 0x33, 0x9F, 0x4F, 0x33, 0xAF, 0x63, 0x2F, 0xBF, 0x77, 0x2F, 0xCF, 0x8F,
0x2B, 0xDF, 0xAB, 0x27, 0xEF, 0xCB, 0x1F, 0xFF, 0xF3, 0x1B, 0x0B, 0x07, 0x00, 0x1B, 0x13, 0x00,
0x2B, 0x23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
0x4F, 0xE7, 0xAB, 0x5F, 0xEF, 0xBF, 0x77, 0xF7, 0xD3, 0x8B, 0xA7, 0x7B, 0x3B, 0xB7, 0x9B, 0x37,
0xC7, 0xC3, 0x37, 0xE7, 0xE3, 0x57, 0x7F, 0xBF, 0xFF, 0xAB, 0xE7, 0xFF, 0xD7, 0xFF, 0xFF, 0x67,
0x00, 0x00, 0x8B, 0x00, 0x00, 0xB3, 0x00, 0x00, 0xD7, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xF3,
0x93, 0xFF, 0xF7, 0xC7, 0xFF, 0xFF, 0xFF, 0x9F, 0x5B, 0x53
} ;
STRING* temp_str="#25";
var wmb_handle;
#define ifiselse(var) if(is(you,var)){str_cat(temp_str,"1");}else{str_cat(temp_str,"0");}
#define skipline file_asc_write (wmb_handle, 13);file_asc_write (wmb_handle, 10)
#define obrackets file_str_write (wmb_handle,"{")
#define cbrackets file_str_write (wmb_handle,"}")
long entflags[32];
void flags_startup()
{
entflags[1]=0;
entflags[2]=0;
entflags[3]=0;
entflags[4]=0;
entflags[5]=0;
entflags[6]=POLYGON;
entflags[7]=0;//Local
entflags[8]=0;
entflags[9]=CAST;
entflags[10]=METAL;
entflags[11]=BRIGHT;
entflags[12]=NOFOG;
entflags[13]=0;
entflags[14]=SHADOW;
entflags[15]=UNLIT;
entflags[16]=NOFILTER;
entflags[17]=0;//Flare
entflags[18]=ZNEAR;
entflags[19]=SPOTLIGHT;
entflags[20]=OVERLAY;
entflags[21]=0;
entflags[22]=TRANSLUCENT;
entflags[23]=PASSABLE;
entflags[24]=INVISIBLE;
entflags[25]=FLAG8;
entflags[26]=FLAG7;
entflags[27]=FLAG6;
entflags[28]=FLAG5;
entflags[29]=FLAG4;
entflags[30]=FLAG3;
entflags[31]=FLAG2;
entflags[32]=FLAG1;
}
void set_flags(var flag16)
{
str_cpy(temp_str,"");
if(flag16>0)
{
str_cat(temp_str,"0");//-?
str_cat(temp_str,"0");//-?
str_cat(temp_str,"0");
str_cat(temp_str,"0");//-?
str_cat(temp_str,"0");//-?
ifiselse(POLYGON)//6
str_cat(temp_str,"0");//LOCAL//7
str_cat(temp_str,"0");//8
ifiselse(CAST)//9
ifiselse(METAL)//10
ifiselse(BRIGHT)//11
ifiselse(NOFOG)//12
str_cat(temp_str,"0");//13
ifiselse(SHADOW)
ifiselse(UNLIT)
ifiselse(NOFILTER)
}
str_cat(temp_str,"0");//17
ifiselse(ZNEAR)//18
ifiselse(SPOTLIGHT)//-?//19
ifiselse(OVERLAY)//20
str_cat(temp_str,"0");//17
ifiselse(TRANSLUCENT)//21
ifiselse(PASSABLE)//22
ifiselse(INVISIBLE)//23
ifiselse(FLAG8)//24
ifiselse(FLAG7)//25
ifiselse(FLAG6)//26
ifiselse(FLAG5)//28
ifiselse(FLAG4)//29
ifiselse(FLAG3)//30
ifiselse(FLAG2)//31
ifiselse(FLAG1)//32
file_str_write (wmb_handle,temp_str); skipline;
}
void save_wmb()
{
//variables
var num = 0;
ENTITY* ent;
char* funcname;
var yourtype;
var say=0;
int i;
//Remove $$m & $$w & expalette.pcx
remove("export.$$M");
remove("export.$$w");
remove("expalette.pcx");
wait(-0.5);
//Create $$w file (wad7)
FILE *myfile = fopen("export.$$w", "wb");
int i=0;
for(i=0;i<12;i++)
{
putc(bufferforwad[i], myfile);
}
fclose(myfile);
//Create expalette.pcx file (wad7)
FILE *myfile = fopen("expalette.pcx", "wb");
int i=0;
for(i=0;i<954;i++)
{
putc(bufferforpalette[i], myfile);
}
fclose(myfile);
//Create $$m
wmb_handle = file_open_append("export.$$M");
file_str_write (wmb_handle,"version 711"); skipline;
//level
obrackets;file_str_write (wmb_handle," //level"); skipline;
file_var_write (wmb_handle,0);skipline;
file_str_write (wmb_handle,"export.$$w"); skipline;
file_str_write (wmb_handle,"expalette.pcx"); skipline;
cbrackets;skipline;
//sun
obrackets;file_str_write (wmb_handle," //sun"); skipline;
file_var_write (wmb_handle,5);skipline;
file_var_write (wmb_handle,sun_angle.tilt);skipline;
file_var_write (wmb_handle,sun_angle.pan);skipline;
cbrackets;skipline;
var myflag16=0;
//entities
you = ent_next(NULL);
while (you)
{
draw_text("PLEASE WAIT",10,10,COLOR_RED);
obrackets;file_str_write (wmb_handle," //model"); skipline;
#ifndef ent_id
#define ent_id
yourtype=0;
/*
from sdk:
'wmpio_ModelEntity * model; // id == 3 (7, for model-ex)'
SO CHECK IF EX OR NOT (if has a material or string1-2 or has a action it's 7 else it's 3)
*/
//if(your.materialtype!=NULL)
if(your.material!=mat_model&&your.material!=NULL&&your.material!=mat_terrain)
{
yourtype+=1;
}
//if(your.string1||string2!=NULL)
if(str_len(your.string1)>0||str_len(your.string2)>0)
{
yourtype+=1;
}
num = 0;
say=0;
//Check Entity has an action or not.
for(num = 0; engine_gettaskinfo(num,&funcname,&ent); num++)
{
if(ent == you)
{
yourtype+=1;
break;
}
}
//
if(yourtype>0)
{
file_var_write (wmb_handle,7);skipline;//model-ex
}
else
{
file_var_write (wmb_handle,3);skipline;//model
}
#endif
//xyz
file_var_write (wmb_handle,you.x);
file_var_write (wmb_handle,you.y);
file_var_write (wmb_handle,you.z);skipline;
//pan-tilt-roll
file_var_write (wmb_handle,you.pan);
file_var_write (wmb_handle,you.tilt);
file_var_write (wmb_handle,you.roll);skipline;
//scale
file_var_write (wmb_handle,you.scale_x);
file_var_write (wmb_handle,you.scale_y);
file_var_write (wmb_handle,you.scale_z);skipline;
//Entitiy file name
str_for_entfile(temp_str,you);
file_str_write (wmb_handle,temp_str); skipline;
//Ent name
str_for_entname(temp_str,you);
file_str_write (wmb_handle,temp_str); skipline;
num = 0;
say=0;
//Get action name of Entity (Thanks to MasterQ32&JustSid for tip)
for(num = 0; engine_gettaskinfo(num,&funcname,&ent); num++)
{
if(ent == you)
{
file_str_write (wmb_handle,_str(funcname)); skipline;
say=1;
break;
}
}
//if entity has no action, put ndef
if(say==0)
{
file_str_write (wmb_handle,"ndef"); skipline;
}
//skills
file_var_write (wmb_handle,you.skill1);
file_var_write (wmb_handle,you.skill2);
file_var_write (wmb_handle,you.skill3);
file_var_write (wmb_handle,you.skill4);
file_var_write (wmb_handle,you.skill5);
file_var_write (wmb_handle,you.skill6);
file_var_write (wmb_handle,you.skill7);
file_var_write (wmb_handle,you.skill8);
if(yourtype>0)//type==7
{
file_var_write (wmb_handle,you.skill9);
file_var_write (wmb_handle,you.skill10);
file_var_write (wmb_handle,you.skill11);
file_var_write (wmb_handle,you.skill12);
file_var_write (wmb_handle,you.skill13);
file_var_write (wmb_handle,you.skill14);
file_var_write (wmb_handle,you.skill15);
file_var_write (wmb_handle,you.skill16);
file_var_write (wmb_handle,you.skill17);
file_var_write (wmb_handle,you.skill18);
file_var_write (wmb_handle,you.skill19);
file_var_write (wmb_handle,you.skill20);
}skipline;
//flags
myflag16=0;
i=0;
for(i=1;i<17;i++)
{
if (is(you,entflags[i]))
{
myflag16=1;
}
}
set_flags(myflag16);
file_var_write (wmb_handle,your.ambient);skipline;
//Get material name of Entity
if(your.material!=mat_model&&your.material!=NULL&&your.material!=mat_terrain)
{ file_var_write (wmb_handle,your.albedo);skipline;
file_var_write (wmb_handle,0);skipline; //path
file_var_write (wmb_handle,0);skipline; //attach
str_cpy(temp_str,_chr(your.material.link.name));
file_str_write (wmb_handle,temp_str); skipline;
}
else
{
if(yourtype>0)
{
file_var_write (wmb_handle,your.albedo);skipline;
file_var_write (wmb_handle,0);skipline;//path
file_var_write (wmb_handle,0);skipline;//attach
file_str_write (wmb_handle,"ndef"); skipline; // if no material put ndef
}
}
//string1 string2
if(str_len(your.string1)>0)
{
str_cpy(temp_str,_chr(your.string1));
file_str_write (wmb_handle,temp_str); skipline;
}
if(str_len(your.string2)>0)
{
str_cpy(temp_str,_chr(your.string2));
file_str_write (wmb_handle,temp_str); skipline;
}
cbrackets;skipline;
you = ent_next(you);
wait(1);
}
file_close(wmb_handle);
wait(-1);
//build it with default
exec("%EXE_DIR%\\wwmp2wmb.exe","export.$$M -pal expalette.pcx
-az 10 -el 60
-sunrgb 100 100 100
-ambrgb 100 100 100
-noportals
-hiprec
-writelog
-close
-nodetail
-threads 2
-gamma 1.50
-phongangle 120
-lmambient 50
-sizeshaded 236
-litres 1.00
-litcomp 0.50
-litmax 196
-litscale 0.50
-radsubdiv 64
-radbounce 0
-bound 56000
-fat 64 48 8
-narrow 32 32 0 ");
//exec("%EXE_DIR%\\wwmp2wmb.exe","export.$$M -pal palette.pcx -close");
}
void on_enter_event()
{
save_wmb();
}
About the action, i think loop is necessary for "engine_gettaskinfo" and i don't know the solution.
|
|
|
Re: Save as .wmb
[Re: sivan]
#392757
01/27/12 10:31
01/27/12 10:31
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
Hi again, I did some further tests: - INVISIBLE entities are now perfect - sprites work fine - wmb entities work fine too! - entity specific decal shadows do not work - not possible to apply both decal and stencil shadows in the same level, only one of them can be used at a time (maybe it is wmb property, not compilation fault... I do not really use WED) - entity bounding boxes are not saved as I see - terrains get black only when I load it from script, and assign to it a material, what modifies the ambient values. in other cases it is fine. (if compiled from WED, it does not happen) - unfortunately I could not test terrain shadowmapping, I have now the trial version on my pc but results in "virtual memory too low" or something similar error... some hints for usage: - to use custom compilation add "-dialog " like this: exec("%EXE_DIR%\\wwmp2wmb.exe","-dialog export.$$M -pal expalette.pcx - be careful, sun and ambient RGB is used within interval of 0..100, and not 0..255, (and not BGR!) - fog rgb colors can be added too, like: -fog1 40 38 40 (but fog_color and start and end should be set in script) - use thread -1 , if you have a single core pc at the moment I compile with these flags: exec("%EXE_DIR%\\wwmp2wmb.exe","export.$$M -pal expalette.pcx -az 315 -el 60 -sunrgb 56 49 43 -ambrgb 19 19 19 -fog1 40 38 40 -fog2 71 81 96 -fog3 25 24 33 -fog4 14 15 19 -hiprec -litmapsonly -writelog -mesh -mergeacross -tesselate -solidsky -nodetail -quiet -threads 1 -gamma 1.50 -phongangle 120 -lmambient 50 -sizeshaded 236 -litres 1.00 -litcomp 0.50 -litmax 196 -litscale 0.50 -radsubdiv 64 -radbounce 0 -noportals -nobsp -bound 56000 -fat 64 48 8 -narrow 32 32 0 "); anyway, great work! a .wmp saving tool would be fun too!
|
|
|
Re: Save as .wmb
[Re: sivan]
#392800
01/27/12 16:13
01/27/12 16:13
|
Joined: Jul 2007
Posts: 619 Turkey, Izmir
Emre
OP
User
|
OP
User
Joined: Jul 2007
Posts: 619
Turkey, Izmir
|
Hi Sivan, thanks for test and hints. entity specific decal shadows do not work Afaik decal shadow can't save with wmb. There is no decal shadow in model struct.
{ //model
ent id
xyz
pan tilt roll
scale_xyz
file name
ent name
action name
skills
flags
ambient
albedo
path
attached entity
material
string1
string2
}
entity bounding boxes are not saved as I see Yes, here is problem about BBOX;
if ((you.eflags & FAT) && (you.eflags & NARROW))
{
str_cat(temp_str,"1");
}
else
{
str_cat(temp_str,"0");
}
it does always return str_cat(temp_str,"1"). I have no idea why. a .wmp saving tool would be fun too! indeed But i am not sure that is possible.
|
|
|
Re: Save as .wmb
[Re: Emre]
#392806
01/27/12 17:19
01/27/12 17:19
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
decal shadows and bbox - yes, I checked the manual, only a script can handle decal shadow settings... maybe a trick can help, e.g. if decal shadow name is stored in string1, and created after level load (or run through simply all entities, and check their file names)... but in this case the bounding box determines its size, what also cannot be set properly (no min_x/y/z..max_x/y/z stored) so that should be handled too, in another tricky way, e.g. storing them in 6 skills...
|
|
|
Re: Save as .wmb
[Re: sivan]
#393177
02/01/12 09:06
02/01/12 09:06
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
Hi I just realized that the saved [.$$M] file can be opened/saved directly by WED, thus this [.wmb] exporter is more useful than I thought... (of course it is more limited than [.wmp] but works)
|
|
|
Re: Save as .wmb
[Re: sivan]
#393247
02/01/12 17:36
02/01/12 17:36
|
Joined: Jul 2007
Posts: 619 Turkey, Izmir
Emre
OP
User
|
OP
User
Joined: Jul 2007
Posts: 619
Turkey, Izmir
|
I just realized that the saved [.$$M] file can be opened/saved directly by WED, thus this [.wmb] exporter is more useful than I thought... (of course it is more limited than [.wmp] but works) Cool! I didn't know that! Thanks for info, Sivan. Also thanks for the tip about ascii.
|
|
|
Re: Save as .wmb
[Re: Emre]
#393325
02/02/12 12:40
02/02/12 12:40
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
@Emre: About the mapentity problem. If i remember correctly, the last release of the Newton implementation of GS iterated through all levelblocks and MapEntities to add them to the collision mesh. The loop is written in LiteC, so maybe this helps
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: Save as .wmb
[Re: Emre]
#393490
02/03/12 23:19
02/03/12 23:19
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
Awesome, i was using a custom xml level format(that only saves same stuff as you). This was just what i needed.
3333333333
|
|
|
Re: Save as .wmb
[Re: Quad]
#393639
02/05/12 19:41
02/05/12 19:41
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
one tiny happy thing: if you remove the wait(1); from the end of the while loop, it works fine, but much faster.
moreover, I wrote a small addition that creates the compilation option string based on actual sun ambient and fog colors. I will post it here tomorrow, really simple.
and finally I could integrate it into my MapBuilder editor. I made a short script that recreates bounding boxes and attached decals shadows too, using the tricky approach I mentioned here earlier.
but as I see lod models do not work (having the same name with different endings: *_0.mdl, *_1.mdl, *_2.mdl, *_3.mdl), but don't know why, I think they should work.
|
|
|
Re: Save as .wmb
[Re: sivan]
#393675
02/06/12 10:10
02/06/12 10:10
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
hi again, here is my options string maker script (put after file close instead of the current exec). does anyone know how to run the compiler in background? if I use exec_wait instead of exec, and include -close among options, it is nearly okay, compilation is done while my application is fullscreen and displays a please wait message, but when ready it gets minimized... so at the moment it is better to use simply exec and no -close. //---------------------------------------------------------- // rgb values are iterated from 0..255 to 0..100 !!! and from BRG to RGB !!! // create string for exec options - to set sun pos, sun color, ambient color, fog colors, and default settings str_cpy(temp_str,"export.$$M -pal expalette.pcx "); // sun azimuth str_cat(temp_str," -az "); str_cat(temp_str,str_for_int(NULL,(int)sun_angle.pan)); str_cat(temp_str," "); // sun elevation str_cat(temp_str,"-el "); str_cat(temp_str,str_for_int(NULL,(int)sun_angle.tilt)); str_cat(temp_str," "); // sun color str_cat(temp_str," -sunrgb "); str_cat(temp_str,str_for_int(NULL,integer(sun_color.red/2.55))); str_cat(temp_str," "); str_cat(temp_str,str_for_int(NULL,integer(sun_color.green/2.55))); str_cat(temp_str," "); str_cat(temp_str,str_for_int(NULL,integer(sun_color.blue/2.55))); str_cat(temp_str," "); // ambient str_cat(temp_str," -ambrgb "); str_cat(temp_str,str_for_int(NULL,integer(ambient_color.red/2.55))); str_cat(temp_str," "); str_cat(temp_str,str_for_int(NULL,integer(ambient_color.green/2.55))); str_cat(temp_str," "); str_cat(temp_str,str_for_int(NULL,integer(ambient_color.blue/2.55))); str_cat(temp_str," "); // fog1 str_cat(temp_str," -fog1 "); str_cat(temp_str,str_for_int(NULL,integer(d3d_fogcolor1.red/2.55))); str_cat(temp_str," "); str_cat(temp_str,str_for_int(NULL,integer(d3d_fogcolor1.green/2.55))); str_cat(temp_str," "); str_cat(temp_str,str_for_int(NULL,integer(d3d_fogcolor1.blue/2.55))); str_cat(temp_str," "); // fog2 str_cat(temp_str," -fog2 "); str_cat(temp_str,str_for_int(NULL,integer(d3d_fogcolor2.red/2.55))); str_cat(temp_str," "); str_cat(temp_str,str_for_int(NULL,integer(d3d_fogcolor2.green/2.55))); str_cat(temp_str," "); str_cat(temp_str,str_for_int(NULL,integer(d3d_fogcolor2.blue/2.55))); str_cat(temp_str," "); // fog3 str_cat(temp_str," -fog3 "); str_cat(temp_str,str_for_int(NULL,integer(d3d_fogcolor3.red/2.55))); str_cat(temp_str," "); str_cat(temp_str,str_for_int(NULL,integer(d3d_fogcolor3.green/2.55))); str_cat(temp_str," "); str_cat(temp_str,str_for_int(NULL,integer(d3d_fogcolor3.blue/2.55))); str_cat(temp_str," "); // fog4 str_cat(temp_str," -fog4 "); str_cat(temp_str,str_for_int(NULL,integer(d3d_fogcolor4.red/2.55))); str_cat(temp_str," "); str_cat(temp_str,str_for_int(NULL,integer(d3d_fogcolor4.green/2.55))); str_cat(temp_str," "); str_cat(temp_str,str_for_int(NULL,integer(d3d_fogcolor4.blue/2.55))); str_cat(temp_str," "); // remaining default values str_cat(temp_str," -hiprec -litmapsonly -writelog -mesh -mergeacross -tesselate -solidsky -nodetail -threads 1 -gamma 1.50 -phongangle 120 -lmambient 50 -sizeshaded 236 -litres 1.00 -litcomp 0.50 -litmax 196 -litscale 0.50 -radsubdiv 64 -radbounce 0 -noportals -nobsp -bound 56000 -fat 64 48 8 -narrow 32 32 0 "); exec( "%EXE_DIR%\\wwmp2wmb.exe" , temp_str );
|
|
|
Re: Save as .wmb
[Re: gamers]
#393903
02/08/12 11:54
02/08/12 11:54
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
How can we use this code ? Please explain it step by step...
Is this a joke? If not, copy the code in your script and call save_wmb(); That is all you have to do
|
|
|
Re: Save as .wmb
[Re: Widi]
#394041
02/09/12 14:36
02/09/12 14:36
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
@Emre: maybe you can add a paremeter(FileName) so users can decide the name/location by themself?
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: Save as .wmb
[Re: Rackscha]
#394052
02/09/12 15:58
02/09/12 15:58
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
I just did it today afternoon And also I solved to place them to a subfolder. It could cause problems during compilation and when opening with WED, if the subfolder is set in the beginning. Thus I apply compiling locally, and moving the 4 files afterwards to the right place. The code is a bit messy, and specific for my application, but I will clear and finalize it to be publishable in the near future...
|
|
|
Re: Save as .wmb
[Re: sivan]
#398447
04/02/12 09:01
04/02/12 09:01
|
Joined: Jul 2007
Posts: 619 Turkey, Izmir
Emre
OP
User
|
OP
User
Joined: Jul 2007
Posts: 619
Turkey, Izmir
|
Thanks! Albedo and ambient are automatically saved by wed. My code working like so. That's simply wmb format and i can't change it. I can't add alpha value and using skill is good way for your editor. As you know Albedo is saved as entity->albedo with my code. (Also ambient.) This can sometimes cause problems. You can set it default value as Wed. file_var_write (wmb_handle,your.albedo);skipline;file_var_write (wmb_handle,50);skipline; file_var_write (wmb_handle,your.ambient);skipline; file_var_write (wmb_handle,0);skipline;
|
|
|
Re: Save as .wmb
[Re: Emre]
#473239
06/23/18 03:57
06/23/18 03:57
|
Joined: Jul 2007
Posts: 619 Turkey, Izmir
Emre
OP
User
|
OP
User
Joined: Jul 2007
Posts: 619
Turkey, Izmir
|
I realized something when i solved this problem. If the name of the model is longer than 8 characters, the model type must be set 7. A similar code can be used.
str_for_entfile(tempstr,you);
if(str_len(tempstr)>12)//model name+4character for ".mdl"
{
yourtype+=1;// or whatever you want to use
}
and there is no need put "ndef" for material if type is 7. So just close the line;
if(yourtype>0)
{
file_var_write (wmb_handle,your.albedo);skipline;
file_var_write (wmb_handle,0);skipline;//path
file_var_write (wmb_handle,0);skipline;//attach
//file_str_write (wmb_handle,"ndef"); skipline; // if no material put ndef
}
|
|
|
|