Jump to content

Blender export error


jSnake04
 Share

Recommended Posts

I'm getting an error when trying to export from blender. It exported fine until I added a UV mapped texture material to the model.

 

Here's the log file:

 

    Exporter version: 4.6.1, Blender version: 2.77 (sub 0)
========= Conversion from Blender to Babylon.js =========
    Scene settings used:
        selected layers only:  false
        flat shading entire scene:  false
        inline textures:  false
        texture directory:  C:\data\web\html5game\models\soldier\
    Python World class constructor completed
    processing begun of skeleton:  ArmLow, id:  0
        processing begun of bone:  Hip, index:  0
        processing begun of bone:  Back, index:  1
        processing begun of bone:  Shoulder.Left, index:  2
        processing begun of bone:  Upperarm.Left, index:  3
        processing begun of bone:  Forearm.Left, index:  4
        processing begun of bone:  Hand.Left, index:  5
        processing begun of bone:  Head, index:  6
        processing begun of bone:  Shoulder.Right, index:  7
        processing begun of bone:  Upperarm.Right, index:  8
        processing begun of bone:  Forearm.Right, index:  9
        processing begun of bone:  Hand.Right, index:  10
        processing begun of bone:  Thigh.Left, index:  11
        processing begun of bone:  Shin.Left, index:  12
        processing begun of bone:  Foot.Left, index:  13
        processing begun of bone:  Thigh.Right, index:  14
        processing begun of bone:  Shin.Right, index:  15
        processing begun of bone:  Foot.Right, index:  16
    processing begun of mesh:  HumanLow
========= An error was encountered =========
  File "C:\Program Files\Blender Foundation\Blender\2.77\scripts\addons\io_export_babylon.py", line 330, in execute
    mesh = Mesh(object, scene, nextStartFace, forcedParent, nameID, self)
  File "C:\Program Files\Blender Foundation\Blender\2.77\scripts\addons\io_export_babylon.py", line 780, in __init__
    recipe = BakingRecipe(object)
  File "C:\Program Files\Blender Foundation\Blender\2.77\scripts\addons\io_export_babylon.py", line 1872, in __init__
    self.backFaceCulling &= material.game_settings.use_backface_culling
ERROR:  'NoneType' object has no attribute 'game_settings'
========= end of processing =========
elapsed time:  0 min, 0.01 secs

 

I tried commenting out the "self.backFaceCulling" line in the python addon script but it appears that 'material_slot.material' is a null value and it just threw the same error on the next if statement.

for material_slot in mesh.material_slots:
            # a material slot is not a reference to an actual material; need to look up
            material = material_slot.material

            self.backFaceCulling &= material.game_settings.use_backface_culling

            # testing for Cycles renderer has to be different
            if material.use_nodes == True:
                self.needsBaking = True
                self.cyclesRender = True
                self.nodeTrees.append(material.node_tree)

 

I am using blender render. I attached the blend file. Not sure what else to try.

soldier_armature_2.blend

Link to comment
Share on other sites

Seems I got it to work, not sure if it is the best solution, but I made a few changes to the exporter addon script to skip the null materials. I have no idea why the material object is null though.

I figured out that there were two materials attempting to be exported. I only added one that I know of.

One of the materials was correct and the other was the null one causing problems.

starting at line #793:

for slot in object.material_slots:

    #------ my change----------
    if slot.material is None:
        continue
    #--------------------------
    
    # None will be returned when either the first encounter or must be unique due to baked textures
    material = exporter.getMaterial(slot.name)
    if (material != None):
        Main.log('registered as also a user of material:  ' + slot.name, 2)
    else:
        material = StdMaterial(slot, exporter, object)
        exporter.materials.append(material)

and at line #1872:

for material_slot in mesh.material_slots:
    # a material slot is not a reference to an actual material; need to look up
    material = material_slot.material

    #------------ my change -----------
    if material is None:
        continue
    #----------------------------------

    self.backFaceCulling &= material.game_settings.use_backface_culling

I attached the modified script. Let me know if you guys think I should make a pull request on github or something. Seems to work, but i'm not sure if there are any unintended consequences.

I probably should have taken a look at the 5.0 version of the exporter. Not sure if that would play nice with my babylon js version though.

io_export_babylon.py

Link to comment
Share on other sites

I have no intension of changing 4.6.1, myself.  You can have 4.6.1 & 5.0 of the exporter installed at the same time, since 5.0 media is a zip file & 4.6 is a py file. 

I do not know the implied min BJS version of either exporter, but if the exporter writes fairly new fields (e.g. animationRanges) and your version of BJS does not have, they should just be ignored.

FYI, how old is this .blend?  Maybe saveAs it.  Please post a 5.0 logfile should it throw error.

Link to comment
Share on other sites

Didn't realize you could have the exporter versions at the same time like that. I will give 5.0 a shot here in a bit. 

I'm pretty new to blender, babylon, and python. lol. I'm willing to dig in and get my hands dirty though.

I'm using babylon 2.4 at the moment.

Are there any big differences between 5.0 and 4.6.1? or circumstances where 4.6.1 should be used instead of 5.0?

the blend file probably started as an older version then I modified it and savedAs it several times as I made progress with the model--creating a bunch of backups being so new to blender.

Link to comment
Share on other sites

Looks like it gives the same error with 5.0.5

 

Exporter version: 5.0.5, Blender version: 2.77 (sub 0)
========= Conversion from Blender to Babylon.js =========
    Scene settings used:
        selected layers only:  false
        flat shading entire scene:  false
        inline textures:  false
        texture directory:  C:\data\web\html5game\models\soldier\export\
    Python World class constructor completed
    processing begun of skeleton:  ArmLow, id:  0
        processing begun of bone:  Hip, index:  0
        processing begun of bone:  Back, index:  1
        processing begun of bone:  Shoulder.Left, index:  2
        processing begun of bone:  Upperarm.Left, index:  3
        processing begun of bone:  Forearm.Left, index:  4
        processing begun of bone:  Hand.Left, index:  5
        processing begun of bone:  Head, index:  6
        processing begun of bone:  Shoulder.Right, index:  7
        processing begun of bone:  Upperarm.Right, index:  8
        processing begun of bone:  Forearm.Right, index:  9
        processing begun of bone:  Hand.Right, index:  10
        processing begun of bone:  Thigh.Left, index:  11
        processing begun of bone:  Shin.Left, index:  12
        processing begun of bone:  Foot.Left, index:  13
        processing begun of bone:  Thigh.Right, index:  14
        processing begun of bone:  Shin.Right, index:  15
        processing begun of bone:  Foot.Right, index:  16
    processing begun of mesh:  HumanLow
========= An error was encountered =========
  File "C:\Users\***[removed]***\AppData\Roaming\Blender Foundation\Blender\2.77\scripts\addons\babylon-js\json_exporter.py", line 99, in execute
    mesh = Mesh(object, scene, nextStartFace, forcedParent, nameID, self)
  File "C:\Users\***[removed]***\AppData\Roaming\Blender Foundation\Blender\2.77\scripts\addons\babylon-js\mesh.py", line 144, in __init__
    recipe = BakingRecipe(object)
  File "C:\Users\***[removed]***\AppData\Roaming\Blender Foundation\Blender\2.77\scripts\addons\babylon-js\material.py", line 199, in __init__
    self.backFaceCulling &= material.game_settings.use_backface_culling
ERROR:  'NoneType' object has no attribute 'game_settings'
========= end of processing =========
elapsed time:  0 min, 0.01 secs

Link to comment
Share on other sites

@jSnake04 : Welcome to thew forum :)

I downloaded your .blend file and loaded it into Blender 2.76 and exported using version 5.0.5 of the exporter - and got the same results as you.

The solution lies in the error message you are getting

4 hours ago, jSnake04 said:

ERROR:  'NoneType' object has no attribute 'game_settings'

Now to get to "game settings" in Blender 2.76 I have to change the drop down box from "Blender Renderer" to "Blender Game" and once you make changes there Blender remembers even if you change it back to "Blender Render"

So - a solution in Blender Render:

1. Select the mesh  -> Texture Tab -> Delete the texture (Shift+Click on the little X next to the + sign beside the texture name)

2. With mesh still selected -> Material Tab -> Delete the material (Shift + Click the little X ......as above)

3. G to the UV image editor ->Select the image you are using -> Delete Image  (Shift + Click on little X  ... as above).

$. Now save your file and reopen it.

If the above is done correctly your figure now has no material or texture any more when reloaded..

In Blender Render mode - Now give it a new material and texture (the UVmap is still there so your original texture should work fine.)

Ohh and below is your little soldier boy with the fix above applied in the BJS Sandbox - unfortunately with no texture as you did not include it with the .blend file.

cheers, gryff :)

soldier1.png

Link to comment
Share on other sites

Hi @gryff, thanks for the help

I tried following your steps, but it seems it isn't working for me. I tried it several times. Maybe I'm doing something slightly different.

I'm of the opinion that this should probably be considered a bug (not sure if blender or the exporter is the root cause). I've always thought that a crazy monkey at the keyboard and mouse shouldn't be able to cause an exception in a application no matter what key and click combinations in the ui, but maybe that is just me. lol

Just curious, but why are there so many blank textures and one blank material in the materials tab?

In my debugging, I noticed that it was trying to output two materials, my material worked okay, but the last one was a null object...

 

Well I just realized all I had to do was delete that one material with a blank name and it started working again. I wonder how that got there in the first place? B)
I guess that answers my question. lol

Oh well, thanks again for the help guys. Got me pointed in the right direction.

 

I attached my texture if you are still curious. consider my most bestest model and texture ever created in the history of the planet, public domain.:D

I made the texture and the model comes from: http://opengameart.org/content/very-low-poly-human

soldier_uv_map_test.png

Link to comment
Share on other sites

@jSnake04 : just a recommendation jSnake - you might want to make your texture size a power of 2. So 512x512, 1024x1024 etc. Some devices don't like textures not a power of 2, I believe.

Now lets see it animated :o

And if you are planning more humanoid characters - take a look at a piece of software called MakeHuman

cheers, gryff :)

Link to comment
Share on other sites

@gryff should be 1024X1024, unless I'm missing something. Could probably pack things in better and optimize a bit, but I'm just trying to prototype at this point.

I plan on doing a walk and run animation here pretty soon.

Thanks for the MakeHuman tip, that should come in handy when I start polishing things. Looks like a pretty cool app.

I plan on creating an ambitious reusable ragdoll manager for babylon js. I want to make it work with any model and babylon physics plugin (plus some config of course).

It's coming along pretty good so far. Been working on it for a while now.
Got it working decently with a cube worm model/animation so far. Just need to try it out with a human form and simplify/reorganize the config options.

I plan on releasing it as a babylon extension or something once I get further along. I noticed there was quite a bit of talk here on the forum about ragdoll physics. Definitely not a simple thing to do, but it sure is a fun challenge. B)

I'm descending deep into the world of matrix math and quaternion rotation fourth dimension hyper-spheres. Wish me luck and if I'm not back in a few months, then wait another few months. lol. I already scoured the forums for every bit of ragdoll talk and even various robotics tutorials.

I will post a playground with the model animation and ragdoll effect once I get things working well.

Link to comment
Share on other sites

@jSnake04 : turns out how I saved the image gave me one 750x750. (I went:  Right click -> view Image -> copy image). If I just click on the image and then copy image it comes over as 1024x1024. No idea why :blink:

Looking forward to seeing your stuff.

38 minutes ago, jSnake04 said:

I'm descending deep into the world of matrix math and quaternion rotation fourth dimension hyper-spheres.

Good luck with that - a braver man than me. :o

cheers, gryff :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...