Author Topic: GUIDE - How to create icons for bricks and bots automatically.  (Read 24241 times)

Making icons for bricks and bots has always been a hassle, and it always resulted in the icons from each person's set looking slightly off from the others. We have known about the existence of the /doIcon command, but didn't really understand how it worked until Rotondo gave us a clearer explanation today. This guide should be a slightly more comprehensive version of the mini-guide Rotondo posted.

Pre-Step: This must be done before you can create icons for bricks.
Create a folder named iconShots in the root part of your Blockland directory.
Code: [Select]
My_Documents\Blockland\iconShots\For best results, you should also have the resolution set to something that is 4:3 in ratio.

Step 1:
Optionally, you should download this skybox which fixes the lighting so your icons are lit like the default pre-v21 ones.
Set up a server (singleplayer is fine) that has the brick/bot you want to make an icon of. It would probably be a good idea to set the skybox to white (Or enable the custom skybox, mentioned above) and make the ground completely transparent in the environment options. For best results, set your screen resolution to a 4:3 ratio (non-widescreen), you may have to disable fullscreen for these resolutions to show up.

Step 2:
Do the /iconInit command, this will set up the environment and your camera for taking the picture. From this point, do not move the camera with your mouse or the ASWD keys.

Step 3:
A: For brick icons
Code: [Select]
/doIcon brickNameFor brickName, you need to take the name for the brick's datablock and remove the "brick" and "data" parts from the name. For example, if I have a brick with it's datablock being named "Brick5x6fData", what I would put in as the brickName would be "5x6f".

B: For bot icons
First, you need to copy and paste this function into the console (until an update fixes it) for bots to have color in your icon.
Then, you can do
Code: [Select]
/DoBotIcon brickData botData namebrickData is the name of the brick datablock. For example, BrickBlockheadBot_HoleSpawnData
botData is the playerData datablock you gave for the bot. For example, BlockheadHoleBot
name is whatever you call the bot. I'm pretty sure it can be anything.

Once you enter that command, you must take a screenshot manually.

Step 4:
A:
For bricks, you take the file out of the iconShots folder and use an image manipulation program to remove the background.

B:
For bots, you take the screenshot out of your screenshots folder and then use an image manipulation program to remove the background.

Step 5:
Use an image manipulation program to set the canvas of the image to 96x96 pixels. Resize the image as needed to fit on the 96x96 canvas. Ensure that it is centered on whatever you took a picture of, though.

Step 6: Put the icon into your brick/bot add-on and refer to it in the iconFile argument in the brick datablock. For example,
Quote
datablock fxDTSBrickData (BrickBlockheadBot_HoleSpawnDa ta)
{
   brickFile = "Add-ons/Bot_Hole/4xSpawn.blb";
   category = "Special";
   subCategory = "Holes";
   uiName = "Blockhead Hole";
   iconName = "Add-Ons/Bot_Blockhead/icon_blockhead";

   bricktype = 2;
   cancover = 0;
   orientationfix = 1;
   indestructable = 1;

   isBotHole = 1;
   holeBot = "BlockheadHoleBot";
};


Now for a large block of code that you need for bot icons, ignore this if you're just doing brick icons or you don't need your bots to be colored.
First, copy the following into your clipboard. (Ctrl + c)
Code: [Select]
function serverCmdDoBotIcon( %client, %data )
{
if( !%client.isSuperAdmin )
return;

// make sure the dataBlock exists
if( !isObject( %data ) )
{
error( "Couldn't find" SPC %data );
return 0;
}

// clear old bot icon brick
if( isObject( $botIconBrick ) )
{
$botIconBrick.botHolder.delete();
      $botIconBrick.botHolder = 0;
$botIconBrick.hBot.delete();
      $botIconBrick.hBot = 0;
$botIconBrick.delete();
      $botIconBrick = 0;
}

%pos = "0 10 -1005";

// should probably take into consideration the rotate adjust thing
%rot = "0 0 -1 90";

// create the bot brick
%brick = new fxDTSBrick()
{
position  = %pos;
rotation  = %rot;
dataBlock = %data;
angleId   = 1;
colorId   = 5;
colorFxId = 0;
shapeFxId = 0;
isPlanted = 1;
client    = %client;
};

// remember the brick we made
$botIconBrick = %brick;

%error = %brick.plant();
%brick.setTrusted(1);
%client.brickGroup.add( %brick );

// make sure the brick is rendering
%brick.scheduleNoQuota( 1000, setRendering, 1 );

// set hBot type since we're doing this out of onplant
%brick.hBotType = %data.holeBot;

// create the static shape that will hold the bot in place, honestly I'm unsure why there are no collision meshes in icon mode
%static = new staticShape()
{
dataBlock = emptyBotHolderShape;
position = vectorAdd( %pos, "0 0 0.225" );
rotation = %rot;
};

missionCleanup.add( %static );

%brick.botHolder = %static;

// spawn the bot
%bot = %brick.spawnHoleBot();
%bot.updateArm(%bot.dataBlock.hWep);
%bot.setWeapon(%bot.dataBlock.hWep);
%bot.stopHoleLoop();

%static.mountObject( %bot, 0 );

return 1;
}
Then enter this into your Blockland console, do not copy and paste it.
Code: [Select]
eval(getclipboard());
This will fix the bot icon function temporarily, now you may scroll back up to read what you must do next for your icon.



Please post any issues you have with this guide, and I'll attempt to fix them.
« Last Edit: December 18, 2017, 08:30:27 AM by Pecon »

This is a nice guide. makes life easier :cookieMonster:

You need to create a folder in the base directory called "iconShots" for it to work.
« Last Edit: March 16, 2013, 02:30:13 AM by Plexious »

You need to create a folder in the base directory called "iconShots" for it to work.
This was already in the guide. Read more thoroughly next time.


I made these icons look Awful!!!  anyone can help me fix the icons?

What resolution should the icon shots be taken in?

What resolution should the icon shots be taken in?
Shouldn't matter, because you have to crop it in an image editor anyways. Just crop it to 96x96 like I mention in the guide.

Is there a way to edit the function that does this? The bricks are rotated incorrectly. Here's a 2x1x2 print brick:

The print face is on the other side.

And this 1x5 brick is supposed to have the dark side be the long side:


A really awesome command but useless to me because of this. Oh and the images are too large. Cropping them to 96x96 leads to the bricks being outside the image like this 1x7 brick:

I'll stick to my 3D renders. Much less hassle and higher quality images.

Oh and the images are too large. Cropping them to 96x96 leads to the bricks being outside the image like this 1x7 brick:

Yeah because you can't scale the image down or anything

I did a 1x1 brick, but it was off centered and smaller and blurrier.

Normal 1x1 brick icon.               My 1x1 brick icon.
                         

I did exactly as you said.
« Last Edit: March 16, 2013, 06:45:45 AM by jes00 »

Yeah because you can't scale the image down or anything
Scaling images makes them lose quality.

the screenshot i took for the bot is too big and wont fit in the 96x96 area

the screenshot i took for the bot is too big and wont fit in the 96x96 area

Did you use /doBotIcon ?

Did you use /doBotIcon ?
edit:ok, no. the /doboticon thing does nothing
« Last Edit: March 16, 2013, 12:08:56 PM by Gsterman »

Add this at the bottom right before return 1 to make your bot hold a weapon:

Code: [Select]
%bot.updateArm(%bot.dataBlock.hWep);
%bot.setWeapon(%bot.dataBlock.hWep);

edit:ok, no. the /doboticon thing does nothing

read the OP