Problem with OgreXML/Blender/jMP

I’d like to create models within Blender and load the into a jME3 projects. I’ve read the tutorials about, but I can’t solve this simple problem:

When I load models they don’t appear in the SceneViewer Window and they aren’t affected by textures in my apps.

I post below the “recipe” I’ve followed.



Blender:

Import .3ds (No Image, No Fix)

Editing F9: Rename OB, Rename ME, CenterNew, Change material 1 base color, Set Smooth

Texture F6: Add new Texture, Rename texture TE

Shading F5: Rename Material MA, Change Col/Spe/Mir, Map to → Change the texture color

[eventually F12 to render the image, it’s ok]

Export → Ogre Meshes

Selected: “Datablock”

Export Materials: Datablock.Material

on Rendering Materials

on Copy Textures

on Fix Up Axis to Y

Path: …/assets/Models/Model/

Export → Exporting Mesh, Exporting Materials, Done



JMP:

Convert .mesh.xml to .j3o and In the source:



Spatial model = assetManager.loadModel(“Models/Model/Datablock.j3o”);

rootNode.attachChild(model);





Output shows:

30-nov-2010 16.14.05 com.jme3.material.MaterialDef

INFO: Loaded material definition: Phong Lighting

30-nov-2010 16.14.05 com.jme3.scene.Node attachChild

INFO: Child (Datablock-ogremesh) attached to this node (Root Node)

30-nov-2010 16.14.06 com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation

INFO: Uniform m_UseMaterialColors is not declared in shader.

30-nov-2010 16.14.06 com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation

INFO: Uniform m_VertexColor is not declared in shader.



What I’m doing wrong?



Thx



r.

There must be some issue with your blender file, could you post it?

Sure, thanks for the interest:

http://dl.dropbox.com/u/2354863/Model.blend

Ok the normals are bad



In blender select your object, go to edit mode, hit ctrl+N, and click on “Recalculate normals outside”.

go to object mode an export again.

Rename the .material file to ModelME.material

And, the most important thing : turn on the light in JMP :stuck_out_tongue: (there is a tiny light bulb icon at the top left corner of the scene viewer window)



The object is showing fine in JMP for me now.

1 Like

Ok, thank you! Recalculate normals works:

  1. The geometry model is loaded well in the app,
  2. but no texture is shown.
  3. In the SceneViewer I still can’t see my object [even the bulb is on]. Not a big deal anyway.

    Maybe I’ve done some mistakes with the material…



    As I see that you are pro with blender, I’ll ask you another question about the integration with jME:

    I want to make a simple FPS game where the enemys are composed by these model I want to load like before.

    So I’m following the “http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro” tutorial, but I immagine that in it there is much more than I have to know about 3D game[maybe not all of rendering, lighting, particle is so fundamental for the game or am I wrong?]. So I’m asking you, and other, if you have any idea about which arguments/topic must to be done before creaet a game and which are secondary…



    Thanks again for the normals!



    r.

Noob to pro are good tutorials. I recommend http://blendercookie.com for great video tutorials about blender.

For 3D knowledge, you’ll have to read a lot, Google knows everything and he’s eager to teach it to you :stuck_out_tongue:

But above all, I recommend to TRY. But I think you’re already on that step :wink:

One more advice, would be to start with a little project with little ambition, and finish it, before starting another project.

If you want to make a fps, first implements basics of your game : first person movements on a map, shooting on enemies…

Once you have a working basis, iterate over it to add features.

Ok, thank you! I’ve already developed a simple fps movements and shooting to objects all from jme’s tutorials.

Hence my ghost player can shot little green balls and when they collide with other fixed sphere[targets], an explosion will run on collision point and the latters balls disappear.

I’ve also created a shape of my player [a lego ragdoll with armature and bones].

Now I’m wondering if I had to create animations with this model whitin blender and call them from the app,or if I can simply load the model inside my jME app and try to move his components [neck, legs and so on] directly from there. Or both?

Another question for collision detection: When I load the model, is there a manner to tell the program where are really his components [reading them from XML] or it will be better to create several collisionshape and associate them with the model? [If I shot near the model but not exactly over him, I want the program doesn’t detect a collision and after kill the enemy]



r.

For the animation both ways should work, but creating an animation with Blender and then importing it with the model will be a lot easier.



For collision shape loading, there is no support, you’ll have to create the shapes in the code. For your purpose you’ll need to create a collision shape for each bone.

For collision shape loading, there is no support, you’ll have to create the shapes in the code. For your purpose you’ll need to create a collision shape for each bone.


Ok, I got my blender animation. Now I'll try to load and run it into the app. How can I hook the animation' bones created whitin blender with collision shapes created into the jme app? I mean, when it appears that shapes are moving because of the animation's run, also the collision's shape will moving with them?

For characters the collision shape is mostly a capsule so it doesnt change with the animation and doesnt need to. A character thats fully physics-simulated is way too much overhead. They only do that in boxing games maybe where you have only two characters on screen. If you need accurate info then you can simply shoot a ray at the geometry where needed.

If you need accurate info then you can simply shoot a ray at the geometry where needed.

I resume. Tell me if I'm wrong:
1. All the characters in my game can be developed as models in blender [player and enemys].
2. Player would be a capsulecollisionshape and enemys even [maybe for the enemys would be simpler with box or sphere cs].
3. When the enemys run I want to see their legs move, so I have to hook their movements [ physicsnode.setLocalTranslation(toPoint) ] with a concurrent animation of the legs [channel.setAnim("something").
4. When the first person player runs/jumps I want that the others [other humans playing from other clients] can see my ragdoll moving his legs. Hence, I move my player[with my camera] using player.setLocalTranslation and I have to set a concurrent animation on my legs [even if I can't see them because I'm looking forward] using playerchannel.setAnim("movelegs"].

Or not?

Another question: to make the camera view going up and down doing during my movements, can I hook some point of my ragdoll in blender with the camera on the game, or would be better only change camera's position in the normal movement's loop in the game without consider the real eyes position?

Thanks a lot! I want to write down a little tutorial when I'll be sure of my progress...

r.

Basically yes except you dont move a physicsnode with setlocaltrans (maybe kinematic nodes), thats the equivalent to beaming in the physics world and is sure to produce funny results. The physicsnodes are nodes and are moved by the physics, the models are child geometries and thus move accordingly.

you dont move a physicsnode with setlocaltrans

Here some lines taken from my source:

I move my player with:
[java]
// Initialize:
player = new PhysicsCharacterNode
player.setLocalTranslation(USERPOS); // Start position out of simpleUpdate

// In the simpleUpdate:
player.setWalkDirection(walkDirection); // Move during
[/java]

and for the bullets:
[java]
PhysicsNode bulletNode = new PhysicsNode(bulletg, bulletCollisionShape, 1);
bulletNode.setCcdMotionThreshold(0.01f);
bulletNode.setLocalTranslation(player.getLocalTranslation().add(camDir.mult(20f))); // To avoid collision with the player's collision shape
bulletNode.setLinearVelocity(cam.getDirection().mult(100));
[/java]

Are these lines correct?

No, just give the bullet a velocity and it will fly.

No, just give the bullet a velocity and it will fly.

So have I to delete "bulletNode.setLocalTranslation(player.getLocalTranslation().add(camDir.mult(20f)));" ?
Isn't necessary an origin from where bullets start to fly?

Another question: to make the camera view going up and down doing during my movements, can I hook some point of my ragdoll in blender with the camera on the game, or would be better only change camera’s position in the normal movement’s loop in the game without consider the real eyes position?

Thats what a physics engine is for, move the objects according to physics, yes. You can just lookAt() each frame to keep the cam updated.

I build a scenario with blender, with all the things in their owm position.

I can export it into jme and it works [except some issues with materials].

So all the object in the scene are in the right place due to the scene.j3o file, which is in effect a simple “Node”.

There is a manner to make these object “PhysicsNode”, so I couldn’t pass trough the wall, boxes, etc ?



thanks!



r.

Try the “Create Physics Collision Shape” button in the SceneComposer of jMP. It basically creates a PhysicsNode with a MeshCollisionShape based on the selected nodes geometries and attaches the model to it.

You and nehon are very kind to answer all the time! Thank you!

“Create Physics Collision Shape”

I'll try and tell you if it works!

But now another question: This is frame of my model with his skeleton associated with the mesh for animation:
blender

But when I load it into jme's app, the armature [in green due to debugger] seems to be shrank andit has lose his legs with the naturally consequence of a bad animation during movements:
JME

What did I mess up?

r.

apply all scaling / rotating to the model in blender before exporting, theres other posts on this and the pdf in the wiki on blender exporting for animations is surely helpful as well.