Question about Blender to Panda3D

Heya, guys. So, I have not seen anything about what I want to ask, unless I am completely and utterly blind. Here’s my situation:

So, I have been using Blender 2.65 and I have created a very simple map. I have added textures to the floors and walls, and that’s it. I have deleted all the lighting and the camera and everything. My question is: Can I convert the entire map, testmapforPanda3d.blend to an x.EGG format? I guess what I’m trying to ask is how do I import my map to Panda3D, if it is possible?

I have tried using YABEE, and I do the ‘Install from Files’ in Blender > Addon; I install the YABEE.PY file, and there is no IMPORT/EXPORT for .EGG. Any suggestions? Thanks for the help! Here’s a photo of the map if anyone’s curious about it. I know it’s not much, but I just want to get my game going!

Looking at the YABEE download page, I see that there doesn’t appear to be a version of YABEE for Blender 2.61; have you tried a version of YABEE other than whichever you’re using (I suggest one of the ones intended for a version of Blender close to 2.61), or, perhaps better, getting one of the newer versions of Blender?

That was absolutely my fault. I made a typo in my original comment; I am using Blender 2.65. I feel like such an idiot for making that typo. But I have tried downloading the YABEE 2.65 support and unfortunately it still does not work. However, before I get into my map creation, can I import a full map into Panda 3D? That’s my main question.

Ah, fair enough, and my apologies for misunderstanding the primary question.

I take it that when you say “the full map”, you mean lights, cameras, collision geometry, spawn points, etc.?

If so, then I’m honestly not sure. If I recall correctly, it should be possible to export collision geometry by setting certain tags on the relevant geometry in Blender (I believe that this is described more fully in the YABEE documentation), and things like spawn points by creating empty meshes carrying Blender tags that you then search for in your game.

As to lights and cameras, I don’t think that they are exported by YABEE, although I stand to be corrected. If I am correct, however, you could use the “empty mesh with tags” mechanism described above, although it’s less than ideal. A special mesh containing geometry used to encode lighting bounds and the like might work, however.

Finally, you might be able to extend YABEE to export elements that it doesn’t already export, I imagine.

By the way, if you’re looking for a level editor, have you looked at kurohyou’s scene editor? I don’t know how feature-complete it is at this stage, but it looks like a pretty good tool. The download page should be here.

To install this addon you should point to the whole downloaded *.zip file with YABEE instead of *.py

Awesome, you guys are a great help. I managed to get a basic level with 3D models and textures created. I have also imported it to an .egg format. So, now I’m trying to load up the level in Geany, and so far thigns aren’t working… Here’s the code:

from direct.showbase.ShowBase import ShowBase

class MyApp(ShowBase):
	
	def __init__(self):
		ShowBase.__init__(self)
		
		self.environ = self.loader.loadModel("I:/adam7540/GameCreating/Maps/Panda3D_Test")
		self.environ.reparentTo(render)
		
		self.environ.setScale(1,1,1)
		self.environ.setPos(0,0,0)
		
app = MyApp()
app.run()

The that it’s giving me is:

Could not load model file(s): I:/adam7540/GameCreating/Maps/Panda3D_Test

(It’s ‘I:’ because I am at school). Am I importing this using the wrong format? I feel like it’s right under my nose.

Have you tried loading the model using a relative path? For example, if your main python script is located at “I:/adam7540/GameCreating”, you might try loading the model by calling loader.loadModel(“Maps/Panda3D_Test”).

I note too that using a relative path should make your code more robust: if you happen to move your program to another machine, or another folder on the current machine, then as long as the model hasn’t been moved relative to your python file the load command should still work, while an absolute path would presumably break.

That said, I suspect that the problem that you’re having with your absolute path is that you’re not using Panda’s file name syntax, as described here. Try simply removing the colon after “I”, and putting another slash before it.

Okay, so I checked out that formatting page, and now my code looks like this:

import sys,os
from direct.showbase.ShowBase import ShowBase

class MyApp(ShowBase):
	
	def __init__(self):
		ShowBase.__init__(self)
		
		self.environ = self.loader.loadModel("/I/adam7540/GameCreating/Maps/Panda3D_Test.egg")
		self.environ.reparentTo(render)
		
		self.environ.setScale(1,1,1)
		self.environ.setPos(0,0,0)
		
app = MyApp()
app.run()

The same error appears. Notice how I have ‘Panda3D_Test.egg’; I have always used ‘Panda3D_Test’ with no ‘.egg’. Here is where my .egg file is located:

UPDATE

I found the solution! I feel like an idiot, too. It turns out, that I should have had a lowercase “i” instead of capital “I”. So, it appears on screen, but it is all white. I assume I have to add some sort of lighting for all the models and textures to appear?

I’m glad that you got it working. :slight_smile:

As to the colour, lighting should indeed help: I’m not sure about textures, but I do seem to recall that materials only show up when lit, at the least.

Hey I appreciate your help, by the way! It really means a lot that you’re taking your time to help a noob like me, haha. So, I’ve added a directional light in my code. The problem is, none of the textures are appearing. It’s just the blocks in the map that are appearing. Did I miss something during the .egg export? Here is another photo.

It’s my pleasure to be of help. :slight_smile:

As to your textures, does your model have UV coordinates? If so, how are you applying your texture – through the UV/Image panel, or via a texture? In the latter case the exportation should be working, but in the former you probably want to check the box labelled “UV as texture” when exporting through YABEE.

Okay, so here’s the deal. I went home, and I tried this out on a much easier level that I created. Just a few simple rectangular boxes (based prisms), that each have a texture on them. The way I added textures to all of them was this process:

Step 1: I added a cube to the 3D View, and manipulated its X,Y,Z values to create a thin rectangular based prism.
Step 2: I repeated Step 1 in order to create a platform-like level
Step 3: I downloaded all my textures and saved them to one folder
Step 4: I right-clicked one platform, tabbed into EDIT MODE, and selected Smart UV Project.
Step 5: In the UV/Texture window, I opened up a new image from my texture folder; I scaled out the UV selection to make the image fit better on the platform.
Step 6: I created a new material, and I called it whatever the image looked like. For example, Rainbow.
Step 7: I created a new texture, under the Rainbow material, and loaded the Rainbow image under it.
Step 8: I checked off under Mapping: Coordinates - UV & Map - UVMap
Step 9: I believe I did the exact same process for all platforms.
Here is a photo of the map I have:

So, I load up this code into Geany.

import sys, os
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Filename

class MyApp(ShowBase):
	
	def __init__(self):
		ShowBase.__init__(self)
		
		self.environ = self.loader.loadModel("/c/Users/AdamLaptop/Documents/BlenderMaps/MapProject/tex/cubetest.egg")
		self.environ.reparentTo(render)
		self.environ.setPos(0,0,0)
		
app = MyApp()
app.run()

And the error I receive is this:

And here is my cubetest.egg code:

<CoordinateSystem> { Z-up } 
<Material> "Brick 1" {
  <Scalar> diffr { 0.640000 }
  <Scalar> diffg { 0.640000 }
  <Scalar> diffb { 0.640000 }
  <Scalar> specr { 0.500000 }
  <Scalar> specg { 0.500000 }
  <Scalar> specb { 0.500000 }
  <Scalar> shininess { 12.5 }
  <Scalar> emitr { 0.000000 }
  <Scalar> emitg { 0.000000 }
  <Scalar> emitb { 0.000000 }
}

  <Group> Cube.004 {
    <Transform> {
      <Matrix4> {
        4.000000 0.000000 0.000000 0.000000 
        0.000000 1.000000 0.000000 0.000000 
        0.000000 0.000000 0.100000 0.000000 
        -11.766403 -8.798506 0.000000 1.000000 
      }
    }
    
    <VertexPool> Cube.004 {
    
      <Vertex> 0 {
        -7.7664031982421875 -7.798505783081055 -0.10000000149011612
        
        <UV>  {
          1.372680 0.333334
        }
        
        <UV> yabee_shadow {
          0.660837 0.338173
        }
      }
      <Vertex> 1 {
        -7.7664031982421875 -9.798505783081055 -0.10000000149011612
        
        <UV>  {
          1.378052 2.084065
        }
        
        <UV> yabee_shadow {
          0.661827 0.660837
        }
      }
      <Vertex> 2 {
        -15.766403198242188 -9.798505783081055 -0.10000000149011612
        
        <UV>  {
          -0.372680 2.089436
        }
        
        <UV> yabee_shadow {
          0.339163 0.661827
        }
      }
      <Vertex> 3 {
        -15.766401290893555 -7.7985053062438965 -0.10000000149011612
        
        <UV>  {
          -0.378051 0.338705
        }
        
        <UV> yabee_shadow {
          0.338173 0.339163
        }
      }
      <Vertex> 4 {
        -7.766401290893555 -7.798506259918213 0.10000000149011612
        
        <UV>  {
          3.134153 0.338704
        }
        
        <UV> yabee_shadow {
          0.995160 0.339163
        }
      }
      <Vertex> 5 {
        -15.766403198242188 -7.798505783081055 0.10000000149011612
        
        <UV>  {
          3.128782 2.089435
        }
        
        <UV> yabee_shadow {
          0.994170 0.661827
        }
      }
      <Vertex> 6 {
        -15.76640510559082 -9.798505783081055 0.10000000149011612
        
        <UV>  {
          1.378052 2.084064
        }
        
        <UV> yabee_shadow {
          0.671507 0.660837
        }
      }
      <Vertex> 7 {
        -7.766406059265137 -9.798506736755371 0.10000000149011612
        
        <UV>  {
          1.383422 0.333334
        }
        
        <UV> yabee_shadow {
          0.672496 0.338173
        }
      }
      <Vertex> 8 {
        -7.7664031982421875 -7.798505783081055 -0.10000000149011612
        
        <UV>  {
          3.128783 -1.422769
        }
        
        <UV> yabee_shadow {
          0.994170 0.004840
        }
      }
      <Vertex> 9 {
        -7.766401290893555 -7.798506259918213 0.10000000149011612
        
        <UV>  {
          3.134153 0.327962
        }
        
        <UV> yabee_shadow {
          0.995160 0.327503
        }
      }
      <Vertex> 10 {
        -7.766406059265137 -9.798506736755371 0.10000000149011612
        
        <UV>  {
          1.383422 0.333333
        }
        
        <UV> yabee_shadow {
          0.672496 0.328493
        }
      }
      <Vertex> 11 {
        -7.7664031982421875 -9.798505783081055 -0.10000000149011612
        
        <UV>  {
          1.378052 -1.417399
        }
        
        <UV> yabee_shadow {
          0.671507 0.005830
        }
      }
      <Vertex> 12 {
        -7.7664031982421875 -9.798505783081055 -0.10000000149011612
        
        <UV>  {
          -0.372680 0.333333
        }
        
        <UV> yabee_shadow {
          0.339163 0.328493
        }
      }
      <Vertex> 13 {
        -7.766406059265137 -9.798506736755371 0.10000000149011612
        
        <UV>  {
          -0.378051 -1.417398
        }
        
        <UV> yabee_shadow {
          0.338173 0.005830
        }
      }
      <Vertex> 14 {
        -15.76640510559082 -9.798505783081055 0.10000000149011612
        
        <UV>  {
          1.372681 -1.422769
        }
        
        <UV> yabee_shadow {
          0.660837 0.004840
        }
      }
      <Vertex> 15 {
        -15.766403198242188 -9.798505783081055 -0.10000000149011612
        
        <UV>  {
          1.378052 0.327962
        }
        
        <UV> yabee_shadow {
          0.661827 0.327504
        }
      }
      <Vertex> 16 {
        -15.766403198242188 -9.798505783081055 -0.10000000149011612
        
        <UV>  {
          -0.383422 0.333334
        }
        
        <UV> yabee_shadow {
          0.327504 0.338173
        }
      }
      <Vertex> 17 {
        -15.76640510559082 -9.798505783081055 0.10000000149011612
        
        <UV>  {
          -0.378051 2.084065
        }
        
        <UV> yabee_shadow {
          0.328493 0.660837
        }
      }
      <Vertex> 18 {
        -15.766403198242188 -7.798505783081055 0.10000000149011612
        
        <UV>  {
          -2.128782 2.089436
        }
        
        <UV> yabee_shadow {
          0.005830 0.661827
        }
      }
      <Vertex> 19 {
        -15.766401290893555 -7.7985053062438965 -0.10000000149011612
        
        <UV>  {
          -2.134153 0.338705
        }
        
        <UV> yabee_shadow {
          0.004840 0.339163
        }
      }
      <Vertex> 20 {
        -7.766401290893555 -7.798506259918213 0.10000000149011612
        
        <UV>  {
          -0.383421 -1.422769
        }
        
        <UV> yabee_shadow {
          0.327504 0.004840
        }
      }
      <Vertex> 21 {
        -7.7664031982421875 -7.798505783081055 -0.10000000149011612
        
        <UV>  {
          -0.378051 0.327962
        }
        
        <UV> yabee_shadow {
          0.328493 0.327504
        }
      }
      <Vertex> 22 {
        -15.766401290893555 -7.7985053062438965 -0.10000000149011612
        
        <UV>  {
          -2.128782 0.333334
        }
        
        <UV> yabee_shadow {
          0.005830 0.328494
        }
      }
      <Vertex> 23 {
        -15.766403198242188 -7.798505783081055 0.10000000149011612
        
        <UV>  {
          -2.134153 -1.417398
        }
        
        <UV> yabee_shadow {
          0.004840 0.005830
        }
      }}
    
    
    <Polygon> {
      <TRef> { rainbow.jpg }
      <TRef> { rainbow.jpg }
      <TRef> { GTA Floor.001 }
      <MRef> { "Brick 1" }
      <Normal> {0.000000 0.000000 -1.000000}
      <VertexRef> { 0 1 2 3 <Ref> { Cube.004 }}
    }
    <Polygon> {
      <TRef> { rainbow.jpg }
      <TRef> { rainbow.jpg }
      <TRef> { GTA Floor.001 }
      <MRef> { "Brick 1" }
      <Normal> {0.000000 0.000000 1.000000}
      <VertexRef> { 4 5 6 7 <Ref> { Cube.004 }}
    }
    <Polygon> {
      <TRef> { rainbow.jpg }
      <TRef> { rainbow.jpg }
      <TRef> { GTA Floor.001 }
      <MRef> { "Brick 1" }
      <Normal> {1.000000 -0.000000 0.000000}
      <VertexRef> { 8 9 10 11 <Ref> { Cube.004 }}
    }
    <Polygon> {
      <TRef> { rainbow.jpg }
      <TRef> { rainbow.jpg }
      <TRef> { GTA Floor.001 }
      <MRef> { "Brick 1" }
      <Normal> {-0.000000 -1.000000 -0.000000}
      <VertexRef> { 12 13 14 15 <Ref> { Cube.004 }}
    }
    <Polygon> {
      <TRef> { rainbow.jpg }
      <TRef> { rainbow.jpg }
      <TRef> { GTA Floor.001 }
      <MRef> { "Brick 1" }
      <Normal> {-1.000000 0.000000 -0.000000}
      <VertexRef> { 16 17 18 19 <Ref> { Cube.004 }}
    }
    <Polygon> {
      <TRef> { rainbow.jpg }
      <TRef> { rainbow.jpg }
      <TRef> { GTA Floor.001 }
      <MRef> { "Brick 1" }
      <Normal> {0.000000 1.000000 0.000000}
      <VertexRef> { 20 21 22 23 <Ref> { Cube.004 }}
    }
  }

This is all totally new to me, so please, if you see thousands of issues, or just one issue, be sure to be critical. Be as hard as you can on me, because I enjoy criticism as it makes me learn much better. I want to thank everyone that has been helping me, and I hope my format of using photos and code isn’t too much of a nuisance for anyone!

Hmm…

First of all, you seem to be applying your textures as I would expect.

The error indicates that Panda is having trouble finding the textures. I see a few potential issues:

  1. This is unlikely to be the issue, but it seems odd to me: why is the model in a folder named “tex”? The name seems to imply that it’s a folder intended for textures…

  2. Do you have “Copy texture files” checked when you export through YABEE, and if so, what path does it indicate? I believe that the default is “./tex”.

  3. Your egg file doesn’t seem to include texture definitions: I would expect to see somewhere in your egg file something along the lines of
    [some name] {
    “[some texture path]”
    }

Perhaps it would help if you were to post some screenshots of the settings that you have in YABEE when you export.

Don’t worry about all of the screenshots that you’ve been posting: they’re helpful, and thank you for them! :slight_smile:

It’s a bug in the previous versions of YABEE. You should update it, or You have to remove or replace the blank space with underscores in the materials and textures names.
Also, as I know - “relative path” in the .egg means that it relative to the model-path specified in the Config.prc or to your main .py file. In the latter case you also should execute python from directory which contain this .py file - for example, with the batch file or from your editor.

So, I’ve tried throwing everything in one folder. The Blender map, .py file, .egg file, textures; everything. I still get the same error. Here is a photo of my YABEE settings before I export anything:

So, I exported it, and the Pview came up with nothing but a blank, grey screen. I tried executing the new exported file, and I get the same error.

as nith said. try removing the spaces in your texture-filenames.

Or – again as ninth indicated, I believe – get a more recent version of YABEE.