Map thumbnail script

General talk about the map making process.
Post Reply
User avatar
blast
General
General
Posts: 4933
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Map thumbnail script

Post by blast »

Here is my "work in progress" map thumbnail script. It's done in pure PHP and uses GD to make the images. You can view examples of it, just note that it's not done yet. This is all generated in real-time from actual map files. It's hosted on my home computer, so it might not be up or responding when you visit. It uses some code from my previous script, and it also uses some from jzaun's old stats.bzflag.org thumbnailer script.

Clock.bzw (Size: 1 | 2 | 3 | 4) (world weapons)

bigtest.bzw (Size: 1 | 2 | 3 | 4)

pyramid.bzw (Size: 1 | 2 | 3 | 4)

parthworld.bzw (Size: 1 | 2 | 3 | 4)

[EDIT]
Upload script
View map list
[/EDIT]

Things to do yet:
* Add map name to image
* Code optimizations

Things that are done:
* Draw line around objects (optional)
* Alpha blending (optional)
* Supports world size
* Can write to browser or file
* Can specify image size
* Draw teleporters
* Draw world weapons
* Add watermark
Last edited by blast on Mon Mar 29, 2004 8:00 pm, edited 4 times in total.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
Grumbler
Dev Monkey
Dev Monkey
Posts: 453
Joined: Wed Jul 09, 2003 3:06 pm
Location: Space

Post by Grumbler »

cool. Its very blue, is that configurable?
.........you kids, get out of my tank...........
User avatar
blast
General
General
Posts: 4933
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Post by blast »

Yeah, that will be configurable.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
User avatar
toaster
Private First Class
Private First Class
Posts: 457
Joined: Sat Feb 21, 2004 4:44 pm

Post by toaster »

Nice! Next thing you know, you'll be getting requests to make this run with live games. I can see it now:

The master of the bzflag universe in his/her office, dozens of public servers and private servers displayed on the walls. The master finds a particular game of sudden interest, and expands that game onto one wall to watch a heated skirmish over a flag.

So when you gonna have the tanks in the thumbnails, too? :) JK!
-toaster
"So there I was, all alone, facing all of the enemy. I started driving in circles, until I had them surrounded, and then I escaped in the confusion."
User avatar
blast
General
General
Posts: 4933
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Post by blast »

It now shows world weapons as orange dots. There is also a transparent watermark in the middle of the images. ;)
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
Grumbler
Dev Monkey
Dev Monkey
Posts: 453
Joined: Wed Jul 09, 2003 3:06 pm
Location: Space

Post by Grumbler »

nice visual toaster, so is that your vision of the next "Find Servers" command in the client?
.........you kids, get out of my tank...........
User avatar
toaster
Private First Class
Private First Class
Posts: 457
Joined: Sat Feb 21, 2004 4:44 pm

Post by toaster »

I suppose it could be, Grumbler, but what a nightmare for processing for the user with a slow client computer. I just ran a few of your thumbnail scripts, and I think it's a bit too slow to try to generate an entire list dynamically. Perhaps, though, the list server could have the smaller thumbnails stored statically on it, and the incoming user could get a list feed of static maps (really icons at that point).

The server code could include your scripts as part of its startup, push the "icon" off to the list server if the -public option is specified... Then, the list server should always have a current icon/thumbnail to match the list.

Do you think that would make more sense?
-toaster
"So there I was, all alone, facing all of the enemy. I started driving in circles, until I had them surrounded, and then I escaped in the confusion."
User avatar
toaster
Private First Class
Private First Class
Posts: 457
Joined: Sat Feb 21, 2004 4:44 pm

Post by toaster »

This and the "Old Map Resource" thread, same forum, are actually pretty inter-related if you start considering the interface options, Grumbler. What you did with pandora, and the pybzflag code, is not only visually attractive, but a good example of what could be done with the client. I'm not sure it that's a "live" generation or just stored thumbnails.

I'm not sure what code Blast used to generate the live thumbnails, either. Certainly, his scripts are running on his server live.

I can see it being especially useful, no matter whose code you use, for servers like galkire where you change maps frequently. Plus, the visual appeal might attact players to check out more worlds than they usually play.

It's a serious "awesome" factor, no matter how it's generated. As I said in the other thread, I'm in awe of you two and the potential.

:thumb:
-toaster
"So there I was, all alone, facing all of the enemy. I started driving in circles, until I had them surrounded, and then I escaped in the confusion."
Grumbler
Dev Monkey
Dev Monkey
Posts: 453
Joined: Wed Jul 09, 2003 3:06 pm
Location: Space

Post by Grumbler »

err.....i didnt do it, i just posted the link so people could get old map files........i can take no credit for pybzflag and its map generator......i didnt even do the website.....its all about sharing information.

with a map contest coming up, i thought it would be nice to have some historical maps as a reference for those considering entry.

i believe pybzflag was a pet project of some of the standard developers......
.........you kids, get out of my tank...........
User avatar
toaster
Private First Class
Private First Class
Posts: 457
Joined: Sat Feb 21, 2004 4:44 pm

Post by toaster »

Oh. Well, sorry to embarrass you, didn't mean to give you credit wrongly. Still, bringing things together is worth some credit! I'm still in awe.
-toaster
"So there I was, all alone, facing all of the enemy. I started driving in circles, until I had them surrounded, and then I escaped in the confusion."
User avatar
blast
General
General
Posts: 4933
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Post by blast »

It now draws the teleporters on the image. It can also draw lines around the objects, but that is currently turned off. Colors are fully customizable. Here is an example of what is required to make a thumbnail (This is how it's done as of right now):

Code: Select all

<?php
require("BZThumb.class.php");

$map = new BZThumb("mymap.bzw");

// Optional color configuration
$map->SetObjectColor("ground", 128, 128, 128);
$map->SetObjectColor("box", 128, 128, 128);
$map->SetObjectColor("pyramid", 128, 128, 128);
$map->SetObjectColor("line", 128, 128, 128);
$map->SetObjectColor("weapon", 128, 128, 128);

$map->SetTeamColor("red", 0, 0, 0);
$map->SetTeamColor("green", 0, 0, 0);
$map->SetTeamColor("blue", 0, 0, 0);
$map->SetTeamColor("purple", 0, 0, 0);

$map->Render(800, false);

?>
Of course, the colors would be different, but you get the idea. They are not even needed, as defaults are specified when you create the BZThumb object. In the call to Render, the first paramater is the width/height of the image to be output, in pixels. The second paramater sets whether or not to use alpha blending on the boxes. This will all be eventually incorporated into a map upload script, and then built into my local S.B.o site.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
User avatar
blast
General
General
Posts: 4933
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Post by blast »

I made a script to take all the BZFlag maps in a directory, render a thubmnail of each, and then display them with a download link to the associated map file. I also used this as a benchmark. There was a total of 104 maps. When I configured it to make 1600x1600 images with alpha blending and line drawing, it took 5 minutes and 28 seconds to render them all. When I turned it down to a more reasonable 200x200, it took about 35 seconds. The images right now are 200x200 without alpha blending or lines.

To speed it up, it now decides if it needs to render the image at all. If the image already exists, and has a modified date/time newer than the map file, it will use the existing image. All you need to do is edit the BZThumb location, drop the script into a writable web directory with map files, and then navigate to that location in your browser, and it will render and display the images.

I am also working on an upload script. With it, you can upload a map of your own and view it as a thumbnail. You can customize the details of the image as well. You just have to make sure the first line is a comment (starting with a #), that the file is under 100KB, and that it ends in .bzw or .map. Might be slow because the server is on dial-up. ;)

The only thing I have left to do it add the map title to the image and optimize the code. Then I'll release the script so others can use it. I'll also start to implement this into my Stats.bzflag.org project.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
User avatar
blast
General
General
Posts: 4933
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Post by blast »

I'm working on adding a Maps section to the Stats.bzflag.org site. Right now it lists the maps with 15 per page. It shows a thumbnail preview, title, description, author, date it was added, and the suggested server settings. It also allows you to download the maps, and counts the downloads.

You can view it if you want.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
Grumbler
Dev Monkey
Dev Monkey
Posts: 453
Joined: Wed Jul 09, 2003 3:06 pm
Location: Space

Post by Grumbler »

you might want to add a field covering what version the map was built for.
.........you kids, get out of my tank...........
User avatar
blast
General
General
Posts: 4933
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Post by blast »

Grumbler wrote:you might want to add a field covering what version the map was built for.
Good idea. I'll be fine tuning it more as well. It's still far from finished.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
Grumbler
Dev Monkey
Dev Monkey
Posts: 453
Joined: Wed Jul 09, 2003 3:06 pm
Location: Space

Post by Grumbler »

finished yet??????????/???


???????? :)
.........you kids, get out of my tank...........
User avatar
blast
General
General
Posts: 4933
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Post by blast »

Heh, actually, I forget about this thing. I can't call it done, but it works. Here's the latest source I have.
Attachments
bzthumb.zip
BZThumb 0.4 (3-26-2004)
Includes thumbnail class, watermark image, index page, sample maps, and upload script.
(18.74 KiB) Downloaded 239 times
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
Post Reply