Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Level Design (https://forums.graalonline.com/forums/forumdisplay.php?f=6)
-   -   Nw2png (https://forums.graalonline.com/forums/showthread.php?t=134259601)

cbk1994 01-18-2011 08:17 PM

Quote:

Originally Posted by DustyPorViva (Post 1623852)
Just stops at "Generating..." no matter what I do.

Try launching it with "java -jar NW2PNG.jar" from the command line and see if it shows any errors when you hit "Generate" (the errors would be shown in the command prompt.)

WhiteDragon 01-18-2011 10:36 PM

I think the major upgrade you can do to this is not keep the whole image or the whole gmap in memory. Work with both of them in chunks which occasionally get read/written to disk.

cbk1994 01-18-2011 10:59 PM

Quote:

Originally Posted by WhiteDragon (Post 1623899)
I think the major upgrade you can do to this is not keep the whole image or the whole gmap in memory. Work with both of them in chunks which occasionally get read/written to disk.

I don't know much about Java's image libraries but I'm guessing it may not be possible since it would need the whole image in memory to save it as a PNG.

born2kill 01-20-2011 09:34 PM

Oh hey ;)
First of all I'm glad that this project is still alive and very impressed that cbk worked on it
Well I left graal a longer time ago because of school and other stuff and
Im kinda sorry for the rather crappy source code (Thats how it looks like in my eyes nowdays)
Well in the last months/years I worked like 24/7 with Java - for school and personal stuff
and even for my own MMO 2D game ( + The Android App for it ;) )
(Not released yet :P)

I just wanted to say that Im going to do a little rewrite on the system, including any functionality you guys want to have

@cbk if you want you can do a little gui for it too :P

MattKan 01-26-2011 02:55 AM

Just out of curiosity, what does .nw stand for?

xXziroXx 01-26-2011 02:57 AM

Quote:

Originally Posted by MattKan (Post 1625561)
Just out of curiosity, what does .nw stand for?

New Level. Old format was .graal.

DustyPorViva 01-26-2011 02:58 AM

New World. It was an old Graal Project, which the format was adopted for(along with other things, like the NPC Server).

NicoX 01-26-2011 03:16 AM

Lol Ziro how you come on New Level xD ".nl" ??? xD

WhiteDragon 01-26-2011 03:49 AM

Quote:

Originally Posted by NicoX (Post 1625568)
Lol Ziro how you come on New Level xD ".nl" ??? xD

Probably new level.

Fulg0reSama 01-26-2011 03:54 AM

Quote:

Originally Posted by DustyPorViva (Post 1625563)
New World. It was an old Graal Project, which the format was adopted for(along with other things, like the NPC Server).

I believe dusty is right (when isn't he?)

MattKan 01-26-2011 04:37 AM

Quote:

Originally Posted by DustyPorViva (Post 1625563)
New World. It was an old Graal Project, which the format was adopted for(along with other things, like the NPC Server).

New World? . >_<

xXziroXx 01-26-2011 10:33 AM

Quote:

Originally Posted by NicoX (Post 1625568)
Lol Ziro how you come on New Level xD ".nl" ??? xD

I actually meant New World, but I wrote it at 3 AM just before going to bed. x_x

NicoX 01-26-2011 01:40 PM

Xd

xAndrewx 01-27-2011 10:07 PM

Quote:

Originally Posted by xXziroXx (Post 1625562)
New Level. Old format was .graal.

lol <3 ziro

papajchris 08-21-2011 06:17 AM

Trying this out and i cant seem to get it work for Era's gmap. I gave it a hour to load and it was still stuck at "generating..." When i try to use the command you gave dusty, it says "unable to access jarfile nw2png.jar".

I tried single levels and those worked, and even tried small gmaps (era_snowresort) which also worked.

Using windows 7/64 bit

cbk1994 08-21-2011 06:23 AM

Quote:

Originally Posted by papajchris (Post 1664596)
Trying this out and i cant seem to get it work for Era's gmap. I gave it a hour to load and it was still stuck at "generating..." When i try to use the command you gave dusty, it says "unable to access jarfile nw2png.jar".

You will need to use the absolute path to the JAR unless it's in your working directory.

If I recall correctly, something like
java -jar C:\Users\You\Desktop\NW2PNG.jar
should work on Windows (obviously changing the path to match your setup).

If you see an OutOfMemoryError in the console after you try to generate the map, close the program, then run it like
java -Xmx1000m -jar C:\Users\You\Desktop\NW2PNG.jar
to allow more heap space. I think 1000 MB ("1000m") was enough when I last did Era's (it took a few minutes, but it will take more if you have to swap).

papajchris 08-21-2011 06:43 AM

Hmm it doesnt seem to be finding the location.

It continues to say "unable to access jarfile...." However it seems to be shortening the location in the error (could that be an issue?)

when i type in java -jar C:\Users\FIRST LAST\Desktop\NW2PNG.jar

it returns "unable to access jarfile c:\users\FIRST"

Im opening up the properties of nw2png.jar and copying the location exactly (and then adding \NW2PNG.jar to the end), so i don't think my location is an issue?

Crow 08-21-2011 12:57 PM

Quote:

Originally Posted by papajchris (Post 1664600)
Hmm it doesnt seem to be finding the location.

It continues to say "unable to access jarfile...." However it seems to be shortening the location in the error (could that be an issue?)

when i type in java -jar C:\Users\FIRST LAST\Desktop\NW2PNG.jar

it returns "unable to access jarfile c:\users\FIRST"

Im opening up the properties of nw2png.jar and copying the location exactly (and then adding \NW2PNG.jar to the end), so i don't think my location is an issue?

Add quotation marks around the path to the JAR; needs to be done if the path contains spaces.

papajchris 08-22-2011 09:02 PM

The quotes made a new NW2PNG open up, but its still stuck at "Generating" 20 min. I tried the second command (to increase mb size) Chris and again a new window popped up, and 10 min later still no luck.

Edit: After messing around with the size, i had to increase it to over 8000 to get it to work. Thanks guys

cbk1994 08-23-2011 05:36 AM

Quote:

Originally Posted by papajchris (Post 1664904)
Something doesnt seem right. When i choose the tileset and choose eras online tileset, i have to have the mb size at 15000. That results in a 18mb image... If i use pics1 though, i can use 3000 (though obviously none of the levels show up). Anyway to reduce the size of the image?

Probably because Era's online tileset is a 24-bit PNG, not an 8-bit one like pics1. You could use Era's offline tileset (or, if it's no longer updated, create an 8-bit version of the online one) and should be able to use less memory. You likely won't notice the difference in quality at a reasonable scale anyway.

Reducing the scale (even to 1:2 or 1:4) should also significantly reduce the memory requirements. The number you're specifying (15000) is the maximum memory it's allowed to use before it crashes (or freezes). It may actually be using far less than that. I suspect watching the process in Task Manager would give you some insight.

DustyPorViva 11-18-2011 08:23 AM

I've finally got this working, and it's awesome except one thing... I can't seem to get it to load images from Graal/*. It seems to load one image(townsign.png) but even if I add my new images into the Graal folder I can't seem to get it to render them.

Also, any chance it can support setimgpart? Kind of ruins maps when NPCs intended to be cropped are rendered fully.

callimuc 11-18-2011 05:24 PM

1 Attachment(s)
Doesn´t seem to work for me. This is what I made

Attachment 53946

The error translated into english means something like:
The command "-jar" is either wroten wrong or it couldn´t be found.

fowlplay4 11-19-2011 01:28 AM

You need to put java in front of that. -jar is just a switch/parameter.

java -jar "path/to/jar"

callimuc 11-19-2011 03:29 AM

Quote:

Originally Posted by fowlplay4 (Post 1674596)
You need to put java in front of that. -jar is just a switch/parameter.

java -jar "path/to/jar"

Tried using that (java -jar "C:\Users\The Boss\Desktop\Neuer Ordner (2)\NW2PNG.jar") but still didn´t work. The same error comes up.

cbk1994 11-19-2011 03:38 AM

Quote:

Originally Posted by callimuc (Post 1674606)
Tried using that (java -jar "C:\Users\The Boss\Desktop\Neuer Ordner (2)\NW2PNG.jar") but still didn´t work. The same error comes up.

Do you have Java installed? Maybe you need to add it to your PATH (or equivalent in Windows).

Quote:

Originally Posted by DustyPorViva (Post 1674539)
I've finally got this working, and it's awesome except one thing... I can't seem to get it to load images from Graal/*. It seems to load one image(townsign.png) but even if I add my new images into the Graal folder I can't seem to get it to render them.

Also, any chance it can support setimgpart? Kind of ruins maps when NPCs intended to be cropped are rendered fully.

Where is your Graal folder located? It's only looking in certain locations by default. It also only looks in the images folder (e.g. levels/images/era/era_gun.png for images that have underscores, levels/images/downloads/sign.png for images without).

I can see about setimgpart but it would be difficult to reliably parse scripts for this. Might be possible to add an option to simply not show these images, as well as one to try to parse it, and one to show the full image.

DustyPorViva 11-19-2011 06:15 AM

Quote:

Originally Posted by cbk1994 (Post 1674608)
Where is your Graal folder located? It's only looking in certain locations by default. It also only looks in the images folder (e.g. levels/images/era/era_gun.png for images that have underscores, levels/images/downloads/sign.png for images without).

I can see about setimgpart but it would be difficult to reliably parse scripts for this. Might be possible to add an option to simply not show these images, as well as one to try to parse it, and one to show the full image.

It's in Program Files/Graal/*

Does this folder have to go in the Graal folder? Also, I'm editing the code right now to try to make it parse setimgpart.

cbk1994 11-19-2011 06:33 AM

Quote:

Originally Posted by DustyPorViva (Post 1674619)
It's in Program Files/Graal/*

Does this folder have to go in the Graal folder? Also, I'm editing the code right now to try to make it parse setimgpart.

As long as it's in the right place in the Graal folder it should be fine—it doesn't scan the folders, it only looks in levels/images/ in the proper subfolder (based on where it would be downloaded if you saw it online).

If it's not working it's possible it's detecting some other directory first (e.g. if you have a C:/Graal/ folder; you can see the full list in the source code).

DustyPorViva 11-19-2011 10:08 AM

2 Attachment(s)
Quote:

Originally Posted by cbk1994 (Post 1674623)
As long as it's in the right place in the Graal folder it should be fine—it doesn't scan the folders, it only looks in levels/images/ in the proper subfolder (based on where it would be downloaded if you saw it online).

If it's not working it's possible it's detecting some other directory first (e.g. if you have a C:/Graal/ folder; you can see the full list in the source code).

I've tried putting the images directly into the Graal folder. I've tried putting them into the NW2PNG images/ folder. I've tried putting them in the Graal/levels/images/downloads/ folder, but still nothing. I just tried putting NW2PNG in the Graal folder itself, with the images alongside it inside the Graal folder, and nothing.

Also, I've finally got it working to parse setimgpart. It works with setimgpart img,x,y,w,h; as well as setimgpart(img,x,y,w,h); Right now though it's only working for gmaps, not NW rendering. Tomorrow I might try to make it remember directories, because constantly having to go and define the tileset, gmap and output file over and over when you're working on the same map each time is a little frustrating.

DustyPorViva 11-19-2011 01:31 PM

2 Attachment(s)
Err, sorry, I wouldn't advise using the one posted above. I made some errors and it didn't always render properly.

I fixed it up though, as well as made a useful addition. It can now render NPCs stacked on top of each other even if they share the same image name and position(before it was having conflicts trying to scan for the NPC).

Big change I had to make for myself was now when loading images it uses Graal's FILENAMECACHE.txt to more accurately find the image. As long as your filenamecache is up to date it(and your Graal folder loaded at C:/Program Files/Graal/) should easily find the images needed. If you need to update your filenamecache just open your Graal folder and delete FILENAMECACHE.txt and then run Graal once.

callimuc 11-19-2011 04:49 PM

Quote:

Originally Posted by cbk1994 (Post 1674608)
Do you have Java installed?

Yes


Just reinstalled Java and added it to this ´Path´ thing. Worked, thanks.

cbk1994 11-19-2011 08:11 PM

Quote:

Originally Posted by DustyPorViva (Post 1674638)
Big change I had to make for myself was now when loading images it uses Graal's FILENAMECACHE.txt to more accurately find the image. As long as your filenamecache is up to date it(and your Graal folder loaded at C:/Program Files/Graal/) should easily find the images needed. If you need to update your filenamecache just open your Graal folder and delete FILENAMECACHE.txt and then run Graal once.

Nice work, thanks for releasing your code.

DustyPorViva 11-19-2011 08:31 PM

2 Attachment(s)
Alright, now it remembers your file selection and/or directory. This should make it easier to work with a map since you can just open it and render the last map you loaded. Next addition I make will just to fix the NW renderer to work like the GMAP one and then I think I'm done. Can't think of anything else this could use.

Emera 11-19-2011 09:00 PM

Quote:

Originally Posted by DustyPorViva (Post 1674677)
Alright, now it remembers your file selection and/or directory. This should make it easier to work with a map since you can just open it and render the last map you loaded. Next addition I make will just to fix the NW renderer to work like the GMAP one and then I think I'm done. Can't think of anything else this could use.

Could you perhaps tweak it so it doesn't crash while trying to make an image for a larger GMAP please? It would be a great help.

cbk1994 11-19-2011 09:11 PM

Quote:

Originally Posted by Emera (Post 1674683)
Could you perhaps tweak it so it doesn't crash while trying to make an image for a larger GMAP please? It would be a great help.

If it's crashing it's because you ran out of memory. I gave instructions on how to fix this in another post in this thread.

DustyPorViva 11-19-2011 09:14 PM

Quote:

Originally Posted by Emera (Post 1674683)
Could you perhaps tweak it so it doesn't crash while trying to make an image for a larger GMAP please? It would be a great help.

Ya, what Chris said. It has to store everything it's rendering somewhere, and memory happens to be where it's stored. If the size of what it's rendering exceeds your memory there's not much that anyone can do other than look into what Chris suggested.

Emera 11-19-2011 09:23 PM

Quote:

Originally Posted by cbk1994 (Post 1674686)
If it's crashing it's because you ran out of memory. I gave instructions on how to fix this in another post in this thread.

Quote:

Originally Posted by DustyPorViva (Post 1674687)
Ya, what Chris said. It has to store everything it's rendering somewhere, and memory happens to be where it's stored. If the size of what it's rendering exceeds your memory there's not much that anyone can do other than look into what Chris suggested.

My eyes completely missed that. It took 2000MB for it to work. Thanks.

DustyPorViva 11-20-2011 01:18 AM

2 Attachment(s)
Alright, guess this is the last update, unless I get ballsy and try to add addtiledef2 support, or redo the rendering to not rely on a buffer(meaning no more memory problems). I simply updated the renderNW function to the same standards of renderGMAP, meaning it now supports setimgpart.

So 2.0 changelog:
- setimgpart support for both NW rendering and GMAP
- recoded NPC storage and rendering
- adjusted GUI's to remember locations, even after closing the application

DustyPorViva 11-20-2011 08:15 AM

2 Attachment(s)
Alright, I think this is it. Added addtiledef2 img,dest,x,y; and addtiledef2("img","dest",x,y); support. However, right now it scans through the levels, and doesn't use tiledefsOffline.txt. I don't seem to have the file, so I'm assuming it doesn't work or something *shrug*. So make sure you have at least one NPC on the overworld that defines the tiledefs.

I think this is pretty complete now, should be able to render most maps efficiently :)

I also included a shortcut in the folder that increases the memory heap for the program. I'm not sure if the shortcut will work for anyone else, but you can try it. It's at 1300mb, but if you right click the short cut and go into properties you can change it via changing:

-Xmx1300m

to something like

-Xmx2000m

This will allow the program more memory to render larger maps. But if you raise the number too high the program won't even manage to run.

edit: I've updated it to catch the memory errors, so it shouldn't just hang at "Generating..." if not enough memory is allocated. I've also included a BAT that lets you define the memory allocation before it starts the program.

ffcmike 11-21-2011 07:59 AM

Now I finally figured out how to get this to work it is quite excellent.

One problem I noticed though is that having 2 different lines of setimgpart within the same script causes it to break.
In this case I had a setimgpart both Clientside in GS1 and serverside in GS2:
PHP Code:

function onCreated(){
  
this.setimgpart("classic_levelitem_roof_church.png"64012848);
}

//#CLIENTSIDE
if(created){
  
setimgpart classic_levelitem_roof_church.png64012848;


One improvement that would be great to have is the ability to assign image names to detectable joined classes.

DustyPorViva 11-21-2011 08:33 AM

1 Attachment(s)
Quote:

Originally Posted by ffcmike (Post 1674903)
Now I finally figured out how to get this to work it is quite excellent.

One problem I noticed though is that having 2 different lines of setimgpart within the same script causes it to break.
In this case I had a setimgpart both Clientside in GS1 and serverside in GS2:
PHP Code:

function onCreated(){
  
this.setimgpart("classic_levelitem_roof_church.png"64012848);
}

//#CLIENTSIDE
if(created){
  
setimgpart classic_levelitem_roof_church.png64012848;


One improvement that would be great to have is the ability to assign image names to detectable joined classes.

Here ya go, should be fixed!

Edit: Oops, I uploaded a bugged version! I accidentally broke some of the parsing so here's a new fixed one that SHOULD work!


All times are GMT +2. The time now is 04:03 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.