Weird model rotation issue

First off, I tried the solution found here.

It did not work.

I am pretty sure the problem has to do with blender and was hoping someone here had the same issue.

Exported as ORGE > Converted to .j3o > Imported with code.

[java]snowMan = assetManager.loadModel(“Models/Snowman/snowman.j3o”);
Material matVC = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
matVC.setBoolean(“VertexColor”, true);

I also tried to export as .obj… and had same basic problem, but my model looked even worse because of vertex coloring. HAHA!

Let me just show you what it looks like since pictures say a 1000 words.

In blender, before exporting, try object—>apply—>visual transform


Same issue. Did not resolve problem.

How does it look when you open the model in the SDK? Maybe you accidentally modify one of the constants in jME (Vector3f.UNIT_X etc.)

Fine… I think.

I don’t have anything in code that changes it… I just looked it over. Not like I have a lot of code, only 145 lines. Hmm.

Could I have changed this outside of the code?

Edit: All of the code that affects snowman is in first post…

There must be something in your code that does that. No Vector3f.UNIT_Y.multLocal(x) or similar somewhere? Maybe you pass some vector like the rootNode rotation somewhere and change it elsewhere?

[java]package mygame;

import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.Spatial;
import com.jme3.scene.debug.Arrow;
import com.jme3.scene.debug.Grid;
import com.jme3.system.AppSettings;

public class Main extends SimpleApplication {

private boolean firstPass = true;
private StopWatch watch = new StopWatch();
Spatial snowMan;

public static void main(String[] args) {
    AppSettings settings = new AppSettings(true);
    settings.setTitle("jMonkeyTesting - By Glen Murdock");
    settings.setResolution(800, 600);
    settings.setSamples(4); // Anti Ailasing
    Main app = new Main();

public void simpleInitApp() {
    cam.setLocation(new Vector3f(0, 0, 300));


    snowMan = assetManager.loadModel("Textures/Snowman/Sphere.007.mesh.xml");
    Material matVC = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    matVC.setBoolean("VertexColor", true);

    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-5, -5, -5));

    DirectionalLight sun2 = new DirectionalLight();
    sun.setDirection(new Vector3f(5, 5, 5));


    this.attachGrid(Vector3f.ZERO, 100, ColorRGBA.Blue);
    this.attachCoordinateAxes(Vector3f.ZERO, 1000);
    cam.lookAt(this.snowMan.getWorldTranslation(), Vector3f.UNIT_Y);

public void simpleUpdate(float tpf) {
    if (firstPass) {
        firstPass = false;
    if(watch.isRunning()) {
        if(watch.getElapsedTimeSecs() > 2) {
            String prepared = "Cam Pos: " + + "\n" +
                    "Model: " + this.snowMan.getWorldTranslation() + " Rotation: " + this.snowMan.getLocalRotation().toString() + "\n";
    } else {

public void simpleRender(RenderManager rm) {
    //TODO: add render code

 * For editing initApp objects
private void initAppSecondary() {
    inputManager.deleteMapping(SimpleApplication.INPUT_MAPPING_CAMERA_POS); // Key_C

// Debugging //
private void attachCoordinateAxes(Vector3f pos, float scale) {
    Arrow arrow = new Arrow(Vector3f.UNIT_X);
    arrow.setLineWidth(5); // make arrow thicker
    putShape(arrow, scale, ColorRGBA.Red).setLocalTranslation(pos);

    arrow = new Arrow(Vector3f.UNIT_Y);
    arrow.setLineWidth(5); // make arrow thicker
    putShape(arrow, scale, ColorRGBA.Green).setLocalTranslation(pos);

    arrow = new Arrow(Vector3f.UNIT_Z);
    arrow.setLineWidth(5); // make arrow thicker
    putShape(arrow, scale, ColorRGBA.Blue).setLocalTranslation(pos);

private void attachGrid(Vector3f pos, int size, ColorRGBA color) {
    Geometry g = new Geometry("wireframe grid", new Grid(size, size, 5.0f));
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", color);

private Geometry putShape(Mesh shape, float scale, ColorRGBA color) {
    Geometry g = new Geometry("coordinate axis", shape);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", color);
    return g;


The vectors you pass to the Arrow are maybe changed internally, use a clone() or make new ones (unit vectors are not exactly complicated).

Are you talking about lines 94, 98, and 102 or are you talking about 96, 100, and 104?

The ones with the constructor arguments. But looking at the engine code those don’t really get changed either. Can you just print the constants out each frame? Also the locations and rotations of the debug objects you have, maybe those are skewed.

Cam Pos: (-350.11038, 7.2069044, -2.2415426) Cam Rot: (0.007299728, 0.70480233, -0.0072531416, 0.7093291)
Model: (0.0, 0.0, 0.0) Rotation: (0.0, 0.0, 0.0, 1.0)
RootNode Location: (0.0, 0.0, 0.0) RootNode Rotation: (0.0, 0.0, 0.0, 1.0)

Is that enough? If not let me know.

Print the values of Vector3f.UNIT_X etc. too to see if they change at some point

X: (1.0, 0.0, 0.0)
Y: (0.0, 1.0, 0.0)
Z: (0.0, 0.0, 1.0)

Stays the same.

I also took the arrow meshes and did location and rotation. They don’t have any.

Shape Loc: Grid: (-247.5, 0.0, -247.5) - (0.0, 0.0, 0.0, 1.0)
Shape Loc: Arrow: (0.0, 0.0, 0.0) - (0.0, 0.0, 0.0, 1.0)
Shape Loc: Arrow: (0.0, 0.0, 0.0) - (0.0, 0.0, 0.0, 1.0)
Shape Loc: Arrow: (0.0, 0.0, 0.0) - (0.0, 0.0, 0.0, 1.0)

** Translation and then rotation **

When you enable the grid in the SDK viewer it also looks straight?

It does to me. Here is a picture. I am in such suspense to figure out what the issue is here. Must be mind blowing!

Weird… And if you convert it to j3o and load that instead of the mesh.xml? (as actually intended)

Yes I did.

Ok, GOT SOMETHING! :slight_smile:

I converted a .obj file to .j3o… it worked as far as rotation goes… scale was very off and the vertex coloring sucked.

ORGE: Vertex coloring works and scale works. Rotation issue.

OBJ: Rotation is fine. Vertex coloring and scale suck.

Here is an image.

And if you just convert the blend file directly?

@normen said: And if you just convert the blend file directly?

Wouldn’t let me convert .blend. Keeps having errors.

I converted a .obj file that was exported from blender. However, I was previously having the same rotation issue with it.

Weird because the only change I made to it was opening it up in the SDK.

Isn’t ORGE preferred because of animation…ect?

If you do animations etc. as described in the manual and use the version of blender that ships with the SDK then it should import the animations etc. fine. If you use extended blender functions that don’t translate directly to live rendering the output varies.