banner



How To Animate A Mesh In Blender

Quick and Muddied Guide:
Rigging and Animating a Model,
then Exporting to and Viewing in Ogre

Step 1: Create a Model

For more details on creating a model, see Creating a model in Blender. We will do a very simple model for this example -- an inchworm! Starting with our friend the initial cube in blender, go to edit mode, switch to face selection, and select whatever face:
Creating Worm

Press 'e' (for extrude, you can instead select Mesh->Extrude->Extrude Region from the menu), and motion the extruded confront over a bit. Repeat until y'all accept a nice worm. Be sure to extrude your worm in a straight line, nosotros will bend the worm with our animations.
Creating Worm

Now we are set up to add a skeleton, or armature, to use in animative the object. First, allow's put the selection marking on the worm, by left-clicking in the scene. To place the marker correctly in 3-space, information technology is commonly easiest to left click, and then chance the view (using the number pads or by mousing around with the middle mouse button) and left click over again.
Cursor Placed

Make certain yous are in object mode (not edit mode), and select add Add->Armature->Single Os
Cursor Placed

Hmm... we don't seem to see annihilation. That'due south considering the bone is inside our model. In the outliner (upper right panel by default), select the armature. Then, in the property panel, select the object pane (piffling cube), coil down to the brandish grouping, and click X-Ray
X-Ray Mode

Now nosotros tin can run into the bone. Motility it around until it is in line with the model. Motion the pointy office of the bone until it is the correct size
Cursor Placed

Nosotros demand to employ this transformation. In Object Mode, with the bone selected, printing ctr-a, and apply rotation and scale. This will have no visible consequence in blender, just it will be required for export. You can bank check to brand sure that the transformation has been practical correctly in the properties pane -- rotation and scale should be nothing. (What is going on is this: Blender stores the local position of each vertex &etc in model space, and then likewise stores a transformation matrix for the entire model itself. When bender displays the model, information technology uses this transformation matrix. When information technology exports the model, it does non. And so, to get the blender visuals to match what Ogre can see, we apply this transformation matrix to the model itself.)
Cursor Placed

Select the "pointy" end of the os, press 'due east' (for extrude), move the mouse to extrude the bone, and press the left mouse button to when yous are washed.
Cursor Placed

Keep extruding basic until y'all take a nice skeleton inside your worm.
Cursor Placed

At this point, the armature is not paired to our object. They happen to be close to each other in space, only there is no human relationship between them. We need to parent the worm mesh to the armature. Before we do this, we need to make sure that all transformations have been applied to the mesh. In object mode, select the mesh and brand sure the rotation, location, and scale are cypher. If non, just press ctrl-a to utilise, every bit with the armature. While in object manner, select showtime the mesh (you can do this in the outliner) and so the armature (shift-click) and parent the object to the armature with automated weights.
Cursor Placed

When parenting an armature to a mesh, the organization needs to know which vertices in the mesh are controlled by which bone. A particular vertex can exist controlled past more than one bone (with different basic having a weighted influence). If nosotros were doing this the "right style", nosotros would create vertex groups, and take each bone control a different vertex grouping. (An example of how to do this using an older version of blender can be found here. Notation that the older version of blender uses an older animation exporter, and animations are handled in a slightly different mode) Allow'due south be lazy and take blender do it for us, using proximity to determine what os controls each vertex.

Select the armature, and then go to pose way. Rotate one of the bones to make sure the armature has been practical to the model
Cursor Placed

In the bottom plane, switch to the Dope Canvass editor
Cursor Placed

Then switch to the activeness editor
Cursor Placed

Click on the new button to get a new action
Cursor Placed

Then click on that aforementioned button (at present named "Action") to rename it something useful, like "Moving ridge"
Cursor Placed

Make sure the armature (and all bones!) are selected and we are in pose way. Then press 'i' to insert a keyframe (or select insert keyframe from the pose card
Cursor Placed

Move the timeline over a few frames -- say, 20 or so, and rotate some of the bones, and insert a new keyframe
Switching to Edit Mode

Go along until you lot have a dainty blitheness. When information technology looks skilful, so click on the F buttons by the action name (so that this animation will be saved when we articulate it), and and then click the X button to clear the animation (then nosotros can practice another i)
Switching to Edit Mode

Echo the process to create more than animations if you lot like. Then, switch to the NLA editor
Switching to Edit Mode

Add together a new track
Switching to Edit Mode

Then add an action strip
Switching to Edit Mode


Switching to Edit Mode

If you take additional animations, add a new track, motion the light-green animation timeline to the end of the previous animation and add a new animation to the timeline
Switching to Edit Mode

Scrub the timeline dorsum and forth across both deportment, and make sure that they both practice what yous want. And so, export everything, and copy the .mesh and .skeleton files to the appropriate locations in the content folder that Ogre can see (I adopt to place both the skeleton and the mesh in the Models folder, but anywhere Ogre tin see them is fine

Now, nosotros are ready to use the animations in Ogre. Create the Entity and scene nodes equally normal. Here, nosotros are creating two objects so we tin show off two animations at one time

        mInchwormEntity = mSceneManager->createEntity("worm.mesh");     mIncrwormNode = mSceneManager->getRootSceneNode()->createChildSceneNode();     mIncrwormNode->attachObject(mInchwormEntity);       mInchwormEntity2 = mSceneManager->createEntity("worm.mesh");     mIncrwormNode2 = mSceneManager->getRootSceneNode()->createChildSceneNode();     mIncrwormNode2->attachObject(mInchwormEntity2);      

Adjacent, become at the animation country for each entity, and enable the appropriate animations. You can have more than one animation active for each entity, with dissimilar weights per animation. We will be simple and just have a since blitheness per object, that controls it completely

        mInchwormEntity->getAnimationState("Inch")->setEnabled(true);     mInchwormEntity->getAnimationState("Inch")->setLoop(true);     mInchwormEntity->getAnimationState("Inch")->setWeight(i.0);      mInchwormEntity2->getAnimationState("Moving ridge")->setEnabled(truthful);     mInchwormEntity2->getAnimationState("Moving ridge")->setLoop(true);     mInchwormEntity2->getAnimationState("Moving ridge")->setWeight(1.0);      

Finally, in the think method for each object, call addTime to move the animation forwards

void  World::Remember(float time) {      // Do other stuff      Ogre::AnimationState *st2 = mInchwormEntity->getAnimationState("Inch");     st2->addTime(time);     Ogre::AnimationState * st = mInchwormEntity2->getAnimationState("Moving ridge");     st->addTime(fourth dimension); }      

In-Class Consignment

Now for the fun part! Creating a model, rigging it, animative it, exporting to ogre. Here's what yous should practise:

  1. Create a simple model in Blender. A worm is fine, or yous can do something more complicated if you like. Keep if fairly uncomplicated, I desire to apply today and Mon to finish this exercise completely
  2. Rig your model. Remember to utilise rotation / location / scale to both armature and model, so that the transforms are all 0s!
  3. In the Dope Sheet, swap to the Action Editor, Create a new action strip, proper name information technology, and create an animation with some keyframes. Move the timeline around to make sure that everything works
  4. Bandy to the NLA Editor, add a Rails, and then add the activeness you just created
  5. Echo the to a higher place, so that y'all take at to the lowest degree 2 different animations. Be sure that they don't overlap in the NLA, and scrub through the timeline so you can run into them move
  6. Consign to Ogre, and get your animated object to appear. Employ the following base project to get started:
      OgreTestbed.zip
    • Congratulations! You now know how to create a model, rig it, and animate it!

Source: https://www.cs.usfca.edu/~galles/cs420/lecture/AnimationInBlender/Animation1.html

Posted by: redmondthentent.blogspot.com

0 Response to "How To Animate A Mesh In Blender"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel