[tutorial] plant altar - from idea to model to game object

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Ryeath_Greystalk
Posts: 366
Joined: Tue Jan 15, 2013 3:26 am
Location: Oregon

Re: [tutorial] plant altar - from idea to game object

Post by Ryeath_Greystalk »

15. Make Material Definitions in the Assets Folder

Here are my custom material definitions for the textures that will be used by the plant altar.

defineMaterial{
name = "plant_altar_moss",
diffuseMap = "assets/textures/items/moss_dif.tga",
specularMap = "assets/textures/items/moss_spec.tga",
doubleSided = false,
lighting = true,
alphaTest = false,
blendMode = "Opaque",
textureAddressMode = "Wrap",
glossiness = 30,
depthBias = 0,
}

defineMaterial{
name = "plant_altar_base",
diffuseMap = "assets/textures/items/plant_altar_base_dif.tga",
specularMap = "assets/textures/items/plant_altar_base_spec.tga",
doubleSided = false,
lighting = true,
alphaTest = false,
blendMode = "Opaque",
textureAddressMode = "Wrap",
glossiness = 30,
depthBias = 0,
}

defineMaterial{
name = "plant_altar_stalk",
diffuseMap = "assets/textures/items/stalk_dif.tga",
specularMap = "assets/textures/items/stalk_spec.tga",
doubleSided = false,
lighting = true,
alphaTest = false,
blendMode = "Opaque",
textureAddressMode = "Wrap",
glossiness = 30,
depthBias = 0,
}

Notice a couple of things here.
First, in two cases (moss and stalk) the material name is not the same as the .dds file name, but in the case of the plant_altar_base it is. The important thing here is that the material name refers to the material itself, with all associated files and settings (remember from earlier a material can have multiple textures), while the name of the .dds file represents on that individual file. In this case I named all three materials similar so they will show up in the GMT materials library next to each other.

Second, note there are only three materials, but six files. Remember each material will get a dif and spec texture, (6/2 = 3).

Third, and really important to note is that the texture files, which are .dds files, must be referenced in the filepath as .tga. I don't understand why, and never seen an explanation, so I just accept it as the truth that it is and everything works just fine and the kingdom rejoices.

Once the materials definitions are in place, open the GMT, if it is open already select reload materials library from the tool menu, and look in the lower right of the node menu (as dicussed above)and see if the new materials are in the pull down menu. If so then it's time to import the model. If not try closing the GMT and reopening it, then recheck the definitions for errors, and check filepaths again)
SpoilerShow
Image
Next I will import the model and apply the textures in GMT, do a rough scaling and start working on getting it in the game. Probably tomorrow though.
Last edited by Ryeath_Greystalk on Sat Aug 17, 2013 7:32 am, edited 2 times in total.
Ryeath_Greystalk
Posts: 366
Joined: Tue Jan 15, 2013 3:26 am
Location: Oregon

Re: [tutorial] plant altar - from idea to game object

Post by Ryeath_Greystalk »

16. Import OBJ, Scale, Rotate and Apply Textures in GMT

I've got my textures in the asset pack folder and GMT can find them. Time for the model.

In GMT file menu there are two options for importing a file, one) import OBL and two) assimp importer. According to John Wordsworth, who created the GMT, it is best to try the assimp importer first. So select assimp and then set the filepath to load the .obj file. When I exported my .obj file I named my it plant_altar_one.obj and exported it to the blender/plant altar folder along with all the other files I had created to this point. So I am going to point the assimp importer to blender/plant altar/plant_altar_one.obj.

When I try to import this model I get an error saying "Failed to import OBJ object with error: Given key not found" (paraphrased, but close to that). If you get this error then cancel that action and open up the plain import OBJ option and point the filepath to the plant altar obj file.

Now the plant altar should be in GMT, but it is most likely gigantic. This is because the scales are different between blender and GMT. There is an option to change the scale in blender when exporting but I have not tried to use it yet. It is fairly simple to scale in GMT and to this point I just use trial and error.

The first thing to do is look under the nodes pull down menu and highlight the node that will select the object. You will know because the selected node will turn red. Once selected enter a number into the scale modifier and since we want the object smaller we want to enter a number less than one. Entering a .5 will decrease the size by half. A .1 will make the object a tenth of the size. I did not make good notes about the numbers I used, but it took about four tries to get it where I thought it might be close. (I opened the altar object from the game first to get a rough idea of the altar size.) When scaling the modifier is applied to the current size, not the starting size. So, for instance, if you apply a .5 scale and find the object is too small, you will then need to apply a number larger than 1 to make the object bigger.
SpoilerShow
Image
Once I have the scale about where I wanted it I will go down to the Node Segments and open the pull down menu. Notice the node are listed as base, top, moss, stalk, stalk, stalk, stalk. These are the same names that I used in the blender to identify the different materials when I was applying the texture to them. So the base and top are both called base, and the 4 stalks are the same. These are the material names, not the names I gave the objects in blender. I was a bit mistaken earlier in the tutorial when I said renaming the objects would help in GMT.

Now it is the simple process of selecting each node segment, opening the materials drop down menu, finding the appropriate material then pressing the set material button and the texture should appear on the object.
SpoilerShow
Image

Image


Note, I also rotated the altar 90 degrees on the Y axis so the wide side of the altar would be facing front in the default position. I didn't pay attention when I built it in blender. One odd thing is I would think that I would want to rotate on the "Z" axis to spin the altar, but it is "Y" axis in GMT. Makes me think the axis' are not the same between the two programs.
Last edited by Ryeath_Greystalk on Sat Aug 17, 2013 7:55 am, edited 1 time in total.
Ryeath_Greystalk
Posts: 366
Joined: Tue Jan 15, 2013 3:26 am
Location: Oregon

Re: [tutorial] plant altar - from idea to game object

Post by Ryeath_Greystalk »

17. Check Textures in test room, Prep for export, Save to a Grimrock Dungeon Folder

A little note about scale in the GMT. The default display grid is 3 x 3 squares. The way I understand it, each square in Grimrock is 3 meters by 3 meters, so each square on the grid represents 1 meter ( or 1/3 of the game square).

In the scene tab it is possible to see your model in a mock up room that is 3 x 3 game grid size (9 x 9 meters). It is easy to think something is a miss when you look at the object in the nodes window and then see it in the scene window and wonder why it appears smaller.

Now that the textures are applied, go to the scene tab and select build 3x3 room. You should see a room with the new object proudly displayed. Go back to the nodes menu and deselect the main node to get rid of the red highlight to see the textures better.
SpoilerShow
Image
The textures are kind of blah in this room, and the stalks are too bright, but that is minor details right now (a dungeon room is probably not going to be this bright). I know I am going to have to fine tune the scale of the model since it is an altar (can't have stuff floating above it, or clipping through it), so for now I just want to get the object in game and test it out.

Back in the nodes menu highlight the main object again. (go back to scene first and select clear all to get rid of the mock up room). Go to the model menu and select recalculate normal. It will probably tell you the normal are already calculated, but go ahead and recalc them anyways. Then you will need to select the main object again and from the model menu select recalculate tangents. Of the two this is probably the most import. Always recalculate tangents before saving, or so I have been told by those much wiser than I.

Now it's time to select save as. Make sure the filepath goes to a Grimrock dungeon folder, (or another folder where you can copy it from later). Hit enter to save and the model is now ready to be placed in the game......almost.
Last edited by Ryeath_Greystalk on Sat Aug 17, 2013 8:00 am, edited 1 time in total.
Ryeath_Greystalk
Posts: 366
Joined: Tue Jan 15, 2013 3:26 am
Location: Oregon

Re: [tutorial] plant altar - from idea to game object

Post by Ryeath_Greystalk »

18. Create Object Definition and Material Definitions to game mod_assets folder, Copy .dds files to mod_assets folder

Now that you have the model close to done and ready for fine tuning it, the model needs to be placed into a dungeons mod_assets/models folder.

Now there are few steps needed to do for the game to be able to use the model.

First thing is to write the object definition into the mod_assets/scripts/objects.lua file. This is one of those times where you might ask yourself "Is this an object or an item"? I'm not sure of the difference but I know I am going to just copy the existing altar definition, and it is listed in the objects.lua so I will put my definition in the mod_assets/scripts/objects.lua also. (See John Wordsworth's interpretation of the differences a couple posts from here.)

This part is easy since I am just copying the altar definition and modifying two lines,

defineObject{
name = "RG_plant_altar",
class = "Altar",
model = "mod_assets/models/RG_plant_altar.fbx",
placement = "floor",
editorIcon = 52,
}

I only had to change two items 1) the name and 2) the filepath. The filepath will point to the .model file. Note two things about filepath 1) the filename ends in.fbx (not .model). Just like the .dds files needed to be called .tga in the material definitions, the .model files need to be referred to as .fbx. and 2)I started the object name with RG_. This helps to reduce the chance of someone else making an object and calling it plant_altar and getting conflicts. (RG for Ryeath Greystalk)

Next I need to write the material definitions into the mod_assets/scripts/materials.lua file.
Again this part is simple because I am just going to copy the definitions that I made up earlier and put in the assets folder. (remember the giant wall of text)

defineMaterial{
name = "plant_altar_moss",
diffuseMap = "assets/textures/items/moss_dif.tga",
specularMap = "assets/textures/items/moss_spec.tga",
doubleSided = false,
lighting = true,
alphaTest = false,
blendMode = "Opaque",
textureAddressMode = "Wrap",
glossiness = 30,
depthBias = 0,
}
defineMaterial{
name = "plant_altar_base",
diffuseMap = "assets/textures/items/plant_altar_base_dif.tga",
specularMap = "assets/textures/items/plant_altar_base_spec.tga",
doubleSided = false,
lighting = true,
alphaTest = false,
blendMode = "Opaque",
textureAddressMode = "Wrap",
glossiness = 30,
depthBias = 0,
}
defineMaterial{
name = "plant_altar_stalk",
diffuseMap = "assets/textures/items/stalk_dif.tga",
specularMap = "assets/textures/items/stalk_spec.tga",
doubleSided = false,
lighting = true,
alphaTest = false,
blendMode = "Opaque",
textureAddressMode = "Wrap",
glossiness = 30,
depthBias = 0,
}

The only problem with these definitions is the file paths. They point to the asset pack folder and the game may not be able to find them there (and if someone else uses your assets, they may not even have the asset pack downloaded). I am going to go through and change the filepaths to go to my dungeons mod_assets\scripts\materials.lua. Here are the new and improved material definitions.

defineMaterial{
name = "plant_altar_moss",
diffuseMap = "mod_assets/textures/moss_dif.tga",
specularMap = "mod_assets/textures/moss_spec.tga",
doubleSided = false,
lighting = true,
alphaTest = false,
blendMode = "Opaque",
textureAddressMode = "Wrap",
glossiness = 30,
depthBias = 0,
}

defineMaterial{
name = "plant_altar_base",
diffuseMap = "mod_assets/textures/plant_altar_base_dif.tga",
specularMap = "mod_assets/textures/plant_altar_base_spec.tga",
doubleSided = false,
lighting = true,
alphaTest = false,
blendMode = "Opaque",
textureAddressMode = "Wrap",
glossiness = 30,
depthBias = 0,
}

defineMaterial{
name = "plant_altar_stalk",
diffuseMap = "mod_assets/textures/stalk_dif.tga",
specularMap = "mod_assets/textures/stalk_spec.tga",
doubleSided = false,
lighting = true,
alphaTest = false,
blendMode = "Opaque",
textureAddressMode = "Wrap",
glossiness = 30,
depthBias = 0,
}

Now our object is defined and our materials are defined the only thing now is to make copies of the .dds files into the mod_assets/textures file. By now you probably are saying why three copies. Because I am too lazy to go through and constantly alter file paths. I also believe the shorter the file path the better chance of success. And I can go through and make changes to one file with out effecting the others. As I will point out near the end, I went and changed the base.dds file in the dungeon copy in a way that I can not undo it, but I still have good copies in blender and GMT I can fall back on.

If everything is correct it is time to fire up the dungeon editor and see if the plant altar is in there and functional.
Last edited by Ryeath_Greystalk on Sat Aug 17, 2013 8:12 am, edited 1 time in total.
Ryeath_Greystalk
Posts: 366
Joined: Tue Jan 15, 2013 3:26 am
Location: Oregon

Re: [tutorial] plant altar - from idea to game object

Post by Ryeath_Greystalk »

19. Test Altar in Grimrock Editor, Re-scale Altar in GMT

I open up Grimrock, open the editor and load up my test dungeon and make a room (actually already have a room since it's a test dungeon). Look over at the items menu and see if I can find RG_plant_altar.
Right there near the top of the list is the altar (I think because RG is capital it goes to the top before the non capitalized items, not sure though. Or maybe because it has an underscore in the name)

So I put it in my room and put a key on it and...
SpoilerShow
Image
Just a wee bit too small. The key just floats over it like magic. I am now going to apply my scientific guessing method and try to increase it by 1.35. Close the editor and go back into GMT. This time instead of importing (no need to start over) I will just select open and point the GMT to the plant altar model. In nodes select the main object, in scale enter 1.35 and hit scale. next I recalculate tangents and save as. The GMT will ask you if want to overwrite the existing model, select yes.

That is all that was need to rescale it. I will now go back into Grimrock editor and try again. This time I could detect a slight hint of light under the key (not bad for a guess), so I am going to repeat the process one more time with a scale of 1.1. I also took the opportunity here to open up the stalk_diff.dds file (the copy from the mod_assets/textures folder) and change the brightness down just a bit in paint.net. Save everything again and go back to test it and

voila,
SpoilerShow
Image

Image

Image
You can see between the first and second picture where I made the stalks darker, although the first one may look better.
Also between the first and second is where I made the change to the base texture. I can not go back and change it, but since I still have copies of the .dds in blender and the asset pack folder, I can go back and copy over the messed up file if I want.

There it is, from idea to game object, how to get a custom item into Legend of Grimrock.

It may not be the most professional looking thing, but I can only get better with time and experience. I took care not to say from idea to finish because I am planning on going through and working on it some more, primarily in the area of textures to make it look a little better. I will post more as I make progress. I also want to go through and clean up my posts a little better, fix some typo's and adding an extra point here and there.

If it helps someone in the future that is great. If not then I still learned things while making it (as well as making a long list of things to learn about).

Again many thanks to everyone who has extended their help, support and encouragement along the way. Perhaps I may be a productive member of the modding community one day.

Thanks.
Last edited by Ryeath_Greystalk on Sat Aug 17, 2013 8:20 am, edited 1 time in total.
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: [tutorial] plant altar - from idea to game object

Post by JohnWordsworth »

Awesome tutorial. It's very handy for anyone starting out to see everything in one place in a nice linear format. Also interesting to see it from the perspective who is relatively new to the process - once you have done it a dozen times, it's hard to remember the difficult spots.

My interpretation on items vs objects nomenclature: I believe that items are things that you can pick up with the mouse cursor and (usually) place in your inventory. Objects are things that only exist in the game world.
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: [tutorial] plant altar - from idea to game object

Post by msyblade »

Fantastic in-depth Tutorial, and well explained for someone who actually wants to follow step by step. Step by step with a tutorial is how I learned to make so much as a cube in blender. Honestly, the UI hurts your thinking parts the first time you try to comprehend it. The pics were a very considerate touch, also. I think a lot of people will be glad you took the time to write this up.

A couple of suggestions to help with future players search efforts:
1 - Insert the word model somewhere in the main title, I would be likely to search for model when wanting to learn about this subject.

2 - Give each post a header describing its contents (ie: "Importing the .obj to GMT", or "setting up the .lua scripts") for people who may be trying to learn on their own, but need to find a specific answer.

Thanx again and Kudos!
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
Ryeath_Greystalk
Posts: 366
Joined: Tue Jan 15, 2013 3:26 am
Location: Oregon

Re: [tutorial] plant altar - from idea to model to game obje

Post by Ryeath_Greystalk »

Thanks for the kind reviews mysblade and John Wordsworth. I couldn't have done any of this with your help and the help of others.

Those are some really good suggestions msyblade. I got the title changed to include model (I should probably do a test search) and I will get some headers on the topics over time as I go through and clean them up some.

I still have a couple things I want to add, but need to research first, such as packaging all the things required so someone can download and use the asset with a minimal effort.

I mentioned at the end I messed up the base texture. What I did was take the texture I had been using and applied a tile modifier to it. It looked neat on the .dds file but not very good on the model. Once I took a good look at it I noticed one of the reasons my textures don't quite look crisp. The parts of the uv wrap are really small compared to the texture. If you look really close at the bottom two pictures you might be able to detect a couple squares (at an angle so more like diamonds) on the base. I was imagining the base would have a tiled looked, but the tiles were so big it didn't give that appearance.

I went and played with the base texture (since I messed it up at the end anyways) and tried to make a copper looking texture. I applied the tile settings again to make very small tiles then added another layer with about 50% transparency to adjust the color some, played around with the color settings and came up with this. Still not great but I think maybe a bit better than the last one.
SpoilerShow
Image
To make simple changes without changing the layout of the uv map, all I had to do was open the plant_altar_base_dif.dds from the test dungeon textures folder, make the changes then resave the file. Next time Grimrock is started it will load the new texture (as long as you don't change the filename or filepath.
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: [tutorial] plant altar - from idea to model to game obje

Post by Neikun »

Really impressed with this. Great job.
I just have one bad joke for you.

Why doesn't the plant altar have a....
Greystalk!
:lol:
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
Ryeath_Greystalk
Posts: 366
Joined: Tue Jan 15, 2013 3:26 am
Location: Oregon

Re: [tutorial] plant altar - from idea to model to game obje

Post by Ryeath_Greystalk »

Neikun wrote:Really impressed with this. Great job.
I just have one bad joke for you.

Why doesn't the plant altar have a....
Greystalk!
:lol:
Thanks for the compliment, and the joke. I got a good chuckle out of that. /rimshot
Post Reply