Blender: Trouble with Multi-Part Character Model! How to do it right?

Hello,

for my game I want to have an animated human character model for which I want to be able to swap clothes.

My plan was like this:
Create a super low poly character model with a proper skeleton that I can use to create all the animations. Load that into the engine as a base model. Then exchange the low poly placeholder parts with real clothing and equipment models. These real part models would be higher quality meshes built on the base skeleton but with just the geometry of the respective part.

So I created a basic blocky model in Blender. Every swappable part is a unique object in Blender and they are all children of a single armature. Every part has Location / Rotation / Scale applied as advised in http://wiki.jmonkeyengine.org/doku.php/jme3:external:blender. Also there is one central root bone. I didn’t model the whole thing from a single mesh object to be able to change parts by replacing meshes in the engine later. And I didn’t do anything with materials or textures yet.

This is how it looks in Blender:

But when I view the blend file in the SDK (3.1 alpha1) it looks like this mess:

When turning on wireframe it looks a bit better but still not correct on certain parts:

What’s strange is that every sub-node of the parts in the SceneExplorer has its own SkeletonControl with the full skeleton in it. That seems to be quite redundant.

Then I thought that I may have to create at least one default frame of animation, so I created a single frame action in Blender with a keyframe for every bone in it’s default position. But then I can’t even view the model anymore because I get an “Asset path is outside assetmanager root” error. I also tried to remove every geometry object in Blender to import just the armature in the SDK but I still get that asset path error and the model is empty in the viewer.

So am I missing something here? Any known pitfalls?
What is the recommended way to structure multi-part character models in Blender so that single parts can be swapped?

Any help is greatly appreciated!

P.S.:
Here is the blend file for inspection: https://www.dropbox.com/s/n16421z6qllg3h0/PlayerBase.zip?dl=0

It is usual that every Sub-Geometry has it’s own Control since they are treated as different objects in JME.
This is, so you can swap them out without breaking everything.
If you’d want them to be non rendundant, they should all be the same object (which also leads to better FPS), however they aren’t swappable anymore.

The Preview in SceneExplorer is independant from the Animation, so make sure you “apply transformations, rotations” etc.

Also try Blenders Object, Edit and Pose Mode to see if your model looks odd on one of them. (In Pose Mode, the Model will have the T-Pose, but it’s important what it has without animations, as this is what you’ll see in SceneExplorer).

Btw: What’s the “real” reason behind swapping out parts instead of simply using a high-poly model?
I mean, the key problem is the skinning (knowing what vertices to change depending on the bone), so you wont really have an advantage with that simply model, you could start directly with the high poly model.

Also: For the “LOW” Quality setting, you could simply use the Lod-Control to create a Lower Poly Version.

In Blender the model looks the same (T-Pose) in Object, Edit and Pose mode, so I think that’s fine.

The reason behind swapping out parts is that I want the user to be able to change clothing of the character. I use a low poly model only for animation purposes in Blender (gives a rough vision of shape and dimensions) and because obviously it is not possible to just import an armature without any geometry applied to it. It is low poly because it will never be seen ingame by the user, as each part should be replaced.
And I don’t have a high poly model right now, but I need to start animating to implement a proper animation system, which will be quite important for my game.
Another advantage of this skeleton / animation and geometry separation approach would be that I could increase the quality of the model parts over time as better assets become available.

Now I noticed that after applying transforms in Blender, all the bones look like they are snapped to the origin in the SDK viewer (of the file without any animation / action included). But if I turn on wireframe in the viewer the model looks fine! Well at least the wireframe representation of it…

But again, after creating a basic action with initial keyframes for every bone the SDK responds with the “Asset path is outside asset manager root” error, which doesn’t make sense to me in this context. I mean I just created an action, which has nothing to do with asset paths…

Could it have something to do with the fact that there is no material applied to any of the meshes in Blender?

Personally I have the “skin” for that and layer the clothings above.
So I think the best would be to have all layers of clothing in blender, so you can make the jeans move accordingly etc (Note: Different humans, different jeans movement actions), and then just remove the unused Geometries.

also:

This still works when you have them all in one file, just make sure they don’t share the same “Mesh”/Vertex Group.

This is definately something to look for then. It could be that the Wireframe is the BoundingBox.
You could also try to generate the Tangents (by Rightclicking on the geoms), but I guess this is not the issue.

Where is the Model placed? This error is really wierd, but maybe it’s trying to load something linked (different blender file, material) :confused:

Anyway FYI: Your Model has a Material applied. Only the default grey unshaded one, but that’s definately a Material.

Unfortunately I am not experienced enough for that thing, so you have to wait and especially: Try something out. There are thousands of ways in doing things in blender and it could be that one works.

Personally, I could get it to work, but I didn’t create the animations, I just imported them from a bvh file and it looked well.

Oh: In SceneComposer, go to the AnimationControl and try to play an animation. But well, that only works when we recognize the keyframes instead of an error :confused:

Could you explain the structure of your multi-part model a bit more since you seem to have it working?

Do you mean you have one blend file with the whole character and all swappable clothing parts in it as (Blender-) layers?
By skin do you mean like human skin in the sense of a naked base model or as in texture skin like swap texture images for different looks?

I would rather have the swappable parts in separate files because I don’t know how much there will be. Also it could result in a massive player model file with huge loading times for all the unecessary parts.

Generating the tangents didn’t help. I still wonder why I get this asset path error with an action included…

I am no Blender expert either, but man, there are really 1000 ways to do everything and most of the time I don’t even know what to look for… That really makes asset creation for JME confusing.
In the past I used to go a more old-school route with Wings 3D → FragMotion → OGRE Files but then I was missing out on some critical tools that Blender provides. And even for small changes I mostly needed to go down the whole process again…

I think I just have to experiment a bit more with some even simpler models.

But thanks for you hints so far!

Hi my friend
I played a few hours with your model :relaxed:
I joined the shapes then added a bow animation on it then inserted to JME.
You need to select all meshes (in object mode) (Note: do not select skeleton) and hit Ctr+J in blender to join them as a one mesh. then add an animation on it.


/////////////////////////////////////////////////////////////////////////////////////////////////////////
This time before joining i added material for each shape then joined them. in JME it kept material .(multi linked material)

///////////////////////////////////////////////////////////////////////////////////////////////


This time before joining I uv mapped each shape and added texture for each of the materials then joined them :

And JME kept uv map for each vertex group.

forgive me if I am talking so complicated. (Soon I will have tutorials about how to prepare your models in blender ready to be used in JME 3.1)
Please watch some tutorials about blender on YouTube.
And whenever had any question ask in forum. there is always some one to help.
Thanks

I do not think it is possible because you need to weight paint it again with bone.

Lets break down complex problem to simpler parts. Take all parts that are not meant to be deformed by multiple bones into separate skeleton-less models and attach them to your model in game using attachment points. Then you’ll be left with much more simple task of just changing your character model without dealing with his equipment in the same file.

Hi guys,
thanks for taking a look into this!

@Ali_RS
That looks good, but joining the shapes doesn’t seem to be an option for what I want to achieve. I think I have to keep the objects separate so that I can swap them out later in the engine.
I know it’s not the most efficient way to have a model structured, but I don’t see another way to keep meshes swappable and animated.

@prog
I’m not sure if I will keep the characters equipment in the file like that, but for now it’s easier for animation. If you keep these one-bone equipment parts in separate files you have to basically guess where they end up in the engine after attachment. Maybe I’ll keep them in the blend file but on a different layer so I can exclude them from export.

So, I have made a very simple test case and can report some progress!

I created a blend file that consists of a two bone armature with two simple objects (box and sphere). Both are attached to the armature and have their vertices weight painted to the bones. Then I created a simple test animation. The file loads into the engine without issues.

I then copied the blend file to make a new model with only one part. All geometry was removed (only the original armature left) and I added and skinned a new object (cone). I also removed all actions from the file to have only a blank armature with a single part geometry.

It loads fine and I can now swap out the test parts like this:

public Node createPlayer()
{
	Node player = new Node( "Player" );
    		
	// Base Model
	Node model = (Node)assetManager.loadModel( "Models/SimpleTest.blend" );
	player.attachChild( model );
    		
	// Material
	Material material = new Material( assetManager, "Common/MatDefs/Misc/ShowNormals.j3md" );
	player.setMaterial( material );
    		
	// Animation
	AnimControl anim = model.getChild( "Sphere" ).getControl( AnimControl.class );
	AnimChannel channel = anim.createChannel();
	channel.setAnim( "Action" );
    		
	// Swap Part
	Node part = (Node)assetManager.loadModel( "Models/SimpleTest_Part.blend" );
	Geometry partGeom = (Geometry)part.getChild( "Cone1" );
	Geometry origGeom = (Geometry)model.getChild( "Sphere1" );
	origGeom.setMesh( partGeom.getMesh() );
    		
	return player;
}

I’m so happy that this finally works, you only need to load the part and swap out the meshes! :grinning:

This means I could basically model any desired body part in arbitrary complexity and just skin it to the existing armature. It should then automatically adapt to the animated base model. And it still works when the files are converted to j3o.

You can get the very simple test case blend files here: Dropbox - File Deleted

Just need to figure out now what was wrong with my initial blocky test-model…

(Don’t know how the rules are on this forum regarding double posting, so I will just leave the following here as an edit)

Important Note:

I just found out what caused those misterious “Asset path is outside asset manager root” exceptions when trying to view or convert my original blend file!
I was getting headaches about what caused this, because I triple checked each and every object, UI tab and data element in Blender to make sure that I didn’t reference any external assets. Then I found this handy tool: File / External Data / Report Missing Files, which then prints the results to the console (there really is a function for everything in Blender…).
So it reported that I was still referencing a background image that I used as a modelling reference on some viewport! And since the image was somewhere outside of my JME-projects files the SDK reported that as an exception when loading the model! :astonished:
So make sure you remove those viewport reference images in the Backgroud Images tab of the properties panel before handling models to the engine. :point_up:

It would be really helpful if the SDK would report at least the file name of problematic assets when returning this exception… Can I file this feature request somewhere?

1 Like

I just discovered another important pitfall in the Blender-JME pipeline:

Make sure you do not have a Blender object and a bone of your armature have the exact same name!

This caused this critical error on my system (Blender 2.73, JME SDK 3.1 alpha 1) when trying to view or convert the blend file:

“Error opening MyModel.blend”

Again without reporting more details such error messages are not very helpful and gave me many headaches…
This and my previous remarks should probably be made more prominent to other users. Can I add them to the Blender related Wiki page?

2 Likes

I use this way to convert my blender models and save them as .j3o :

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.export.binary.BinaryExporter;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author IDEA
 */
public class ModelLoader extends SimpleApplication {
    Spatial world;
    File file;
    @Override
    public void simpleInitApp() {
        flyCam.setEnabled(true);
        flyCam.setMoveSpeed(10);
        
        //Load your blender file
        world = assetManager.loadModel("Scenes/World.blend");
      
        rootNode.attachChild(world);

        /** A white, directional light source */ 
        DirectionalLight sun = new DirectionalLight();
        sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());
        sun.setColor(ColorRGBA.White);
        rootNode.addLight(sun); 
        
        //Directory for saving j3o model 
        file = new File("D:/Java/jME_NB-PW-11-6-2015/The Night Watchman Test/assets/Models/World.j3o");
    
    }
       
    /* This is called when the user quits the app. */
  @Override
  public void stop() {
        BinaryExporter exporter = BinaryExporter.getInstance();
    try {
      exporter.save(world, file);
        System.out.println("Generated!!!!!!!!!!!!");
    } catch (IOException ex) {
      Logger.getLogger(Main.class.getName()).log(Level.SEVERE, "Error: Failed to save game!", ex);
       System.out.println("Not Generated!!!!!!!!!!!!");
   }
    super.stop(); // continue quitting the game
  }
    
    
    
    
    
    public static void main(String[] args) {
        ModelLoader app = new ModelLoader();
        app.start();
    }
}

In this way you can get more error details .Also I had some models that SDK converter could not import them but using this way I could import them.!!!

Edit :
Here is one example :
I had a model which had .psd texture in it and had no animation on it . when i tried to import it with SDK converter i get an error saying Importing animation will be add to scene later . :hushed:
But when i used this code based way I got this precise error : can not add PSD texture loader … (it was something like this) . so I converted .psd to .jpg texture then imported it and it worked perfectly.

2 Likes

Cool, thanks for the hint!

Not as easy as the right-click commands in the SDK but I guess it’s good for inspecting difficult cases :+1:

This seems like a sdk/blender importer bug. Make sure you submit an issue on GitHub.

Hey,
Sorry, I completely forgot about this topic.
Do you still have that “MyModel.blend” so I could look into it?
Since the SimpleTest Files seem to work without a Problem.

Edit: The AssetPath thing is fixed, however you can only have it if you build from source currently. Maybe when an alpha-3 comes out you can use those jar’s in the alpha-1 sdk.

No problem, I have this solved basically (as stated above) - at least for now, who knows…
The “MyModel” file doesn’t exist, I just typed it in as a placeholder for other users with similar issues.

Great that the AssetPath issue is fixed, but I will stay on alpha 1 for a little while until the dust has settled.
With fixed you mean that the exception isn’t thrown right? I guess it doesn’t do anything with such background images?

1 Like