model import problem!

Return to Scripting Issues

model import problem!

Postby ilikePanda3D » Sat Jul 16, 2005 9:07 am

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!! :( If you want me to show some screenshots I'll do....
ilikePanda3D
 

xyz

Postby Josh Yelon » Sat Jul 16, 2005 9:42 am

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.
Josh Yelon, Teacher, Carnegie Mellon Entertainment Technology Center
Josh Yelon
 
Posts: 1360
Joined: Wed Mar 30, 2005 8:30 pm

Postby ilikePanda3D » Sun Jul 17, 2005 5:00 pm

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!
ilikePanda3D
 

texturing a blender model

Postby Jadawin » Sun Jul 24, 2005 6:36 am

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. :)

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:

Code: Select all
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
Jadawin
 

Postby Manakel » Sun Jul 24, 2005 7:24 am

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 .
Bold words are keyword to help you decide quickly if this post interest you or not....
(you should be able to understand the post by reading only bold words :-))
User avatar
Manakel
 
Posts: 318
Joined: Fri Jan 21, 2005 2:25 pm
Location: France

Postby Jadawin » Sun Jul 24, 2005 11:41 am

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.
Jadawin
 

Postby drwr » Sun Jul 24, 2005 12:32 pm

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
drwr
 
Posts: 11286
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby Guest » Sun Jul 24, 2005 1:05 pm

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

Postby Jadawin » Sun Jul 24, 2005 1:10 pm

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. :D
Jadawin
 

Postby Jadawin » Mon Jul 25, 2005 2:51 am

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

Postby ilikePanda3d » Wed Jul 27, 2005 4:08 pm

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?
ilikePanda3d
 

Postby Jadawin » Thu Jul 28, 2005 6:02 am

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. :)
Jadawin
 

Postby Jadawin » Thu Jul 28, 2005 6:11 am

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!)
Jadawin
 


Return to Scripting Issues

Who is online

Users browsing this forum: No registered users and 1 guest