World of Banished

MODS Garage => Tutorials => Topic started by: Discrepancy on June 26, 2016, 09:24:38 AM

Title: Creating a 3d model house in blender and making it available in game
Post by: Discrepancy on June 26, 2016, 09:24:38 AM
Hello,

I thought I would try to make a (hopefully) straight forward tutorial for anyone wanting to get a model into banished.

I'm using Blender 2.76, this a free open source program, updated often   you can download lastest version for free here (https://www.blender.org/download/).

First up I'll give a list of the my most used keyboard shortcuts for blender when 3d modelling (these are very handy, and enable quicker and less tiresome 3d modelling):
tab = change between Edit / Object mode.
shift + A = Add a mesh / a shape predefined or adjustable.
A = toggle between Select all / Select none
L + hovering cursor over vertex/edge/face = Select Linked, selects vertices attached.
shift + D = adds a duplicate of the selected vertices
E = extrudes face/edge/vertex
S = Scale, adjust the scale, size of the selected vertices
R = Rotate
Also using the numpad buttons 1-9,
most important is:
1 = front view
3 = side view
7 = top down view

alternatively many of these can be accessed through a menu (bottom left of my screen [View | Select | Add | Object/Mesh] in the pictures below)


links to sites that I have used to learn from:

The Blender Manual (https://www.blender.org/manual/contents.html)
Blender Keyboard shortcuts (https://wiki.blender.org/index.php/Doc:2.4/Reference/Hotkeys/All)
and a good printable quick access for most used shortcuts: BlenderHotkeysCheatsheet.pdf (http://gryllus.net/Blender/Syllabus/Blender%20Hotkeys%20Cheatsheet.pdf)

and a tutorial that helped me a lot:
Creating a Low Poly Medieval House in Blender: Part 1
 (http://cgi.tutsplus.com/tutorials/creating-a-low-poly-medieval-house-in-blender-part-1--cms-24002) & mostly Part 2 (http://cgi.tutsplus.com/tutorials/creating-a-low-poly-medieval-house-in-blender-part-2--cms-24018)

I will post the full tutorial over the next few days...


I will also upload all code and source code, as well as a .pkm version for those who just want to play :) I hope to inspire a lot of would-be modders.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Discrepancy on June 26, 2016, 09:25:11 AM
Creating a 3d model house in blender and making it available in game
Part 1

Open up Blender, start a New project,
delete everything (press the A key to select all, press del and then enter key),
In the Properties window panel, click on 'Metric'(1), and ensure that the scale is set to 1.000 (2)
It should look like this:

(http://i.imgur.com/0TfMtb2.jpg)

Setting the measurement system and scale to metric will mean that a square in Blender will represent a game tile square in Banished.
Orientate your view so that the Y-axis travels away from you (3) – this is your North point in the game.
Also ensure you are in 'Object Mode'.

Press shift + A then click on  Add – Mesh – Cube

(http://i.imgur.com/X7nJBpX.jpg)

Press Tab to enter into 'Edit Mode' (4).
Click on 'Face Select' (5), and then click on the icon next to it 'Limit Selection to Visible', this will allow you to see through the now semi-transparent faces for easier editing.

(http://i.imgur.com/RGYsmFe.jpg)

Press A key to deselect the cube.
Now select only the lowest face, and in the 'Transform' window pane, change the Median  Z: to 0m (6), this will bring the bottom of the cube up to ground height.

(http://i.imgur.com/KMZFJaz.jpg)

We are going to make a house with a footprint of width 4 x height 3 + road, to sit in a 4x4 plot.
In blender, from point 0,0,0 (the 0 point at which the x,y,z – axis points meet) we will make our model fit within the 2 squares to either side to that point...

By selecting faces one at a time, move the cube and adjust shape and size so it looks like this:

(http://i.imgur.com/s1FTxnN.jpg)

This will be the stone foundation.

(http://i.imgur.com/SBcvTt5.jpg)

Using a selection of 'Edge Select' (7) to adjust the edges of the mesh, and then using the E key to extrude faces, create the houses stone foundation to look like this:

(http://i.imgur.com/zNohnbQ.jpg)

rotating your view , and holding shift while selecting the individual faces of the underside of the foundation, press delete, and press Delete – Faces.

(http://i.imgur.com/AN43Zse.jpg)

Press A key to select all. Then press ctrl + E to bring up Edges menu, click on 'Mark Seam' and this should have marked all of the surrounds of the foundation faces in red:

(http://i.imgur.com/d7HnOQR.jpg)

Press A to select all again, then press U to bring up the UV mapping menu and click on 'Unwrap'.

Now we need to bring up another view with the UV map on it.
Top Right of the screen (8) drag the little angle lines to the left, hide away the new duplicate menus that appear, then load up the UV/Image Editor view:

(http://i.imgur.com/AoPbzPW.jpg)

Now in this new view you will see the UV mapping that will call up the textures. I'm going to give a quick basic tutorial, textures will be basic. In this new view, press S key and scale down the foundation faces on the UV square, and we will later create a basic texture.
(http://i.imgur.com/mj0MUux.jpg)

Now, back to the 3d view, we will be making the wooden frame. We will add a new mesh cube by pressing shift + A to add a new mesh-cube.
Use the arrows to move it around, then press S to scale it smaller, adjust the faces to make an upright next to the doorway.

(http://i.imgur.com/byHVSUW.jpg)

Now select only the top face, the bottom face and only one of the side edges, press ctrl = E, 'Mark Seam', hover over mesh, press L to select all connected vertices, press U, select 'Unwrap'.

(http://i.imgur.com/EfdEWjt.jpg)

Scale down the UV map of the wooden frame upright, and place away from the area you put the stone foundation UV map

(http://i.imgur.com/1eaQk9q.jpg)

Now back to the 3d view, we will deselect all, then only select the wooden frame upright we just created (hover over press L to select all connected vertices).
Press shift + D to duplicate, move each duplicate around the foundation to create the houses uprights for its frame.

(http://i.imgur.com/loPBgTk.jpg)

Now duplicating one of the uprights again, press 1 on your keyboard's numpad to bring up front view, press R key to rotate and create a horizontal piece and using what we've learned, and utilise brining up the front, side and top views, duplicate, rotate and adjust pieces until you have a frame like this:

(http://i.imgur.com/BHuc86a.jpg)
(http://i.imgur.com/HxEO0b3.jpg)
In side view (press 3 on the numpad), use the 'Loop Cut and Slide' tool (10),
And with new edges in each roof truss, adjust so they are more 'rounded':

(http://i.imgur.com/usjZNrd.jpg)

Create a duplicate of one of the trusses, move to the centre of your frame, to create a centre truss.
Press tab to exit to 'Object mode',
Your model should  loosely resemble this:

(http://i.imgur.com/18du1FV.jpg)

Next, click on 'Object' (11), then 'Apply' (12), then 'Location' (13), again: Object, Apply and then this time 'Rotation & Scale' (14).

(http://i.imgur.com/ggReyKC.jpg)

Save your project as a blender file.


Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Discrepancy on June 26, 2016, 09:25:44 AM
Part 2


Keyboard shortcus for working in UV mapping view:
S = Scale
G = Move
R = Rotate
W = Weld/Align tools
L = Select connected vertices




In part 2 we will finalise the 3d model.
First we will add the roof and walls.

Back into 'Edit Mode', add a new plane (press Shift + A, select Plane), move it into place over the centre of the house frame.
By selecting the planes face, click on 'Subdivide' (13) this will split the face into 4 planes, the using the 'Knife' tool, cut a new edge line from the centre of the roof to the outer corners. Pull down the edges and and make slight adjustments to create a roof like this:

(http://i.imgur.com/1zEVw8j.jpg)

Select all the edge lines of the roof piece we just made.
Press ctrl + E to mark the seams, then by hovering over only a section of the roof plane, press L to highlight the rest of the roof,
Press U and unwrap the roof, it should have shown up in the UV window like this:

(http://i.imgur.com/bAdkB4x.jpg)

Adjust the UV layout do the roof fits into the top right,
Your house and UV should look like this when you select all:

(http://i.imgur.com/yvJpYp3.jpg)

Now we will add a front wall, by adding another plane and moving it into the frame and adjusting so it sits just back from the wooden frame,
It will look like this:

(http://i.imgur.com/Qldy9co.jpg)

Now mark the seam of this wall and unwrap like we have done before scale and move the wall in the UV view to the bottom right.

Continue duplicating (shift + D) this front wall and fill up all the sides of the house.
By doing this, like we did with the Wooden frame, all of the walls will grab the same texture.

(http://i.imgur.com/BXjQ7E6.jpg)

Fill up most of the holes between the walls and roof by using all you've learned.
Utilising the 'Loop Cut and Slide' tool (10), as well as the 'Knife' tool (13) will help you to split faces and then move edges around to fill in the gaps.

Once done we will add a chimney to the building.

I have pressed shift + A, added a new cube and moved it next to the wall and altered the shape like this:

(http://i.imgur.com/dHzWLz8.jpg)

Next click on the top face of this cube and press E to extrude the face, pull this new section up over the roof, and click. With the top face still selected, press S to scale it slightly smaller than the base:

(http://i.imgur.com/OKSlw89.jpg)

Now using the extrude and scale tools I made a 'lip' on the top of the chimney, and then made it go back down into the chimney a bit to create a 'hollow':

(http://i.imgur.com/wXagJOH.jpg)

Delete the ground face on the chimney, deleting faces that are not visible is good practice to keep the poly count low.

Select all of the chimney (press L to select all connected vertices), move it back away from the house so we can UV unwrap it easier.

With 'Edge Select' active, highlight all of the bottom edges, then highlight one side of the rear chimney edge:

(http://i.imgur.com/b7hUpPM.jpg)

Now zoom in and only select the edges that run around the bottom of the chimney 'lip'.

(http://i.imgur.com/rLUQsPy.jpg)

Press ctrl + E to mark the seam you just highlighted, then deselecting, mark out the chimney 'lip' seam lines like this:

(http://i.imgur.com/Isz0zgE.jpg)

Mark the seam, and then select all of the chimney, and press U to Unwrap the chimney.

In the UV window it'll look like this:

(http://i.imgur.com/CSILBPC.jpg)

Using the tools for the UV map (see top of this post), scale, rotate and align edges to fit within the whole UV map:

(http://i.imgur.com/Jg7ZaG8.jpg)

I have moved the chimney lip to a place that overlaps with what will be the foundation texture.

Back into the 3d view, select only the chimney and bring it back next to the house.

Now add a new plane, and adjust it so that it sits back within the door frame:

(http://i.imgur.com/1wNH2Xj.jpg)

Mark the seams on this, and then Unwrap to bring it up on the UV map. Adjust so that is fits between everything:

(http://i.imgur.com/p4YyDHD.jpg)

Now add in a new cube, this time scale and adjust, we will make a window, delete the back face, and then mark the seams like this:

(http://i.imgur.com/dryeuWK.jpg)

Unwrap, and adjust on the UV map. I have moved the sides of the window to the same spot as the wooden frame to share the same wood texture. Select the window and then move it into the wall next to the door, I also duplicated it and added another window on the side wall.

(http://i.imgur.com/seZUJcy.jpg)

So that is going to be our basic house model.
Exit to 'Object Mode' (press tab key), and it will look like this:
Ensure the model is still located at 0,0,0, click on 'Object' – 'Apply' – 'Location' and then 'Apply' - 'Rotation & Scale'

(http://i.imgur.com/tlEoeCc.jpg)

Save your work :)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Discrepancy on June 26, 2016, 09:26:06 AM
Part 3


In part 3 we will be adding the (AO) Ambient Occlusion, creating the texture file, the build models and adding the points.



.... baking the AO

In 'Object Mode', add a new plane, align it to 0,0,0. Scale it so that it is larger than the house:

(http://i.imgur.com/8So8IYl.jpg)

We add this to stop light shining through the bottom of the house when new bake the AO.

Select the house model, and in the properties window select 'World' (15), then activate 'Ambient Occlusion' (16), adjust the 'Gather' sample count to 10 (17).

(http://i.imgur.com/L6nG5L2.jpg)

Now click on the 'Render' tab (18), scroll down until you find the 'Bake' section, change the Bake mode to Ambient Occlusion (19), change the margin to 10px (20)

(http://i.imgur.com/xFEs4iw.jpg)

Now in the houses 'Edit mode', select all, and then in the UV view, click on 'Image' – 'New Image', keep all the default settings, and size of 1024x1024. Press okay.
Now click on the 'Bake' button (21).

(http://i.imgur.com/Uho8iUf.jpg)

The ambient occlusion will have been 'baked' on this new image, you will see the effects in the UV view.
Press 'Image' – 'Invert' – 'Invert Image Colors' this will make the AO image have a predominantly white appearance, need to work with Banished.
Press 'Image' – 'Save as Image', save as an RGB (22) .png file, I named mine SmallTownHomeAO.png
Click on 'Save as image' (23)

(http://i.imgur.com/cVliZ9i.jpg)

Back in the UV view, click on 'UVs'  - 'Export UV Layout' – change the 'Fill Opacity' to 0.000 (24).

I named my file SmallTownHomeUV.png, ensure it is saving as .png, click on 'Export UV Layout' (25)

(http://i.imgur.com/iAmAnzx.jpg)

Enter into 'Object mode', select the plane we made just prior to baking the AO, and delete it as it is no longer needed.

Save your file.



.... Texturing

Now open up your SmallTownHomeUV.png image in a Image Editing program, I am using Adobe Photoshop, but there are plenty of others (and free ones) that can be used.

We want to now start adding textures to fit within the UV lines,

Put your textures into separate 'Layers' for easier editing..

All sorts of textures can be found on the internet for free use (I got all of these textures from Textures.com – requires setting up a free account)

This is what I have done for the textures:

(http://i.imgur.com/o0Z3R5R.jpg)

Before saving I hide the UV lines, then I save the image as a .png format (SmallTownHome.png).



.... creating the Build models

Back into Blender.

Load up your .blend model of the house if not already.

Then 'File' – 'Export' – 'FBX'  keep all settings as is, make sure  scale is set to 1.00 , pick a file name, I saved mine as SmallTownHome_nopoints.fbx

Save your file.

Back into 'Edit mode',

and now for what I think the fun part is.... making the build models.

Before you start it is a good idea to firstly save this file again but as a different save – call it something like SmallTownHome_build02.blend

Now, in 'Edit mode' start deleting parts and moving sections of the mesh as if you were dismantling the house in reverse to someone building it...

For example I deleted the roof first, then I deleted the door and windows and all the walls. (depending on your design you could incorporate more build models, but in this tutorial I'm trying to keep it pretty simple)

(http://i.imgur.com/7mKlCk1.jpg)

From here I save again (as SmallTownHome_build02.blend), then I export this an .fbx like we did earlier.


Now save a new .blend save – build01

Delete more, or move things around like they have just gotten to building site. Build 01 is what you see after the resources have been taken to the houses footprint.

(http://i.imgur.com/ReBe218.jpg)

Build 01, saved and exported as an .fbx file also.


Now that all of our models are made, we can reopen up the complete house .blend save.

We now need to add 'points' for the game to interact with the building.

In 'Object mode', press shift + A and 'Add' – 'Empty' – 'Plain Axes'

Using the 'Transform' properties menu window, orientate this so it is at 0,0,0 (26).
Then change the name of this to 'points' (27)

(http://i.imgur.com/uERlETw.jpg)

Add in more points in the same manner, this time, keep them all at ground level (z-axis=0), name them:
build_001
build_002
use_001

by clicking on the little icons next to the names of the points, drag them all onto the 'points' to 'Drop to Select Parent'
it should look like this:

(http://i.imgur.com/9OLmls9.jpg)

Now add in a new point, this time it will be called 'smoke', move it so that it is sitting within the chimney slightly, set it's parent to 'points'.

Save the file.

Now delete the house mesh object, so you will only have the points.

Export this as an FBX, (SmallTownHome_points.fbx)

(http://i.imgur.com/eVIbSni.jpg)


Now you can close blender (don't save when prompted otherwise you will loose you model


… in part 4 we will be creating all the code. We are getting close to finishing :)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Discrepancy on June 26, 2016, 09:26:29 AM
Part 4


It is a good idea to try to familiarize yourself with the basic ways in which a mod needs to be put together.
Taking a look at the examples in the mod kit and within the resource folder to see how elements of the game works.
Download and install your Banished modKit, (install to main drive and with no '.,-' symbols in the folder paths)

My modkit, and path to this mod is installed on my main hard drive like this:

C:\BanishedKit106\MyMods\SmallTownHome

Within this 'SmallTownHome' folder I will create more folders and copy files from the example mods as well as from the resource folder.

Create folders called: Dialog / Models / Template / Texture / UI all within the 'SmallTownHome' folder

Into the Dialog folder, make a copy of 'SharedElements.rsc' no need to change the name or anything within the file, but it will be required when compiling. (can be found in modkit folder/resource/Dialog)

Out of the Apiary/Models example folder, copy all the .rsc files named with Apiary.... leave the one named honeyMesh, this is not needed. Copy these into your own Modles folder.

Time to start altering these files so they will link to what we're making.

I start by changing the filenames first, substituting 'Apiary' with 'SmallTownHome',
Then open up each file in notepad, and do the same for all the instances that it says 'Apiary'.

Create a folder within this Models folder, and name it 'MaterialInstance'
In it put the .png files we created – the texture rile and the AO image. Don't need the UV image.

Again from the Apiary example folder, copy the .rsc files from this folder that are concerned with the Apiary only, except for the one concerning the ApiaryFootprint, we don't need these.

Back in our own folder, rename the file names and substitute 'Apiary' for 'SmallTownHome', do the same inside all the files, but with the Build01 and Build02AO files, link the images all to the same .png file – 'SmallTownHomeAO.png' This is because we only made the one AO image in this tutorial (if wanted, they can be easily made though by baking a new AO in the 2 build saves and exporting the image like before)

After this your Models folder, and Models/MaterialInstance folder should look like:

(http://i.imgur.com/jRVkaMg.jpg)

From the resource/Template folder, copy the 'Woodhouse.rsc' file, put it into your own template folder.

Change the file name to 'SmallTownHome.rsc'

in it scroll down until you find this section:

Code: [Select]
ToolbarDescription toolbar
{
SpriteSheet _spriteSheet = "Dialog/SpriteSheet.rsc";
String _spriteName = "BuildHouse";

StringTable _stringTable = "Dialog/StringTable.rsc:objects";
String _stringName = "WoodHome";
String _stringNameLwr = "WoodHomeLwr";
String _toolTip = "WoodHomeTip";

String _statusStrings
[
"CreateOk",
"CreateBlocked",
]

int _group = 3;
}

This is the section that makes all the connections for the menu button, icons and text regarding the house.
Change it to:
Code: [Select]
ToolbarDescription toolbar
{
SpriteSheet _spriteSheet = "UI/SmallTownHomeSpriteSheet.rsc";
String _spriteName = "BuildSmallTownHome";

StringTable _stringTable = "UI/SmallTownHomeStringTable.rsc";
String _stringName = "SmallTownHome";
String _stringNameLwr = "SmallTownHomeLwr";
String _toolTip = "SmallTownHomeTip";

String _statusStrings
[
"CreateOk",
"CreateBlocked",
]

int _group = 3;
}

Under this code you will find:

Code: [Select]
CreatePlacedDescription createplaced
{
PathBits _placeBits = Normal | Obstacle;

int _width = 4;
int _height = 5;
int _footprintRotation = 0;

PathBits _placeBitArray
[
Normal | Obstacle,
Normal | Obstacle | Fast | Faster,
]
String _placeBitmap =
"0000
0000
0000
0000
1111";

ComponentDescription _allowAndRemove = "Template/Clear.rsc";
}

MapDescription map
{
PathType _pathType = Immovable;
String _pathBitmap =
"####
####
####
###_
....";

bool _addToOverhead = true;
Color _mapColor = 0xFF545454;
}

This is the section that controls how the house sits on the game tiles.
In Blender we have made our house to sit on a footprint of 4x3 + road tiles (4x4)

So we need to change the createplaced to:

Code: [Select]
CreatePlacedDescription createplaced
{
PathBits _placeBits = Normal | Obstacle;

int _width = 4;
int _height = 4;
int _footprintRotation = 0;

PathBits _placeBitArray
[
Normal | Obstacle,
Normal | Obstacle | Fast | Faster,
]
String _placeBitmap =
"0000
0000
0000
1111";

ComponentDescription _allowAndRemove = "Template/Clear.rsc";
}

the placeBitArray, is what the placeBitmap is calling up info from.
The first line ' Normal | Obstacle,' = 0 in the placeBitmap,
so when we have the 0's listed, it is saying it is an Obstacle (building) that can be placed on Normal (level) terrain.
While the 1's mean it can have a road travel on the tiles, though it is still an obstacle so cannot have another building built there.

Now we change the next part the map description.
Our building will look like this:
Code: [Select]
MapDescription map
{
PathType _pathType = Immovable;
String _pathBitmap =
"####
####
##_#
....";

bool _addToOverhead = true;
Color _mapColor = 0xFF545454;
}

The #'s mean that it is a solid building, the _ (underscore) is passage that citizens can take 'inside' a building, and the .'s (dots) are the part that  assigns a road to be built on the front tiles? I think
The other section is what for the display on the overhead game map.

Thanks goes to Kralyerg for giving me insight into how the placeBitArray and placeBits work.


Next we will change the rest of the template file to link up to the model and materials.
A fair bit will need to be deleted from the woodhouse.rsc as it has many F-key variants.
It should look like this:
Code: [Select]
DecalDescription decal
{
MaterialInstance _materials
[
"Terrain/TiledDecals/BuildingFootprint8Material.rsc"
"Terrain/TiledDecals/BuildingFootprint8DamageMaterial.rsc"
]
bool _tiled = false;
float _initialAlpha = 0.5;
float _mapWidth = 2048.0;

DecalLocation _decalLocations
[
{
float _x0 = 0.0;
float _y0 = 0.0;
float _x1 = 256.0;
float _y1 = 320.0;
}
]
}

PickingDescription picking
{
MaterialInstance _selectMaterial = "Material/SelectionMask/SelectionMask.rsc";
PickingGroup _meshes
[
{
PickingMesh _mesh
[
"Models\SmallTownHomeBuild01Picking.rsc",
"Models\SmallTownHomeBuild02Picking.rsc",
"Models\SmallTownHomePicking.rsc"
]
}
]
}

ModelDescription model
{
MeshGroup _meshes
[
{
GraphicsMesh _mesh
[
"Models\SmallTownHomeBuild01Mesh.rsc",
"Models\SmallTownHomeBuild02Mesh.rsc",
"Models\SmallTownHomeMesh.rsc"
]
}
]

int _displayIndex = 0;
int _subIndex = 0;
bool _randomIndex = false;
}

HighlightDescription highlight
{
EdgeGroup _meshes
[
{
EdgeMesh _mesh
[
"Models\SmallTownHomeBuild01Mesh.rsc:edge"
"Models\SmallTownHomeBuild02Mesh.rsc:edge"
"Models\SmallTownHomeMesh.rsc:edge"
]
}
]

// materials for drawing selection with no mesh
MaterialInstance _maskMaterial = "Material/SelectionMask/SelectionMask.rsc";
MaterialInstance _edgeMaterial = "Material/SelectionEdge/SelectionEdge.rsc";
}


InteractDescription interact
{
PointList _pointList = "Models\SmallTownHomePoints.rsc";
}


at the bottom of the file, delete this from the UI section:
Code: [Select]
{
ObjectType _type = UpgradeUI;
ElementDescription _element = "Dialog/Upgrade.rsc:upgradeButton";
String _insertAt = "pageTabGroup";
DialogControllerConfig _config = "upgradeConfig";
}

and then right at the bottom, delete:
Code: [Select]
UpgradeUIConfig upgradeConfig
{
ComponentDescription _upgradeTo = "Template/StoneHouse.rsc";
}

These are the sections that handles the stone house upgrade, not needed for this house.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Discrepancy on June 26, 2016, 09:47:43 AM
Part 5


From the Apiary example folder, copy the 4 .rsc files in the Texture folder, put them into your own. Done.

Now again from the Apiary example folder, copy the 4 .rsc files in the UI folder, put them into your own and then alter the filenames, again substituting 'Apiary' for 'SmallTownHome'.

SmallTownHomeSpriteSheet.rsc will look like this:
Code: [Select]
SpriteSheet resource
{
String _materialName = "SmallTownHomeSpriteSheetMaterial.rsc";
String _imageName = "Build/SmallTownHomeSpriteSheet.png";
int _imageWidth = 128;
int _imageHeight = 128;
bool _padForFiltering = true;

Sprite _sprites
[
{ String _name = "BuildSmallTownHome"; String _source = "UI/Sprite/BuildSmallTownHome.png"; }
]
}

This is what calls up the individual toolbar icon for the house.

Now in SmallTownHomeSpriteSheetMaterial.rsc and SmallTownHomeSpriteSheetTexture.rsc
Alter the sections where it says 'Apiary', replace with 'SmallTownHome'

The SmallTownHomeStringTable.rsc file controls the text that is written in the game (display names/toolbar tips etc)
I changed mine to be:
Code: [Select]
StringTable resource
{
Entry _strings
[
{ String _name = "SmallTownHome"; String _text = "Small Town Home"; }
{ String _name = "SmallTownHomeLwr"; String _text = "small town home"; }
{ String _name = "SmallTownHomeTip"; String _text = "A small home with same costs and same numbers as the Wood house."; }
]
}

Now we need to create the Toolbar icon, it needs to be a 32x32 png image with a transparent background to match the other icons.
Name it 'BuildSmallTownHome.png'
Once made it needs to go into a folder called 'Sprite' within the UI folder.


Back into the main folder (MyMods/SmallTownHome)
we will need to add in copies from the Apiary example folder:
copy: Apiary.rsc, apiaryResources.rsc and Package.rsc

Rename Apiary.rsc to SmallTownHome.rsc,
This file is the toolbar file- it controls where the houses icon will be.
We want it to sit with the other houses, so I have changed it to:
Code: [Select]
Toolbar SmallTownHome
{
Toolbar _parent = "Game\Toolbar.rsc:housing";
int _sortPriority = 111;

Action _action = Tool;
ComponentDescription _tool = "Template/SmallTownHome.rsc";

bool _autoHotKey = true; 
}

Now change apiaryResources.rsc to SmallTownHomeResources.rsc
this is the mod kit’s 'call up' sheet for when compiling the mod.
Inside it should look like this:
Code: [Select]
ExternalList resource
{
External _resources
[
// toolbar - references building and everything else - nothing else need be listed here
"SmallTownHome.rsc:SmallTownHome"
]
}


Now  edit the Package file, this is what controls the information that is shown in the game mod menu and in the steam workshop.
I made my Package file look like this:
Code: [Select]
PackageFile SmallTownHome
{
String _name = "Small Town Home";
String _author = "Discrepancy";
String _description = "This is small home with the same numbers of the Wooden House.
    This was made for a tutorial, you can find it at www.worldofbanished.com";
String _icon = "icon.png";
String _preview = "preview.jpg";
int _userVersion = 1;

// all files in resource directory
String _includeList
[
"*"
]

// exclude package files, mod files, file used for building packages
String _excludeList
[
"Package_*.crs"
"*.pkg"
"*.pkm"
]
}

Next make the icon.png file it is asking for. This needs to be 48x48. I just resize the toolbar build icon.

Don't worry about the preview.jpg, as we haven’t got an in game shot yet.

Now to make the bat files to compile the mod:
In the main folder (MyMods/SmallTownHome), we will now create 3 text files,
they will be named as:
'1 Build.bat'
'2 Run.bat'
3 Package.bat'

inside '1 Build.bat' put this:
Code: [Select]
..\..\bin\x64\Tools-x64.exe /build SmallTownHomeResources.rsc:resource /pathres ../MyMods/SmallTownHome /pathdat ../MyMods/SmallTownHome/bin
pause

inside '2 Run.bat' put this:
Code: [Select]
..\..\bin\x64\Application-x64-profile.exe /ref SmallTownHomeResources.rsc:resource /pathres ../MyMods/SmallTownHome /pathdat ../MyMods/SmallTownHome/bin
pause

inside '3 Package.bat'' put this:
Code: [Select]
..\..\bin\x64\Tools-x64.exe /mod Package.rsc:SmallTownHome /pathres ../MyMods/SmallTownHome /pathdat ../MyMods/SmallTownHome/bin
pause



… Compiling all the 3d models

Now we must make the single .fbx file that the game will read from.

Open Blender and with a new blank project, press 'File' – 'Import' – 'FBX'
Change the scale to 0.01 (28), and then import the main house model we exported to .fbx (29)

(http://i.imgur.com/VgZRcnf.jpg)

The house should have been imported and you will have to zoom in a long way to see it.

Change the name of the model to 'mesh' (30) (*NOTE: pictures are wrongly displaying 'Mesh', this I later changed to 'mesh' – sorry couldn't take new screenshots)

(http://i.imgur.com/LVcJm9g.jpg)

Import the point.fbx file, keep it all the same at scale of 0.01, it should fall directly into the model at 0,0,0

Import the build models one at a time in the same way, they should also fall directly into the centre of the house, if not they were not exported properly at 0,0,0.
With the build models, while still in 'Object mode', move them sideways away from he main house model, and rename them 'build01' and 'build02'

(http://i.imgur.com/fnPIQar.jpg)

Now select the main mesh, and click on the 'Material' property tab (31), then click 'New' (32)

(http://i.imgur.com/JRocYYQ.jpg)

Rename the new material to 'SmallTownHome'

Next to the 'Material' tab, click on the 'Texture' tab (33), click 'New' to add a texture place-holder, rename this also to 'SmallTownHome' (34)

(http://i.imgur.com/RaMvRA6.jpg)

Press 'Open' (35), and link to the SmallTownHome.png file in the MaterialInstance folder.

Now click on each of the build models and call up the same texture, only this time you only need to click on the 'Material' tab, and instead of adding a new material, just click on the 'SmallTownHome' material we had just made. Just click on the little globe/circle, and select the material.

Now it is ready to export again, this time as a single .fbx file.

Export to the 'Models' folder we made, named as 'SmallTownHome.fbx'

Now we can build the model!

Double click on the '1 Build.bat' file we created, and if all was followed it should build...
You will be prompted if there is an issue.

My build went fine,

I then double click on the 2 Run.bat file and the game loads up. Start a new game.

The model loads up fine in game, but it is too big !

(http://i.imgur.com/rSJOHrn.jpg)






.... In Part 6 we will resize the models and make it fit on a smaller footprint.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Discrepancy on June 27, 2016, 01:22:28 AM
Part 6


So our house model is way too large inside the game, looking at the picture in game, we could easily take one square off the side, so it will be a smaller house sitting on a smaller footprint of 3x3 instead of 4x4.

Open up Blender and load up the save you have for the completed house (SmallTownHome.blend):

(http://i.imgur.com/7hImRD7.jpg)

In 'Object mode',
Select the house, and in the Transform window panel, change the scale to 0.650 for all axis points (36)
Do the same for the points holder (it will resize all points).
We now have a house scaled to 65% of what it was.
It takes up approx. 1.5 squares either side of the Y-axis.

(http://i.imgur.com/LP2AxwJ.jpg)

Important, we now need to 'Apply' these changes to the scale.

Like we did earlier in the tutorial, click on 'Object' – 'Apply' – 'Rotation & Scale', repeat with the 'point' holder. (you will see that the 'Transform' scale will have changed to 1.000) (37)

Save file.

(http://i.imgur.com/19xt0rK.jpg)

Now like we did earlier, delete the house mesh, and export only the points as an .fbx file (at scale 1.000).

Reload the house save, this time delete all the points (all points can quickly be deleted by 'right-clicking' on the 'points' holder in the Outliner window pane [top right of my blender view], and click on 'Delete Hierarchy').
Now export the house only as an .fbx.

Now load up the build01 & build02.blend saves we made earlier, and make the same changes in scale that we made to the complete house, apply the scale, and save and export as .fbx's.

And again following the same method we did in Part 5, we will start a new empty Blender project and import the .fbx files one at a time at 0.01 scale.

And add the 'Material/Texture' to each of the mesh, build 02 & build 01 like we did earlier. (they all call up the same Material holder)
If you want, you can press on the 'Object mode'  button (38), press 'Texture Paint' and it will show up the house with the texture you just assigned.

(http://i.imgur.com/48IyuET.jpg)

Once you've assigned the materials, export all as an .fbx, and replace the SmallTownHome.fbx you created in the Models folder.

Open up the SmallTownHome.rsc file in the Templete folder.

Change the following:
Code: [Select]
CreatePlacedDescription createplaced
{
PathBits _placeBits = Normal | Obstacle;

int _width = 4;
int _height = 4;
int _footprintRotation = 0;

PathBits _placeBitArray
[
Normal | Obstacle,
Normal | Obstacle | Fast | Faster,
]
String _placeBitmap =
"0000
0000
0000
1111";

ComponentDescription _allowAndRemove = "Template/Clear.rsc";
}

MapDescription map
{
PathType _pathType = Immovable;
String _pathBitmap =
"####
####
##_#
....";

bool _addToOverhead = true;
Color _mapColor = 0xFF545454;
}

to:
Code: [Select]
CreatePlacedDescription createplaced
{
PathBits _placeBits = Normal | Obstacle;

int _width = 3;
int _height = 3;
int _footprintRotation = 0;

PathBits _placeBitArray
[
Normal | Obstacle,
Normal | Obstacle | Fast | Faster,
]
String _placeBitmap =
"000
000
111";

ComponentDescription _allowAndRemove = "Template/Clear.rsc";
}

MapDescription map
{
PathType _pathType = Immovable;
String _pathBitmap =
"###
#_#
...";

bool _addToOverhead = true;
Color _mapColor = 0xFF545454;
}

We have now changed the house to sit on a 3x3 footprint including the road.

Now recompile the mod (delete the 'bin' and 'Build' folders first) by clicking on the '1 Build.bat' file. Run the mod by clicking '2 Run.bat'.


More issues:

The size is better in game, but a problem! although hard to see... our roof is on fire! Smoke is billowing out from the centre of the roof! (I recall this coming up before: http://worldofbanished.com/index.php?topic=1112.0 (http://worldofbanished.com/index.php?topic=1112.0) but how it was solved?...)

(http://i.imgur.com/1t7wWWh.jpg)

I guess we will find out in Part 7! … I was hoping to have this finished by now. But problem solving is the best way to learn.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Discrepancy on June 27, 2016, 04:03:29 AM
Part 7

So thankfully this issue isn't anything major, and it wasn't really our fault considering it isn't in the wooden house file...


Within the SmallTownHome.rsc file in the Template folder is this code:

Code: [Select]
InteractDescription interact
{
PointList _pointList = "Models\SmallTownHomePoints.rsc";
}

ParticleDescription particle
{
ParticleAttachment _systems
[
{
Time _fadeInOutTime = 2.0;
bool _addOnCreate = false;
bool _addOnNotify = false;
Particle _particle = "ParticleSystems\Fire\FireSmall.rsc";
}
{
bool _addOnCreate = false;
Particle _particle = "ParticleSystems\ChimneySmoke\ChimneySmoke.rsc";
String _attachNode = "smoke";
}
]
}

Thanks to @kid1293 , we now know that the particle system needs to call up the points.rsc file directly from its code in the template file.
Change the section above to:

Code: [Select]
InteractDescription interact
{
PointList _pointList = "Models\SmallTownHomePoints.rsc";
}

ParticleDescription particle
{
PointList _pointList = "Models\SmallTownHomePoints.rsc";

ParticleAttachment _systems
[
{
Time _fadeInOutTime = 2.0;
bool _addOnCreate = false;
bool _addOnNotify = false;
Particle _particle = "ParticleSystems\Fire\FireSmall.rsc";
}
{
bool _addOnCreate = false;
Particle _particle = "ParticleSystems\ChimneySmoke\ChimneySmoke.rsc";
String _attachNode = "smoke";
}
]
}

just that added 'PointList _pointList = "Models\SmallTownHomePoints.rsc";' line will make the chimney point act as it should.

:) It is now complete.

Almost.

To properly add a mod to the steam workshop you need a preview picture...
using this...
(http://i.imgur.com/84LLOw7.jpg)

I edit and crop it so that it is a 360x360px image, save it as 'preview.jpg'

Now rebuild the mod with these added changes, and lastly package the mod.

The SmallTownHome.pkm file is found in my C:\BanishedKit106\bin\WinData/ folder

Test the mod in the normal Banished environment.

All done.



Thanks for reading, any questions? happy to help.



(http://i.imgur.com/zv8wIlw.jpg)



If you want to use this house in your game,
Download the SmallTownHome.pkm file here (https://drive.google.com/open?id=0B0D37rA1CD9BSXVWQldWZHYyeGc)

See how it is made? Download the source code here: (all code, textures and .fbx models)
SmallTownHome_SourceCode (https://drive.google.com/open?id=0B0D37rA1CD9BeWowRTdMZ1Y1ZU0) v1.0

NEW sourcecode (includes model alterations, AO added, footprint added, file name changes)
SmallTownHome_v1.1_sourcecode.zip (https://mega.nz/#!yRF3kRJC!FoRg3QwMcCvFVphqr4o3DopmMeC5_SQRt3ZrWx9y6LM) v1.1

here you can download the original Blender files, .psd texture file etc, etc SmallTownHome_SourceWorkFiles.zip (https://drive.google.com/open?id=0B0D37rA1CD9BX2FiN05DMXYyNDg)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Discrepancy on June 27, 2016, 04:44:48 AM
... I'm sorry that I have titled this as a tutorial when I myself am having problems...

but I still hope, going through all of this might allow others to venture into the 3d modelling and Banished modding world.

Keep checking back above, as we will solve the issue.

I will also upload all the source files once it is operating as required.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Discrepancy on June 27, 2016, 07:41:26 AM
This tutorial is now complete.

I hope that some of you will find it helpful.

:) happy modding.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 27, 2016, 10:12:48 AM
THANKS YOU ALOT @Discrepancy  for this nice tuto :)
sure it will help some people :)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Ogedei on July 03, 2016, 06:26:57 PM
Great tutorial. This is actually a lot better than most Blender tutorials out there - the others tend to be so needlessly complicated. :)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: mellowtraumatic on August 07, 2016, 06:42:40 AM
Thank you for this! It makes me want to break out Blender again. I tried it once and got hopelessly frustrated with it.
Title: Re: Just Great Stuff
Post by: triangle on January 12, 2018, 10:47:49 PM
Just wanted to say thank you for the tutorial I use it 10 times a day as my goto model problem solving 101.

If you decide to update it at some point I hope you add to it showing more F-Key textured model variants of your smallhouse that are lined up in rows inside the same .fbx so people understand how this can be done and restructured/renamed: SmallHouse01Mesh, SmallHousepoints, SmallHouse01Build01, SmallHouse01Build02.

I didn't know how this was done until kid pointed this out to me and could save others like him from overhelpwelming PM's  lol
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on January 12, 2018, 10:55:43 PM
if happends to have a chimney in each model not at same place as the other models, then you need to "link" the smoke point to the mesh and not to the "points" point.
and in the template, you take out the pointlist mention from the particle system function paragraph.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on March 16, 2018, 06:07:52 AM
I have followed this guide to a T, with only difference i have used 3ds max, instead of blender.

While this guide looks like it misses something, i can tell for sure it does not explain what "point" is: it's a dummy\helpers object.

While i managed to find and fix issues in files and naming, I still recieve error messages about sources not covered in this thread.

Code: [Select]
Assert: Failed to load resource 'C:\Users\kraso\Desktop\BanishedKit_1.0.7.170910\MyMods\House_test\bin\UI\HouseStringTable_objects.crs'

Object\ExternalFactory.cpp(364)


Code: [Select]
Assert: Source resource 'C:\Users\kraso\Desktop\BanishedKit_1.0.7.170910\MyMods\House_test\MaterialInstance\01 - Default.rsc' does not exist, and compiled resource not found in pack!

Object\ExternalFactory.cpp(312)

I skipped these warnings, launched build.bat file multiple times, and at some point it was built without any warnings.

I had the game model looking wrong, but i fixed it by turning the pivot axis into right direction. The game crashes when I place the building.
(https://i.imgur.com/FSQuadj.jpg)

Here is how it's done in 3ds max for those who needs to know
(https://i.imgur.com/IFmPZzc.png)

I have been looking into .rsc files to find errors, but it is as it's written in the guide

I'm out of ideas what to do.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on March 16, 2018, 03:22:01 PM
what you see at your screen is not necessairly what you ll get. 3dsmax has 2 kind of location datas : the ones you see in your screen, and the real world ones.
you can take things at your screen and move them around , turn them around as you wish without changing the real world datas.

if at your screen everything is perfect but in real world isnt as you thought, i suggest you to export as an .obj file and then delete it and get it back as "import" an .obj file
that way you will easily make screen datas become real world datas. make sure each elements is at the right place relative to the 0,0 point because the real data will become relative to 0,0 point.

normally then after, when you want to move something around, it is not pickup the mouse and move around, you need to edit mesh and select the elements you want to move around. when you are editing mesh and selects parts and move the parts around ... you are editing the real world data in that mode.(screen 1 at your right)

but for your problem you have today, just place your building as it looks good to your eyes, at your screen, and then export to .obj , delete, import the .obj saved that way what you see at your screen will becomes real data.

do it for your mesh, but also do it for your build02 and build01 seperately (make sure they are at 0,0 too).


-----------

about your textures. decorate your mesh with textures is not that what is very important, textures arent saved inside a .fbx only the names of the textures are saved inside the .fbx. this is the reason why a .fbx is so small. it has no textures inside the .fbx

so what is important for your banished model is you need to "label" and "name" properly your textures. only the names will be saved.

or you press "M" to call the "Material window" and doing it there..... or open the schematic view and change the names there (It is there i personally change my names of my textures) This is the 7th icon on the menu from the right and called "Schematic View" (and it is just side of the material window icon)

screen 1 and 2

in screen 2 you see the window, and the boxes in brown, are the 'name' of your textures, just rename thouse 1_ default by the real name of your texture. only that name will be saved to your .fbx


------------------------

now the pointlist

i always use the helpers => dummy (but the helpers => point are good too. up to you)
you need 1 and call it "points" and place it at 0,0
then you need some as "build_001, build_002.... " the number of those = the number of builders in game which will build your building. if you put 2 of those, then the player will need 2 builders to build that building.
you need some "use_001, use_002...." those ones will tell the game where a citizen need to stand to interact with your model
"create_001, create_002..." is for buildings that take material and create something new, thats the spawn points where your new resource created will appear in game.


all those points (helpers => dummy) need to be "linked" to your "points" dummy. for that again you need to go in the schematic view and use the 3rd first icon named "Connect"
you select "connect" and then select all your dummies but the main one called "points" and then drag them to connect  those to "connect" with your main dummy called "points"

screen 3 and 4.

as you see in screen 4 , they will connect your dummy called "points"

Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on March 16, 2018, 03:39:53 PM
for about your 'C:\Users\kraso\Desktop\BanishedKit_1.0.7.170910\MyMods\House_test\bin\UI\HouseStringTable_objects.crs error this is because in your template your link for your stringtable contains a " :objects " at the end. just delete this ":objects" from your link

this is because your string table doesnt have a paragraph name objects. this is usefull only when you have a stringtable as big as CC or megamod or NMT.
by default we use paragraph named "resource" so if you put no ":something" at the end of a link , it means "resource" by default. it would be the same if you did put a ":resource" at the end of your string table link. So  just delete this ":objects" from your link



by the way when you are dealing and making mods, i suggest to never never use any strange caracters in folder structure and file names. you are running ahead big frustrated problems if you do so.
so i suggest to never use any "." or "-" or "_" in folders/name_files
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on March 16, 2018, 07:46:30 PM
but maybe a quick fix can be screen 1:
when you export in .fbx, check Advanced Options => Axis conversion and try Z up  if not do what i said, export in .obj and reimport.


not sure if you did this yourself, or grabbed a free .obj from the net....
when you did imported it the first time... probably should have just clicked : " Flip ZY " checked box ON/OFF (screen2)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on March 17, 2018, 08:03:35 AM
You have put a lot of effort to clear the issue with the model's alignment in the game. I have solved it myself and shared quick solution in the post.

I still can't find traces of "01 - Default.rsc" in files, lack of which causes builder to return error message.

I can get mod built by skipping these error messages, but in the game placing the mod's building will cause crash.
Code: [Select]
A fatal access violation has occurred in Runtime-x64-profile.dll and the game cannot continue!

A crash dump has been saved to C:\Users\kraso\Desktop\BanishedKit_1.0.7.170910\bin\x64\crash.dmp


Again, the code of error i receive while running the builder:
Code: [Select]
Assert: Source resource 'C:\Users\kraso\Desktop\BanishedKit_1.0.7.170910\MyMods\House_test\MaterialInstance\01 - Default.rsc' does not exist, and compiled resource not found in pack!

Object\ExternalFactory.cpp(312)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on March 17, 2018, 01:23:26 PM

I still can't find traces of "01 - Default.rsc" in files, lack of which causes builder to return error message.


your answer is there, you need to "etiquette" the names of your textures properly, you have read all my posts but didnt verified. you need to open your Schematic View window.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on March 17, 2018, 01:44:08 PM
this screenshot again will show you the Schematic view of a model which i assigned texture but i didnt made my job properly : i added textures to things, but i didnt "named" my textures and i've let the 3dsmax to give those XX - default name.

you need to open your schematic view and go rename your textures :)


In this screenshots you will see the names of the textures wrongly named : 16 - Default , 17 - Default ,18 - Default , 20 - Default



like i said, the toolkit and the banished does not read your texture, it only read the NAME of the textures and check inside your folder MaterialInstance for those names.
the MaterialInstance folder contains your textures and the .rsc to make it work those textures


so your toolkit read those : 16 - Default , 17 - Default ,18 - Default , 20 - Default and search inside the MaterialInstance folder for the .rsc to make work those names
it will search for : 16 - Default.rsc , 17 - Default.rsc ,18 - Default.rsc , 20 - Default.rsc because the .fbx told your toolkit those are the name of your texture you decided !!
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on March 17, 2018, 03:29:19 PM
Now i see, it compiles, reading material names from the FBX file, and if material name and maps attached to the material do not match file names in the mod, it will attempt to compile wrong file and return error message.


(https://i.imgur.com/oos5K4Y.jpg)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on March 17, 2018, 03:35:12 PM
now you need to make a proper AO file !!
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on March 20, 2018, 02:29:28 PM
After creating new mesh with new textures, and checking everything to be in order, the builder now crashes without error message at the same point of progress.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Discrepancy on March 20, 2018, 03:18:32 PM
@hadrian900 ,

I notice you have your modkit folder named:

'BanishedKit_1.0.7.170910' (Desktop\BanishedKit_1.0.7.170910\MyMods)

the compiler does not like this, I suggest changing it to just 'BanishedKit'.

You have done very well, and I am amazed it was compiling at all for you.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Discrepancy on March 20, 2018, 03:20:35 PM
If the compiler is hanging and crashing when trying to compile the texture, ensure the texture image is of right size and also that all names are correct in .fbx and MaterialInstance folder.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on March 20, 2018, 03:41:30 PM
If the compiler is hanging and crashing when trying to compile the texture, ensure the texture image is of right size and also that all names are correct in .fbx and MaterialInstance folder.

yup! your texture need to be in 32pixelsX32pixels ,  64x64, 128x128, 256x256, 512x512, 1024x1024 or any of these numbers (like 128x512 for example)
we cannot say multiples cause it wont like 192 or 384 numbers....
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on March 20, 2018, 06:15:50 PM
It was caused by wrong texture size.

Now game crashes when i try to place the building, despite build was complete without any issues.

Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on March 20, 2018, 07:34:01 PM
then certainly your code
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on March 21, 2018, 11:03:30 AM
I have made fresh mod, repeated steps, compiled without issues, but it still crashes the same as before when i place the building on the map.

I have attached archive of the mod and source file of the meshes for transparency.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on March 21, 2018, 06:18:11 PM
sorry took some time between commercial pub pauses in my hockey game....

your problem comes from the names "labels" you gave to your textures in your .fbx
i am not sure why but instead to give the name of your texture "izba"(.png) you gave the name of your AO files ???
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on March 21, 2018, 09:20:08 PM
It works fine and smooth.

(https://i.imgur.com/5UttUiw.jpg)

I'm going to adjust some other maps and attempt to make mod with more than one building in it.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Discrepancy on March 21, 2018, 09:33:12 PM
Looks great :)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: galensgranny on March 22, 2018, 04:52:35 AM
I like these little log houses with wooden roofs!  I am wanting such buildings for my game.  One that is a larger size would be splendid, like double the length.  It is wonderful to see more people are learning how to mod.   :)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: kid1293 on March 22, 2018, 06:51:13 AM
I like that!
It feels genuine! :)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on March 24, 2018, 01:30:55 AM
Modeling these log houses is time-consuming, given how you can't let down details and how many polygons you have to unwrap and adjust to avoid patterns repeating too much.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: BlueFireChelle on May 23, 2018, 04:25:23 AM
Thanks so much for posting this tutorial... I just want to say.. Holy WOW this is hard!! I can't believe how long it's taking me to do anything, and I've only just managed to get up to the first row of horizontal beams. LOL!
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on May 23, 2018, 03:34:32 PM
Thanks so much for posting this tutorial... I just want to say.. Holy WOW this is hard!! I can't believe how long it's taking me to do anything, and I've only just managed to get up to the first row of horizontal beams. LOL!

at our experience, it can take us from 4 hrs to 16 hrs of works to us to depending the complexity and details we want to add.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Voeille on May 23, 2018, 03:39:52 PM
4-16h? When I made plants, it takes me about 2 days, working on it basically every waking hour. In Banished it’ll be even more because of coding part. But I’m not the fastest ever ;)

I want to say thanks for the tutorial too. It helped me a lot with getting things done in Blender.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on May 23, 2018, 04:39:37 PM
4-16h? When I made plants, it takes me about 2 days, working on it basically every waking hour. In Banished it’ll be even more because of coding part. But I’m not the fastest ever ;)

I want to say thanks for the tutorial too. It helped me a lot with getting things done in Blender.

like i said, with our experience. 2-3 y of Banished Mod experience now. so it is normal at begining, you pass 2-3 days... even a week ^^
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Discrepancy on May 23, 2018, 09:34:34 PM
I also had no experience in modding games or making anything 3d apart from in a CAD program back in school 15yrs earlier. And that didn't include any texturing.

I wrote this back when I started as a way for myself to learn and hopefully get others to follow. Back then it took me days to do something basic. And I'm not kidding when I say I spent months before just looking at and trying to get a grip with blender to just do those basics, learning some of the keyboard shortcuts makes all the difference in blender I think. I started by making a tree, and no way could I get that thing in banished... or any game. Don't even want to say how many faces it has.

I also now texture as I make the 3d model, it is nicer to do, allows more experimentation with details I think.
For a while I did unwrap the models so each plane had it's own place on the UV, but now I overlap quite a bit and re-use same parts of textures, and yes mirror them also sometimes.

Sometimes I can spend 1-3hrs making a model, or others can take me upwards of 36hrs+ on something with more detail. Sometimes I can do it within a day, other times it can get frustrating and work on the model slows to over a month or year...

basic code to get a model in the game can be quick once you get the hang of it : 10-15min.
but once you start getting into it more and experimenting with different code and UI, things slow down. For example the last week i have been updating mostly only the UI of the styth tower mod, I've added a few other models but at the most the 3d modelling/texturing has contributed to maybe 2-3% of the time spent on it. I've spent I think over 48hrs so far on it.
I thought this update would take a day at the most, but modding banished is a bit like a puzzle that has no solution, and very much like falling down a rabbit hole...
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on June 24, 2018, 08:04:48 AM
Code: [Select]
Assert: Source resource 'C:\Users\kraso\Desktop\BanishedKit\MyMods\Slav\Models\MaterialInstance\Pit_House.rsc' does not exist, and compiled resource not found in pack!
I have been brushing my files to find any reference to this path, to fix it, but it's not present there.

Code: [Select]
/MyMods/Slav /pathdat ../MyMods/Slav/bin
SRS Toolset version 1.0.7 Build 170910
Compiling 'SlavResources.rsc:resource'
Compiling 'Slav.rsc:Zem'
Compiling 'Template\Zem.rsc:resource'
Compiling 'Template\Zem.rsc:model'
Compiling 'Models\Zem\ZemBuild01Mesh.rsc:resource'
Warning: Source resource 'C:\Users\kraso\Desktop\BanishedKit\MyMods\Slav\Models\MaterialInstance\Pit_House.rsc' does not exist, and compiled resource not found in pack!
Object\ExternalFactory.cpp(312)

I haven't found any file which has link to this rsc file in my mod. I don't know what's going on.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: kid1293 on June 24, 2018, 09:45:58 AM
You have a link in your fbx to a texture named Pit_House (something) probably .png
You must provide the material file for that link.
Check your model if it is really in use. Else delete it.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on June 24, 2018, 10:48:53 AM
You have a link in your fbx to a texture named Pit_House (something) probably .png
You must provide the material file for that link.
Check your model if it is really in use. Else delete it.
The link is for .rsc file

This is how source file's links look like
http://prntscr.com/jysjsu
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 24, 2018, 05:32:27 PM
an .fbx doesnt contain any image files inside its .fbx. banished only use the "name" of the .png that is written inside your "light brown boxes" ( inside your screenshot. )


this name should be wriiten exactly the same as you textured your mesh with. In the present case, it suggests you textured your mesh with a .png named Pit_House.png

if the name of your .png isnt really that, this is because you didnt put the good name in the light brown box. Or you rename your .png or you rename your light brown boxes.



and then for making your .png work in banished you need 2 files to tell the toolkit "How to make it work" your .png

here in this case you should have a Pit_House.rsc and a Pit_HouseTexture.rsc that will tell the toolkit how to handle your Pit_House.png
(just take the 2 files from apiary/model/materialinstance and rename those and change the lines inside those to files to match your Pit_House.png)


also in your model/Pit_HouseMesh.rsc and Pit_HouseBuild02Mesh.rsc and Pit_HouseBuild01Mesh.rsc files, there are links too that need to point to your Pit_House.png file. make sure those are renamed properly. Make sure the paths are always good.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on June 24, 2018, 06:17:21 PM
The mesh uses proper texture that is present in the mod, and files link to it properly.
No .rsc file is suposed to be in folder "model", no file has a link to .rsc file into that folder.

It has following structure: "mod"/models/zem(this is where pit house model and its material are)

I have brushed through .rsc files to see any of them linking to another .rsc in models folder, none has it.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 24, 2018, 06:47:33 PM
The mesh uses proper texture that is present in the mod, and files link to it properly.
No .rsc file is suposed to be in folder "model", no file has a link to .rsc file into that folder.

It has following structure: "mod"/models/zem(this is where pit house model and its material are)

I have brushed through .rsc files to see any of them linking to another .rsc in models folder, none has it.

no they should be in the mod/models/MaterialInstance. they cannot be anywhere else, the game will search there by default and no way can be placed elsewhere. (internal link)
make a copy paste of your 3 files (.rsc, Texture.rsc and .png) where the toolkit look for it.


like another example. in my RK Ed , i put all models in /Models/Buildings/folder ( like /Models/Buildings/Lumbermill/ folder, or /Models/Buildings/WoodHouse/ folder)
the toolkit will still look for it at /Models/Buildings/MaterialInstance/ folder no matter what i ll try to put those elsewhere.

the internal link hidden in the game will do a .. go back up 1 folder before and search for a /MaterialInstance/ folder there.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on June 25, 2018, 08:15:41 AM
But the game is made that specific way.

https://prnt.sc/jz5gur

Where from does the compiler even gets Pit_House.rsc in the first place since NOTHING links to it, nor contains Pit_House.rsc in its code. Aren't we supposed to look at source files and repeat after that?

Code: [Select]
MaterialInstance resource
{
Material _material = "Material\OpaqueSnow\OpaqueSnowMaterial.rsc";
Texture _textures
[
{
String _name = "diffuse";
ImageBuffer _texture = "Models\Buildings\Chapel\MaterialInstance\ChapelTexture.rsc";
}
{
String _name = "snow";
ImageBuffer _texture = "Terrain\TerrainSnowTexture.rsc";
}
]
}

I have managed to get mod compiled and working At last, but i still don't get many of things.

(https://i.imgur.com/OiQuFSa.jpg)

However the build02 of the new house shows incorrect map or incorrect UV, despite FBX and source file being set correctly

This is how it look like in game
(https://i.imgur.com/FfgNaVR.jpg)

And this is how it looks in 3ds max
(https://i.imgur.com/5x9c7B8.jpg)

.FBX file attached so that you can see the model in editor.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 25, 2018, 01:42:59 PM

Where from does the compiler even gets Pit_House.rsc in the first place since NOTHING links to it, nor contains Pit_House.rsc in its code. Aren't we supposed to look at source files and repeat after that?

Code: [Select]
MaterialInstance resource
{
Material _material = "Material\OpaqueSnow\OpaqueSnowMaterial.rsc";
Texture _textures
[
{
String _name = "diffuse";
ImageBuffer _texture = "Models\Buildings\Chapel\MaterialInstance\ChapelTexture.rsc";
}
{
String _name = "snow";
ImageBuffer _texture = "Terrain\TerrainSnowTexture.rsc";
}
]
}


i know you figured it out, but since you dont get the thing...
you stated in your .FBX  Pit_House (Pit_House.png) as texture !! not Chapel (Chapel.png)

like i said, or you rename your light brown boxes, or you rename your .png

(https://i.imgur.com/7kPuXiJ.png)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 25, 2018, 02:03:18 PM
btw while we are there... Chapel.png is a very very bad name, you will conflict with any Chapel.png that already exist. find a better personalized name for it. like Hadrian900Chapel.png

Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on June 25, 2018, 02:17:11 PM
btw while we are there... Chapel.png is a very very bad name, you will conflict with any Chapel.png that already exist. find a better personalized name for it. like Hadrian900Chapel.png
This is piece of code from game's resource folder. It's the very same chapel that is in the game. I have brought it as example of what would be intuitive to look at to learn how buildings are put into the game.

Why following the game's original files would not work making mod?
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 25, 2018, 02:19:03 PM
btw while we are there... Chapel.png is a very very bad name, you will conflict with any Chapel.png that already exist. find a better personalized name for it. like Hadrian900Chapel.png
This is piece of code from game's resource folder. It's the very same chapel that is in the game. I have brought it as example of what would be intuitive to look at to learn how buildings are put into the game.

ah ok. did you saw it in your .fbx software ? the Pit_House names ?


redo your AO files have do 1 for your mesh, do 1 for your build02 and do 1 for your build01. 3 seperated AO.png files. and inside your Mesh.rsc, Build01Mesh.rsc, and Build01Mesh.rsc do the links properly in your .rsc to link the new AO.png , Build02AO.png and Build02AO.png
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 25, 2018, 02:30:51 PM
Why following the game's original files would not work making mod?

bah because you dont really know how the chapel.png is.

do you want it ?
this is how it looks:
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 25, 2018, 02:35:12 PM
so if you made a new Chapel.png it will conflict with the real Chapel.png in game. when you will build the real chapel in game, it will use your texture.
i dunno if it can make sense for you.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on June 25, 2018, 02:37:25 PM
Why following the game's original files would not work making mod?

bah because you dont really know how the chapel.png is.

do you want it ?
this is how it looks:

No, this is not what i was meaning.

The game's original files point to texture files in a SPECIFIC folder, unique to this building, that folder contains only those file that are related to the building. Why following the same instruction, pointing to .rsc file at a chosen folder, would result in an error. Why do we even point to those files to begin with, if builder ignores those instructions and searches for files where it was hardcoded to look for.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 25, 2018, 02:48:30 PM
you are drawing your mesh and you apply your own textures. you need to point and use your own modified .rsc files to begin with and that use your own textures !!
or you are running into problems :)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on June 25, 2018, 03:05:58 PM
(https://i.imgur.com/fMNBa7x.jpg)

Alright, let's try tuning in again.

The game originally has the following structure:

models/building/chapel/materialinstance

Chapel folder would contain .rsc files that refer to those in MaterialInstance which is contained in the same folder.

When you try to make a mod and try to do as the GAME FILES SHOW you to do, it would end up with error.
Why, despite we point inside .rsc files to the SPECIFIC location of textures builder ignores it? Why we even need to do so in the first place if builder is hardcoded to seek for files and textures in only folders it's coded to do.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 25, 2018, 04:36:52 PM
the models/building/chapel/materialinstance folder only contain the footprints and the AO files. not the texture.
the game will search the textures there : models/building/materialinstance (it go up 1 dir and check for a /materialinstance/ folder there.)


there is 2 folders named materialinstance and it is messing with you :)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on June 27, 2018, 05:41:25 AM
Still, why does my model shows wrong UV\texture despite being set correctly?
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 27, 2018, 12:58:46 PM
Still, why does my model shows wrong UV\texture despite being set correctly?

do you have seperate AO files for mesh, build02, build01 ?
are you sure they are done correctly ? because it is not showing that way, did you left a good 2-3 pixels between every parts.
the links inside your AO.rsc Build02AO.rsc Build01AO.rsc have the good link and points to the good files ?

how i can go travel in astral and go see you so i can see if you ve done everything ok ? i see nothing from here.
if want me to check and fix it, you will have to drop your whole package down here.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on June 28, 2018, 10:23:34 AM
This zip includes .rsc files and textures
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 28, 2018, 01:49:48 PM
edit in fact, i made those ao files, but it looks maybe something wrong with your meshes itself

redo your build 01 mesh and redo your build02 mesh. they have definitly something wrong
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on June 28, 2018, 02:28:42 PM
build01 works right in the game.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 28, 2018, 04:32:56 PM
build01 works right in the game.

redo your build02 then, should be easy, you make a clone of mesh. rename it build02 and then at that clone, you delete the roof , doors, windows, and everything you think it is necessairy and you keep the front/back walls. and you redo an AO file.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on June 28, 2018, 06:59:55 PM
It's not as easy as you think, that would be different polygons, that need to be adjusted. You have the model, you can see yourself.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 28, 2018, 07:20:30 PM
It's not as easy as you think, that would be different polygons, that need to be adjusted. You have the model, you can see yourself.

thats up to you to see it through different polygons. i personally (and most of us) we always use the mesh copy, remove pieces and add a roof support like this (screenshot) how the builds are made and look depends entirely on how YOU, you decide :)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on June 29, 2018, 06:39:37 AM
This is what i'm talking about.

(https://i.imgur.com/2qKGlUU.jpg)
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 29, 2018, 01:23:09 PM
but thats still ok :) anyway most of the time you wont ever get to look at that build02 before it has been completly built and functionnal
yes presently, as you build your mod you take a closer look on it, but in 2-3 weeks, you wont ever notice it or neither ever try to look at it.
i speak by experience.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: hadrian900 on June 29, 2018, 03:49:06 PM
I'm in complete awareness, however, people, with time, will notice details watching same thing again and again.

Many mods have poor texturing, I don't want to be in those numbers.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on June 29, 2018, 05:00:21 PM
I'm in complete awareness, however, people, with time, will notice details watching same thing again and again.

Many mods have poor texturing, I don't want to be in those numbers.

all comes with skills and experience :)
continue your good work and be patient to allow yourself time to learn.
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: Trizeropz on August 29, 2018, 05:05:43 AM
As a beginner in coding, I am very thankful for this! Gonna try myself in the next days
Title: Re: Creating a 3d model house in blender and making it available in game
Post by: RedKetchup on August 29, 2018, 05:20:57 AM
As a beginner in coding, I am very thankful for this! Gonna try myself in the next days

wooot !!