3 registered members (7th_zorro, Aku_Aku, 1 invisible),
579
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
save hmp file dll
#450136
04/07/15 09:37
04/07/15 09:37
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
here's a contribution to save hmp terrain --- http://www.datafilehost.com/d/5998324bdeclare this function in your project:
int save_hmp(char* filename,ENTITY* terrain,int skip_original_pixels);
set skip_original_pixels to 1 ,if you want to skip the original image pixel data , and try to rather use the pixel data from the bmap buffers, use this if you want to save modified pixel operations . else set it to 0. --- include save_hmp.dll in your project folder . then call this function to save your terrain entity out to file . --- has skin support , bmp and tga supports modified pixel data . dds and png and jpg only supports non modified pixel data and "skip_original_pixels" wil default to 0 , no matter what the value "skip_original_pixels" was set to when you called the function (for now anyway)...
Last edited by Wjbender; 04/15/15 20:58.
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: 3run]
#450142
04/07/15 10:48
04/07/15 10:48
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
roger that , over and out
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: sivan]
#450146
04/07/15 11:47
04/07/15 11:47
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
did you write that dll ? or where did you get it .
I am surely planning on that , however my current understanding of the ctexture & cskin information ,is a bit vague , especially working from the bmap pointers of the skin's data towards completely correct data for ctexture and cskin , well I believe that's where I am supposed to retrieve my data to fill up ctexture and cskin .
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: sivan]
#450149
04/07/15 12:02
04/07/15 12:02
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
well it appears to be just arrays of (color per pixel) with bmap->bytespp, either arranged as rgb or bgr , I think I can manage .
Last edited by Wjbender; 04/07/15 12:16.
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: sivan]
#450156
04/07/15 14:27
04/07/15 14:27
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
hhmm maby I should add dds and whatever , currently I only have simple bmp skins
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: sivan]
#450185
04/08/15 09:40
04/08/15 09:40
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
thanks superku.
@sivan well tga ,bmp worked okay when I tested , jpg dds png however is a different story .
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: sivan]
#450221
04/09/15 16:47
04/09/15 16:47
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
can you give me a code example ?
I couldn't reproduce the problem .
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: sivan]
#450237
04/10/15 08:08
04/10/15 08:08
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
the test I did was , I loaded a hmp with textures applied (which is what I presume you do) then I replaced the skins with different textures , I then saved it ,removed the entity , and loaded it ,everything were correctly saved and applied ..
I also tested with ent_reload but this one seems to have a problem , because it doesn't reload the whole mesh , possible a bug there with terrain and ent_reload?
are you saving your modified files before saving the hmp ? or are you altering the skins bmp's then saving just the hmp ?
I wil conduct some bmp_lock ,with alterations on the pixels tests today .
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: sivan]
#450245
04/10/15 09:33
04/10/15 09:33
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
the pointer of data I am using to fill the data pointer of the hmp before saving , is the pointer available to palettized pixels of the original image .
oh and the manual states that a bmap_save's image format can only be read back with bmap_load and can not be used for BMAP definitions or textures. .
I see the issue , thank you.
Last edited by Wjbender; 04/10/15 09:45.
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: Wjbender]
#450252
04/10/15 14:29
04/10/15 14:29
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
try the new dll , set skip_original_pixels to 1 if you want the modified pixel data to be saved instead of the original pixel data .
jb
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: sivan]
#450290
04/11/15 16:55
04/11/15 16:55
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
the new function must be declared as :
int save_hmp(char* filename,ENTITY* terrain,int skip_original_pixels);
to save the original pixel data , if you just replaced the skins with other files :
if (save_hmp("hmpfilenamehere.hmp",terrain_entity_here,0)) // success
to save the pixel data that was modified with for example bmap_lock operations ,instead :
if (save_hmp("hmpfilenamehere.hmp",terrain_entity_here,1)) // success
that's how it is for now. yes the link is updated on the first page first post
Last edited by Wjbender; 04/11/15 17:03.
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: Wjbender]
#450294
04/11/15 20:30
04/11/15 20:30
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
hey, it works! the only issue happens (crash on save), when there is an empty or NULL skin (skin without texture). I have an optimized shader where I sometimes use such an arrangement. and dds support would be great! thanks for the efforts!
|
|
|
Re: save hmp file dll
[Re: sivan]
#450298
04/11/15 20:56
04/11/15 20:56
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
okay I'll sort out with more error checking .
I am working on it on and off , between 2 other projects ,sometimes I multitask between all 3 ,coding/ testing and improving a few lines of code at a time .
glad it helps out for now .
edit: <-- am I now the one who's name they dare not speak 666 posts
Last edited by Wjbender; 04/11/15 21:01.
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: Wjbender]
#450315
04/12/15 11:03
04/12/15 11:03
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
fixed ,updated link and info on page 1 , 1st post
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: Wjbender]
#450365
04/13/15 12:04
04/13/15 12:04
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
thanks, it help me to find some bugs in MapBuilder (some missing protections of null textures) further tests: if the skin texture is not square, and modified, it is not saved, the original is kept (square textures are saved properly)
|
|
|
Re: save hmp file dll
[Re: sivan]
#450368
04/13/15 13:09
04/13/15 13:09
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
didn't test it but I believe that should work now .
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: Wjbender]
#450373
04/13/15 14:04
04/13/15 14:04
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
unfortunately it doesn't work... or the link is old, dll file size is the same, what can rarely happen.
Last edited by sivan; 04/13/15 14:05.
|
|
|
Re: save hmp file dll
[Re: sivan]
#450387
04/13/15 15:32
04/13/15 15:32
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
okay I also noticed a size difference with the one on my pc , I uploaded it , let me know because as I read my code it should work .
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: sivan]
#450474
04/15/15 11:51
04/15/15 11:51
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
mm I must have missed a line of original width & height code likely.
just to be clear , how are you resizing the images ?
and are you using skip_original_pixels set to 1 or 0
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: Wjbender]
#450491
04/15/15 20:57
04/15/15 20:57
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
as stated above I found one I missed , and corrected it . if it doesn't save correct now , I would need more details in the methods involved .
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: Wjbender]
#450492
04/15/15 20:57
04/15/15 20:57
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
as stated above I found one I missed , and corrected it . if it doesn't save correct now , I would need more details in the methods involved .
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: Wjbender]
#450510
04/16/15 07:29
04/16/15 07:29
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
hi, no success, only square skins are saved well, here is the colouring code I used for testing:
void TerEdit_Tx_SetColor()
{
wait(3);
int skin_int = teredit_tx_selected+1+(teredit_tx_set-1)*max_teredit_tx_items;
if (skin_int > teredit_tx_count) return; // protection
if (!ent_getskin(terrain_entity, skin_int))
{
return;
}
TerEdit_Tx_Color( bmap_for_entity(terrain_entity , skin_int) , vector(teredit_tx_blue,teredit_tx_green,teredit_tx_red) );
wait_for(TerEdit_Tx_Color);
}
void TerEdit_Tx_Color(BMAP* bmap_pointer, COLOR* to_color)
{
if (bmap_pointer == NULL)
{
return;
}
var pixel_format = bmap_lock(bmap_pointer,0); // lock and get format
if (pixel_format >= 565)
{
var pixel;
COLOR pixel_color;
var pixel_alpha;
int i,j;
for(i=0;i<bmap_width(bmap_pointer);i++)
{
for(j=0;j<bmap_height(bmap_pointer);j++)
{
pixel = pixel_for_bmap( bmap_pointer , i , j ); // get pixel
pixel_to_vec( pixel_color , pixel_alpha , pixel_format , pixel ); // get color and alpha
pixel = pixel_for_vec( to_color , pixel_alpha , pixel_format ); // set alpha
pixel_to_bmap( bmap_pointer , i , j , pixel ); // set pixel
}
}
}
bmap_unlock(bmap_pointer);
bmap_to_mipmap(bmap_pointer); // @@@ update mipmaps after unlocking, to avoid the original skin to appear from big distance
wait(1);
TerEdit_Tx_UpdateSets32(); // uses bmap_blit to copy skin texture to thumbnail
TerrHmp_Tx_UpdateMaterialSkins(); // sets material skins to entity skins due to shader requirements
wait(1);
}
|
|
|
Re: save hmp file dll
[Re: sivan]
#450512
04/16/15 07:40
04/16/15 07:40
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
okay I wil look at the code , could it be possible that its a limitation ? I remember reading something about width and height being able to support non square values but the engine keeps it a power of 2 , I may be confusing this with something else but if I find it I wil tel you
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: sivan]
#450519
04/16/15 10:22
04/16/15 10:22
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
in the manual , I found this :
If the texture had no mipmaps before, modified texture content gets lost when creating the mipmap chain the first time. Thus, create the mipmaps before modifying the texture, and call bmap_to_mipmap afterwards a second time for updating the modified content to the other mipmaps. This function can not be applied to compressed (DDS), cubic, normal, tangent, rendertarget, or other special bitmaps. If required, create the mipmaps before converting the bitmap to a special format (for instance bmap_to_cubemap(bmap_to_mipmap(skymap)). Creating mipmaps afterwards will otherwise render the special bitmap unusable.
there's a problem with your code there(if you didn't have mipmaps before ) and I do not save mipmaps out to file yet.
I tested by doing pixel operations , followed by bmap_to_mipmap , which destroyed the modifications and results in behaviour you would not want ,if you were planning on keeping the pixel alterations ..
but still , how are you resizing the bmaps to be non square ? I mean what function ?
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: Wjbender]
#450529
04/16/15 19:58
04/16/15 19:58
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
ahh thanks! a missed info. I can do that mipmap generation on texture editor initialization.
they are pre-made textures, 4 textures are combined into one, to easily access 8 textures from the terrain shader as 4 entity and 4 material skins (global color map, global normal map, rgba blendmap1, rgba blendmap2, 1st 1x4 color map, 1st 1x4 optional normal map, 2nd 1x4 color map, 2nd 1x4 optional normal map), but I could make 2x2 arrangement instead of 1x4, but with Gimp it is easier to create 1x4.
|
|
|
Re: save hmp file dll
[Re: sivan]
#450533
04/16/15 20:35
04/16/15 20:35
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
okay so you made texture atlases ,I understand .
how do you feed the texture parts from the atlas, as new bmap skins , before you save ?
and what format are those bmaps ?
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: sivan]
#450547
04/17/15 09:18
04/17/15 09:18
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
I have tested with
bmap_createpart bmap_createblack bmap_blitpart
with non square sizes , to try and duplicate your problem when you said it doesn't save non square skins .
but all of those saved them out , however they are filled with black to make them powers of 2, by the engine when applied as a texture skin , that's the only thing I can think of now ,that bears any kind of similarities with your problem , because I am stil not sure what functions your using so that I can try and duplicate the problem .
edit : let me look in to this a bit more
Last edited by Wjbender; 04/17/15 10:30.
Compulsive compiler
|
|
|
Re: save hmp file dll
[Re: Wjbender]
#450549
04/17/15 10:31
04/17/15 10:31
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
unfortunately I cannot give a simple answer as in MapBuilder I use different configurations for single skin + detail map terrains, and for multitexturing where blending is stored in the alpha channel. if you are patient enough and want to read a lot, it is within MBteredit_tx.h/.c and MBterrhmp.h/.c. later I'm planning to upload it to GitHub, it would be easier to discuss. so it is okay now, this mipmap thingie at least fixed some other issues and I can change my shaders to use square atlas maps. currently I'm mostly using an autotexturing shader, which is much better for using with many levels than to save skins to every hmp-s (and I frequently use the same hmp for many levels beside a deformation info file), thus imo it is better if you don't invest too much time into my problem at the moment. and I'm not sure how much I will work with 3dgs in future... the dll basically works fine beside this limitation.
|
|
|
Re: save hmp file dll
[Re: sivan]
#450550
04/17/15 10:40
04/17/15 10:40
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
OP
User
|
OP
User
Joined: Mar 2012
Posts: 927
cyberspace
|
I found this in the manual under bmap_lock
After locking an uncompressed bitmap, you can access its texture content directly through the bmap.finalbits pointer. The texture size (in bytes) is given through (mybmap.finalwidth * mybmap.finalheight * bmap.finalbytespp). The texture size is normally a power of 2 and not identical to the original image size returned by bmap_width and bmap_height.
I just had to know why and what goes wrong
Compulsive compiler
|
|
|
|