Author Topic: Simple Modeling School  (Read 21045 times)

Cherppow

  • Hydlaa Citizen
  • *
  • Posts: 493
    • View Profile
Re: Simple Modeling School
« Reply #15 on: January 08, 2007, 06:15:42 pm »
Hi again,

Thanks for the contribution everyone! Especially thanks for everyone who posted nice tutorial links.

To Erik:
Erik you guru! Come back to us, we need the Sunshine. *bows*

To Robinmagus:
Thanks for pointing those out, I modified the guide slightly. In the edit4 you're propably right, only the selected vertices move because the falloff radius is too small to reach the next vertices. You can grow the range with Page Up or with mouse wheel. Judging from your screenshot you have the proportional edit enabled, so you should see a circle once you enlarge the radius a bit. Just make the circle about same size as in this picture, and the other vertices start to move too.




 *Edit*


*****


Lesson 6: Drawing a texture

Let us continue by making a more realistic skin to the banana. Instead of using Manny's makeshift texture, let's create a new one from the scratch. Start Blender and open the banana model. Select the banana and go into UV/Image editor. From the UVs menu there, choose "Save UV Face Layout..." option. A query window will appear, asking some values for the output.
- The topmost value is the size of the image in pixels.
- The second value controls line width of the faces.
- Wrap button controls how the faces outside the image borders will be handled; either wrapped to appear from the opposite edge, or scaled down so they fit in.
- All Faces button toggles whether all faces will be drawn on the layout, or just the ones selected.
- Ob button causes the object name to be added in the front of the output filename.
- Edit button enables one to launch an external image editor program straight away.
- The last field is used for the external edit program path.

Here are quite suitable options for the banana texture. Set the same values and click OK. Then select suitable directory and filename, preferably "banana01a", and click Save UV Image.




I don't know about you, but I can't remember the path to where I installed Gimp, so I have to start it manually. Start Gimp and open the UV image layout we just created. It should be there as .tga if you've not changed the default output settings in Blender. Result should look like this:



We have a problem again. The export script in Blender only saves square images, and ours was a rectangle. Luckily we still remember the original resolution: 128x256. We should scale the image right away to prevent further confusion. Right click the image area in Gimp and select Tools-Transform Tools-Scale... a window will appear asking scale values. Unlock the aspect ratio from the chain icon, and change the width from 256 to 128. Finally hit Scale.



The result resembles the UV map of our banana. Now we know what to draw where. Onward to find a realistic banana image! A good source is the Image*After-website. It provides textures of many categories, free for both personal and commercial use. I searched the foods section and found these interesting banana peels. Copy the image and paste it to your Gimp. As you can see the image is quite large. Scale it down to 18%.



Next we need to rotate the image 90 degree counter-clockwise. Select Tools-Transform Tools-Rotate... and input -90 as angle. Now copy the rotated image to the clipboard, typical shortcut ctrl+c. Select the image with the UV face layout again and paste the clipboard there. Banana peel image appears as a floating selection. While the pasted selection is floating, create a new layer (Right mouse-Layer-New Layer), this will promote the current selection to layer, while keeping it's original size (which is larger than the current image). Finally open the layers tab in Gimp. You'll see two layers there: Pasted layer and Background. Change the Mode of the "Pasted Layer" to Multiply, this enables you to see the UV layout through it. The image should now look like this:



Next we need to place the peels with our UV map. First flip the whole layer horizontally. Move the twin peel to the center of the image with move tool. Finally rotate the layer 5 degree counter-clockwise. Try to match this:



Open the layers tab again, and change the Pasted layer mode back to normal. Then save the texture as banana01a.tga. Gimp warns that tga cannot save multiple layers, but it's ok, as we only need the visible layer for now. Just click "Export". Start Blender again if you've closed it. Select the banana object and enter UV Face select mode F and open the banana01a.tga in the UV/Image editor. Situation looks like this:



One advantage of texturing your own models is that you have the ability to modify the UV layout to match your texture. This is often faster than modifying your texture to match the UV-map. Don't go too far though, if you mess up the uv-map completely, creating additional skins will be close to impossible. In our case however, only slight modification is needed. First select the side pieces and move them 10 to the right and rotate them -1.5. Then select the six middlemost UVs of the top and bottom sides (as seen in the image) and move them 12 to the right. This will distort the texture a bit, but not noticably.



Select the three topmost and three lowermost UVs of those pieces and move them 14 to the left. Finally select the tiny end pieces and move them 18 to the right. Your uv map should look like this:



Exit UV Face select mode F and render F12.



Oh yeah, have to change that material pointer too. Check the buttons window, texture buttons. Change the image to banana01a.tga. Render.



It's a banana. Manny arrives and does the funky banana dance. You should save your work now, before Manny eats it. Here is my final render.



That's the end of Drawing a texture. Manny thanks for your interest and bananas. More advanced tips later perhaps.

End of Lesson 6: Drawing a texture
« Last Edit: January 10, 2007, 04:24:41 am by Cherppow »

Cherppow

  • Hydlaa Citizen
  • *
  • Posts: 493
    • View Profile
Re: Simple Modeling School
« Reply #16 on: January 15, 2007, 05:00:03 pm »
Lesson 7: Exporting to PlaneShift
 
Time has come to test the model in PlaneShift. Start Blender and open the banana model. Let's just export it and see how it looks. If you've installed Blender2Crystal properly in the first lesson, you'll have a "CrystalSpace" option in File-Export menu. Click it and wait for the exporter window to open. Select the library option, as we're creating an item and not a level. Choose suitable export directory and push Export. I get a python script error and the exporter disappears.

*edit*
If you do not get an error and the export runs through fine, you should congratulate yourself; you're either lucky or know what you're doing. You should still change the object type to genmesh from the overlay gui, but you don't have to mess with the renderloop. Then export the object again, as library, and jump to 7.1.




If we take a look at the console program, we see a long list of traceback. The last item is the most interesting:

Code: [Select]

 "...line 273, in get_material_shaders steps = b2cs.prop.global_keys["renderloops"][rloop].getSteps() KeyError: 'standard'"

I'm no coder, but it seems to point that something is amiss in the renderloop 'standard'. We need to change that. First open the overlay interface of the blender2crystal. You can do this from View-Space Handler Scripts-Event:blender2crystal.py. Finally click on your 3D view to open the exporter on that window. A large grey box appears to fill your view. That's the export, jammed due to the error. Double click on it to close. Now you should see the normal overlay gui. Change the object type to genmesh:
 


Onward to change the renderloop then. Select the square painting from the top row, there we can change sector settings. We also see a renderloop option there. It's currently "not set". Click the value to change it and choose "ambient" from the popup menu. (This doesn't affect anything really, since we're only exporting a single object library.)
 

 
Continue by clicking the gear icon on the top row. This brings up the exporter main screen. Click the "create library" button and the export should run through.
 




7.1 Tweaking by hand
If you check the export dir, there is a world.zip packed file. Open it and you'll see it has tree files in it:
 
- banana01a.tga (texture)
- library (so called worldfile)
- genbanana (banana model file)
 
Ok, let's get the model in PS then. Open your PS install directory. Go into /art/things dir and copy all the export files there. First let's get rid of the worldfile, since libraries don't need them. Open the "library" on a text editor. It's not very long. Mine is like this:
 
Code: [Select]
<?xml version='1.0' encoding='UTF-8'?>
<library>
  <plugins>
    <plugin name='genmeshfact'>crystalspace.mesh.loader.factory.genmesh</plugin>
  </plugins>
  <shaders/>
  <textures>
    <texture name='banana01a.tga'>
      <file>textures/banana01a.tga</file>
    </texture>
  </textures>
  <materials>
    <material name='ma_bananabanana01a.tga'>
      <texture>banana01a.tga</texture>
    </material>
  </materials>
  <sounds/>
  <library>factories/genbanana</library>
</library>

There are two things of interest there:
 
    <plugin name='genmeshfact'>crystalspace.mesh.loader.factory.genmesh</plugin>
 
Which links a plugin named 'genmeshfact' to a certain crystalspace mesh loader. And
 
    <material name='ma_bananabanana01a.tga'>
      <texture>banana01a.tga</texture>
    </material>
 
Which links a material named "ma_bananabanana01a.tga" to a texture named "banana01a.tga".
 
Next open "genbanana" in text editor. It's a bit longer file, but most of it is coordinate data, which we don't have to go into. The first few lines are of interest here.
 
Code: [Select]
<library>
<meshfact name='genbanana'>
<plugin>genmeshfact</plugin>
<zuse/>
<params>
<material>ma_bananabanana01a.tga</material>

The first tag "library" defines that this is a library. The meshfact-tag defines name for this object factory. Next we have a plugin tag that specifies what type of mesh this is. Next is zuse-tag which is the Z-Buffer render mode for this object. Then there is params tag, and inside, material tag, which defines the texture. Let's replace the plugin and texture with the ones found in the earlier file:
 
Replace
<plugin>genmeshfact</plugin>
with
<plugin>crystalspace.mesh.loader.factory.genmesh</plugin>
 
and replace
      <material>ma_bananabanana01a.tga</material>
with
      <material>banana01a.tga</material>
 
Then let's delete the line
<zuse/>
alltogether and just let CS use the default.
 
Last but not least, change the meshfact name
<meshfact name='genbanana'>
to
<meshfact name='banana'>
 
The model file is starting to look good. Might be a good time to save your changes. You can also delete the file named "library", we don't need it anymore. Next step is to replace an existing PS item model with our custom one. I have selected shortsword as the item to replace, because I know I my character has that item in his inventory. If I open the shortsword01a.spr from PS/art/things/weapons.zip in a text editor, it looks like this:
 
Code: [Select]
<meshfact name="weapons#shortsword01a">
   <plugin>crystalspace.mesh.loader.factory.sprite.3d</plugin>
  <params>
    <material>/planeshift/weapons/shortsword01a.dds</material>
    <frame name="stand0">
...

We see certain differences with our "genbanana" file. Most importantly:
 
<meshfact name="weapons#shortsword01a">
and
<material>/planeshift/weapons/shortsword01a.dds</material>
 
Let's add those changes to the genbanana. The banana file should now look like this:
 
Code: [Select]
<library>
<meshfact name="weapons#shortsword01a">
<plugin>crystalspace.mesh.loader.factory.genmesh</plugin>
<params>
<material>/planeshift/weapons/banana01a.tga</material>
...

Note that I left the material to point to the banana texture. Finally save the genbanana file and close the text editor. Rename "genbanana" to "shortsword01a.spr". Take a backup copy of the original PS shortsword01a.spr! Then copy the both custom files, banana01a.tga and shortsword01a.spr, into PS/art/things/weapons.zip. Run Planeshift normally and find yourself a shotsword.
 

 
 
Well it is exported, although the fruit is over 9,5 meters long and poorly aligned. More about fine tuning the results later. This is the end of the exporting lesson.
 
End of Lesson 7: Exporting to PlaneShift
« Last Edit: May 07, 2007, 05:07:57 am by Cherppow »

ThomPhoenix

  • Testers
  • Forum Addict
  • *
  • Posts: 2678
  • A Phoenix, what'd you expect?
    • View Profile
Re: Simple Modeling School
« Reply #17 on: January 15, 2007, 05:04:58 pm »
I knew it would work out! :)
We're not evil. We're simply amazing.

Cherppow

  • Hydlaa Citizen
  • *
  • Posts: 493
    • View Profile
Re: Simple Modeling School
« Reply #18 on: January 16, 2007, 07:33:59 pm »
*****


Lesson 8: Exporting conventions

The banana was no good. The biggest problem was humongous size, but also orientation and position was wrong. Why? The answer is as simple as "we made it such". The mistakes are in our model, which is kind of good, because we can easily fix them as long as we have the source. And that we do. Open banana.blend in Blender.

First, let's check the size. In PlaneShift we use size convention 1 unit = 1 meter. There are several ways to view your objects size in Blender, let's take a look at one of them. In object mode select the banana and press N-key. This will open a Transform Properties window. You can see four sets of numbers.



- Loc-values show the location of this object along the three axis of space. To be exact, they point where the object's origin is located.
- Rot-values show the rotation of the object.
- Scale-values show if the object has been scaled outside edit mode.
- Dim-values state the dimensions of the object.

In our case dimension values are of importance. These values are in units (=meters). Our banana is 9.537 meter long, 2.605 meter wide and 1.595 meters thick. I'd say 30cm is a realistic target size here. A quick calculation reveals that the banana should be scaled down to 0.0315 of it's current size. We could scale it right away, in object mode, but that would only scale the current one instance of the object. So let's be smart and enter edit mode for scaling. There we can edit the actual factory, which is used by all possible instances of this object. Hit TAB to enter edit mode. Select all A vertices and scale S the banana to 0.0315. Once scaling you can type the value in with keyboard. Pretty tiny, huh? Press TAB again to exit edit mode. Open the Transform Properties window again if you closed it. Check the values now, should look like this:



30 x 8,2 x 5 cm a fine specimen it is. Now the size is fixed, let's move on to position. Currently the banana is not centered. For PlaneShift weapons and handheld items, objects should be centered so that the handle is in coordinate space origin 0,0,0. So, let us move the banana to the middle of space. One way is to go into edit mode and move all the mesh manually, however, Blender also provides a shortcut for this. See the buttons window Editing panel for a button named "Centre". As the tooltip explains, this will center the objects data to the objects origin. Click it. Zoom in to the banana a bit to get a better look. Should look like this:



Pretty good, however... The handle is not quite at the origin. We'll have to tweak it by hand after all. Enter edit mode TAB, select all A and grab G them 0.02 along x-axis. You can use top view Numpad 7 to help.



Good. Now the only thing left is the orientation. In PlaneShift weapons and handheld items should face towards Blenders negative y-axis, and have topside pointing up. Our banana needs to be rotated in two ways. Still in editmode and all vertices selected? Good. Go into top view Numpad 7 and try rotating R them a bit. As you can see our handle position would get messed up again. Cancel the rotate. We need a different rotating pivot. To be exact, we want our banana to rotate around the handle point, that way it'll remain stationary no matter how we rotate. Change the rotation/scaling pivot .-key to "3D Cursor". Now to snap the 3D cursor to 0,0,0 open View-View Properties window and type in zero to all the 3D Cursor values. 



Now then, try rotating all the vertices. Nice moves. Go in top view mode Numpad 7 if not already and begin rotate R. While rotating, hit R again to go in trackball mode. Rotate the banana to values -90 and -90. The banana's front should now be pointing down, and the thin top end towards you.



Finally, let's tilt the banana a bit forward, since it's a curved object and not straight like swords and such. This reduces how much the upper end of the banana will be overlapping the thumb. I don't think this is in any official rules, but practice has shown it works. While in top view, rotate the banana 15 along x-axis.




Exit edit mode and save your work. It's time to export and try the object in-game. Check previous lesson how to open the exporter overlay gui, if you've closed it. Check that object type is set to genmesh, and renderloop something else than "not set". Then click "create library".

Go into your export directory and unzip the world.zip there. You'll get three files again. Copy them to PlaneShift/art/things/ directory. I'll replace the existing shortsword again. I still have the older banana model as .spr in the directory, so I can use that as a reference. I also have the old banana texture already in weapons.zip, so I only need the new genbanana-file. Modify the new genbanana-file to begin like this:

Code: [Select]
<library>
<meshfact name="weapons#shortsword01a">
<plugin>crystalspace.mesh.loader.factory.genmesh</plugin>
<params>
<material>/planeshift/weapons/banana01a.tga</material>

Save it and rename it to "shortsword01a.spr" and copy it in weapons.zip. Then run PS and test. Mine looked like this:



Manny rejoices! Now he has his favourite fruit in-game! Surely eadible. This is the end of exporting conventions. You should now be able to fine tune your export results as needed.

End of Lesson 8: Exporting conventions
« Last Edit: January 16, 2007, 07:46:05 pm by Cherppow »

Donari Tyndale

  • Hydlaa Notable
  • *
  • Posts: 748
    • View Profile
Re: Simple Modeling School
« Reply #19 on: January 17, 2007, 04:12:32 pm »
Great guide \\o//, but my banana doesn't move, no matter how I turn it. It stays static like that  >:(

Any suggestions what to do?

Cherppow

  • Hydlaa Citizen
  • *
  • Posts: 493
    • View Profile
Re: Simple Modeling School
« Reply #20 on: January 17, 2007, 05:06:35 pm »
Hi,

Hmm, it still follows the arm movement while you walk, right? Two possible things come into my mind:

- It seems that the "export library" command only takes into consideration the object factory data. Thus any rotation done outside editmode, will not be exported. Check that you've rotated not rotated the banana in object mode (see Transform Properties window). Also any rotation done in object mode can be cleared with alt+r. Then enter edit mode, rotate as you wish, exit edit mode and export.

- If the above doesn't help, check that there's no typos in the filenames, and that the updated file really overwrites the old shortsword01a.spr.

- If that doesn't help either you can paste your exported banana into http://rafb.net/paste/ and I'll take a closer look at it. :)

Thanks for your interest,
 - Cherppow

Donari Tyndale

  • Hydlaa Notable
  • *
  • Posts: 748
    • View Profile
Re: Simple Modeling School
« Reply #21 on: January 18, 2007, 08:33:31 am »
- It seems that the "export library" command only takes into consideration the object factory data. Thus any rotation done outside editmode, will not be exported. Check that you've rotated not rotated the banana in object mode (see Transform Properties window). Also any rotation done in object mode can be cleared with alt+r. Then enter edit mode, rotate as you wish, exit edit mode and export.
:D That's it! Thank you  \\o//

Cherppow

  • Hydlaa Citizen
  • *
  • Posts: 493
    • View Profile
Re: Simple Modeling School
« Reply #22 on: January 25, 2007, 08:18:16 pm »
Hi,

next parts. :)

Lesson 9: Into the intermediate

All right, You now have the knowledge to create basic PS models. However, the banana we created is about the simplest model there is, very small, static and unimportant object. There's a lot more that can be done. Your imagination is the only limit. The following are not lessons anymore, rather just tips, tricks and techniques that can be used to improve your models. There are many ways to do models, so these shouldn't be taken as the 'only right way'. Instead, you can try them out and use them if they feel useful for your style of modeling. Also feel welcome to propose a subject.

Lesson 9: Into the intermediate

****

Tip 1: Texture size

First step when creating a new texture is to choose a size. You can't make a good texture with bad size. In general it's better to create too large textures than too small, since large can be scaled down without much loss in detail. Here are some examples of different sized textures on 1 meter cube from 4m distance. See how the texture size affects the model:



At this distance, all top row textures are little bit too low on detail. Same goes for the 32x32. The 64x64 is already usable for generic objects, however, if the object is special, something that draws peoples' attention, I'd suggest using at least 128x128 texture. 256x256 and the larger ones don't show much difference here, but if we'd walk closer, the bigger textures would have the advantage. For a box like this I'd propably use 256x256.

The smaller textures are usable too. Mainly for smaller or less important objects, but also if UV-mapped efficiently. One way to get more out of small textures is by tiling the texture. This means simply that the UV map is actually bigger than the texture. The overflowing UV parts wrap to the opposite edge of the texture. Not all textures tile well, some may have sudden jumps in colour or lightness when wrapping from one edge to another. Those that do tile well, are called seamless. Here is the 16x16 texture tiled to resemble 48x48 texture:



Note how the tiled is much less pixelated than the original, although the cubes are similar otherwise. Also remember that you don't have to tile the texture in both directions, for example if you have a long staff model, you can tile it just vertically.

End of Tip 1: Texture size

*****

Tip 2: Texture drawing

Ok, let's have a closer look at drawing textures. I have made a simple sword to act as a test object. It has 104 triangles.



Manny goes "Boo, Cherp, you suck!". True, it isn't very impressive at it's current state. The sword is also uv-mapped; it uses 128x512 texture. Here's the layout:


So with the above loaded onto the sword, looks like this:


Next, I add the base textures as new layers. Just downloaded them from internet's many free texture sites. I've hidden the UV-layout for the pictures here, but I still have it as separate layer. Texture and mesh now look like this:



It's starting to look good, however, we can improve. In the next phase, I typically create a "grain merge" or "overlay" layer and paint static shadows. Here the UV layout comes to good use. I tend use large and smooth edged brush for this and pure black or white for colour.



Finally, I make a new "normal" layer on the top, and hand draw some details. This is the most timetaking part, and requires imagination too. I enhance edges and fix earlier errors, but also add colour and extra details. Sometimes I go back to earlier layers to fix errors there, or to add more shadows and light.  Patience is the key here. Just relax, listen to funky music and think about that special person in your life, while drawing a bit. Fun stuff. For this I use very small and sharp brush.



And that's about all there is to it. Or at least all I can teach you, I'm just a hobbyist. :)



End of Tip 2: Texture drawing
« Last Edit: January 25, 2007, 08:37:07 pm by Cherppow »

Nikodemus

  • Prospects
  • Veteran
  • *
  • Posts: 1808
    • View Profile
Re: Simple Modeling School
« Reply #23 on: January 26, 2007, 11:35:26 am »
too add a bit to the Cherppow's Lesson 9
To increase texture quality, near tiling, we can also play with the file size of the image. In extreme circumstances it is possible that 1024x1024 texture will have smaller filesize than 512x512 texture. In such an event, we increase the texture quality 4 times, keeping similiar filesize.
There are basically 3 factors we can play with to decrease the filesize.
  • - number of colors
  • - format (I gues it doesn't matter when we convert to binary format .dds, which PS uses)
  • - how the texture look itself
Number of colors - it depends of the format. For example .png: we can choose 16mln, 64k, 32k and 256 - 2 Generally, the less colors, the smaller file size. The above Cherppow's texture is 256 colors, because it wouldn't look really better if 16mln for example.
Format - it may happen that it may be worth to consider using a .jpeg, where we may not play with colors, but its compression, even if lossy, will make tiny difference in quality and so we gain smaller filesize.
The texture itself - generally, the less details, the smaller filesize. That's why when decreasing colors we choose "nearest color" over "error diffusion". Since it often happen that we don't use the whole texture surface for showing it on the model, Cherppow's texture should look like this in its last stage:


  • New texture filesize: 28152 B
  • Old texture filesize: 53072 B

The UV lines shouldn't be visible on the texture, but they are as indicator for you, where we should drawn the border of single color area. It shouldn't start along with the UV lines. When the texture start to blure, because of the angle how we look at the surface with texture, we start seeing what is behind the UV coords, because colors at different pixels are avaraged with this what is around. The more texture is blured because of the angle, the wider area from which the avarage color is obtained.



What you can failure tommorow, failure today.


Better click for shiny stylez Help me with images!

ThomPhoenix

  • Testers
  • Forum Addict
  • *
  • Posts: 2678
  • A Phoenix, what'd you expect?
    • View Profile
Re: Simple Modeling School
« Reply #24 on: January 26, 2007, 11:47:40 am »
As always, a great tutorial!
* ThomPhoenix loves it!
We're not evil. We're simply amazing.

Induane

  • Veteran
  • *
  • Posts: 1287
  • What should I put here?
    • View Profile
    • Vaalnor Inc.
Re: Simple Modeling School
« Reply #25 on: February 22, 2007, 09:11:16 pm »
It inspired me to make my first weapon ever!


Nikodemus

  • Prospects
  • Veteran
  • *
  • Posts: 1808
    • View Profile
Re: Simple Modeling School
« Reply #26 on: March 03, 2007, 12:23:28 pm »
You forgot to make a black robe with hood for the Ylian ;P

And you would have to atach the blade vertically if it is going to be considered a weapon ;P It's what peasands do when they are rebelling.



What you can failure tommorow, failure today.


Better click for shiny stylez Help me with images!

mufler

  • Hydlaa Resident
  • *
  • Posts: 61
    • View Profile
    • The Rails
Re: Simple Modeling School
« Reply #27 on: April 05, 2007, 03:29:54 pm »
OMG i love you! ;D

*edit*

if i modeled a wepon and stuff, will anybody els be able to see it? or just me?

[ Please avoid making one post right after the other in the same thread. Just "Modify" your first post to add more information. --Karyuu ]
« Last Edit: April 05, 2007, 03:32:54 pm by Karyuu »

Karyuu

  • Forum Legend
  • *
  • Posts: 9341
    • View Profile
Re: Simple Modeling School
« Reply #28 on: April 05, 2007, 03:34:36 pm »
The modifications you do on your side of the client can only be seen by you, and those you give your modifications to. Client-based changes are not a server-wide event. Just imagine the problems that could arise if anyone could modify any item or texture they want and instantly have others see them
Judge: Are you trying to show contempt for this court, Mr Smith?
Smith: No, My Lord. I am attempting to conceal it.

mufler

  • Hydlaa Resident
  • *
  • Posts: 61
    • View Profile
    • The Rails
Re: Simple Modeling School
« Reply #29 on: April 05, 2007, 04:47:12 pm »
ah i see, no would be nasty:s