Kojack's Adventures In Blender

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Kojack's Adventures In Blender

Post by Kojack »

As part of a project I'm working on (which I'll talk about more later) I'm doing stuff in Blender. I know a few basics of Blender (really really basics), but I'm much more at home in Max or Maya.

Currently I'm doing an upgrade to the Ogre sinbad model by Omniter. It's a great model and makes a great mascot for Ogre, but there some aspects of the way it was modeled that make it a little harder to use than it could be. So I'm doing the following:
- Making it a bit friendlier in the NLA editor (naming the channels after the matching animation tracks, etc)
- Making the model face into the screen instead of out (most artists like the models to face them, but for Ogre it's better to face away, that way meshes face the direction of their scene node automatically).
- Moving the origin to between his feet. Sinbad is modeled with his origin in his chest. Again, this is common for artists from what I've seen, but makes placement in a game harder.
- Rescale the model to SI units (metres in this case).

Of course modifying an already rigged and animated model in this way is always tricky.

So far I've got the first 3 steps done. Sinbad is rotated and his origin is correct. It took a lot of experimenting (and google) to get it working with all animations correct after exporting to Ogre.
But scaling... argh.

As a test, I've been scaling by 0.1, making Sinbad 10% of his original size.

Scaling is easy if I just scale the entire thing in object mode. But after export the model is the same size (since the mesh and bone data wasn't scaled, just the node that contained it). That's just like scaling the SceneNode in Ogre.

The required technique is to scale the armature and mesh individually in edit mode. That works correctly for almost everything, except a few bones are doing odd things:
Image
This image shows the same frame (frame 1 of the dance animation). The top pic is the original. The bottom pic is after scaling by 0.1. (The camera was positioned by hand, so it looks a little different for a few bones that are really the same). When animated he also bounces up and down by a huge amount.
From what I can tell (after hours of experimenting) is that scaling an armature doesn't scale the relative translation of bones from the initial pose in keyframes. If I manually go into a bone in pose editor mode and scale the bone's translation by 0.1, it seems to be in the right place.
This is either a blender bug or I'm doing something wrong.

One way to fix this: use python to iterate through every animation track's keyframe and scale translations of every bone by 0.1 (or whatever scale factor I decide on for the final version). All bones with a translation that's not 0,0,0 are placed wrong. But I've never coded in Python and don't know the Blender API.
I did manage to get Python to tell me the translation value of a specific bone in the current frame in the current animation, but it's read only. I need to get into the keyframes and tracks, but I don't know how yet.

(Got some more plans for sinbad, then it's on to the ninja!)
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Kojack's Adventures In Blender

Post by Kojack »

I might have something.
I can change the y coordinate of the tongue bone in frame 1 of the Dance animation to the correct translation value using:
bpy.data.actions[0].fcurves[602].keyframe_points[0].co = (1, 0.02)

Time for some scripting... (in a language I don't know)
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Kojack's Adventures In Blender

Post by Kojack »

Hmm, if I had of waited another hour I wouldn't need this thread.
Here's the solution:

Code: Select all

import bpy
for a in bpy.data.actions:
	for f in a.fcurves:
		if f.data_path.find("location") > -1:
			for k in f.keyframe_points:
				v = k.co
				v[1] = v[1] * 0.1
				k.co = v
			f.update()
That looks for every keyframe of every action and scales all location channels by 0.1.
The animations now export correctly in ogre!

Well, they look correct so far in ogremeshy. I haven't tried reattaching the swords. Damn it, just realised I haven't done anything to the swords (scale, rotate or move), I wonder if they still work? Probably not.

Getting Sinbad modified is step 1 of the Ogre Asset Overhaul (OAO), an attempt to improve and unify all ogre sample assets for Ogre 2.0.
TheSHEEEP
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 972
Joined: Mon Jun 02, 2008 6:52 pm
Location: Berlin
x 65

Re: Kojack's Adventures In Blender

Post by TheSHEEEP »

That scale 0.1 thing should be a feature ;)
My site! - Have a look :)
Also on Twitter - extra fluffy
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Kojack's Adventures In Blender

Post by Kojack »

Yeah, it should have been done automatically. But I don't know enough about blender to know if it's my fault (something not ticked in the armature properties, etc) or Blender has a bug.

Now for the hard bit... how tall should Sinbad be? If he's too big compared to a human, that makes him hard to use in generic scenarios. But too short and he's not intimidating enough.
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: Kojack's Adventures In Blender

Post by spacegaier »

I don't think he needs to be that big. He is rather strongly build (big, board chest), so by making him roughly 2 meters he is physically intimidating enough IMHO. And after all: He is a nice guy anyway ;) .
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Kojack's Adventures In Blender

Post by Kojack »

Here's some quick tests.
The girl is a makehuman model that's 1.57m tall.
(red lines are 10cm, green lines are 50cm)

Sinbad at 2m tall:
Image

Sinbad at 1.8m tall:
Image

Maybe 1.9m would be good. The average us male height is 1.76.
amartin
Halfling
Posts: 87
Joined: Wed Aug 14, 2013 6:55 am
Location: Norway
x 13

Re: Kojack's Adventures In Blender

Post by amartin »

I'd like the 2m personally sure it's not much of a difference from 1.9 but it's a round number and as a test asset it just makes it easier to scale and use to eyeball dimensions. It shouldn't be hard to scale down to 1.9 for the samples if required. If it is too hard then we need to look into why.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Kojack's Adventures In Blender

Post by Kojack »

amartin wrote:It shouldn't be hard to scale down to 1.9 for the samples if required. If it is too hard then we need to look into why.
In ogre it's just a scenenode scale of 0.95 to make him 1.9 instead of 2.0. I'd just like a good default.

2.0 is probably good. It turns out my 0.1 scale (just a convenient guess) made sinbad exactly 2.0m tall (6.5 feet)

Girl at 1.57m, Sinbad at 2.0m and ninja at roughly 1.72m (average height of japanese males).
Image
amartin
Halfling
Posts: 87
Joined: Wed Aug 14, 2013 6:55 am
Location: Norway
x 13

Re: Kojack's Adventures In Blender

Post by amartin »

The only thing I wasn't sure of was if the scaling affected things like animations I haven't done much with animations. I'd stick to roundish numbers for the assets assuming they are there for both samples and as temporary assets for people to test things with. Different applications will have different ideas of what 1 Ogre unit should be so things that are easier to multiply are probably better 1.75 rather than 1.72.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Kojack's Adventures In Blender

Post by Kojack »

amartin wrote:The only thing I wasn't sure of was if the scaling affected things like animations I haven't done much with animations.
Scaling in ogre (scenenode scale) is fine, animations will work identically.
Scaling in blender is where problems can occur, you need to scale the mesh and the armature separately, but around the same pivot point. For Sinbad, it's a three step process:
- scale mesh
- scale armature
- run python script to scale bone translations
All three must be identical scale factors, so no hand adjustment, you need to type in the scale.

Otherwise:
[youtube]X_RBubYdO6E[/youtube]

:)
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Kojack's Adventures In Blender

Post by Kojack »

More adventures in Blender.

I've been working on the ninja.
Psionic's ninja model is fairly iconic to Ogre applications. The original archive comes with the mesh in Blitz Basic, CharacterFX and Milkshape3D formats.
Part of my Ogre Asset Overhaul project is to make all Ogre meshes available in Blender. So I've been getting the Ninja ported.

Blender has a milkshape importer. I used it to load the ninja.
There's several things that need to be done to make the ninja suitable:
- Scale
- Materials
- Make animations blender/ogre compatible
I'm focusing on the third one first.

Milkshape doesn't have separate named animations. The ninja has one 300 frame animation sequence that contains every animation, and a text file that lists which frame numbers match which animations. Ogre's blender exporter doesn't support that style, I need to have separate tracks in the Non Linear Animation editor. But the entire NLA and dopesheet editors are rather confusing to me. I've worked it mostly out though.

I started trying to cut the action sequences on the text file listed frame numbers to split it up (such as walk animation is frames 1-14). But the keyframes in the ninja didn't match up with blender's frames. I could only cut on a blender frame. Cutting at blender frame 14 actually included a bit of frame 15 from milkshape, so the animations bled into each other a little.
I quit for a couple of weeks.

Back again, and I'm doing things differently and found a fix. Turns out blender was defaulting to 24fps for animation, while milkshape is 25fps. I set Blender to 25fps in it's render settings and after an import the keyframes are correct. Of course Ogre doesn't care about that, it has no frame rate as such, it's animation is purely time based keyframes.
I then used the Dopesheet's action editor to duplicate the huge animation track then manually delete keyframes outside of the required range and shift the frames back to 1 (the [ and ] keys were very handy, they select everything before or after (respectively) the current frame).
With all ninja animations available as actions, I then added them to the NLA in tracks (I'm probably mixing up all the terms here, there's actions and tracks and sequences and stuff). Yay, it exports to Ogre!

Or so I thought. Turns out some animations are a little broken now. Blender's keyframe interpolation is a little different to milkshape's. During some animation sequences the orientation freaks out, such as the ninja flipping upside down during a sword swing.
There's an option (somewhere, apparently) to change between euler and quaternion animation on a milkshape import. Maybe that will fix it. But I'll need to do the entire sequence splitting thing above again (looks like it needs a fresh import). Argh.
Or I can hand edit the animations that are broken, but I suck at animations.

Hmm, I wonder what will go wrong when I move on to the Robot mesh? :)
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: Kojack's Adventures In Blender

Post by spacegaier »

Great effort! Really appreciate the work you put in for the asset overhaul! Much needed...and always an interesting read what you come aross while doing so :D .
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Kojack's Adventures In Blender

Post by Kojack »

I ended up fixing the problem by hand. Two animations were broken: Spin and Backflip. Both times it broke when a joint crossed 180 degrees. I just found the inaccurate bone, duplicated its rotation keyframes and placed them in the offending time slot, then manually corrected. The Spin had a bunch of glitches after 180, so I had to hand edit 7 or so frames (luckily just 45 degree rotations). But it does mean the ninja may not animate identically to before (but close enough that you shouldn't notice).

Materials appear correct (I'd like all 5 ninja colours to be automatically in the one material file, but I don't know how to do that. They each get a file instead. Then again, Ogre only shipped with one of the ninja's 5 materials).

Now there's two things left. First up is scale. I need it in real world SI units (metres). Second, the bone names aren't that great. The ninja has 21 bones, named as Joint1 to Joint25. Yes, 25, there's 4 numbered bones missing. I'd prefer a better naming standard. Not sure what to use yet, is there a standard around? It would be really cool if all our meshes used the same names where possible.

Image

Something we really need is some new high quality but free (including commercial use) general purpose models. Sinbad is a bit solid and cartoony, and the ninja and robot are low detail (cool in the past, but not impressive anymore). Jaiqua is pretty useless (half her animations have movement baked in and the license is iffy, she was a sample with some commercial app).
I keep checking places like BlendSwap for free models that not only look good but would be useful in a wide range of Ogre samples. I'd still like to get Sintel working, but last time I exported her to Ogre she ended up looking like a drug addict. She really needed a full render to look good (especially the hair).
misiak1989
Gnoblar
Posts: 9
Joined: Mon Nov 25, 2013 9:01 pm
x 1

Re: Kojack's Adventures In Blender

Post by misiak1989 »

I don't think there is a commonly used standard joints/bones naming convention... I've read at least 2 online during past 2-3 years. As for new models - have you heard about MakeHuman? Their website is http://www.makehuman.org/ , it is an open source human 3d model generator - maybe generate something using it and start from there? It might require more work (when I last tried it the models did not support animation in any easy way), but models would be HD and baked specially for Ogre ;)
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Kojack's Adventures In Blender

Post by Kojack »

Yep, makehuman is pretty cool. The girl in the height comparison pics above is from makehuman.
The rig looks suitable and it exports to ogre pretty easily. The main issue is that it has no animations.
Once my PrioVR arrives (probably next year, they've been delayed a fair bit) I could do motion capture to get a good range of animations.
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: Kojack's Adventures In Blender

Post by spacegaier »

Is there an easy way in Blender to transfer animations between (unequal) rigs. Could be fun to few a human girl moving like Sinbad does :D .
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
amartin
Halfling
Posts: 87
Joined: Wed Aug 14, 2013 6:55 am
Location: Norway
x 13

Re: Kojack's Adventures In Blender

Post by amartin »

Make human blender integration also includes make walk which seems to be designed to take mocap data and apply it to the rigs from make human. I'm not sure how well that works I'm only just starting to play around with the rigging and modeling side of things.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Kojack's Adventures In Blender

Post by Kojack »

There's a motion capture plugin that comes with blender and it includes retargetting of animations. I don't know how to use it yet though.
http://wiki.blender.org/index.php/User: ... SOC/Manual
jonim8or
Goblin
Posts: 287
Joined: Mon Dec 08, 2008 4:49 pm
x 10

Re: Kojack's Adventures In Blender

Post by jonim8or »

I'd actually propose the opposite approach: put a new 3d model to the Sinbad skeleton and animations, and then make small fixes when needed.
And of course add a different dance animation, because no-one dances the same.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5292
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Kojack's Adventures In Blender

Post by dark_sylinc »

The Sinbad and robot model are actually very useful for debugging purposes. I'm in favour of keeping them; but having new models for showcasing purposes.
jonim8or
Goblin
Posts: 287
Joined: Mon Dec 08, 2008 4:49 pm
x 10

Re: Kojack's Adventures In Blender

Post by jonim8or »

Kojack, could you post your "improved" Sinbad somewhere when you're done with it? I'd like to try how much work it is to put another character to that skeleton.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Kojack's Adventures In Blender

Post by Kojack »

Yep, just need to fix the sword (it's not scaled) and do some tests to make sure nothing is broken.
euden
Gnoblar
Posts: 4
Joined: Mon Jan 18, 2016 7:34 pm

Re: Kojack's Adventures In Blender

Post by euden »

Did you ever finish this? I'd very much like to use the Sindbad model in a project I'm working on :)

Thanks!

Euden
Post Reply