Blender export to .obj

Following along with the tutorials I see that jme currently only supports .obj or .xml model files. I can not get blender to work properly with .xml exporters so I continued with exporting to .obj. What I am running into is either a error stating that the colormap is null, but I am not using any coded in texture map. If I try to code in a texture to the model by assigning the colormap to a .jpg texture it still gives me same colormap is null exception.



Now if I remove any textures from the model in blender and then export to .obj, I can get the program to run, but the blender model does not appear. I have tried importing the model from the import asset button but it still shows as blank. I have a .obj model that I downloaded from online. If I open this in blender and then export to .obj the new .obj will show as invisible once again, but works if not exported from blender. Would this be an error with blenders .obj exporter?

@danvath said:
Following along with the tutorials I see that jme currently only supports .obj or .xml model files.

There is also a direct Blender importer

Are you using Blender 2.63? because I had similar problems, try 2.62

Thank you for your quick response, but where do I find this importer?



I am trying 2.63 I will give 2.62 a go to help.

Tools > Plugins > Available Plugins > Blender Support

I looked around in there for awhile and see that my jme already has blender support installed and activated, but when I try a .blend file it always gives me an error about the file not being able to be used, and throws exception:



Unknown data type: uint64_t



that was still with blender 2.63 I am in the process of downloading 2.62 and will see what that does.



Update:



I got done downloading 2.62 and when I try to import a the newly saved file from 2.62 it gives same error.



I closed it and reopened to add a monkey. My thinking being that maybe the other file still had something strange in it from the 2.63 blender.

Even with using just 2.62 and adding a monkey when I try to import the file it says that it can not import the file and gives same exception.

Exception when I move the file to asset/model folder of project:



Jun 12, 2012 5:41:48 PM com.jme3.scene.plugins.blender.BlenderModelLoader load

SEVERE: Unknown data type: uint64_t

com.jme3.scene.plugins.blender.exceptions.BlenderFileException: Unknown data type: uint64_t

at com.jme3.scene.plugins.blender.file.Structure$DataType.getDataType(Structure.java:313)

at com.jme3.scene.plugins.blender.file.Field.fill(Field.java:93)

at com.jme3.scene.plugins.blender.file.Structure.fill(Structure.java:124)

at com.jme3.scene.plugins.blender.file.FileBlockHeader.getStructure(FileBlockHeader.java:113)

at com.jme3.scene.plugins.blender.BlenderLoader.setup(BlenderLoader.java:232)

at com.jme3.scene.plugins.blender.BlenderModelLoader.load(BlenderModelLoader.java:57)

at com.jme3.scene.plugins.blender.BlenderModelLoader.load(BlenderModelLoader.java:50)

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:243)

at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:376)

at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:386)

at jme3test.helloworld.hellojme3.simpleInitApp(hellojme3.java:51)

at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:230)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)

at java.lang.Thread.run(Thread.java:722)



code I am using pulled directly from tutorial with just some changes to models/textures:



package jme3test.helloworld;



import com.jme3.app.SimpleApplication;

import com.jme3.font.BitmapText;

import com.jme3.light.DirectionalLight;

import com.jme3.material.Material;

import com.jme3.math.Vector3f;

import com.jme3.scene.Geometry;

import com.jme3.scene.Spatial;

import com.jme3.scene.shape.Box;



/** Sample 3 - how to load an OBJ model, and OgreXML model,

  • a material/texture, or text. */

    public class hellojme3 extends SimpleApplication {



    public static void main(String[] args) {

    hellojme3 app = new hellojme3();

    app.start();

    }



    @Override

    public void simpleInitApp() {



    Spatial teapot = assetManager.loadModel(“Models/Teapot.obj”);

    Material mat_default = new Material(

    assetManager, “Common/MatDefs/Misc/ShowNormals.j3md”);

    teapot.setMaterial(mat_default);

    rootNode.attachChild(teapot);



    // Create a wall with a simple texture from test_data

    Box box = new Box(Vector3f.ZERO, 2.5f,2.5f,1.0f);

    Spatial wall = new Geometry(“Box”, box );

    Material mat_brick = new Material(

    assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

    mat_brick.setTexture(“ColorMap”,

    assetManager.loadTexture(“Textures/WhiteBrickWall.jpg”));

    wall.setMaterial(mat_brick);

    wall.setLocalTranslation(2.0f,-2.5f,0.0f);

    rootNode.attachChild(wall);



    // Display a line of text with a default font

    guiNode.detachAllChildren();

    guiFont = assetManager.loadFont(“Interface/Fonts/Default.fnt”);

    BitmapText helloText = new BitmapText(guiFont, false);

    helloText.setSize(guiFont.getCharSet().getRenderedSize());

    helloText.setText(“Hello World”);

    helloText.setLocalTranslation(300, helloText.getLineHeight(), 0);

    guiNode.attachChild(helloText);



    // Load a model from test_data (OgreXML + material + texture)

    Spatial ninja = assetManager.loadModel(“Models/monkey.blend”);

    ninja.scale(0.75f, 0.75f,0.75f );

    ninja.rotate(0.0f, -3.0f, 0.0f);

    ninja.setLocalTranslation(0.0f, -5.0f, -2.0f);

    rootNode.attachChild(ninja);

    // You must add a light to make the model visible

    DirectionalLight sun = new DirectionalLight();

    sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));

    rootNode.addLight(sun);



    }

    }

If I export it to .obj I can see a bounding box and outline in the scene composer, but nothing appears.



I added:



Material mat_stl = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

ninja.setMaterial(mat_stl);



just underneath the spatial ninja = line and now it shows up, but it is all white with no materials or textures applied to it, I can go through and add a texture onto it but it stretchs it and if I move to close half the texture gets culled. I am not sure if there are any other shadings because when I go to MatDefs nothing is there.

In the scene composer, if you click the light icon can you see your model?

I can but only faintly, it seems to be faded or culled randomly.



After looking at it some more it looks as if the whole model is there, but just black. If I move the camera around some of it will show up more, but some do not show up at all.

You are going to need to update to latest stable. The bug(s) you mentioned were fixed in that version.

I went to tools>plugins>update for all the installed plugins, but I can not load .blend files in directly now. It tells me that the scene is not created, and if I convert to .j3o and try again it gives same message in scenemanager.



Link to what the scene manager shows:



Imgur

Can you open the error message on the bottom right of the screen?

It says Unexpected Exception.



Node:class.com.jme3.gde.core.scenexplorer.nodes.JmeNode[null] gets null name!



If I click this blue link I get a popup that reads:



A java.lang.IllegalArgumentException exception has occurred.

However, the system should continue working without further problems.

Click Show Details for the stack trace.



if I do show details I get another popup that shows:



java.lang.IllegalArgumentException: Node:class com.jme3.gde.core.sceneexplorer.nodes.JmeNode[null] gets null name!

at org.openide.nodes.NodeOp.createPath(NodeOp.java:250)

at org.openide.explorer.ExplorerManager.equalNodes(ExplorerManager.java:206)

at org.openide.explorer.ExplorerManager.access$200(ExplorerManager.java:92)

at org.openide.explorer.ExplorerManager$1AtomicSetSelectedNodes.checkAndSet(ExplorerManager.java:232)

at org.openide.explorer.ExplorerManager$1AtomicSetSelectedNodes.run(ExplorerManager.java:290)

at org.openide.util.Mutex.readAccess(Mutex.java:365)

at org.openide.util.Mutex$1R.run(Mutex.java:1307)

at org.openide.nodes.Children$ProjectManagerDeadlockDetector.execute(Children.java:1907)

at org.openide.util.Mutex.doWrapperAccess(Mutex.java:1326)

at org.openide.util.Mutex.readAccess(Mutex.java:354)

at org.openide.explorer.ExplorerManager.setSelectedNodes(ExplorerManager.java:295)

[catch] at com.jme3.gde.core.sceneexplorer.SceneExplorerTopComponent.setSelectedNode(SceneExplorerTopComponent.java:260)

at com.jme3.gde.scenecomposer.SceneComposerTopComponent.selectSpatial(SceneComposerTopComponent.java:875)

at com.jme3.gde.scenecomposer.SceneComposerTopComponent.setSceneInfo(SceneComposerTopComponent.java:758)

at com.jme3.gde.scenecomposer.SceneComposerTopComponent.sceneOpened(SceneComposerTopComponent.java:904)

at com.jme3.gde.core.scene.SceneApplication.notifyOpen(SceneApplication.java:312)

at com.jme3.gde.core.scene.SceneApplication.access$1100(SceneApplication.java:83)

at com.jme3.gde.core.scene.SceneApplication$3.run(SceneApplication.java:383)

at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)

at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:701)

at java.awt.EventQueue.access$000(EventQueue.java:102)

at java.awt.EventQueue$3.run(EventQueue.java:662)

at java.awt.EventQueue$3.run(EventQueue.java:660)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:671)

at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:148)

at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)

at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)





This is after converting the .blend file to a .j3o file.



We can partially see it in the scene manager, but if I try to put the .j3o file directly into the code to use and run it nothing appears.

aha… those types of errors are Normen’s domain.

@Normen: can you take a look at this exception?

This is way after conversion, what error do you get when loading the j3o in code?

If I code in the .j3o and try to run it I get a exception of:



un 15, 2012 2:53:30 PM com.jme3.app.Application handleError

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.IllegalArgumentException: Expected a Boolean value!

at com.jme3.shader.Uniform.setValue(Uniform.java:266)

at com.jme3.material.Technique.updateUniformParam(Technique.java:147)

at com.jme3.material.MatParam.apply(MatParam.java:147)

at com.jme3.material.Material.render(Material.java:1037)

at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:657)

at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:301)

at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:353)

at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:893)

at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:849)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1125)

at com.jme3.renderer.RenderManager.render(RenderManager.java:1167)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:251)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:149)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:182)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:223)

at java.lang.Thread.run(Thread.java:722)



This is still with nightly build going, and now when I go to scene builder and try to view the model I get a pop up error message as well of:



Error in scene!

(java.lang.IllegalArgumentException:Expected a Boolean value!



I also still get the same error from the previous reply in the bottom right corner.



Update:



I converted a .xml file to .j3o as well and it is doing the same thing now when I try to open the .j3o into the scenecomposer. I can load the .xml through the code, but if converted to a .j3o it does not work properly anymore.

As said before, this issue was fixed in nightly. Update again.

The .j3o of the .xml file is working perfectly now. Unfortunaly the .obj that was exported from blender is still giving the error message in the bottom right with the same error message and looks the same as the previous image link.







the .j3o of the .obj image.