Blender object exporting trouble

Hi, I’ve recently started using Panda3d/Blender in hopes of making an interactive simulation for research. So far, I’ve created a house object in blender, with multiple rooms and walls. After successfully rendering, I assumed I could export it to P3D. I downloaded YABEE 13.1, and added it to blender (v2.70). After selecting all the objects, I exported it as a .egg file, and loaded up a quick script to see how it looked in panda. However, I’m getting an error message:

This is the code used to test the maze:

from direct.showbase.ShowBase import ShowBase
class MyApp(ShowBase):
    def __init__(self):
        # Load the environment model.
        self.environ = self.loader.loadModel("models/maze")
        # Reparent the model to render.
        # Apply scale and position transforms on the model.
        self.environ.setScale(30, 30, 30)
        self.environ.setPos(-8, 42, 0)
app = MyApp()

and finally the .egg and .blend files:
.egg =
.blend =

I am very new to both programs, so hopefully this is an easy fix! Thanks

I know next to nothing about using Blender, but the egg file has some problems with names, or rather spaces in them.

The blender exporter will add quotes to object names with spaces but it looks like only for the group names, not vertex pools. Changing the names in Blender should fix the problem, I fixed the egg with some find-and-replace-fu:

Thanks wezu :mrgreen: , after changing all the object names it was able to run. However, I have another question. In my script, the walls show up as just white walls, whereas in blender I gave specific walls different colors. Would I have to add something to my code in panda or make a change on the object in blender?

How did you colour the walls in Blender, and are there any lights in your scene?

If you applied the colour via materials, then (if I recall correctly) you may find that the colours only show up when you apply a light to your scene.

If you don’t want a light in your scene, I think that vertex colours show up without lights.

(By the way, I recommend using YABEE’s option to automatically run pview in order to check your models after exportation: it can help you to find, and in some cases diagnose, issues with your model or exportation thereof. Check the documentation for pview’s various options, including toggling lighting, per-pixel lighting, and so on.)

To color the walls, I applied it via materials. Even though I have light in my scene, after pressing L in pview I was able to see some color. However, I’ve run into another problem. Depending on the angle of the camera, some walls/faces disappear while others appear. I’ve taken some screenshots of both pview and blender.

Where did the faces go?

Blender view

EDIT: After messing around with view options in pview, I found the inverse single sided faces command (i) that made it look like this:

I’m assuming I can run these commands in my code, but I haven’t figured out how to yet :stuck_out_tongue:

In short, the problem would appear to be the normals of your model.

Panda (as with most 3D engines, I imagine) uses back-face culling to remove polygons that are facing away from the camera; this makes the rendering more efficient by not attempting to draw polygons that are–in most cases, at least–not visible.

To see this effect in Blender, go to a 3D view and open the “Properties” panel (in my version of Blender there is a small icon at the top-right of the 3D view that toggles this panel, and the hotkey ‘n’ should do the same). Scroll down to the “Display” section, and check “Backface Culling”.

To deal with this, there are a few options:

  1. In Blender (and with back-face culling on), select your model and enter “Edit Mode” (toggled using “tab” in my version), then go to the “Mesh” menu, select “Normals” and “Recalculate Outside”. If that fails, try “Recalculate Inside” instead. If the model still looks wrong, then your model might have an issue somewhere.

  2. In your Panda code, enable double-sided rendering. This should disable backface culling. For a simple scene, this might not significantly impact performance.

  3. In your Panda code, reverse the direction considered to be “facing the camera”–as you discovered in PView. This shouldn’t impact performance (I don’t think), but if you get a model with standard normals you’ll probably find that it looks inside-out as a result.

I strongly recommend option (1) above, since it allows Panda to continue to use back-face culling, has your normals point in the expected direction (I honestly don’t know whether the odd normals might affect lighting later on), and keeps your models consistent, both amongst themselves and with any that might be produced by others (presuming that those others are familiar with such things themselves, of course).

I have a steep learning curve here. I just started on Blender yesterday. I have been a POV-Ray user literally since the last century. Blender I tried years ago and got immediate frustration at the lack of things doing what they were “supposed” to do. Two days ago I picked up Blender again due to the need to create Panda models. I immediately ran into the egg file issue.

I have downloaded YABEE 13.1, went through the steps of installation, and this forum was very helpful. I was able to create and export some simple models and look at them in Panda without too much trouble. Well, a lot of trouble, but I chalk it up to learning. Now, today, without making any changes, when I try to export the same model, I get ‘module’ object has no attribute ‘tbn_generator’ from Blender.

Source of frustration: Yesterday it worked. I have changed nothing. Today it does not work. Now what?

Thanks in advance.

Update: Now, when I try to export, the program produces a text file instead of an egg file. What gives? Can Panda import 3DS from Blender? I am not having much luck here. Things have gone from working sort of to not at all.


If it’s not an animated object then maybe you could try Blender->obj export->obj2egg?
The obje2egg command line program should be included with the Panda3D SDK

Well, your advice has paid off in part. I got the and it works okay mostly. The geometry does export for the buildings and structures in my little test, but with one hitch. The textures and colors are not showing up. I get a whole stack of “warning: undefined material:” errors. The result is a white structure in a gray universe with no lighting other than ambient. No colors or details. I can navigate around a white blocky thing in a gray amorphous thing. Some progress no doubt but pretty useless for practical purposes.

I see that there is a .obj file and a .mtl file, which to my dim cognition seems to be related to material. Including it in the directory does suppress the error messages which confirms it for me, I suppose. But- the ever crucial but- the world is still gray, the buildings are still white. I do get warning: ignoring: [‘s’, ‘off’] for each solid.

So it seems that the textures (and yes, I see them at the top of the conversion) are present but being ignored for some reason. I appreciate the help and would love to share a little of what I am doing, but at this point it is pretty primitive.

What, oh wise ones, is next?



Okay, I included the .blend1 file and that suppressed all error messages but I still have no colors or textures visible. The data is surely there, but what the hey. I may have somehow omitted something simple like a light source or whatever, although I did have it selected with everything else. BUT I also made sure all the source files were in the same directory and to no avail. I now have an error-free conversion that does not work. Sigh.



I may be mistaken, but I don’t think that YABEE exports lights, so it may well be a lack of lighting in your scene.

As I suggested to the poster above, if you’re using YABEE, select the “PView” option before exporting in order to get an idea of how your exported object should look in-game. Specifically, if toggling lights (“l”) toggles your colours, too, then a lack of lights in your in-game scene is likely a problem.

As to missing textures, how are you applying them in Blender? Depending on how you’re going about it, you may not be exporting correctly to get them in your output file.

In short, a general tip for using YABEE is that what Blender shows isn’t necessarily what Panda will show; again, PView can be very useful in discovering issues quickly, especially as it has various key-commands that allow for testing against various issues (such as a lack of lights).

As to your earlier problems, I honestly don’t know what was causing them, but I’m not an expert in YABEE’s functioning–unfortunately, I don’t know how often the most likely person logs on.

One thing does occur to me: have you checked that you’re using the right version of YABEE for your version of Blender? A mis-match there–such as if you updated Blender, but didn’t get a new version of YABEE, or simply downloaded the wrong version of YABEE for your version of Blender–could well cause issues, I believe. Note that, if I’m not much mistaken, the latest version of YABEE might not work with an earlier version of Blender, and you might be better served by either getting a more recent version of Blender or an older version of YABEE (I recommend the former).

Yes, thanks, I found by examining the output file that there are no lights. The textures are listed, the geometry is correct. I now get errors again, but that is another issue probably. I have the latest YABEE and Blender. I have to do some learning about Panda also, clearly. Working it out, thanks.


This may be your problem.

As I said, YABEE is somewhat attached to a given version (or perhaps range of versions; I’m not sure) of Blender–if I recall correctly, the Blender developers sometimes change things that break YABEE compatibility. Looking at the Blender site, at time of writing the latest version appears to be 2.71, while the latest version of YABEE at time of writing (13.1) is associated with Blender version 2.66.

Have you tried getting Blender 2.66 (I believe that the relevant download page can be reached via this one) and exporting from there?

Thanks, I will try that. I can’t hurt. I have been able to sort out a lot of the issues and the textures are now exporting, but I get primitive blocky shapes with no finesse at all. The lighting is totally weird as well, with the ceilings dark and the floors bright. I installed the lights in my panda script but it appears like they are somehow… really off. I don’t know, lots to figure out still.



I’ve been away from the forums, trying things out and I’ve made some good progress. I’m aiming to make a floor plan layout, and have a user (as the first person camera) walk from room to room. This is what I have for my code so far:

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
import sys

class World(DirectObject):
   def __init__(self):
    # disable default mouse controls
    # loads maze model
      self.environmentModel = loader.loadModel("models/maze")
      self.environmentModel.setPos(-2, -4, 0)
      base.setBackgroundColor(0, 0.3, 0.8)
	# enable two sided rendering
	# loads camera  
      self.cameraModel = loader.loadModel("models/camera")
      self.cameraModel.setPos(-1, -1, 1.5)
    # Create Ambient Light
      ambientLight = AmbientLight('ambientLight')
      ambientLight.setColor(VBase4(.5, .5, .5, 1))
      ambientLightNP = render.attachNewNode(ambientLight)
    # Directional light 1
      directionalLight = DirectionalLight('directionalLight')
      directionalLight.setColor(Vec4(0.1, 0.1, 0.1, 1))
      directionalLightNP = render.attachNewNode(directionalLight)
      directionalLightNP.setHpr(180, 0, 0)
    # Directional light 2
      directionalLight = DirectionalLight('directionalLight')
      directionalLight.setColor(Vec4(0.1, 0.1, 0.1, 1))
      directionalLightNP = render.attachNewNode(directionalLight)
      directionalLightNP.setHpr(0, 0, 0)
      self.keyMap = {"up" : False, "down" : False, "left" : False, "right" : False,}

      self.accept("escape", sys.exit)
      self.accept("arrow_up", self.setKey, ["up", True])
      self.accept("arrow_down", self.setKey, ["down", True])   
      self.accept("arrow_left", self.setKey, ["left", True])   
      self.accept("arrow_right", self.setKey, ["right", True])
      self.accept("arrow_up-up", self.setKey, ["up", False])
      self.accept("arrow_down-up", self.setKey, ["down", False])   
      self.accept("arrow_left-up", self.setKey, ["left", False])   
      self.accept("arrow_right-up", self.setKey, ["right", False])
      taskMgr.add(self.cameraControl, "Camera Control")
   def setKey(self, key, value):
      self.keyMap[key] = value
   def cameraControl(self, task):
      dt = globalClock.getDt()
      if(dt > .20):
         return task.cont 
		 #Assigns key input to movement
		 #up = forward
	     #down = back
		 #left = turn left
		 #right = turn right
      if(self.keyMap["up"] == True):
         self.cameraModel.setY(self.cameraModel, 7 * dt)
         return task.cont
      elif(self.keyMap["down"] == True):
         self.cameraModel.setY(self.cameraModel, -7 * dt)
         return task.cont
      elif(self.keyMap["left"] == True):
         self.cameraModel.setH(self.cameraModel, 50 * dt)
         return task.cont
      elif(self.keyMap["right"] == True):
         self.cameraModel.setH(self.cameraModel, -50 * dt)
         return task.cont
         return task.cont
w = World()

However, I have some things that I want to improve:

  • I want to make the corners of the rooms more visible, as it can be hard to distinguish walls at times.
  • I want to add collision detection, to not allow the camera to pass through.

This is the .egg of the “maze”

I’m glad that you two are making progress. :slight_smile:

@MGxD: Those sound like reasonable goals; post if you find yourself stuck! :slight_smile:

Hmm… Do you have the faces set to “shade smooth” in Blender?

(In Blender, if your version functions as mine does, select your object, then enter “Edit Mode” (toggled by pressing “tab”), then open the “Mesh” menu, select the “Faces” sub-menu, and select “Shade Smooth”.)

That reads to me like an issue with the normals, similar to what I described in one of my posts above–although, if it is an issue in your normals, I’m not sure of why it’s not causing you back-face culling issues, as I recall that MGxD was having. (There are potential explanations–including my being incorrect about it being an issue with the normals–but without more information it’s difficult to guess at one.)

So, here is what I have. I had obj2egg recalculate the normals and that was a major improvement. Not entirely correct but far, far better than before. Next, I tried just in Blender to go to smooth shading of things, but it worked with mixed results. Objects look fine but rooms get weird darkened areas. If I go with flat for the rooms and smooth for the objects in the rooms, everything is peachy. I don’t know enough to say why but I have some suspicions gnawing and will figure that out.

Anyway it has done me a great deal of good to read some of the posts here so thank you and I will continue on the path. Writing a game in jig time with no experience in Blender or Panda but so far, I do have some working things. Not bad for a cold start two days ago. Now creating the game logic and working out my interface.



If your rooms are composed of large polygons, with no additional polygons to edge the corners, and especially if you’re using the default, non-per-pixel lighting, then that’s likely a result of the room polygon normals being smoothed at the corners–having directions somewhere between those of their connected faces, more or less–and the way that the default lighting system lights polygons.

I’m hesitant to give suggestions at this point, both because I don’t know your goals and requirements for your rooms and because there are elements of 3D modelling that I think that it might help you to learn first.

In short, when not using per-pixel lighting (and if I recall all of this correctly), a triangle is lit by taking the light values of each vertex, calculated based on distance to light source (if applicable to the type of light) and direction of normal, and then interpolating those for points within the triangle.

If you’re using a directional light (hence making distance to light source irrelevant), and using flat-shaded rooms (making the normals of each vertex of a given polygon the same, and oriented orthogonal to the polygon, then the lighting probably will look more or less right–as long as you have no curves to give away the flat shading.

It might be a good idea to look for a decent tutorial covering the basics of 3D modelling for games at this point; I don’t know of one offhand, but there might be links somewhere on the forum, or recommended elsewhere.

You are probably absolutely correct. I am intimately familiar with coding for complex geometry and back in 1988 wrote an engine for creating wire-frame walk-through models from any perspective, so it isn’t for lack of the math. I believe that the normals are really the problem. At least that makes the most sense. I will reformulate one of the rooms for smoother edges and see how that works.

One other thing just turned up. I create an image map to wrap on one of my models. It works great in Blender, it exports to the egg file, and the Panda script complains if it is not in the directory, so I know that it knows it needs it. But it does not show up at all on the model. Oh well. I’ll work it out.

Wow, I’ve been doing the geometric stuff (plus other things) since the PDP-11 days… scary, isn’t it?