= Warg - from cube to animated and textured game model Example
:author:
:revnumber:
:revdate: 2016/03/17 20:48
:relfileprefix: ../../
:imagesdir: ../..
ifdef::env-github,env-browser[:outfilesuffix: .adoc]



[IMPORTANT]
====
to make this example you need to know basic of modeling like extending faces / merge vertexes / (move vertex / edge / face) / etc.
====



== Preview

image:jme3/external/preview.jpg[preview.jpg,width="",height=""]


== Step 1 - Prepare

- Open Blender with new Scene
- Add a simple Cube. To make it press shift-a and select Cube

image:jme3/external/2.jpg[2.jpg,width="",height=""]

- “t” key open tool window. let’s open it and set x-mirror ON

image:jme3/external/4.jpg[4.jpg,width="",height=""]

- Subdivide this cube to get more faces
* this can be also done via modifiers → subdivision surface (it will be later)

image:jme3/external/5.jpg[5.jpg,width="",height=""]

- “n” key open second toolbar with useable options. let's load an example image to help us build Warg.
I found a nice warg image on devian art.

image:jme3/external/example.jpg[example.jpg,width="",height=""]

- make simple Warg Shape like on images

image:jme3/external/6.jpg[6.jpg,width="",height=""]
image:jme3/external/7.jpg[7.jpg,width="",height=""]
image:jme3/external/9.jpg[9.jpg,width="",height=""]


== Step 2 - Modeling

- in tool window(“t”) is a smooth tool that can help model the warg.

image:jme3/external/10.jpg[10.jpg,width="",height=""]

- to easly add edge loop use “loop cut and slide” tool that work that way:

image:jme3/external/12.jpg[12.jpg,width="",height=""]
image:jme3/external/13.jpg[13.jpg,width="",height=""]

- Go to modifiers and add Mirror surface

image:jme3/external/14.jpg[14.jpg,width="",height=""]

- add some details like eyes / etc.


[IMPORTANT]
====
need to know how to use extend faces(key “e) and merge extended face.
====


image:jme3/external/15.jpg[15.jpg,width="",height=""]
image:jme3/external/16.jpg[16.jpg,width="",height=""]

- to use smooth shading just set it in tool window.

image:jme3/external/17.jpg[17.jpg,width="",height=""]

- Apply modifier. just press “Apply” button in Mirror modifier.
- Remove doubles (it removes vertexes that are too close each other).

image:jme3/external/18.jpg[18.jpg,width="",height=""]


== Step 2 - Armature

- Shift-a and add armature in Object Mode.


[NOTE]
====
shift-a to add a bone in Edit Mode
====

image:jme3/external/19.jpg[19.jpg,width="",height=""]

[NOTE]
====
tail should be done in other way. Start to build skeleton from start of the tail (not end)
====

image:jme3/external/21.jpg[21.jpg,width="",height=""]

- Show names and change armature view (if you like)

image:jme3/external/22.jpg[22.jpg,width="",height=""]

- set Names for bones (via properties window or “n” option window)

image:jme3/external/23.jpg[23.jpg,width="",height=""]

- Select left side bones only, press shift-d to copy them, and make mirror.
Remember to have cursor in 0,0,0 and have settings like on image (if not then you will need just to move copied bones manually)

image:jme3/external/25.jpg[25.jpg,width="",height=""]

- Press “w” and select “flip names”

image:jme3/external/26.jpg[26.jpg,width="",height=""]
image:jme3/external/27.jpg[27.jpg,width="",height=""]

- In Object Mode:
* Select Model
* With SHIFT select armature
* Press “p” and select “with automatic weights”

image:jme3/external/28.jpg[28.jpg,width="",height=""]

- Try move a leg in Pose Mode

[NOTE]
====
Pose Mode work like Edit mode, use “r to rotate a bone. using “x/“y/“z after “g/“r/“s will also work here like everything else.
====

image:jme3/external/29.jpg[29.jpg,width="",height=""]

- Go to Animation View

image:jme3/external/30.jpg[30.jpg,width="",height=""]

- Add a new action

image:jme3/external/31.jpg[31.jpg,width="",height=""]

- Select all bones in Pose Mode and apply location / rottion / scale.
To do it press “i” and select it like on image:

image:jme3/external/32.jpg[32.jpg,width="",height=""]


[TIP]
====
alt-r / alt-g / alt-s – clear rotation / location / scale
====

- there is possibility to copy poses

image:jme3/external/33.jpg[33.jpg,width="",height=""]

- and also to copy them in mirrored pose

image:jme3/external/35.jpg[35.jpg,width="",height=""]

- in action editor you can easly remove / move / scale frames

image:jme3/external/34.jpg[34.jpg,width="",height=""]

- If animation work not linear (and you don't like it), then you can change it in Curve editor window

image:jme3/external/36.jpg[36.jpg,width="",height=""]

- Thats all for Animations, for more just Read JME wiki / documentation.


== Step 2 - Texturing

- Move armature to second layer.
press “m” to make it.

image:jme3/external/37.jpg[37.jpg,width="",height=""]

- In edit mode, need to mark seam on Edges to prepare model for texturing.
press ctrl-e to make it.

image:jme3/external/38.jpg[38.jpg,width="",height=""]

- do it similar to this (or you can make it better):

image:jme3/external/40.jpg[40.jpg,width="",height=""]
image:jme3/external/41.jpg[41.jpg,width="",height=""]
image:jme3/external/43.jpg[43.jpg,width="",height=""]

- Press “u” and select first option “unwrap”
- In UV window you can minimize stretch
(minimize stretch change with mouse wheele).

image:jme3/external/44.jpg[44.jpg,width="",height=""]

- make a 2 geometries for model:
* body (contains faces for body)
* eyes (containes faces for eyes)

image:jme3/external/45.jpg[45.jpg,width="",height=""]

image:jme3/external/48.jpg[48.jpg,width="",height=""]

- for eyes you can use “Sphere projection for unwrap”

image:jme3/external/49.jpg[49.jpg,width="",height=""]

- Select texture image

image:jme3/external/50.jpg[50.jpg,width="",height=""]

- under “n” option window, set like on image to see texture.
(ViewPort need to be set as solid, ViewPort is near Object/Edit select)

image:jme3/external/52.jpg[52.jpg,width="",height=""]

- Just make texture of model (using Texture Mode – where Object / edit mode is)


[NOTE]
====
under “t tools you can change color / size / etc of brush
====


image:jme3/external/55.jpg[55.jpg,width="",height=""]

- Using 2d tool like Gimp / Photoshop, use filter/modifier to get nice looking skin

image:jme3/external/56.jpg[56.jpg,width="",height=""]

- Now only need to export via Ogre Mesh or just via Blend file (using SDK).

- For eyes and body, use separated j3m files, then set them in SceneComposer.


[IMPORTANT]
====
also don’t forget about NLA editor and set off envelopes to make animations work!
====


here are docs:

<<jme3/external/blender#,jme3:external:blender>>

- Done!
