model import problem!

Hello there!
First of all: I love Panda3D!
But I have following problem: I create a simple mesh (cube) in 3ds or Blender, give it a color or texture, then I export the file to an egg file (in 3ds) or to an X file. When I say Panda to load the model, it does, but the cube always is white and has no texture. Furthermore the cube doesn’t look like a 3D model. I tried this more than once and with differet meshes. I also tried to export an more komplex model (that found by googling), but the result was the same. I hope you can help me!! :frowning: If you want me to show some screenshots I’ll do…

Very often, these untextured-models are untextured because the egg contains an incorrect pathname for the texture file. Take a look at the first few lines of the egg file and see where it says the texture is. If it’s a relative path, it’s supposed to be relative to the egg file. If the path is wrong, fix it, and then see if it works.

Thank you Josh for the quick answer!
I did what you told me to do. I looked at my egg file and I didn’t see any Texture declaration although I gave my cube a texture in Blender. In my egg file there is nothing about textures!.. Maybe the egg file exporter for Blender doesn’t support textures??? I read in this forum that it’s still in development. If anyone knows how to use Blender for exporting egg file models, please help me!

Hello,

first I want to say that I’m new to Panda3D and Python.
But I’m enjoying learning more about it day after day.
I like Panda3D and I’m confident that I like it even
more once I learned how to use it. :slight_smile:

But since there is no offline manual it’s hard to find
out what methods a class provides and how they behave
and how they must work together and what dependecies
there are between several classes and all this.
The tutorials are helpfull but can’t answer all questions.
(So does the online manual.)

But that’s not the point of this posting.

At the moment I have the same problem as ilikePanda3D.
I created a simple mesh with blender. A plane about
100x100 units with some height differences. Just the
mesh without material or texture.
Then I exported it as “.egg”. I exported it also as “.x”,
“.lwo” and “.wrl” but it’s the same problem with all
file formats.

My Python code looks like this:


import direct.directbase.DirectStart
from direct.showbase import DirectObject
from pandac.PandaModules import *
from direct.interval.IntervalGlobal import *
from direct.gui.DirectGui import *

class World(DirectObject):
  def __init__(self):
    self.floorTex = loader.loadTexture("models/gras.jpg")

    self.floor = loader.loadModelCopy("models/ebene.egg")
    self.floor.setTexture(self.floorTex, 1)
    self.floor.reparentTo(render)
  #end __init__
# end class World

w = World()
run()

Without a texture my model is completly white. No problem
so far. (Except that there are no shades.)
After I inserted the loadTexture()/setTexture() in my
code the model is not white anymore but has a certain solid
color. (But it’s not textured.)
And it seems the model is displayed without shading. The
same color all over the model.

The color however is influenced by the texture image. I
played around with the texture image and it looks like
Panda3D calculates an average color from all pixels color
of the texture image and assigns the resulting color to my
model.

Where’s my mistake?
Can anyone explain that behavior?

Hopefull regards
Jadawin

Hello Guys,

I experienced such things when my textures were not a 2^n size in both direction.

In this case , the best is to use the cardmaker tools , it will generate an egg wih proper texture on it .

Hello Manakel,

thanks for the hint but it doesn’t solve the problem. I changed my
texture image to a 64x64 size. With no visible effect to the scene.

I will have a look at the cardmaker tools anyway.

It sounds like your model does not have texture coordinates on it. The texture coordinates tell the graphics engine how the texture should be mapped to the vertices; without them, the behavior is undefined when you apply the texture, but it usually ends up applying a single random color from the texture to all vertices.

There should be an option in blender to generate texture coordinates (though I’m not familiar with blender myself).

David

1 Like

Thank you David.
I’ll have a closer look at my blender settings.

Sorry, that posting right before this one was also from me.

I think I’m going to register myself for the Panda3D forum one of these days.
So I don’t have to run around as Guest. :smiley:

I got it. :smiley:
And just for the record:
I used blenders UV editor to texture my model instead of the material editor. And it works.

Hi Jadawin!
It seems that you’ve solved the problem with the textures in blender. Do you mean the ‘UV Face select’ mode? can you tell me how you did it?

Hello ilikePanda3d,

I can try. I had to look it up in the blender manual myself.
But here’s what I did:

  • empty the blender scene (no camera, no light, nothing)
  • create a plane
  • scale it up to about 1000x1000
  • subdivide it until it had many nice little faces
  • selected some verticles and translated them along the z-axis to
    generate some height differences on the plane

(now comes the texturing)

  • take a 3D window and change it’s mode to “UV Face Select”
    (all faces are automaticly selected)
  • take another window and make it a “UV/Image Editor”
  • now load the texture image ([Image] -> [Open …])

It will be assigned to all selected faces. You can select single faces in the
3D window and assign another texture to them by loading a second image.
You can see the textured model by switching the viewport shading mode
of the 3D window to “textured”.

Then I exported the model into an egg.
It’s important that all used texture images are present in the exact path
that is written in the egg file (relative to the egg file) when you load it
with Panda3D.

I haven’t tried more complex models yet but it should be the same
procedure.
According to the manual, using the UV editor is the only way to equip a
blender model with UV coordinates as needed for Panda3D.

Hope this helped. :slight_smile:

One more thing …

Like Manakel mentioned above maybe your texture images have to have
a 2^n size (like 64x64 or 256x256).
I believe this depends on the graphic card you are using. Some cards only
support 2^n sized textures. And some cards support only textures sizes up
to 256x256.
(If I’m wrong there please anyone correct me!)